65 K
get(
int,
int )
const;
66 void set(
int,
int,
const K& );
74 int rank(
void )
const;
75 int solve( K**,
int* );
80 K
add_rows(
int,
int,
const K&,
const K& );
110 if( a != (K*)
NULL && rows > 0 && cols > 0 )
delete [] a;
129 #ifdef KMATRIX_IOSTREAM
130 cerr <<
"void KMatrix::copy_new( int k )";
131 cerr <<
": no memory left ..." << endl;
149 #ifdef KMATRIX_IOSTREAM
150 cerr <<
"void KMatrix::copy_new( int k )";
151 cerr <<
": k < 0 ..." << endl;
184 for( r=0; r<n; a[r++]=(K)0 );
186 for( r=0; r<rows; r++ )
211 if(
m.a == (K*)
NULL )
222 for(
int i=0;
i<n;
i++ )
263 for(
int i=0;
i<n;
i++ )
295 #ifdef KMATRIX_IOSTREAM
296 cerr <<
"KMatrix<K>::test_row( " << r <<
" )" << endl;
297 cerr <<
" rows = " << rows << endl;
298 cerr <<
" exiting...." << endl;
316 #ifdef KMATRIX_IOSTREAM
317 cerr <<
"KMatrix<K>::test_col( " << c <<
" )" << endl;
318 cerr <<
" cols = " << cols << endl;
319 cerr <<
" exiting...." << endl;
379 if(
r1 ==
r2 )
return 1;
383 for(
int c=0; c<cols; c++ )
386 a[
r1*cols+c] = a[
r2*cols+c];
432 int i_src = src*cols;
456 for(
int c=0; c<cols; c++ )
458 if( a[r*cols+c] != (K)0 )
return FALSE;
476 for(
int r=0; r<rows; r++ )
478 if( a[r*cols+c] != (K)0 )
return FALSE;
500 for( r=
r0; r<rows && a[r*cols+c]==(K)0; r++ );
510 double val = a[r*cols+c].complexity( );
516 if( a[r*cols+c] != (K)0 &&
517 (
val_new = a[r*cols+c].complexity( ) ) < val )
538 K
g =
gcd( &(a[r*cols]),cols );
540 for(
int c=0; c<cols; c++ )
561 for( r=0; r<rows; r++ )
563 set_row_primitive( r );
569 for( c=0; c<cols && rank<rows; c++ )
571 if( ( r = column_pivot( rank,c )) >= 0 )
575 for( r=rank+1; r<rows; r++ )
577 if( a[r*cols+c] != (K)0 )
579 g =
gcd( a[r*cols+c],a[rank*cols+c] );
580 add_rows( rank,r,-a[r*cols+c]/
g,a[rank*cols+c]/
g );
581 set_row_primitive( r );
609 for( r=0; r<rows; r++ )
611 set_row_primitive( r );
619 for( c=0; c<cols && rank < rows; c++ )
621 if( ( r = column_pivot( rank,c )) >= 0 )
625 for( r=0; r<rank; r++ )
627 if( a[r*cols+c] != (K)0 )
629 g =
gcd( a[r*cols+c],a[rank*cols+c] );
630 add_rows( rank,r,-a[r*cols+c]/
g,a[rank*cols+c]/
g );
631 set_row_primitive( r );
635 for( r=rank+1; r<rows; r++ )
637 if( a[r*cols+c] != (K)0 )
639 g =
gcd( a[r*cols+c],a[rank*cols+c] );
640 add_rows( rank,r,-a[r*cols+c]/
g,a[rank*cols+c]/
g );
641 set_row_primitive( r );
659 for( c=0; c<cols-1; c++ )
661 (*solution)[c] = (K)0;
664 for( r=0; r<rows; r++ )
666 for( c=0; c<cols && a[r*cols+c] == (K)0; c++ );
670 (*solution)[c] = ((K)a[(r+1)*cols-1])/a[r*cols+c];
697 return dummy.gausseliminate( );
713 for(
unsigned int i=0;
i <
num;
i++ )
715 #ifdef KMATRIX_IOSTREAM
730 for(
i=0;
i<
m.rows*
m.cols;
i++ )
737 for( r=0; r<
m.rows; r++ )
741 #ifdef KMATRIX_IOSTREAM
749 #ifdef KMATRIX_IOSTREAM
755 else if( r ==
m.rows - 1 )
757 #ifdef KMATRIX_IOSTREAM
765 #ifdef KMATRIX_IOSTREAM
772 for( c=0; c<
m.cols; c++ )
774 #ifdef KMATRIX_IOSTREAM
785 #ifdef KMATRIX_IOSTREAM
793 #ifdef KMATRIX_IOSTREAM
799 else if( r ==
m.rows - 1 )
801 #ifdef KMATRIX_IOSTREAM
809 #ifdef KMATRIX_IOSTREAM
840 if( is_quadratic( ) )
844 for( r=1; r<rows; r++ )
848 if( a[r*cols+c] != a[c*cols+r] )
869 if( !is_quadratic( ) )
884 for( r=0; r<
dummy.rows; r++ )
886 det *=
dummy.set_row_primitive( r );
892 for( c=0; c<cols && rank<
dummy.rows; c++ )
894 if( ( r =
dummy.column_pivot( rank,c )) >= 0 )
896 det *=
dummy.swap_rows( rank,r );
898 for( r=rank+1; r<
dummy.rows; r++ )
900 if(
dummy.a[r*cols+c] != (K)0 )
908 det *=
dummy.set_row_primitive( r );
915 if( rank !=
dummy.rows )
920 for( r=0; r<
dummy.rows; r++ )
922 det *=
dummy.a[r*cols+r];
void set(int, int, const K &)
int column_pivot(int, int) const
int is_symmetric(void) const
K multiply_row(int, const K &)
K add_rows(int, int, const K &, const K &)
int column_is_zero(int) const
K determinant(void) const
int row_is_zero(int) const
void copy_shallow(KMatrix &)
int is_quadratic(void) const
void copy_deep(const KMatrix &)
const CanonicalForm int s
void copy_deep(spectrum &spec, lists l)
bool pivot(const matrix aMat, const int r1, const int r2, const int c1, const int c2, int *bestR, int *bestC, const ring R)
This code computes a score for each non-zero matrix entry in aMat[r1..r2, c1..c2].
ostream & operator<<(ostream &s, const spectrum &spec)