Re: [Jprogramming] Agenda on different versions ...

2023-12-27 Thread Martin Kreuzer

That sort of summarizes my question quite well ...
Thanks.
-Martin

At 2023-12-27 02:01, you wrote:


Uh... but before I can sensibly update the wiki I need to understand
what I am talking about.

  0:`1:`2:@.(3&|) i. 6
0 1 2 0 1 2
  0:`1:`2:@.(3&|) i. 7
|rank error, executing monad (0:`1:`2:)@.(3&|)
|each gerund must return a result whose shape agrees with its inputs
|   0:`1:`2:@.(3&|)i.7

In both examples, the rank of the result of each gerund is 0, and the
rank of the inputs to each of the corresponding verbs is 1.

Why did the i.6 example work and the i.7 example fail?

Thanks,

--
Raul



On Tue, Dec 26, 2023 at 6:39 PM Henry Rich  wrote:

> The result of v contains verb numbers for the cells of x/y.  It also
> indicates the rank of those cells: the verbs execute on (-rv)-cells,
> where rv is the rank of the result of v.

> The text seems to me to describe the operation correctly, but as always
> you can change it if it is unclear.  Your description of the operation
> is correct.

> Henry Rich

> On 12/26/2023 6:14 PM, Raul Miller wrote:
> > I should add that the nuvoc has some examples of implied rank, but I
> > can't figure out why a list of 10 numbers from an infinite ranked v
> > means rank 0 while a list of five numbers from infinite ranked v means
> > rank 1. I suspect what it's intended to mean is that the implied rank
> > is _1 and "_1 on a rank 1 list acts at rank 0 and "_1 on a rank 2 list
> > acts at rank 1. But that doesn't match the text of the description.
> >

> --
> 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


[Jprogramming] Agenda on different versions ...

2023-12-26 Thread Martin Kreuzer

Dear all -

This left me puzzled today; have I missed some developments ?
(all in Console on Windows10)

-  v8.07 -

   (0:`1: @. (2&|)) i.1
|rank error
|   (0:`1:@.(2&|))i.1

-  v9.0.1 -

   (0:`1: @. (2&|)) i.1
|rank error
|   (0:`1:@.(2&|))i.1

-  v9.0.2 -

   (0:`1: @. (2&|)) i.4
0 1 0 1
   (0:`1: @. (2&|)) i.5
|rank error
|   (0:`1:@.(2&|))i.5

-  v9.5.1 -

   (0:`1: @. (2&|)) i.4
