![]() |
Blitz Devel : |
From: jeremic_at_[hidden]
Date: 1998-07-09 08:33:49
Hello All,
I just had to rewrite this expression:
>>
>> Copy_Index ii('i'), jj('j');
>> Index i('i'), j('j');
>>
>> K_new(ii,jj)<Lapse*(R(i,j) + Trace_K*K(i,j) - (2*K(i,k)&K_mix(k,j))
>> - 0.5*g(i,j)*(density - (g_up(k,l)|S(k,l))) - S(i,j));
>>
>> The Copy_Index tells the computer to return the original tensor with
>> the indices set to 'i' and 'j'. Index tells the computer to return a
>> *copy* with the indices set to 'i' and 'j'. The < operator tells the
>> computer to perform a copy using reference counting, and not an actual
>> copy over the 3D grid. A big disadvantage is that I have used up
>> symbols like &. There might be some people who would want to use & as
>> the original bit-wise AND. Also, the
>> Contraction_Index/Copy_Index/Index thing is a bit of an extra
>> complication, although with expression templates, I can probably get
>> rid of Copy_Index and Contraction_Index.
>>
as:
tensor K_new = Lapse*R + Trace_K*K - (2.*K("ik")*K_mix("kj") -
0.5 * g("ij") * (density - g_up("kl")*S("kl")) - S;
or with indices all the way (not necessary since there is no implicit
transositions, and for example Lapse*R("ij") is the same as Lapse*R,
and K_new will get new indices next times it is used in contractions:
tensor K_new = Lapse*R("ij") + Trace_K*K("ij") - (2.*K("ik")*K_mix("kj") -
0.5 * g("ij") * (density - g_up("kl")*S("kl")) - S("ij");
At operator=() copy is by reference counting by default. . . You can
also do a "deep" copy and there is a function that does that,
deep_copy().
For +, - you don't really need to specifically write indices since they
are not used anyway, except if you are doing transpositions implicitly,
which I am not.
Best regards, Boris
Boris Jeremic Phone (315) 268-4435
Assistant Professor Fax (315) 268-7985
Department of Civil and Jeremic_at_[hidden]
Environmental Engineering http://www.clarkson.edu/~jeremic
Clarkson University
Potsdam, NY 13699-5710
--------------------- blitz-dev list --------------------------------
* To subscribe/unsubscribe: mail to majordomo_at_[hidden], with
"subscribe blitz-dev" or "unsubscribe blitz-dev" in the body of the message
* Blitz++ web page: http://oonumerics.org/blitz/