MOAB: Mesh Oriented datABase  (version 5.4.1)
HessTestMetricAbs_2 Class Reference
+ Inheritance diagram for HessTestMetricAbs_2:
+ Collaboration diagram for HessTestMetricAbs_2:

Public Member Functions

std::string get_name () const
bool evaluate (const MsqMatrix< 2, 2 > &A, const MsqMatrix< 2, 2 > &, double &result, MsqError &err)
 Evaluate \(\mu(A,W)\).
bool evaluate_with_grad (const MsqMatrix< 2, 2 > &A, const MsqMatrix< 2, 2 > &, double &result, MsqMatrix< 2, 2 > &d, MsqError &err)
 Gradient of \(\mu(A,W)\) with respect to components of A.
bool evaluate_with_hess (const MsqMatrix< 2, 2 > &A, const MsqMatrix< 2, 2 > &, double &result, MsqMatrix< 2, 2 > &d, MsqMatrix< 2, 2 > d2[3], MsqError &err)
 Hessian of \(\mu(A,W)\) with respect to components of A.
bool evaluate (const MsqMatrix< 3, 3 > &A, const MsqMatrix< 3, 3 > &, double &result, MsqError &err)
 Evaluate \(\mu(A,W)\).
bool evaluate_with_grad (const MsqMatrix< 3, 3 > &A, const MsqMatrix< 3, 3 > &, double &result, MsqMatrix< 3, 3 > &d, MsqError &err)
 Gradient of \(\mu(A,W)\) with respect to components of A.
bool evaluate_with_hess (const MsqMatrix< 3, 3 > &A, const MsqMatrix< 3, 3 > &, double &result, MsqMatrix< 3, 3 > &d, MsqMatrix< 3, 3 > d2[6], MsqError &err)
 Hessian of \(\mu(A,W)\) with respect to components of A.

Detailed Description

Simple target metric for testing second partial derivatives. \(\mu(T) = |T|\) \(\frac{\partial\mu}{\partial T} = \frac{1}{|T|} T \) \(\frac{\partial^{2}\mu}{\partial t_{i,i}^2} = \frac{1}{|T|} - \frac{t_{i,i}^2}{|T|^3}\) \(\frac{\partial^{2}\mu}{\partial t_{i,j} \partial t_{k,l} (i \ne k or j \ne l)} = -\frac{t_{i,j} a_{k,l}}{|T|^3}\) Simple target metric for testing second partial derivatives. \(\mu(A,W) = |A|\) \(\frac{\partial\mu}{\partial A} = \frac{1}{|A|} A \) \(\frac{\partial^{2}\mu}{\partial a_{i,i}^2} = \frac{1}{|A|} - \frac{a_{i,i}^2}{|A|^3}\) \(\frac{\partial^{2}\mu}{\partial a_{i,j} \partial a_{k,l} (i \ne k or j \ne l)} = -\frac{a_{i,j} a_{k,l}}{|A|^3}\)

Definition at line 165 of file AWMetricTest.cpp.


Member Function Documentation

bool HessTestMetricAbs_2::evaluate ( const MsqMatrix< 2, 2 > &  A,
const MsqMatrix< 2, 2 > &  W,
double &  result,
MsqError err 
) [inline, virtual]

Evaluate \(\mu(A,W)\).

