blas_resorting.cc

00001 #if 0
00002 /***************************************************************************
00003  *   Copyright (C) 2007 by Francesco Evangelista and Andrew Simmonett
00004  *   frank@ccc.uga.edu
00005  *   SR/MRCC Code
00006  ***************************************************************************/
00007 
00008 #include "moinfo.h"
00009 #include "error.h"
00010 #include "blas.h"
00011 #include "utilities.h"
00012 #include <pthread.h>
00013 
00014 namespace psi{ namespace psimrcc{
00015 
00016 
00017 using namespace std;
00018 
00019 extern FILE *infile, *outfile;
00020 
00021 
00022 
00023 void CCBLAS::Operation::reindex(double constant)
00024 {
00025   double*** A_matrix = A_Matrix->get_matrix();
00026   double*** B_matrix = B_Matrix->get_matrix();
00027 
00028   // TBM : make this more general
00029   // Determine wether any of the indices needs to be expanded
00030   // Example A[vv][vv] <- B[vv][v>v]
00031   bool expand_left  = false;
00032   bool expand_right = false;
00033   if(B_Matrix->get_left()->get_greater_than() && (!A_Matrix->get_left()->get_greater_than()))
00034     expand_left = true;
00035   if(B_Matrix->get_right()->get_greater_than() && (!A_Matrix->get_right()->get_greater_than()))
00036     expand_right = true;
00037 
00038   if(reindexing.size()==2){
00039     // Setup reindexing_array
00040     // This assumes that the reindexing starts from 1 !!! This can cost you an headache
00041     short* reindexing_array = new short[2];
00042     if(reindexing.size()==0)
00043       reindexing="12";
00044     for(int i = 0; i< reindexing.size(); i++)
00045       reindexing_array[i]=(int)ToDouble(reindexing.substr(i,1))-1;
00046 
00047     if((!expand_left) && (!expand_right)){
00048       // Do not expand
00049       short* pq   = new short[2];
00050       for(int n=0;n<moinfo->get_nirreps();n++){
00051         for(int i = 0;i<A_Matrix->get_left_pairpi(n);i++){
00052           for(int j = 0;j<A_Matrix->get_right_pairpi(n);j++){
00053             // Get the pq indices  [v][o],[vo] - > v, o
00054             A_Matrix->get_two_indices(pq,n,i,j);
00055             A_matrix[n][i][j]+=constant*B_Matrix->get_two_address_element(pq[reindexing_array[0]],pq[reindexing_array[1]]);
00056           }
00057         }
00058       }
00059       delete[] pq;
00060     }else{
00061       print_developing("Reindexing algorithm with 2-index expansion",__FILE__,__LINE__);
00062     }
00063   }else{
00064     /* ==== Use the PThreads library to parallelize the 4-index resorting ==== */
00065     if(reindexing.size()==0)
00066       reindexing="1234";
00067     data = new data_t[moinfo->get_num_threads()];
00068     for(int i=0; i<moinfo->get_num_threads(); i++){
00069       data[i].num_threads     = moinfo->get_num_threads();
00070       data[i].A_Matrix        = A_Matrix;
00071       data[i].B_Matrix        = B_Matrix;
00072       data[i].constant        = constant;
00073       data[i].num_indices     = reindexing.size();
00074       data[i].reindexing_array = new short[reindexing.size()];
00075       for(int j = 0; j< reindexing.size(); j++)
00076         data[i].reindexing_array[j]=(int)ToDouble(reindexing.substr(j,1))-1;
00077         // This assumes that the reindexing starts from 1 !!! This can cost you an headache
00078     }
00079 
00080     // Allocate memory for the threads
00081     pthread_t *thread_id = new pthread_t[moinfo->get_num_threads()];
00082     // Now we create data arrays and start the threads
00083     for(int i=0;i<moinfo->get_num_threads();i++){
00084       if(!expand_left && !expand_right)
00085         pthread_create(&(thread_id[i]),NULL,reindex_thread,(void*)i);
00086       else if(!expand_left && expand_right)
00087         pthread_create(&(thread_id[i]),NULL,reindex_thread_right_expand,(void*)i);
00088       else if(expand_left){
00089         print_developing("Reindexing algorithm with 4-index left expansion",__FILE__,__LINE__);
00090       }
00091     }
00092 
00093     // Now we wait for all threads to finish before exiting
00094     for(int i=0;i<moinfo->get_num_threads();i++){
00095       pthread_join(thread_id[i],NULL);
00096       delete[] data[i].reindexing_array;
00097     }
00098     delete[] data;
00099     delete[] thread_id;
00100   }
00101 }
00102 
00103 void *CCBLAS::Operation::reindex_thread(void * my_id)
00104 {
00105   int thread_id           = (int) my_id;
00106   short *reindexing_array = data[thread_id].reindexing_array;
00107   CCMatrix* A_Matrix       = data[thread_id].A_Matrix;
00108   CCMatrix* B_Matrix       = data[thread_id].B_Matrix;
00109   double constant         = data[thread_id].constant;
00110   int n_threads           = data[thread_id].num_threads;
00111   int num_indices         = data[thread_id].num_indices;
00112 
00113   CCIndex* A_left   = A_Matrix->get_left();
00114   CCIndex* A_right  = A_Matrix->get_right();
00115   CCIndex* B_left   = B_Matrix->get_left();
00116   CCIndex* B_right  = B_Matrix->get_right();
00117   double*** A_matrix= A_Matrix->get_matrix();
00118   double*** B_matrix= B_Matrix->get_matrix();
00119 
00120   int A_left_nelements = A_left->get_nelements();
00121   int B_left_nelements = B_left->get_nelements();
00122 
00123   int*    A_left_pairpi   = A_left->get_pairpi_thread(thread_id);
00124   int*    A_right_pairpi  = A_right->get_pairpi_thread(thread_id);
00125   int*    A_left_first    = A_left->get_first_thread(thread_id);
00126   int*    A_right_first   = A_right->get_first_thread(thread_id);
00127   short** A_left_tuples   = A_left->get_tuples_thread(thread_id);
00128   short** A_right_tuples  = A_right->get_tuples_thread(thread_id);
00129 
00130   int*    B_left_first    = B_left->get_first_thread(thread_id);
00131   int*    B_right_first   = B_right->get_first_thread(thread_id);
00132 
00133   int b_irrep,b_left,b_right;
00134   if(num_indices==4){
00135     short* pqrs = new short[4];
00136     // A[x][xxx] <- B[x][xxx]
00137     if((A_left_nelements == 1) && (B_left_nelements == 1)){
00138       int*    B_left_one_index_to_irrep    = B_left->get_one_index_to_irrep_thread(thread_id);
00139       int*    B_left_one_index_to_tuple    = B_left->get_one_index_to_tuple_thread(thread_id);
00140       int***  B_right_three_index_to_tuple = B_right->get_three_index_to_tuple_thread(thread_id);
00141       for(int n=0;n<moinfo->get_nirreps();n++){
00142         for(int i = 0;i<A_left_pairpi[n];i++){
00143           //Check that this should be handled by this thread
00144           pqrs[0]=A_left_tuples[i+A_left_first[n]][0];
00145           if (thread_id == i%n_threads)
00146             for(int j = 0;j<A_right_pairpi[n];j++){
00147               // Get the pqrs indices
00148               pqrs[1]=A_right_tuples[j+A_right_first[n]][0];
00149               pqrs[2]=A_right_tuples[j+A_right_first[n]][1];
00150               pqrs[3]=A_right_tuples[j+A_right_first[n]][2];
00151               b_irrep = B_left_one_index_to_irrep[pqrs[reindexing_array[0]]];
00152               b_left  = B_left_one_index_to_tuple[pqrs[reindexing_array[0]]];
00153               b_right = B_right_three_index_to_tuple[pqrs[reindexing_array[1]]]
00154                                                     [pqrs[reindexing_array[2]]]
00155                                                     [pqrs[reindexing_array[3]]];
00156               A_matrix[n][i][j]+=constant*B_matrix[b_irrep][b_left][b_right];
00157             }
00158         }
00159       }
00160     }
00161 
00162     // A[xx][xx] <- B[x][xxx]
00163     if((A_left_nelements == 2) && (B_left_nelements == 1)){
00164       int*    B_left_one_index_to_irrep    = B_left->get_one_index_to_irrep_thread(thread_id);
00165       int*    B_left_one_index_to_tuple    = B_left->get_one_index_to_tuple_thread(thread_id);
00166       int***  B_right_three_index_to_tuple = B_right->get_three_index_to_tuple_thread(thread_id);
00167       for(int n=0;n<moinfo->get_nirreps();n++){
00168         for(int i = 0;i<A_left_pairpi[n];i++){
00169           //Check that this should be handled by this thread
00170           pqrs[0]=A_left_tuples[i+A_left_first[n]][0];
00171           pqrs[1]=A_left_tuples[i+A_left_first[n]][1];
00172           if (thread_id == i%n_threads)
00173             for(int j = 0;j<A_right_pairpi[n];j++){
00174               // Get the pqrs indices
00175               pqrs[2]=A_right_tuples[j+A_right_first[n]][0];
00176               pqrs[3]=A_right_tuples[j+A_right_first[n]][1];
00177               b_irrep = B_left_one_index_to_irrep[pqrs[reindexing_array[0]]];
00178               b_left  = B_left_one_index_to_tuple[pqrs[reindexing_array[0]]];
00179               b_right = B_right_three_index_to_tuple[pqrs[reindexing_array[1]]]
00180                                                     [pqrs[reindexing_array[2]]]
00181                                                     [pqrs[reindexing_array[3]]];
00182               A_matrix[n][i][j]+=constant*B_matrix[b_irrep][b_left][b_right];
00183             }
00184         }
00185       }
00186     }
00187 
00188     // A[xxx][x] <- B[x][xxx]
00189     if((A_left_nelements == 3) && (B_left_nelements == 1)){
00190       int*    B_left_one_index_to_irrep    = B_left->get_one_index_to_irrep_thread(thread_id);
00191       int*    B_left_one_index_to_tuple    = B_left->get_one_index_to_tuple_thread(thread_id);
00192       int***  B_right_three_index_to_tuple = B_right->get_three_index_to_tuple_thread(thread_id);
00193       for(int n=0;n<moinfo->get_nirreps();n++){
00194         for(int i = 0;i<A_left_pairpi[n];i++){
00195           //Check that this should be handled by this thread
00196           pqrs[0]=A_left_tuples[i+A_left_first[n]][0];
00197           pqrs[1]=A_left_tuples[i+A_left_first[n]][1];
00198           pqrs[2]=A_left_tuples[i+A_left_first[n]][2];
00199           if (thread_id == i%n_threads)
00200             for(int j = 0;j<A_right_pairpi[n];j++){
00201               // Get the pqrs indices
00202               pqrs[3]=A_right_tuples[j+A_right_first[n]][0];
00203               b_irrep = B_left_one_index_to_irrep[pqrs[reindexing_array[0]]];
00204               b_left  = B_left_one_index_to_tuple[pqrs[reindexing_array[0]]];
00205               b_right = B_right_three_index_to_tuple[pqrs[reindexing_array[1]]]
00206                                                     [pqrs[reindexing_array[2]]]
00207                                                     [pqrs[reindexing_array[3]]];
00208               A_matrix[n][i][j]+=constant*B_matrix[b_irrep][b_left][b_right];
00209             }
00210         }
00211       }
00212     }
00213 
00214     // A[x][xxx] <- B[xx][xx]
00215     if((A_left_nelements == 1) && (B_left_nelements == 2)){
00216       int** B_left_two_index_to_irrep    = B_left->get_two_index_to_irrep_thread(thread_id);
00217       int** B_left_two_index_to_tuple    = B_left->get_two_index_to_tuple_thread(thread_id);
00218       int** B_right_two_index_to_tuple   = B_right->get_two_index_to_tuple_thread(thread_id);
00219       for(int n=0;n<moinfo->get_nirreps();n++){
00220         for(int i = 0;i<A_left_pairpi[n];i++){
00221           //Check that this should be handled by this thread
00222           pqrs[0]=A_left_tuples[i+A_left_first[n]][0];
00223           if (thread_id == i%n_threads)
00224             for(int j = 0;j<A_right_pairpi[n];j++){
00225               // Get the pqrs indices
00226               pqrs[1]=A_right_tuples[j+A_right_first[n]][0];
00227               pqrs[2]=A_right_tuples[j+A_right_first[n]][1];
00228               pqrs[3]=A_right_tuples[j+A_right_first[n]][2];
00229               b_irrep = B_left_two_index_to_irrep[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00230               b_left  = B_left_two_index_to_tuple[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00231               b_right = B_right_two_index_to_tuple[pqrs[reindexing_array[2]]][pqrs[reindexing_array[3]]];
00232               A_matrix[n][i][j]+=constant*B_matrix[b_irrep][b_left][b_right];
00233             }
00234         }
00235       }
00236     }
00237 
00238     // A[xx][xx] <- B[xx][xx]
00239     if((A_left_nelements == 2) && (B_left_nelements == 2)){
00240       int** B_left_two_index_to_irrep    = B_left->get_two_index_to_irrep_thread(thread_id);
00241       int** B_left_two_index_to_tuple    = B_left->get_two_index_to_tuple_thread(thread_id);
00242       int** B_right_two_index_to_tuple   = B_right->get_two_index_to_tuple_thread(thread_id);
00243       for(int n=0;n<moinfo->get_nirreps();n++){
00244         for(int i = 0;i<A_left_pairpi[n];i++){
00245           //Check that this should be handled by this thread
00246           pqrs[0]=A_left_tuples[i+A_left_first[n]][0];
00247           pqrs[1]=A_left_tuples[i+A_left_first[n]][1];
00248           if (thread_id == i%n_threads)
00249             for(int j = 0;j<A_right_pairpi[n];j++){
00250               // Get the pqrs indices
00251               pqrs[2]=A_right_tuples[j+A_right_first[n]][0];
00252               pqrs[3]=A_right_tuples[j+A_right_first[n]][1];
00253               b_irrep = B_left_two_index_to_irrep[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00254               b_left  = B_left_two_index_to_tuple[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00255               b_right = B_right_two_index_to_tuple[pqrs[reindexing_array[2]]][pqrs[reindexing_array[3]]];
00256               A_matrix[n][i][j]+=constant*B_matrix[b_irrep][b_left][b_right];
00257             }
00258         }
00259       }
00260     }
00261 
00262     // A[xxx][x] <- B[xx][xx]
00263     if((A_left_nelements == 3) && (B_left_nelements == 2)){
00264       int** B_left_two_index_to_irrep    = B_left->get_two_index_to_irrep_thread(thread_id);
00265       int** B_left_two_index_to_tuple    = B_left->get_two_index_to_tuple_thread(thread_id);
00266       int** B_right_two_index_to_tuple   = B_right->get_two_index_to_tuple_thread(thread_id);
00267       for(int n=0;n<moinfo->get_nirreps();n++){
00268         for(int i = 0;i<A_left_pairpi[n];i++){
00269           //Check that this should be handled by this thread
00270           pqrs[0]=A_left_tuples[i+A_left_first[n]][0];
00271           pqrs[1]=A_left_tuples[i+A_left_first[n]][1];
00272           pqrs[2]=A_left_tuples[i+A_left_first[n]][2];
00273           if (thread_id == i%n_threads)
00274             for(int j = 0;j<A_right_pairpi[n];j++){
00275               // Get the pqrs indices
00276               pqrs[3]=A_right_tuples[j+A_right_first[n]][0];
00277               b_irrep = B_left_two_index_to_irrep[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00278               b_left  = B_left_two_index_to_tuple[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00279               b_right = B_right_two_index_to_tuple[pqrs[reindexing_array[2]]][pqrs[reindexing_array[3]]];
00280               A_matrix[n][i][j]+=constant*B_matrix[b_irrep][b_left][b_right];
00281             }
00282         }
00283       }
00284     }
00285 
00286     // A[x][xxx] <- B[xxx][x]
00287     if((A_left_nelements == 1) && (B_left_nelements == 3)){
00288       int*** B_left_three_index_to_tuple  = B_left->get_three_index_to_tuple_thread(thread_id);
00289       int*   B_right_one_index_to_irrep   = B_right->get_one_index_to_irrep_thread(thread_id);
00290       int*   B_right_one_index_to_tuple   = B_right->get_one_index_to_tuple_thread(thread_id);
00291       for(int n=0;n<moinfo->get_nirreps();n++){
00292         for(int i = 0;i<A_left_pairpi[n];i++){
00293           //Check that this should be handled by this thread
00294           pqrs[0]=A_left_tuples[i+A_left_first[n]][0];
00295           if (thread_id == i%n_threads)
00296             for(int j = 0;j<A_right_pairpi[n];j++){
00297               // Get the pqrs indices
00298               pqrs[1]=A_right_tuples[j+A_right_first[n]][0];
00299               pqrs[2]=A_right_tuples[j+A_right_first[n]][1];
00300               pqrs[3]=A_right_tuples[j+A_right_first[n]][2];
00301               b_irrep = B_right_one_index_to_irrep[pqrs[reindexing_array[3]]];
00302               b_left  = B_left_three_index_to_tuple[pqrs[reindexing_array[0]]]
00303                                                    [pqrs[reindexing_array[1]]]
00304                                                    [pqrs[reindexing_array[2]]];
00305               b_right = B_right_one_index_to_tuple[pqrs[reindexing_array[3]]];
00306               A_matrix[n][i][j]+=constant*B_matrix[b_irrep][b_left][b_right];
00307             }
00308         }
00309       }
00310     }
00311 
00312     // A[xx][xx] <- B[xxx][x]
00313     if((A_left_nelements == 2) && (B_left_nelements == 3)){
00314       int*** B_left_three_index_to_tuple  = B_left->get_three_index_to_tuple_thread(thread_id);
00315       int*   B_right_one_index_to_irrep   = B_right->get_one_index_to_irrep_thread(thread_id);
00316       int*   B_right_one_index_to_tuple   = B_right->get_one_index_to_tuple_thread(thread_id);
00317       for(int n=0;n<moinfo->get_nirreps();n++){
00318         for(int i = 0;i<A_left_pairpi[n];i++){
00319           //Check that this should be handled by this thread
00320           pqrs[0]=A_left_tuples[i+A_left_first[n]][0];
00321           pqrs[1]=A_left_tuples[i+A_left_first[n]][1];
00322           if (thread_id == i%n_threads)
00323             for(int j = 0;j<A_right_pairpi[n];j++){
00324               // Get the pqrs indices
00325               pqrs[2]=A_right_tuples[j+A_right_first[n]][0];
00326               pqrs[3]=A_right_tuples[j+A_right_first[n]][1];
00327               b_irrep = B_right_one_index_to_irrep[pqrs[reindexing_array[3]]];
00328               b_left  = B_left_three_index_to_tuple[pqrs[reindexing_array[0]]]
00329                                                    [pqrs[reindexing_array[1]]]
00330                                                    [pqrs[reindexing_array[2]]];
00331               b_right = B_right_one_index_to_tuple[pqrs[reindexing_array[3]]];
00332               A_matrix[n][i][j]+=constant*B_matrix[b_irrep][b_left][b_right];
00333             }
00334         }
00335       }
00336     }
00337 
00338     // A[xxx][x] <- B[xxx][x]
00339     if((A_left_nelements == 3) && (B_left_nelements == 3)){
00340       int*** B_left_three_index_to_tuple  = B_left->get_three_index_to_tuple_thread(thread_id);
00341       int*   B_right_one_index_to_irrep   = B_right->get_one_index_to_irrep_thread(thread_id);
00342       int*   B_right_one_index_to_tuple   = B_right->get_one_index_to_tuple_thread(thread_id);
00343       for(int n=0;n<moinfo->get_nirreps();n++){
00344         for(int i = 0;i<A_left_pairpi[n];i++){
00345           //Check that this should be handled by this thread
00346           pqrs[0]=A_left_tuples[i+A_left_first[n]][0];
00347           pqrs[1]=A_left_tuples[i+A_left_first[n]][1];
00348           pqrs[2]=A_left_tuples[i+A_left_first[n]][2];
00349           if (thread_id == i%n_threads)
00350             for(int j = 0;j<A_right_pairpi[n];j++){
00351               // Get the pqrs indices
00352               pqrs[3]=A_right_tuples[j+A_right_first[n]][0];
00353               b_irrep = B_right_one_index_to_irrep[pqrs[reindexing_array[3]]];
00354               b_left  = B_left_three_index_to_tuple[pqrs[reindexing_array[0]]]
00355                                                    [pqrs[reindexing_array[1]]]
00356                                                    [pqrs[reindexing_array[2]]];
00357               b_right = B_right_one_index_to_tuple[pqrs[reindexing_array[3]]];
00358               A_matrix[n][i][j]+=constant*B_matrix[b_irrep][b_left][b_right];
00359             }
00360         }
00361       }
00362     }
00363 
00364     delete[] pqrs;
00365   }
00366   return NULL;
00367 }
00368 
00369 
00370 
00371 void *CCBLAS::Operation::reindex_thread_right_expand(void * my_id)
00372 {
00373   int thread_id           = (int) my_id;
00374   short *reindexing_array = data[thread_id].reindexing_array;
00375   CCMatrix* A_Matrix      = data[thread_id].A_Matrix;
00376   CCMatrix* B_Matrix      = data[thread_id].B_Matrix;
00377   double constant         = data[thread_id].constant;
00378   int n_threads           = data[thread_id].num_threads;
00379   int num_indices         = data[thread_id].num_indices;
00380 
00381   CCIndex* A_left   = A_Matrix->get_left();
00382   CCIndex* A_right  = A_Matrix->get_right();
00383   CCIndex* B_left   = B_Matrix->get_left();
00384   CCIndex* B_right  = B_Matrix->get_right();
00385   double*** A_matrix= A_Matrix->get_matrix();
00386   double*** B_matrix= B_Matrix->get_matrix();
00387 
00388   int A_left_nelements = A_left->get_nelements();
00389   int B_left_nelements = B_left->get_nelements();
00390 
00391 
00392   // Matrix A data
00393   int*    A_left_first    = A_left->get_first_thread(thread_id);
00394   int*    A_right_first   = A_right->get_first_thread(thread_id);
00395 
00396   // Matrix B data
00397   int*    B_left_pairpi   = B_left->get_pairpi_thread(thread_id);
00398   int*    B_right_pairpi  = B_right->get_pairpi_thread(thread_id);
00399   int*    B_left_first    = B_left->get_first_thread(thread_id);
00400   int*    B_right_first   = B_right->get_first_thread(thread_id);
00401   short** B_left_tuples   = B_left->get_tuples_thread(thread_id);
00402   short** B_right_tuples  = B_right->get_tuples_thread(thread_id);
00403 
00404   int     a_irrep,a_left,a_right;
00405   short   swap_temp;
00406   double  sym_constant = constant * B_Matrix->get_symmetry(); 
00407 
00408   if(num_indices==4){
00409     short* pqrs = new short[4];
00410     // A[x][xxx] <- B[x][xxx]
00411     if((A_left_nelements == 1) && (B_left_nelements == 1)){
00412       print_developing("A[x][xxx] <- B[x][xxx] with expansion",__FILE__,__LINE__);
00413     }
00414 
00415     // A[xx][xx] <- B[x][xxx]
00416     if((A_left_nelements == 2) && (B_left_nelements == 1)){
00417       print_developing("A[xx][xx] <- B[x][xxx] with expansion",__FILE__,__LINE__);
00418     }
00419 
00420     // A[xxx][x] <- B[x][xxx]
00421     if((A_left_nelements == 3) && (B_left_nelements == 1)){
00422       print_developing("A[xxx][x] <- B[x][xxx] with expansion",__FILE__,__LINE__);
00423     }
00424 
00425     // A[x][xxx] <- B[xx][xx]
00426     if((A_left_nelements == 1) && (B_left_nelements == 2)){
00427       print_developing("A[x][xxx] <- B[xx][xx] with expansion",__FILE__,__LINE__);
00428     }
00429 
00430     // A[xx][xx] <- B[xx][xx]
00431     if((A_left_nelements == 2) && (B_left_nelements == 2)){
00432       int** A_left_two_index_to_irrep    = A_left->get_two_index_to_irrep_thread(thread_id);
00433       int** A_left_two_index_to_tuple    = A_left->get_two_index_to_tuple_thread(thread_id);
00434       int** A_right_two_index_to_tuple   = A_right->get_two_index_to_tuple_thread(thread_id);
00435       for(int n=0;n<moinfo->get_nirreps();n++){
00436         for(int i = 0;i<B_left_pairpi[n];i++){
00437           //Check that this should be handled by this thread
00438           pqrs[0]=B_left_tuples[i+B_left_first[n]][0];
00439           pqrs[1]=B_left_tuples[i+B_left_first[n]][1];
00440           if (thread_id == i%n_threads)
00441             for(int j = 0;j<B_right_pairpi[n];j++){
00442               // Get the pqrs indices
00443               pqrs[2]=B_right_tuples[j+B_right_first[n]][0];
00444               pqrs[3]=B_right_tuples[j+B_right_first[n]][1];
00445               a_irrep = A_left_two_index_to_irrep[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00446               a_left  = A_left_two_index_to_tuple[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00447               a_right = A_right_two_index_to_tuple[pqrs[reindexing_array[2]]][pqrs[reindexing_array[3]]];
00448               A_matrix[a_irrep][a_left][a_right]+=constant*B_matrix[n][i][j];
00449               // Add the expandend term with the correct symmetry
00450               swap_temp =pqrs[2];
00451               pqrs[2] = pqrs[3];
00452               pqrs[3] = swap_temp;
00453               a_irrep = A_left_two_index_to_irrep[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00454               a_left  = A_left_two_index_to_tuple[pqrs[reindexing_array[0]]][pqrs[reindexing_array[1]]];
00455               a_right = A_right_two_index_to_tuple[pqrs[reindexing_array[2]]][pqrs[reindexing_array[3]]];
00456               A_matrix[a_irrep][a_left][a_right]+=sym_constant*B_matrix[n][i][j];
00457             }
00458         }
00459       }
00460     }
00461 
00462     // A[xxx][x] <- B[xx][xx]
00463     if((A_left_nelements == 3) && (B_left_nelements == 2)){
00464       print_developing("A[xxx][x] <- B[xx][xx] with expansion",__FILE__,__LINE__);
00465     }
00466 
00467     // A[x][xxx] <- B[xxx][x]
00468     if((A_left_nelements == 1) && (B_left_nelements == 3)){
00469       print_developing("A[x][xxx] <- B[xxx][x] with expansion",__FILE__,__LINE__);
00470     }
00471 
00472     // A[xx][xx] <- B[xxx][x]
00473     if((A_left_nelements == 2) && (B_left_nelements == 3)){
00474       print_developing("A[xx][xx] <- B[xxx][x] with expansion",__FILE__,__LINE__);
00475     }
00476 
00477     // A[xxx][x] <- B[xxx][x]
00478     if((A_left_nelements == 3) && (B_left_nelements == 3)){
00479       print_developing("A[xxx][x] <- B[xxx][x] with expansion",__FILE__,__LINE__);
00480     }
00481 
00482     delete[] pqrs;
00483   }
00484   return NULL;
00485 }
00486 
00487 }} /* End Namespaces */
00488 
00489 #endif

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