OON: Re: oon-digest V1 #57

From: James A. Crotinger (jac@lanl.gov)
Date: Thu Mar 23 2000 - 17:30:40 EST


on 3/23/00 1:13 PM, oon-digest at owner-oon-digest@oonumerics.org wrote:

> void rank1Update(Matrix& A, const Vector& x)
> {
> for (int i=0; i < A.rows(); ++i)
> for (int j=0; j < A.cols(); ++j)
> A(i,j) += x(i) * x(j);
> }
>
> [...] However, the compiler can't be sure that the data in the matrix A
> doesn't overlap the data in the vector x -- there is a possibility that
> writing to A(i,j) could change the value of x(i) partway through.

This one has always bothered me - why isn't "const" enough to tell the
compiler that x isn't being changed by the assignment.

  Jim

-- 
------------------------------------------------------------------------
James A. Crotinger      Los Alamos National Lab     email: jac@lanl.gov
Technical Staff Member     CIC-ACL, MS B287         phone: 505-665-6022
Advanced Computing Lab   Los Alamos, NM 87545       fax:   505-665-4939

--------------------- Object Oriented Numerics List -------------------------- * To subscribe/unsubscribe: use the handy web form at http://oonumerics.org/oon/ * If this doesn't work, please send a note to owner-oon-list@oonumerics.org



This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:10 EST