assign5/mat.cpp
// performs the function over the cartesian product over the rows of the two matrices
// WARNING: allocates new matrix for answer
performs the function over the cartesian product over the rows of the two matrices
WARNING: allocates new matrix for answer
performs the function over the cartesian product over the rows of the two matrices WARNING : allocates new matrix for answer
Matrix Matrix::cartesianRow(double (*f)(int size, double *x, double *y), Matrix &other)
{
    assertDefined("cartesianRow");
    other.assertDefined("cartesianRow");
    assertColsEqual(other, "cartesianRow");
    Matrix out(maxr, other.maxr);
    for (int r=0; r<out.maxr; r++) {
        for (int c=0; c<out.maxc; c++) {
            out.m[r][c] = f(maxc, m[r], other.m[c]);
        }
    }
    out.defined = true;
    return out;
}
Matrix Matrix :: cartesianRow ( double ( * f ) ( int size , double * x , double * y ) , Matrix & other ) { assertDefined ( " " ) ; other . assertDefined ( " " ) ; assertColsEqual ( other , " " ) ; Matrix out ( maxr , other . maxr ) ; for ( int r = 0 ; r < out . maxr ; r ++ ) { for ( int c = 0 ; c < out . maxc ; c ++ ) { out . m [ r ] [ c ] = f ( maxc , m [ r ] , other . m [ c ] ) ; } } out . defined = true ; return out ; }
performs the function over the cartesian product over the rows of the two matrices
WARNING: allocates new matrix for answer
performs the function over the cartesian product over the rows of the two matrices WARNING : allocates new matrix for answer