MOAB: Mesh Oriented datABase  (version 5.4.1)
tensor.c File Reference
#include "moab/FindPtFuncs.h"
+ Include dependency graph for tensor.c:

Go to the source code of this file.

Functions

static void mxm_cc (const realType *A, unsigned na, const realType *B, unsigned nb, realType *C, unsigned nc)
static void mxm_rc (const realType *A, unsigned na, const realType *B, unsigned nb, realType *C, unsigned nc)
static void mxm_cr (const realType *A, unsigned na, const realType *B, unsigned nb, realType *C, unsigned nc)
static void mxv_c (realType *y, unsigned ny, const realType *A, const realType *x, unsigned nx)
static void mxv_r (realType *y, unsigned ny, const realType *A, const realType *x, unsigned nx)
static realType inner (const realType *u, const realType *v, unsigned n)
void tensor_c1 (const realType *R, unsigned mr, unsigned nr, const realType *u, realType *v)
void tensor_r1 (const realType *R, unsigned mr, unsigned nr, const realType *u, realType *v)
void tensor_c2 (const realType *R, unsigned mr, unsigned nr, const realType *S, unsigned ms, unsigned ns, const realType *u, realType *v, realType *W)
void tensor_r2 (const realType *R, unsigned mr, unsigned nr, const realType *S, unsigned ms, unsigned ns, const realType *u, realType *v, realType *W)
void tensor_c3 (const realType *R, unsigned mr, unsigned nr, const realType *S, unsigned ms, unsigned ns, const realType *T, unsigned mt, unsigned nt, const realType *u, realType *v, realType *W, realType *Z)
void tensor_r3 (const realType *R, unsigned mr, unsigned nr, const realType *S, unsigned ms, unsigned ns, const realType *T, unsigned mt, unsigned nt, const realType *u, realType *v, realType *W, realType *Z)
realType tensor_i1 (const realType *Jr, unsigned nr, const realType *u)
realType tensor_i2 (const realType *Jr, unsigned nr, const realType *Js, unsigned ns, const realType *u, realType *work)
realType tensor_i3 (const realType *Jr, unsigned nr, const realType *Js, unsigned ns, const realType *Jt, unsigned nt, const realType *u, realType *work)
realType tensor_ig1 (const realType *Jr, const realType *Dr, unsigned nr, const realType *u, realType *g)
realType tensor_ig2 (const realType *Jr, const realType *Dr, unsigned nr, const realType *Js, const realType *Ds, unsigned ns, const realType *u, realType *g, realType *work)
realType tensor_ig3 (const realType *Jr, const realType *Dr, unsigned nr, const realType *Js, const realType *Ds, unsigned ns, const realType *Jt, const realType *Dt, unsigned nt, const realType *u, realType *g, realType *work)

Function Documentation

static realType inner ( const realType *  u,
const realType *  v,
unsigned  n 
) [static]

Definition at line 132 of file tensor.c.

References moab::sum().

Referenced by run_quality_optimizer(), tensor_i1(), tensor_i2(), tensor_i3(), tensor_ig1(), tensor_ig2(), and tensor_ig3().

{
    const realType* u_end = u + n;
    realType sum          = *u++ * *v++;
    while( u != u_end )
    {
        sum += *u++ * *v++;
    }
    return sum;
}
static void mxm_cc ( const realType *  A,
unsigned  na,
const realType *  B,
unsigned  nb,
realType *  C,
unsigned  nc 
) [static]

Definition at line 13 of file tensor.c.

Referenced by tensor_c2(), tensor_c3(), tensor_r2(), and tensor_r3().

{
    unsigned i, j, k;
    realType* Ccol       = C;
    const realType* Bcol = B;
    for( j = 0; j < nc; ++j, Ccol += na, Bcol += nb )
    {
        const realType* Acol = A;
        for( i = 0; i < na; ++i )
            Ccol[i] = 0;
        for( k = 0; k < nb; ++k, Acol += na )
            for( i = 0; i < na; ++i )
                Ccol[i] += Acol[i] * Bcol[k];
    }
}
static void mxm_cr ( const realType *  A,
unsigned  na,
const realType *  B,
unsigned  nb,
realType *  C,
unsigned  nc 
) [static]

