NYCJUG/2010-05-11

From J Wiki
Jump to navigation Jump to search

plot polygon, J 7.01, XML, video for teaching

Location::BEST, Hoboken, NJ


Meeting Agenda for NYCJUG 20100511

1. Beginner's regatta: some recent questions from beginners and their answers:
see "Introductory Emphasis.doc" and "Explaining Rank.doc".


2. Show-and-tell: see "Sample of J Publish Addon.doc" and "sampPublish.pdf".

   See "Plotting non-simple polygons.odt".


3. Advanced topics: J 7.01 - see "XMLHttpRequest-ing xml files and nouns.doc" -
has anyone tried this?

   Some impressive problem solutions?  See "Compressed Sensing meets Machine
   Learning.doc", "How to wow your friends.odt", and "Deconvolution.doc".


4. Learning, teaching and promoting J: See
"http://www.youtube.com/watch?v=vIFCV2spKtg" for an introduction to re-sizing
images by "targeting".

   General question: see "Chasing Tail.doc".

   General discussion: is more data not just more but different?  See "All we
   want are the facts.doc".

Beginner's Regatta: Recent Questions from Beginners

We discussed some recent questions from beginners to get an idea of basic information about J and its environment that may not be obvious or easy to find.

[Jprogramming] J article in Vector about Cauchy Curves

This first one is a question of understanding environmental issues peripheral to the language, specifically the existence and use of the add-ons (which might be more usually thought of as "libraries").

from    Wim de Lange <wimdelange@gmail.com>
to      Programming forum <programming@jsoftware.com>
date    Sun, Mar 21, 2010 at 2:40 PM
subject [Jprogramming] J article in Vector about Cauchy Curves

Currently I'm going trough the article in Vector Volume 24, No 1 about Cauchy curves. Looks good, but there is this line:

 require '~addons/media/image3/prevare.ijs'

Now I have found the code for this, but I'm not able to run this required code. Where must I place the contents of the zip file that contains the media/image3/1.0./ directory that contains this preveare.ijs file?

I'm rather new to J (although I can handle APL) and not accustomed to the library structure.

from
Wim de Lange <wimdelange@gmail.com>
- - - - - - - - - - - - - - -
from Sherlock, Ric R.G.Sherlock at massey.ac.nz
date  Mon Mar 22 04:19:44 HKT 2010

Hi Wim,
If you use the GUI or command line interface for the package manager:
http://www.jsoftware.com/jwiki/JAL/Package%20Manager

... then addons will be correctly installed in the appropriate folder for you.
- - - - - - - - - - - - - - -
from Devon McCormick devonmcc at gmail.com
date  Mon Mar 22 04:20:13 HKT 2010

Hi -

The package manager (from an ijx session window: Run/Package Manager) should put this in "C:\Program Files\J602\addons\media\image3\" assuming you have J installed under "Program Files".
- - - - - - - - - - - - - - -
date    Mon, Mar 22, 2010 at 3:01 AM
subject Re: [Jprogramming] J article in Vector about Cauchy Curves

Thanks guys! I'm playing already some time with J, but missed the package manager totally. Many interesting packages there....

Groetjes,
 Wim

[Jprogramming] Plot into Form Example

These questions about the grid add-on are well-answered with some relevant examples.

from    David Vincent-Jones <davidvj@verizon.net>
to      JSoftware <programming@jsoftware.com>
date    Sun, Mar 21, 2010 at 5:40 PM
subject [Jprogramming] Plot into Form Example

Could somebody kindly point me to an example of inserting a plot into a form.
Thank you;
David
- - - - - - - - - - - - - - -
from    Björn Helgason <gosinn@gmail.com>
date    Sun, Mar 21, 2010 at 5:51 PM
subject Re: [Jprogramming] Plot into Form Example

In message Grid and Plot

http://groups.google.com/group/j-programming/browse_thread/thread/afad94e61d1a1654/aa0b4c3d8497d1d1?lnk=gst&q=gridandplot#aa0b4c3d8497d1d1