Parameters:
A2x2 active matrix
W2x2 target matrix
resultOutput: value of function
Returns:
false if function cannot be evaluated for given A and W (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::AWMetric.

Definition at line 173 of file AWMetricTest.cpp.

References MBMesquite::Frobenius().

    {
        result = Frobenius( A );
        return true;
    }
bool HessTestMetricAbs_2::evaluate ( const MsqMatrix< 3, 3 > &  A,
const MsqMatrix< 3, 3 > &  W,
double &  result,
MsqError err 
) [inline, virtual]

Evaluate \(\mu(A,W)\).

Parameters:
A3x3 active matrix
W3x3 target matrix
resultOutput: value of function
Returns:
false if function cannot be evaluated for given A and W (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::AWMetric.

Definition at line 210 of file AWMetricTest.cpp.

References MBMesquite::Frobenius().

    {
        result = Frobenius( A );
        return true;
    }
bool HessTestMetricAbs_2::evaluate_with_grad ( const MsqMatrix< 2, 2 > &  A,
const MsqMatrix< 2, 2 > &  W,
double &  result,
MsqMatrix< 2, 2 > &  deriv_wrt_A,
MsqError err 
) [inline, virtual]

Gradient of \(\mu(A,W)\) with respect to components of A.

Parameters:
A2x2 active matrix
W2x2 target matrix
resultOutput: value of function
deriv_wrt_AOutput: partial deriviatve of \(\mu\) wrt each term of A, evaluated at passed A.

\[\left[\begin{array}{cc} \frac{\partial\mu}{\partial A_{0,0}} & \frac{\partial\mu}{\partial A_{0,1}} \\ \frac{\partial\mu}{\partial A_{1,0}} & \frac{\partial\mu}{\partial A_{1,1}} \\ \end{array}\right]\]

Returns:
false if function cannot be evaluated for given A and W (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::AWMetric.

Definition at line 179 of file AWMetricTest.cpp.

References MBMesquite::Frobenius().

Referenced by AWMetricTest::test_numerical_gradient_2D(), and AWMetricTest::test_numerical_gradient_3D().

    {
        result = Frobenius( A );
        d      = A / result;
        return true;
    }
bool HessTestMetricAbs_2::evaluate_with_grad ( const MsqMatrix< 3, 3 > &  A,
const MsqMatrix< 3, 3 > &  W,
double &  result,
MsqMatrix< 3, 3 > &  deriv_wrt_A,
MsqError err 
) [inline, virtual]

Gradient of \(\mu(A,W)\) with respect to components of A.

Parameters:
A3x3 active matrix
W3x3 target matrix
resultOutput: value of function
deriv_wrt_AOutput: partial deriviatve of \(\mu\) wrt each term of A, evaluated at passed A.

\[\left[\begin{array}{ccc} \frac{\partial\mu}{\partial A_{0,0}} & \frac{\partial\mu}{\partial A_{0,1}} & \frac{\partial\mu}{\partial A_{0,2}} \\ \frac{\partial\mu}{\partial A_{1,0}} & \frac{\partial\mu}{\partial A_{1,1}} & \frac{\partial\mu}{\partial A_{1,2}} \\ \frac{\partial\mu}{\partial A_{2,0}} & \frac{\partial\mu}{\partial A_{2,1}} & \frac{\partial\mu}{\partial A_{2,2}} \end{array}\right]\]

Returns:
false if function cannot be evaluated for given A and W (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::AWMetric.

Definition at line 216 of file AWMetricTest.cpp.

References MBMesquite::Frobenius().

    {
        result = Frobenius( A );
        d      = A / result;
        return true;
    }
bool HessTestMetricAbs_2::evaluate_with_hess ( const MsqMatrix< 2, 2 > &  A,
const MsqMatrix< 2, 2 > &  W,
double &  result,
MsqMatrix< 2, 2 > &  deriv_wrt_A,
MsqMatrix< 2, 2 >  second_wrt_A[3],
MsqError err 
) [inline, virtual]

Hessian of \(\mu(A,W)\) with respect to components of A.

Parameters:
A2x2 active matrix
W2x2 target matrix
resultOutput: value of function
deriv_wrt_AOutput: partial deriviatve of \(\mu\) wrt each term of A, evaluated at passed A.
second_wrt_AOutput: 4x4 matrix of second partial deriviatve of \(\mu\) wrt each term of A, in row-major order. The symmetric matrix is decomposed into 2x2 blocks and only the upper diagonal blocks, in row-major order, are returned.

\[\left[\begin{array}{cc|cc} \frac{\partial^{2}\mu}{\partial A_{0,0}^2} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{0,1}} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{1,0}} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{1,1}} \\ \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{0,1}} & \frac{\partial^{2}\mu}{\partial A_{0,1}^2} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{1,0}} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{1,1}} \\ \hline & & \frac{\partial^{2}\mu}{\partial A_{1,0}^2} & \frac{\partial^{2}\mu}{\partial A_{1,0}\partial A_{1,1}} \\ & & \frac{\partial^{2}\mu}{\partial A_{1,0}\partial A_{1,1}} & \frac{\partial^{2}\mu}{\partial A_{1,1}^2} \\ \end{array}\right]\]