0 1 0 1
   (0:`1: @. (2&|)) i.5
|rank error, executing monad (0:`1:)@.(2&|)
|each gerund must return a result whose shape agrees with its inputs
|   (0:`1:@.(2&|))i.5

What did happen between v9.0.1 andv 9.0.2 ?

-Martin

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


Re: [Jprogramming] Roger's Essay 'Continued Fractions' ...

2023-12-23 Thread Martin Kreuzer

Hi Devon -

Thanks for your help -- much appreciated.

I had a hunch when I saw this expression (%:n**:a).

But as part of it (n**:a) turned up as well in the calculation for (r')
I tackled the compound fraction using pen and paper
to make shure that formula was correct.

Then I changed the line for (f).

-Martin



At 2023-12-22 20:46, you wrote:

I tested the revised code and it works properly 
for the examples, returning *_4

1 11;3 12* for *qcf 10 _1 _3 2* whereas the older version gives the same
result (*0;12 3*) for both *qcf 10 _1 _3 2* and *qcf 10 1 _3 2*.
I edited the body of *qcf* to remove the commented out line that Martin
revised since his change looks correct.

On Fri, Dec 22, 2023 at 2:42 PM Martin Kreuzer  wrote:

> Hi all -

> (This wasn't an easy one for me, as I still very much miss him.)

> I have been into CF for some time and re-read the essay this morning.

> It looks as there was a small glitch (maybe typo) in the body of function
> *qcf.

> May I ask you (having much more experience than me) to have a look at
> my edits as I do by no means want to spoil something.

> Many thanks.

> -Martin

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



--

Devon McCormick, CFA

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


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


[Jprogramming] Roger's Essay 'Continued Fractions' ...

2023-12-22 Thread Martin Kreuzer

Hi all -

(This wasn't an easy one for me, as I still very much miss him.)

I have been into CF for some time and re-read the essay this morning.

It looks as there was a small glitch (maybe typo) in the body of function *qcf.

May I ask you (having much more experience than me) to have a look at 
my edits as I do by no means want to spoil something.


Many thanks.

-Martin

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


Re: [Jprogramming] how to apply the same adverb repeatedly ?

2023-12-22 Thread Martin Kreuzer

@Raul | @Pepe -

Sorry for the delay.
I was ill for quite some time (slowly recovering).
Thanks for your detailed answers.

With season's greetings
-Martin

At 2023-06-13 21:11, you wrote:


Exactly: "(extra parentheses and spaces for clarity)"

On Tue, Jun 13, 2023 at 2:27 PM Raul Miller  wrote:

> [I thought I had sent this yesterday, but today I find it in draft status]

> Note that you can eliminate some of the parenthesis here, and some of
> the quotation marks (though this does place a burden on the reader's
> understanding of j syntax):

>({{y`:6 nc`''}} ^: 9 +:`'') (`:6) 7
> 23

> or

> ({{y`:6 nc`''}} ^: 9 +:`'') `:6 ]7
> 23

> The final parentheses are essential (to force early verb evaluation).


> --
> Raul

> On Mon, Jun 12, 2023 at 7:01 PM Jose Mario Quintana
>  wrote:
> >
> >(3 : '((y`:6) nc)`' ^: 9 +: (`'')) (`:6) 7
> > 23
> >
> >
> >
> > On Mon, Jun 12, 2023 at 6:57 PM Jose Mario Quintana <
> > jose.mario.quint...@gmail.com> wrote:
> >
> > > Concisely,
> > >
> > >ncver=. 3 : '((y`:6) nc)`'
> > >(ncver ^: 9 +: (`'')) (`:6) 7
> > > 23
> > >
> > >
> > >
> > >
> > > On Mon, Jun 12, 2023 at 6:46 PM Jose Mario Quintana <
> > > jose.mario.quint...@gmail.com> wrote:
> > >
> > >> An alternative way is verbing, so to speak, the (nc) adverb taking and
> > >> producing instead the gerunds corresponding to the verbs, powering the
> > >> verbed adverb (ncver) and converting the resulting gerund back to the
> > >> desired verb (extra parentheses and spaces for clarity),
> > >>
> > >> ncver=. 3 : 0
> > >>   u=. (y`:6)
> > >>   v=. u nc
> > >>   v (`'')
> > >> )
> > >>
> > >>(ncver ^: 2 +: (`'')) (`:6) 7
> > >> 16
> > >>(ncver ^: 9 +: (`'')) (`:6) 7
> > >> 23
> > >>
> > >> PS.  The previous generation of interpreters allowed one (illegally,
> of
> > >> course) to operate directly on the entities without having to go back
> > >> and forth.  For example, one can just write,
> > >>
> > >>+: ((Ver 'nc')^:9 adv) 7
> > >> 23
> > >>
> > >> using the suitable utilities (Ver) for verbing and (adv) for
> adverbing.
> > >>
> > >>
> > >>
> > >> On Mon, Jun 12, 2023 at 6:12 AM Martin Kreuzer 
> > >> wrote:
> > >>
> > >>> Dear all -
> > >>>
> > >>> Having used Fixed Power (u^:n y) before, I noticed that it works on
> > >>> the verb-adverb compound to its left.
> > >>>
> > >>> Let's have a simple, silly example:
> > >>>
> > >>> nc=. 1 : '[: >: u' NB. defining an adverb 'increase'
> > >>>
> > >>> +: i. nc 7 NB. which works fine
> > >>> 2 4 6 8 10 12 14
> > >>>
> > >>> Using Fixed Power like
> > >>>
> > >>> +: nc ^:1 (7)
> > >>> 15
> > >>> +: nc ^:2 (7)
> > >>> 31
> > >>>
> > >>> I do get the expected results (compound is executed once, twice).
> > >>>
> > >>> Here we have a verb, followed by two adverbs (if I understand
> correctly).
> > >>>
> > >>> What I have initially been looking for however, is how to apply the
> > >>> *same* adverb repeatedly, like
> > >>>
> > >>> +: nc nc (7)
> > >>> 16
> > >>>
> > >>> while having the adverb part "nc nc" somehow abbreviated.
> > >>>
> > >>> What would be a (or the) way to phrase that ?
> > >>>
> > >>> Thanks.
> > >>> -M
> > >>>
> > >>>
> --
> > >>> 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


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


[Jprogramming] how to apply the same adverb repeatedly ?

2023-06-12 Thread Martin Kreuzer

Dear all -

Having used Fixed Power (u^:n y) before, I noticed that it works on 
the verb-adverb compound to its left.


Let's have a simple, silly example:

   nc=. 1 : '[: >: u' NB. defining an adverb 'increase'

   +: i. nc 7 NB. which works fine
2 4 6 8 10 12 14

Using Fixed Power like

   +: nc ^:1 (7)
15
   +: nc ^:2 (7)
31

I do get the expected results (compound is executed once, twice).

Here we have a verb, followed by two adverbs (if I understand correctly).

What I have initially been looking for however, is how to apply the 
*same* adverb repeatedly, like


   +: nc nc (7)
16

while having the adverb part "nc nc" somehow abbreviated.

What would be a (or the) way to phrase that ?

Thanks.
-M

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


Re: [Jprogramming] Problem with capped fork ?

2023-05-25 Thread Martin Kreuzer

In addition, I don't understand why

   f=: (1:)`(* [: $: <:) @. *

shouldn't suffice, compared to

   f=: (1:)`(] * [: $: <:) @. *

as

   (* [: $: <:) y

looks to me like a regular hook.

-M


At 2023-05-25 18:33, you wrote:


This is odd.

According to https://code.jsoftware.com/wiki/Vocabulary/atdot f should
have rank 0 (since v is * here).

But, when I redefine f as
   f=: 1:`(] * [: $:&([echo) <:)@.*

I see that when (f 2 3 5 7 11) is executed, f is being treated as some
other rank. This does not occur for (f 2 3 5 7).

Using $:@<: works around this issue by using $: with the rank of <:
(the rank problem with @. would still occur, without triggering a rank
error).

Also, the j implementation tells me that f has infinite rank - despite
what nuvoc says and despite the behavior for (f 2 3 5 7):

   f b.0
_ _ _

--
Raul

On Thu, May 25, 2023 at 11:12 AM Martin Kreuzer  wrote:

> Dear all -

> Thought I had succeeded in deducing step by 
step the tacit verb for factorial,


> f=: 1:`(] * [: $: <:)@.*

> when I encountered this:

> f=. 1:`(] * [: $: <:)@.*
> f 2 3 5 7
> 2 6 120 5040
> f 2 3 5 7 11
> |rank error in f, executing monad $:
> |   f 2 3 5 7 11

> In contrast this seems to work alright:

> g=. 1:`(] * $: @ <:)@.* NB. dictionary entry
> g 2 3 5 7
> 2 6 120 5040
> g 2 3 5 7 11
> 2 6 120 5040 39916800

> JVERSION
> Engine: j9.4.2/j64avx2/windows
> Build: commercial/2023-04-10T01:19:53/clang-15-0-7/SLEEF=1
> Library: 9.4.21
> Platform: Win 64
> Installer: j9.4 install
> InstallPath: d:/program files (non-sys)/j9.4
> Contact: www.jsoftware.com

> However, my verb

> f=: 1:`(] * [: $: <:)@.*
> f 2 3 5 7 11 13
> 2 6 120 5040 39916800 6227020800

> works under v8.07 as expected 

> Could somebody shed some light on this ?

> -M

> --
> 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


[Jprogramming] Problem with capped fork ?

2023-05-25 Thread Martin Kreuzer

Dear all -

Thought I had succeeded in deducing step by step the tacit verb for factorial,

   f=: 1:`(] * [: $: <:)@.*

when I encountered this:

   f=. 1:`(] * [: $: <:)@.*
   f 2 3 5 7
2 6 120 5040
   f 2 3 5 7 11
|rank error in f, executing monad $:
|   f 2 3 5 7 11

In contrast this seems to work alright:

   g=. 1:`(] * $: @ <:)@.* NB. dictionary entry
   g 2 3 5 7
2 6 120 5040
   g 2 3 5 7 11
2 6 120 5040 39916800

   JVERSION
Engine: j9.4.2/j64avx2/windows
Build: commercial/2023-04-10T01:19:53/clang-15-0-7/SLEEF=1
Library: 9.4.21
Platform: Win 64
Installer: j9.4 install
InstallPath: d:/program files (non-sys)/j9.4
Contact: www.jsoftware.com

However, my verb

   f=: 1:`(] * [: $: <:)@.*
   f 2 3 5 7 11 13
2 6 120 5040 39916800 6227020800

works under v8.07 as expected 

Could somebody shed some light on this ?

-M

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


Re: [Jprogramming] startup.ijs under Linux ...

2023-04-05 Thread Martin Kreuzer

Chris, Bill ...

There was one 2!:5 call found still referring to 
a Windows environment variable, which I hadn't 
converted, and that was where the startup script derailed.


Many thanks. You sort of saved my holiday weekend.

-M

At 2023-04-06 03:28, you wrote:


Or you can try
   0!:1 <'/home/math/j9.4-user/config/startup.ijs'

to see what's going wrong.

On Thu, 6 Apr 2023 at 3:13 AM chris burke  wrote:

> What do you get when loading that script? Try

>loadd '/home/math/j9.4-user/config/startup.ijs'

> On Wed, Apr 5, 2023 at 10:45 AM Martin Kreuzer 
> wrote:
> >
> > Dear all -
> >
> > My Linux machine broke down.
> >
> > New J setup (v9.4.1) on different hardware seems to work, except that
> > my startup.ijs isn't recognised:
> > "An error occurred when loading startup script:
> > /home/math/j9.4-user/config/startup.ijs"
> >
> > It's the same file I use under Windows without any problem.
> >
> > These are the current file permissions:
> > -rwxr-xr-x 1 math math 881193 Apr  2 11:57 startup.ijs
> >
> > What am I doing wrong?
> >
> > Thanks.
> >
> > -M
> >
> > --
> > 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


[Jprogramming] startup.ijs under Linux ...

2023-04-05 Thread Martin Kreuzer

Dear all -

My Linux machine broke down.

New J setup (v9.4.1) on different hardware seems to work, except that 
my startup.ijs isn't recognised:
   "An error occurred when loading startup script: 
/home/math/j9.4-user/config/startup.ijs"


It's the same file I use under Windows without any problem.

These are the current file permissions:
   -rwxr-xr-x 1 math math 881193 Apr  2 11:57 startup.ijs

What am I doing wrong?

Thanks.

-M

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


Re: [Jprogramming] J Console background

2023-03-25 Thread Martin Kreuzer

Have you tried Windows Terminal (WT) yet?
e.g. 
https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us=us

It's more customisable than regular cmd (and plain jcon).
I'm using version 1.16.10261.0 on a W10 machine, to run different 
version of Jconsole (and PowerShell, WSL Debian etc).

-M

At 2023-03-25 00:29, you wrote:


Hi Everyone
I'm a very new user of J Language. The development environment seems
terrific et i 've heard nothing but good things about its users :)
To begin with, is it possible to change the background color of the
console? I've tried that for a while but i didn't find a way to do it
Thanks
--
For information about J forums see http://www.jsoftware.com/forums.htm


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


Re: [Jprogramming] EVM

2022-12-04 Thread Martin Kreuzer

Thanks, -M

At 2022-12-04 17:23, you wrote:


IIRC  u refers to verb or noun while m refers to noun only.

On Sun, 4 Dec 2022 at 11:30 PM Martin Kreuzer  wrote:

> Sorry Bill, gotten distracted, didn't noticed you already answered.
> btw, what's the difference between m and u in this case?
> -M

> At 2022-12-04 15:11, you wrote:

> >First of all because of change in syntax,  you have to change the line
> >setup x
> >to
> >setup m
> >
> >and then it works like this
> >'*: 4' EVM
> >16
> >hist ''
> >
> >  Queue Stack   Rule
> >
> >  +-+   +--++---+   +-+
> >  |mark *: 4|   |  ||   |   | |
> >  +-+   +--++---+   +-+
> >  |mark *:  |   | 4||   |   | |
> >  +-+   +--++---+   +-+
> >  |mark |   | *:   | 4  |   |   | |
> >  +-+   +--++---+   +-+
> >  | |   | mark | *: | 4 |   |monad|
> >  +-+   +--++---+   +-+
> >  | |   | mark | 16 |   |   | |
> >  +-+   +--++---+   +-+
> >
> >
> >On Sat, Dec 3, 2022 at 8:14 PM Richard Donovan 
> >wrote:
> >
> > > I was reading on the J website of the useful sounding adverb EVM so I
> went
> > > to the link at Help / Learning / Ap 1: Evaluating Expressions - J Wiki
> (
> > > jsoftware.com)<
> > >
> https://code.jsoftware.com/wiki/Help/Learning/Ap_1:_Evaluating_Expressions
> >
> > > and downloaded it.
> >
> > > So far I cannot get it to work at all using the examples given, I get
> > > syntax error in every case! EG
> >
> > > From the wiki page...
> > > *: 4
> > > '*: 4' EVM
> > > 16
> > > 16
> >
> > > Me:
> >
> > > *: 4'*: 4' EVM
> > > |syntax error
> > > | *: 4'*: 4'EVM
> >
> > > Have I catastrophically misunderstood this, or missed something
> obvious??
> >
> > > Thanks
> > > --
> > > 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


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


Re: [Jprogramming] EVM

2022-12-04 Thread Martin Kreuzer

Sorry Bill, gotten distracted, didn't noticed you already answered.
btw, what's the difference between m and u in this case?
-M

At 2022-12-04 15:11, you wrote:


First of all because of change in syntax,  you have to change the line
setup x
to
setup m

and then it works like this
   '*: 4' EVM
16
   hist ''

 Queue Stack   Rule

 +-+   +--++---+   +-+
 |mark *: 4|   |  ||   |   | |
 +-+   +--++---+   +-+
 |mark *:  |   | 4||   |   | |
 +-+   +--++---+   +-+
 |mark |   | *:   | 4  |   |   | |
 +-+   +--++---+   +-+
 | |   | mark | *: | 4 |   |monad|
 +-+   +--++---+   +-+
 | |   | mark | 16 |   |   | |
 +-+   +--++---+   +-+


On Sat, Dec 3, 2022 at 8:14 PM Richard Donovan 
wrote:

> I was reading on the J website of the useful sounding adverb EVM so I went
> to the link at Help / Learning / Ap 1: Evaluating Expressions - J Wiki (
> jsoftware.com)<
> https://code.jsoftware.com/wiki/Help/Learning/Ap_1:_Evaluating_Expressions>
> and downloaded it.

> So far I cannot get it to work at all using the examples given, I get
> syntax error in every case! EG

> From the wiki page...
> *: 4
> '*: 4' EVM
> 16
> 16

> Me:

> *: 4'*: 4' EVM
> |syntax error
> | *: 4'*: 4'EVM

> Have I catastrophically misunderstood this, or missed something obvious??

> Thanks
> --
> 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


Re: [Jprogramming] EVM

2022-12-04 Thread Martin Kreuzer

In script ''91a.ijs", line 23,

after replacing (setup x) with (setup u)

j903/j64avx2/windows/release-b/commercial/www.jsoftware.com/2022-01-28T04:09:50/clang-13-0-0/SLEEF=1

works like this:

   '2*3' EVM
6
   hist''

 Queue  Stack  Rule

 +--+   +--+   ++
 ¦mark 2 * 3¦   ¦  ¦   ¦   ¦   ¦   ¦¦
 +--¦   +--+---+---+---¦   +¦
 ¦mark 2 *  ¦   ¦ 3¦   ¦   ¦   ¦   ¦¦
 +--¦   +--+---+---+---¦   +¦
 ¦mark 2¦   ¦ *¦ 3 ¦   ¦   ¦   ¦¦
 +--¦   +--+---+---+---¦   +¦
 ¦mark  ¦   ¦ 2¦ * ¦ 3 ¦   ¦   ¦¦
 +--¦   +--+---+---+---¦   +¦
 ¦  ¦   ¦ mark ¦ 2 ¦ * ¦ 3 ¦   ¦dyad¦
 +--¦   +--+---+---+---¦   +¦
 ¦  ¦   ¦ mark ¦ 6 ¦   ¦   ¦   ¦¦
 +--+   +--+   ++

-M

At 2022-12-04 14:48, you wrote:


Used to work fine in J807 but evidently doesn't in J903 ...
Haven't found out why not.
-M

At 2022-12-04 12:33, you wrote:


That just displays the EVM adjective!



Sent from Mail for Windows




From: Richard Donovan 
Sent: Saturday, December 3, 2022 12:14:34 PM
To: J Programming 
Subject: EVM



I was reading on the J website of the useful 
sounding adverb EVM so I went to the link at 
Help / Learning / Ap 1: Evaluating Expressions 
- J Wiki 
(jsoftware.com) 
and downloaded it.




So far I cannot get it to work at all using the 
examples given, I get syntax error in every case! EG





From the wiki page...



*: 4



'*: 4' EVM



16



16



Me:





*: 4'*: 4' EVM



|syntax error



| *: 4'*: 4'EVM





Have I catastrophically misunderstood this, or missed something obvious??





Thanks
--
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


Re: [Jprogramming] EVM

2022-12-04 Thread Martin Kreuzer

Used to work fine in J807 but evidently doesn't in J903 ...
Haven't found out why not.
-M

At 2022-12-04 12:33, you wrote:


That just displays the EVM adjective!

Sent from Mail for Windows


From: Richard Donovan 
Sent: Saturday, December 3, 2022 12:14:34 PM
To: J Programming 
Subject: EVM


I was reading on the J website of the useful sounding adverb EVM so 
I went to the link at Help / Learning / Ap 1: Evaluating Expressions 
- J Wiki 
(jsoftware.com) 
and downloaded it.




So far I cannot get it to work at all using the examples given, I 
get syntax error in every case! EG




From the wiki page...

*: 4

'*: 4' EVM

16

16

Me:



*: 4'*: 4' EVM

|syntax error

| *: 4'*: 4'EVM



Have I catastrophically misunderstood this, or missed something obvious??



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


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


Re: [Jprogramming] Plot a Squircle in J

2022-08-17 Thread Martin Kreuzer

Had a look at the 1st quadrant (0 .. 1r2p1 rad).

Worked with a vector "sweep" (origin to perimeter) for these graphs:

   - unit circle
   - square circumscribed unit circle
   - quadric plane function x^4 + y^4= 1 ('real squircle')
   - 'fake squircle'

The 'fake squircle' was constructed by taking the mean of vector 
length (at the same angle) for square and unit circle.


The figure obtained by this procedure is a bulging square, situated 
between circle and circumscribed square, with its four corners 
sitting on the four bisectors of the four quadrants.


That's the region where the 'real squircle' lives; but in contrast, 
that is a smooth curve.


I tried a couple of different means, notably harmonic, geometric and 
arithmetic mean.


Using geometric mean, I noticed that the four corners of the 'fake 
squircle' almost conincide (error below 2%) with the 'real' one 
(while most of its graph lies *inside* of the 'real squircle'). Maybe 
these corner positions gave rise to the mention of mean in this context.


I hesitate to include the awkward code I used, but as a starting 
point I took your circle function (cos j. sin); my mean is different 
from yours as I stayed on the same 'sweep vector' when comparing 
different graph's vector lengths.


As RM would probably have written at this point: I hope this makes some sense.

Thanks
-M

At 2022-08-16 18:08, you wrote:


RD> I want to construct and plot a Squircle in J.   [...]
RD>
RD> Has anyone a good idea for performing that calculation? Could the J
RD> function plot then draw the Squircle?

It is easy to "plot" parametric functions in the complex plane.

Here are three parametric functions, to be computed over parameter
inputs for a full circle, say, -pi to pi in 200 tiny steps:

circle =. cos  j.  sin
square =. cos j.&* sin

squircle =. (square + circle) % 2:  NB. your "mean" of the functions.

NB. Show time!

plot (circle , square ,: squircle)  i: 1p1 j. 200

Martin Neitzel

PS:

That * in  cos j.&* sin  is Sign, bulging out the circle to the full
1 _1 (square) borders.

Have some thoughts on what actually happens when the Sign * acts on and
returns a 0, and how that shows up.
--
For information about J forums see http://www.jsoftware.com/forums.htm


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


Re: [Jprogramming] How to get the timezone?

2022-06-21 Thread Martin Kreuzer




You could simplify this to:

NB. android date example: Mon Jun 20 10:50:01 AZOST 2022
tz=: {{ 4 {:: cut shell 'date' }}


-
That looks cute -- one of the extensions added lately I'm not yet 
familiar with.

More stuff to digest ...
-

Please disregard the above paragraph (besides the word cute, maybe) --
as fetch and cut proved to be part of my toolbox
(used it only a couple of weeks ago in a comparable context).
I definitely must have been confused.

-M



I hope this helps,

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


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


Re: [Jprogramming] How to get the timezone?

2022-06-20 Thread Martin Kreuzer




You could simplify this to:

NB. android date example: Mon Jun 20 10:50:01 AZOST 2022
tz=: {{ 4 {:: cut shell 'date' }}


That looks cute -- one of the extensions added lately I'm not yet 
familiar with.

More stuff to digest ...



If you wanted something portable, you could also add an IFJA branch to
your earlier tz implementation.


That's great -- I have been on the lookout for that boolean to make 
my startup script portable.

Thanks.

-M



I hope this helps,

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


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


Re: [Jprogramming] How to get the timezone?

2022-06-20 Thread Martin Kreuzer
This bumpy workaround I'm going to share (in case somebody might be 
interested) isn't meant to answer the original question of this 
thread but helped me to fix the ported system_date_time functions for 
my smartphone.


These I had defined for the use within a Windows PC environment, 
mimicking the ISO date-time string (simply as a wrapper for 6!:0):


tz=: {{  NB. timezone info
 if. IFUNIX do.
  2!:5'TZ'
 elseif. IFWIN do.
  shell 'tzutil /g' [ require 'task' NB. as suggested by Raul
 end.
}}

sdtfz=: {{ (sdtf''),' ',(tz'') }} NB. ~ISO, w/ TimeZone information added

with example output

   sdtfz'' NB. ~ISO, system date-time, formatted w/ TZ
2022-06-13 15:19:51.4 UTC

This is the version I now use on my SONY Xperia Z3 Compact D5803
running Android v4.4.4 (KitKat), which lets me
choose a timezone (equivalent to UTC) different from the provider's
but date-time still updated over the network:

tz=: {{
 NB. get Android date (e.g.: Mon Jun 20 10:50:01 AZOST 2022)
 ad=. shell 'date'
 NB. define Blank
 BL=.  32 { a.
 NB. get list of blanks in the date string
 lob=. ad = BL
 NB. get indices of those 5 blanks
 iob=. I. lob
 NB. calc index of tz start
 izs=. >: 3 { iob
 NB. calc index of tz end
 ize=. <: 4 { iob
 NB. calc tz string length
 tzl=. >: ize - izs
 NB. extract TZ string
 TZ=. (izs + i. tzl) { ad
}}

Now these are working again:

   tz''
AZOST

   sdtfz''
2022-06-20 14:54:09.8 AZOST

-M


At 2022-06-13 18:49, you wrote:


On my phone (an iphone 7):

Yes, TZ is not defined for you (nor for me on this phone).

Plausibly a consequence of over zealous security measures, though more
likely a consequence of the "long running process" model for phones  where
many phone users (particularly influential users) frequently change time
zones without rebooting their phone.

Thanks,

--
Raul

On Mon, Jun 13, 2022 at 2:40 PM Martin Kreuzer  wrote:

> On my phone (Android v4.4.4) I get

> 2!:5 'TZ'
> 0

> which is to say that this environment variable doesn't exist?

> JVERSION
> Engine: j03/j32/android
> Release-a: commercial/2022-01-08T13:47:02
> Library: 9.03.08
> J Android: 1.4.17/4.4.4/19
> ...

> -M

> At 2022-06-12 04:01, you wrote:

> >If you are running under a unix-like operating system, 2!:5'TZ' should
> work.
> >
> >If you are running under windows, on an older version of J, I think
> >2!:0'tzutil /g' would work.
> >
> >In more recent versions of J, something has gone wrong with 2!:0 so
> >instead you would use
> >
> >require'task'
> >shell'tzutil /g'
> >
> >Note that all of these approaches provide a textual result.
> >
> >I hope this helps,
> >
> >--
> >Raul
> >
> >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


Re: [Jprogramming] How to get the timezone?

2022-06-14 Thread Martin Kreuzer

Sorry if this reads already 'chatty' ...

> "machines that do not move":

From the beginning I had all my machines running on UTC  (if it only 
was for getting rid of the silly daylight saving time),
had the date set to ISO format (which tended to annoy people beyond 
imagination), and
the software installed in English (to participate from a much larger 
user base).


But that still posed problems later, e.g. when

--  I couldn't use the full functionality of any banking software due 
to their servers refusing to connect because of the 'unacceptable 
time difference',
--  a major known accounting software completely refused to function 
(or even to install) because the Windows platform was not installed 
in German and variables like date were not set to the format 
according to German locale (viz dd.mm.).


I also remember my astonishment when I had bought my first mobile 
phone (some time in the mid-eighties) and realized that the displayed 
time was still wandering around based on a cheap quartz oscillator 
(while we were regularly using GPS already (with a small handheld 
box) as backup for navigation on long range flights).


Even the famous Siemens S35 I acquired later (and still use until 
this day) has not been equipped for having the time set by the 
service provider.
Which somehow suited me, so we had a GMT reference; people who wanted 
more comfort they wore a second time piece (showing local time).


On the Samsung Galaxy A40 I've had access to there was the choice 
between manually setting the timezone (or region) to GMT or have date 
and time automatically set by the network, which then tossed me back 
to CEST (GMT +02:00). (Wouldn't know about the options with a recent 
custom ROM.)


-M

At 2022-06-13 21:31, you wrote:


Environmental variables are inherited by a process from the program
which spawned it.

So, the information supplied in environmental variables must be
supplied before the process launches.

This is fine for the timezone for machines which do not move. It's
inadequate for machines which do move.

That said, security (or, more specifically, the concept of "attack
surface") is a commonly used "catchall rationale" for tossing
unnecessary or malfunctioning mechanisms.

--
Raul

On Mon, Jun 13, 2022 at 3:06 PM Martin Kreuzer  wrote:
---> snip <--- 


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


Re: [Jprogramming] How to get the timezone?

2022-06-13 Thread Martin Kreuzer
Wasn't aware of that particular development (though experiencing 
'overly zealous security measures' every day on the web). --
I'm glad that I got J903 running on that little Sony xperia in the 
first place (since this morning).

Thanks for the info.
-M

At 2022-06-13 18:49, you wrote:


On my phone (an iphone 7):

Yes, TZ is not defined for you (nor for me on this phone).

Plausibly a consequence of over zealous security measures, though more
likely a consequence of the "long running process" model for phones  where
many phone users (particularly influential users) frequently change time
zones without rebooting their phone.

Thanks,

--
Raul

On Mon, Jun 13, 2022 at 2:40 PM Martin Kreuzer  wrote:

> On my phone (Android v4.4.4) I get

> 2!:5 'TZ'
> 0

> which is to say that this environment variable doesn't exist?

> JVERSION
> Engine: j03/j32/android
> Release-a: commercial/2022-01-08T13:47:02
> Library: 9.03.08
> J Android: 1.4.17/4.4.4/19
> ...

> -M

> At 2022-06-12 04:01, you wrote:

> >If you are running under a unix-like operating system, 2!:5'TZ' should
> work.
> >
> >If you are running under windows, on an older version of J, I think
> >2!:0'tzutil /g' would work.
> >
> >In more recent versions of J, something has gone wrong with 2!:0 so
> >instead you would use
> >
> >require'task'
> >shell'tzutil /g'
> >
> >Note that all of these approaches provide a textual result.
> >
> >I hope this helps,
> >
> >--
> >Raul
> >
> >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


Re: [Jprogramming] How to get the timezone?

2022-06-13 Thread Martin Kreuzer

On my phone (Android v4.4.4) I get

   2!:5 'TZ'
0

which is to say that this environment variable doesn't exist?

   JVERSION
Engine: j03/j32/android
Release-a: commercial/2022-01-08T13:47:02
Library: 9.03.08
J Android: 1.4.17/4.4.4/19
...

-M

At 2022-06-12 04:01, you wrote:


If you are running under a unix-like operating system, 2!:5'TZ' should work.

If you are running under windows, on an older version of J, I think
2!:0'tzutil /g' would work.

In more recent versions of J, something has gone wrong with 2!:0 so
instead you would use

require'task'
shell'tzutil /g'

Note that all of these approaches provide a textual result.

I hope this helps,

--
Raul

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


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


Re: [Jprogramming] wiki maintenance

2022-06-06 Thread Martin Kreuzer

Looks like this was the result of a temporal overlap.
Sorry for the noise ...
Thanks to all involved for their intense work which is much appreciated.
-M

At 2022-06-06 18:49, you wrote:


I think this problem is already fixed. Please check and make sure you are
reading the latest page.

On Mon, Jun 6, 2022 at 3:19 AM Martin Kreuzer  wrote:

> Chris -

> NuVoc layout (after the move) is in the need for a brush-up.

> Would you run a bot to replace all the
> ¢?¢
> characters with HTML
> 

> I haven't used the

> Replace Text extension so far (and probably do
> not have the rights to use it anyway).

> Thanks.

> -M



> At 2022-06-06 00:06, you wrote:

> >It looks like the wiki move did not complete correctly!
> >
> >The page titles are all there, but some pages have no content, e.g.
> >https://code.jsoftware.com/wiki/Essays/Eigenvalues .
> >
> >The same problem is in the code2 wiki that was set up earlier for testing
> >wiki changes. We just never noticed it.
> >
> >I am going to try to rebuild the new wiki now, so it will be unavailable
> >for a few minutes.
> >
> >
> >On Sun, Jun 5, 2022 at 8:01 AM chris burke  wrote:
> >
> > > The wiki move is finished and you can edit the wiki again. It is on a
> new
> > > IP address so you may need to refresh your browser.
> >
> > > The old wiki will be made available at oldcode.jsoftware.com for a few
> > > weeks. Right now I am just getting the ssl certs working for it.
> >
> >--
> >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


Re: [Jprogramming] wiki maintenance

2022-06-06 Thread Martin Kreuzer

Chris -

NuVoc layout (after the move) is in the need for a brush-up.

Would you run a bot to replace all the
   â?¢
characters with HTML
   

I haven't used the

Replace Text extension so far (and probably do 
not have the rights to use it anyway).


Thanks.

-M



At 2022-06-06 00:06, you wrote:


It looks like the wiki move did not complete correctly!

The page titles are all there, but some pages have no content, e.g.
https://code.jsoftware.com/wiki/Essays/Eigenvalues .

The same problem is in the code2 wiki that was set up earlier for testing
wiki changes. We just never noticed it.

I am going to try to rebuild the new wiki now, so it will be unavailable
for a few minutes.


On Sun, Jun 5, 2022 at 8:01 AM chris burke  wrote:

> The wiki move is finished and you can edit the wiki again. It is on a new
> IP address so you may need to refresh your browser.

> The old wiki will be made available at oldcode.jsoftware.com for a few
> weeks. Right now I am just getting the ssl certs working for it.

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


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


Re: [Jprogramming] plot: units ratio

2022-03-22 Thread Martin Kreuzer

Thanks ... And I did some tests this morning:

Plotted the *bisector (3rd, 1st quadrant) and *sin using

   pd 'xrange _1 1'
   pd 'yrange _1.1 1.1'
and
   pd 'aspect xx'   with these values:  xx= 0.866 | 1.0 | 1.155

Results:

aspect: 0.866 | 1.0  | 1.155'xrange _1 1'
-
vertical/horizontal unit length:0.81  | 0.92 | 1.05
height/width of grid frame: 0.87  | 1.0  | 1.15

'aspect 1.0' does not produce an angle of 45 deg of tangent versus 
horizontal at the root as expected.


Try it with a different xrange and have a look how distorted it becomes:

aspect: 0.866 | 1.0  | 1.155'xrange _2 2'
-
vertical/horizontal unit length:1.57  | 1.83 | 2.13
height/width of grid frame: 0.87  | 1.0  | 1.15

This clearly shows (at least to me) that the aspect value is 
definitely governing the rectangular grid frame, and somehow (on the 
way) influencing the units ratio.

I think that's a bug (as it should at least be the other way around).
Therefore I still plead for a separate pf option of e.g. 'compression 
ratio' or 'units ratio' if possible.


-M



At 2022-03-21 21:43, you wrote:


On Mon, 21 Mar 2022, Martin Kreuzer wrote:

[I'm writing under the influence of a (so long) mild attack of big 
C, so beg your pardon if reads a bit incoherently in places.]


Sad to hear that.  Hope you get better soon.


When plotting a unit circle (using pd commands and options) I got 
disappointed again as it looked like a ballon from last weeks birthday party.


When I run the following:

plot r.2p1 * 128 %~ i.128

I get something that looks stretched out and disappointing.  But the 
aspect ratio follows the window size.  If, instead, I run this:


'aspect 1' plot r.2p1 * 128 %~ i.129

The aspect ratio remains fixed regardless of the window size, and I 
get something that looks like a circle.


On to the issue of the hexagon:

   pd'reset'
   pd'aspect 1'
   pd r.2p1*6%~i.7
   pd'show'

If I do this, I get a slightly distorted hexagon.  However, if I 
inscribe it in a circle, it looks correct:


   pd r.2p1*128%~i.129
   pd'show'

So I think it is a bug in plot.  The aspect ratio is being computed 
relative to the max/min bounds of the function being plotted, not in 
absolute terms.


So where does 0.866 come from?  We can find the max/min bounds of 
the points in our hexagon, and thereby find the (incorrect) aspect 
ratio used by plot:


   +. p=. r.2p1*6%~i.6
   1   0
 0.50.866025
_0.50.866025
  _1 1.22465e_16
_0.5   _0.866025
 0.5   _0.866025
   (>./ - <./)+.p
2 1.73205
   %/(>./ - <./)+.p
1.1547

plot is using ~1.1547 as its aspect ratio, so we need the reciprocal,
which is ~0.866.  0.866 is also visible in p, as it really comes from
1 o. o. %3.  And yes, it really is -:%:3.
--
For information about J forums see http://www.jsoftware.com/forums.htm

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


[Jprogramming] plot: units ratio

2022-03-21 Thread Martin Kreuzer

Dear all -

[I'm writing under the influence of a (so long) mild attack of big C, 
so beg your pardon if reads a bit incoherently in places.]


When plotting a unit circle  (using pd commands and options) I got 
disappointed again as it looked like a ballon from last weeks birthday party.


I then remembered this threat from yesteryear
http://www.jsoftware.com/pipermail/programming/2021-February/057582.html

where Bill wrote:
"I think it's ok to have different axis length, but the unit of each axis
should have the same physical length. Is this a bug in qt output only?"

And somewhat later:
"The hexagon has vertices on x axis but the flat side on y axis. the
distance between opposite vertices is longer than the distance between
opposite sides."

As I checked myself, it's not a problem of qt output only, but also 
visible in print.


The option 'aspect' which was suggested as a remedy (using a value of 
0.866, which -for reasons unknown to me- is suspiciously close to 
-:%:3) has probably more to do with the aspect of the plotted grid 
(and if so, in a weird way, at least one I do not fully understand).


And I wondered whether there should be an additional pd option 
labelled something like


   'units ratio'   or  'compression ratio'

where a value of 1 would force identical unit lengths on both the 
vertical and horizontal axis.


I must admit that I'm not current on that issue, might have missed 
any further discussion (if there was one).


-M





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


Re: [Jprogramming] Calculus & Newton's iteration

2020-10-24 Thread Martin Kreuzer

N is at most times sensitive to its start value ...
it does work in this case (but as you stated, it will not be 
neccessary in this case):


   (4.9+2&%) N^:1 (_0.1)
_0.1755
   (4.9+2&%) N^:2 (_0.1)
_0.275539
   (4.9+2&%) N^:4 (_0.1)
_0.403614
   (4.9+2&%) N^:14 (_0.1)
_0.408163
   (4.9+2&%) N^:_ (_0.1)
_0.408163

-M


At 2020-10-24 15:52, you wrote:
I just realized that I don't need Newton: 2/x + 4.9 = 0? 2/x = 49/10 
2 = 49/10 * x x = 2/(49/10) = 2*(10/49) = 20/49 = 0.4081632653 Skip 
Cave Cave Consulting LLC On Sat, Oct 24, 2020 at 10:12 AM Skip Cave 
 wrote: > The Newton Raphson root finder 
using the new J definition of derivative is: > > N=: 1 : '- u % u 
deriv_jcalculus_ 1' > > > How would I use N to solve for x in the 
equation 2/x + 4.9 = 0? > > > Skip Cave > Cave Consulting LLC > 
-- 
For information about J forums see http://www.jsoftware.com/forums.htm


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


Re: [Jprogramming] Newton polynomial without using a loop?

2020-10-15 Thread Martin Kreuzer

Hello Hauke -

That sounds very interesting -- I too would be 
glad to receive a copy (if it's not asking too 
much - you could use PM in that case);
btw, I'm a fellow citizen (former Math teacher, 
long retired = a.D., besides other occupations) 
losely following forum discussions (not much of a 
contributor lately due to personal reasons).


-M

At 2020-10-15 14:20, you wrote:
Hello Stefan, I guess by your name and email 
adress that you’re from austria so you could 
read and understand German. I took lecture notes 
last year in a Numerics course here at the 
university of Jena and implemented nearly all of 
the algorithms using J, with coloured J lines 
interspersed with the notes. (typeset with LaTeX 
and the minted package) I used explicit code in 
some places but most of it is tacit and thus 
without for. style loops. But of course there 
need to be ^: style loops in many places. EDIT: 
I just did a /for\. search and it turned out I 
didn’tuse it at all For example, the 
line for the newton representation of the 
lagrange polynomial reads Newton =: 1 : ’[: +/ 
(nbase pmul u divdiff)\’ NB. pmul aus Beispiel 
1.40 where 1.40 is a clickable back-reference. 
All the other names have been defined in the 
current section. Up to that point there are no 
explicit definitions at all. If you’re 
interested, I’ll ask if I may send you the pdf 
file (I guess it will be okay) in case you’re 
interested. cheers, Hauke Am 15.10.20 um 15:50 
schrieb Stefan Baumann: > Dear all. > Recently I 
stumbled upon the Newton polynomial and took it 
as a practice to > implement it without using 
loops, but failed. I first didn't get a grab 
on > how to create the matrix used in > 
https://en.wikipedia.org/wiki/Newton_polynomial#Main_idea, 
and eventually > came up with code following > 
https://en.wikipedia.org/wiki/Newton_polynomial#Application:  
> > NB. Newton polynomial > > np=: 4 : 0 > > 
a=. {. y > > for_i. }.>:i.#x do. > > y=. (2 
(-~)/\ y) % i ({:-{.)\ x NB. Divided 
differences > > a=. a, {. y NB. Coefficients are 
the topmost entries > > end. > > NB. Convert the 
summands aáµ¢(x-x₀)…(x-xᵢ₋₁) of the 
polynomial > > NNB. from multiplier-and-roots to 
coefficients form and add them up > > +/@,:/ 
p."1 (;/a) ,. (<''), }:<\ x > > ) > > x=: _3r2 
_3r4 0 3r4 3r2 > > y=: 3 x > > load'plot' > > 
load'stats' > > plot (];(x np y)) steps _1.5 
1.5 30 > > I also tried replacing the loop with 
fold F:. but again was not able to do > so. 
Anyone out there who can enlighten me? > > Many 
thanks. Stefan. > 
--  
> For information about J forums see 
http://www.jsoftware.com/forums.htm > -- 
-- mail written using NEO 
neo-layout.org 
-- 
For information about J forums see 
http://www.jsoftware.com/forums.htm 


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


Re: [Jprogramming] value error using math/uu in v8.07 *Console*

2020-05-06 Thread Martin Kreuzer

1
Confirming that in JConsole (under WX_64 with J 
v8.07_64) I get the same results:


   load 'math/uu/'

   wd_uu_=. ] NB. or [

   uu '*ssic 0'
0
   'deg' uu '1 rad'
57.2958 deg

2
Adding the line in question to the 'uu.ijs' script, like so:

\"
...
[71]   cocurrent 'uu'
[72]
[73]   wd_uu_=: ]
...
"\

works fine here.

-M

At 2020-05-06 05:35, you wrote:

I notice that assigning "wd" to "[" or "]", in the "uu" coclass,
avoids the spurious "msgs" problem.




On Wed, May 6, 2020 at 1:33 AM Devon McCormick  wrote: >
I mostly use jconsole and have occasionally run into "wd" problems since >
this is the window driver defined in the Qt code.
Typically I get around > it by assigning "wd" to "[" or "smoutput".
This works for the "uu" code, > e.g. >
load 'e:\users\owner\j901\addons\ide\qt\qt.ijs' >
cocurrent 'uu' >
wd=: smoutput >
'deg' uu '1 rad' >
msgs >
msgs >
57.2958° > >
It does give the spurious "msgs" output, though. > >



On Tue, May 5, 2020 at 2:36 PM Martin Kreuzer 
 wrote: > >> Ian - >> >> 
Sorry for the delay; was on telephone support 
all afternoon. >> >> In JConsole v8.07 (32- and 
64-bit), there's no >> more reaction to the two 
lines you wanted me to test 
than: >> _ NB. Cursor on the following 
line ... >> >> wd_z_ =: ] >> wd_uu_ =: 
] >> _ >> >> The line >> >> cocurrent 
'uu' >> >> I remember it being suggested (a year 
ago, during >> a discussion with Tom A) to try 
in case the addon won't start at all. >> Haven't 
used it on a regular basis. >> >> Thanks for the 
hint about the lab. >> And feel free to ask for 
any more tests if it deems neccessary... >> >> 
-M >> >> ps: >> As always, I beg your pardon for 
the weird >> formatting below (which is most 
probably due to >> my not having converted to a 
more modern mail client.) >> >> At 2020-05-05 
14:20, you wrote: >> >Thanks Martin. I'll look 
into these too. They all give me bad 
feelings. >> >I think I know what's going wrong. 
In >> >particular, if math/uu ever calls wd 
under jconsole then it'll die. >> >I'd like to 
know what happens (under jconsole ONLY) after 
you have >> entered: >> >wd_z_ =: 
] >> >and/or: >> >   wd_uu_ =: ] >> >BTW: you 
shouldn't do:cocurrent 'uu' 
… >>  >odd  things may occasionally happen if 
you do. >> >There's a verb: uu_z_ which is a 
cover for uu_uu_ >> >There's a lab for math/uu, 
or ought to be, which uses it the recommended >> 
way. >> >> >> >On Tue, 5 May 2020 at 14:30, 
Martin Kreuzer  >> 
wrote: > >> >Hi all - > > 1 > This is the 
behaviour I've >> >observed here ... > J v8.07 
64-bit Console under >> >Windows 10 
(1909)  64-bit > > 
load >> >'~addons/math/uu/uu.ijs' > 
VERSION_uu_ > >> >2.1.24 > cocurrent 
'uu' > 'deg' uu '1 >> >rad' > |value error: 
wd > |   wd'msgs' > > >> >2 > Used to work 
fine in J v8.06 32-bit Console >> >under Vista 
32-bit > > 
load >> >'~addons/math/uu/uu.ijs' > 
VERSION_uu_ > >> >2.1.11 > cocurrent 
'uu' > uu '*ssig 3' > >> >3 > uu '*ssic 
0' > 0 > 'deg' uu '1 >> >rad' > 57.296 
deg > > 3 > Works as expected in >> >both 32- 
and 64-bit JQt Terminals. > > Q: >> >Anybody any 
ideas? Did I miss something? > > >> >Thanks, > 
-M > > >> >-- 
 >> > > 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 >> > > > 
-- > > Devon McCormick, CFA > > Quantitative 
Consultant > > -- Devon McCormick, CFA 
Quantitative Consultant 
-- 
For information about J forums see http://www.jsoftware.com/forums.htm


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


Re: [Jprogramming] value error using math/uu in v8.07 *Console*

2020-05-05 Thread Martin Kreuzer

Ian -

Sorry for the delay; was on telephone support all afternoon.

In JConsole v8.07 (32- and 64-bit), there's no 
more reaction to the two lines you wanted me to test than:

   _ NB. Cursor on the following line ...

   wd_z_ =: ]
   wd_uu_ =: ]
   _

The line

   cocurrent 'uu'

I remember it being suggested (a year ago, during 
a discussion with Tom A) to try in case the addon won't start at all.

Haven't used it on a regular basis.

Thanks for the hint about the lab.
And feel free to ask for any more tests if it deems neccessary...

-M

ps:
As always, I beg your pardon for the weird 
formatting below (which is most probably due to 
my not having converted to a more modern mail client.)


At 2020-05-05 14:20, you wrote:

Thanks Martin. I'll look into these too. They all give me bad feelings.
I think I know what's going wrong. In 
particular, if math/uu ever calls wd under jconsole then it'll die.

I'd like to know what happens (under jconsole ONLY) after you have entered:
   wd_z_ =: ]
and/or:
  wd_uu_ =: ]
BTW: you shouldn't do:cocurrent 'uu' …
odd  things may occasionally happen if you do. 
There's a verb: uu_z_ which is a cover for uu_uu_

There's a lab for math/uu, or ought to be, which uses it the recommended way.




On Tue, 5 May 2020 at 14:30, Martin Kreuzer  wrote: >
Hi all - > > 1 > This is the behaviour I've 
observed here ... > J v8.07 64-bit Console under 
Windows 10 (1909)  64-bit > > load 
'~addons/math/uu/uu.ijs' > VERSION_uu_ > 
2.1.24 > cocurrent 'uu' > 'deg' uu '1 
rad' > |value error: wd > |   wd'msgs' > > 
2 > Used to work fine in J v8.06 32-bit Console 
under Vista 32-bit > > load 
'~addons/math/uu/uu.ijs' > VERSION_uu_ > 
2.1.11 > cocurrent 'uu' > uu '*ssig 3' > 
3 > uu '*ssic 0' > 0 > 'deg' uu '1 
rad' > 57.296 deg > > 3 > Works as expected in 
both 32- and 64-bit JQt Terminals. > > Q: 
Anybody any ideas? Did I miss something? > > 
Thanks, > -M > > 
--  
> 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


[Jprogramming] value error using math/uu in v8.07 *Console*

2020-05-05 Thread Martin Kreuzer

Hi all -

1
This is the behaviour I've observed here ...
J v8.07 64-bit Console under Windows 10 (1909)  64-bit

   load '~addons/math/uu/uu.ijs'
   VERSION_uu_
2.1.24
   cocurrent 'uu'
   'deg' uu '1 rad'
|value error: wd
|   wd'msgs'

2
Used to work fine in J v8.06 32-bit Console under Vista 32-bit

   load '~addons/math/uu/uu.ijs'
   VERSION_uu_
2.1.11
   cocurrent 'uu'
   uu '*ssig 3'
3
   uu '*ssic 0'
0
   'deg' uu '1 rad'
57.296 deg

3
Works as expected in both 32- and 64-bit JQt Terminals.

Q: Anybody any ideas? Did I miss something?

Thanks,
-M

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


Re: [Jprogramming] What makes a Windows installation read-only?

2020-05-03 Thread Martin Kreuzer
I've made it a habit to install sensitive and/or 
old software to something like

*D:\Program Files (non-sys)\...*
in order to steer away from Windows rights and automatisms.
-M

At 2020-05-03 16:17, you wrote:
I point the users to the installation 
page.  Can you give me a sentence to add to my 
instructions so they won't encounter this 
problem? Henry Rich On 5/3/2020 12:15 PM, Norman 
Drinkwater wrote: > If they are an administrator 
on the computer, they can use the all-in-one > 
installer to install for all users. Then J runs 
with admin rights and > pacman will work fine. 
If they aren't an administrator, they can only > 
install as a user. The current behavior conforms 
to windows guidelines, > though I understand 
that it's inconvenient. > > On Sun, May 3, 2020 
at 10:33 AM Henry Rich  
wrote: > >> I have a J application, distributed 
as a Addon.  When it starts, it runs >> Pacman 
to check for updates. >> >> A couple of users 
report that the catalog is read-only and thus 
they >> can't run Pacman without administrative 
rights.  As they are Windows >> users, this 
means that they have to Run as Administrator. 
This is >> undesirable. >> >> Does anyone know 
what causes this state of affairs?  Is it 
something in >> the way they installed J, or how 
they have their Windows system set up? >> I 
don't think it's an antivirus issue. >> >> And 
is there a workaround for them to give J the 
rights to manage its >> stuff? >> >> Henry 
Rich >> >> -- >> This email has been checked for 
viruses by AVG. >> https://www.avg.com >> >> 
--  
>> For information about J forums see 
http://www.jsoftware.com/forums.htm >> > 
--  
> For information about J forums see 
http://www.jsoftware.com/forums.htm -- This 
email has been checked for viruses by AVG. 
https://www.avg.com 
-- 
For information about J forums see 
http://www.jsoftware.com/forums.htm 


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


Re: [Jprogramming] Recursive verbs

2018-11-29 Thread Martin Kreuzer

Mike -
(having followed only loosely) shouldn't this 'hook' read
   h=: + +:
?
-M

At 2018-11-28 23:05, you wrote:


Thanks, though I think Cliff’s approach is more advanced.

Noticing that your g is applied with ~,  you can also use this “hook”
  h =: + +
which does x + 2y

Also, you can use the constant noun _1 1,  so 
avoiding the constant function _1 1”_, as the lhs in this expression:

(_1 1$~]) 5
_1 1 _1 1 _1

So your verb may be modified thus:
   4 (h/\.&.|.@, _1 1$~]) 5
4 7 15 29 59 117

Or with another variation for building the list of +-1,
   4 (h/\.&.|.@, $&_1 1) 6
4 7 15 29 59 117 235

I wonder if this discussion is what Skip was hoping for?

Cheers,

Mike


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

Re: [Jprogramming] Using rank to avoid looping - reference?

2018-10-18 Thread Martin Kreuzer

