No. With (3;e)$.y I can change the sparse element of an already existing .y.
My problem was that my y could not come into existence unless it already had
the right sparse element.   -Michael

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Fraser Jackson
Sent: Saturday, December 16, 2006 6:06 PM
To: Programming forum
Subject: Re: [Jprogramming] Is there a way I can let J
knowwhatthesparseelement ought to be for the result of a booleancomparison?

I may be misunderstanding the question, but doesn't changing the 'sparse' 
element using (3;e)$.y as in the documentation for $. do what you want?

----- Original Message ----- 
From: "Michael Berry" <[EMAIL PROTECTED]>
To: "'Programming forum'" <[email protected]>
Sent: Sunday, December 17, 2006 11:55 AM
Subject: RE: [Jprogramming] Is there a way I can let J know 
whatthesparseelement ought to be for the result of a boolean comparison?


> Perhaps I wasn't clear.  I know I can change the sparse element of an
> existing, named array by adding a constant. The array whose sparse element

> I
> want to change is the unnamed result of a comparison of two integer 
> arrays,
> one of which is sparse.  Adding 1 (or any constant) to the sparse array 
> that
> is one argument to the comparison would certainly change its sparse 
> element,
> but that doesn't address my problem.
>
> Fortunately, I am becoming reconciled to the idea of always doing
> comparisons whose results are mostly 0.
>
> -Michael
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Richard Donovan
> Sent: Saturday, December 16, 2006 4:58 PM
> To: [email protected]
> Subject: RE: [Jprogramming] Is there a way I can let J know what
> thesparseelement ought to be for the result of a boolean comparison?
>
> I guess you could subtract 1 from the array elements pre-
> processing, then add it back after?
>
> As a side issue, I did some time/space comparison on the
> difference between dyad take {.     and dyad copy #
> and was somewhat surprised that take-with-fill is much
> faster and leaner than copy!
>
> Could someone tell me why please?
>
>   ts 'a=:1e7{.1'
> 0.023078631502 16778048
>   ts 'b=:1, 9999999#0'
> 0.0744748285047 33555328
>   a-:b
> 1
>
> Thanks in advance
>
>
>
>>From: "Michael Berry" <[EMAIL PROTECTED]>
>>Reply-To: Programming forum <[email protected]>
>>To: "'Programming forum'" <[email protected]>
>>Subject: [Jprogramming] Is there a way I can let J know what the
>>sparseelement ought to be for the result of a boolean comparison?
>>Date: Sat, 16 Dec 2006 16:40:20 -0500
>>
>>Dear J experts,
>>
>>
>>
>>In the course of trying to figure out why I sometimes get "out of memory"
>>errors when I didn't think I had done anything to cause my sparse arrays 
>>to
>>become dense, I became curious about how J knows what the right sparse
>>element will be for the result of a Boolean function where one argument is
>>a
>>sparse integer array.  By experiment, I see that if I compare my sparse
>>array to a scalar argument, the resulting Boolean array has the 
>>appropriate
>>sparse element, namely the result of comparing the integer array's sparse
>>element with the scalar argument:
>>
>>
>>
>>    v1 =.$.100{.3
>>
>>    v2=.$._100{.3
>>
>>    b1=.v1<3
>>
>>    b2=.v2<3
>>
>>    b1
>>
>>0 | 0
>>
>>    b2
>>
>>99 | 0
>>
>>    b3=.v1>0
>>
>>    b4=.v2>0
>>
>>    b3
>>
>>0 | 1
>>
>>    b4
>>
>>99 | 1
>>
>>
>>
>>If, on the other hand, I have an array argument, the sparse element of the
>>resulting array is always 0:
>>
>>
>>
>>    v5=. ?. 100$10
>>
>>    b1 =. v1>v5
>>
>>    b2 =. v1<v5
>>
>>    3 $. b1
>>
>>0
>>
>>    3 $. b2
>>
>>0
>>
>>    +/b1
>>
>>0
>>
>>    +/b2
>>
>>94
>>
>>
>>
>>This explains my out of memory problem.  b2 is mostly 1, but its sparse
>>element is 0. It is in the nature of the comparisons I am doing, that I
>>expect my results to be either mostly 1 or mostly 0 and I know in advance
>>which. I can, of course, rephrase my comparisons so that the "mostly" case
>>is always 0, but this sometimes seems unnatural. I don't suppose there is 
>>a
>>way I could whisper in J's ear to say I'm expecting mostly 1?
>>
>>
>>
>>-Michael
>>
>>
>>
>>
>>
>>===============
>>
>>Michael J. A. Berry
>>
>>Data Miners, Inc.
>>
>>+1 617 742 4252
>>
>>
>>
>>----------------------------------------------------------------------
>>For information about J forums see http://www.jsoftware.com/forums.htm
>
> _________________________________________________________________
> Be the first to hear what's new at MSN - sign up to our free newsletters!
> http://www.msn.co.uk/newsletters
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm 

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to