- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am new on MKL. I try to make matrix product, but results are wrong, i can not solve the problem. Would you kindly help me, I will be pleased.
Thanks in advance.
Source Code #1:
//transa and transb are "n"
#include
#include
#include
void main()
{
char* trans="n";
double alpha=1.0;
double beta=0.0;
int lda=2;
int ldb=4;
int ldc=2;
int m=2;
int n=3;
int k=4;
int i,j;
double a[2][4];
double b[4][3];
double c[2][3];
printf("a matrisi\\n");
for(i=0;i
for(j=0;j
a
printf("%.02f\\t",a
}
printf("\\n\\n");
}
printf("b mmatrisi\\n");
for(i=0;i
for(j=0;j
b
printf("%.02f\\t",b
}
printf("\\n\\n");
}
dgemm(trans,trans,&m,&n,&k,α,(double*)a,&lda,(double*)b,&ldb,β,(double*)c,&ldc);
printf("a*b matrisi\\n");
for(i=0;i
for(j=0;j
printf("%f\\t",c
}
printf("\\n");
}
getch();
}
----------------
Source Code #2:
//transa and transb are "t"
#include
#include
#include
void main()
{
char* trans="t";
double alpha=1.0;
double beta=0.0;
int lda=4;
int ldb=3;
int ldc=2;
int m=2;
int n=3;
int k=4;
int i,j;
double a[2][4];
double b[4][3];
double c[2][3];
printf("a matrisi\\n");
for(i=0;i
for(j=0;j
a
printf("%.02f\\t",a
}
printf("\\n\\n");
}
printf("b mmatrisi\\n");
for(i=0;i
for(j=0;j
b
printf("%.02f\\t",b
}
printf("\\n\\n");
}
dgemm(trans,trans,&m,&n,&k,α,(double*)a,&lda,(double*)b,&ldb,β,(double*)c,&ldc);
printf("a*b matrisi\\n");
for(i=0;i
for(j=0;j
printf("%f\\t",c
}
printf("\\n");
}
getch();
}
---------------
and respected result is below
2.4 9.6 16.8
5.4 26.6 47.8
but i can notcalculate this result. Please run my source codes and then give your results, i think there is something wrong with my codes, but i can not find.
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
double a[2][4];
double b[4][3];
double c[2][3];
int lda=4;
int ldb=3;
int ldc=3;
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k,alpha,(double*)a,lda,(double*)b,ldb,
beta,(double*)c,ldc);
and try the test again.
For example, with your data I have:
1.20 2.20 3.20 4.20
b mmatrisi0.50 0.50 0.50
0.50 1.50 2.50
0.50 2.50 4.50
0.50 3.50 6.50
a*b matrisi
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
double a[2][4];
double b[4][3];
double c[2][3];
int lda=4;
int ldb=3;
int ldc=3;
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k,alpha,(double*)a,lda,(double*)b,ldb,
beta,(double*)c,ldc);
and try the test again.
For example, with your data I have:
1.20 2.20 3.20 4.20
b mmatrisi0.50 0.50 0.50
0.50 1.50 2.50
0.50 2.50 4.50
0.50 3.50 6.50
a*b matrisi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Alper Basturk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Petr
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page