and script gridandplot.ijs under files
--
Björn Helgason, Verkfræðingur
- - - - - - - - - - - - - - -
from    Sherlock, Ric <R.G.Sherlock@massey.ac.nz>
date    Sun, Mar 21, 2010 at 7:09 PM
subject Re: [Jprogramming] Plot into Form Example

See also:
 * http://www.jsoftware.com/jwiki/Grid/Examples#Linkedgridandplot
 * The Studio|Labs|Building Applications Lab
 * http://www.jsoftware.com/jwiki/Addons/media/wav
 * http://www.jsoftware.com/jwiki/ChrisBatho/Lorenz%20Plot
 * http://www.jsoftware.com/jwiki/Scripts/Real-time%20Plot

[Jprogramming] Rank amateur question

This and the following question require a better understanding of "rank". We've noticed a recurring difficulty that beginners have grasping this concept. This is important in J but is perhaps unique to the language, so most people have not encountered anything like it before. "Rank" is an example of a more general set of concepts requiring "array thinking" that is also unfamiliar to anyone only used to traditional, scalar languages.

from Frederick W Mellem mellemf at frontiernet.net
date Fri Mar 19 05:48:33 HKT 2010
   i.&.> 4 2 3
+-------+---+-----+
|0 1 2 3|0 1|0 1 2|
+-------+---+-----+
   i.&.>("0) 4 2 3
+-------+---+-----+
|0 1 2 3|0 1|0 1 2|
+-------+---+-----+
   i.&.(>"0) 4 2 3
+-+-+-+-+
|0|1|2|3|
+-+-+-+-+
|0|1| | |
+-+-+-+-+
|0|1|2| |
+-+-+-+-+

Please explain the scalar boxing.  I assume it is correct,  but I don't see
why >("0) is different from  (>"0)
- - - - - - - - - - - - - - -
from Zsbán Ambrus ambrus at math.bme.hu
date Fri Mar 19 06:00:10 HKT 2010

Those two would be exactly the same, but the difference is because
(i.&.>("0)) is the same as ((i.&.>)"0).

The scalar boxing is because the inverse of (>"0) in J is (<"0) so
(i.&.(>"0) 4 2 3) is the same as (((<"0)@:i.@:(>"0)"0) 4 2 3) in which
(<"0) boxes each atom in the output individually.

Ambrus

The File:IntroductoryEmphasisWithExtensiveGridExamples.pdf also continues with extensive examples of using the "grid" add-on for displaying items in a grid, referencing these examples.

Explaining Rank

Here's another puzzle solved by a better understanding of "rank".

from Robert O'Boyle <bcubed@accesswave.ca>
to   programming@jsoftware.com
date Mon, Apr 26, 2010 at 6:15 AM
subject [Jprogramming] Each and #

Hi

I have a matrix, x, which is boxed

  x=. i. 4 6
   <x
------------------┐
│ 0  1  2  3  4  5│
│ 6  7  8  9 10 11│
│12 13 14 15 16 17│
│18 19 20 21 22 23│
L------------------

I want to copy each row of x. Using #, I can do this on the unboxed x matrix

  1 2 3 4 #"2 x
 0  1  2  3  4  5
 6  7  8  9 10 11
 6  7  8  9 10 11
12 13 14 15 16 17
12 13 14 15 16 17
12 13 14 15 16 17
18 19 20 21 22 23
18 19 20 21 22 23
18 19 20 21 22 23
18 19 20 21 22 23

But I get an unexpected result when I use the verb 'each'.

   1 2 3 4 #"2 each <x
------------------T-----------------T-----------------T-----------------┐
│ 0  1  2  3  4  5│ 0  1  2  3  4  5│ 0  1  2  3  4  5│ 0  1  2  3  4  5│
│ 6  7  8  9 10 11│ 0  1  2  3  4  5│ 0  1  2  3  4  5│ 0  1  2  3  4  5│
│12 13 14 15 16 17│ 6  7  8  9 10 11│ 0  1  2  3  4  5│ 0  1  2  3  4  5│
│18 19 20 21 22 23│ 6  7  8  9 10 11│ 6  7  8  9 10 11│ 0  1  2  3  4  5│
│                 │12 13 14 15 16 17│ 6  7  8  9 10 11│ 6  7  8  9 10 11│
│                 │12 13 14 15 16 17│ 6  7  8  9 10 11│ 6  7  8  9 10 11│
│                 │18 19 20 21 22 23│12 13 14 15 16 17│ 6  7  8  9 10 11│
│                 │18 19 20 21 22 23│12 13 14 15 16 17│ 6  7  8  9 10 11│
│                 │                 │12 13 14 15 16 17│12 13 14 15 16 17│
│                 │                 │18 19 20 21 22 23│12 13 14 15 16 17│
│                 │                 │18 19 20 21 22 23│12 13 14 15 16 17│
│                 │                 │18 19 20 21 22 23│12 13 14 15 16 17│
│                 │                 │                 │18 19 20 21 22 23│
│                 │                 │                 │18 19 20 21 22 23│
│                 │                 │                 │18 19 20 21 22 23│
│                 │                 │                 │18 19 20 21 22 23│
L-----------------+-----------------+-----------------+------------------

Any assistance on this would be appreciated.

Bob
- - - - - - - - - - - - -
from    Björn Helgason <gosinn@gmail.com>
date    Mon, Apr 26, 2010 at 10:15 AM
subject Re: [Jprogramming] Each and #

When you are working with rank you can investigate it by using b.

  # b. 0
_ 1 _

You can change the rank as you do
  #"2 b. 0
2 2 2

As you see you then get three numbers and the first is for the monadic
case and then for left and right argument so the first number means
nothing when you apply it dyadically.

I am not sure why you want to use each when it is enough to use >

  1 2 3 4 #"0 1 2 > <x
 0  1  2  3  4  5
 6  7  8  9 10 11
 6  7  8  9 10 11
12 13 14 15 16 17
12 13 14 15 16 17
12 13 14 15 16 17
18 19 20 21 22 23
18 19 20 21 22 23
18 19 20 21 22 23
18 19 20 21 22 23

Show-and-tell: "Publish" Add-on and Plotting Non-Simple Polygons

Some of us had not heard about J's "Publish" add-on. This is a simple text-based way to produce good-looking documents in PDF format with minimal overhead. We looked at an example of a few simple items such as embedded images and tables entered in a simple text-based format that is amenable to programmatic generation and the resulting PDF file.

So, creating a title page is as simple as this:

<title>Samples of "Publish"</title>
<author>Me</author>

Top-level headers and basic text formatting are specified as shown in these self-referential examples:

<h0>Samples from J "Publish" Addon</h0>

<para align=left>
<b>Here is an example of some bold text.</b><br/><br/>
<i>Here is an example of some italic text.</i><br/><br/>
</para>

Embedding an external image is as simple as this:

<h2>Example Image</h2>
<pre>
   <image align=center,scale=0.3>afbeelding-6.jpg</image>

<image align=center,scale=0.3>afbeelding-6.jpg</image>

and so on - see the wiki for more information about "publish" add-on. There's a GUI front-end and a set of examples.

We also looked at a simple way to plot simple and complex polygons using the venerable "roots of unity" program that has the distinction of being the first code written in APL. The following two J phrases are used to specify these roots - which are also the vertexes of a regular polygon embedded in the unit circle - then plot them not in their simple but alternating order to get non-simple polygons - polygons with intersecting sides - i.e. "stars".

rou=: [:^ 0j2p1&% * i.   NB.* rou: roots of unity from JPhrases/ComplexNumbers.
binAlt=: ]</.~ 2|[:i.#

   binAlt&.>i.&.>5 6 7
+-----------+-------------+---------------+
|+-----+---+|+-----+-----+|+-------+-----+|
||0 2 4|1 3|||0 2 4|1 3 5|||0 2 4 6|1 3 5||
|+-----+---+|+-----+-----+|+-------+-----+|
+-----------+-------------+---------------+

NB. Now use this to plot "stars"
   pd 'reset'
   pd 'type line'
   pd 'color blue'
   pd (],{.);binAlt rou 5
   pd 'color red;pensize 2'
   pd &.>1j1+&.>(],{.)&.>binAlt rou 6
   pd 'color green;pensize 3'
   pd 1j_1+(],{.);binAlt rou 7
   pd 'show'

NonSimplePoly3.png