assign3/mat.cpp
// should do in a more numerically stable way
should do in a more numerically stable way
should do in a more numerically stable way
double Matrix::stddevCol(int c) const
{
    double sum, sum2;
    assertDefined("sum");
    checkBounds(0, c, "stddevCol");
    sum = sum2 = 0.0;
    for (int r=0; r<maxr; r++) {
        sum += m[r][c];
        sum2 += m[r][c]*m[r][c];
    }
    return sqrt(sum2/maxr - (sum*sum)/(maxr*maxr));  
}
double Matrix :: stddevCol ( int c ) const { double sum , sum2 ; assertDefined ( " " ) ; checkBounds ( 0 , c , " " ) ; sum = sum2 = 0.0 ; for ( int r = 0 ; r < maxr ; r ++ ) { sum += m [ r ] [ c ] ; sum2 += m [ r ] [ c ] * m [ r ] [ c ] ; } return sqrt ( sum2 / maxr - ( sum * sum ) / ( maxr * maxr ) ) ; }
should do in a more numerically stable way
should do in a more numerically stable way
// not the most stable way to compute!!