19 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
20 MPI_Comm_size(MPI_COMM_WORLD, &num_pes);
24 printf(
"n = %d\n", n);
27 int shapeAS4[] = {
AS,
NS,
AS,NS};
31 int shapeTS4[] = {
AS,
NS,
NS,NS};
32 int shapeNS4[] = {
NS,
NS,
NS,NS};
34 int nnnm[] = {n,n,n,m};
35 int mmnn[] = {m,m,n,n};
36 int mmmnnn[] = {m,m,m,n,n,n};
39 Tensor<> AS_A(4, nnnm, shapeTS4, dw,
"AS_A", 1);
40 Tensor<> AS_B(6, mmmnnn, shapeAS6, dw,
"AS_B", 1);
41 Tensor<> HS_B(6, mmmnnn, shapeHS6, dw);
42 Tensor<> AS_C(4, mmnn, shapeAS4, dw,
"AS_C", 1);
43 Tensor<> NS_A(4, nnnm, shapeNS4, dw,
"NS_A", 1);
44 Tensor<> NS_B(6, mmmnnn, shapeTS6, dw,
"NS_B", 1);
45 Tensor<> NS_C(4, mmnn, shapeTS4, dw);
49 printf(
"tensor creation succeed\n");
59 NS_A[
"abij"] = AS_A[
"abij"];
60 NS_B[
"abcijk"] = AS_B[
"abcijk"];
63 NS_C[
"abij"] += AS_C[
"abij"];
67 NS_A[
"abij"] -= AS_A[
"baij"];
68 NS_A[
"abij"] += AS_A[
"abij"];
70 HS_B[
"abcijk"] -= AS_B[
"abcjik"];
71 HS_B[
"abcijk"] -= AS_B[
"abckji"];
72 HS_B[
"abcijk"] -= AS_B[
"abcikj"];
73 HS_B[
"abcijk"] += AS_B[
"abcijk"];
74 HS_B[
"abcijk"] += AS_B[
"abckij"];
75 HS_B[
"abcijk"] += AS_B[
"abcjki"];
77 NS_B[
"ijkabc"] += HS_B[
"ijkabc"];
78 NS_B[
"ikjabc"] -= HS_B[
"ijkabc"];
79 NS_B[
"kjiabc"] -= HS_B[
"ijkabc"];
80 NS_C[
"abij"] += AS_C[
"abij"];
90 AS_C[
"abij"] += 0.5*AS_A[
"mnje"]*AS_B[
"abeimn"];
92 NS_C[
"abij"] += 0.5*NS_A[
"mnje"]*NS_B[
"abeimn"];
94 NS_C[
"abji"] -= 0.5*NS_A[
"mnje"]*NS_B[
"abeimn"];
96 double nrm_AS, nrm_NS;
102 nrm_AS = sqrt((
double)(AS_C[
"ijkl"]*AS_C[
"ijkl"]));
103 nrm_NS = sqrt((
double)(NS_C[
"ijkl"]*NS_C[
"ijkl"]));
105 if (rank == 0) printf(
"triangular norm of AS_C = %lf NS_C = %lf\n", nrm_AS, nrm_NS);
107 double cnrm_AS = AS_C.norm2();
108 double cnrm_NS = NS_C.norm2();
109 if (fabs(nrm_AS-cnrm_AS) >= 1.E-6) {
110 printf(
"ERROR: AS norm not working!\n");
113 if (fabs(nrm_NS-cnrm_NS) >= 1.E-6) {
114 printf(
"ERROR: NS norm not working!\n");
118 if (rank == 0) printf(
"norm of AS_C = %lf NS_C = %lf\n", nrm_AS, nrm_NS);
120 NS_C[
"abij"] -= AS_C[
"abij"];
122 NS_C[
"abij"] += AS_C[
"abji"];
127 double nrm = NS_C.norm2();
130 printf(
"norm of NS_C after contraction should be zero, is = %lf\n", nrm);
133 if (fabs(nrm) > 1.E-6) pass = 0;
136 MPI_Reduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
138 printf(
"{ AS_C[\"abij\"] += 0.5*AS_A[\"mnje\"]*AS_B[\"abeimn\"] } passed\n");
140 printf(
"{ AS_C[\"abij\"] += 0.5*AS_A[\"mnje\"]*AS_B[\"abeimn\"] } failed\n");
142 MPI_Reduce(&pass, MPI_IN_PLACE, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
152 char ** itr = std::find(begin, end, option);
153 if (itr != end && ++itr != end){
160 int main(
int argc,
char ** argv){
161 int rank,
np, niter, n, m;
163 char ** input_str = argv;
165 MPI_Init(&argc, &argv);
166 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
167 MPI_Comm_size(MPI_COMM_WORLD, &np);
170 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
174 m = atoi(
getCmdOption(input_str, input_str+in_num,
"-m"));
178 if (
getCmdOption(input_str, input_str+in_num,
"-niter")){
179 niter = atoi(
getCmdOption(input_str, input_str+in_num,
"-niter"));
180 if (niter < 0) niter = 3;
186 World dw(argc, argv);
char * getCmdOption(char **begin, char **end, const std::string &option)
an instance of the CTF library (world) on a MPI communicator
void fill_random(dtype rmin, dtype rmax)
fills local unique tensor elements to random values in the range [min,max] works only for dtype in {f...
int ccsdt_t3_to_t2(int n, int m, World &dw)
int main(int argc, char **argv)
an instance of a tensor within a CTF world