assign5/mat.cpp
// dot or inner product or classic matrix multiply BUT
// the SECOND argument is transposed!
// WARNING: allocates new matrix for answer
dot or inner product or classic matrix multiply BUT
the SECOND argument is transposed.
WARNING: allocates new matrix for answer
dot or inner product or classic matrix multiply BUT the SECOND argument is transposed . WARNING : allocates new matrix for answer
Matrix Matrix::dotT(const Matrix &other)
{
    assertDefined("lhs of dotT");
    other.assertDefined("rhs of dotT");
    assertColsEqual(other, "dotT");
    Matrix out(maxr, other.maxr);
    for (int r=0; r<maxr; r++) {               
        for (int c=0; c<other.maxr; c++) {
            double sum;
            sum = 0;
            for (int i=0; i<maxc; i++) {       
                sum += m[r][i] * other.m[c][i];  
            }
            out.m[r][c] = sum;
        }
    }
    out.defined = true;
    return out;
}
Matrix Matrix :: dotT ( const Matrix & other ) { assertDefined ( " " ) ; other . assertDefined ( " " ) ; assertColsEqual ( other , " " ) ; Matrix out ( maxr , other . maxr ) ; for ( int r = 0 ; r < maxr ; r ++ ) { for ( int c = 0 ; c < other . maxr ; c ++ ) { double sum ; sum = 0 ; for ( int i = 0 ; i < maxc ; i ++ ) { sum += m [ r ] [ i ] * other . m [ c ] [ i ] ; } out . m [ r ] [ c ] = sum ; } } out . defined = true ; return out ; }
dot or inner product or classic matrix multiply BUT
the SECOND argument is transposed!
dot or inner product or classic matrix multiply BUT the SECOND argument is transposed!
// use columns from first // sum over columns // go down the transpose