%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%  base_matrix.tex       LiDIA documentation
%%
%%  This file contains the documentation of the class base_matrix
%%
%%  Copyright   (c)   1995   by  LiDIA-Group 
%%
%%  Authors: Patrick Theobald
%%

\markright{\BF{base\_matrix}}
\begin{lidia_man}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NAME
\BF{base\_matrix\TEMPL{T}} \DOTFILL parameterized base matrix class        

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ABSTRACT
The class \BF{base\_matrix\TEMPL{T}} allows to order elements of 
type \BF{T} which is allowed to be either a built--in type or a 
class in form of a matrix.
\[A=(a_{i,j})_{0\LE i<m, 0\LE j<n}\IN T^{m\TIMES n},\]
It allows to create matrices and offers elementary access functions.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DESCRIPTION
A variable of type \BF{base\_matrix\TEMPL{T}} consists of a 2-dimensional 
array \BF{T \TT{**}value} and two elements (\BF{rows, columns}) of type 
\BF{lidia\_size\_t} which store the number of rows and columns of the 
matrix, respectively. Additionally a variable of type \BF{base\_matrix\TEMPL{T}} 
contains two unsigned integers (\BF{print\_mode}, (\BF{print\_mode}).
The member \MATH{print\_mode} determines in which format 
the matrix will be printed. The member \MATH{lattice\_mode} stores
informations used by the lattice classes.
\medskip\\
In the following descriptions we use \MATH{A.rows} to label the number 
of rows and \MATH{A.columns} to label the number of columns of the 
matrix \MATH{A}. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\CONS
If \MATH{a\LE 0} or \MATH{b\LE 0} or \MATH{v = NULL} in one of the 
following constructors, the \TT{lidia\_error\_handler} will be invoked. 

\fcode{ct}{base\_matrix\TEMPL{T}}{}
{
constructs a \MATH{1 \TIMES 1} matrix initialized with values generated 
by the default constructor of type \BF{T}.
}

\fcode{ct}{base\_matrix\TEMPL{T}}{lidia\_size\_t a\k lidia\_size\_t b}
{
constructs an \MATH{a \TIMES b} matrix initialized with values generated 
by the default constructor of type \BF{T}.
}

\fcode{ct}{base\_matrix\TEMPL{T}}{lidia\_size\_t a\k lidia\_size\_t b\k const T **v}
{
constructs an \MATH{a \TIMES b} matrix initialized with the values of 
the 2-dimensional array \MATH{v}. The behaviour of this constructor is 
undefined if the array \MATH{v} has less than \MATH{a} rows or less than 
\MATH{b} columns.
}

\fcode{ct}{base\_matrix\TEMPL{T}}{const base\_matrix\TEMPL{T} \& A}
{
constructs a copy of matrix A.
}

\fcode{dt}{\SIM base\_matrix\TEMPL{T}}{}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ASGN
Let \MATH{A} be of type \BF{base\_matrix\TEMPL{T}}.
The operator \TT{=} is overloaded. For efficiency reasons, the following 
functions are also implemented:

\fcode{void}{A.assign}{const base\_matrix\TEMPL{T} \& B}{}

\fcode{void}{assign}{base\_matrix\TEMPL{T} \& A\k const base\_matrix\TEMPL{T} \& B}
{
sets the dimensions of matrix \MATH{A} to the dimensions of matrix 
\MATH{B} and copies each entry of \MATH{B} to the corresponding 
position in \MATH{A}.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ACCS
Let \MATH{A} be of type \BF{base\_matrix\TEMPL{T}}. Note that the
numbering of columns and rows starts with zero. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{Access to the number of rows}
\cfcode{lidia\_size\_t}{A.get\_no\_of\_rows}{}
{
returns the number of rows of matrix \MATH{A}.
}

\fcode{void}{A.set\_no\_of\_rows}{lidia\_size\_t k}
{
changes the number of rows of matrix \MATH{A} into \MATH{k}. If 
\MATH{k<A.rows}, the rows \MATH{k,\LDOTS , (A.rows-1)} are 
discarded. If \MATH{k>A.rows}, this function adds \MATH{k-A.rows} 
new rows initialized with values generated by the default constructor of
type \BF{T}. The \TT{lidia\_error\_handler} will be invoked if \MATH{k<1}.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{Access to the number of columns}
\cfcode{lidia\_size\_t}{A.get\_no\_of\_columns}{}
{
returns the number of columns of matrix \MATH{A}.
}

\fcode{void}{A.set\_no\_of\_columns}{lidia\_size\_t k}
{
changes the number of columns of matrix \MATH{A} into \MATH{k}. 
If \MATH{k<A.columns}, then the columns \MATH{i,\LDOTS,(A.columns-1)} 
are discarded. If \MATH{k>A.columns}, then this function adds 
\MATH{k-A.columns} new columns initialized with values generated by 
the default--constructor for type \BF{T}. The \TT{lidia\_error\_handler} 
will be invoked if \MATH{k<1}.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{Access to the number of rows and columns}
\fcode{void}{A.resize}{lidia\_size\_t i\k lidia\_size\_t j}
{
changes the number of rows into \MATH{i} and the number of columns 
of matrix \MATH{A} into \MATH{j} by calling the functions 
\TT{A.set\_no\_of\_rows(i)} and \TT{A.set\_no\_of\_columns(j)}.
The \TT{lidia\_error\_handler} is invoked if \MATH{i<1} or \MATH{j<1}.
}

\fcode{void}{A.reset}{}
{
changes the number of columns and number of rows of the
matrix \MATH{A} to 1.\\
Note: Memory is deallocated.
}

\fcode{void}{A.kill}{}
{
changes the number of columns and number of rows of the
matrix \MATH{A} to 1.\\
Note: Memory is deallocated.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{Access to a row}
\cfcode{base\_vector\TEMPL{T}}{A.operator[]}{lidia\_size\_t i}
{
returns a \BF{base\_vector} created by copying the values of row 
\MATH{i}. If \MATH{i\GEQ A.rows} or \MATH{i<0} the \TT{lidia\_error\_handler} 
will be invoked. Note, that the size of the vector that is returned has 
\MATH{size = A.columns} and \MATH{capacity = A.columns}.
}

\cfcode{T *}{A.row}{lidia\_size\_t i}
{
allocates memory and returns a copy of row \MATH{i}. If \MATH{i\GEQ A.rows} 
or \MATH{i<0}, the \TT{lidia\_error\_handler} will be invoked.
}

\cfcode{T *}{A.get\_row}{lidia\_size\_t i}
{
allocates memory and returns a copy of row \MATH{i}. If \MATH{i\GEQ A.rows} 
or \MATH{i<0}, the \TT{lidia\_error\_handler} will be invoked.
}

\cfcode{void}{A.row}{T *v\k lidia\_size\_t i}
{
copies the values of row \MATH{i} to array \MATH{v}. If \MATH{i\GEQ A.rows} 
or \MATH{i<0} or \MATH{v = NULL}, the \TT{lidia\_error\_handler} will be invoked. 
The behaviour of this function is undefined if the array \MATH{v} has less than 
\MATH{A.columns} elements.
}

\cfcode{void}{A.get\_row}{T *v\k lidia\_size\_t i}
{
copies the values of row \MATH{i} to array \MATH{v}. If \MATH{i\GEQ A.rows} 
or \MATH{i<0} or \MATH{v = NULL}, the \TT{lidia\_error\_handler} will be invoked. 
The behaviour of this function is undefined if the array \MATH{v} has less than 
\MATH{A.columns} elements.
}

\cfcode{base\_vector\TEMPL{T}}{A.row\_vector}{lidia\_size\_t i}
{
returns a \BF{base\_vector} created by copying the values of row 
\MATH{i}. If \MATH{i\GEQ A.rows} or \MATH{i<0} the \TT{lidia\_error\_handler} 
will be invoked. Note, that the size of the vector that is returned has 
\MATH{size = A.columns} and \MATH{capacity = A.columns}.
}

\cfcode{base\_vector\TEMPL{T}}{A.get\_row\_vector}{lidia\_size\_t i}
{
returns a \BF{base\_vector} created by copying the values of row 
\MATH{i}. If \MATH{i\GEQ A.rows} or \MATH{i<0} the \TT{lidia\_error\_handler} 
will be invoked. Note, that the size of the vector that is returned has 
\MATH{size = A.columns} and \MATH{capacity = A.columns}.
}

\cfcode{void}{A.row\_vector}{base\_vector\TEMPL{T} \& v\k lidia\_size\_t i}
{
copies the values of row \MATH{i} to \BF{base\_vector} \MATH{v}. If 
\MATH{i\GEQ A.rows} or \MATH{i<0} the \TT{lidia\_error\_handler} will be 
invoked. Note, that the size of vector \MATH{v} is adapted automatically.
}

\cfcode{void}{A.get\_row\_vector}{base\_vector\TEMPL{T} \& v\k lidia\_size\_t i}
{
copies the values of row \MATH{i} to \BF{base\_vector} \MATH{v}. If 
\MATH{i\GEQ A.rows} or \MATH{i<0} the \TT{lidia\_error\_handler} will be 
invoked. Note, that the size of vector \MATH{v} is adapted automatically.
}

\fcode{void}{A.sto\_row}{const T *v\k lidia\_size\_t j\k lidia\_size\_t i}
{
stores \MATH{j} entries of array \MATH{v} in row \MATH{i} of matrix 
\MATH{A} starting at column zero. If \MATH{j>A.columns} or \MATH{j\LEQ 0} 
or \MATH{i\GEQ A.rows} or \MATH{i<0}, the \TT{lidia\_error\_handler} 
will be invoked.
}

\fcode{void}{A.sto\_row\_vector}{const base\_vector\TEMPL{T} \& v\k lidia\_size\_t j\k lidia\_size\_t i}
{
stores \MATH{j} entries of \BF{base\_vector} \MATH{v} in row \MATH{i} 
of matrix \MATH{A} starting at column zero. If \MATH{j>A.columns} or 
\MATH{j\LEQ 0} or \MATH{i\GEQ A.rows} or \MATH{i<0}, the 
\TT{lidia\_error\_handler} will be invoked.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{Access to a column}
\cfcode{base\_vector\TEMPL{T}}{A.operator()}{lidia\_size\_t i}
{
returns a \BF{base\_vector} created by copying the values of column 
\MATH{i}. If \MATH{i\GEQ A.columns} or \MATH{i<0} the \TT{lidia\_error\_handler} 
will be invoked. Note, that the size of the vector that is returned has 
\MATH{size = A.rows} and \MATH{capacity = A.rows}.
}

\cfcode{T *}{A.column}{lidia\_size\_t i}
{
allocates memory and returns a copy of column \MATH{i}. If 
\MATH{i\GEQ A.columns} or \MATH{i<0}, the \TT{lidia\_error\_handler} 
will be invoked.
}

\cfcode{T *}{A.get\_column}{lidia\_size\_t i}
{
allocates memory and returns a copy of column \MATH{i}. If 
\MATH{i\GEQ A.columns} or \MATH{i<0}, the \TT{lidia\_error\_handler} 
will be invoked.
}

\cfcode{void}{A.column}{T *v\k lidia\_size\_t i}
{
copies the values of column \MATH{i} to array \MATH{v}. If 
\MATH{i\GEQ A.columns} or \MATH{i<0} or \MATH{v = NULL}, the 
\TT{lidia\_error\_handler} will be invoked. The behaviour of this function 
is undefined if the array \MATH{v} has less than \MATH{A.rows} elements.
}

\cfcode{void}{A.get\_column}{T *v\k lidia\_size\_t i}
{
copies the values of column \MATH{i} to array \MATH{v}. If 
\MATH{i\GEQ A.columns} or \MATH{i<0} or \MATH{v = NULL}, the 
\TT{lidia\_error\_handler} will be invoked. The behaviour of this function 
is undefined if the array \MATH{v} has less than \MATH{A.rows} elements.
}

\cfcode{base\_vector\TEMPL{T}}{A.column\_vector}{lidia\_size\_t i}
{
returns a \BF{base\_vector} created by copying the values of column 
\MATH{i}. If \MATH{i\GEQ A.columns} or \MATH{i<0} the \TT{lidia\_error\_handler} 
will be invoked. Note, that the size of the vector that is returned has 
\MATH{size = A.rows} and \MATH{capacity = A.rows}.
}

\cfcode{base\_vector\TEMPL{T}}{A.get\_column\_vector}{lidia\_size\_t i}
{
returns a \BF{base\_vector} created by copying the values of column 
\MATH{i}. If \MATH{i\GEQ A.columns} or \MATH{i<0} the \TT{lidia\_error\_handler} 
will be invoked. Note, that the size of the vector that is returned has 
\MATH{size = A.rows} and \MATH{capacity = A.rows}.
}

\cfcode{void}{A.column\_vector}{base\_vector\TEMPL{T} \& v\k lidia\_size\_t i}
{
copies the values of column \MATH{i} to \BF{base\_vector} 
\MATH{v}. If \MATH{i\GEQ A.columns} or \MATH{i<0}, the 
\TT{lidia\_error\_handler} will be invoked. Note, that the size of 
vector \MATH{v} is adapted automatically.
}

\cfcode{void}{A.get\_column\_vector}{base\_vector\TEMPL{T} \& v\k lidia\_size\_t i}
{
copies the values of column \MATH{i} to \BF{base\_vector} 
\MATH{v}. If \MATH{i\GEQ A.columns} or \MATH{i<0}, the 
\TT{lidia\_error\_handler} will be invoked. Note, that the size of 
vector \MATH{v} is adapted automatically.
}

\fcode{void}{A.sto\_column}{const T *v\k lidia\_size\_t j\k lidia\_size\_t i}
{
stores \MATH{j} entries of array \MATH{v} in column \MATH{i} of 
matrix \MATH{A} starting at row zero. If \MATH{j>A.rows} or 
\MATH{j\LEQ 0} or \MATH{i\GEQ A.columns} or \MATH{i<0}, the 
\TT{lidia\_error\_handler} will be invoked.
}

\fcode{void}{A.sto\_column\_vector}{const base\_vector\TEMPL{T} \& v\k lidia\_size\_t j\k lidia\_size\_t i}
{
stores \MATH{j} entries of \BF{base\_vector} \MATH{v} in column 
\MATH{i} of matrix \MATH{A} starting at row zero. If \MATH{j>A.rows} 
or \MATH{j\LEQ 0} or \MATH{i\GEQ A.columns} or \MATH{i<0}, the 
\TT{lidia\_error\_handler} will be invoked.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{Access to an element}
\fcode{T \&}{A.operator()}{lidia\_size\_t i\k lidia\_size\_t j}
{
returns a reference of \MATH{a_{i,j}}. If \MATH{i\GEQ A.rows} or 
\MATH{i<0} or \MATH{j\GEQ A.columns} or \MATH{j<0}, the 
\TT{lidia\_error\_handler} will be invoked.
}

\cfcode{const T \&}{A.member}{lidia\_size\_t i\k lidia\_size\_t j}
{
returns a constant reference of \MATH{a_{i,j}}. If \MATH{i\GEQ A.rows} or 
\MATH{i<0} or \MATH{j\GEQ A.columns} or \MATH{j<0}, the 
\TT{lidia\_error\_handler} will be invoked.
}

\fcode{void}{A.sto}{lidia\_size\_t i\k lidia\_size\_t j\k const T \& x}
{
stores \MATH{x} as \MATH{a_{i,j}}. If \MATH{i\GEQ A.rows} or 
\MATH{i<0} or \MATH{j\GEQ A.columns} or \MATH{j<0}, the 
\TT{lidia\_error\_handler} will be invoked.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{Access to the print\_mode}
\label{base_matrix_access}
\cfcode{unsigned long}{A.get\_print\_mode}{}
{
returns the \MATH{print\_mode} for printing matrix \MATH{A}
(for further information see the description of Input / Output,
page \pageref{base_matrix_io}).
}

\fcode{void}{A.set\_print\_mode}{unsigned long i}
{
sets the \MATH{print\_mode} for matrix \MATH{A} to \MATH{i} 
(for further information see the description of Input / Output,
page \pageref{base_matrix_io}).
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\SSTITLE{Access to the lattice\_mode}
%\label{base_matrix_access}
%\cfcode{unsigned long}{A.get\_lattice\_mode}{}
%{
%returns the \MATH{lattice\_mode} of matrix/lattice \MATH{A}
%(for further information see the description of the lattice classes,
%page \pageref{lattice_mode}).
%}

%\fcode{void}{A.set\_lattice\_mode}{unsigned long i}
%{
%sets the \MATH{lattice\_mode} for matrix \MATH{A} to \MATH{i} 
%(for further information see the description of the lattice classes,
%page \pageref{lattice_mode}).
%}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{Access to the array of values}
\cfcode{T **}{A.get\_data}{}
{
returns a pointer to a copy of the array of values of matrix \MATH{A}.
}

\fcode{void}{A.set\_data}{const T **v\k lidia\_size\_t r\k lidia\_size\_t c}
{
sets the number of rows of matrix \MATH{A} to \MATH{r} and the number 
of columns of matrix \MATH{A} to \MATH{c} and copies the values of the 
\MATH{(r \TIMES c)}--array \MATH{v} to the array of values of matrix 
\MATH{A}. The \TT{lidia\_error\_handler} will be invoked if \MATH{r<1} 
or \MATH{c<1}.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\STITLE{Split Functions}
Let \MATH{A} be of type \BF{base\_matrix\TEMPL{T}}. The following 
split functions allow area overlap of the submatrices or subvectors 
in the following sense: \medskip\\
According to the dimensions of the parameters and the special scheme 
described in the respective split function, the values of the 
member matrix are copied to the parameters.  \medskip\\
\BF{\large Example:}
\medskip\\
Look at the matrix 
\latex{\[A=\LEFT(\begin{array}{cccc}
12 & 23 & 62 & 89\\
90 & 19 & 80 & 73\\
45 & 90 & 32 & 91\end{array}\RIGHT).\]}
\html{\begin{verbatim}

          ( 12 23 62 89 )
      A = ( 90 19 80 73 )
          ( 45 90 32 91 )

\end{verbatim}}
Furthermore, let \MATH{B} be a \MATH{(2\TIMES 3)}--\BF{base\_matrix}, 
\MATH{C} a \MATH{(2\TIMES 2)}--\BF{base\_matrix}, 
\MATH{D} a \MATH{(3\TIMES 2)}--\BF{base\_matrix} and E a 
\MATH{(3\TIMES 3)}--\BF{base\_matrix}.
\medskip\\ 
After executing \TT{A.split\_t(B,C,D,E)} for the matrices 
\MATH{B}, \MATH{C}, \MATH{D} and \MATH{E} hold the following:

\latex{\[\begin{array}{c} 
A=\LEFT(\begin{array}{cccc}
12 & 23 & 62 & 89\\
90 & 19 & 80 & 73\\
45 & 90 & 32 & 91\end{array}\RIGHT)\\
\mbox{and}\\
B=\LEFT(\begin{array}{ccc}
12 & 23 & 62 \\
90 & 19 & 80 \end{array}\RIGHT),
C=\LEFT(\begin{array}{cccc}
62 & 89\\
80 & 73\end{array}\RIGHT),
D=\LEFT(\begin{array}{cc}
12 & 23 \\
90 & 19 \\
45 & 90 \end{array}\RIGHT),
E=\LEFT(\begin{array}{ccc}
23 & 62 & 89\\
19 & 80 & 73\\
90 & 32 & 91\end{array}\RIGHT)
\end{array}\]}
\html{\begin{verbatim}

                           ( 12 23 62 89 )
                       A = ( 90 19 80 73 )
                           ( 45 90 32 91 )

                                 and

     ( 12 23 62 )      ( 62 89 )      ( 12 23 )      ( 23 62 89 )
 B = (          ), C = (       ), D = ( 90 19 ), E = ( 19 80 73 )
     ( 90 19 80 )      ( 80 73 )      ( 45 90 )      ( 90 32 91 )

\end{verbatim}}

If the given conditions in the descriptions of the following functions 
are not fulfilled, the \TT{lidia\_error\_handler} will be invoked.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{split\_total}
\cfcode{void}{A.split\_t}{base\_matrix\TEMPL{T} \& B\k base\_matrix\TEMPL{T} \& C \k base\_matrix\TEMPL{T} \& D\k base\_matrix\TEMPL{T} \& E}
{
takes matrix \MATH{A} apart into the submatrices \MATH{B}, \MATH{C}, 
\MATH{D} and \MATH{E}, with
\latex{\[A=\LEFT(\begin{array}{cc} B & C \\ D & E \end{array}\RIGHT)\]}
\html{\begin{verbatim}

           ( B C )
       A = (     )
           ( D E )
         
\end{verbatim}}
where the following conditions have to be fulfilled: 

\vspace{0.2cm} 
\centerline{\MATH{B.rows,C.rows,D.rows,E.rows \LE A.rows}}
\centerline{\MATH{B.columns,C.columns,D.columns,E.columns \LE A.columns}.}
}
\vspace{-0.4cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{split\_horizontal}
\cfcode{void}{A.split\_h}{base\_matrix\TEMPL{T} \& B\k base\_matrix\TEMPL{T} \& C}
{
takes matrix \MATH{A} apart into the submatrices \MATH{B} and 
\MATH{C}, with \latex{\MATH{A=\LEFT(\begin{array}{cc} B & C \end{array}\RIGHT)}}
\html{\MATH{A = ( B C )}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{B.rows,C.rows \LE A.rows}}
\centerline{\MATH{B.columns,C.columns \LE A.columns}.}
}
\vspace{-0.4cm}

\cfcode{void}{A.split\_h}{T *v\k base\_matrix\TEMPL{T} \& C}
{
takes matrix \MATH{A} apart into the array \MATH{v} and the submatrix 
\MATH{C}, with \latex{\MATH{A=\LEFT(\begin{array}{cc} v & C \end{array}\RIGHT)}}
\html{\MATH{A = ( v C )}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v \not= NULL}}
\centerline{\MATH{C.rows \LE A.rows}}
\centerline{\MATH{C.columns \LE A.columns}.}
The behaviour of this function is undefined if \MATH{v} has less 
than \MATH{A.rows} elements.
}

\cfcode{void}{A.split\_h}{base\_vector\TEMPL{T} \& v\k base\_matrix\TEMPL{T} \& C}
{
takes matrix \MATH{A} apart into the vector \MATH{v} and the submatrix 
\MATH{C}, with \latex{\MATH{A=\LEFT(\begin{array}{cc} v & C \end{array}\RIGHT)}}
\html{\MATH{A = ( v C )}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v.size \LE A.rows}}
\centerline{\MATH{C.rows \LE A.rows}}
\centerline{\MATH{C.columns \LE A.columns}.}
}
\vspace{-0.4cm}

\cfcode{void}{A.split\_h}{base\_matrix\TEMPL{T} \& B\k T *v}
{
takes matrix \MATH{A} apart into the submatrix \MATH{B} and the array 
\MATH{v}, with \latex{\MATH{A=\LEFT(\begin{array}{cc} B & v \end{array}\RIGHT)}}
\html{\MATH{A = ( B v )}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v \not= NULL}} 
\centerline{\MATH{B.rows \LE A.rows}}
\centerline{\MATH{B.columns \LE A.columns}.}
The behaviour of this function is undefined if \MATH{v} has less than 
\MATH{A.rows} elements.
}

\cfcode{void}{A.split\_h}{base\_matrix\TEMPL{T} \& B\k base\_vector\TEMPL{T} \& v}
{
takes matrix \MATH{A} apart into the submatrix \MATH{B} and the vector 
\MATH{v}, with \latex{\MATH{A=\LEFT(\begin{array}{cc} B & v \end{array}\RIGHT)}}
\html{\MATH{A = ( B v )}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v.size \LE A.rows}}
\centerline{\MATH{B.rows \LE A.rows}}
\centerline{\MATH{B.columns \LE A.columns}.}
}
\vspace{-0.4cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{split\_vertical}
\cfcode{void}{A.split\_v}{base\_matrix\TEMPL{T} \& B\k base\_matrix\TEMPL{T} \& C}
{
takes matrix \MATH{A} apart into the submatrices \MATH{B} and 
\MATH{C}, with \latex{\MATH{A=\LEFT(\begin{array}{c} B \\ C \end{array}\RIGHT)}}
\html{\MATH{A = ( B C )^t}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{B.rows,C.rows \LE A.rows}}
\centerline{\MATH{B.columns,C.columns \LE A.columns}.}
}
\vspace{-0.4cm}

\cfcode{void}{A.split\_v}{T *v\k base\_matrix\TEMPL{T} \& C}
{
takes matrix \MATH{A} apart into the array \MATH{v} and the submatrix 
\MATH{C}, with \latex{\MATH{A=\LEFT(\begin{array}{c} v \\ C \end{array}\RIGHT)}}
\html{\MATH{A = ( v C )^t}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v \not= NULL}} 
\centerline{\MATH{C.rows \LE A.rows}}
\centerline{\MATH{C.columns \LE A.columns}.}
The behaviour of this function is undefined if \MATH{v} has less 
than \MATH{A.columns} elements.
}

\cfcode{void}{A.split\_v}{base\_vector\TEMPL{T} \& v\k base\_matrix\TEMPL{T} \& C}
{
takes matrix \MATH{A} apart into the vector \MATH{B} and the submatrix 
\MATH{C}, with \latex{\MATH{A=\LEFT(\begin{array}{c} v \\ C \end{array}\RIGHT)}}
\html{\MATH{A = ( v C )^t}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v.size \LE A.columns}}
\centerline{\MATH{C.rows \LE A.rows}}
\centerline{\MATH{C.columns \LE A.columns}.}
}
\vspace{-0.4cm}

\cfcode{void}{A.split\_v}{base\_matrix\TEMPL{T} \& B\k T *v}
{
takes matrix \MATH{A} apart into the submatrix \MATH{B} and the array 
\MATH{v}, with \latex{\MATH{A=\LEFT(\begin{array}{c} B \\ v \end{array}\RIGHT)}}
\html{\MATH{A = ( B v )^t}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v \not= NULL}}
\centerline{\MATH{B.rows \LE A.rows}}
\centerline{\MATH{B.columns \LE A.columns}.}
The behaviour of this function is undefined if \MATH{v} has less 
than \MATH{A.columns} elements.
}

\cfcode{void}{A.split\_v}{base\_matrix\TEMPL{T} \& B\k base\_vector\TEMPL{T} \& v}
{
takes matrix \MATH{A} apart into the submatrix \MATH{B} and the vector 
\MATH{v}, with \latex{\MATH{A=\LEFT(\begin{array}{c} B \\ v \end{array}\RIGHT)}}
\html{\MATH{A = ( B v )^t}}, 
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v.size \LE A.columns}}
\centerline{\MATH{B.rows \LE A.rows}}
\centerline{\MATH{B.columns \LE A.columns}.}
}
\vspace{-0.4cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\STITLE{Compose Functions}
Let \MATH{A} be of type \BF{base\_matrix\TEMPL{T}}. The following 
compose functions allow area overlap of the submatrices or subvectors 
in the following sense: \medskip\\
According to the dimensions of the parameters, the order of the 
parameters in the prototype and the special scheme described in the 
respective compose function, the values of the parameters are copied 
to the member matrix.  \medskip\\
\BF{\large Example:}
\medskip\\
Look at the matrices 
\latex{\[B=\LEFT(\begin{array}{ccc}
12 & 23 & 30 \\
90 & 19 & 40 \end{array}\RIGHT),
C=\LEFT(\begin{array}{cccc}
24 & 89\\
67 & 73\end{array}\RIGHT),
D=\LEFT(\begin{array}{c}
21 \\
92 \\
45 \end{array}\RIGHT),
E=\LEFT(\begin{array}{ccc}
12 & 88 & 73\\
99 & 33 & 91\end{array}\RIGHT)\]}
\html{\begin{verbatim}

     ( 12 23 30 )      ( 24 89 )      ( 21 )      ( 12 88 73 )
 B = (          ), C = (       ), D = ( 92 ), E = (          )
     ( 90 19 40 )      ( 67 73 )      ( 45 )      ( 99 33 91 )

\end{verbatim}}
Further let \MATH{A} be a \MATH{(3\TIMES 4)}--\BF{base\_matrix}.\\ 
After executing \TT{A.compose\_t(B,C,D,E)} for \MATH{A} the following holds:
\latex{\[A=\LEFT(\begin{array}{cccc}
21 & 23 & 24 & 89\\
92 & 12 & 88 & 73\\
45 & 99 & 33 & 91\end{array}\RIGHT)\]}
\html{\begin{verbatim}

          ( 21 23 24 89 )
      A = ( 92 12 88 73 )
          ( 45 99 33 91 )

\end{verbatim}}
The matrices \MATH{B}, \MATH{C}, \MATH{D} and \MATH{E} remain unchanged.
\medskip\\
If the given conditions in the descriptions of the following functions 
are not fulfilled, the \TT{lidia\_error\_handler} will be invoked.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{compose\_total}
\fcode{void}{A.compose\_t}{const base\_matrix\TEMPL{T} \& B\k const base\_matrix\TEMPL{T} \& C\k const base\_matrix\TEMPL{T} \& D\k const base\_matrix\TEMPL{T} \& E}
{
composes the matrices \MATH{B}, \MATH{C}, \MATH{D} and \MATH{E} to 
the matrix \MATH{A}, with 
\latex{\MATH{A=\LEFT(\begin{array}{cc} B & C \\ D & E \end{array}\RIGHT)}}
\html{\begin{verbatim}
     ( B C )
 A = (     )
     ( D E )
\end{verbatim}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{B.rows,C.rows,D.rows,E.rows \LE A.rows}}
\centerline{\MATH{B.columns,C.columns,D.columns,E.columns \LE A.columns}.}
}
\vspace{-0.4cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{compose\_horizontal}
\fcode{void}{A.compose\_h}{const base\_matrix\TEMPL{T} \& B\k const base\_matrix\TEMPL{T} \& C}
{
composes the matrices \MATH{B} and \MATH{C} to the matrix \MATH{A}, 
with \latex{\MATH{A=\LEFT(\begin{array}{cc} B & C \end{array}\RIGHT)}}
\html{\MATH{A = ( B C )}} where 
the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{B.rows,C.rows \LE A.rows}}
\centerline{\MATH{B.columns,C.columns \LE A.columns}.}
}
\vspace{-0.4cm}

\fcode{void}{A.compose\_h}{const T *v\k const base\_matrix\TEMPL{T} \& C}
{
composes the array \MATH{v} and the matrix \MATH{C} to the matrix 
\MATH{A}, with \latex{\MATH{A=\LEFT(\begin{array}{cc} v & C \end{array}\RIGHT)}}
\html{\MATH{A = ( v C )}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v\not= NULL}}
\centerline{\MATH{C.rows \LE A.rows}}
\centerline{\MATH{C.columns \LE A.columns}.}
The behaviour of this function is undefined if \MATH{v} has less 
than \MATH{A.rows} elements.
}

\fcode{void}{A.compose\_h}{const base\_vector\TEMPL{T} \& v\k const base\_matrix\TEMPL{T} \& C}
{
composes the vector \MATH{v} and the matrix \MATH{C} to the matrix 
\MATH{A}, with \latex{\MATH{A=\LEFT(\begin{array}{cc} v & C \end{array}\RIGHT)}}
\html{\MATH{A = ( v C )}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v.size \LE A.rows}}
\centerline{\MATH{C.rows \LE A.rows}}
\centerline{\MATH{C.columns \LE A.columns}.}
}
\vspace{-0.4cm}

\fcode{void}{A.compose\_h}{const base\_matrix\TEMPL{T} \& B\k const T *v}
{
composes the matrix \MATH{B} and the array \MATH{v} to the matrix 
\MATH{A}, with \latex{\MATH{A=\LEFT(\begin{array}{cc} B & v \end{array}\RIGHT)}}
\html{\MATH{A = ( B v )}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v\not= NULL}}
\centerline{\MATH{B.rows \LE A.rows}}
\centerline{\MATH{B.columns \LE A.columns}.}
The behaviour of this function is undefined if \MATH{v} has less 
than \MATH{A.rows} elements.
}

\fcode{void}{A.compose\_h}{const base\_matrix\TEMPL{T} \& B\k const base\_vector\TEMPL{T} \& v}
{
composes the matrix \MATH{B} and the vector \MATH{v} to the matrix 
\MATH{A}, with \latex{\MATH{A=\LEFT(\begin{array}{cc} B & v \end{array}\RIGHT)}}
\html{\MATH{A = ( B v )}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v.size \LE A.rows}}
\centerline{\MATH{B.rows \LE A.rows}}
\centerline{\MATH{B.columns \LE A.columns}.}
}
\vspace{-0.4cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SSTITLE{compose\_vertical}
\fcode{void}{A.compose\_v}{const base\_matrix\TEMPL{T} \& B\k const base\_matrix\TEMPL{T} \& C}
{
composes the matrices \MATH{B} and \MATH{C} to the matrix \MATH{A}, 
with \latex{\MATH{A=\LEFT(\begin{array}{c} B \\ C \end{array}\RIGHT)}}
\html{\MATH{A = ( B C )^t}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{B.rows,C.rows \LE A.rows}}
\centerline{\MATH{B.columns,C.columns \LE A.columns}.}
}
\vspace{-0.4cm}

\fcode{void}{A.compose\_v}{const T *v\k const base\_matrix\TEMPL{T} \& C}
{
composes the array \MATH{v} and the matrix \MATH{C} to the matrix 
\MATH{A}, with \latex{\MATH{A=\LEFT(\begin{array}{c} v \\ C \end{array}\RIGHT)}}
\html{\MATH{A = ( v C )^t}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v\not= NULL}}
\centerline{\MATH{C.rows \LE A.rows}}
\centerline{\MATH{C.columns \LE A.columns}.}
The behaviour of this function is undefined if \MATH{v} has less 
than \MATH{A.columns} elements.
}