NB. regular verb using Do (".)

   d=. 3 : '". ''vb=. +:y'''
   d i.21
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40

NB. verb with call to compiler

   dc=. 13 : '". ''vb=. +:y'''
   dc 5
2
   dc i.21
2
   dc("0) i.21
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

NB. Stuck at (2:) and using rank somehow differently.


NB. verb using inside definition works alright:

   di=. 3 : '3 * dbl y [ ". ''dbl=. +:'''
   di 5
30

NB. with(13 :) refuses to work ...

   dic=. 13 : '3 * dbl y [ ". ''dbl=. +:'''
   dic 5
|value error: dbl
|   dic 5

-M

ps:
Regarding the (?) issue -
Added a "Caution" section to the NuVoc "Roll/Deal" page.


At 2018-10-17 22:29, you wrote:


I am aware that executing code with ". relying on explicit context can trip
13 : , for instance,

u=. 3 : '".''+:y'''

u 5

10

v=. 13 : '".''+:y'''

v 5





2:

I am not quite sure but probably there are more glitches, according to,

NuVoc  13 :
https://code.jsoftware.com/wiki/Vocabulary/com#m13

"If you get exotic, you may encounter a bug or two in the implementation of 13
:"


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

Re: [Jprogramming] Using rank to avoid looping - reference?

2018-10-17 Thread Martin Kreuzer

José -

Thanks for pointing out that issue in the first place.

I wasn't aware of the compiler module being overzealous sometimes ...

Are there any other known (I'm fighting for 
words, might I call them) 'glitches' comparable to this one, and

where would they be documented for lookup..?

-M

At 2018-10-17 16:25, you wrote:


Martin,

In my example, using + instead of -, u was the double of a single roll and
v was the sum of two "independent" rolls.

Yours is a far better example for illustrating the issue,

  ( u=.  3 : ' T - (T=. ? y)' )
3 : ' T - (T=. ? y)'

u is one roll minus itself which produces zeroes; whereas

  ( v=. 13 : ' T - (T=. ? y)' )
? - ?

is the difference of two "independent" rolls.

Thus, for example,

   u 0 0 0 0 0
0 0 0 0 0

whereas,

   v 0 0 0 0 0
_0.0389238 0.321837 0.0862073 0.552116 _0.134629

Thanks!  I had one of those moments after I read your posts...  Why did I
not think of that?  :)


On Wed, Oct 17, 2018 at 8:08 AM Martin Kreuzer  wrote:

> Addendum:

> Consider, in contrast, the behaviour of this *explicit* definition:

> ee=. 3 : 'T - T=. ?y'
> ee 10+i.7
> 0 0 0 0 0 0 0

> Same result as working *outside* a verb definition:

> ] T=.  ? 10+i.7
> 6 6 0 9 12 1 5
> T - T
> 0 0 0 0 0 0 0

> -M

> At 2018-10-17 11:40, you wrote:

> >Let's modify Jose's example (by taking the *difference* of two
> >identocal terms):
> >
> >NB. this works as expected:
> >
> >d=. 13 : 'T - T=. +:y'
> >d 10+i.7
> >0 0 0 0 0 0 0
> >
> >NB. this doesn't:
> >
> >e=. 13 : 'T - T=. ?y'
> >e 10+i.7
> >_1 1 5 _5 8 _2 _4
> >
> >NB. this yields the same result (zero) for every argument:
> >
> >d
> >+--+-+--+
> >|+:|-|+:|
> >+--+-+--+
> >+: - +:
> >
> >NB. this yields arbitrary results (because minuend and subtrahend do
> >not necessaryly have the same value):
> >e
> >+-+-+-+
> >|?|-|?|
> >+-+-+-+
> >? - ?
> >
> >But ... from the underlying structure they should have.
> >
> >NB. in comparison this works as intended:
> >
> >f=. 13 : 'T - T=. ?.y'
> >f 10+i.7
> >0 0 0 0 0 0 0
> >f
> >+--+-+--+
> >|?.|-|?.|
> >+--+-+--+
> >?. - ?.
> >
> >-M
> >
> >
> >At 2018-10-17 10:22, you wrote:
> >
> >>Jose,
> >
> >>You said: You might be interested to know that 13 : '...'
> >>occasionally is too smart; some verbs, such as ?, which do not
> >>always produce the same result given the same argument, sometimes
> >>do not mix well with 13 : '...'; for example,
> >
> >>Something is not wrong when verbs with ? don't agree.  I would
> >>worry is they did agree. They areproducing different results each
> >>time they are used.
> >
> >>Linda
> >
> >
> >>-Original Message-
> >>From: Programming  On
> >>Behalf Of Jose Mario Quintana
> >>Sent: Tuesday, October 16, 2018 7:37 PM
> >>To: Programming forum 
> >>Subject: Re: [Jprogramming] Using rank to avoid looping - reference?
> >
> >>Linda,
> >
> >>You might be interested to know that 13 : '...' occasionally is too
> >>smart; some verbs, such as ?, which do not always produce the same
> >>result given the same argument, sometimes do not mix well with 13 :
> >>'...'; for example,
> >
> >>( u=.  3 : ' T + (T=. ? y)' )
> >>3 : ' T + (T=. ? y)'
> >
> >>and
> >>( v=. 13 : ' T + (T=. ? y)' )
> >>? + ?
> >
> >>do not mean the same process.
> >
> >>I hope it helps
> >
> >--
> >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

Re: [Jprogramming] Using rank to avoid looping - reference?

2018-10-17 Thread Martin Kreuzer

Addendum:

Consider, in contrast, the behaviour of this *explicit* definition:

   ee=. 3 : 'T - T=. ?y'
   ee 10+i.7
0 0 0 0 0 0 0

Same result as working *outside* a verb definition:

   ] T=.  ? 10+i.7
6 6 0 9 12 1 5
   T - T
0 0 0 0 0 0 0

-M

At 2018-10-17 11:40, you wrote:

Let's modify Jose's example (by taking the *difference* of two 
identocal terms):


NB. this works as expected:

   d=. 13 : 'T - T=. +:y'
   d 10+i.7
0 0 0 0 0 0 0

NB. this doesn't:

   e=. 13 : 'T - T=. ?y'
   e 10+i.7
_1 1 5 _5 8 _2 _4

NB. this yields the same result (zero) for every argument:

   d
+--+-+--+
|+:|-|+:|
+--+-+--+
+: - +:

NB. this yields arbitrary results (because minuend and subtrahend do 
not necessaryly have the same value):

   e
+-+-+-+
|?|-|?|
+-+-+-+
? - ?

But ... from the underlying structure they should have.

NB. in comparison this works as intended:

   f=. 13 : 'T - T=. ?.y'
   f 10+i.7
0 0 0 0 0 0 0
   f
+--+-+--+
|?.|-|?.|
+--+-+--+
?. - ?.

-M


At 2018-10-17 10:22, you wrote:


Jose,


You said: You might be interested to know that 13 : '...' 
occasionally is too smart; some verbs, such as ?, which do not 
always produce the same result given the same argument, sometimes 
do not mix well with 13 : '...'; for example,


Something is not wrong when verbs with ? don't agree.  I would 
worry is they did agree. They areproducing different results each 
time they are used.



Linda




-Original Message-
From: Programming  On 
Behalf Of Jose Mario Quintana

Sent: Tuesday, October 16, 2018 7:37 PM
To: Programming forum 
Subject: Re: [Jprogramming] Using rank to avoid looping - reference?



Linda,


You might be interested to know that 13 : '...' occasionally is too 
smart; some verbs, such as ?, which do not always produce the same 
result given the same argument, sometimes do not mix well with 13 : 
'...'; for example,



   ( u=.  3 : ' T + (T=. ? y)' )
3 : ' T + (T=. ? y)'



and
   ( v=. 13 : ' T + (T=. ? y)' )
? + ?



do not mean the same process.



I hope it helps


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


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

Re: [Jprogramming] Using rank to avoid looping - reference?

2018-10-17 Thread Martin Kreuzer
Let's modify Jose's example (by taking the *difference* of two 
identocal terms):


NB. this works as expected:

   d=. 13 : 'T - T=. +:y'
   d 10+i.7
0 0 0 0 0 0 0

NB. this doesn't:

   e=. 13 : 'T - T=. ?y'
   e 10+i.7
_1 1 5 _5 8 _2 _4

NB. this yields the same result (zero) for every argument:

   d
+--+-+--+
|+:|-|+:|
+--+-+--+
+: - +:

NB. this yields arbitrary results (because minuend and subtrahend do 
not necessaryly have the same value):

   e
+-+-+-+
|?|-|?|
+-+-+-+
? - ?

But ... from the underlying structure they should have.

NB. in comparison this works as intended:

   f=. 13 : 'T - T=. ?.y'
   f 10+i.7
0 0 0 0 0 0 0
   f
+--+-+--+
|?.|-|?.|
+--+-+--+
?. - ?.

-M


At 2018-10-17 10:22, you wrote:


Jose,

You said: You might be interested to know that 13 : '...' 
occasionally is too smart; some verbs, such as ?, which do not 
always produce the same result given the same argument, sometimes do 
not mix well with 13 : '...'; for example,


Something is not wrong when verbs with ? don't agree.  I would worry 
is they did agree. They areproducing different results each time they are used.


Linda


-Original Message-
From: Programming  On 
Behalf Of Jose Mario Quintana

Sent: Tuesday, October 16, 2018 7:37 PM
To: Programming forum 
Subject: Re: [Jprogramming] Using rank to avoid looping - reference?

Linda,

You might be interested to know that 13 : '...' occasionally is too 
smart; some verbs, such as ?, which do not always produce the same 
result given the same argument, sometimes do not mix well with 13 : 
'...'; for example,


   ( u=.  3 : ' T + (T=. ? y)' )
3 : ' T + (T=. ? y)'

and
   ( v=. 13 : ' T + (T=. ? y)' )
? + ?

do not mean the same process.

I hope it helps


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

Re: [Jprogramming] Using rank to avoid looping - reference?

2018-10-10 Thread Martin Kreuzer
Not sure whether this meets your understanding of "interesting"; this 
is from basic algebra:


NB. Factoring the difference of two squares (binomial)
NB, a^2 - b^2= (a+b)*(a-b)

NB. explicit version

   bine=. 13 : '(x+y)*(x-y)'

   2 bine 3
_5

NB. compiler suggestion of tacit version

   bine
+-+-+-+
|+|*|-|
+-+-+-+
+ * -

NB. tacit definition, three dyadic verbs in a row (dyadic fork)

bint=. + * -

   2 bint 3
_5

NB. tree representation

   5!:4 <'bint'
  +- +
--+- *
  +- -

-M

At 2018-10-10 20:58, you wrote:

You missed my most important phrase.  Reading fro,m right to 
left...   I learned APL from Ken and thus still reand wriaste from 
right to left.  Try reading the "words" from right to left as I described.


I am also trying to avoid hooks at  this pioint.

Can you provide an interesting verb that has three dyadic verbs in a sequence.

Actually I'm trying to stranslate back and forth between explicit and tacit.

Linda


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

Re: [Jprogramming] Latest Beta D

2018-09-30 Thread Martin Kreuzer

Anyway, under Windows, in the case of JQt, you got two options
which both start with a right mouse click on the shortcut,
then selecting >Properties >Change icon, then continue

1
you either steer to
 /j80x//bin/
where you'll find the JQt executable;
on selecting that it should present the green J icon,

2
or you steer to
 /j80x//bin/icons/
where you'll find the coloured icons;
select the green one...
[this is the way Mike described earlier]

-M


At 2018-09-30 00:59, you wrote:

I think the reason I can't add a J icon in  windows is that the 
icons in bin are images rather than files.  If I click properties on 
the jqt image on the desktop it would accept a file for a new image, 
but it doesn't seem to like images.


Is there another way to get a J icon on the desktop?

Linda

Get Outlook for Android

From: Programming  on 
behalf of Joey K Tuttle 


Sent: Friday, April 20, 2018 4:22:40 PM

To: programm...@jsoftware.com

Subject: Re: [Jprogramming] Latest Beta D



I think it may have been pint 3 that led to my sloppy typing ...  I 
really should limit myself to one pint ...  ;-)


> On 2018Apr 20, at 09:02, Joey K Tuttle  wrote:



> I had no problem with pint 1. in either linux or Mac OS updates of 807-d

--

For information about J forums see 
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm=02%7C01%7C%7C4365d254ef6b4ff95c1308d5a6daf439%7C84df9e7fe9f640afb435%7C1%7C0%7C636598381695758467=4qqa9hBB16Z5oRRqrKMmgG4QH7Sw4VMTQgvA7Dgt2vA%3D=0


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


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

Re: [Jprogramming] Message Threads

2018-09-15 Thread Martin Kreuzer

wilco
-M

At 2018-09-15 17:31, you wrote:

Please note that there is no need to include an entire thread in 
forum messages, 


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

Re: [Jprogramming] Tacit form: How to handle intermediate

2018-09-15 Thread Martin Kreuzer

Hi Linda -

There are three versions I sent you 
(unfortunately badly garbled by unintentional line breaks).


1
amor: explicit, with function body  (3 : 0 ... )
amore: explicit, one-liner (13 : ' ...' )
amort: tacit (from 13 :)

2
Your question about factor 1'200:

1st line of amor reads in y (a list)

 'rap n p'=. y

and converts it to variables

 rap: annual interest rate in percent
 n: number of (monthly) periods
 p: principal (loan)

For payment calculation, we need the *monthly* rate (as a fraction),
therefore rap is transformed

(a) by dividing it by 12 (12 months in a year)
(b) by dividing it by 100 (percentage to fractional part)

leading to rmf (monthly rate as fraction),
in conventional notation rmf= rap /12 /100,

 rmf=. rap %12 *100

which is in turn used to calculate the monthly amortization payment

 a=. p * rmf % (1-(>: rmf)^-n)

This is the line the explicit one-liner got started from.

-M


At 2018-09-15 17:14, you wrote:




Thanks Martin,

