Matrix Multiplication

This is a discussion on Matrix Multiplication within the C++ Programming forums, part of the General Programming Boards category; Thanks for your help, sorry to have bothjered you. Just one last question. Is this along the right lines? Code: ...

  1. #16
    dlf
    dlf is offline
    Registered User
    Join Date
    Nov 2005
    Posts
    17
    Thanks for your help, sorry to have bothjered you. Just one last question.

    Is this along the right lines?

    Code:
    void scaling (double line[][3])
    {
       //double a=0;
       double s;
       double new_line2[2][3];
       
       printf("\nHow much would you like to scale the line by?\nEnter a value between 0 and 1:");
       scanf("%lf", &s);
    
       int scaling_matrix[3][3] = { {s, 0, 0}, {0, s, 0}, {0, 0, s} };
       
    
       //scaling_matrix[0][0]=s;
       //scaling_matrix[1][0]=0;
       //scaling_matrix[2][0]=0;
       //scaling_matrix[0][1]=0;
       //scaling_matrix[1][1]=s;
       //scaling_matrix[2][1]=0;
       //scaling_matrix[0][2]=0;
       //scaling_matrix[1][2]=0;
       //scaling_matrix[2][2]=s;
       
       scaling_multiplication(line, scaling_matrix, new_line2);
       
       printf("\nThe new start coordinates are: (%lf,%lf,%lf)", new_line2[0][0], new_line2[0][1], new_line2[0][2]);
       printf("\nThe new end coordinates are: (%lf,%lf,%lf)", new_line2[1][0], new_line2[1][1], new_line2[1][2]);
    }  
    
    
    void scaling_multiplication (double a[][3], double b[][3], double F[][3])
    {
       //F[0][0]=D[0][0]*E[0][0];
       //F[0][1]=D[1][0]*E[0][1];
       //F[0][2]=D[2][0]*E[0][2];
       //F[1][0]=D[0][1]*E[1][0];
       //F[1][1]=D[1][1]*E[1][1];
       //F[1][2]=D[2][3]*E[1][2];
    int i, j, k;
       for(i=0; i<3; i++)
       {
    	 for(j=0; j<3; j++)
    	 {
    	    for(k=0; k<3; k++)
    	    {
    		  F[i][j] = a[i][k] + b[k][j];
    	    }
    	 }
       }
    }

  2. #17
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Describe in english what you want to do and don't use the term 'scaling' or 'coordinates of a line'.

  3. #18
    dlf
    dlf is offline
    Registered User
    Join Date
    Nov 2005
    Posts
    17
    I want to multiply an array_a[2][3] by another array_b[3][3] and have the results in a final array_c[2][3].

    I think some of the code above may be correct but I have a feeling the equations/calculations are wrong.

    Thaks for being so patient.

  4. #19
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    I want to multiply an array_a[2][3] by another array_b[3][3]
    Describe in detail what you mean by multiplying one array by another array. For instance, do you mean add up all the values in one array and then add up all the values in the other array, and then multiply those two sums together--with the result being a single double value?
    Last edited by 7stud; 12-07-2005 at 07:30 AM.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 02:30 PM
  2. *operator overloading: scalar matrix multiplication
    By gemini_shooter in forum C++ Programming
    Replies: 4
    Last Post: 06-08-2009, 02:14 PM
  3. Matrix Multiplication ( Accessing data from a file ) HELP
    By six_degreez in forum C Programming
    Replies: 2
    Last Post: 07-24-2008, 06:21 PM
  4. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 05:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21