Bugzilla – Attachment 208 Details for
Bug 303
bigMat.block(...).array()*mat.array() is slower than mat.array()*mat.array()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
This bugzilla service is closed. All entries have been migrated to
https://gitlab.com/libeigen/eigen
Program to get timings
foo.cc (text/x-c++src), 1.21 KB, created by
Jitse Niesen
on 2011-09-11 12:11:28 UTC
(
hide
)
Description:
Program to get timings
Filename:
MIME Type:
Creator:
Jitse Niesen
Created:
2011-09-11 12:11:28 UTC
Size:
1.21 KB
patch
obsolete
>#include <iostream> >#include <time.h> >#include <Eigen/Core> > >using namespace std; >using namespace Eigen; > >int main(int argc, char** argv) >{ > const int N = 10; > MatrixXd bigMat = MatrixXd::Random(50*N, 2*N); > MatrixXd mat1 = MatrixXd::Random(10*N, 2*N); > MatrixXd mat2 = MatrixXd::Random(10*N, 2*N); > MatrixXd sol(100, 20); > clock_t start, end; > int repeats = 100000000 / (N*N); > double timePerMult; > > start = clock(); > for (int k = 0; k < repeats; ++k) > sol = bigMat.block(0,0,10*N,2*N).array() * mat2.array(); > end = clock(); > timePerMult = ((double) (end - start)) / CLOCKS_PER_SEC / repeats * 1e6; > cout << "Multiplication 1 takes " << timePerMult << " usec \n"; > > start = clock(); > for (int k = 0; k < repeats; ++k) > sol = mat1.array() * mat2.array(); > end = clock(); > timePerMult = ((double) (end - start)) / CLOCKS_PER_SEC / repeats * 1e6; > cout << "Multiplication 2 takes " << timePerMult << " usec \n"; > > start = clock(); > for (int k = 0; k < repeats; ++k) > sol = bigMat.block(0,0,10*N,2*N).transpose().array() * mat2.transpose().array(); > end = clock(); > timePerMult = ((double) (end - start)) / CLOCKS_PER_SEC / repeats * 1e6; > cout << "Multiplication 3 takes " << timePerMult << " usec \n"; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 303
: 208