Basic C++ code for multiplication of 2 matrix or vectors (C++ beginner)
        Posted  
        
            by 
                Ice
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Ice
        
        
        
        Published on 2012-04-07T04:15:56Z
        Indexed on 
            2012/04/07
            5:30 UTC
        
        
        Read the original article
        Hit count: 223
        
I am a new C++ user and I am also doing a major in Maths so thought I would try implement a simple calculator. I got some code off the internet and now I just need help to multiply elements of 2 matrices or vectors.
Matrixf multiply(Matrixf const& left, Matrixf const& right) {
    // error check
    if (left.ncols() != right.nrows()) {
        throw std::runtime_error("Unable to multiply: matrix dimensions not agree.");
    }
    /* I have all the other part of the code for matrix*/
    /** Now I am not sure how to implement multiplication of vector or matrix.**/
    Matrixf ret(1, 1);
    return ret;
}
        © Stack Overflow or respective owner