Yorick (programming language)

Last updated
Yorick
Designed by David H. Munro
First appeared1996;25 years ago (1996)
Stable release
2.2.04 / May 2015;6 years ago (2015-05)
OS Unix-like systems including macOS, Microsoft Windows
License BSD
Filename extensions .i
Website github.com/LLNL/yorick

Yorick is an interpreted programming language designed for numerics, graph plotting, and steering large scientific simulation codes. It is quite fast due to array syntax, and extensible via C or Fortran routines. It was created in 1996 by David H. Munro of Lawrence Livermore National Laboratory.

Contents

Features

Indexing

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

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<x)> list[2,3,4,5,6]> y=x(list)> y[2,3,4,5,6]
Pseudo-index

Like "theading" in PDL and "broadcasting" in Numpy, 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 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]]

Related Research Articles

ALGOL Family of programming languages

ALGOL is a family of imperative computer programming languages originally developed in 1958. ALGOL heavily influenced many other languages and was the standard method for algorithm description used by the Association for Computing Machinery (ACM) in textbooks and academic sources for more than thirty years.

Tensor Algebraic object with geometric applications

In mathematics, a tensor is an algebraic object that describes a multilinear relationship between sets of algebraic objects related to a vector space. Objects that tensors may map between include vectors and scalars, and even other tensors. There are many types of tensors, including scalars and vectors, dual vectors, multilinear maps between vector spaces, and even some operations such as the dot product. Tensors are defined independent of any basis, although they are often referred to by their components in a basis related to a particular coordinate system.

Vector space Basic algebraic structure of linear algebra

In mathematics, physics, and engineering, a vector space is a set of objects called vectors, which may be added together and multiplied ("scaled") by numbers called scalars. Scalars are often real numbers, but some vector spaces have scalar multiplication by complex numbers or, generally, by a scalar from any mathematic field. The operations of vector addition and scalar multiplication must satisfy certain requirements, called vector axioms. To specify whether the scalars in a particular vector space are real numbers or complex numbers, the terms real vector space and complex vector space are often used.

A mathematical symbol is a figure or a combination of figures that is used to represent a mathematical object, an action on mathematical objects, a relation between mathematical objects, or for structuring the other symbols that occur in a formula. As formulas are entirely constituted with symbols of various types, many symbols are needed for expressing all mathematics.

A list comprehension is a syntactic construct available in some programming languages for creating a list based on existing lists. It follows the form of the mathematical set-builder notation as distinct from the use of map and filter functions.

In mathematics and computer programming, index notation is used to specify the elements of an array of numbers. The formalism of how indices are used varies according to the subject. In particular, there are different methods for referring to the elements of a list, a vector, or a matrix, depending on whether one is writing a formal mathematical paper for publication, or when one is writing a computer program.

Sparse matrix

In numerical analysis and scientific computing, a sparse matrix or sparse array is a matrix in which most of the elements are zero. There is no strict definition regarding the proportion of zero-value elements for a matrix to qualify as sparse but a common criterion is that the number of non-zero elements is roughly equal to the number of rows or columns. By contrast, if most of the elements are non-zero, the matrix is considered dense. The number of zero-valued elements divided by the total number of elements is sometimes referred to as the sparsity of the matrix.

NumPy Numerical programming library for the Python programming language

NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. The ancestor of NumPy, Numeric, was originally created by Jim Hugunin with contributions from several other developers. In 2005, Travis Oliphant created NumPy by incorporating features of the competing Numarray into Numeric, with extensive modifications. NumPy is open-source software and has many contributors.

In mathematics and theoretical physics, a superalgebra is a Z2-graded algebra. That is, it is an algebra over a commutative ring or field with a decomposition into "even" and "odd" pieces and a multiplication operator that respects the grading.

Foreach loop Control flow statement

Foreach loop is a control flow statement for traversing items in a collection. Foreach is usually used in place of a standard for loop statement. Unlike other for loop constructs, however, foreach loops usually maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this x times". This avoids potential off-by-one errors and makes code simpler to read. In object-oriented languages an iterator, even if implicit, is often used as the means of traversal.

In computer programming, array slicing is an operation that extracts a subset of elements from an array and packages them as another array, possibly in a different dimension from the original.

In mathematics, the Kronecker product, sometimes denoted by ⊗, is an operation on two matrices of arbitrary size resulting in a block matrix. It is a generalization of the outer product from vectors to matrices, and gives the matrix of the tensor product linear map with respect to a standard choice of basis. The Kronecker product is to be distinguished from the usual matrix multiplication, which is an entirely different operation. The Kronecker product is also sometimes called matrix direct product.

In computer science, array programming refers to solutions which allow the application of operations to an entire set of values at once. Such solutions are commonly used in scientific and engineering settings.

Row- and column-major order

In computing, row-major order and column-major order are methods for storing multidimensional arrays in linear storage such as random access memory.

A logical matrix, binary matrix, relation matrix, Boolean matrix, or (0,1) matrix is a matrix with entries from the Boolean domain B = {0, 1}. Such a matrix can be used to represent a binary relation between a pair of finite sets.

Non-associative algebra Algebra over a field where binary multiplication is not necessarily associative

A non-associative algebra is an algebra over a field where the binary multiplication operation is not assumed to be associative. That is, an algebraic structure A is a non-associative algebra over a field K if it is a vector space over K and is equipped with a K-bilinear binary multiplication operation A × AA which may or may not be associative. Examples include Lie algebras, Jordan algebras, the octonions, and three-dimensional Euclidean space equipped with the cross product operation. Since it is not assumed that the multiplication is associative, using parentheses to indicate the order of multiplications is necessary. For example, the expressions (ab)(cd), d and a(b ) may all yield different answers.

This comparison of programming languages (array) compares the features of array data structures or matrix processing for over 48 various computer programming languages.

Matrix (mathematics) Two-dimensional array of numbers with specific operations

In mathematics, a matrix is a rectangular array or table of numbers, symbols, or expressions, arranged in rows and columns, which is used to represent a mathematical object or a property of such an object. For example,

In computer science, an array type is a data type that represents a collection of elements, each selected by one or more indices that can be computed at run time during program execution. Such a collection is usually called an array variable, array value, or simply array. By analogy with the mathematical concepts vector and matrix, array types with one and two indices are often called vector type and matrix type, respectively. More generally, a multidimensional array type can be called a tensor type.

Hadamard product (matrices) Matrix operation

In mathematics, the Hadamard product is a binary operation that takes two matrices of the same dimensions and produces another matrix of the same dimension as the operands, where each element i, j is the product of elements i, j of the original two matrices. It is to be distinguished from the more common matrix product. It is attributed to, and named after, either French mathematician Jacques Hadamard or German mathematician Issai Schur.