amore=: 13 : '({: y) * rmf % (1-(>: rmf=. 1200 %~ {. y)^- 1&{ y)'

   amort=: {: * (1200 %~ {.) % 1 - ([: >: 1200 %~ {.) ^ [: - 1&{

   (amore 5.75 240 12500);amort 5.75 240 12500
┌───────┬───────┐
│87.7604│87.7604│
└───────┴───────┘

   amore
{: * (1200 %~ {.) % 1 - ([: >: 1200 %~ {.) ^ [: - 1&{

   amort
{: * (1200 %~ {.) % 1 - ([: >: 1200 %~ {.) ^ [: - 1&{


Now for any simplifications. Where did your 1200 come from?


  We need t0 get an explicit definition.

It's looking better all the time.  I think 
Raul's adds an interesting twist.  More later.


Linda

It
-Original Message-
From: Programming 
 On Behalf Of Martin Kreuzer

Sent: Thursday, September 13, 2018 11:22 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Tacit form: How to handle intermediate

This I put together independently a couple of 
days ago (sorry for possible similarities in 
other posts as I didn't check them all).


NB. * amor | monad | y: list (of: annual rate 
[percent], no of periods (months), principal) 
NB. * amore (explicit) NB. * amort (tacit)


NB. explicit, with body

amor=: 3 : 0NB. periodic
amortization payment a= p * r %
(1+r)^-n
  'rap n p'=. y  NB. rap: annual
rate [percent], n: no of (monthly) periods, p: principal (loan)
  rmf=. rap%12*100   NB. monthly rate
as fraction (instead of percent)
  a=. p * rmf % (1-(>: rmf)^-n)  NB. monthly payment
)

NB. explicit one-liner

({. , 1&{ ,: {:) 5.75 240 12500 NB. extracting values from list
5.75
240
12500

amore=: 13 : '({: y) * rmf % (1-(>: rmf=. 1200 %~ {. y)^- 1&{ y)'

NB. tacit version (output from (13 :) - probably with room for improvement)

amort=: {: * (1200 %~ {.) % 1 - ([: >: 1200 %~ {.) ^ [: - 1&{

amor 5.75 240 12500
87.7604
amore 5.75 240 12500
87.7604
amort 5.75 240 12500
87.7604

-M


At 2018-09-13 14:34, you wrote:

>Here  are two tacit verb for pmt from Raul,
>
>
>pmt1200=:(%<:)@D * 1 0 1 */ .# ]
>pmt=: pmt1200@(%&1200 1 1)
>pmt 5.75 240 12500
>87.7604
>
>D
>[: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]
>
>pmt1200
>(% <:)@D * 1 0 1 */ .# ]
>
>Can anyone other than Raul or Rob) writ an explicit OR tacit single
>sentence definition for:
>
>PMREX=:
>
>PMTTA=:
>
>Cheers, Linda
>
>(Raul and Bob can coach tacits and I'll respond to explicits) Try 5.75
>240 12500
>
>-Original Message-
>From: Programming
> On Behalf Of 'Rob
>Hodgkinson' via Programming
>Sent: Thursday, September 13, 2018 2:23 AM
>To: programm...@jsoftware.com
>Subject: Re: [Jprogramming] Tacit form: How to handle intermediate
>
>Ahh I’m sorry Linda, that was my bad copy/paste into the email …
>
>Please ignore previous email, I have ccorrected the transcript below
>(and verified) so this should run without conflict (aside from being
>careful of quotes on copy/paste perhaps):
>
>Raul’s functions:
>D=:[: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]
>pmt1200=:(%<:)@D * 1 0 1 */ .# ]
>pmt=: pmt1200@(%&1200 1 1)
>pmt 5.75 240 12500
>87.7604
>
>My revised input for 13 : is also included here, as I had a mis-copy
>there too.
>Da=:13 : '(^~ >:)/ (2 3$0 1 0 1 0 0) +/ .*
> y’  NB. Removed the leading [: as not
> required for explicit (I could have left it in,  but I’m trying to
>exactly reproduce Raul’s  tacit definitions above), and added last
>term y to the explicit expression
>pmt1200a=: 13 : '((%<:)@Da y) * 1 0 1 */ .#
> y’   NB. Added last term y to the first and
> last “tine” of the fork Raul produced
>pmta=: 13 : 'pmt1200a@(%&1200 1 1)
> y’  NB. Added last term y (although
> this is not required as composition can be  ap

Re: [Jprogramming] Tacit form: How to handle intermediate

2018-09-13 Thread Martin Kreuzer
 1 0 1 */ .# 
y’ NB. Added last term y
>   pmta=: 13 : 'pmt1200@(%&1200 1 1) 
y’ NB. Added last term y 
(although this is not required as composition 
can be applied directly as Raul did) without requiring explicit)

>
> NB. Let’s compare to Raul’s solution in email below ...
>   Da
> [: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* 
]NB. Same definition as Raul

>   pmt1200a
> [: (% <:)@Da [: * 1 0 1 */ .# 
]  NB. Same

>   pmta
> pmt1200@(%&1200 1 1)
>  pmta 5.75 240 12500
> 87.7604
>
> HTH but if still unclear please expand ?
>
> For further reference re [: only having 
meaning in tacit form (which is why I removed 
it for explicit form) it may be helpful to read this link:

>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcode
> .jsoftware.com%2Fwiki%2FVocabulary%2Fsquarelfcodata=02%7C01%7C%7C
> c059f09bd6fc424708d61928c374%7C84df9e7fe9f640afb435%7C
> 1%7C0%7C636724060199447363sdata=OrnLHRv1N%2Fe5lnADLmIGobGEQkw5kxY
> mbnHMVx84AIs%3Dreserved=0
> 
<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcod> 
e.jsoftware.com%2Fwiki%2FVocabulary%2Fsquarelfcodata=02%7C01%7C%7

> Cc059f09bd6fc424708d61928c374%7C84df9e7fe9f640afb435%7
> C1%7C0%7C636724060199447363sdata=OrnLHRv1N%2Fe5lnADLmIGobGEQkw5kx
> YmbnHMVx84AIs%3Dreserved=0>
>
> Thanks, Rob
>
>
>> On 13 Sep 2018, at 1:05 am, Linda Alvord 
 wrote:

>>
>>
>>
>> When you'e're done f=: 13  :'...
>>
>> enter
>> f
>>
>> If the result is tacit there will be no x or 
y.  Instead you get a string of  separate J 
symbols which J uses from right to left to follow your instructions.

>>
>> I need a laptop to check. Raul's function.
>>
>> Linda
>>
>>
>>
>> '
>>
>> Sent from my Verizon, Samsung Galaxy smartphone
>>  Original message 
>> From: Raul Miller > <mailto:rauldmil...@gmail.com>>
>> Date: 9/10/18 12:55 AM (GMT-05:00)
>> To: Programming forum > <mailto:programm...@jsoftware.com>>
>> Subject: Re: [Jprogramming] Tacit form: How to handle intermediate
>>
>> x=:0 is bad form, so I am going to ignore that part.
>>
>> In fact, I'd eliminate all internal =: from 
that definition and start with:

>>
>> pmt=: 3 : 0
>> 0 pmt y
>> :
>> 'r t b'=. y
>> D=.(1 + r % 1200) ^ t
>> b*(r % 1200) * D % D - 1
>> )
>>
>> And our paranoia test is:
>>  pmt 5.75 240 12500
>> 87.7604
>>
>> The next issue is that we're working with more than two values, that
>> makes it a bit complicated.
>>
>> On the other hand, we never use x - if it's provide we ignore it. So
>> I'm going to ignore it here. If that bothers you, use pmt=: pmt&] f.
>> after we've got the tacit expression. (Using f. on the final
>> expression will also protect from some damage if you happen to run
>> the original with it's D=: expression...).
>>
>> Anyways...
>>
>> To simplify this slightly, notice that we never want to use the value
>> of r. Instead, we always want r%1200. So we can divide y by 1200 1 1
>> and work the remainder of the dyadic expression becomes:
>>
>> pmt1200=: 3 : 0
>> 'r t b'=. y
>> D=.(1 + r) ^ t
>> b*r * D % D - 1
>> )
>>
>> A tacit expression to compute D directly from this y would be:
>>  D=:  [: (^~ >:)/ (2 3$0 1 0 1 0 0) +/ .* ]
>>
>> with that definition of D, pmt1200 can be
>>  pmt1200 =: (%<:)@D * 1 0 1 */ .# ]
>>
>> and our tacit pmt becomes
>>  pmt=: pmt1200@(%&1200 1 1)
>>
>> Trying it out:
>>  pmt 5.75 240 12500
>> 87.7604
>>
>> Good enough?
>>
>> --
>> Raul
>> On Sun, Sep 9, 2018 at 9:55 PM Linda Alvord 
mailto:lindaalvor...@outlook.com>> wrote:

>>>
>>> Here's a classic. Can anyone write this in tacit?
>>>
>>> NB. Mortgage is Rate Months Loan
>>>
>>> pmt=: 3 : 0
>>> (x =: 0) pmt y
>>> :
>>> 'r t b'=:y
>>> D=:(1 + r % 1200) ^ t
>>> b*(r % 1200) * D % D - 1
>>> )
>>>
>>> pmt 5.75 240 12500
>>>
>>> In 1961 I bought a house for $17,000. With 
a loan of $12,000 at 5.75 interest for 20 
years. As a tenured teacher and a woman no bank 
would give me a mortgage but for 20 years I 
payed the previous woman owner $87.77. At the 
last payment it just so happened that I sold it.

>>>
>>> Linda
>>>
>>> -Original

Re: [Jprogramming] Tacit form: How to handle intermediate

2018-09-08 Thread Martin Kreuzer

@Linda

I think that your
   heron=: 13 :'%:*/(s y),(s y)-y'
looks superior to my initial approach as
it gathers _all four_ factors under the (*/) Times Insert.

btw "Hope you have good classes!"

For quite some time, I don't have classes any 
more, but once in a while do private tutoring; my 
last two students finished their 'matura' at 
Easter this year (and one of them is on 'work & 
travel' in New Zealand presently).


@Mike

Looking at your 'minor change' and the resulting 
tacit code, methinks that (sy=. s - y) is giving 
the interpreter a much stronger hint that there's 
a re-used intemediate result than the construct 
(' ... [ s2=.  ') I used initially.


-M

At 2018-09-07 09:43, you wrote:

Fair enough,  it looks neat,  but doesn't deal 
with Martin Kreuzer's original requirement to apply

s just the once, ie how should we handle the intermediate result, s?

On the other hand, David Lambert and others 
propose variations on how to factor the formula so

as to use the result of s.

It's usually easy in explicit form,  harder in 
tacit form.  It seems to me that using 13 : ... is very
helpful in developing a tacit form,  but it 
often fails to spot opportunities to save intermediate
results.  13 : ... isn't an optimising compiler 
- or is it? It certainly doesn't spot the opportunity

to save the repeated (s y) in Linda's example.

Somewhat to my surprise,  a minor change to 
Linda's explicit expression does result in a

single applicaton of s in a quite elegant tacit form:

    herona=: 13 :'%:*/sy,(sy=.s y)-y'

    herona 3 4 5



    herona 5 12 13

30

    herona

[: %: [: */ s ([ , -) ]


Cheers,

Mike

On 07/09/2018 08:19, Linda Alvord wrote:

It keeps getting simpler:



s=: 13 :'-:+/y'
heron=: 13 :'%:*/(s y),(s y)-y'
heron 3 4 5
heron 4 5 6
d




;:'[: -: +/'



heron



;:'[: %: [: */ s , s - ]'



Explisit sentences are like English and the new 
language is the computers J anguage.  First 
learn the words and then learn to read ghe ords 
in sentences. And just as you might when 
learning Spanish, you might in time begin to speak it.



Linda




-Original Message-
From: Programming 
 On Behalf Of David Lambert

Sent: Thursday, September 6, 2018 6:11 PM
To: programming 
Subject: Re: [Jprogramming] Tacit form: How to handle intermediate



A hook can save recomputation.



(computation with original data and reused me)Â  (resuse me)




  Â Â  test=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]



  Â Â  NB. play with the half factor
  Â Â  f=:Â Â Â  4 %~ [: %: [: */ (([ , (- +:))~ +/)



  Â Â  NB. shorter



     NB.    c o m p u t a t i o n    r e u s e
  Â Â  g=:Â Â Â  ([: %: [: */ [ , -)~Â Â Â Â  ([: -: +/)



  Â Â  g2=:Â Â  ([: %: [: */ [ , -)~ -:@:(+/)




  Â Â  %/ (g , test) 3?@:$0
1




On 09/04/2018 08:00 AM, programming-requ...@forums.jsoftware.com wrote:

Date: Tue, 04 Sep 2018 11:50:43 +0000
From: Martin Kreuzer To:programm...@jsoftware.com
Subject: [Jprogramming] Tacit form: How to handle intermediate
result..?
Message-ID:
<5b8e71a5.1c69fb81.65e5c.4a9esmtpin_added_miss...@mx.google.com>
Content-Type: text/plain; charset="us-ascii"; format=flowed

Hi all -

To calculate the area of a flat triangle, using Heron's formula,
A(a,b,c)= sqrt( s2*(s2-a)*(s2-b)*(s2-c) ) I wrote a simple function
doing this:

* get the three sides (as list input y)
* compute the half  perimeter s2
* build the differences s2-y
* build product
* take square root

My explicit solution looks like this

taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'

and works

  taher 3 4 5
6

Suggested tacit version looks like this (and works too)

tahert=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]

Q: Is there a way to reference the intermediate result of ([: -: +/)
the half perimeter s2 within the tacit expression, as has been done in
the explicit..?
[Guess the interpreter takes care of this anyway; my question aims at
whether a shorter formulation could be reached.]

Thanks
-M

--
For information about J forums see 
https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htmdata=02%7C01%7C%7C8d2147240443485c7f8c08d61445ac18%7C84df9e7fe9f640afb435%7C1%7C0%7C636718686798916834sdata=Yuys8QE3yMvBtUraCohR9dRgPugZDeNaNh3BoBCzJjU%3Dreserved=0

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




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-07 Thread Martin Kreuzer

@Louis

I must admit  that I had forgotten about (or even 
never heard of) Brahmagupta's formula for the area of a cyclic quadrilateral.
Treating Heron's formula as a special case of the 
former makes indeed an elegant solution.

Thanks for pointing that out.

-M

At 2018-09-05 01:25, you wrote:

I sent this message earlier today, but it seems 
that I used the wrong email address. I didn’t 
find it in the forum archives; sorry if it comes in twice.

I see that most of what I said has since been covered by Mike.

~~~

I would’ve done it this way; the 
semi-perimeter is not stored, but rather passed 
through the subtraction by subtracting 0.


   H=: [: %: -:@(+/) */ . - ,&0
   H 3 4 5


Heron’s formula is in fact a special case the 
more general Brahmagupta formula for calculating 
the area of a quadrilateral with sides a b c d inscribed in a circle:


A = sqrt( (s-a)(s-b)(s-c)(s-d) )

and a triangle is a quadrilateral with one side 
of length 0, and is always inscribed in a circle.

This formula I would implement like this:

   A=: %:@(*/ . -~ [: -: +/)
   A 1 1 1 1

   A 2 2 2 2

   A 3 4 5 0


In the last example of the same triangle as 
before, the semi-perimeter is effectively passed 
through the subtraction, inspiring the definition of H.


Louis

> On 4 Sep 2018, at 13:50, Martin Kreuzer  wrote:
>
> Hi all -
>
> To calculate the area of a flat triangle, using Heron's formula,
> A(a,b,c)= sqrt( s2*(s2-a)*(s2-b)*(s2-c) )
> I wrote a simple function doing this:
>
> * get the three sides (as list input y)
> * compute the half  perimeter s2
> * build the differences s2-y
> * build product
> * take square root
>
> My explicit solution looks like this
>
> taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'
>
> and works
>
>   taher 3 4 5
> 6
>
> Suggested tacit version looks like this (and works too)
>
> tahert=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]
>
> Q: Is there a way to reference the 
intermediate result of ([: -: +/) the half perimeter s2

> within the tacit expression, as has been done in the explicit..?
> [Guess the interpreter takes care of this 
anyway; my question aims at whether a shorter formulation could be reached.]

>
> Thanks
> -M
>
> --
> 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

Re: [Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-07 Thread Martin Kreuzer

@Martin

At 2018-09-04 20:34, you wrote:


What *does* matter is that using such auxiliary functions is *good*.
Eugene McDonnell was a great teacher demonstrating elegant, readable
code composed out of useful little parts.


Thanks for the reminder and encouragement -- I now remember having 
had private libraries ('Units' in Pascal) full of 're-usable' software modules.

And thanks for the fork-to-hook lesson.

-M 


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

Re: [Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-07 Thread Martin Kreuzer

@Michael

Thanks -- yes, I do ...
(And coincidentally, it's along the same lines as 
Mike day's 2nd suggestion a day later.)


-M

At 2018-09-04 14:06, you wrote:


Did you mean something like this?

   f=: -:@(+/) %:@([* */@:-) ]
   f 3 4 5



On Tue, Sep 4, 2018, 10:01 AM Raul Miller,  wrote:

> I was about to suggest something similar:

>13 : '(%: x * */ x-y)'
> [: %: [ * [: */ -
>13 : '(%: y * */ y-x)'
> [: %: ] * [: */ -~
>13 :'y ([: %: ] * [: */ -~)-:+/y'
> ] ([: %: ] * [: */ -~) [: -: +/
>taher=: ] ([: %: ] * [: */ -~) [: -: +/
>taher 3 4 5
> 6

> Variations are possible, of course. For example:
>taher=: %:@(] * +/@:-~) +/@:-:

> Thanks,

> --
> Raul
> On Tue, Sep 4, 2018 at 9:46 AM 'Mike Day' via Programming
>  wrote:
> >
> > Does this help?
> > Each line is a small amendment to the preceding one...
> >(-:@(+/))3 4 5NB. Semiperimeter, s
> > 6
> >(-:@(+/)-0&,)3 4 5  NB. s - 0, a, b, c
> > 6 3 2 1
> >(-:@(+/)*/@:-0&,)3 4 5  NB.  s * (s - a) * ...
> > 36
> >(-:@(+/)%:@(*/)@:-0&,)3 4 5  NB. Heron’s formula applied to 3 4 5
> > 6
> >(-:@(+/)%:@(*/)@:-0&,)  NB. Let interpreter remove unnecessary
> brackets...
> > -:@(+/) %:@(*/)@:- 0&,
> > So the semiperimeter is calculated just the once.  It relies on
> converting the triplet a,b,c to the quadruplet 0, a, b, c,  rather than
> doing particularly smart bracketing.
> >
> > I don’t often use  [: but if you prefer 
it,  the following arises from a

> similar building process using [: rather than @ and @:
> >
> >   ([:-:(+/))3 4 5
> > 6
> >(([:-:(+/)) - 0&,)3 4 5
> > 6 3 2 1
> >(([:-:(+/))( [: */ - )0&,)3 4 5
> > 36
> >(([:-:(+/))( [: %: [: */ - )0&,)3 4 5
> > 6
> >(([:-:(+/))( [: %: [: */ - )0&,)  NB. Get rid of extra brackets
> > ([: -: +/) ([: %: [: */ -) 0&,
> >
> > Cheers,
> > Mike
> >
> >
> >
> > Sent from my iPad
> >
> > > On 4 Sep 2018, at 12:50, Martin Kreuzer  wrote:
> > >
> > > Hi all -
> > >
> > > To calculate the area of a flat triangle, using Heron's formula,
> > > A(a,b,c)= sqrt( s2*(s2-a)*(s2-b)*(s2-c) )
> > > I wrote a simple function doing this:
> > >
> > > * get the three sides (as list input y)
> > > * compute the half  perimeter s2
> > > * build the differences s2-y
> > > * build product
> > > * take square root
> > >
> > > My explicit solution looks like this
> > >
> > > taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'
> > >
> > > and works
> > >
> > >   taher 3 4 5
> > > 6
> > >
> > > Suggested tacit version looks like this (and works too)
> > >
> > > tahert=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]
> > >
> > > Q: Is there a way to reference the intermediate result of ([: -: +/)
> the half perimeter s2
> > > within the tacit expression, as has been done in the explicit..?
> > > [Guess the interpreter takes care of this anyway; my question aims at
> whether a shorter formulation could be reached.]
> > >
> > > Thanks
> > > -M
> > >
> > > --
> > > 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


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

Re: [Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-06 Thread Martin Kreuzer

@Rob

Thanks for the patient clarification ...

I should have seen this (if I had been more persistent :) by comparing

   3,4,5 -: 3 4 5
3 4 0

with

   (3,4,5) -: 3 4 5
1

-M



At 2018-09-06 06:28, you wrote:


Martin, this is normal evaluation of Noun Verb Noun Verb Noun Verb …

Consider:

 100 200 300+1NB. The â“literal” 
100 200 3000 is identified as a single noun of 
3 numbers, so this is parsed as NOUN VERB NOUN

101 201 301

 100,200,300+1.   NB. This is identified as 
Noun VERB Noun VERB Noun VERB Noun, and 
evaluated as normal (what appears right to left)

100 200 301


Breaking down your example 3,4,5 (4 : ‘y-x) 6

 5 (4 : 'y-x') 6

 4,5 (4 : 'y-x') 6.  NB. Here 4 is catenated to the result of the above
4 1
 3,4,5 (4 : 'y-x') 6.  NB: Here 3 is catenated to the result of above
3 4 1

You will require ( ) to do the catenations first 
if you have them to the left of the (4: verb)

   (3,4,5) (4 : 'y-x') 6
3 2 1

Cheers, Rob

> On 6 Sep 2018, at 4:09 pm, Martin Kreuzer  wrote:
>
> @Raul
>
> Thanks - it has been very enlightening to see 
the expression to grow 'more' tacit from line to line ...

>
> I went through it (line by line) and stumbled upon this issue:
>
> Until now I thought that
>
>   3 4 5 -: 3,4,5
> 1
>
> giving identical results in subtraction
>
>   6 - 3 4 5
> 3 2 1
>   6 - 3,4,5
> 3 2 1
>
> I then wrapped that into a function (still giving identical results)
>
>   6 (4 : 'x-y') 3 4 5
> 3 2 1
>   6 (4 : 'x-y') 3,4,5
> 3 2 1
>
> but not with reverse order
>
>   3 4 5 (4 : 'y-x') 6
> 3 2 1
>   3,4,5 (4 : 'y-x') 6
> 3 4 1
>
> This I do not understand ...
>
> -M
>
>
>
>
> At 2018-09-04 14:00, you wrote:
>
>> I was about to suggest something similar:
>>
>>   13 : '(%: x * */ x-y)'
>> [: %: [ * [: */ -
>>   13 : '(%: y * */ y-x)'
>> [: %: ] * [: */ -~
>>   13 :'y ([: %: ] * [: */ -~)-:+/y'
>> ] ([: %: ] * [: */ -~) [: -: +/
>>   taher=: ] ([: %: ] * [: */ -~) [: -: +/
>>   taher 3 4 5
>>
>>
>> Variations are possible, of course. For example:
>>   taher=: %:@(] * +/@:-~) +/@:-:
>>
>> Thanks,
>>
>> --
>> Raul
>> On Tue, Sep 4, 2018 at 9:46 AM 'Mike Day' via Programming
>>  wrote:
>>
>> > Does this help?
>> > Each line is a small amendment to the preceding one...
>> >(-:@(+/))3 4 5NB. Semiperimeter, s
>> > 6
>> >(-:@(+/)-0&,)3 4 5  NB. s - 0, a, b, c
>> > 6 3 2 1
>> >(-:@(+/)*/@:-0&,)3 4 5  NB.  s * (s - a) * ...
>> > 36
>> >(-:@(+/)%:@(*/)@:-0&,)3 4 5  NB. 
Heron’s formula applied to 3 4 5

>> > 6
>> >(-:@(+/)%:@(*/)@:-0&,)  NB. Let 
interpreter remove unnecessary brackets...

>> > -:@(+/) %:@(*/)@:- 0&,
>> > So the semiperimeter is calculated just 
the once.  It relies on converting the triplet 
a,b,c to the quadruplet 0, a, b, c,  rather 
than doing particularly smart bracketing.

>>
>> > I don’t often use  [: but if you 
prefer it,  the following arises from a similar 
building process using [: rather than @ and @:

>>
>> >   ([:-:(+/))3 4 5
>> > 6
>> >(([:-:(+/)) - 0&,)3 4 5
>> > 6 3 2 1
>> >(([:-:(+/))( [: */ - )0&,)3 4 5
>> > 36
>> >(([:-:(+/))( [: %: [: */ - )0&,)3 4 5
>> > 6
>> >(([:-:(+/))( [: %: [: */ - )0&,)  NB. Get rid of extra brackets
>> > ([: -: +/) ([: %: [: */ -) 0&,
>>
>> > Cheers,
>> > Mike
>>
>>
>>
>> > Sent from my iPad
>>
>> > > On 4 Sep 2018, at 12:50, Martin Kreuzer  wrote:
>> > >
>> > > Hi all -
>> > >
>> > > To calculate the area of a flat triangle, using Heron's formula,
>> > > A(a,b,c)= sqrt( s2*(s2-a)*(s2-b)*(s2-c) )
>> > > I wrote a simple function doing this:
>> > >
>> > > * get the three sides (as list input y)
>> > > * compute the half  perimeter s2
>> > > * build the differences s2-y
>> > > * build product
>> > > * take square root
>> > >
>> > > My explicit solution looks like this
>> > >
>> > > taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'
>> > >
>> > > and works
>> > >
>> > >   taher 3 4 5
>> > > 6
>> > >
>> > > Suggested tacit version looks like this (and works too)
>> > >
>> > > tahert=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]
>> > >
>> > > Q: Is there a

Re: [Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-06 Thread Martin Kreuzer

@Raul

Thanks - it has been very enlightening to see the 
expression to grow 'more' tacit from line to line ...


I went through it (line by line) and stumbled upon this issue:

Until now I thought that

   3 4 5 -: 3,4,5
1

giving identical results in subtraction

   6 - 3 4 5
3 2 1
   6 - 3,4,5
3 2 1

I then wrapped that into a function (still giving identical results)

   6 (4 : 'x-y') 3 4 5
3 2 1
   6 (4 : 'x-y') 3,4,5
3 2 1

but not with reverse order

   3 4 5 (4 : 'y-x') 6
3 2 1
   3,4,5 (4 : 'y-x') 6
3 4 1

This I do not understand ...

-M




At 2018-09-04 14:00, you wrote:


I was about to suggest something similar:

   13 : '(%: x * */ x-y)'
[: %: [ * [: */ -
   13 : '(%: y * */ y-x)'
[: %: ] * [: */ -~
   13 :'y ([: %: ] * [: */ -~)-:+/y'
] ([: %: ] * [: */ -~) [: -: +/
   taher=: ] ([: %: ] * [: */ -~) [: -: +/
   taher 3 4 5


Variations are possible, of course. For example:
   taher=: %:@(] * +/@:-~) +/@:-:

Thanks,

--
Raul
On Tue, Sep 4, 2018 at 9:46 AM 'Mike Day' via Programming
 wrote:

> Does this help?
> Each line is a small amendment to the preceding one...
>(-:@(+/))3 4 5NB. Semiperimeter, s
> 6
>(-:@(+/)-0&,)3 4 5  NB. s - 0, a, b, c
> 6 3 2 1
>(-:@(+/)*/@:-0&,)3 4 5  NB.  s * (s - a) * ...
> 36
>(-:@(+/)%:@(*/)@:-0&,)3 4 5  NB. Heron’s formula applied to 3 4 5
> 6
>(-:@(+/)%:@(*/)@:-0&,)  NB. Let 
interpreter remove unnecessary brackets...

> -:@(+/) %:@(*/)@:- 0&,
> So the semiperimeter is calculated just the 
once.  It relies on converting the triplet 
a,b,c to the quadruplet 0, a, b, c,  rather 
than doing particularly smart bracketing.


> I don’t often use  [: but if you prefer 
it,  the following arises from a similar 
building process using [: rather than @ and @:


>   ([:-:(+/))3 4 5
> 6
>(([:-:(+/)) - 0&,)3 4 5
> 6 3 2 1
>(([:-:(+/))( [: */ - )0&,)3 4 5
> 36
>(([:-:(+/))( [: %: [: */ - )0&,)3 4 5
> 6
>(([:-:(+/))( [: %: [: */ - )0&,)  NB. Get rid of extra brackets
> ([: -: +/) ([: %: [: */ -) 0&,

> Cheers,
> Mike



> Sent from my iPad

> > On 4 Sep 2018, at 12:50, Martin Kreuzer  wrote:
> >
> > Hi all -
> >
> > To calculate the area of a flat triangle, using Heron's formula,
> > A(a,b,c)= sqrt( s2*(s2-a)*(s2-b)*(s2-c) )
> > I wrote a simple function doing this:
> >
> > * get the three sides (as list input y)
> > * compute the half  perimeter s2
> > * build the differences s2-y
> > * build product
> > * take square root
> >
> > My explicit solution looks like this
> >
> > taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'
> >
> > and works
> >
> >   taher 3 4 5
> > 6
> >
> > Suggested tacit version looks like this (and works too)
> >
> > tahert=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]
> >
> > Q: Is there a way to reference the 
intermediate result of ([: -: +/) the half perimeter s2

> > within the tacit expression, as has been done in the explicit..?
> > [Guess the interpreter takes care of this 
anyway; my question aims at whether a shorter formulation could be reached.]

> >
> > Thanks
> > -M
> >
> > --
> > 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

Re: [Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-04 Thread Martin Kreuzer

@Mike

Yes, it does help, as
it is a sort of eye-opener, rephrasing the fourth factor (s) as (s-0), and
it answers my (yet un-uttered) question about "m14".

-M


At 2018-09-04 13:46, 'Mike Day' via Programming wrote:


Does this help?
Each line is a small amendment to the preceding one...
   (-:@(+/))3 4 5NB. Semiperimeter, s

   (-:@(+/)-0&,)3 4 5  NB. s - 0, a, b, c
6 3 2 1
   (-:@(+/)*/@:-0&,)3 4 5  NB.  s * (s - a) * ...
36
   (-:@(+/)%:@(*/)@:-0&,)3 4 5  NB. Heron’s formula applied to 3 4 5

   (-:@(+/)%:@(*/)@:-0&,)  NB. Let interpreter remove unnecessary brackets...
-:@(+/) %:@(*/)@:- 0&,
So the semiperimeter is calculated just the 
once.  It relies on converting the triplet a,b,c 
to the quadruplet 0, a, b, c,  rather than doing particularly smart bracketing.


I don’t often use  [: but if you prefer 
it,  the following arises from a similar 
building process using [: rather than @ and @:


  ([:-:(+/))3 4 5

   (([:-:(+/)) - 0&,)3 4 5
6 3 2 1
   (([:-:(+/))( [: */ - )0&,)3 4 5
36
   (([:-:(+/))( [: %: [: */ - )0&,)3 4 5

   (([:-:(+/))( [: %: [: */ - )0&,)  NB. Get rid of extra brackets
([: -: +/) ([: %: [: */ -) 0&,

Cheers,
Mike



Sent from my iPad

> On 4 Sep 2018, at 12:50, Martin Kreuzer  wrote:
>
> Hi all -
>
> To calculate the area of a flat triangle, using Heron's formula,
> A(a,b,c)= sqrt( s2*(s2-a)*(s2-b)*(s2-c) )
> I wrote a simple function doing this:
>
> * get the three sides (as list input y)
> * compute the half  perimeter s2
> * build the differences s2-y
> * build product
> * take square root
>
> My explicit solution looks like this
>
> taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'
>
> and works
>
>   taher 3 4 5
> 6
>
> Suggested tacit version looks like this (and works too)
>
> tahert=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]
>
> Q: Is there a way to reference the 
intermediate result of ([: -: +/) the half perimeter s2

> within the tacit expression, as has been done in the explicit..?
> [Guess the interpreter takes care of this 
anyway; my question aims at whether a shorter formulation could be reached.]

>
> Thanks
> -M
>
> --
> 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

Re: [Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-04 Thread Martin Kreuzer

@Cliff

Yes - I got a tacit form, and have been wondering
whether there is a way to avoid
the repetition of ([: -: +/) ...

-M


At 2018-09-04 12:51, you wrote:


Your 13 created a tacit verb

   taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'
   taher
[: %: ([: -: +/) * [: */ ([: -: +/) - ]


On 9/4/2018 7:50 AM, Martin Kreuzer wrote:

Hi all -



To calculate the area of a flat triangle, using Heron's formula,
A(a,b,c)= sqrt( s2*(s2-a)*(s2-b)*(s2-c) )
I wrote a simple function doing this:



* get the three sides (as list input y)
* compute the half  perimeter s2
* build the differences s2-y
* build product
* take square root



My explicit solution looks like this



taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'



and works



   taher 3 4 5
6



Suggested tacit version looks like this (and works too)



tahert=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]


Q: Is there a way to reference the intermediate 
result of ([: -: +/) the half perimeter s2

within the tacit expression, as has been done in the explicit..?
[Guess the interpreter takes care of this 
anyway; my question aims at whether a shorter formulation could be reached.]



Thanks
-M



--
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

Re: [Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-04 Thread Martin Kreuzer

@Bo

Went step by step through that biquadratic function ...
and understoodits components.
Was totally unaware of that formula (shame on me);
could you cite a source, that sounds like an interesting book..?

-M

At 2018-09-04 12:24, you wrote:



   ([: %&4 [: %: *:@:(+/@:^)&2 - +:@:(+/@:^)&4)  3 4 5




As the square of the area of a triangle is a 
symmetric polynomial of the squares of the 
sides, the above tacit code also works.Â
   Den tirsdag den 4. september 2018 13.51.07 
CEST skrev Martin Kreuzer :


 Hi all -

To calculate the area of a flat triangle, using Heron's formula,
A(a,b,c)= sqrt( s2*(s2-a)*(s2-b)*(s2-c) )
I wrote a simple function doing this:

* get the three sides (as list input y)
* compute the half  perimeter s2
* build the differences s2-y
* build product
* take square root

My explicit solution looks like this

taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'

and works

    taher 3 4 5


Suggested tacit version looks like this (and works too)

tahert=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]

Q: Is there a way to reference the intermediate result of ([: -: +/)
the half perimeter s2
within the tacit expression, as has been done in the explicit..?
[Guess the interpreter takes care of this anyway; my question aims at
whether a shorter formulation could be reached.]

Thanks
-M

--
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

[Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-04 Thread Martin Kreuzer

Hi all -

To calculate the area of a flat triangle, using Heron's formula,
A(a,b,c)= sqrt( s2*(s2-a)*(s2-b)*(s2-c) )
I wrote a simple function doing this:

* get the three sides (as list input y)
* compute the half  perimeter s2
* build the differences s2-y
* build product
* take square root

My explicit solution looks like this

taher=: 13 : '%: s2 * */ s2-y [ s2=. -: +/ y'

and works

   taher 3 4 5
6

Suggested tacit version looks like this (and works too)

tahert=: [: %: ([: -: +/) * [: */ ([: -: +/) - ]

Q: Is there a way to reference the intermediate result of ([: -: +/) 
the half perimeter s2

within the tacit expression, as has been done in the explicit..?
[Guess the interpreter takes care of this anyway; my question aims at 
whether a shorter formulation could be reached.]


Thanks
-M

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

Re: [Jprogramming] Tacit form: Where to put the start value..?

2018-08-09 Thread Martin Kreuzer

On this machine

   JVERSION
Engine: j805/j32/windows
Release: commercial/2016-12-11T08:03:59
Library: 8.05.10
Platform: Win 32
Installer: J805 install
InstallPath: e:/program files (non-sys)/j805
Contact: www.jsoftware.com

and as well

   JVERSION
Engine: j807/j32/windows
Beta-g: commercial/2018-07-02T18:12:05
Library: 8.07.16
Platform: Win 32
Installer: J807 install
InstallPath: e:/program files (non-sys)/j807
Contact: www.jsoftware.com

-M

At 2018-08-09 12:38, you wrote:


There was no warning that negative numbers were not allowed.
Especially considering that the "equivalent" phrase accommodates a negative
number.

   +:^:_5 (1)

0.03125
   _5(+:@[&0)1
|domain error
|   _5(+:@[&0)1


http://www.jsoftware.com/help/dictionary/d630n.htm
   JVERSION
Engine: j807/j64/darwin
Beta-f: commercial/2018-06-28T12:14:57
Library: 8.07.16
Platform: Darwin 64
Installer: J807 install
InstallPath: /users/brian/j64-807
Contact: www.jsoftware.com


On Thu, Aug 9, 2018 at 6:03 AM, Martin Kreuzer  wrote:

> ** Brian

> Took your hint and managed to put together a named verb which does work
> even for lists

>p=. 13 : '1(+:@[&0)~y'
>p i.5
> 1 2 4 8 16
>pt=. 1 (+:@[&0)~ ]
>pt i.5
> 1 2 4 8 16

> but for some reason not for negative arguments ..

>p -i.5
> |domain error: p
> |   p-i.5

> -M



> --
(B=)
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] Tacit form: Where to put the start value..?

2018-08-09 Thread Martin Kreuzer

First of all, I have been careless with the suggested verbs p1, p2 insofar as

   (%~)i.5
0 1 1 1 1
   (*)i.5
0 1 1 1 1

the "circumlocutions" (did learn this new word along the way) give 
the wrong result for argument zero (as Martin cautiously pointed out).


-- begin of sidestep
Came up with a circumlocution which *does* work alright :)
   (+:^:(]`(2@-~))"0) -i.5
1 0.5 0.25 0.125 0.0625
-- end of  sidestep

So far, I gathered these three verbs:

   (+:^:(]`1:)) -i.5
1 0.5 0.25 0.125 0.0625
   (+:@]^:[&1) -i.5
1 0.5 0.25 0.125 0.0625
   (+:@]^:[1:) -i.5
1 0.5 0.25 0.125 0.0625

** Raul

You're right, of course; sorry for my sloppy remark - was simply 
trying to express the fact that I'm still far from being safe & sure 
using ([) and (]); sometimes I get it right (mostly by experimenting).
What confuses me with this is that  (]) references a verb (1:) inside 
the parentheses while the other ([) refers to the argument outside.

Which brings me to

** Pascal

Hooks: I've seen, written and understood basic ones, like e.g. 
"scale" (%<./) or "eval cf" (+%)/ but alas failed to recognize it in this case.


I've some idea why this dyad
   5 (+:@]^:[) 1
 works, but am unable to follow/ describe/ argue about/ substantiate 
the steps leading to the final monad

   (+:@]^:[1:) 5

-M


At 2018-08-07 22:22, you wrote:


In
(+:@]^:[ 1:) 5

The ] gives the value 1 and the [ gives the value 5.

There are other contexts where they can give the same value ([@]0
being an example of that), but I don't think we're talking about that
here?

Thanks,

--
Raul

On Tue, Aug 7, 2018 at 5:54 PM Martin Kreuzer  wrote:

> Martin -

> Good to see you back once in a while :)

> Have been brooding over this for quite some time.

> Using (1:) seems like cheating, but ... (as you pointed out) there
> are benefits.

> I'm still puzzled by the use of (]) and ([) at the same time for the
> same argument  (I remember Raul giving me some treatment on that
> subject some years ago).

> Anyway, I think this thread has produced enough information to enable
> me to put some example on the wiki ... (will hopefully get around to
> it next weekend).

> Thanks for the discussion, and all the best.

> -M


> At 2018-08-07 18:00, you wrote:

> >Hi Martin!
> >
> > >(+:^:(]`(%~))) 5
> > >32
> > >(+:^:(]`*)) 5
> > >32
> >
> >The good old Constant function 1: will give you the benefits of
> >less circumlocution, better results for non-positive arguments,
> >and coverage of array arguments:
> >
> >+:^:(]`1:)  (,: -) 0 1 2 5
> > 1   24  32
> > 1 0.5 0.25 0.03125
> >
> >A nice puzzle, BTW.  I was only capable to get to
> >
> >(+:@]^:[ 1:) 5
> > 32
> >
> >on my own, ignorant of the gerund option.
> >
> > Martin (the other one)
> >--
> >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

Re: [Jprogramming] Tacit form: Where to put the start value..?

2018-08-09 Thread Martin Kreuzer

** Brian

Took your hint and managed to put together a named verb which does 
work even for lists


   p=. 13 : '1(+:@[&0)~y'
   p i.5
1 2 4 8 16
   pt=. 1 (+:@[&0)~ ]
   pt i.5
1 2 4 8 16

but for some reason not for negative arguments ..

   p -i.5
|domain error: p
|   p-i.5

-M


At 2018-08-07 15:04, you wrote:


http://www.jsoftware.com/help/dictionary/d630n.htm

at the bottom suggests another approach using

x f@[&0 y

On Tue, Aug 7, 2018 at 9:55 AM, Henry Rich  wrote:

> https://code.jsoftware.com/wiki/Vocabulary/hatco#Gerund_n

> Henry Rich



--
(B=)
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] Tacit form: Where to put the start value..?

2018-08-07 Thread Martin Kreuzer

Martin -

Good to see you back once in a while :)

Have been brooding over this for quite some time.

Using (1:) seems like cheating, but ... (as you pointed out) there 
are benefits.


I'm still puzzled by the use of (]) and ([) at the same time for the 
same argument  (I remember Raul giving me some treatment on that 
subject some years ago).


Anyway, I think this thread has produced enough information to enable 
me to put some example on the wiki ... (will hopefully get around to 
it next weekend).


Thanks for the discussion, and all the best.

-M


At 2018-08-07 18:00, you wrote:


Hi Martin!

>(+:^:(]`(%~))) 5
>32
>(+:^:(]`*)) 5
>32

The good old Constant function 1: will give you the benefits of
less circumlocution, better results for non-positive arguments,
and coverage of array arguments:

   +:^:(]`1:)  (,: -) 0 1 2 5
1   24  32
1 0.5 0.25 0.03125

A nice puzzle, BTW.  I was only capable to get to

   (+:@]^:[ 1:) 5
32

on my own, ignorant of the gerund option.

Martin (the other one)
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] Tacit form: Where to put the start value..?

2018-08-07 Thread Martin Kreuzer

Brian -
Sorry - have missed your post (as you were active also on another 
thread) - let me sleep it over ...

-M


At 2018-08-07 15:04, you wrote:


http://www.jsoftware.com/help/dictionary/d630n.htm

at the bottom suggests another approach using

x f@[&0 y

On Tue, Aug 7, 2018 at 9:55 AM, Henry Rich  wrote:

> https://code.jsoftware.com/wiki/Vocabulary/hatco#Gerund_n

> Henry Rich



--
(B=)
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] Tacit form: Where to put the start value..?

2018-08-07 Thread Martin Kreuzer

** Henry, thank you very much, as that answered my question.

(Went through that very section this morning and 
remember disregarding it simply because of the 
string example, and didn't even catch the fact 
that there is the monadic case mentioned. - 
Probably effect of African heat wave.)

Anyway, here's what I did, for the record:

u^:(v1 y ) (v2 y) <==> u^:(v1`v2) y   NB. NuVoc: 
monadic case of Power/ Gerund n


This is what I wanted to re-build

   (+:^:5) 1
32

Since

   (],%~)5
5 1
   (],*) 5
5 1

therefore I re-wrote it this way (two variants)

   (+:^:(]`(%~))) 5
32
   (+:^:(]`*)) 5
32

and defined two verbs

   p1=. +:^:(]`(%~))
   p2=. +:^:(]`*)

which perform about the same

   timespacex 'p1 100'
2.03937e_5 896
   timespacex 'p2 100'
3.57587e_5 896

** Raul, your suggestion is precious to me as I 
have investigated along those lines to begin with but wasn't successful ...


   p3=. +:@]^:[&1
   p3 5
32
   timespacex 'p3 100'
2.0673e_5 832

-M


At 2018-08-07 13:55, you wrote:


https://code.jsoftware.com/wiki/Vocabulary/hatco#Gerund_n

Henry Rich

On 8/7/2018 6:57 AM, Martin Kreuzer wrote:

Hi all -


Have been playing with the Power conjunction 
using this (not uncommon) example



   po2=. 3 : '+:^:y 1'   NB. power of two by repeated doubling
   po2 5
32


Then I have wanted to come up with a tacit 
version of *po2 (a monad with no of repetions as only argument) and tried



   (+:^:])5   NB. does the doubling alright but  ...
160



and a number of variations of this



   (+:^:] 1)5
|syntax error
|Â Â Â Â Â Â  (+:^:]1)5



Q: Where should I put the start value of 1..?



Thanks
-M



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



---
This email has been checked for viruses by AVG.
https://www.avg.com

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


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

[Jprogramming] Tacit form: Where to put the start value..?

2018-08-07 Thread Martin Kreuzer

Hi all -

Have been playing with the Power conjunction using this (not uncommon) example

   po2=. 3 : '+:^:y 1'   NB. power of two by repeated doubling
   po2 5
32

Then I have wanted to come up with a tacit version of *po2 (a monad 
with no of repetions as only argument) and tried


   (+:^:])5   NB. does the doubling alright but  ...
160

and a number of variations of this

   (+:^:] 1)5
|syntax error
|   (+:^:]1)5

Q: Where should I put the start value of 1..?

Thanks
-M

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

Re: [Jprogramming] Finding integers:

2018-06-13 Thread Martin Kreuzer

-1-
For
"I want to find the integers in a vector of floating point numbers"
this will do:

   inr=: =<.  NB. boolean 'is not real'

   ] v=. 1r3 1r2 1,(%:3),2 2.99 3 1p1
0.33 0.5 1 1.73205 2 2.99 3 3.14159
   inr v
0 0 1 0 1 0 1 0
   (inr v) # v
1 2 3

   fi=: (=<.) # ]
   fi v
1 2 3

-2-
For
"Use the mark vector to find the perfect squares in a"
this will be one solution:

   b=. %: a=. >: i.17

   fi=. (=<.) @ %: # ]
   fi a
1 4 9 16

   fi1=. ] #~ (=<.) @ %:
   fi1 a
1 4 9 16

   fi p: i.17   NB. lots of integers, but no square ...


-M


At 2018-06-12 20:40, you wrote:


I want to find the integers in a vector of floating point numbers, by
generating a boolean marking vector indicating the locations of the
integers in the floating-point vector:

Generate a vector of integers & store in a, and generate a second vector of
floating and integer numbers by taking the square root of a:

b =. %: a=. 1+i.20


Create an integer-finding/marking verb:


fi =. 3 :'(<.y)=y'


Use 'fi' to find the integers in b:

fi b

1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0


Use the mark vector to find the perfect squares in a, by finding the
integers in b:


a#~ fi b

1 4 9 16

My question is:  What are some tacit ways to implement the fi verb?

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


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

Re: [Jprogramming] J wiki unavailable

2018-04-17 Thread Martin Kreuzer

http://www.isitdownrightnow.com/code.jsoftware.com.html
reports "code.jsoftware.com is DOWN",
it does not answer to my "ping";
doesn't seem to be a country issue as I get that result through VPN 
via a NYC server.

-M

At 2018-04-17 10:48, you wrote:


The J wiki has been inaccessible to me in England all morning, either on
Firefox or Safari. I get a blank screen and a loading bar, which simply
hangs, and eventually times-out with a message "Safari can't open the page".

Strangely, this works: www.jsoftware.com
-but the resulting "Guides" link in the left sidebar does not.

Is this a local problem, or a server problem? Do the management know about
it? Is the solution in-hand?

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


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

Re: [Jprogramming] exact comparison (tolerance zero) ...

2018-03-23 Thread Martin Kreuzer

Yes, it does (help) ...
-M

At 2018-03-23 19:35, you wrote:


I suppose so...

Keep in mind that the floating point standard can represent integers
(if they are not too large - after 2^53 it starts losing the ability
to represent some integers).

One way of looking at it is this:

   ":!.20 *:%:5
5.0008882
   ":!.20 %:*:5


Another way of looking at it is this:

   5 - %:*:5

   5 - *:%:5
_8.88178e_16

I hope this helps,

--
Raul


On Fri, Mar 23, 2018 at 3:31 PM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> Looks like I have been mislead by

>datatype 5
> integer

>datatype %: *: 5
> floating
>datatype *: %: 5
> floating

> -M


> At 2018-03-23 18:25, you wrote:

>> *:5 is 25 which has an integer square root, so %: *: 5 has a result
>> which is exactly 5
>>
>> %:5 does not have an integer result, but instead has a floating point
>> (approximate) result, so *: %: 5 has a result which is approximately
>> 5.
>>
>> --
>> Raul
>>
>>
>>
>>
>> On Fri, Mar 23, 2018 at 2:04 PM, Martin Kreuzer <i...@airkreuzer.com>
>> wrote:
>> > Having read through
>> > http://code.jsoftware.com/wiki/Essays/Tolerant_Comparison
>> > (as far as I managed to follow the reasoning)
>> > I tried these examples:
>>
>> >5 (=!.0) %: *: 5
>> > 1
>> >5 (=!.0) *: %: 5
>> > 0
>>
>> >5 - %: *: 5
>> > 0
>> >5 - *: %: 5
>> > _8.88178e_16
>> >(*:&%: - %:&*:) 5
>> > 8.88178e_16
>>
>> > and have been wondering since how/why the order of evaluation would make
>> > a
>> > difference (having expected it to throw a zero in *both* cases).
>> > I'm aware of the the asymmetric interval boundaries x*1-t ; x%1-t but
>> > can't
>> > figure out whether they might be involved in the differing of results,
>> > as
>> > the tolerance is set to zero.
>>
>> > Anybody volunteering with a layman's explanation..?
>>
>> > -M
>>
>> > --
>> > 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


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

Re: [Jprogramming] exact comparison (tolerance zero) ...

2018-03-23 Thread Martin Kreuzer

Raul, Henry -
Thank you.
-M

At 2018-03-23 19:34, you wrote:


5 can be represented exactly in floating-point, but %: 5 cannot.

Henry Rich

On 3/23/2018 3:31 PM, Martin Kreuzer wrote:

Looks like I have been mislead by



   datatype 5
integer



   datatype %: *: 5
floating
   datatype *: %: 5
floating



-M



At 2018-03-23 18:25, you wrote:



*:5 is 25 which has an integer square root, so %: *: 5 has a result
which is exactly 5

%:5 does not have an integer result, but instead has a floating point
(approximate) result, so *: %: 5 has a result which is approximately
5.

--
Raul




On Fri, Mar 23, 2018 at 2:04 PM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> Having read through
> http://code.jsoftware.com/wiki/Essays/Tolerant_Comparison
> (as far as I managed to follow the reasoning)
> I tried these examples:

>Â Â Â  5 (=!.0) %: *: 5
> 1
>Â Â Â  5 (=!.0) *: %: 5
> 0

>Â Â Â  5 - %: *: 5
> 0
>Â Â Â  5 - *: %: 5
> _8.88178e_16
>Â Â Â  (*:&%: - %:&*:) 5
> 8.88178e_16

> and have been wondering since how/why the 
order of evaluation would make a

> difference (having expected it to throw a zero in *both* cases).
> I'm aware of the the asymmetric interval 
boundaries x*1-t ; x%1-t but can't

> figure out whether they might be involved in the differing of results, as
> the tolerance is set to zero.

> Anybody volunteering with a layman's explanation..?

> -M

> --
> 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



---
This email has been checked for viruses by AVG.
http://www.avg.com

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


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

Re: [Jprogramming] exact comparison (tolerance zero) ...

2018-03-23 Thread Martin Kreuzer

Looks like I have been mislead by

   datatype 5
integer

   datatype %: *: 5
floating
   datatype *: %: 5
floating

-M

At 2018-03-23 18:25, you wrote:


*:5 is 25 which has an integer square root, so %: *: 5 has a result
which is exactly 5

%:5 does not have an integer result, but instead has a floating point
(approximate) result, so *: %: 5 has a result which is approximately
5.

--
Raul




On Fri, Mar 23, 2018 at 2:04 PM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> Having read through
> http://code.jsoftware.com/wiki/Essays/Tolerant_Comparison
> (as far as I managed to follow the reasoning)
> I tried these examples:

>5 (=!.0) %: *: 5
> 1
>5 (=!.0) *: %: 5
> 0

>5 - %: *: 5
> 0
>5 - *: %: 5
> _8.88178e_16
>(*:&%: - %:&*:) 5
> 8.88178e_16

> and have been wondering since how/why the order of evaluation would make a
> difference (having expected it to throw a zero in *both* cases).
> I'm aware of the the asymmetric interval boundaries x*1-t ; x%1-t but can't
> figure out whether they might be involved in the differing of results, as
> the tolerance is set to zero.

> Anybody volunteering with a layman's explanation..?

> -M

> --
> 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

[Jprogramming] exact comparison (tolerance zero) ...

2018-03-23 Thread Martin Kreuzer

Having read through
http://code.jsoftware.com/wiki/Essays/Tolerant_Comparison
(as far as I managed to follow the reasoning)
I tried these examples:

   5 (=!.0) %: *: 5
1
   5 (=!.0) *: %: 5
0

   5 - %: *: 5
0
   5 - *: %: 5
_8.88178e_16
   (*:&%: - %:&*:) 5
8.88178e_16

and have been wondering since how/why the order of evaluation would 
make a difference (having expected it to throw a zero in *both* cases).
I'm aware of the the asymmetric interval boundaries x*1-t ; x%1-t but 
can't figure out whether they might be involved in the differing of 
results, as the tolerance is set to zero.


Anybody volunteering with a layman's explanation..?

-M

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

Re: [Jprogramming] Vector Similarity

2018-02-28 Thread Martin Kreuzer

Skip -

The paper can be downloaded from this link
https://www.academia.edu/people/search?utf8=%E2%9C%93=bo+jacoby+ordinal+fractions
provided you have an account to log into ...

If that's not working out -and Bo agrees- I could 
send you the short paper by PM.


-M

At 2018-02-28 14:25, you wrote:


Bo,

.edu
Advanced Search found 9,227papers containing “ORDINAL FRACTIONS”
Search within the full text of 20 million papers


Skip Cave
Cave Consulting LLC

On Tue, Feb 20, 2018 at 4:20 PM, 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:

> ORDINAL FRACTIONS - the algebra of data

> |
> |
> |
> |   ||

>|

>   |
> |
> ||
> ORDINAL FRACTIONS - the algebra of data
>  This paper was submitted to the 10th World Computer Congress, IFIP 1986
> conference, but rejected by the referee  |   |

>   |

>   |




> Den 22:42 tirsdag den 20. februar 2018 skrev Skip Cave <
> s...@caveconsulting.com>:


>  Very nice! Thanks Raul.

> However, there is something wrong about the cosine similarity,
> which should always be between 0 & 1

> prod=:+/ .*

> 1 1 1 (prod % %:@*) 0 3 3

> 1.41421

> ​Skip

> On Tue, Feb 20, 2018 at 2:27 PM, Raul Miller 
> wrote:

> > I don't know about blog entries - I think there are probably some that
> > partially cover this topic.
> >
> > But it shouldn't be hard to implement most of these operations:
> >
> > Euclidean distance:
> >
> >1 0 0 +/&.:*:@:- 0 1 0
> > 1.41421
> >
> > Manhattan distance:
> >
> >1 0 0 +/@:|@:- 0 1 0
> > 2
> >
> > Minkowski distances:
> >
> >minkowski=: 1 :'m %: [:+/ m ^~ [:| -'
> >1 0 0 (1 minkowski) 0 1 0
> > 2
> >1 0 0 (2 minkowski) 0 1 0
> > 1.41421
> >
> > Cosine similarity:
> >
> >prod=:+/ .*
> >1 0 0 (prod % %:@*) 0 1 0
> > 0
> >
> > Jacard Similarity:
> >
> >union=: ~.@,
> >intersect=: [ ~.@:-. -.
> >1 0 0 (intersect %

Re: [Jprogramming] understanding constants

2018-01-14 Thread Martin Kreuzer

Henry -
Only following developments from a distance, as I have been ill.
Want to let you know that I appreciate your help ...
-M

At 2018-01-14 19:34, you wrote:

The page 
http://code.jsoftware.com/wiki/Vocabulary/Constants 
, though incomplete, has much good to say about 
constants.  I just now added a section 
The_Hierarchy_of_Letters with some details.


Henry Rich

On 1/14/2018 1:19 PM, More Rice wrote:

Hi, a newbie question …


I’vee been trying to test my understanding of 
the following page by combining them in different ways.



http://www.jsoftware.com/help/dictionary/dcons.htm



It went well except when I try mixing with non-decimal numbers.  Like:


 NB. Tried to do 10*1p0, but p is higher 
than b in hierarchy; won’t work.

 NB. But it still have an answer?
16bap0
2960



So, questions are:
1. how does it get the value of 2960?
2. Is there a tool to help understand construct 
like this? (similar to dissect, or ;: for example)



thank you.




Maurice



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



---
This email has been checked for viruses by AVG.
http://www.avg.com

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


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

Re: [Jprogramming] Boxing sparse arrays?

2017-12-23 Thread Martin Kreuzer

... and citing from a post by Robert Bernecky (dated 1992-01-28)
https://groups.google.com/forum/#!msg/alt.folklore.computers/SFev2gkcZR4/_QF7zvbX5_AJ

'What is a NONCE error?'
"...
Within the APL community, we strove for decision by Quaker consent:
If we couldn't agree on how to do something, we would defer a design
decision, for the NONCE, by doing nothing.

For example, we might have implemented complex math in SHARP APL, but
were having second thoughts on the definition of the floor of a complex
number. (This didn't happen, by the way -- merely an example)

So, we would implement the parts we DID agree on. In the above case
you'd be able to enter, add, subtract, and otherwise manipulate
complex numbers, but an attempt to take the floor of one would
result in: NONCE ERROR with a caret 
pointing to the offending primitive.


The floor of a real would work, of course, as advertised.

The intent of signalling NONCE ERROR instead of DOMAIN ERROR was
to make it clear to the user that we:

a. Were planning to do something here, but hadn't decided what it was yet.
OR
b. Were doing something here, but it wasn't 
released yet. Sort of an "under construction" sign.

..."

-M

At 2017-12-23 13:35, you wrote:


Hi all,
Why can't I box sparse arrays?  I was exploring sparse arrays after it came
up on the mailing list and was surprised to get a nonce error when I tried
to box a sparse error.  Using the example given on the dictionary entry for
$. to demonstrate the issue:

   ] d=: (?. 3 4$2) * ?. 3 4$100
 0 56  0  6
85  0  0 96
 0  0 33  0
   ] s=: $. d
0 1 │ 56
0 3 │  6
1 0 │ 85
1 3 │ 96
2 2 │ 33
   s ; d
|nonce error
|   s;d
   http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] Boxing sparse arrays?

2017-12-23 Thread Martin Kreuzer

... and the Dictionary in the Notes section of ($.) says:
"Sparse literal and boxed arrays not yet implemented. "
-M

At 2017-12-23 13:35, you wrote:


Hi all,
Why can't I box sparse arrays?  I was exploring sparse arrays after it came
up on the mailing list and was surprised to get a nonce error when I tried
to box a sparse error.  Using the example given on the dictionary entry for
$. to demonstrate the issue:

   ] d=: (?. 3 4$2) * ?. 3 4$100
 0 56  0  6
85  0  0 96
 0  0 33  0
   ] s=: $. d
0 1 │ 56
0 3 │  6
1 0 │ 85
1 3 │ 96
2 2 │ 33
   s ; d
|nonce error
|   s;d
   http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] Boxing sparse arrays?

2017-12-23 Thread Martin Kreuzer
Being definitely no expert on that, but a forum 
search with keywords "sparse array boxed" returned e.g. this post:

http://www.jsoftware.com/pipermail/programming/2017-October/049443.html

As for Roger Stokes' LJ book, see

Section 1.9 'Side By Side Displays', where he states:

"Side-by-side displays are not a feature of the J 
system, but merely figures, or illustrations, in 
this book. They show expressions in the first 
row, and corresponding values below them in the second row. "

So, I don't think that he managed to box sparse arrays.

-M

At 2017-12-23 13:35, you wrote:


Hi all,
Why can't I box sparse arrays?  I was exploring sparse arrays after it came
up on the mailing list and was surprised to get a nonce error when I tried
to box a sparse error.  Using the example given on the dictionary entry for
$. to demonstrate the issue:

   ] d=: (?. 3 4$2) * ?. 3 4$100
 0 56  0  6
85  0  0 96
 0  0 33  0
   ] s=: $. d
0 1 │ 56
0 3 │  6
1 0 │ 85
1 3 │ 96
2 2 │ 33
   s ; d
|nonce error
|   s;d
   http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] Fractional parts

2017-08-09 Thread Martin Kreuzer
From what I've gathered so far is, that people 
seem to not mind that much, when extracting the 
fractional part from a (negative) float, they use


   (1&|) _8.11
0.89

or

   (1

Re: [Jprogramming] Fractional parts

2017-08-08 Thread Martin Kreuzer

Credit should go to the people who suggested the building blocks, e.g.
(1|y) Raul  --  (1||y) Pascal  --  (*y) Raul

which I only picked up to assemble

   fp1=. **1||

(get fractional part and show negative sign).

Agreed, without proper specification one finds oneself travelling the 
road of speculation ...


These variants

   fp2 =. 1&| - 0&>

(get fractional part, show negative sign, offset -1 for any negative *integer*)

   fp3=. 1&|`*@.(0&>"0)

(get fractional part from any positive number, offset -1 for any 
negative found, taking fp2 to the extreme ...)


are interesting, but remain speculative.

-M

At 2017-08-08 06:05, you wrote:


signum is zero tolerant but that may be what you intended.

On Tue, Aug 8, 2017 at 1:15 PM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> Raul, picking up your suggestion,

> take the fractional part if positive number,
> mark by _1 if negative (sort of a mask?)

>v=. 2.25 _8.11 16 _3

> using Agenda

>(1&|)`(*) @. (0&>"0) v
> 0.25 _1 0 _1
>fp3=. 1&|`*@.(0&>"0)
>fp3 v
> 0.25 _1 0 _1

> -M


> At 2017-08-07 22:26, Raul Miller wrote:

>> When I suggested an offset of _1 I did not understand the full
>> specification, and was fishing for clues.
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Mon, Aug 7, 2017 at 5:30 PM, Martin Kreuzer <i...@airkreuzer.com>
>> wrote:
>> > I'm not sure what Raul had in mind when he suggested an offset of _1 to
>> > mark
>> > the position of negatives (maybe that would help further calculations or
>> > decisions on the data set, I do not have the experience to judge that);
>> > at
>> > this stage it only works with integers but not with floats ...
>> > -M
>>
>>
>> > At 2017-08-07 21:08, you wrote:
>>
>> >> Ooops! it looks like fp2 isn't so good after all.
>> >>
>> >> Skip
>> >>
>> >> Skip Cave
>> >> Cave Consulting LLC
>> >>
>> >> On Mon, Aug 7, 2017 at 4:02 PM, Martin Kreuzer <i...@airkreuzer.com>
>> >> wrote:
>> >>
>> >> > Was it meant like that..?
>> >>
>> >> >fp2 0.3 _0.3 3 _3
>> >> > 0.3 _0.3 0 _1
>> >>
>> >> > -M
>> >>
>> >>
>> >> > At 2017-08-07 20:38, you wrote:
>> >>
>> >> > It looks like we have two good solutions to find a fractional part:
>> >> >>
>> >> >> v
>> >> >>
>> >> >> _2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
>> >> >> fp1=. * * 1||NB. Martin
>> >> >> fp2 =. (1&| - 0&>)   NB.  Bo & Raul collaboration.
>> >> >>
>> >> >> fp1 v
>> >> >>
>> >> >> _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
>> >> >>
>> >> >> fp2 v
>> >> >>
>> >> >> _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
>> >> >>
>> >> >>
>> >> >> Also the converse - integer part:
>> >> >>
>> >> >> ip=: * * <.@|
>> >> >>
>> >> >> ip v NB. Louis
>> >> >>
>> >> >> _2 _5 _11 13 13 13 12
>> >> >>
>> >> >>
>> >> >> These two verbs need to be somewhere in the "Numbers" section of the
>> >> >> J
>> >> >> Phrases doc. Maybe under "8A-Numbers & Counting", or
>> >> >> 8C-Representations",
>> >> >> or "8D-Arithmetic". How do we get them in there? Can I edit the
>> >> >> Phrases
>> >> >> doc?
>> >> >>
>> >> >>
>> >> >> Skip
>> >> >>
>> >> >>
>> >> >>
>> >> >> Skip Cave
>> >> >> Cave Consulting LLC
>> >> >>
>> >> >> On Sun, Aug 6, 2017 at 11:22 AM, Louis de Forcrand
>> >> >> <ol...@bluewin.ch>
>> >> >> wrote:
>> >> >>
>> >> >> > ip would be best implemented as
>> >> >>
>> >> >> >ip=: * * <.@|
>> >> >>
>> >> >> > as it would return an integer result.
>> >> >>
>> >> >> > Louis
>

Re: [Jprogramming] Fractional parts

2017-08-07 Thread Martin Kreuzer

Raul, picking up your suggestion,

take the fractional part if positive number,
mark by _1 if negative (sort of a mask?)

   v=. 2.25 _8.11 16 _3

using Agenda

   (1&|)`(*) @. (0&>"0) v
0.25 _1 0 _1
   fp3=. 1&|`*@.(0&>"0)
   fp3 v
0.25 _1 0 _1

-M

At 2017-08-07 22:26, Raul Miller wrote:


When I suggested an offset of _1 I did not understand the full
specification, and was fishing for clues.

Thanks,

--
Raul


On Mon, Aug 7, 2017 at 5:30 PM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> I'm not sure what Raul had in mind when he suggested an offset of 
_1 to mark

> the position of negatives (maybe that would help further calculations or
> decisions on the data set, I do not have the experience to judge that); at
> this stage it only works with integers but not with floats ...
> -M


> At 2017-08-07 21:08, you wrote:

>> Ooops! it looks like fp2 isn't so good after all.
>>
>> Skip
>>
>> Skip Cave
>> Cave Consulting LLC
>>
>> On Mon, Aug 7, 2017 at 4:02 PM, Martin Kreuzer <i...@airkreuzer.com>
>> wrote:
>>
>> > Was it meant like that..?
>>
>> >fp2 0.3 _0.3 3 _3
>> > 0.3 _0.3 0 _1
>>
>> > -M
>>
>>
>> > At 2017-08-07 20:38, you wrote:
>>
>> > It looks like we have two good solutions to find a fractional part:
>> >>
>> >> v
>> >>
>> >> _2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
>> >> fp1=. * * 1||NB. Martin
>> >> fp2 =. (1&| - 0&>)   NB.  Bo & Raul collaboration.
>> >>
>> >> fp1 v
>> >>
>> >> _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
>> >>
>> >> fp2 v
>> >>
>> >> _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
>> >>
>> >>
>> >> Also the converse - integer part:
>> >>
>> >> ip=: * * <.@|
>> >>
>> >> ip v NB. Louis
>> >>
>> >> _2 _5 _11 13 13 13 12
>> >>
>> >>
>> >> These two verbs need to be somewhere in the "Numbers" section of the J
>> >> Phrases doc. Maybe under "8A-Numbers & Counting", or
>> >> 8C-Representations",
>> >> or "8D-Arithmetic". How do we get them in there? Can I edit the Phrases
>> >> doc?
>> >>
>> >>
>> >> Skip
>> >>
>> >>
>> >>
>> >> Skip Cave
>> >> Cave Consulting LLC
>> >>
>> >> On Sun, Aug 6, 2017 at 11:22 AM, Louis de Forcrand <ol...@bluewin.ch>
>> >> wrote:
>> >>
>> >> > ip would be best implemented as
>> >>
>> >> >ip=: * * <.@|
>> >>
>> >> > as it would return an integer result.
>> >>
>> >> > Louis
>> >>
>> >> > > On 06 Aug 2017, at 12:17, Skip Cave <s...@caveconsulting.com>
>> >> > > wrote:
>> >> > >
>> >> > > All, Thanks for the help.
>> >> > >
>> >> > > Here's some real numbers from a problem I'm working on:
>> >> > > Calculate some values from this equation:
>> >> > >v=:2%(3r19-%1 2 3 245 246 247 248)
>> >> > > v
>> >> > >_2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
>> >> > > Raul's first suggestion:
>> >> > >1|v
>> >> > > 0.625 0.153846 0.6 0.0027933 0.00139082 0 0.998621
>> >> > > More precision, but signs are wrong on the negative numbers.
>> >> > >
>> >> > > Nolaig's suggestion:
>> >> > > (- <.) v
>> >> > > 0.625 0.153846 0.6 0.0027933 0.00139082 1.77636e_15 0.998621
>> >> > > Negative signs are still wrong, and the 6th entry should be zero.
>> >> Looks
>> >> > > like a compare tolerance problem.
>> >> > >
>> >> > > Pascal's solution:
>> >> > >
>> >> > >   1 (| |)v
>> >> > >
>> >> > > 0.375 0.846154 0.4 0.0027933 0.00139082 0 0.998621
>> >> > > Still has the negatives wrong.
>> >> > >
>> >> > > Martin's solution:
>> >> > > fp=.**1||
>> >> > >
>> >> > >   fp v
>> >> > >
>> >> > > _0.375 _0.846154 _

Re: [Jprogramming] Fractional parts

2017-08-07 Thread Martin Kreuzer
I'm not sure what Raul had in mind when he suggested an offset of _1 
to mark the position of negatives (maybe that would help further 
calculations or decisions on the data set, I do not have the 
experience to judge that); at this stage it only works with integers 
but not with floats ...

-M

At 2017-08-07 21:08, you wrote:


Ooops! it looks like fp2 isn't so good after all.

Skip

Skip Cave
Cave Consulting LLC

On Mon, Aug 7, 2017 at 4:02 PM, Martin Kreuzer <i...@airkreuzer.com> wrote:

> Was it meant like that..?

>fp2 0.3 _0.3 3 _3
> 0.3 _0.3 0 _1

> -M


> At 2017-08-07 20:38, you wrote:

> It looks like we have two good solutions to find a fractional part:
>>
>> v
>>
>> _2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
>> fp1=. * * 1||NB. Martin
>> fp2 =. (1&| - 0&>)   NB.  Bo & Raul collaboration.
>>
>> fp1 v
>>
>> _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
>>
>> fp2 v
>>
>> _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
>>
>>
>> Also the converse - integer part:
>>
>> ip=: * * <.@|
>>
>> ip v NB. Louis
>>
>> _2 _5 _11 13 13 13 12
>>
>>
>> These two verbs need to be somewhere in the "Numbers" section of the J
>> Phrases doc. Maybe under "8A-Numbers & Counting", or 8C-Representations",
>> or "8D-Arithmetic". How do we get them in there? Can I edit the Phrases
>> doc?
>>
>>
>> Skip
>>
>>
>>
>> Skip Cave
>> Cave Consulting LLC
>>
>> On Sun, Aug 6, 2017 at 11:22 AM, Louis de Forcrand <ol...@bluewin.ch>
>> wrote:
>>
>> > ip would be best implemented as
>>
>> >ip=: * * <.@|
>>
>> > as it would return an integer result.
>>
>> > Louis
>>
>> > > On 06 Aug 2017, at 12:17, Skip Cave <s...@caveconsulting.com> wrote:
>> > >
>> > > All, Thanks for the help.
>> > >
>> > > Here's some real numbers from a problem I'm working on:
>> > > Calculate some values from this equation:
>> > >v=:2%(3r19-%1 2 3 245 246 247 248)
>> > > v
>> > >_2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
>> > > Raul's first suggestion:
>> > >1|v
>> > > 0.625 0.153846 0.6 0.0027933 0.00139082 0 0.998621
>> > > More precision, but signs are wrong on the negative numbers.
>> > >
>> > > Nolaig's suggestion:
>> > > (- <.) v
>> > > 0.625 0.153846 0.6 0.0027933 0.00139082 1.77636e_15 0.998621
>> > > Negative signs are still wrong, and the 6th entry should be zero.
>> Looks
>> > > like a compare tolerance problem.
>> > >
>> > > Pascal's solution:
>> > >
>> > >   1 (| |)v
>> > >
>> > > 0.375 0.846154 0.4 0.0027933 0.00139082 0 0.998621
>> > > Still has the negatives wrong.
>> > >
>> > > Martin's solution:
>> > > fp=.**1||
>> > >
>> > >   fp v
>> > >
>> > > _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
>> > > Negatives are right, zeroes are right. This fractional part verb
>> needs to
>> > > be in the documentation as part of the numbers chapter.
>> > >
>> > > Also the integer part verb: ip=.]-**1||should be included in the
>> > > numbers section as well.
>> > >   ip v
>> > >
>> > > _2 _5 _11 13 13 13 12
>> > >
>> > > Skip
>> > >
>> > > Skip Cave
>> > > Cave Consulting LLC
>> > >
>> > > On Sun, Aug 6, 2017 at 6:42 AM, Raul Miller <rauldmil...@gmail.com>
>> > wrote:
>> > >
>> > >> 1&| does work, actually.
>> > >>
>> > >> And, if you want an offset of -1 on that result when the original
>> > >> value was negative, you can use (1&| - 0&>)
>> > >>
>> > >> Thanks,
>> > >>
>> > >> --
>> > >> Raul
>> > >>
>> > >> On Sun, Aug 6, 2017 at 3:19 AM, Martin Kreuzer <i...@airkreuzer.com>
>> > >> wrote:
>> > >>> In easy steps (and for further reference) ...
>> > >>>
>> > >>> From these test data (two floats, two integers, different signs), to
>> > get
>> > >> the
>> > >>

Re: [Jprogramming] Fractional parts

2017-08-07 Thread Martin Kreuzer

Was it meant like that..?

   fp2 0.3 _0.3 3 _3
0.3 _0.3 0 _1

-M

At 2017-08-07 20:38, you wrote:


It looks like we have two good solutions to find a fractional part:

v

_2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
fp1=. * * 1||NB. Martin
fp2 =. (1&| - 0&>)   NB.  Bo & Raul collaboration.

fp1 v

_0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621

fp2 v

_0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621


Also the converse - integer part:

ip=: * * <.@|

ip v NB. Louis

_2 _5 _11 13 13 13 12


These two verbs need to be somewhere in the "Numbers" section of the J
Phrases doc. Maybe under "8A-Numbers & Counting", or 8C-Representations",
or "8D-Arithmetic". How do we get them in there? Can I edit the Phrases doc?


Skip



Skip Cave
Cave Consulting LLC

On Sun, Aug 6, 2017 at 11:22 AM, Louis de Forcrand <ol...@bluewin.ch> wrote:

> ip would be best implemented as

>ip=: * * <.@|

> as it would return an integer result.

> Louis

> > On 06 Aug 2017, at 12:17, Skip Cave <s...@caveconsulting.com> wrote:
> >
> > All, Thanks for the help.
> >
> > Here's some real numbers from a problem I'm working on:
> > Calculate some values from this equation:
> >v=:2%(3r19-%1 2 3 245 246 247 248)
> > v
> >_2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
> > Raul's first suggestion:
> >1|v
> > 0.625 0.153846 0.6 0.0027933 0.00139082 0 0.998621
> > More precision, but signs are wrong on the negative numbers.
> >
> > Nolaig's suggestion:
> > (- <.) v
> > 0.625 0.153846 0.6 0.0027933 0.00139082 1.77636e_15 0.998621
> > Negative signs are still wrong, and the 6th entry should be zero. Looks
> > like a compare tolerance problem.
> >
> > Pascal's solution:
> >
> >   1 (| |)v
> >
> > 0.375 0.846154 0.4 0.0027933 0.00139082 0 0.998621
> > Still has the negatives wrong.
> >
> > Martin's solution:
> > fp=.**1||
> >
> >   fp v
> >
> > _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
> > Negatives are right, zeroes are right. This fractional part verb needs to
> > be in the documentation as part of the numbers chapter.
> >
> > Also the integer part verb: ip=.]-**1||should be included in the
> > numbers section as well.
> >   ip v
> >
> > _2 _5 _11 13 13 13 12
> >
> > Skip
> >
> > Skip Cave
> > Cave Consulting LLC
> >
> > On Sun, Aug 6, 2017 at 6:42 AM, Raul Miller <rauldmil...@gmail.com>
> wrote:
> >
> >> 1&| does work, actually.
> >>
> >> And, if you want an offset of -1 on that result when the original
> >> value was negative, you can use (1&| - 0&>)
> >>
> >> Thanks,
> >>
> >> --
> >> Raul
> >>
> >> On Sun, Aug 6, 2017 at 3:19 AM, Martin Kreuzer <i...@airkreuzer.com>
> >> wrote:
> >>> In easy steps (and for further reference) ...
> >>>
> >>> From these test data (two floats, two integers, different signs), to
> get
> >> the
> >>> fractional parts
> >>>
> >>>   v=. 2.25 _8.11 16 _3
> >>>
> >>> simply taking the Residue (when dividing by 1) doesn't work (error at
> >>> negative float position)
> >>>
> >>>   1|v
> >>> 0.25 0.89 0 0
> >>>
> >>> So first get Magnitude
> >>>
> >>>   | v
> >>> 2.25 8.11 16 3
> >>>
> >>> then take Residue
> >>>
> >>>   1 | (| v)
> >>> 0.25 0.11 0 0
> >>>
> >>> then get the sign right (see Raul's remark below)
> >>>
> >>>   (*v) * (1 | | v)
> >>> 0.25 _0.11 0 0
> >>>
> >>> and put it as verb (fp), written as a fork
> >>>
> >>>   fp=. * * 1||
> >>>   fp v
> >>> 0.25 _0.11 0 0
> >>>
> >>> -M
> >>>
> >>>
> >>> At 2017-08-06 02:14, you wrote:
> >>>
> >>>> Eh... but that's wrong.  You can't add any integer to 0.542857 to get
> >>>> _0.542857.
> >>>>
> >>>> If you want signed fractions, you'd need something like (*@] * (| |))
> >>>>
> >>>> Thanks,
> >>>>
> >>>> --
> >>>> Raul
> >>>>
> >>>>
> >>>> On Sat, Aug 5, 2017 at 10:01 PM, 'Pascal Jasmin' via Programming
> >>&

Re: [Jprogramming] Fractional parts

2017-08-06 Thread Martin Kreuzer

In easy steps (and for further reference) ...

From these test data (two floats, two integers, different signs), to 
get the fractional parts


   v=. 2.25 _8.11 16 _3

simply taking the Residue (when dividing by 1) doesn't work (error at 
negative float position)


   1|v
0.25 0.89 0 0

So first get Magnitude

   | v
2.25 8.11 16 3

then take Residue

   1 | (| v)
0.25 0.11 0 0

then get the sign right (see Raul's remark below)

   (*v) * (1 | | v)
0.25 _0.11 0 0

and put it as verb (fp), written as a fork

   fp=. * * 1||
   fp v
0.25 _0.11 0 0

-M

At 2017-08-06 02:14, you wrote:

Eh... but that's wrong.  You can't add any integer to 0.542857 to 
get _0.542857.


If you want signed fractions, you'd need something like (*@] * (| |))

Thanks,

--
Raul


On Sat, Aug 5, 2017 at 10:01 PM, 'Pascal Jasmin' via Programming
 wrote:
> combining other answers we get the cute:

> 1 (| |)  _0.542857 _1.1875 1.96552 2.92308 4.13043 5.7 7.82353 
10.8571 15.5455 23.75





> 
> From: Bill 
> To: "programm...@jsoftware.com" 
> Sent: Saturday, August 5, 2017 8:30 PM
> Subject: Re: [Jprogramming] Fractional parts



> this also depends on what do you expect for negative numbers.

> Sent from my iPhone

> On 6 Aug, 2017, at 7:35 AM, Skip Cave  wrote:

>> Oops! i meant:
>>
>> How does one find the fractional parts of a vector of floating point
>> numbers?
>>
>> 0.542857 1.1875 1.96552 2.92308 4.13043 5.7 7.82353 10.8571 15.5455 23.75
>> 41.8 114 247
>>
>> i want:
>> 0.542857 0.1875 0.96552 0.92308 0.13043 0.7 0.82353 0.8571 5.5455 0.75 0.8
>> 0 0
>>
>> (Last two integers have zero fractional part.)
>>
>>
>> Skip Cave
>> Cave Consulting LLC
>>
>> On Sat, Aug 5, 2017 at 6:30 PM, Skip Cave  wrote:
>>
>>> How does one find the fractional parts of a vector of floating point
>>> numbers?
>>>
>>> 0.542857 1.1875 1.96552 2.92308 4.13043 5.7 7.82353 10.8571 15.5455 23.75
>>> 41.8 114 247
>>>
>>> i want:
>>> 0.542857 0.1875 0.96552 0.92308 0.13043 0.7 0.82353 0.8571 
5.5455 0.75 0.8

>>> 114 247
>>>
>>> Skip
>>>
>>> Skip Cave
>>> Cave Consulting LLC
>> --
>> 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


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

Re: [Jprogramming] largest rectangle problem

2017-07-04 Thread Martin Kreuzer

Have tried wrapping around the "finalrev" into while./whilst. loops:

lrds1=: 3 : 0
 q=. m=. >./ y
 w=. 1
 n=. # y
 while. m <: q * n do.
  w=. >: w
  m=. m >. w * q=. >./ y=. 2 <./\ y
 end.
)

lrds2=: 3 : 0
 m=. >./ y
 w=. 1
 n=. # y
 whilst. m < q * n do.
  w=. >: w
  m=. m >. w * q=. >./ y=. 2 <./\ y
 end.
)

Here, they gave these results:

   timex 'lrds1 qq'   NB. while.
0.00236119
   timex 'lrds2 qq'   NB. whilst.
0.00240813
   timex 'lrds qq' NB. for_i.
0.00272632

-M

At 2017-06-25 18:18, you wrote:


Thanks.

I haven't heard of paste & match - I like to use Thunderbird to 
support the sharewarers,
but fight against some of its features.  With time & patience, I 
copy & paste into a notepad
file,  and then re-copy and paste into T/bird.  I hadn't bothered in 
my recent posts.
I do (and did in this case) indent and insert whitespace,  albeit by 
hand rather than using

any formatter that J might have to hand.

I see "because copulas are special" but don't quite see why avoiding 
the space helps.


Yes - if I'm really worried about performance,  I do similar tweaks 
on loop input. Is a while

loop better in this case?  (I haven't time to check that now.)

Anyway,  I've got to practise a bit of music and then go out for the 
evening,  so enough

from me for now.

Breakfast tomorrow is another day,

Mike



On 25/06/2017 18:36, Raul Miller wrote:

Not quite, I have a few trivial tweaks that I think make reading it a
bit easier.



(1) I used "Paste and match style" rather than simply paste, when
inserting the code into my message, to eliminate the blank lines that
some insane programming teams decided should be inserted when using
paste.



(2) I indented the code to reflect the explicit structures.



(3) I commuted a multiplication to better show similarity with a
multiplication on the line above.



(4) I ate the whitespace to the left of copulas, because copulas are special.



These are, granted, issues of taste, which means there will always be
someone with different views. They do not help0 performance nor reduce
resource costs in any way. Nevertheless, these reflect my views.



And, (5) a nearly invisible performance improvement (eliminate one
operation) when setting up the loop.



Now... if I could just get my mailer to display messages using a fixed
width font...



finalrev=: 3 : 0NB.  good name?
   m=. >./y
   for_i. 2+i.<:n=. #y do.
 m=. m >. i * q=. >./ y =. 2 <./\ y
 if. m >: n * q do. break. end.
   end.
)



I am not certain though if my (5) hurts readability, but for code like
this you sort of need to go in and see the data to really understand
it. So, here's an instrumented version - I would recommend only trying
this on small arguments (and the displayed result is meant to be used
to help understand the uninstrumented version):



show=: 1 {:: 1!:2&2@(] :(,~))
showfinalrev=: 3 : 0
   show 'y';y
   show 'm';m=. >./y
   for_i. 2+i.<: show 'n';n=. #y do.
 ('q';q;'y';y) show 'm';m=. m >. i * q=. >./ y =. 2 <./\ y
 if. show 'break';m >: n * q do. break. end.
   end.
)



That said, thank you for the excellent treatment of this problem. You
took this a lot further than I had.



Thanks,




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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


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

Re: [Jprogramming] largest rectangle problem

2017-07-03 Thread Martin Kreuzer

Mike -
Yes, thanks for asking.
I've (again) learned a lot during the last week from you guys.
It took me that long digesting the code's core 
because my rhythm is (unfortunately) mostly 
something like 15 mins on, some hours (or days) off.

And your pace (and experience) is so much different from mine.
That's why I'm grateful for 'crumbs off the table' :)
-M

At 2017-07-03 15:15, you wrote:

I think Martin & Raul have sorted this out - 
sorry I haven't had an opportunity


to comment until now (tea-time!)

Everything ok now?

Mike



On 03/07/2017 10:04, Martin Kreuzer wrote:
Sorry, that citation "(b) saves an extra 
multiply ..." obviously stems from one of Mike Day's posts.

-M



At 2017-07-03 08:28, you wrote:



"Anyways, faster is not always better..."
Agreed :)

N: nice test data to clarify your point (using 
qq=: 1e3?.1e6 produced no differing results, so did not alert me).

Larger is not always better ...

Seems that I missed the change in the 
definition of (q) in one stage of the 
program's development, to which this remark 
(from one of your previous posts) refers
"(b) saves an extra multiply in the comparison 
by using the maximum before scaling by i,"

which implies a modified break-off condition
and which I came to understand completely only just now.

Thanks for your help.
-M

At 2017-07-03 06:59, you wrote:


Note that in cs1 m is defined as i * >./y so effectively in "lrds" you
have a factor of i^2



Thus:



  N=: 1 1 4 8 3 3 2 5 4 7
   lrds N
12
   cs1 N
16



Anyways, faster is not always better...



Thanks,



--
Raul



On Mon, Jul 3, 2017 at 2:25 AM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> Mike -



> Somewhere during the discussion, from "finalrev" an "i" somehow silently
> slipped away ...



> On my machine (P4 3 GHz 4 GB ) I got



> * using the (more conservative) break-off condition m >: q * n



>(timex 'lrds qq') , (memex 'lrds qq')
> 0.00452488 14912



> * re-introducing the (more stringent) condition (m * i) >: (q * n)



>(timex 'lrds qq') , (memex 'lrds qq')
> 0.000540292 14912



> which is about one more factor 10 in speed-up.



> (btw, 'lrds' is my abbrev for 'largest rectangle in data set'.)



> This is the code I used in testing:


> lrds=: 3 : 
0   NB. Joint effort of RM, MD,

> LdF (final rev)
>  m=. >./ 
y NB. initialize m with max(y),

> i.e. rectangle with base length 1
>  for_j. 2 + i. <: n=. # y 
do.  NB. looping from j= 2 to n

> (total number of bars, const)
>   m=. m >. j * q=. >./ y=. 2 <./\ y NB. q: max of running min
> between elements (x=2) of y
>   if. (m * j) >: (q * n) do. return. end.  NB. skipping unnecessary
> tests
>  end.
> )



> -M




> At 2017-06-25 16:55, you wrote:



>> Thanks.   That's a bit strange.  I'd spotted the same thing - that we
>> could
>> need only take the minimum of each pair 
of elements provided we replaced
>> the input array with the new set of 
minima.  But it appeared to be slower,

>> and I thought enough was enough, tweaking-wise!
>>
>> Also,  Raul & Henry commented later on 
the superfluous result line,  "m" ,

>> at
>> the end of my previous best 
offering,  and as in Louis' revised version,

>> below.
>> I'd only added that line when introducing the early stopping break,
>> assuming
>> that m wouldn't be available. I should have checked!
>>
>> So - here's a final (?) revised version,  which
>> (a) uses the rolling replacement of y a la Louis,
>> (b) saves an extra multiply in the comparison by using the maximum
>> before scaling by i,
>> and c) dispenses with the result line, a la Raul:
>>
>> finalrev =: 3 : 0NB.  good name?
>>
>> m =. >./y
>>
>> for_i. }.>:i.n =. #y do.
>>
>> m =. m >. i * q =. >./ y =. 2 <./\ y
>>
>> if. m >: q * n do. break. end.
>>
>> end.
>>
>>
>>
>>
>> 1000 ts'finalrev qq'
>>
>> 0.00353084 29696
>>
>> 1000 ts'cs1 qq'NB. !!! dead-heat !!!
>>
>> 0.00357644 29440
>>
>>
>> Enough?
>>
>> Mike
>>
>>
>>
>> On 25/06/2017 14:10, Louis de Forcrand wrote:
>>>
>>> Here is Mike’s version 
with 2<./\ insenserted (and >./i* replaced by i*>./

>>> since
>>> i is positive):
>>
>>
>>> cs1=: 3 : 0
>>>   m=. >./y
>>>   for_i. }.>:i.n=. #y do.
>>>m=. m>.q=. i*>./y=. 2<./\y
>>>if. (m*i)>:n*q do. break. end.
>>>   end.
>&g

Re: [Jprogramming] largest rectangle problem

2017-07-03 Thread Martin Kreuzer
Sorry, that citation "(b) saves an extra multiply 
..." obviously stems from one of Mike Day's posts.

-M

At 2017-07-03 08:28, you wrote:


"Anyways, faster is not always better..."
Agreed :)

N: nice test data to clarify your point (using 
qq=: 1e3?.1e6 produced no differing results, so did not alert me).

Larger is not always better ...

Seems that I missed the change in the definition 
of (q) in one stage of the program's 
development, to which this remark (from one of your previous posts) refers
"(b) saves an extra multiply in the comparison 
by using the maximum before scaling by i,"

which implies a modified break-off condition
and which I came to understand completely only just now.

Thanks for your help.
-M

At 2017-07-03 06:59, you wrote:


Note that in cs1 m is defined as i * >./y so effectively in "lrds" you
have a factor of i^2



Thus:



  N=: 1 1 4 8 3 3 2 5 4 7
   lrds N
12
   cs1 N
16



Anyways, faster is not always better...



Thanks,



--
Raul



On Mon, Jul 3, 2017 at 2:25 AM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> Mike -



> Somewhere during the discussion, from "finalrev" an "i" somehow silently
> slipped away ...



> On my machine (P4 3 GHz 4 GB ) I got



> * using the (more conservative) break-off condition m >: q * n



>(timex 'lrds qq') , (memex 'lrds qq')
> 0.00452488 14912



> * re-introducing the (more stringent) condition (m * i) >: (q * n)



>(timex 'lrds qq') , (memex 'lrds qq')
> 0.000540292 14912



> which is about one more factor 10 in speed-up.



> (btw, 'lrds' is my abbrev for 'largest rectangle in data set'.)



> This is the code I used in testing:



> lrds=: 3 : 0   NB. Joint effort of RM, MD,
> LdF (final rev)
>  m=. >./ 
y NB. initialize m with max(y),

> i.e. rectangle with base length 1
>  for_j. 2 + i. <: n=. # y do.  NB. looping from j= 2 to n
> (total number of bars, const)
>   m=. m >. j * q=. >./ y=. 2 <./\ yNB. q: max of running min
> between elements (x=2) of y
>   if. (m * j) >: (q * n) do. return. end.  NB. skipping unnecessary
> tests
>  end.
> )



> -M




> At 2017-06-25 16:55, you wrote:



>> Thanks.   That's a bit strange.  I'd spotted the same thing - that we
>> could
>> need only take the minimum of each pair of elements provided we replaced
>> the input array with the new set of 
minima.  But it appeared to be slower,

>> and I thought enough was enough, tweaking-wise!
>>
>> Also,  Raul & Henry commented later on the 
superfluous result line,  "m" ,

>> at
>> the end of my previous best offering,  and as in Louis' revised version,
>> below.
>> I'd only added that line when introducing the early stopping break,
>> assuming
>> that m wouldn't be available. I should have checked!
>>
>> So - here's a final (?) revised version,  which
>> (a) uses the rolling replacement of y a la Louis,
>> (b) saves an extra multiply in the comparison by using the maximum
>> before scaling by i,
>> and c) dispenses with the result line, a la Raul:
>>
>> finalrev =: 3 : 0NB.  good name?
>>
>> m =. >./y
>>
>> for_i. }.>:i.n =. #y do.
>>
>> m =. m >. i * q =. >./ y =. 2 <./\ y
>>
>> if. m >: q * n do. break. end.
>>
>> end.
>>
>>
>>
>>
>> 1000 ts'finalrev qq'
>>
>> 0.00353084 29696
>>
>> 1000 ts'cs1 qq'NB. !!! dead-heat !!!
>>
>> 0.00357644 29440
>>
>>
>> Enough?
>>
>> Mike
>>
>>
>>
>> On 25/06/2017 14:10, Louis de Forcrand wrote:
>>>
>>> Here is Mike’s version with 2<./\ 
insenserted (and >./i* replaced by i*>./

>>> since
>>> i is positive):
>>
>>
>>> cs1=: 3 : 0
>>>   m=. >./y
>>>   for_i. }.>:i.n=. #y do.
>>>m=. m>.q=. i*>./y=. 2<./\y
>>>if. (m*i)>:n*q do. break. end.
>>>   end.
>>>   m
>>> )
>>
>>
>>> 1e3 ts'cs1 qq'
>>> 0.00107603 29440
>>> qqq=: 1e4?.1e6
>>> ts'cs1 qqq'
>>> 0.045429 398080
>>> ts'cs qqq'
>>> 0.180366 397440
>>
>>
>>> Real fast!
>>> Louis
>>
>>
>>>> On 25 Jun 2017, at 14:47, Louis de Forcrand <ol...@bluewin.ch> wrote:
>>>>
>>>> Let V be a vector of real numbers, and V[i] its ith component.
>>>> Then
>>>>
>>>> min( V[i] … V[j+1]] ) 

Re: [Jprogramming] largest rectangle problem

2017-07-03 Thread Martin Kreuzer

"Anyways, faster is not always better..."
Agreed :)

N: nice test data to clarify your point (using 
qq=: 1e3?.1e6 produced no differing results, so did not alert me).

Larger is not always better ...

Seems that I missed the change in the definition 
of (q) in one stage of the program's development, 
to which this remark (from one of your previous posts) refers
"(b) saves an extra multiply in the comparison by 
using the maximum before scaling by i,"

which implies a modified break-off condition
and which I came to understand completely only just now.

Thanks for your help.
-M

At 2017-07-03 06:59, you wrote:


Note that in cs1 m is defined as i * >./y so effectively in "lrds" you
have a factor of i^2

Thus:

  N=: 1 1 4 8 3 3 2 5 4 7
   lrds N
12
   cs1 N
16

Anyways, faster is not always better...

Thanks,

--
Raul

On Mon, Jul 3, 2017 at 2:25 AM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> Mike -

> Somewhere during the discussion, from "finalrev" an "i" somehow silently
> slipped away ...

> On my machine (P4 3 GHz 4 GB ) I got

> * using the (more conservative) break-off condition m >: q * n

>(timex 'lrds qq') , (memex 'lrds qq')
> 0.00452488 14912

> * re-introducing the (more stringent) condition (m * i) >: (q * n)

>(timex 'lrds qq') , (memex 'lrds qq')
> 0.000540292 14912

> which is about one more factor 10 in speed-up.

> (btw, 'lrds' is my abbrev for 'largest rectangle in data set'.)

> This is the code I used in testing:

> lrds=: 3 : 0   NB. Joint effort of RM, MD,
> LdF (final rev)
>  m=. >./ 
y NB. initialize m with max(y),

> i.e. rectangle with base length 1
>  for_j. 2 + i. <: n=. # y do.  NB. looping from j= 2 to n
> (total number of bars, const)
>   m=. m >. j * q=. >./ y=. 2 <./\ yNB. q: max of running min
> between elements (x=2) of y
>   if. (m * j) >: (q * n) do. return. end.  NB. skipping unnecessary
> tests
>  end.
> )

> -M


> At 2017-06-25 16:55, you wrote:

>> Thanks.   That's a bit strange.  I'd spotted the same thing - that we
>> could
>> need only take the minimum of each pair of elements provided we replaced
>> the input array with the new set of minima.  But it appeared to be slower,
>> and I thought enough was enough, tweaking-wise!
>>
>> Also,  Raul & Henry commented later on the superfluous result line,  "m" ,
>> at
>> the end of my previous best offering,  and as in Louis' revised version,
>> below.
>> I'd only added that line when introducing the early stopping break,
>> assuming
>> that m wouldn't be available. I should have checked!
>>
>> So - here's a final (?) revised version,  which
>> (a) uses the rolling replacement of y a la Louis,
>> (b) saves an extra multiply in the comparison by using the maximum
>> before scaling by i,
>> and c) dispenses with the result line, a la Raul:
>>
>> finalrev =: 3 : 0NB.  good name?
>>
>> m =. >./y
>>
>> for_i. }.>:i.n =. #y do.
>>
>> m =. m >. i * q =. >./ y =. 2 <./\ y
>>
>> if. m >: q * n do. break. end.
>>
>> end.
>>
>>
>>
>>
>> 1000 ts'finalrev qq'
>>
>> 0.00353084 29696
>>
>> 1000 ts'cs1 qq'NB. !!! dead-heat !!!
>>
>> 0.00357644 29440
>>
>>
>> Enough?
>>
>> Mike
>>
>>
>>
>> On 25/06/2017 14:10, Louis de Forcrand wrote:
>>>
>>> Here is Mike’s version with 2<./\ 
insenserted (and >./i* replaced by i*>./

>>> since
>>> i is positive):
>>
>>
>>> cs1=: 3 : 0
>>>   m=. >./y
>>>   for_i. }.>:i.n=. #y do.
>>>m=. m>.q=. i*>./y=. 2<./\y
>>>if. (m*i)>:n*q do. break. end.
>>>   end.
>>>   m
>>> )
>>
>>
>>> 1e3 ts'cs1 qq'
>>> 0.00107603 29440
>>> qqq=: 1e4?.1e6
>>> ts'cs1 qqq'
>>> 0.045429 398080
>>> ts'cs qqq'
>>> 0.180366 397440
>>
>>
>>> Real fast!
>>> Louis
>>
>>
>>>> On 25 Jun 2017, at 14:47, Louis de Forcrand <ol...@bluewin.ch> wrote:
>>>>
>>>> Let V be a vector of real numbers, and V[i] its ith component.
>>>> Then
>>>>
>>>> min( V[i] … V[j+1]] ) = min( min( V[i] 
â… V[j] ), min( V[i+1] … V[j+1] )

>>>> ) ).
>>>>
>>>>
>>>>> This version is based on that:
>>>>
>>>>  

Re: [Jprogramming] largest rectangle problem

2017-07-03 Thread Martin Kreuzer

Mike -

Somewhere during the discussion, from "finalrev" 
an "i" somehow silently slipped away ...


On my machine (P4 3 GHz 4 GB ) I got

* using the (more conservative) break-off condition m >: q * n

   (timex 'lrds qq') , (memex 'lrds qq')
0.00452488 14912

* re-introducing the (more stringent) condition (m * i) >: (q * n)

   (timex 'lrds qq') , (memex 'lrds qq')
0.000540292 14912

which is about one more factor 10 in speed-up.

(btw, 'lrds' is my abbrev for 'largest rectangle in data set'.)

This is the code I used in testing:

lrds=: 3 : 
0   NB. Joint effort of RM, MD, LdF (final rev)
 m=. >./ 
y NB. 
initialize m with max(y), i.e. rectangle with base length 1
 for_j. 2 + i. <: n=. # y 
do.  NB. looping from j= 2 to n (total number of bars, const)
  m=. m >. j * q=. >./ y=. 2 <./\ 
yNB. q: max of running min between elements (x=2) of y

  if. (m * j) >: (q * n) do. return. end.  NB. skipping unnecessary tests
 end.
)

-M


At 2017-06-25 16:55, you wrote:


Thanks.   That's a bit strange.  I'd spotted the same thing - that we could
need only take the minimum of each pair of elements provided we replaced
the input array with the new set of minima.  But it appeared to be slower,
and I thought enough was enough, tweaking-wise!

Also,  Raul & Henry commented later on the superfluous result line,  "m" , at
the end of my previous best offering,  and as in 
Louis' revised version, below.

I'd only added that line when introducing the early stopping break, assuming
that m wouldn't be available. I should have checked!

So - here's a final (?) revised version,  which
(a) uses the rolling replacement of y a la Louis,
(b) saves an extra multiply in the comparison by using the maximum
before scaling by i,
and c) dispenses with the result line, a la Raul:

finalrev =: 3 : 0NB.  good name?

m =. >./y

for_i. }.>:i.n =. #y do.

m =. m >. i * q =. >./ y =. 2 <./\ y

if. m >: q * n do. break. end.

end.




1000 ts'finalrev qq'

0.00353084 29696

1000 ts'cs1 qq'NB. !!! dead-heat !!!

0.00357644 29440


Enough?

Mike



On 25/06/2017 14:10, Louis de Forcrand wrote:
Here is Mike’s version with 2<./\ inserted 
(and >./i* replaced by i*>./ since

i is positive):



cs1=: 3 : 0
  m=. >./y
  for_i. }.>:i.n=. #y do.
   m=. m>.q=. i*>./y=. 2<./\y
   if. (m*i)>:n*q do. break. end.
  end.
  m
)



1e3 ts'cs1 qq'
0.00107603 29440
qqq=: 1e4?.1e6
ts'cs1 qqq'
0.045429 398080
ts'cs qqq'
0.180366 397440



Real fast!
Louis



On 25 Jun 2017, at 14:47, Louis de Forcrand  wrote:

Let V be a vector of real numbers, and V[i] its ith component.
Then

min( V[i] … V[j+1]] ) = min( min( V[i] … V[j] 
), min( V[i+1] … V[j+1] )  ) ).


This version is based on that:

   ms=: #\ >./ . * [: >./@> # 2&(<./\&.>)&< ]
   1e3 ts 'ms qq'
0.00491435 5.74234e6

Incorporating this in Mike's explicit version 
with an early stopping condition

could lead to even faster runtimes!

Cheers,
Louis

On 25 Jun 2017, at 11:00, 'Mike Day' via 
Programming  wrote:


There must be something about breakfast.
A loopy stopping condition has just presented 
itself.  Others might see a tacitisation:


cs =: 3 : 0

m =. >./y

for_i. }.>:i.n =. #y do.

m =. m >. q =. >./ i ([ * <./\) y

if. (m * i) >: n * q do. break. end.

end.

m

)

q holds the maximum area at "width" i . No subsequent area

can be greater than q*n%i where n is the maximum width, so

stop if that is no greater than the current maximum, m.

It's twice as fast and uses slightly less space than c, the loopy verb

without an early stopping condition:

ts'c qq'

0.014258 21632

ts'cs qq'

0.0044897 21504

ts'C qq' NB. Raul's best tacit version - so far...

0.00803071 289920

Now for lunch,

Mike


On 24/06/2017 20:09, Raul Miller wrote:
True, except that if you did not have the 
inner >./ the "0 1 would not help.


Thanks,



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--
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

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

Re: [Jprogramming] Complex Number Problems

2017-07-01 Thread Martin Kreuzer

Raul -

* Many thanks for pointing out the difference 
between (.) the character and (.) the conjunction; has made it very clear.


* Powers of 10 -- the Dictionary says under 
/Constants that "The form of a numeric constant 
... is elaborated by the use of further letters, 
as in 2r3 for two-thirds, 2p1 for two [pi], and 2e3p1 for 2000 [pi]."


Here we have the exception to the rule 
formulated; (e) seems -by implementation- to be 
the "weakest" of these elements, "dominated" by 
r, p (and x), as a result of accepting only integer (not real) exponents:


   1e1r2NB. 10/2, instead of sqrt(10)
5
   1e1p1   NB. 10*pi, instead of 10^3.14...
31.4159
   1e1x1   NB. 10*en, instead of 10^2.71...
27.1828

-M

At 2017-07-01 15:23, you wrote:


Looking at word formation is important for understanding this issue:

   ;:'2 .3 .4 .5'
+-+-+-+-+-+-+-+
|2|.|3|.|4|.|5|
+-+-+-+-+-+-+-+
   ;:'0.2 0.3 0.4 0.5'
+---+
|0.2 0.3 0.4 0.5|
+---+
   ;:'3j.4'
++
|3j.4|
++

An issue here is that . is a conjunction and passing numbers to it is
invalid (bad syntax). Its domain for its verb arguments does not
include numbers.

That doesn't happen for 3j.4.  Meanwhile, if you look at the result:

   3j.4
3j0.4

you can see that it makes sense.

Basically, the dot character is a valid part of a number and since
3j.4 begins with a digit, it is being interpreted as a number, and
since . makes sense where it's being used here there's no error.

That would not be the case if the j were replaced with an e because
basically no one uses fractions in the exponent in exponential
notation. Hypothetically, it could be implemented, so that instead of
getting

   3e.4
|ill-formed number

you would get

   3*10^0.4
7.53566

but since 3e.4 is more likely to be a mistake than something done
intentionally, and since it's easy to catch, it's treated as an error.

Thanks,

--
Raul

On Sat, Jul 1, 2017 at 6:50 AM, bill lam <bbill@gmail.com> wrote:
> this is parsed as a token
>;:'3e.4'
> ++
> |3e.4|
> ++
> but it (rightfully?) throws an error
>3e.4
> |ill-formed number

> this is also parsed as a token
>;:'3j.4'
> ++
> |3j.4|
> ++

> the behavior seems endemic
>3p.4
> 4.74221
>3ad.4
> 2.3j0.0209438
>3ar.4
> 2.76318j1.16826
>3x.4
> 4.47547
>3b.4
> 1.3

> I think either 3e.4 should be legal or all others should be illegal
> for consistent.

> Сб, 01 июл 2017, Martin Kreuzer написал(а):
>> Looking at the examples, I came across the difference between
>>
>>3 j. 4  NB. spaces
>> 3j4
>>
>> and
>>
>>3j.4  NB. no spaces
>> 3j0.4
>>
>> Given that this (rightfully) throws an error
>>
>>.2 .3 .4 .5
>> |syntax error
>> |.2 .3 .4 .5
>>
>>  while this doesn't
>>
>>0.2 0.3 0.4 0.5
>> 0.2 0.3 0.4 0.5
>>
>> why then is the construct  3j.4 valid..?
>>
>> -M
>>
>>
>> At 2017-07-01 04:43, you wrote:
>>
>> > > As Henry points out, the NuVoc page is 
quite a bit clearer on this topic.

>> >
>> > Sample google search:
>> >site:jsoftware.com inurl:nuvoc complex
>> >
>> > Quite a bit of reading there, if you have the patience for it (be sure
>> > to mix in plenty of trial and error, though, or it's a total snoozer).
>> >
>> > Thanks,
>> >
>> > --
>> > Raul
>> >
>> >
>> > On Fri, Jun 30, 2017 at 11:30 PM, Rob 
Hodgkinson <rhodg...@me.com> wrote:
>> > > Hi Lawrence, the “ill-formed 
number† i¬  is because "j." is a verb,
>> > quite different to “œj† which is 
part of a noun construct (like 3j4,

>> >> or 1e3 for 1000).
>> >
>> > > So in your examples ...
>> >
>> > > NB. But wait, not so fast:
>> > >   1j.(2^0.5)%2
>> > > |ill-formed number
>> > > NB. No
>> >
>> > > NB. Now try to separate the 
“j.† verb with a spacspace either side to
>> > make it clear to J that this is not 
“1jxxx† where J would assume you

>> > are try trying to make a complex constant.
>> > >1 j. (2^0.5)%2
>> > > 1j0.707107
>> >
>> > > The reason is that J can also directly interpret ‘complex
>> > constantsâ€â€™ entered directly using 
the j notation (as a continuous

>> > sequence of non-blank chars)â€Â¦
>> > >3j4 NB. This is a single complex constant 3+i4
>> > > 3j4
>> >
>> > >3 j4NB. But now J tries to view this as a list of 

Re: [Jprogramming] Complex Number Problems

2017-07-01 Thread Martin Kreuzer

Agreed.
-M


At 2017-07-01 15:26, you wrote:


I think the inconsistency you are pointing to here is that r. as a
verb has a different meaning from r in number formation?

But I think that that's a red herring. For example, e. as a verb has a
different meaning from e in number formation.

Thanks,

--
Raul


On Sat, Jul 1, 2017 at 7:34 AM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> Looking at (r.) Angle, which is a verb somewhat similar to (j.) Complex, I
> get

>2 r. 0.2
> 1.96013j0.397339
>2 r.0.2
> 1.96013j0.397339
>2 r. 2
> _0.832294j1.81859
>2 r.2
> _0.832294j1.81859

> which all four look fine to me, but are not constistent with (j.)'s
> behaviour, that's been my point ...

> and then there is this construct

>2r.2
> 10

> which doesn't have anything to do with (r.) Angle but is a (fractional)
> constant of value 2/0.2 showing another instance of .2 being interpreted as
> 0.2 which is not accepted in other circumstances.

> -M


> At 2017-07-01 10:50, you wrote:

>> this is parsed as a token
>>;:'3e.4'
>> ++
>> |3e.4|
>> ++
>> but it (rightfully?) throws an error
>>3e.4
>> |ill-formed number
>>
>> this is also parsed as a token
>>;:'3j.4'
>> ++
>> |3j.4|
>> ++
>>
>> the behavior seems endemic
>>3p.4
>> 4.74221
>>3ad.4
>> 2.3j0.0209438
>>3ar.4
>> 2.76318j1.16826
>>3x.4
>> 4.47547
>>3b.4
>> 1.3
>>
>> I think either 3e.4 should be legal or all others should be illegal
>> for consistent.
>>
>> Сб, 01 июл 2017, Martin 
Kreuzer Ð½Ð°Ð¿Ð¸Ñ Ð°Ð»(а):

>>
>> > Looking at the examples, I came across the difference between
>> >
>> >3 j. 4  NB. spaces
>> > 3j4
>> >
>> > and
>> >
>> >3j.4  NB. no spaces
>> > 3j0.4
>> >
>> > Given that this (rightfully) throws an error
>> >
>> >.2 .3 .4 .5
>> > |syntax error
>> > |.2 .3 .4 .5
>> >
>> >  while this doesn't
>> >
>> >0.2 0.3 0.4 0.5
>> > 0.2 0.3 0.4 0.5
>> >
>> > why then is the construct  3j.4 valid..?
>> >
>> > -M
>> >
>> >
>> > At 2017-07-01 04:43, you wrote:
>> >
>> > > > As Henry points out, the NuVoc page is quite a bit clearer on this
>> > > > topic.
>> > >
>> > > Sample google search:
>> > >site:jsoftware.com inurl:nuvoc complex
>> > >
>> > > Quite a bit of reading there, if you have the patience for it (be sure
>> > > to mix in plenty of trial and error, though, or it's a total snoozer).
>> > >
>> > > Thanks,
>> > >
>> > > --
>> > > Raul
>> > >
>> > >
>> > > On Fri, Jun 30, 2017 at 11:30 PM, Rob Hodgkinson <rhodg...@me.com>
>> > > wrote:
>> > > > Hi Lawrence, the â€Âœill-formed 
numberâ€Â  is because "j." is ais a

>> > > > verb,
>> > > quite different to 
â€ÂœjÃjâ€Â  which is part of a noun construct

>> > > (likke 3j4,
>> > > or 1e3 for 1000).
>> > >
>> > > > So in your examples ...
>> > >
>> > > > NB. But wait, not so fast:
>> > > >   1j.(2^0.5)%2
>> > > > |ill-formed number
>> > > > NB. No
>> > >
>> > > > NB. Now try to separate the 
â€Âœj.â€Â  verb with a space either

>> > > > > > side to
>> > > make it clear to J that this is not 
â€Âœ1jxxxâ€Â  where J would

>> > > assume ume you
>> > > are trying to make a complex constant.
>> > > >1 j. (2^0.5)%2
>> > > > 1j0.707107
>> > >
>> > > > The reason is that J can also directly interpret ‬˜complex
>> > > constantsâ€Â™ entered directrectly 
using the j notation (as a continuous

>> > > sequence of non-blank chars)â€Â¦
>>
>> > > >3j4NBB. This is a single complex constant 3+i4
>> > > > 3j4
>> > >
>> > > >3 j4NB. But now J tries to view this as a list of (3) and
>> > > > (j4)
>> > > which which J would assume is (3) and a variable called (j4).
>> > > > |syntax error
>> > > > | 3 j4
>> > >
>> >

Re: [Jprogramming] Complex Number Problems

2017-07-01 Thread Martin Kreuzer

Looking at (r.) Angle, which is a verb somewhat similar to (j.) Complex, I get

   2 r. 0.2
1.96013j0.397339
   2 r.0.2
1.96013j0.397339
   2 r. 2
_0.832294j1.81859
   2 r.2
_0.832294j1.81859

which all four look fine to me, but are not 
constistent with (j.)'s behaviour, that's been my point ...


and then there is this construct

   2r.2
10

which doesn't have anything to do with (r.) Angle 
but is a (fractional) constant of value 2/0.2 
showing another instance of .2 being interpreted 
as 0.2 which is not accepted in other circumstances.


-M

At 2017-07-01 10:50, you wrote:


this is parsed as a token
   ;:'3e.4'
++
|3e.4|
++
but it (rightfully?) throws an error
   3e.4
|ill-formed number

this is also parsed as a token
   ;:'3j.4'
++
|3j.4|
++

the behavior seems endemic
   3p.4
4.74221
   3ad.4
2.3j0.0209438
   3ar.4
2.76318j1.16826
   3x.4
4.47547
   3b.4
1.3

I think either 3e.4 should be legal or all others should be illegal
for consistent.

Сб, 01 июл 2017, Martin Kreuzer написал(а):
> Looking at the examples, I came across the difference between
>
>3 j. 4  NB. spaces
> 3j4
>
> and
>
>3j.4  NB. no spaces
> 3j0.4
>
> Given that this (rightfully) throws an error
>
>.2 .3 .4 .5
> |syntax error
> |.2 .3 .4 .5
>
>  while this doesn't
>
>0.2 0.3 0.4 0.5
> 0.2 0.3 0.4 0.5
>
> why then is the construct  3j.4 valid..?
>
> -M
>
>
> At 2017-07-01 04:43, you wrote:
>
> > > As Henry points out, the NuVoc page is 
quite a bit clearer on this topic.

> >
> > Sample google search:
> >site:jsoftware.com inurl:nuvoc complex
> >
> > Quite a bit of reading there, if you have the patience for it (be sure
> > to mix in plenty of trial and error, though, or it's a total snoozer).
> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> > On Fri, Jun 30, 2017 at 11:30 PM, Rob Hodgkinson <rhodg...@me.com> wrote:
> > > Hi Lawrence, the “ill-formed 
number” is because "j." is a verb,
> > quite different to “j” which is 
part of a noun construct (like 3j4,

> > or 1e3 for 1000).
> >
> > > So in your examples ...
> >
> > > NB. But wait, not so fast:
> > >   1j.(2^0.5)%2
> > > |ill-formed number
> > > NB. No
> >
> > > NB. Now try to separate the 
“j.” verb with a space either side to
> > make it clear to J that this is not 
“1jxxx” where J would assume you

> > are trying to make a complex constant.
> > >1 j. (2^0.5)%2
> > > 1j0.707107
> >
> > > The reason is that J can also directly interpret ‘complex
> > constants’ entered directly using the j notation (as a continuous
> > sequence of non-blank chars)…
> > >3j4NB. This is a single complex constant 3+i4
> > > 3j4
> >
> > >3 j4NB. But now J tries to view this as a list of (3) and (j4)
> > which which J would assume is (3) and a variable called (j4).
> > > |syntax error
> > > | 3 j4
> >
> > > As Henry points out, the NuVoc page is 
quite a bit clearer on this topic.

> >
> > > HTH, Regards Rob
> >
> >
> > >> On 1 Jul 2017, at 1:14 pm, Lawrence Wickert <skippy_...@hotmail.com>
> > wrote:
> > >>
> > >> Hello,  I am a old EE still trying to learn.  I am a real beginner
> > having no end of problems with specifying complex numbers.  I am using
> > j64-804 on ubuntu 12.04.  I am either doing something really stupid or I
> > need to update to 806.  Updating anything gives me heartburn or worse so
> > I hope it is just my misunderstanding of basic principles. Although I
> > have a bad habit of RTFM as a last resort I have tried the Dictionary to
> > no avail.  I appreciate any guidance.
> > >>
> > >>   0j(2^0.5)%2
> > >> |ill-formed number
> > >>
> > >>   0j((2^0.5)%2)
> > >> |ill-formed number
> > >>
> > >>   j.(2^0.5)%2
> > >> 0j0.707107
> > >> NB. Eureaka, OK, I get it!
> > >>
> > >> NB. But wait, not so fast:
> > >>   1j.(2^0.5)%2
> > >> |ill-formed number
> > >> NB. No
> > >>
> > >>   1j(2^0.5)%2
> > >> |ill-formed number
> > >> NB. Still No
> > >>
> > >>   1+j.(2^0.5)%2
> > >> 1j0.707107
> > >> NB. This works!
> > >>
> > >> Let's try to do something with it:
> > >>   k=:(0 1+j.(2^0.5)%2 3 4 0 5)
&g

Re: [Jprogramming] Complex Number Problems

2017-07-01 Thread Martin Kreuzer

Looking at the examples, I came across the difference between

   3 j. 4  NB. spaces
3j4

and

   3j.4  NB. no spaces
3j0.4

Given that this (rightfully) throws an error

   .2 .3 .4 .5
|syntax error
|.2 .3 .4 .5

 while this doesn't

   0.2 0.3 0.4 0.5
0.2 0.3 0.4 0.5

why then is the construct  3j.4 valid..?

-M


At 2017-07-01 04:43, you wrote:


> As Henry points out, the NuVoc page is quite a bit clearer on this topic.

Sample google search:
   site:jsoftware.com inurl:nuvoc complex

Quite a bit of reading there, if you have the patience for it (be sure
to mix in plenty of trial and error, though, or it's a total snoozer).

Thanks,

--
Raul


On Fri, Jun 30, 2017 at 11:30 PM, Rob Hodgkinson  wrote:
> Hi Lawrence, the “ill-formed number” is 
because "j." is a verb, quite different to 
“j” which is part of a noun construct (like 3j4, or 1e3 for 1000).


> So in your examples ...

> NB. But wait, not so fast:
>   1j.(2^0.5)%2
> |ill-formed number
> NB. No

> NB. Now try to separate the “j.” verb 
with a space either side to make it clear to J 
that this is not “1jxxx” where J would 
assume you are trying to make a complex constant.

>1 j. (2^0.5)%2
> 1j0.707107

> The reason is that J can also directly 
interpret ‘complex constants’ entered 
directly using the j notation (as a continuous sequence of non-blank chars)…

>3j4NB. This is a single complex constant 3+i4
> 3j4

>3 j4NB. But now J tries to view this 
as a list of (3) and (j4) which which J would 
assume is (3) and a variable called (j4).

> |syntax error
> | 3 j4

> As Henry points out, the NuVoc page is quite a bit clearer on this topic.

> HTH, Regards Rob


>> On 1 Jul 2017, at 1:14 pm, Lawrence Wickert 
 wrote:

>>
>> Hello,  I am a old EE still trying to 
learn.  I am a real beginner having no end of 
problems with specifying complex numbers.  I am 
using j64-804 on ubuntu 12.04.  I am either 
doing something really stupid or I need to 
update to 806.  Updating anything gives me 
heartburn or worse so I hope it is just my 
misunderstanding of basic principles. Although 
I have a bad habit of RTFM as a last resort I 
have tried the Dictionary to no avail.  I appreciate any guidance.

>>
>>   0j(2^0.5)%2
>> |ill-formed number
>>
>>   0j((2^0.5)%2)
>> |ill-formed number
>>
>>   j.(2^0.5)%2
>> 0j0.707107
>> NB. Eureaka, OK, I get it!
>>
>> NB. But wait, not so fast:
>>   1j.(2^0.5)%2
>> |ill-formed number
>> NB. No
>>
>>   1j(2^0.5)%2
>> |ill-formed number
>> NB. Still No
>>
>>   1+j.(2^0.5)%2
>> 1j0.707107
>> NB. This works!
>>
>> Let's try to do something with it:
>>   k=:(0 1+j.(2^0.5)%2 3 4 0 5)
>> |length error
>> |   k=:(0 1+j.(2^0.5)%2 3 4 0 5)
>>
>> NB. Maybe parantheses will help:
>>   k=:(0 (1+j.(2^0.5)%2) 3 4 0 5)
>> |syntax error
>> |   k=:(0(1+j.(2^0.5)%2)3 4 0 5)
>>
>> NB. This one has to work:
>>   k=:(0 1j0.7071 3 4 0 5)
>>   k
>> 0 1j0.7071 3 4 0 5
>> NB. It does but it can't be the only way to do it.
>>
>> NB. One last rry:
>>   g=: 1+j.(2^0.5)%2
>>   g
>> 1j0.707107
>> NB. That's nice.
>>
>>   k=:(0 g 3 4 0 5)
>> |syntax error
>> |   k=:(0 g 3 4 0 5)
>> NB. This isn't nice.
>>
>> Lost in the high desert of New Mexico, Larry Wickert
>>
>> --
>> 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

Re: [Jprogramming] largest rectangle problem

2017-06-20 Thread Martin Kreuzer

Proved myself wrong with this set of data:

   lrds 2 6 7 4 1 7 7 NB. largest rectangle within data set 
(at that stage only matrix output)

2 6 7 4 1 7 7
0 1 1 1 0 1 1NB. 14 vs 12 (hmm)

So, if I'd stick with that approach, it isn't the *longest *block, 
but maybe largest product of block length and minimum height.

Even that would need some coding to extract different block lengths ...

-M

At 2017-06-20 16:07, you wrote:


Both of those are valid answers.

The problem is simply to determine the largest area.

Thanks,

--
Raul


On Tue, Jun 20, 2017 at 11:58 AM, 'Pascal Jasmin' via Programming
 wrote:
> is the answer to your example, 6x2 or 4x3?



> 
> From: Raul Miller 
> To: Programming forum 
> Sent: Tuesday, June 20, 2017 11:30 AM
> Subject: [Jprogramming] largest rectangle problem



> Something I stumbled over today.


> If we have a series of bars of varying height, what's the largest

> rectangle that can be drawn over the bars without covering any empty

> space.


> For example:


>'*'#"0~2 6 7 4 1 7

> **

> **

> ***

> 

> *

> ***


> I'll post a solution later, and I'll be interested in seeing if it's

> basically the only obvious approach or if there's a variety of good

> approaches. (I have reason to believe, though, that there's a better

> way than what I came up with.)


> Thanks,


> --

> Raul

> --

> 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

Re: [Jprogramming] largest rectangle problem

2017-06-20 Thread Martin Kreuzer

@Raul

Beg your pardon for taking your time ...

This is what I did (as an approach); maybe I learn something from you 
(or somebody else) proving me wrong.


Anyway, this seems to work on the given set of data:

Taking  the mean of the column heights

   ] v=. 2 6 7 4 1 7
2 6 7 4 1 7
   am=. +/ % #
   am v
4.5

gives a "compacted" rectangle of 4.5 times 6 (base) = 27 units of area.

IIf I 'floor' the mean

   ] mf=. <. am v
4

and take a look at which columns exceed (the floor of ) the mean I 
get this matrix


   v,:mf<: v
2 6 7 4 1 7
0 1 1 1 0 1

Here I got stuck with my coding, so I will describe in words only 
what I intend to do further on:


* Extract the indices of the largest (longest) block of 1s (1..3) and 
calculate its length (3)

* Within that block search for the lowest column value (4)
* Multiply  block length (3) with lowest column value within that 
range (4) to obtain a rectangle area of 3*4 = 12 units.


Thanks for your patience.
-M

At 2017-06-20 16:07, you wrote:


Both of those are valid answers.

The problem is simply to determine the largest area.

Thanks,

--
Raul


On Tue, Jun 20, 2017 at 11:58 AM, 'Pascal Jasmin' via Programming
 wrote:
> is the answer to your example, 6x2 or 4x3?



> 
> From: Raul Miller 
> To: Programming forum 
> Sent: Tuesday, June 20, 2017 11:30 AM
> Subject: [Jprogramming] largest rectangle problem



> Something I stumbled over today.


> If we have a series of bars of varying height, what's the largest

> rectangle that can be drawn over the bars without covering any empty

> space.


> For example:


>'*'#"0~2 6 7 4 1 7

> **

> **

> ***

> 

> *

> ***


> I'll post a solution later, and I'll be interested in seeing if it's

> basically the only obvious approach or if there's a variety of good

> approaches. (I have reason to believe, though, that there's a better

> way than what I came up with.)


> Thanks,


> --

> Raul

> --

> 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

Re: [Jprogramming] (- ~:) documented somewhere..?

2017-04-05 Thread Martin Kreuzer

For the record (and later reference) ...

Euler's product formula for the totient of a number n with k 
*distinct* prime factors p_i reads


phi(n) = n * (1 - 1/p_1) * (1 - 1/p_2) * ... * (1 - 1/p_k)

Rewriting this by replacing n with the product of prime factors one gains

Product (i=1 to k) over [ (p_i - 1) * p_i^(e_i - 1) ]

(J code)
*/ (p-1)*p^e-1

~-~-~

Andrew Nikitin's version is a fresh look at the same formula, as 
illustrated by this example:


   ] n=. !7  NB. composite number
5040
   q: n  NB. listing prime factors
2 2 2 2 3 3 5 7
   ~: q: n  NB. marking distinct prime factors
1 0 0 0 1 0 1 1

Subtracting the two lists gives

   (q: n) - (~: q: n)
1 2 2 2 2 3 4 6

a result which may be looked at (grouped) like
1 2 2 2 | 2 3 | 4 | 6

Now the brilliant idea obviously is
that subtracting the 'Nub Sieve' of the list of prime factors from 
that very list

'kills two birds with one stone' in as it

[1] subtracts 1 from each of the *distinct* prime factors and
[2] reduces the number of identical prime factors by 1 each

at the very *same* time.

Writing the difference as a 'Hook' and

   (- ~:) q: n
1 2 2 2 2 3 4 6

building the product and

   */ (- ~:) q: n
1152

realizing that (*/) is the 'Inverse' of (q:)
using 'Under (Dual)' one gets the final expression

   (- ~:) &. q: n
1152

~-~-~

-M





At 2017-04-02 14:26, you wrote:


Andrew Nikitin posted the expression to the forum 2009-11-03
http://www.jsoftware.com/pipermail/programming/2009-November/016746.html.
You can derive it by more conventional expressions for computing the
totient, such as the expression */(p-1)*p^e-1 which immediately precedes it
in the dictionary.


On Sun, Apr 2, 2017 at 12:39 AM, Martin Kreuzer <i...@airkreuzer.com> wrote:

> Hi all -

> In section 'Primes' of the Vocabul I found this line of code (at the very
> end, function no 5):

> (- ~:) &. q: y

> I do know that it is another way to calculate the totient of y, and
> I'm somehow familiar with the use of (~:) and (&.) and (q:), but
> have not yet found any documentation of this construct (- ~:)
> [btw, these seem to work too (+ ~:), (* ~:), (% ~:)]

> Where should I explore further..?

> -M

> --
> 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

Re: [Jprogramming] (- ~:) documented somewhere..?

2017-04-03 Thread Martin Kreuzer

Bob,
Thanks for the hint on Dissect and accompanying Labs - mighty tool.
F2 is responding now after having modified the 'userkeys.cfg' file 
(according to the Wiki)

plus a couple of restarts of JQt ...
-M

At 2017-04-02 22:50, you wrote:


Hi Martin,

I think that Don was referring to Dissect, the visual debugger that 
Henry Rich created for the jqt environment.

It is available on the Package Manager for the jqt environment.
You may want to look at the labs for Dissect I & II for more information.

Cheers, bob

> On Apr 2, 2017, at 3:27 PM, Martin Kreuzer <i...@airkreuzer.com> wrote:
>
> * Raul,
>
> I have been working on this example
>
>   (- ~:) &. q: 5040
> 1152
>
> and have been able to unfold it to
>
>   q:^:_1 (q: 5040) - (~: q: 5040)
> 1152
>
> resp
>
>   */ (q: 5040) - (~: q: 5040)
> 1152
>
> and all the time hadn't recognized (- ~:) as the hook it is ...
> Thanks for pointing that out to me (again..?).
>
> * Don,
>
> I've never used that 'F2' trick as
> I'm mostly doing stuff within jconsole (sometimes in jqt) -
> I'd be interested to learn where (in what kind of environment) is 
that hotkey to be used..?

>
> * Roger,
>
> I've successflully derived the more conventional product formula
> */(p-1)*p^e-1
> and obviously need to do some more deriving :)
> Thanks for the link to Andrew's post;
> I also regard his expression as 'neat',
> that's been the motivation to follow up on it ...
>
> -M
>
>
> At 2017-04-02 07:48, you wrote:
>
>> Are you asking about trains (hooks and forks)?
>>
>> http://www.jsoftware.com/help/dictionary/dictf.htm
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Sun, Apr 2, 2017 at 3:39 AM, Martin Kreuzer 
<i...@airkreuzer.com> wrote:

>> > Hi all -
>>
>> > In section 'Primes' of the Vocabul I found this line of code 
(at the very

>> > end, function no 5):
>>
>> > (- ~:) &. q: y
>>
>> > I do know that it is another way to calculate the totient of y, and
>> > I'm somehow familiar with the use of (~:) and (&.) and (q:), but
>> > have not yet found any documentation of this construct (- ~:)
>> > [btw, these seem to work too (+ ~:), (* ~:), (% ~:)]
>>
>> > Where should I explore further..?
>>
>> > -M
>>
>> > --
>> > 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


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

Re: [Jprogramming] (- ~:) documented somewhere..?

2017-04-02 Thread Martin Kreuzer

* Raul,

I have been working on this example

   (- ~:) &. q: 5040
1152

and have been able to unfold it to

   q:^:_1 (q: 5040) - (~: q: 5040)
1152

resp

   */ (q: 5040) - (~: q: 5040)
1152

and all the time hadn't recognized (- ~:) as the hook it is ...
Thanks for pointing that out to me (again..?).

* Don,

I've never used that 'F2' trick as
I'm mostly doing stuff within jconsole (sometimes in jqt) -
I'd be interested to learn where (in what kind of environment) is 
that hotkey to be used..?


* Roger,

I've successflully derived the more conventional product formula
*/(p-1)*p^e-1
and obviously need to do some more deriving :)
Thanks for the link to Andrew's post;
I also regard his expression as 'neat',
that's been the motivation to follow up on it ...

-M


At 2017-04-02 07:48, you wrote:


Are you asking about trains (hooks and forks)?

http://www.jsoftware.com/help/dictionary/dictf.htm

Thanks,

--
Raul


On Sun, Apr 2, 2017 at 3:39 AM, Martin Kreuzer <i...@airkreuzer.com> wrote:
> Hi all -

> In section 'Primes' of the Vocabul I found this line of code (at the very
> end, function no 5):

> (- ~:) &. q: y

> I do know that it is another way to calculate the totient of y, and
> I'm somehow familiar with the use of (~:) and (&.) and (q:), but
> have not yet found any documentation of this construct (- ~:)
> [btw, these seem to work too (+ ~:), (* ~:), (% ~:)]

> Where should I explore further..?

> -M

> --
> 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

[Jprogramming] (- ~:) documented somewhere..?

2017-04-02 Thread Martin Kreuzer

Hi all -

In section 'Primes' of the Vocabul I found this line of code (at the 
very end, function no 5):


(- ~:) &. q: y

I do know that it is another way to calculate the totient of y, and
I'm somehow familiar with the use of (~:) and (&.) and (q:), but
have not yet found any documentation of this construct (- ~:)
[btw, these seem to work too (+ ~:), (* ~:), (% ~:)]

Where should I explore further..?

-M

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

Re: [Jprogramming] Geometric Mean definition ...

2016-08-31 Thread Martin Kreuzer
... and my last remark probably deals more with efficiency than 
effectiveness -- I sometimes fight for words even in my mother tongue.

-M

At 2016-08-31 06:33, you wrote:


Don -

That's been exacly the idea behind what I called "gm1" (taking the 
roots first) ...


The Log approach "gm2" however proves to be a little bit more effective:

   1 timespacex 'gm1 >: ? 6 $~ 2^10'
0.000185607 50816
   1 timespacex 'gm2 >: ? 6 $~ 2^10'
0.000110259 42752

-M


At 2016-08-31 03:24, you wrote:


How about this-it fits the definition of "nth root of product of n items"



gmean =: # %: */



(gmean,gm1)>: ? 6 $~ 637



2.98625 2.98625



(gm0,gm1,gm2,gmean)>:?6$~637



2.97123 2.97123 2.97123 2.97123



(gm0,gm1,gm2,gmean) >:?6$~637



_ 3.04854 3.04854 _



(gmean, gm1)s=:>:?6$~638



_ 3.06565



b=: 638 %: s



*/b



3.06565



(amean s) ^ 638





*/s




The problem appears when */ results in an overflow and is detected 
as infinite



*/ 638#3



2.5314e304



*/ 638#4






  638 %:638#4



1.00218 1.00218 1.00218 1.00218218 1.00218 1.00218 ...



*/ 638 %:638#4





The advantage lies with taking the roots first for numbers >1




Don Kelly




On 8/26/2016 4:38 AM, Martin Kreuzer wrote:

Hi all -



Sharing something I observed ...



While the definitions (for arithmetic and geometric mean)



   amean=: +/ % #
and
   gmean=: */ %:~ #


are nice to look at as a pair (because of symmetry) I prefer this 
definition of geometric mean



   gmean=: [: */ # %: ]
or
   NB. using the Log domain
   gmean=: [: ^ [: amean ^.



because, given these (intermediate) definitions



   NB. often found
   gm0=. */ %:~ #
   NB. taking the roots first, then multiply
   gm1=. [: */ # %: ]
   NB. definition found on (&.:) page of NuVoc
   gm2=. amean &.: ^.



I got these results (see gm0 failing while the other two hold)



   (gm0,gm1,gm2) >: ? 6 $~ 637
3.04409 3.04409 3.04409
   (gm0,gm1,gm2) >: ? 6 $~ 638
_ 3.05264 3.05264
   (gm0,gm1,gm2) >: ? 6 $~ 2^24
_ 2.99357 2.99357



under J v8.04 on a 32-bit Vista machine.



Thanks
-M



--
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

Re: [Jprogramming] Geometric Mean definition ...

2016-08-31 Thread Martin Kreuzer

Don -

That's been exacly the idea behind what I called "gm1" (taking the 
roots first) ...


The Log approach "gm2" however proves to be a little bit more effective:

   1 timespacex 'gm1 >: ? 6 $~ 2^10'
0.000185607 50816
   1 timespacex 'gm2 >: ? 6 $~ 2^10'
0.000110259 42752

-M


At 2016-08-31 03:24, you wrote:


How about this-it fits the definition of "nth root of product of n items"

gmean =: # %: */

(gmean,gm1)>: ? 6 $~ 637

2.98625 2.98625

(gm0,gm1,gm2,gmean)>:?6$~637

2.97123 2.97123 2.97123 2.97123

(gm0,gm1,gm2,gmean) >:?6$~637

_ 3.04854 3.04854 _

(gmean, gm1)s=:>:?6$~638

_ 3.06565

b=: 638 %: s

*/b

3.06565

(amean s) ^ 638



*/s



The problem appears when */ results in an overflow and is detected as infinite

*/ 638#3

2.5314e304

*/ 638#4




  638 %:638#4

1.00218 1.00218 1.00218 1.00218218 1.00218 1.00218 ...

*/ 638 %:638#4



The advantage lies with taking the roots first for numbers >1


Don Kelly


On 8/26/2016 4:38 AM, Martin Kreuzer wrote:

Hi all -



Sharing something I observed ...



While the definitions (for arithmetic and geometric mean)



   amean=: +/ % #
and
   gmean=: */ %:~ #


are nice to look at as a pair (because of symmetry) I prefer this 
definition of geometric mean



   gmean=: [: */ # %: ]
or
   NB. using the Log domain
   gmean=: [: ^ [: amean ^.



because, given these (intermediate) definitions



   NB. often found
   gm0=. */ %:~ #
   NB. taking the roots first, then multiply
   gm1=. [: */ # %: ]
   NB. definition found on (&.:) page of NuVoc
   gm2=. amean &.: ^.



I got these results (see gm0 failing while the other two hold)



   (gm0,gm1,gm2) >: ? 6 $~ 637
3.04409 3.04409 3.04409
   (gm0,gm1,gm2) >: ? 6 $~ 638
_ 3.05264 3.05264
   (gm0,gm1,gm2) >: ? 6 $~ 2^24
_ 2.99357 2.99357



under J v8.04 on a 32-bit Vista machine.



Thanks
-M



--
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

Re: [Jprogramming] Geometric Mean definition ...

2016-08-26 Thread Martin Kreuzer

Brian -

This of course depends on _both_ the no of elements and their size 
(the smaller the elements, the higher you can go)


   (gm0,gm1,gm2) 441#5
5 5 5
   (gm0,gm1,gm2) 442#5
_ 5 5

   (gm0,gm1,gm2) 396#6
6 6 6
   (gm0,gm1,gm2) 397#6
_ 6 6

or, using Raul's argument, it fails at the same order of magnitude

   5^ 441 442
1.76105e308 _

   6^ 396 397
1.40571e308 _

-M


At 2016-08-26 21:38, you wrote:


Martin,

Your examples of gm0 failing are not clear to me because you use random
data.
I tried the following nonrandom data, but a sort of random case where the
number of data values seems to be the issue because for samples of 441 and
less the failure is not present, but is present for 442 and greater.

Does this example suggest any more general pattern to other folks?


   (gm0,gm1,gm2) 442#5
_ 5 5
   (gm0,gm1,gm2) 441#5
5 5 5

On Fri, Aug 26, 2016 at 7:38 AM, Martin Kreuzer <i...@airkreuzer.com> wrote:

> Hi all -

> Sharing something I observed ...

> While the definitions (for arithmetic and geometric mean)

>amean=: +/ % #
> and
>gmean=: */ %:~ #

> are nice to look at as a pair (because of symmetry) I prefer this
> definition of geometric mean

>gmean=: [: */ # %: ]
> or
>NB. using the Log domain
>gmean=: [: ^ [: amean ^.

> because, given these (intermediate) definitions

>NB. often found
>gm0=. */ %:~ #
>NB. taking the roots first, then multiply
>gm1=. [: */ # %: ]
>NB. definition found on (&.:) page of NuVoc
>gm2=. amean &.: ^.

> I got these results (see gm0 failing while the other two hold)

>(gm0,gm1,gm2) >: ? 6 $~ 637
> 3.04409 3.04409 3.04409
>(gm0,gm1,gm2) >: ? 6 $~ 638
> _ 3.05264 3.05264
>(gm0,gm1,gm2) >: ? 6 $~ 2^24
> _ 2.99357 2.99357

> under J v8.04 on a 32-bit Vista machine.

> Thanks
> -M

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




--
(B=) <-my sig
Brian Schott
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

[Jprogramming] Geometric Mean definition ...

2016-08-26 Thread Martin Kreuzer

Hi all -

Sharing something I observed ...

While the definitions (for arithmetic and geometric mean)

   amean=: +/ % #
and
   gmean=: */ %:~ #

are nice to look at as a pair (because of symmetry) I prefer this 
definition of geometric mean


   gmean=: [: */ # %: ]
or
   NB. using the Log domain
   gmean=: [: ^ [: amean ^.

because, given these (intermediate) definitions

   NB. often found
   gm0=. */ %:~ #
   NB. taking the roots first, then multiply
   gm1=. [: */ # %: ]
   NB. definition found on (&.:) page of NuVoc
   gm2=. amean &.: ^.

I got these results (see gm0 failing while the other two hold)

   (gm0,gm1,gm2) >: ? 6 $~ 637
3.04409 3.04409 3.04409
   (gm0,gm1,gm2) >: ? 6 $~ 638
_ 3.05264 3.05264
   (gm0,gm1,gm2) >: ? 6 $~ 2^24
_ 2.99357 2.99357

under J v8.04 on a 32-bit Vista machine.

Thanks
-M

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

Re: [Jprogramming] Simple example with (@.) 'Agenda'

2016-07-12 Thread Martin Kreuzer

Pascal -
Thanks for the quick answer;
I already worked the example from the NuVoc page 
using the prime exponents from (_ q:), I 
mentioned it here simply as a reference for result values.

My idea has been to stick with the straight approach (as an exercise) ...
-M

At 2016-07-12 16:14, you wrote:


__ q: each 16 17 18
┌─┬──┬───┐
│2│17│2 3│
│4│ 1│1 2│
└─┴──┴───┘


gives divisors as 2 rows with exponents as 2nd.


_ q: each 16 17 18
┌─┬─────────────┬───┐
│4│0 0 0 0 0 0 1│1 2│
└─┴─────────────┴───┘


just the exponents.

the 2nd program just increases these by 1, and takes product.



- Original Message -
From: Martin Kreuzer <i...@airkreuzer.com>
To: programm...@jsoftware.com
Sent: Tuesday, July 12, 2016 12:03 PM
Subject: [Jprogramming] Simple example with (@.) 'Agenda'

Hi all -

Tried a _straight approach_ to answer the question "How many divisors
does an (integer) number have?" ...

Hope my math is correct:

Check divisibility for all integers from 1 to floor of number's (square) root;
count number of divisor product pairs;
double that to get number of divisors and
subtract 1 in case of a square (integer root) which sports one
symmetrical pair.

This is what I put together:

dn=. 13 : '(<:)`(]) @. (* (|~ %:) y) +: +/ -. * (>: i. <. %: y) | y'("0)
dn 16 17 48 49 1024 1025 1103
5 2 10 3 11 6 2

As a comparison, here are the results using the example verb from the
NuVoc/ Prime Exponents page:

don=. 13 : '*/ >: _ q: y'("0)
don 16 17 48 49 1024 1025 1103
5 2 10 3 11 6 2

Guess verb (dn) can be written in a more compact way, sort of
"folding it" as it obviously has similar structural elements;

Q: Would someone have the time and patience to gently guide me through this..?

Thanks
-M

--
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

[Jprogramming] Simple example with (@.) 'Agenda'

2016-07-12 Thread Martin Kreuzer

Hi all -

Tried a _straight approach_ to answer the question "How many divisors 
does an (integer) number have?" ...


Hope my math is correct:

Check divisibility for all integers from 1 to floor of number's (square) root;
count number of divisor product pairs;
double that to get number of divisors and
subtract 1 in case of a square (integer root) which sports one 
symmetrical pair.


This is what I put together:

   dn=. 13 : '(<:)`(]) @. (* (|~ %:) y) +: +/ -. * (>: i. <. %: y) | y'("0)
   dn 16 17 48 49 1024 1025 1103
5 2 10 3 11 6 2

As a comparison, here are the results using the example verb from the 
NuVoc/ Prime Exponents page:


   don=. 13 : '*/ >: _ q: y'("0)
   don 16 17 48 49 1024 1025 1103
5 2 10 3 11 6 2

Guess verb (dn) can be written in a more compact way, sort of 
"folding it" as it obviously has similar structural elements;


Q: Would someone have the time and patience to gently guide me through this..?

Thanks
-M

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

[Jprogramming] Use of (@) 'Atop'

2016-07-07 Thread Martin Kreuzer

Hi all -

Approximating Pi using the Monte Carlo method (circle enscribed in 
unit square) came up with


   pia=. 13 : '(4 * y %~ +/ 1 >: +/ *: <: +: ? (2,y) $ 0)'("0)
   (pia 10^(4+i.3)) ,:(4+i.3)
3.1524 3.1438 3.14106
 4  5   6

I then compared my version with the J verb at Rosetta Code and the 
only difference I found was the use of 'Atop':


piMC=: monad define "0
   4* y%~ +/ 1>: %: +/ *: <: +: (2,y) ?@$ 0
)

Q:
What is the advantage (in this particular case) of using 'Atop'..?
   ? (2,y) $ 0
vs
   (2,y) ?@$ 0

Thanks
-M

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

[Jprogramming] Avarage of Distances between Point Pairs in Unit Square, Cube, Tesseract, etc (parallel thread)

2016-07-05 Thread Martin Kreuzer

Raul -

I opened this as a "parallel thread" to not interfere (mess) with 
your original one ...


Using the 'brute force' approach you mentioned (took me a while, but 
I'm now with you, after I looked up 'Under" (&.:) again)


Random Generator arguments:

[1] pair of points, two points: 2
[2] no of coordinates, dimension: 2, 3, 4, ...
[3] consider myriad point pairs, like: 1e6
[4] stay within unit square, cube, tesseract, etc: $ 0

So, moving up through dimensions, only that value [2nd parameter] 
needs to change ...


* Unit Square (average distance)
   (+/ % #) +/ &.: *: -/ ? 2 2 1e6 $ 0
0.521956
* Unit Cube
   (+/ % #) +/ &.: *: -/ ? 2 3 1e6 $ 0
0.661962
* Unit Tesseract
   (+/ % #) +/ &.: *: -/ ? 2 4 1e6 $ 0
0.777293
* Unit body (5th dimension) what's its name
   (+/ % #) +/ &.: *: -/ ? 2 5 1e6 $ 0
0.878806

I'm definitely not an expert in probability, so I'm not sure whether 
this makes any sense:

* Unit Line
   (+/ % #) +/ &.: *: -/ ? 2 1 1e6 $ 0
0.333411

What I do know from experience is, that gut feeling and probability 
don't go together (most of the time).
That said, I did some "plausibility checks" comparing avarage 
distance with the unit "body" diagonal:


*Unit Line
   0.33 % %: 1
0.33
* Unit Square
   0.52 % %: 2
0.367696
* Unit Cube
   0.66 % %: 3
0.381051
* Unit Tesseract
   0.78 % %: 4
0.39

That looks somehow reasonable to me, means the equation probably 
degrades gracefully in the case Dimension 1 (Line).


Furthermore, when going from Unit Square to Unit Cube, then from Unit 
Cube to Unit Tesseract, I'd expect the average to increase according 
to the increase of proportion of diagonals, i.e.


* Square -> Cube
   0.52 * %: 3r2
0.636867
* Cube -> Tesseract
   0.66 * %: 4r3
0.762102

which seems to approximately check with the distance average for 
three, resp four dimensions.


Just a thought ...
-M

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

Re: [Jprogramming] An easy one

2016-07-05 Thread Martin Kreuzer
Bill - Thanks; that's quite a shortcut -- my 
negligence: wasn't aware (q:) had also a dyadic use ...


The closest I could get toward that verb would now be

   red=. [: ^/ __ & q:
   red 4200
8 3 25 7

(didn't manage to keep (q:) "outside" ...)

-M

At 2016-07-05 11:10, you wrote:


q: in ^/__ q:4200  is dyad
executed  as
  ^/ ( __ q: 4200 )


Вт, 05 июл 2016, Martin Kreuzer написал(а):
> Please be patient while I elaborate;
>
> Ric -
> -
> Looking at your solution, I first read up on "Key" (x u /.. y) and came up
> with this example:
>
>2 3 2 3 3 (2&|)/. 9 5 7 6 4
> 1 1 0
> 1 0 0
>
> which I interpreted as
> * group the list on the left (2 2) (3 3 3), then
> * partition the list on the right accordingly (9 7) (5 6 4), then
> * apply decision between odd (1) and even (0) to the two partitions;
> (the zero in the first row is patched).
>
> I then did 'group' and 'tally' on a vector (along an example borrowed from
> NuVoc page)
>
>]a=. 7 9 8 7 8 7
> 7 9 8 7 8 7
>(a # /. a)
> 3 1 2
>(~. a) ,:(a # /. a)
> 7 9 8
> 3 1 2
>
> to show the frequency of each item.
>
> Replacing 'tally' by 'multiply' and extracting (a)
>
>(a */ /. a)
> 343 9 64
>(*/ /.~) a
> 343 9 64
>
> I arrived the sought verb
>
>red=. */ /.~
>red q: 4200
> 8 3 25 7
>] v=. q: 4200
> 2 2 2 3 5 5 7
>red v
> 8 3 25 7
>
> Don -
> -
> Looking at your solution, I first tried to put it ( in my naive way) into a
> verb like
>
>red=. ^/__
>red q: 4200
> 2 3 5 7
> 3 1 2 1
>red v
> |syntax error
> |   red v
>
> The first result looked similar to the above 
frequency table, which inspired

> me to follow this path:
>
>reduc=. 13 : '^/ (~.y) ,:(y#/.y)'
>reduc v
> 8 3 25 7
>reduc q:4200
> 8 3 25 7
>reduc=. [: ^/ ~. ,: # /.~
>reduc q: 4200
> 8 3 25 7
>reduc v
> 8 3 25 7
>
> This gives the correct answer but is way from  what you suggested ...
> Would you kindly explain how you arrived at your code..?
>
> Thanks
> -M
>
> At 2016-07-04 21:50, you wrote:
>
> >^/__ q:4200
> >
> > 8 3 25 7
> >
> > On Mon, Jul 4, 2016 at 3:48 PM, Ric Sherlock <tikk...@gmail.com> wrote:
> >
> > > How's this?
> > >*//.~ q: 4200
> > > 8 3 25 7
> >
> > > On Tue, Jul 5, 2016 at 9:46 AM, Kip 
Murray <thekipmur...@gmail.com> wrote:

> >
> > > > Consider
> > > >
> > > > q: 4200
> > > >  2 2 2 3 5 5 7
> > > >
> > > > How would you "reduce" this to  8 3 25 7  ?
> > > > Write the verb red:
> > > >
> > > > red q: 4200
> > > >  8 3 25 7
> > > >
> > > > --Kip Murray
> > > >
> > > >
> > > >
> > > > --
> > > > Sent from Gmail Mobile
> > > > 
--
> > > > 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

--
regards,

GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

  1   2   >