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