Numerical Computation with Shang

As a general purpose programming language, Shang might be used for a variety of computing tasks. It is particular suitable for numerical computation due to its extensive built-in support for matrix and functions, and many new features designed to express mathematical concepts more effectively.
Numerical Matrix
Numerical Matrix of various storage format (real and complex, double precision, integer, byte, binary), 2-dimensional as well as multi-dimensional

Seamless support for special matrices (diagonal, tridiagonal, and sparse; more will be done in the future).

Matrix and vector opperations are supported in a similar fashon as Matlab, while matrix indexing is more powerful so that not only square sub blocks but also arbitrary submatrix including diagonals and triangular blocks can be directly accessed and updated.

Arbitrary Precision Computing
Shang supports matrices of integers of unlimitted sizes and floating point numbers of arbitrary precisions. While this is usually less efficient than using hardware double precision numbers for large problems it can be useful when very accurate answers are required.

You can probably do a lot more to and with functions in Shang than in other languages. In most programming langues, you can do only two things with functions --- write them and call them. In Shang, you can
  • customize functions after they are created and make new functions out of them,
  • spawn new functions giving new parameter values
  • call a function with only part of the argument list specified to make new functions,
  • add, multiply, subtract, divide and chain functions to make new ones (just like doing Math),
  • specify domains for function arguments, and ranges for return values.
  • create functions inside other functions, pass functions to function calls as argument values, return functions as function call outcomes, and use functions as array entries, matrix elements, or attributes of structures.
And, function is a concept in Shang and not tied to a single data structure. Most data types can be used as functions in natural ways. For example, a matrix is naturally used as function (the linear operator), and a hash table is a more effective way to define a finite function, and finite sets are automatically functions (their characteristic functions).

The mathematical concept of set is implemented in a similar manner to functions. Finite sets and intervals can be easily created using built-in data structures, while any functions can used as sets (in the sense of characteristic functions; likewise, finites sets and intervals can be used as functions as well).

Argument passing is always done by value so calling a function won't alter the value of the argument. This minimizes implicit and hard to predict program behavior (a problem suffered by popular reference-based programming languages). However, if it is desired to have the function change the argument value, it is easily realized by passing pointers to local variables to functions. Shang pointers have intuitive syntax and are safe and easy to use.

More features
Besides numerical matrices, more features for building complicated data structures and programs. Shang supports standard OOP programming, and yet offers a bunch of enhancements to OOP such as class attribute domains, conditional classes, and automaton.

Shang Home