Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Roger Hui
You can always use ~. =/ ] a=: 'wontipanicinapitnow' '-0' {~ = a 0-0 -0---0- --00---00-- ---0---0--- 0---0-0---0 -0---0- --0-0-- -0- '-0' {~ (~. =/ ]) a 0-0 -0---0- --

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Michal Wallace
D'oh. I realized what it was for a few minutes later, and came back hoping everyone was asleep and I could answer myself. Ah well. :) On Thu, Feb 27, 2014 at 12:42 AM, Raul Miller wrote: > > Mind you, it might have made more sense for = to always construct > identity matrices. > But then how wo

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Roger Hui
BTW, the use of rank can obviate the need for creating a diagonal matrix: Post-multiplying by a diagonal matrix is the same as *"1, and pre-multiplying by a diagonal matrix is the same as just * . For example: diag=: * =@/: diag 1 10 100 1 0 0 0 10 0 0 0 100 ] M=: i.3 4 0 1 2 3

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Roger Hui
= 3 1 4 1 5 9 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 = \: 3 1 4 1 5 9 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 /: would also have worked. On Wed, Feb 26, 2014 at 10:36 PM, Michal Wallace wrote: > What purpose does the \: serve there? >

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Raul Miller
Same as i.@# in =@i.@# It's generating a list of distinct values which = will use to construct an identity matrix. Mind you, it might have made more sense for = to always construct identity matrices. But in terms of time, constructing an identity matrix is O(n^2) and \: is O(n log n) or better (

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Michal Wallace
What purpose does the \: serve there? (*=) 9 7 5 3 9 0 0 0 0 7 0 0 0 0 5 0 0 0 0 3 On Wed, Feb 26, 2014 at 11:48 PM, J. Patrick Harrington wrote: > even shorter: > > diag4=: *=@\: > > diag4 9 7 5 3 > 9 0 0 0 > 0 7 0 0 > 0 0 5 0 > 0 0 0 3 > Patrick > > > On Wed, 26 Feb

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Roger Hui
Bravo. On Wed, Feb 26, 2014 at 9:48 PM, J. Patrick Harrington wrote: > even shorter: > > diag4=: *=@\: > > diag4 9 7 5 3 > 9 0 0 0 > 0 7 0 0 > 0 0 5 0 > 0 0 0 3 > Patrick > > > On Wed, 26 Feb 2014, km wrote: > >>(*"0 1 =@i.@#) 1 2 3 >> 1 0 0 >> 0 2 0 >> 0 0 3 >> >> --Kip M

Re: [Jprogramming] using dll's in wine (linux/mac) (also a windows implementation of hash functions)

2014-02-26 Thread bill lam
> sslsha256 =: ' SHA256 i *c l *c' ssl you may want to check signature of cd call, in particular are they correct for both 32 and 64 bits. Ср, 26 фев 2014, Pascal Jasmin писал(а): > Thanks very much Joe.  With your code, I was able to link to libeay32.dll > (precompiled with opensll).  SHA256 i

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread J. Patrick Harrington
even shorter: diag4=: *=@\: diag4 9 7 5 3 9 0 0 0 0 7 0 0 0 0 5 0 0 0 0 3 Patrick On Wed, 26 Feb 2014, km wrote: (*"0 1 =@i.@#) 1 2 3 1 0 0 0 2 0 0 0 3 --Kip Murray Sent from my iPad On Feb 26, 2014, at 9:35 PM, Roger Hui wrote: diag=: 3 : 'y (,&.>~i.#y)} 0 $~ ,~#y

Re: [Jprogramming] apl character support

2014-02-26 Thread bill lam
IFAIK APL does not allow names with non-ascii character. That will be an interesting extension but it also depends on locales which include Indic and Arabic language that I have no knowledge at all. It is easier if we restrict it to European international characters, but then I consider it not too

Re: [Jprogramming] apl character support

2014-02-26 Thread Don Guinn
​​ But it is a start to playing with APL characters as names. Some unicode characters need to be treated like letters and others as words in themselves for ;: . International characters should be like A-Z,a-z and can be included in words. Other characters like Greek characters could be treated as w

Re: [Jprogramming] apl character support

2014-02-26 Thread Raul Miller
There are a variety of different kinds of unicode "characters". http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters Looking at the ;: monad, the general classes of characters which one would expect ;: to recognize are: Numbers Letters Spaces Other (and "spelling error"). So the first ste

Re: [Jprogramming] apl character support

2014-02-26 Thread bill lam
If we simply allow unicode characters in names, although we can assign ascii primitives to APL-like names, but that will require space around each of those names, so that insead of writing life←{↑1 ⍵∨.∧3 4=+/,_1 0 1∘.⊖_1 0 1∘.⌽⊂⍵} we need to write life ← {↑ 1 ⍵ ∨ . ∧ 3 4=+/,¯1 0 1 ∘ .⊖ ¯1 0 1 ∘

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Roger Hui
Yup. Amalgating the ideas in diag1 and expressions by Don Guinn and Kip Murray: diag1a=: * =@i.@# diag1a 10 20 30 40 10 0 0 0 0 20 0 0 0 0 30 0 0 0 0 40 See also http://www.jsoftware.com/jwiki/Essays/Identity_Matrix On Wed, Feb 26, 2014 at 7:40 PM, km wrote: > (*"0 1

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread km
(*"0 1 =@i.@#) 1 2 3 1 0 0 0 2 0 0 0 3 --Kip Murray Sent from my iPad > On Feb 26, 2014, at 9:35 PM, Roger Hui wrote: > > diag=: 3 : 'y (,&.>~i.#y)} 0 $~ ,~#y' > diag 10 20 30 40 > 10 0 0 0 > 0 20 0 0 > 0 0 30 0 > 0 0 0 40 > > diag1=: ]\ * =/~@i.@# > diag1 10 20 30 40

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Roger Hui
diag=: 3 : 'y (,&.>~i.#y)} 0 $~ ,~#y' diag 10 20 30 40 10 0 0 0 0 20 0 0 0 0 30 0 0 0 0 40 diag1=: ]\ * =/~@i.@# diag1 10 20 30 40 10 0 0 0 0 20 0 0 0 0 30 0 0 0 0 40 diag2=: -@>:@i.@# {."0 ] diag2 10 20 30 40 10 0 0 0 0 20 0 0 0 0 30 0 0 0 0

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Don Guinn
(*=/~@i.@#)4 3 2.23607 0 4 0 0 0 0 3 0 0 0 0 2.23607 0 0 0 0 0 On Wed, Feb 26, 2014 at 8:12 PM, Joe Bogner wrote: > Sorry, I figured it out: > > I just needed one more 0... > >] S * (4 4 $ 1 0 0 0 0) > 4 0 0 0 > 0 3 0 0 > 0 0 2.23607 0 > 0 0 0 0

Re: [Jprogramming] create matrix from diagonal

2014-02-26 Thread Joe Bogner
Sorry, I figured it out: I just needed one more 0... ] S * (4 4 $ 1 0 0 0 0) 4 0 0 0 0 3 0 0 0 0 2.23607 0 0 0 0 0 On Wed, Feb 26, 2014 at 10:02 PM, Joe Bogner wrote: > I'm experimenting with svd and am looking for a nicer way of creating > a matrix from the S diagonal >

[Jprogramming] create matrix from diagonal

2014-02-26 Thread Joe Bogner
I'm experimenting with svd and am looking for a nicer way of creating a matrix from the S diagonal 4 3 2.23607 0 needs to be ] (4 4 $ 4 0 0 0 0 3 0 0 0 0 2.23607 0 0 0 0 0 ) 4 0 0 0 0 3 0 0 0 0 2.23607 0 0 0 0 0 What would be the idiomatic way to make that conversion? I tri

Re: [Jprogramming] using dll's in wine (linux/mac) (also a windows implementation of hash functions)

2014-02-26 Thread Pascal Jasmin
I was going off https://en.wikipedia.org/wiki/SHA-256 (pseudocode section) - Original Message - From: Raul Miller To: Programming forum Cc: Sent: Wednesday, February 26, 2014 3:37:08 PM Subject: Re: [Jprogramming] using dll's in wine (linux/mac) (also a windows implementation of hash

Re: [Jprogramming] introducing JON alternative to JSON

2014-02-26 Thread Pascal Jasmin
Thank you Raul, I've updated safe1 and safe2 to prevent arbitrary names that start with aLj... apply was the problem rather than u: I hope. safe1 =: '''_0123456789+*-<>|;,#{}()[]' safe2 =: 'u:';'x:';'}.';'}:';'" ';'":';'! ';'$ ';'= ';'^ ';'^.';'a.';'a:';'L.';'L:';'j.';'i.';'i:' - Origina

Re: [Jprogramming] introducing JON alternative to JSON

2014-02-26 Thread Raul Miller
On Wed, Feb 26, 2014 at 1:45 PM, Pascal Jasmin wrote: > My big question though is have I overlooked any potential unsafe code that > could be run with doSafe? Yes. Here's an example: exploit=: smoutput@3: doSafe '(u: ',(":u:inv 5!:5 <'exploit'),') apply 0' 3 Of course, there's not too m

Re: [Jprogramming] using dll's in wine (linux/mac) (also a windows implementation of hash functions)

2014-02-26 Thread Raul Miller
I might try to get sha256 working (not today - I have other things I need to get done today). But before I could do that, I'd need to find a copy of the relevant standard (otherwise I will not have a clue how to debug it). It's honestly not all that hard to do, you just need to read the standard a

Re: [Jprogramming] apl character support

2014-02-26 Thread Don Kelly
Not that I know of - but if it takes 2 keys to produce the mathematical divide and 2 to produce the box and one to overstrike what is the gain? Don. On 26/02/2014 12:09 PM, Jim Russell wrote: Has modern technology eliminated over strikes? On Feb 26, 2014, at 2:52 PM, Don Kelly wrote: 'box d

Re: [Jprogramming] apl character support

2014-02-26 Thread Jim Russell
Has modern technology eliminated over strikes? > On Feb 26, 2014, at 2:52 PM, Don Kelly wrote: > > 'box divide' requires pressing 3 keys at once -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] apl character support

2014-02-26 Thread Don Kelly
I have used APL for many years and while I like the glyphs (eg 'iota' vs i. ) , having the upper and lower case alphabet] along with the APL glyphs requires each key having up to 4 characters resulting in much more use of shift , alt or alt-shift. 'box divide' requires pressing 3 keys at once -

Re: [Jprogramming] introducing JON alternative to JSON

2014-02-26 Thread Joe Bogner
Pascal, this looks really interesting. I also needed a safe do / eval for my JHS spreadsheet formulas. Your implementation looks similar to what I had in mind. I'm also interested if there's any security gaps in it. On Wed, Feb 26, 2014 at 1:45 PM, Pascal Jasmin wrote: > Jon is a text data tran

Re: [Jprogramming] using dll's in wine (linux/mac) (also a windows implementation of hash functions)

2014-02-26 Thread Pascal Jasmin
That is cool Raul, since you are interested in this, allow me to show you some native code for sha256 that does not produce correct results.  I originally took code from (I think Michael's github page) that did not work.  I am probably not doing the rotate/shift correctly. Earlier this morning,

Re: [Jprogramming] jqt and qt addon updated

2014-02-26 Thread Don Kelly
On J801 -64 under windows 7, there was no problem with install 'jqt' in the J console - but then after updating according to the notice given by this referring to the base library etc. Jqt didn't work. I ended up uninstalling and reinstalling J801 and all is bliss. I was using 602 and find the j

[Jprogramming] introducing JON alternative to JSON

2014-02-26 Thread Pascal Jasmin
Jon is a text data transfer format similar to JSON  encoding is simply: JON =: lr_z_ =: 3 : '5!:5 <''y''' rest of code: cocurrent 'jon' safe1 =: '''_0123456789+*-<>|;,#ijL{()a[]' safe2 =: 'u:';'x:';'}.';'}:';'" ';'":';'! ';'$ ';'= ';'^ ';'^.' issafe1d =: safe1 e.~ {. &> issafe2d =: safe2 e.~ 2&{

Re: [Jprogramming] using dll's in wine (linux/mac) (also a windows implementation of hash functions)

2014-02-26 Thread Raul Miller
I threw together a slightly faster version of that J implementation of SHA-1 (because it's looking like I'm going to need a hashing capability). Unfortunately, I only got a factor of 2 speed improvement. It's up on rosettacode. Thanks, -- Raul On Tue, Feb 25, 2014 at 8:46 PM, Raul Miller wrote

Re: [Jprogramming] Finding Largest Prime of Numbers (Tacit)

2014-02-26 Thread Roger Hui
> I'm still struggling with the @ and & purposes, but I think only > reading the explanations more carefully can fix that. If there are only monadic functions, you can use juxtaposition to denote function composition: f=: f0 f1 f2 ... or, as in conventional mathematical notation, use the simpl

Re: [Jprogramming] Combinatorial Maths with J

2014-02-26 Thread robert therriault
Welcome to the 'well that's embarrassing' club. We have all been there. For the 3 arguments you would like to use, I generally use one of two techniques. For explicit area=: 3 : 0NB. Area of rectangle - y is width and height 'w h'=. y NB. multiple assignment to w and h w*h ) or ta

Re: [Jprogramming] Combinatorial Maths with J

2014-02-26 Thread Mike Day
Jon, You need the dyadic version of !, though it does yCx rather than xCy: 3!7 35 The following idiom delivers your required number of Steiner subsets: ({.%~/@:!}. ) 2 3 7 7 ... if you're happy to treat the triples in this way. It's derived from this verb which delivers 2!3 and 2!7:

Re: [Jprogramming] Combinatorial Maths with J

2014-02-26 Thread Don Guinn
((!3)*!(7-3))%~!7 35 3!7 35 On Wed, Feb 26, 2014 at 8:25 AM, Jon Hough wrote: > I have a question about doing combinations and permutations with J. > There is an easy to use factorial function (or is that verb) : ! > !5120 > Is there a combination verb? Or do I make my own? > ((!3)*!(7

Re: [Jprogramming] Combinatorial Maths with J

2014-02-26 Thread Jon Hough
Well that's embarrassing. I should have read the definition more carefully. > Date: Wed, 26 Feb 2014 08:31:45 -0700 > From: dongu...@gmail.com > To: programm...@jsoftware.com > Subject: Re: [Jprogramming] Combinatorial Maths with J > >((!3)*!(7-3))%~!7 > > 35 > >3!7 > > 35 > > > On W

Re: [Jprogramming] Combinatorial Maths with J

2014-02-26 Thread Dan Bron
Yes, you want 3!7 (the dyadic form of !). You'll find that a lot of J primitives are designed so that their monadic and dyadic valences are thematically related, and frequently their spelling is mnemonic (or at least suggestive) as well. -Dan - Original Message --- Subject: [Jp

[Jprogramming] Combinatorial Maths with J

2014-02-26 Thread Jon Hough
I have a question about doing combinations and permutations with J. There is an easy to use factorial function (or is that verb) : ! !5120 Is there a combination verb? Or do I make my own? ((!3)*!(7-3))%~!7 Gives 7 choose 3. I think I butchered that. Is there a better way to do this, without all t

Re: [Jprogramming] apl character support

2014-02-26 Thread Don Guinn
The discussion keeps coming back to APL characters. For now not why not just look at using international characters (Unicode/UTF-8) as letters in names? One can assign some of those as letters for primitives if he wants. Then see where things go. A problem with accepting unicode/UTF-8 characters i

Re: [Jprogramming] Finding Largest Prime of Numbers (Tacit)

2014-02-26 Thread Jon Hough
Thanks for replying, everyone.Sorry the formatting was all garbled. It was copy and pasted. It seems, for me at least, that >./ @ q: is the simplest and most elegant way to do it. I'm still struggling with the @ and & purposes, but I think only reading the explanations more carefully can fix th

Re: [Jprogramming] Finding Largest Prime of Numbers (Tacit)

2014-02-26 Thread Raul Miller
When I want to see inside the execution of a tacit verb, I usually introduce verbs that let me see or grab values. For example: (#~ [:(e. p:)+/\@:=&' ')'this is an example of something' an example something So here's a couple verbs, to see values and to grab them: see=: 1!:2&2 grab=:

Re: [Jprogramming] apl character support

2014-02-26 Thread Raul Miller
a. is just 256 literal characters, it is a noun. I expect u: might have been what you were thinking about? It's a verb. Thanks, -- Raul On Wed, Feb 26, 2014 at 2:19 AM, Björn Helgason wrote: > Actually I want a. back as it was. > > Giving me two or three number is wrong and is confusing at be

Re: [Jprogramming] using dll's in wine (linux/mac) (also a windows implementation of hash functions)

2014-02-26 Thread Pascal Jasmin
Thanks very much Joe.  With your code, I was able to link to libeay32.dll (precompiled with opensll).  SHA256 is not one of the official interfaces.  To boot, this is twice as fast as the MSFT interface. sslp =: 'D:\OpenSSL-Win64\bin'  NB.set path to your system OPENSSL =: sslp , '\libeay32.dll

Re: [Jprogramming] using dll's in wine (linux/mac) (also a windows implementation of hash functions)

2014-02-26 Thread Joe Bogner
Hi Pascal, I updated my wiki page on Calling DLLs to include a linux example that uses SHA256 from openssl (with a shim) http://www.jsoftware.com/jwiki/JoeBogner/CallingDLL Hopefully it helps in case you want to go down that path On Tue, Feb 25, 2014 at 8:40 PM, Pascal Jasmin wrote: > I don't

Re: [Jprogramming] algotrade and backtest platform

2014-02-26 Thread Scott Locklin
>>"Y-01"> > 1. J practise; > 2. interesting task; > 3. the effect of social reinforcement (international team); > 4. experiments with strategies; > 5. possibility to earn some candy wrappers (like btc or usd) > 6. pride oneself and pride for the lost time. >Also I propose to start with Mtgox.com

Re: [Jprogramming] Finding Largest Prime of Numbers (Tacit)

2014-02-26 Thread bill lam
You can write trace 'g=.([:{:3 p:])23434' but that will trace composition of the tacit verb. On 26.02.2014, at 16:03, "Linda Alvord" wrote: > Trace has a problem. It works fine with an explicit statement. > > require'trace' > trace 'f=:{: 3 p: 23434' > --- 2 Dyad --- > 3

Re: [Jprogramming] Finding Largest Prime of Numbers (Tacit)

2014-02-26 Thread Linda Alvord
Trace has a problem. It works fine with an explicit statement. require'trace' trace 'f=:{: 3 p: 23434' --- 2 Dyad --- 3 p: 23434 2 11717 --- 0 Monad -- {: 2 11717 11717 --- 7 Is - f =: 11717 11717 =