                              matrix++
                         C++ matrix library
                         ------------------
matrix++ is a C++ matrix library that provides operations on matrices.
The size of the matrices is practically limited by the available memory.
Theoritically it is limited by the maximum unsigned long, which on a
32bit machine is a little over four billion.  In practice, memory is the
limitation, but if you have lots of virtual memory, you can have quite
large matrices.  

matrix++ conncetrates on the operations, and not on the details.  There
are no worries, to the user, about memory managment, as you should 
expect in most C++ code. A lot of functionality is build by means of 
operators (overloading), thus making matrix manipulation more natural to
the mathematician.

- Defining a matrix data type.

The matrix++ library introduces the 'matrix' data type.  You can delcare
a matrix just like you would delcare an integer or any built-in data type.

The simpleset form of a matrix delceration is:
matrix a; 
which declares a matrix variable 'a'.
Often the size if the matrix is known at the time of the declaration, so
you can directly specify it as:
matrix a(10,10); // this is a 10x10 matrix

Note that the second example actualy reserves space for the matrix,
while the first merly declares a matrix variable.

You can also declare a matrix of specific size, and initialize it at the
same time.  For example:
matrix a(10,10,0.0); // a 10x10 matrix, all elements initialized to 0.0

The initialization of a matrix as an 'identity' matrix occures often
enough to account for the shortcut:
matrix a(10,10,identity); // a 10x10 identity matrix

You can also declare and initialize a matrix from a file as:
matrix a(10,10,"file_1"); // a 10x10 matrix initialized from file 'file_1'
More about the format of the file later.

There is one more way of delcaring and initializing a matrix, using an
assignment operator.  More about that after the description of
assignment operations.

- Operators
The matrix++ library implements all the usuall matrix operators one
would expect.  These are: 

=  : assignment.
+  : addition between two matrices.
+= : addition and assignment.
-  : (1) subtruction between two matrices.
     (2) unary minus of a matrix (same as -1 * matrix).
-= : subtraction and assignment.
*  : (1) multiplication between two matrices.
     (2) multiplication between a matrix and a scalar (all elements of
         the matrix are multiplied by the scalar.)
*= : multiplication and assignment.
<< : output the matrix
>> : input to the matrix
~  : inverse of the matrix
!  : transpose of the matrix
%  : solves a linear system defined as AX=B.  X is A % B.

Here are some examples, all variable are assumed to be declared.

a = b; 
a = a - b; 
a -= b; // same as above 
a = 2*a;
a = a*2; // same as above
a *= 2; // same as above 
a = ~b;
a = ~~b; // a is b now
a = !b;
a = !~~b; // a has the same value as above
cin >> a; // initialize a from standard input.  a MUST be declared, 
          // and it's size must be defined.
"file_1" >> a; // initialize a from file_1. a MUST be declared,
               // and it's size must be defined.
file >> a; // same as above, file is an open stream.
cout << a; // output a to standard output.

- The assignment operator can be used, just like in regular C or C++ in
any matrix declerations.  For example:
matrix a=b; // delcares a, and initializes it from matrix b.
This is usually convenient when dealing with temporary matrix variables.

- The operators >> << and the matrix delcarations, can do i/o to and from
files.  The format used is quite simple, and allows the direct view of 
stored matrices, and possible later use.

A 3x3 identity matrix is stored or printed as:
1 0 0
0 1 0
0 0 1

Actually, all that really matters is that matrix elements are seperated
by spaces, so the above matrix could be stored, for input, as:
1 0 0 0 1 0 0 0 1

It is essensial to define matrix size, when inputing from a file, so the
matrix is properly created.

- INSTALLATION
You should have the file matrix++.tgz
This is a tar file compressed with GNU zip; to unpack do:

gunzip matrix++.tgz
tar xvf matrix++.tar

(GNU tar users can combine the above with: tar zxvf matrix++.tgz) 

To create the library, first make sure your C++ compiler is defined
properlly in the Makefile (mine is g++).  Then do:
cd matrix++
make clean
make depend
SunOS users:
  make sun
Other users:
  make generic

Hopefully it will compile, and create matrix++.a
To test the library, cd examples and do (assuming your C++ compiler is g++):
g++ test.c ../matrix++.a

If you use matrix++.a, you can put it in /usr/lib/libmatrix++.a
or /usr/local/lib/libmatrix++.a, and link it with -l like: 
g++ test -lmatrix++

Problems or suggestions can be reported to kdgrc@rc.rit.edu
I am particularly interested in the speed of some of the operations
provided.  If you think you have a faster implementation at hand, 
and would like to see it used in here, email me.

Kyriakos Georgiou