Definition at line 46 of file tensor.c.

Referenced by tensor_c2(), and tensor_c3().

{
    unsigned i, j, k;
    const realType *Acol = A, *Brow = B;
    for( i = 0; i < na * nc; ++i )
        C[i] = 0;
    for( k = 0; k < nb; ++k, Acol += na, Brow += nc )
    {
        realType* Ccol = C;
        for( j = 0; j < nc; ++j, Ccol += na )
            for( i = 0; i < na; ++i )
                Ccol[i] += Acol[i] * Brow[j];
    }
}
static void mxm_rc ( const realType *  A,
unsigned  na,
const realType *  B,
unsigned  nb,
realType *  C,
unsigned  nc 
) [static]

Definition at line 29 of file tensor.c.

Referenced by tensor_r2(), and tensor_r3().

{
    unsigned i, j, k;
    realType* Ccol       = C;
    const realType* Bcol = B;
    for( j = 0; j < nc; ++j, Ccol += na, Bcol += nb )
    {
        const realType* Arow = A;
        for( i = 0; i < na; ++i, Arow += nb )
        {
            Ccol[i] = 0;
            for( k = 0; k < nb; ++k )
                Ccol[i] += Arow[k] * Bcol[k];
        }
    }
}
static void mxv_c ( realType *  y,
unsigned  ny,
const realType *  A,
const realType *  x,
unsigned  nx 
) [static]

Definition at line 89 of file tensor.c.

Referenced by tensor_c1().

{
    realType *yp = y, *y_end = y + ny;
    const realType* x_end = x + nx;
    realType xk           = *x;
    do
    {
        *yp++ = *A++ * xk;
    } while( yp != y_end );
    for( ++x; x != x_end; ++x )
    {
        xk = *x;
        yp = y;
        do
        {
            *yp++ += *A++ * xk;
        } while( yp != y_end );
    }
}
static void mxv_r ( realType *  y,
unsigned  ny,
const realType *  A,
const realType *  x,
unsigned  nx 
) [static]

Definition at line 109 of file tensor.c.

References moab::sum().

Referenced by tensor_i2(), tensor_i3(), tensor_ig2(), tensor_ig3(), and tensor_r1().

{
    realType* y_end       = y + ny;
    const realType* x_end = x + nx;
    do
    {
        const realType* xp = x;
        realType sum       = *A++ * *xp++;
        while( xp != x_end )
        {
            sum += *A++ * *xp++;
        }
        *y++ = sum;
    } while( y != y_end );
}
void tensor_c1 ( const realType *  R,
unsigned  mr,
unsigned  nr,
const realType *  u,
realType *  v 
)

Definition at line 155 of file tensor.c.

References mxv_c().

{
    mxv_c( v, mr, R, u, nr );
}
void tensor_c2 ( const realType *  R,
unsigned  mr,
unsigned  nr,
const realType *  S,
unsigned  ms,
unsigned  ns,
const realType *  u,
realType *  v,
realType *  W 
)

Definition at line 166 of file tensor.c.

References mxm_cc(), and mxm_cr().

{
    mxm_cc( R, mr, u, nr, W, ns );
    mxm_cr( W, mr, S, ns, v, ms );
}
void tensor_c3 ( const realType *  R,
unsigned  mr,
unsigned  nr,
const realType *  S,
unsigned  ms,
unsigned  ns,
const realType *  T,
unsigned  mt,
unsigned  nt,
const realType *  u,
realType *  v,
realType *  W,
realType *  Z 
)

Definition at line 197 of file tensor.c.

References mxm_cc(), mxm_cr(), and Z.

{
    unsigned n, mrns = mr * ns, mrms = mr * ms;
    realType* Zp = Z;
    mxm_cc( R, mr, u, nr, W, ns * nt );
    for( n = 0; n < nt; ++n, W += mrns, Zp += mrms )
        mxm_cr( W, mr, S, ns, Zp, ms );
    mxm_cr( Z, mrms, T, nt, v, mt );
}
realType tensor_i1 ( const realType *  Jr,
unsigned  nr,
const realType *  u 
)

Definition at line 255 of file tensor.c.

References inner().

