A line from UBLAS explanation

U

utab

Dear all, I have a question regarding an assignment operation

This is the statement:

"If you know for sure that the left hand expression and the right hand
expression have no common storage, then assignment has no aliasing."

This is from

http://www.boost.org/libs/numeric/ublas/doc/
operations_overview.htm#noalias

under Matrix/Vector operation header.

I could not understand this, can someone clarify that for me?

Best regards
 
M

Markus Moll

Hi
Dear all, I have a question regarding an assignment operation

This is the statement:

"If you know for sure that the left hand expression and the right hand
expression have no common storage, then assignment has no aliasing." [...]
I could not understand this, can someone clarify that for me?

Consider the following assignment with matrices A and B
A = A * B
Clearly, the expression on the left hand side and the expression on the
right hand side refer to common storage, the storage of A. It is obvious
that you cannot assign the result of A*B directly into A, as you would
destroy your first operand. Therefore, in that case (and generally
whenever _some_ storage is shared among left and right hand side) you
need to store the result in some temporary storage before you can assign
them. If, on the other hand, there is no common storage, e.g. because
you have two _distinct_ matrices A and B, you know that you could store
directly into A in the expression
A = B * B
The documentation says that in those cases you can use noalias(A) to
speed things up.

hth
Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top