Yorick programming language
Encyclopedia
Yorick is an interpreted
Interpreted language
Interpreted language is a programming language in which programs are 'indirectly' executed by an interpreter program. This can be contrasted with a compiled language which is converted into machine code and then 'directly' executed by the host CPU...

 programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 designed for numerics
Numerics
Numerics is typically the term used to describe the numerical field of employment, or its instructional program at a college or university . Numerics occupations can include sub-divisions such as tooling specialist, materials specialist, and others.-Numerical programming:Also known as numerical...

, graph
Graph of a function
In mathematics, the graph of a function f is the collection of all ordered pairs . In particular, if x is a real number, graph means the graphical representation of this collection, in the form of a curve on a Cartesian plane, together with Cartesian axes, etc. Graphing on a Cartesian plane is...

 plotting and steering large scientific simulation codes. It is quite fast due to array syntax, and extensible via C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 or Fortran
Fortran
Fortran is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing...

 routines. It was created in 1996 by David H. Munro
David H. Munro
David Herbert Munro is a physicist at Lawrence Livermore National Laboratory who created the programming language Yorick as well as the scientific graphics library Gist. Munro earned his B.S. at Caltech and Ph.D. at the Massachusetts Institute of Technology...

 of Lawrence Livermore National Laboratory
Lawrence Livermore National Laboratory
The Lawrence Livermore National Laboratory , just outside Livermore, California, is a Federally Funded Research and Development Center founded by the University of California in 1952...

.

Features

  • Indexing

Yorick is good at manipulating elements in N-dimensional arrays conveniently with its powerful syntax.

Range of indices

Several elements can be accessed all at once:


> x=[1,2,3,4,5,6];
> x
[1,2,3,4,5,6]
> x(3:6)
[3,4,5,6]
> x(3:6:2)
[3,5]
> x(6:3:-2)
[6,4]


Arbitrary elements


> x=1,2,3],[4,5,6
> x
1,2,3],[4,5,6
> x([2,1],[1,2])
2,1],[5,4
> list=where(1 > list
[2,3,4,5,6]
> y=x(list)
> y
[2,3,4,5,6]


Pseudo-index

Like "theading" in PDL
Perl Data Language
PDL is a set of array programming extensions to the Perl programming language.PDL is an extension to Perl v5, intended for scientific and other data intensive programming tasks...

 (Perl Data Language) and "broadcasting" in Numpy (Numeric extension for Python), Yorick has a mechanism to do this:


> x=[1,2,3]
> x
[1,2,3]
> y=1,2,3],[4,5,6
> y
1,2,3],[4,5,6
> y(-,)
[1],[2],[3,4],[5],[6]
> x(-,)
1],[2],[3
> x
1,2,3
> x/y
1,1,1],[0,0,0
> y=1.,2,3],[4,5,6
> x/y
1,1,1],[0.25,0.4,0.5


Rubber index

".." is a rubber-index to represent zero or more dimensions of the array.


> x=1,2,3],[4,5,6
> x
1,2,3],[4,5,6
> x(..,1)
[1,2,3]
> x(1,..)
[1,4]
> x(2,..,2)
5


"*" is a kind of rubber-index to reshape a slice(sub-array) of array to a vector.


> x(*)
[1,2,3,4,5,6]


Tensor multiplication

Tensor
Tensor
Tensors are geometric objects that describe linear relations between vectors, scalars, and other tensors. Elementary examples include the dot product, the cross product, and linear maps. Vectors and scalars themselves are also tensors. A tensor can be represented as a multi-dimensional array of...

 multiplication is done as follows in Yorick:

P*Q

means


> x=1,2,3],[4,5,6
> x
1,2,3],[4,5,6
> y=7,8],[9,10],[11,12
> x*y(+,)
39,54,69],[49,68,87],[59,82,105
> x(+,)*y
58,139],[64,154

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK