computes doubleDet.
#include <iostream>
#include <givaro/zring.h>
#include <linbox/util/matrix-stream.h>
#include <linbox/algorithms/double-det.h>
using namespace std;
int main (int argc, char **argv)
{
Givaro::ZRing<Integer> ZZ;
ifstream input (argv[1]);
if (!input)
{ cerr << "Error opening matrix file " << argv[1] << endl;
return -1;
}
MatrixStream <Givaro::ZRing<Integer> > ms (ZZ, input);
DenseMatrix <Givaro::ZRing<Integer> > A (ms);
cout << "Matrix is " << A.rowdim() << " by " << A.coldim() << endl;
if (A.rowdim() != A.coldim() + 1){
cerr<<"Wrong dimensions: A must be (n+1) x n"<<endl;
exit (-1);
}
Timer tim; tim.clear();
tim.start();
bool proof=false;
if (argc > 2)
proof = true;
doubleDet (det1, det2, A, proof);
tim.stop();
size_t n = A.coldim();
DenseMatrix<Givaro::ZRing<Integer> > B (ZZ, n, n);
for (size_t i=0; i<n-1; ++i)
for (size_t j=0; j<n; ++j)
B.setEntry (i,j,A.getEntry(i,j));
for (size_t j=0; j<n; ++j)
B.setEntry (n-1,j,A.getEntry(n-1,j));
for (size_t j=0; j<n; ++j)
B.setEntry(n-1,j,A.getEntry(n,j));
Timer tim2;
tim2.clear();
tim2.start();
tim2.stop();
if ((det1 != db) || (det2 != dc))
std::cerr<<"Check FAIL"<<endl;
cout<< "Det 1 = " << det1 << endl;
cout<< "Det 2 = " << det2 << endl;
cerr << "Double Det: " << tim.usertime() << "s" << endl;
cerr << "Each single Det: "<<tim2.usertime() << "s" << endl;
return 0 ;
}
Givaro::Integer integer
Integers in LinBox.
Definition: integer.h:55
Blackbox::Field::Element & det(typename Blackbox::Field::Element &d, const Blackbox &A, const DomainCategory &tag, const DetMethod &Meth)
Compute the determinant of A.
linbox base configuration file
Namespace in which all linbox code resides.
Definition: alt-blackbox-block-container.h:4