Referenced by opt_edge_hess_2(), opt_edge_hess_3(), opt_edge_intp_2(), and opt_edge_intp_3().

{
    return inner( Jr, u, nr );
}
realType tensor_i2 ( const realType *  Jr,
unsigned  nr,
const realType *  Js,
unsigned  ns,
const realType *  u,
realType *  work 
)
realType tensor_i3 ( const realType *  Jr,
unsigned  nr,
const realType *  Js,
unsigned  ns,
const realType *  Jt,
unsigned  nt,
const realType *  u,
realType *  work 
)
realType tensor_ig1 ( const realType *  Jr,
const realType *  Dr,
unsigned  nr,
const realType *  u,
realType *  g 
)

Definition at line 304 of file tensor.c.

References inner().

Referenced by opt_edge_intp_2(), and opt_edge_intp_3().

{
    *g = inner( Dr, u, nr );
    return inner( Jr, u, nr );
}
realType tensor_ig2 ( const realType *  Jr,
const realType *  Dr,
unsigned  nr,
const realType *  Js,
const realType *  Ds,
unsigned  ns,
const realType *  u,
realType *  g,
realType *  work 
)

Definition at line 311 of file tensor.c.

References inner(), and mxv_r().

Referenced by obbox_calc_2(), opt_area_intp_2(), opt_face_hess_3(), and opt_face_intp_3().

{
    realType *a = work, *ar = a + ns;
    mxv_r( a, ns, u, Jr, nr );
    mxv_r( ar, ns, u, Dr, nr );
    g[0] = inner( Js, ar, ns );
    g[1] = inner( Ds, a, ns );
    return inner( Js, a, ns );
}
realType tensor_ig3 ( const realType *  Jr,
const realType *  Dr,
unsigned  nr,
const realType *  Js,
const realType *  Ds,
unsigned  ns,
const realType *  Jt,
const realType *  Dt,
unsigned  nt,
const realType *  u,
realType *  g,
realType *  work 
)

Definition at line 330 of file tensor.c.

References inner(), and mxv_r().

Referenced by obbox_calc_3(), and opt_vol_intp_3().

{
    unsigned nsnt = ns * nt;
    realType *a = work, *ar = a + nsnt, *b = ar + nsnt, *br = b + ns, *bs = br + ns;
    mxv_r( a, nsnt, u, Jr, nr );
    mxv_r( ar, nsnt, u, Dr, nr );
    mxv_r( b, nt, a, Js, ns );
    mxv_r( br, nt, ar, Js, ns );
    mxv_r( bs, nt, a, Ds, ns );
    g[0] = inner( Jt, br, nt );
    g[1] = inner( Jt, bs, nt );
    g[2] = inner( Dt, b, nt );
    return inner( Jt, b, nt );
}
void tensor_r1 ( const realType *  R,
unsigned  mr,
unsigned  nr,
const realType *  u,
realType *  v 
)

Definition at line 160 of file tensor.c.

References mxv_r().

{
    mxv_r( v, mr, R, u, nr );
}
void tensor_r2 ( const realType *  R,
unsigned  mr,
unsigned  nr,
const realType *  S,
unsigned  ms,
unsigned  ns,
const realType *  u,
realType *  v,
realType *  W 
)

Definition at line 181 of file tensor.c.

References mxm_cc(), and mxm_rc().

{
    mxm_rc( R, mr, u, nr, W, ns );
    mxm_cc( W, mr, S, ns, v, ms );
}
void tensor_r3 ( const realType *  R,
unsigned  mr,
unsigned  nr,
const realType *  S,
unsigned  ms,
unsigned  ns,
const realType *  T,
unsigned  mt,
unsigned  nt,
const realType *  u,
realType *  v,
realType *  W,
realType *  Z 
)

Definition at line 221 of file tensor.c.

References mxm_cc(), mxm_rc(), and Z.

{
    unsigned n, mrns = mr * ns, mrms = mr * ms;
    realType* Zp = Z;
    mxm_rc( R, mr, u, nr, W, ns * nt );
    for( n = 0; n < nt; ++n, W += mrns, Zp += mrms )
        mxm_cc( W, mr, S, ns, Zp, ms );
    mxm_cc( Z, mrms, T, nt, v, mt );
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines