blas_compatibile.cc

00001 /***************************************************************************
00002  *  PSIMRCC : Copyright (C) 2007 by Francesco Evangelista and Andrew Simmonett
00003  *  frank@ccc.uga.edu   andysim@ccc.uga.edu
00004  *  A multireference coupled cluster code
00005  ***************************************************************************/
00006 
00007 #include "blas.h"
00008 #include "utilities.h"
00009 
00010 extern FILE *infile, *outfile;
00011 
00012 namespace psi{ namespace psimrcc{
00013 
00014 using namespace std;
00015 
00016 bool CCOperation::compatible_dot()
00017 {
00018   //
00019   //  Here we are doing the following check:
00020   //            --------------
00021   //           |              |
00022   //   A = B[B_l][B_r] . C[C_l][C_r]
00023   //               |               |
00024   //                ---------------
00025   //
00026   bool same = false;
00027 
00028   int A_left   = A_Matrix->get_left()->get_ntuples();
00029   int A_right  = A_Matrix->get_right()->get_ntuples();
00030   int B_left   = B_Matrix->get_left()->get_ntuples();
00031   int B_right  = B_Matrix->get_right()->get_ntuples();
00032   int C_left   = C_Matrix->get_left()->get_ntuples();
00033   int C_right  = C_Matrix->get_right()->get_ntuples();
00034 
00035   if((A_left==1) && (B_left==C_left) && (A_right==1) && (B_right==C_right))
00036     same = true;
00037   if(!same){
00038     fprintf(outfile,"\n\nSolve couldn't perform the operation ");
00039     print_operation();
00040     fflush(outfile);
00041     exit(1);
00042   }
00043   return(same);
00044 }
00045 
00046 bool CCOperation::compatible_element_by_element()
00047 {
00048   //
00049   //  Here we are doing the following check:
00050   //            ---------------------------
00051   //           |             |             |
00052   //   A[A_l][A_r] = B[B_l][B_r] / C[C_l][C_r]
00053   //      |             |             |
00054   //       ---------------------------
00055   //
00056   bool same = false;
00057 
00058   int A_left   = A_Matrix->get_left()->get_ntuples();
00059   int A_right  = A_Matrix->get_right()->get_ntuples();
00060   int B_left   = B_Matrix->get_left()->get_ntuples();
00061   int B_right  = B_Matrix->get_right()->get_ntuples();
00062 
00063   // First case: We are comparing A and B
00064   if(C_Matrix==NULL){
00065     if((A_left==B_left) && (A_right==B_right))
00066       same = true;
00067   }else{
00068   // Second case: We are comparing A, B, and C
00069     int C_left   = C_Matrix->get_left()->get_ntuples();
00070     int C_right  = C_Matrix->get_right()->get_ntuples();
00071     if((A_left==B_left) && (B_left==C_left) && (A_right==B_right) && (B_right==C_right))
00072       same = true;
00073     if((B_left!=C_left) || (B_right!=C_right)){
00074       fprintf(outfile,"\n\nSolve couldn't perform the operation ");
00075       print_operation();
00076       fflush(outfile);
00077       exit(1);
00078     }
00079   }
00080   return(same);
00081 }
00082 
00083 bool CCOperation::compatible_contract()
00084 {
00085   //
00086   //  Here we are doing the following check:
00087   //            -----------------------------
00088   //           |                             |
00089   //   A[A_l][A_r] = B[B_i][B_c] 2@1 C[C_c][C_i]
00090   //      |             |    |          |
00091   //       -------------      ----------
00092   //
00093   bool same = false;
00094 
00095   int A_left   = A_Matrix->get_left()->get_ntuples();
00096   int A_right  = A_Matrix->get_right()->get_ntuples();
00097   int B_contracted;
00098   int B_index;
00099   int C_contracted;
00100   int C_index;
00101 
00102   if(operation[0]=='1'){
00103     B_contracted   = B_Matrix->get_left()->get_ntuples();
00104     B_index        = B_Matrix->get_right()->get_ntuples();
00105   } else{
00106     B_contracted   = B_Matrix->get_right()->get_ntuples();
00107     B_index        = B_Matrix->get_left()->get_ntuples();
00108   }
00109   if(operation[2]=='1'){
00110     C_contracted   = C_Matrix->get_left()->get_ntuples();
00111     C_index        = C_Matrix->get_right()->get_ntuples();
00112   } else{
00113     C_contracted   = C_Matrix->get_right()->get_ntuples();
00114     C_index        = C_Matrix->get_left()->get_ntuples();
00115   }
00116 
00117   if((B_contracted==C_contracted) && (A_left==B_index) && (A_right==C_index))
00118     same = true;
00119   if(B_contracted!=C_contracted){
00120     fprintf(outfile,"\n\nSolve couldn't perform the operation ");
00121     print_operation();
00122     fflush(outfile);
00123     exit(1);
00124   }
00125   return(same);
00126 }
00127 
00128 }} /* End Namespaces */

Generated on Wed Feb 13 16:35:39 2008 for PSI by  doxygen 1.5.4