\fcode{void}{A.compose\_v}{const base\_vector\TEMPL{T} \& v\k const base\_matrix\TEMPL{T} \& C}
{
composes the vector \MATH{v} and the matrix \MATH{C} to the matrix 
\MATH{A}, with \latex{\MATH{A=\LEFT(\begin{array}{c} v \\ C \end{array}\RIGHT)}}
\html{\MATH{A = ( v C )^t}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v.size \LE A.columns}}
\centerline{\MATH{C.rows \LE A.rows}}
\centerline{\MATH{C.columns \LE A.columns}.}
}
\vspace{-0.4cm}

\fcode{void}{A.compose\_v}{const base\_matrix\TEMPL{T} \& B\k const T *v}
{
composes the matrix \MATH{B} and the array \MATH{v} to the matrix 
\MATH{A}, with \latex{\MATH{A=\LEFT(\begin{array}{c} B \\ v \end{array}\RIGHT)}}
\html{\MATH{A = ( B v )^t}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v\not= NULL}}
\centerline{\MATH{B.rows \LE A.rows}}
\centerline{\MATH{B.columns \LE A.columns}.}
The behaviour of this function is undefined if \MATH{v} has less 
than \MATH{A.columns} elements.
}

\fcode{void}{A.compose\_v}{const base\_matrix\TEMPL{T} \& B\k const base\_vector\TEMPL{T} \& v}
{
composes the matrix \MATH{B} and the vector \MATH{v} to the matrix 
\MATH{A}, with \latex{\MATH{A=\LEFT(\begin{array}{c} B \\ v \end{array}\RIGHT)}}
\html{\MATH{A = ( B v )^t}}
where the following conditions have to be fulfilled:

\vspace{0.2cm}
\centerline{\MATH{v.size \LE A.columns}}
\centerline{\MATH{B.rows \LE A.rows}}
\centerline{\MATH{B.columns \LE A.columns}.}
}
\vspace{-0.4cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\STITLE{Swap Functions}
\fcode{void}{swap}{base\_matrix\TEMPL{T} \& A\k base\_matrix\TEMPL{T} \& B}
{
swaps \MATH{A} and \MATH{B}.
}

\fcode{void}{A.swap\_columns}{lidia\_size\_t i\k lidia\_size\_t j}
{
swaps the entries of the columns \MATH{i} and \MATH{j} in \MATH{A}. 
If \MATH{0\LE i,j < A.columns} doesn't hold, the \TT{lidia\_error\_handler} 
will be invoked.
}

\fcode{void}{A.swap\_rows}{lidia\_size\_t i\k lidia\_size\_t j}
{
swaps the entries of the rows \MATH{i} and \MATH{j} in \MATH{A}. 
If \MATH{0\LE i,j < A.rows} doesn't hold, the \TT{lidia\_error\_handler} will be
invoked.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\STITLE{Diagonal Functions}
\fcode{void}{A.diag}{const T \& a\k const T \& b}{
stores \MATH{a} at all positions \MATH{(i,i)} of matrix \MATH{A} 
with \MATH{0\LE i < min(A.rows, A.columns)} and \MATH{b} at all 
other positions.
}

\fcode{void}{diag}{base\_matrix\TEMPL{T} \& A\k const T \& a\k const T \& b}
{
stores \MATH{a} at all positions \MATH{(i,i)} of matrix \MATH{A} 
with \MATH{0\LE i < min(A.rows, A.columns)} and \MATH{b} at all 
other positions.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\STITLE{Transpose Functions}
\cfcode{base\_matrix\TEMPL{T}}{A.trans}{}
{
returns \MATH{A^T}.
}

\fcode{base\_matrix\TEMPL{T}}{trans}{const base\_matrix\TEMPL{T} \& A}
{
returns \MATH{A^T}.
}

\fcode{void}{A.trans}{const base\_matrix\TEMPL{T} \& B}
{
stores \MATH{B^T} to \MATH{A}.
}

\fcode{void}{trans}{base\_matrix\TEMPL{T} \& A\k const base\_matrix\TEMPL{T} \& B}
{
stores \MATH{B^T} to \MATH{A}.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\IO
\label{base_matrix_io}
The \BF{istream} operator \TT{>>} and the \BF{ostream} operator 
\TT{<<} are overloaded. The \BF{istream} operator \TT{>>} reads 
matrices in any of the supported formats from istream. 

The \BF{ostream} operator \TT{<<} outputs the matrix in the format 
given by the variable \MATH{print\_mode} (See Access Functions, 
page \pageref{base_matrix_access}, for further information on how 
to set the print mode). By default, the \TT{``beautify mode''} is used. 
The following table shows, which values of \MATH{print\_mode} 
correspond to the different output format.

\latex{
\begin{center}
\begin{tabular}{|c||c|}\hline
print\_mode & format \\\hline\hline
0 & ``beautify''\\\hline
1 & \LiDIA\\\hline
2 & PARI \\\hline
3 & MATHEMATICA \\\hline
4 & MAPLE\\\hline
5 & KANT \\\hline
\end{tabular} 
\end{center}}

\html{\begin{verbatim}
        
          print_mode  |    format
                 ----------------------------
                       0      | "beautify"
                           1      |   LiDIA
                           2      |   PARI
                           3      | MATHEMATICA
                           4      |   MAPLE
                           5      |   KANT
        
\end{verbatim}}

\begin{itemize}
\item By beautify format we mean the following ASCII format, which 
should be used only to output matrices on the screen, since it cannot 
be read by our library:
\latex{
\begin{center}
\[\begin{array}{cccccc}
(& a_{0,0} & a_{0,1} & \LDOTS & a_{0,c-1}&)\\ 
(& a_{1,0} &  \LDOTS & \LDOTS & a_{1,c-1}&)\\
(& \vdots & \vdots & \vdots & \vdots &)\\
(& a_{r-1,0} & \LDOTS &\LDOTS & a_{r-1,c-1}&)
\end{array}\]
\end{center}}
\html{\begin{verbatim}
        
 ( a_0,0   a_0,1  .   .   .   a_0,c-1  )
 ( a_1,0     .    .   .   .   a_1,c-1  )
 (   .       .    .   .   .      .     )
 (   .       .    .   .   .      .     )
 (   .       .    .   .   .      .     )
 ( a_r-1,0   .    .   .   .  a_r-1,c-1 )
        
\end{verbatim}}

\item By \LiDIA\ format we mean the following ASCII format:
\[r \SQCUP c \SQCUP a_{0,0} \SQCUP a_{0,1} \SQCUP 
\LDOTS \SQCUP a_{0,c-1} \SQCUP a_{1,0} \SQCUP \LDOTS \SQCUP a_{1,c-1}
\SQCUP  \LDOTS \SQCUP a_{r-1,0} \SQCUP \LDOTS \SQCUP a_{r-1,c-1}\]
where \MATH{r = A.rows} and \MATH{c = A.columns}.

\item By PARI\ format we mean the following ASCII format:
\[[a_{0,0},\ a_{0,1}, \LDOTS,\ a_{0,c-1};\ a_{1,0}, \LDOTS,\ a_{1,c-1};\ 
\LDOTS;\  a_{r-1,0}, \LDOTS,\ a_{r-1,c-1}]\]
where \MATH{r = A.rows} and \MATH{c = A.columns}.

\item By MATHEMATICA\ format we mean the following ASCII format:
\[\{\{a_{0,0},\ a_{0,1},\LDOTS,\ a_{0,c-1}\},\ \{a_{1,0},\LDOTS,\ a_{1,c-1}\},
\LDOTS,\ \{a_{r-1,0},\LDOTS,\ a_{r-1,c-1}\}\}\]
where \MATH{r = A.rows} and \MATH{c = A.columns}.

\item By MAPLE\ format we mean the following ASCII format:
\begin{center}
\MATH{\begin{array}{ccccc}
array(1..r,\ 1..c,[&(1,1)=a_{0,0}, & (1,2)=a_{0,1}, & \LDOTS, & (1,c)=a_{0,c-1},\\ 
&(2,1)=a_{1,0}, &  \LDOTS & \LDOTS, &(2,c)=a_{1,c-1},\\
&\vdots & \vdots & \vdots & \vdots\\
&(r,1)=a_{r-1,0}, & \LDOTS &\LDOTS, &(r,c)=a_{r-1,c-1})];
\end{array}}
\end{center}
where \MATH{r = A.rows} and \MATH{c = A.columns}.

\item By KANT\ format we mean the following ASCII format:
\[LIDIA:=Mat(Z,[[a_{0,0},\ a_{0,1},\LDOTS,\ a_{0,c-1}],\ [a_{1,0},\LDOTS,\ a_{1,c-1}],
\LDOTS,\ [a_{r-1,0},\LDOTS,\ a_{r-1,c-1}]])\]
where \MATH{r = A.rows} and \MATH{c = A.columns}.
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\STITLE{Interfaces}
The following member functions support writing to and reading from
ASCII files in the standard format of other computer algebra
programs:

\cfcode{void}{A.write\_to\_stream}{ostream \& out}
{
writes matrix \MATH{A} to ostream \MATH{out} in \LiDIA\ format.
}

\fcode{void}{A.read\_from\_stream}{istream \& in}
{
reads \LiDIA\ matrix \MATH{A} from istream \MATH{in}.
}

\cfcode{void}{A.write\_to\_gp}{ostream \& out}
{
writes matrix \MATH{A} to ostream \MATH{out} in GP format.
}

\fcode{void}{A.read\_from\_gp}{istream \& in}
{
reads GP matrix \MATH{A} from istream.
}

\cfcode{void}{A.write\_to\_mathematica}{ostream \& out}
{
writes matrix \MATH{A} to ostream \MATH{out} in MATHEMATICA format.
}

\fcode{void}{A.read\_from\_mathematica}{istream \& in}
{
reads MATHEMATICA matrix \MATH{A} from istream.
}

\cfcode{void}{A.write\_to\_maple}{ostream \& out}
{
writes matrix \MATH{A} to ostream \MATH{out} in MAPLE format.
}

\fcode{void}{A.read\_from\_maple}{istream \& in}
{
reads MAPLE matrix \MATH{A} from istream.
}

\cfcode{void}{A.write\_to\_kash}{ostream \& out}
{
writes matrix \MATH{A} to ostream \MATH{out} in KASH format.
}

\fcode{void}{A.read\_from\_kash}{istream \& in}
{
reads KASH matrix \MATH{A} from istream.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SEEALSO
\BF{math\_matrix}, \BF{bigint\_matrix}, \BF{base\_vector}, \BF{math\_vector}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\BUGS
By now, the function reading and writing matrices in GP--format 
don't understand the use of \MATH{\backslash} as a multiple line break 
symbol.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NOTES
\begin{enumerate}
\item As described in the template introduction (see page \pageref{template_introduction2})
for using an instance of type \BF{base\_matrix\TEMPL{T}}\ the type \BF{T} has to have at least
least have 
\begin{itemize}
\item a swap--function \TT{void swap(T \&, T\&)},
\item the input--operator \TT{>>},
\item the output--operator \TT{<<} and 
\item the assignment--operator \TT{=}.
\end{itemize}

\item As usually in ''C'' the numbering of columns and rows starts with zero.
\end{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\EXAMPLES
\begin{verbatim}
 #include <LiDIA/base_matrix.h>
 #include <LiDIA/bigint.h>

 main()
 {
   base_matrix < bigint > A(4,5);
   register int i,j;
   for (i = 0; i < A.get_no_of_rows(); i++)
     for (j = 0; j < A.get_no_of_columns(); j++)
        A.sto(i,j,(bigint)(i+j));
   cout << A << flush;
 }
\end{verbatim}        

For further examples please refer to\\
\TT{LiDIA/src/templates/matrix/base\_matrix\_appl.c}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\AUTHOR
Stefan Neis, Patrick Theobald

\end{lidia_man}