Returns:
false if function cannot be evaluated for given A and W (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::AWMetric.

Definition at line 190 of file AWMetricTest.cpp.

References MBMesquite::Frobenius(), MBMesquite::MsqMatrix< R, C >::row(), and MBMesquite::transpose().

Referenced by AWMetricTest::test_numerical_hessian_2D(), and AWMetricTest::test_numerical_hessian_3D().

    {
        result = Frobenius( A );
        d      = A / result;
        int h  = 0;
        for( int r = 0; r < 2; ++r )
        {
            int i = h;
            for( int c = r; c < 2; ++c )
                d2[h++] = transpose( A.row( r ) ) * A.row( c ) / -( result * result * result );
            d2[i] += MsqMatrix< 2, 2 >( 1.0 / result );
        }
        return true;
    }
bool HessTestMetricAbs_2::evaluate_with_hess ( const MsqMatrix< 3, 3 > &  A,
const MsqMatrix< 3, 3 > &  W,
double &  result,
MsqMatrix< 3, 3 > &  deriv_wrt_A,
MsqMatrix< 3, 3 >  second_wrt_A[6],
MsqError err 
) [inline, virtual]

Hessian of \(\mu(A,W)\) with respect to components of A.

Parameters:
A3x3 active matrix
W3x3 target matrix
resultOutput: value of function
deriv_wrt_AOutput: partial deriviatve of \(\mu\) wrt each term of A, evaluated at passed A.
second_wrt_AOutput: 9x9 matrix of second partial deriviatve of \(\mu\) wrt each term of A, in row-major order. The symmetric matrix is decomposed into 3x3 blocks and only the upper diagonal blocks, in row-major order, are returned.

\[\left[\begin{array}{ccc|ccc|ccc} \frac{\partial^{2}\mu}{\partial A_{0,0}^2} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{0,1}} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{0,2}} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{1,0}} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{1,1}} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{1,2}} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{2,0}} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{2,1}} & \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{2,2}} \\ \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{0,1}} & \frac{\partial^{2}\mu}{\partial A_{0,1}^2} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{0,2}} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{1,0}} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{1,1}} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{1,2}} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{2,0}} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{2,1}} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{2,2}} \\ \frac{\partial^{2}\mu}{\partial A_{0,0}\partial A_{0,2}} & \frac{\partial^{2}\mu}{\partial A_{0,1}\partial A_{0,2}} & \frac{\partial^{2}\mu}{\partial A_{0,2}^2} & \frac{\partial^{2}\mu}{\partial A_{0,2}\partial A_{1,0}} & \frac{\partial^{2}\mu}{\partial A_{0,2}\partial A_{1,1}} & \frac{\partial^{2}\mu}{\partial A_{0,2}\partial A_{1,2}} & \frac{\partial^{2}\mu}{\partial A_{0,2}\partial A_{2,0}} & \frac{\partial^{2}\mu}{\partial A_{0,2}\partial A_{2,1}} & \frac{\partial^{2}\mu}{\partial A_{0,2}\partial A_{2,2}} \\ \hline & & & \frac{\partial^{2}\mu}{\partial A_{1,0}^2} & \frac{\partial^{2}\mu}{\partial A_{1,0}\partial A_{1,1}} & \frac{\partial^{2}\mu}{\partial A_{1,0}\partial A_{1,2}} & \frac{\partial^{2}\mu}{\partial A_{1,0}\partial A_{2,0}} & \frac{\partial^{2}\mu}{\partial A_{1,0}\partial A_{2,1}} & \frac{\partial^{2}\mu}{\partial A_{1,0}\partial A_{2,2}} \\ & & & \frac{\partial^{2}\mu}{\partial A_{1,0}\partial A_{1,1}} & \frac{\partial^{2}\mu}{\partial A_{1,1}^2} & \frac{\partial^{2}\mu}{\partial A_{1,1}\partial A_{1,2}} & \frac{\partial^{2}\mu}{\partial A_{1,1}\partial A_{2,0}} & \frac{\partial^{2}\mu}{\partial A_{1,1}\partial A_{2,1}} & \frac{\partial^{2}\mu}{\partial A_{1,1}\partial A_{2,2}} \\ & & & \frac{\partial^{2}\mu}{\partial A_{1,0}\partial A_{1,2}} & \frac{\partial^{2}\mu}{\partial A_{1,1}\partial A_{1,2}} & \frac{\partial^{2}\mu}{\partial A_{1,2}^2} & \frac{\partial^{2}\mu}{\partial A_{1,2}\partial A_{2,0}} & \frac{\partial^{2}\mu}{\partial A_{1,2}\partial A_{2,1}} & \frac{\partial^{2}\mu}{\partial A_{1,2}\partial A_{2,2}} \\ \hline & & & & & & \frac{\partial^{2}\mu}{\partial A_{2,0}^2} & \frac{\partial^{2}\mu}{\partial A_{2,0}\partial A_{2,1}} & \frac{\partial^{2}\mu}{\partial A_{2,0}\partial A_{2,2}} \\ & & & & & & \frac{\partial^{2}\mu}{\partial A_{2,0}\partial A_{2,1}} & \frac{\partial^{2}\mu}{\partial A_{2,1}^2} & \frac{\partial^{2}\mu}{\partial A_{2,1}\partial A_{2,2}} \\ & & & & & & \frac{\partial^{2}\mu}{\partial A_{2,0}\partial A_{2,2}} & \frac{\partial^{2}\mu}{\partial A_{2,1}\partial A_{2,2}} & \frac{\partial^{2}\mu}{\partial A_{2,2}^2} \\ \end{array}\right]\]

Returns:
false if function cannot be evaluated for given A and W (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::AWMetric.

Definition at line 227 of file AWMetricTest.cpp.

References MBMesquite::Frobenius(), MBMesquite::MsqMatrix< R, C >::row(), and MBMesquite::transpose().

    {
        result = Frobenius( A );
        d      = A / result;
        int h  = 0;
        for( int r = 0; r < 3; ++r )
        {
            int i = h;
            for( int c = r; c < 3; ++c )
                d2[h++] = transpose( A.row( r ) ) * A.row( c ) / -( result * result * result );
            d2[i] += MsqMatrix< 3, 3 >( 1.0 / result );
        }
        return true;
    }
std::string HessTestMetricAbs_2::get_name ( ) const [inline, virtual]

Implements MBMesquite::AWMetric.

Definition at line 168 of file AWMetricTest.cpp.

    {
        return "HessTest2";
    }

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines