Example #1
0
 void Tensor4d::tensorize(const Matrix & mat) {
     assert( dims_[1] * dims_[2] * dims_[3] == mat.width());
     assert( dims_[0] == mat.height() );
     for(UINT i = 0; i < dims_[0]; ++i)
         for(UINT j = 0; j < dims_[1]; ++j)
             for(UINT m = 0; m < dims_[2]; ++m)
                 for(UINT n = 0; n < dims_[3]; ++n)
                     set_elt(i, j, m, n, mat.get_elt(i, j * dims_[2] * dims_[3] + m * dims_[3] + n));
 }
Example #2
0
/* This is the function you need to optimize. It takes one
   square matrix as input
*/
void verfunc(smat_t *a)
{
    int i, j;
    double x,x2;

    // i is the column of a we're computing right now
    for(i = 0; i < a->n; i++)
    {
        // j is the row of a we're computing right now
        for(j = 0; j < a->n; j++)
        {            
                // First, compute f(A) for the element of a in question
			x = get_elt(a, i, j);
                x = ver_f(x, i, j);
                
                // Add this to the value of a we're computing and store it
                x2 = get_elt(a, i, j);
			x = x * x2;
                set_elt(a, i, j, x);
            
        }
    }
}