00001
00002
00003
00004
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
00020
00021
00022
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
00050
00051
00052
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
00064 if(C_Matrix==NULL){
00065 if((A_left==B_left) && (A_right==B_right))
00066 same = true;
00067 }else{
00068
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
00087
00088
00089
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 }}