example matrices that were chosen for Smith form testing.
example matrices that were chosen for Smith form testing.
- Author
- bds & zw
Various Smith form algorithms may be used for matrices over the integers or over Z_m. Moduli greater than 2^32 are not supported here. Several types of example matrices may be constructed or the matrix be read from a file. Run the program with no arguments for a synopsis of the command line parameters.
For the "adaptive" method, the matrix must be over the integers. This is expected to work best for large matrices.
For the "2local" method, the computation is done mod 2^32.
For the "local" method, the modulus must be a prime power.
For the "ilio" method, the modulus may be arbitrary composite. If the modulus is a multiple of the integer determinant, the integer Smith form is obtained. Determinant plus ilio may be best for smaller matrices.
This example was used during the design process of the adaptive algorithm.
#include <iostream>
#include <string>
template <class PIR>
int main(
int argc,
char* argv[])
{
if (argc < 3 or argc > 4) {
cout << "usage: " << argv[0] << " type n [filename]" << endl;
cout << " type = `random', `random-rough', `tref',"
<< " 'moler', 'redheffer', "
<< " or `fib',"
<< " and n is the dimension" << endl;
cout << " If filename is present, matrix is written there, else to cout." << endl;
return 0;
}
string type = argv[1];
typedef Givaro::ZRing<Givaro::Integer>
PIR;
if (M.rowdim() <= 20 && M.coldim() <= 20) {
}
if (argc == 4) {
ofstream out(argv[3]);
M.write(out) << endl;
} else {
M.write(cout) << endl;
}
}
template <class PIR>
string src) {
else if (src ==
"tref")
TrefMat(M, R,
n);
else if (src ==
"krat")
KratMat(M, R,
n);
else {
}
}
size_t rowdim() const
Get the number of rows in the matrix.
Definition blas-matrix.h:233
std::istream & read(std::istream &file)
Read the matrix from an input stream.
Definition blas-matrix.inl:286
linbox base configuration file
void Mat(LinBox::DenseMatrix< PIR > &M, PIR &R, int &n, string src)
Output matrix is determined by src which may be: "random-rough" This mat will have s,...
Definition matrices.C:122
void RandomFibMat(LinBox::DenseMatrix< PIR > &M, PIR &R, int n)
Definition matrices.h:124
void RandomFromDiagMat(LinBox::DenseMatrix< PIR > &M, PIR &R, int n)
Definition matrices.h:108
void RandomRoughMat(LinBox::DenseMatrix< PIR > &M, PIR &R, int n)
Definition matrices.h:81
void TrefMat(LinBox::DenseMatrix< PIR > &M, PIR &R, int n)
Definition matrices.h:160
void KratMat(LinBox::DenseMatrix< PIR > &M, PIR &R, int q)
Definition matrices.h:226
void RedhefferMat(LinBox::DenseMatrix< PIR > &A, PIR &R, int n)
Definition matrices.h:263
void MolerMat(LinBox::DenseMatrix< PIR > &A, PIR &R, int n)
Definition matrices.h:244
@ Maple
Definition linbox-tags.h:87
BlasMatrix< _Field > DenseMatrix
Definition dense-matrix.h:46
int n
Definition t-rdisolve.C:74
int main()
Definition test-tutorial.C:54
LinBox timer is Givaro's.