pyscf/lib/shciscf/libSHCITools.c
/*
  Sum over m1s rows and m2s columns. The indx variable determines which
  index of m1 is summed over, e.g. 0 is the first index and so on. m1 should
  be the one-body matrix, m2 should be the unitary matrix. This function has
  a temporal cost of O(n^3).
*/
Sum over m1s rows and m2s columns. The indx variable determines which
index of m1 is summed over, e.g. 0 is the first index and so on. m1 should
be the one-body matrix, m2 should be the unitary matrix. This function has
a temporal cost of O(n^3).
Sum over m1s rows and m2s columns . The indx variable determines which index of m1 is summed over e . g . 0 is the first index and so on . m1 should be the one - body matrix m2 should be the unitary matrix . This function has a temporal cost of O ( n^3 ) .
void multMat2D ( size_t n, double * m1, double * m2, double * mout,
		 size_t indx )
{
  size_t i, j, k, ik, kj, ij, ki;
  if ( indx == 1 )
    {
      for ( i = 0; i < n; ++i )
	for ( j = 0; j < n; ++j )
	  {
	    ij = j + i*n;
	    mout[ij] = 0;
	    for ( k = 0; k < n; ++k )
	      {
		ik = k + i*n;
		kj = j + k*n;
		mout[ij] += m1[ik] * m2[kj];
	      }
	  }
    }
  else if ( indx == 0 )
    {
      for ( i = 0; i < n; ++i )
	for ( j = 0; j < n; ++j )
	  {
	    ij = j + i*n;
	    mout[ij] = 0;
	    for ( k = 0; k < n; ++k )
	      {
		ki = i + k * n;
		kj = j + k * n;
		mout[ij] += m1[ki] * m2[kj];
	      }
	  }
    }
}
void multMat2D ( size_t n , double * m1 , double * m2 , double * mout , size_t indx ) { size_t i , j , k , ik , kj , ij , ki ; if ( indx == 1 ) { for ( i = 0 ; i < n ; ++ i ) for ( j = 0 ; j < n ; ++ j ) { ij = j + i * n ; mout [ ij ] = 0 ; for ( k = 0 ; k < n ; ++ k ) { ik = k + i * n ; kj = j + k * n ; mout [ ij ] += m1 [ ik ] * m2 [ kj ] ; } } } else if ( indx == 0 ) { for ( i = 0 ; i < n ; ++ i ) for ( j = 0 ; j < n ; ++ j ) { ij = j + i * n ; mout [ ij ] = 0 ; for ( k = 0 ; k < n ; ++ k ) { ki = i + k * n ; kj = j + k * n ; mout [ ij ] += m1 [ ki ] * m2 [ kj ] ; } } } }
Sum over m1s rows and m2s columns.
Sum over m1s rows and m2s columns .