Re: BZDEV: Re: Initial thoughts about tensors

From: jeremic@sokocalo.cee.clarkson.edu
Date: Wed Jun 17 1998 - 17:06:05 EST


Hello All,

Maybe I should put some more light on the inner workings of nDarray
classes.

Consider:

tensor test = A("ijkl") * B("jklm") * C("mrpq");

internally a temporary will be created from A * B
and it will be a tensor of order 2 with two indices "im",
and then that temorary will be multipiled with C and the result, tensor
test will be a tensor of order 4 with indices "irpq". This resulting
indices will be deleted after this line and if test is used later it
will be provided with new set of indices like in:

tensor test2 = test("ijxy") * test("jxyL");

which results in a tensor test2 being an order 2 tensor with indices
"iL", which will be again deleted right after that line of code. Every
tensor object has two char * which receive current indices (two, because
we can have same tensor being multiplied with itself). I have put only
two char * because I have not seen any tensor formulae that have the
same tensor more than twice. That is, not more than twice in the same
contraction-multiplication part.

here is the class definition of ndarray (which is the base class for
tensors, matrices and vectors):

 private:
    double *pd_nDdata; // nD array as 1D array
    int nDarray_rank; ///* nDarray rank :
                        // 0 -> scalar
                        // 1 -> vector
                        // 2 -> matrix
                        // * -> ******** */
    long int total_numb; // total number of elements in nDarray
    int *dim; // array of dimensions in each rank direction
                       // for example, if nDarray_rank = 3 :
                       // dim[0] = dimension in direction 1
                       // dim[1] = dimension in direction 2
                       // dim[2] = dimension in direction 3 */
    int n; // reference count

and then tensor class adds:

    char *indices1; // character array of indices
    char *indices2; // they should be checked for matching and
                       // then operator will be identified

Indices are parsed very efficiently (couple of lines of integer and
char operations) so that should not be a concern regarding the
actual extra memory or efficiency.

You can have any contraction or expansion involved (like
a("ijkl")*b("ijkl") or c("ijk")*d("l") ) it will be taken care of by
the operator* defined for tensors.

nDarray tool directly works on indices and multiplies (contracts or
expands) indices indicated as an argument (for example in the case of
E("ijk"), char * to ijk is delivered to tensor object and it is ready to
be parsed if E is to be multiplied with some other tensor).

There are no extra expansion and then contraction with Kronecker deltas
or Levi-Civita permutation tensors.

So much for now, best regards, Boris

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

--------------------- 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:05 EST