Re: BZDEV: Re: Initial thoughts about tensors

From: jeremic@clarkson.edu
Date: Wed Jul 22 1998 - 15:33:50 EST


Hello All,

> > lX(ii,jj) < (g_up(i,k)%dX(j,k) || g_up(j,k)%dX(i,k))
> > - (2/3.0)*dX(q,q)*g_up(i,j)
> > + (g_up(i,k)%(christof(j,k,l)%X(l)) || g_up(j,k)%(christof(i,k,l)%X(l)));
> >
> > The "||" symbol adds two non_symmetric rank 2 tensors to make a
> > symmetric rank 2 tensor. Once again, it only does 6 instead of 9
> > adds.
> >
>
> There is a problem here since C++ standard does not say what the order
> of execution of functions should be. The above line might not be
> portable across different compilers. I am not sure about the details of
> your code, but try compiling and runing with different compilers.
>
> Are you saying that C++ is getting rid of operator precedence? That
> is all that I use to uniquely define how everything above is
> evaluated. That is why I have parentheses in varying places.

// Some relevant notes from the Dec. 96 Draft (as pointed out by KAI folks):
//
// "A binary operator shall be implemented either by a non-static member
// function (_class.mfct_) with one parameter or by a non-member function
// with two parameters. Thus, for any binary operator @, x@y can be
// interpreted as either x.operator@(y) or operator@(x,y)." [13.5.2]
//
// "The order of evaluation of arguments [of a function call] is
// unspecified." [5.2.2 paragraph 9]
//
//

The point here being that if you overload operator() it might mess up
indices if you have same tensor used more than once in a statement. For
example:

(g_up(i,k)%dX(j,k) || g_up(j,k)%dX(i,k)) might create problem for g_up
or dX. I'm not sure how your implementation works but it would be
useful to try it with other compilers. In my case it surfaced when I
tried KAI C++ (it used to work with SUN CC, all versions of gcc...).

best regards, Boris

Boris Jeremic Phone (315) 268-4435
Assistant Professor Fax (315) 268-7985
Department of Civil and Jeremic@Polaris.Clarkson.edu
Environmental Engineering http://www.clarkson.edu/~jeremic
Clarkson University
Potsdam, NY 13699-5710

 

--------------------- blitz-dev list --------------------------------
* To subscribe/unsubscribe: mail to majordomo@oonumerics.org, with
"subscribe blitz-dev" or "unsubscribe blitz-dev" in the body of the message
* Blitz++ web page: http://oonumerics.org/blitz/



This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 04:30:06 EST