deathparado's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
8 (0.02 per day)
Joined:
30-April 12
Profile Views:
51
Last Active:
User is offline May 02 2012 09:55 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   deathparado has not set their status

Posts I've Made

  1. In Topic: Matrices multiplying by using vector.

    Posted 1 May 2012

    Nevermind, I had brainfreeze. Thank you for all the help :)!
  2. In Topic: Matrices multiplying by using vector.

    Posted 1 May 2012

    Well..
    vector<vector<double> > MultiplyingMatrix(const vector<vector<double> >& A, const vector<vector<double> >& B, vector< vector<double> > &C)
    {
        int vrows;
        int vcols;
        vrows = A.size();
        vcols = A[1].size();
    
        for (int i = 0; i < vrows; i++)
        {
            for (int j = 0; j < vcols; j++)
            {
                for (int rwcl = 0; rwcl < vcols; rwcl++)
                {
                  C[i][j] += (A[i][rwcl] * B[rwcl][j]);
                }
                cout << C[i][j] << " ";
            }
            cout << endl;
        }
        return C;
    }
    


    That's what I got so far...

    Why can't I display MatrixC [0][3] and [1][3]??
  3. In Topic: Matrices multiplying by using vector.

    Posted 30 Apr 2012

    I know how to multiply matrices on paper..

    Well for mine:

    MatrixA
    (1 2 3)
    (4 5 6)
    MatrixB
    (1 2 3 4)
    (5 6 7 8)
    (9 10 11 12)

    matrixC(should be)
    (38 44 50 56)
    (83 98 113 128)


    Well this is alternative for the multiplying part(nested for loops)
    vector<vector<double> > MultiplyingMatrix(const vector<vector<double> >& x1, const vector<vector<double> >& x2)
    {
        for(int i=0;i<2;i++)
        {
            for(int j=0;j<2;j++)
            {
            x1[i][j]=0; // getting an error.
                for(int k=0;k<2;k++)
                {
                x1[i][j]= x1[i][j]+(x1[i][k]*[k][j]);
                }
            }
        }
        for(int i=0;i<2;i++)
        {
            for(int j=0;j<2;j++)
            {
            cout << [i][j]; //MatricX multiplying
            }
        cout << endl;
        }
    
        return MatrixC;
    }
    
    


    I think I am going into right direction but I still don't understand why I have to use
    vector<vector<double> >
    
    to return MatrixC.
  4. In Topic: Matrices multiplying by using vector.

    Posted 30 Apr 2012

    double MultiplyingMatrix(vector <vector<double> >& x1, vector <vector<double> >& x2)
    {
        for(int row = 0; row < x1.size(); row++)
        {
            for(int col = 0; col < x2[row].size(); col++)
            {
             double answer = double [x1.size()][x2.size()];
            }
            cout << endl;
        }
        return vector <vector<double> answer>;
    }
    
    

    Not even sure I am going in right direction..
  5. In Topic: Matrices multiplying by using vector.

    Posted 30 Apr 2012

    View Postr.stiltskin, on 30 April 2012 - 07:12 PM, said:

    My suggestion for multiplying is that you don't use push_back at all to create each row in MultiplyingMatrix. It will be much easier if you first create a vector<vector<double> > matrix of the correct size filled with 0s, and then you can use ordinary matrix notation, x2[i][j], to access the elements.

    Look at the second form of constructor shown on this vector reference page. It shows you how to create a vector of a specific size filled with "n" copies of a specific value.

    Do you know how to determine the size of the "answer" matrix when you multiply two matrices?


    Edit: sorry, that was partially wrong. Use the "explicit vector" constructor mentioned above to create one row of 0s of the required size. Then use push_back to push that vector<double> into the vector<vector<double> > to create the full matrix. You only have to create 1 row. Then you can push_back that 1 row as many times as you want in a loop. That will automatically create multiple copies of the row.

    I am on the part where trying to figure out returning "answer" matrix.. Do i have to return it on each of the parameter?


    So do I even need MatrixC? I mean if you are suggesting using the "explicit vector" I don't think it's necessary to have one.
    vector <vector<double> > MatrixC;
    
    vector <double> rowC;
    
    for(int i=0; i<4; i++)
    rowC.push_back(0.0);
    for(int i=0; i<2;i++)
    MatrixC.push_back(rowC);
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

deathparado hasn't added any friends yet.

Comments

deathparado has no profile comments yet. Why not say hello?