assign5/mat.cpp
// This computes the mean of every column and puts it into a row vector
// WARNING: allocates new matrix for answer
This computes the mean of every column and puts it into a row vector
WARNING: allocates new matrix for answer
This computes the mean of every column and puts it into a row vector WARNING : allocates new matrix for answer
Matrix Matrix::meanVec()
{
    Matrix mean(1, maxc);
    for (int c=0; c<maxc; c++) {
        double sum;
        sum = 0;
        for (int r=0; r<maxr; r++) {
            sum += m[r][c];
        }
        mean.m[0][c] = sum/maxr;
    }
    mean.defined = true;
    return mean;
}
Matrix Matrix :: meanVec ( ) { Matrix mean ( 1 , maxc ) ; for ( int c = 0 ; c < maxc ; c ++ ) { double sum ; sum = 0 ; for ( int r = 0 ; r < maxr ; r ++ ) { sum += m [ r ] [ c ] ; } mean . m [ 0 ] [ c ] = sum / maxr ; } mean . defined = true ; return mean ; }
This computes the mean of every column and puts it into a row vector
WARNING: allocates new matrix for answer
This computes the mean of every column and puts it into a row vector WARNING : allocates new matrix for answer