Ural Project Home Page

Click here to go to the project summary and downloads.

Motivation:

As is well known, C++ does not have built-in support for linear algebra objects such as vectors, matrices or tensors. While STL does provide vector class template among its standard containers, arithmetic operations are not defined for vector, and its functionality is limited. Therefore, for linear algebra, C++ programmer must use libraries that are not part of the language itself.

Description:

Ural is a linear algebra C++ library built upon a tensor class template that can be used to represent tensors of ranks
0 - scalaras,
1 - vectors,
2 - matrices,
3 - tensors of rank 3,
...
This part of the library is located in tensor.h and is written in ANSI/ISO C++ and, therefore, should work with any standards-compliant C++ compiler.

Additionally, Ural also includes an interface to the most common BLAS and LAPACK subroutines. FORTRAN - C++ interfaces are not standardized and are intrinsically platform-dependent.

Ural uses C++ templates to have the same code represent all tensor ranks. For instance, the same function template operator*  encodes inner product of two vectors, a product of a vector and a matrix, a product of a matrix and a vector, matrix product, tensor contraction, etc. For simplicity and usage clarity, reference counting and expression templates are not used by the library, i.e. if you have a function that returns a 1000x1000 matrix, a copy-constructor will be invoked by C++ to copy all 1000,000 elements of the matrix when your function returns. A tensor object owns its data (and deletes it) when its destructor is invoked if and only if the data was allocated by the object's constructor. For instance, in the following example
double* p = new double[1000*1000];
MatrixReal M(1000, 1000, p)
the user must deallocate memory manually, but memory deallocation will happen automatically if the matrix is constructed with, for example
MatrixReal M(1000, 1000);

One of the featurures of the library is its ability to mix types, for example, multiply complex and real objects:
MatrixComplex M(100, 20);
VectorReal V(20);
VectorComplex R(100);
R = M*V;
or increment a floating-point object by an integer one:
Tensor<double, 3> F(10, 20, 30);
Tensor<int, 3> I(10, 20, 30);
F += I;

Compatible compilers:


Compiler and Platform
Core Library
BLAS and LAPACK inferface
G++-2.95, Linux
Yes
Yes
G++-2.95, SunOS
Yes
No Info
G++-3.0, Linux
Yes
Yes
Sun Workshop C++ 5.0, SunOS
No1
No1
MS Visual C++ 6.0, Windows
No2
No2
Borland C++ 5.5.1, Windows
No Info
No Info

1) Compiler does not implement member templates.
2) Broken compiler: no std::size_t , internal compiler errors.

To install the library and to compile the examples, follow the instructions in the INSTALL file.

To see the examples, look under the examples directory.

Oleg Trott



Hosted by
SourceForge Logo