This forum has been archived. All content is frozen. Please use KDE Discuss instead.

does array wrapper use alias?

Tags: None
(comma "," separated)
rgriffin122
Registered Member
Posts
7
Karma
0
OS

does array wrapper use alias?

Fri Mar 23, 2012 1:44 pm
Hello,

I'm running a benchmark with Eigen and MKL, and in order to get the best results I'm using information gathered from the Linpack becnmark test (hpl), to find the largest possible matrix I can use.

Since most my operations don't use a single matrix, I have to find out the total matrices that will be used in the scope, and divide my max amount of space by that.

Some of my functions require the <Matrix_Base>.array() function. Will the array create an alias? I'm assuming it will, but couldn't find any documentation on it. Just want to make sure before I run a large scale test, and crash halfway through.

Also, will a matrix expression create a tmp alias per operation?

So (if letters are matrices): E = (A + B * C - D) will have,
tmp1 = B * C, tmp2 = A + tmp1, tmp3 = tmp2 - D. E = tmp3?

Thank you!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: does array wrapper use alias?

Fri Mar 23, 2012 5:50 pm
.array() is no-op, it only provides a different API.

Regarding:
E = (A + B * C - D)

the matrix product has to be evaluated into a temporary to be efficient:

tmp = B * C;

then the other operations are evaluated through a single loop without any temp:

for(....)
E[i] = A[i] + tmp[i] - D[i];


You can avoid this tmp by rewriting it as:

E = A - D;
E.noalias() += B * C;

In this case B*C is directly accumulated into the content of E.

Most of the operations in Eigen only returns an expression with lazy evaluation, they include .transpose(), .adjoint(), etc. Only products and inverse products have to be evaluated.
rgriffin122
Registered Member
Posts
7
Karma
0
OS
Thank you!


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]