Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Matrix Addition

Matrix Addition

Scheduled Pinned Locked Moved C#
csharphelp
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chitra4sat
    wrote on last edited by
    #1

    Hi All, I am new to programming with C#. I have been asked to calulate the sum of the 2x2 matrix and it should display the output on the third matrix. I tried a lot but i could not able to get it. if there is any link also pls send me. pls help me. regards, Chitra

    S K 4 Replies Last reply
    0
    • C chitra4sat

      Hi All, I am new to programming with C#. I have been asked to calulate the sum of the 2x2 matrix and it should display the output on the third matrix. I tried a lot but i could not able to get it. if there is any link also pls send me. pls help me. regards, Chitra

      S Offline
      S Offline
      sherifffruitfly
      wrote on last edited by
      #2

      What code do you have? I take it you haven't tried google - why not?

      C 1 Reply Last reply
      0
      • S sherifffruitfly

        What code do you have? I take it you haven't tried google - why not?

        C Offline
        C Offline
        chitra4sat
        wrote on last edited by
        #3

        hey i tried google also but i could not able to get the correct thing which i m needed. regatds, Chitra.

        1 Reply Last reply
        0
        • C chitra4sat

          Hi All, I am new to programming with C#. I have been asked to calulate the sum of the 2x2 matrix and it should display the output on the third matrix. I tried a lot but i could not able to get it. if there is any link also pls send me. pls help me. regards, Chitra

          K Offline
          K Offline
          Keshav V Kamat 0
          wrote on last edited by
          #4

          hello chitra. the following link might probably help you. http://www.extremeoptimization.com/mathematics/samples/MSharp.aspx

          Keshav Kamat :) India

          1 Reply Last reply
          0
          • C chitra4sat

            Hi All, I am new to programming with C#. I have been asked to calulate the sum of the 2x2 matrix and it should display the output on the third matrix. I tried a lot but i could not able to get it. if there is any link also pls send me. pls help me. regards, Chitra

            K Offline
            K Offline
            Keshav V Kamat 0
            wrote on last edited by
            #5

            the earlier link was for a M# language. this link is much better http://www.codeproject.com/csharp/psdotnetmatrix.asp

            Keshav Kamat :) India

            1 Reply Last reply
            0
            • C chitra4sat

              Hi All, I am new to programming with C#. I have been asked to calulate the sum of the 2x2 matrix and it should display the output on the third matrix. I tried a lot but i could not able to get it. if there is any link also pls send me. pls help me. regards, Chitra

              K Offline
              K Offline
              Keshav V Kamat 0
              wrote on last edited by
              #6

              Check this link as well. http://www.extremeoptimization.com/QuickStart/MatrixVectorOperationsCS.aspx

              Keshav Kamat :) India

              C 1 Reply Last reply
              0
              • K Keshav V Kamat 0

                Check this link as well. http://www.extremeoptimization.com/QuickStart/MatrixVectorOperationsCS.aspx

                Keshav Kamat :) India

                C Offline
                C Offline
                chitra4sat
                wrote on last edited by
                #7

                Hi Keshav, Thanks for your reply. And i tried it like this. here is the code for ur ref I am running it in the console application Matrix.cs file namespace MatrixAddition { public class Matrix { public double[,] Data; public Matrix(double[,] data) { Data = data; } public static Matrix operator +(Matrix M1, Matrix M2) { int r1 = M1.Data.GetLength(0); int c1 = M1.Data.GetLength(1); int r2 = M2.Data.GetLength(0); int c2 = M2.Data.GetLength(1); double[,] res = new double[r1, c1]; for (int i = 0; i < r1; i++) { for (int j = 0; j < c1; j++) { res[i, j] = M1.Data[i, j] + M2.Data[i, j]; } } return new Matrix(res); } } } them i am trying to call it in the main fumction but i could not able to get it. pls correct my code in the matrix.cs page and tell me how to call it in the main program. waiting for reply regards, chitra.

                K 1 Reply Last reply
                0
                • C chitra4sat

                  Hi Keshav, Thanks for your reply. And i tried it like this. here is the code for ur ref I am running it in the console application Matrix.cs file namespace MatrixAddition { public class Matrix { public double[,] Data; public Matrix(double[,] data) { Data = data; } public static Matrix operator +(Matrix M1, Matrix M2) { int r1 = M1.Data.GetLength(0); int c1 = M1.Data.GetLength(1); int r2 = M2.Data.GetLength(0); int c2 = M2.Data.GetLength(1); double[,] res = new double[r1, c1]; for (int i = 0; i < r1; i++) { for (int j = 0; j < c1; j++) { res[i, j] = M1.Data[i, j] + M2.Data[i, j]; } } return new Matrix(res); } } } them i am trying to call it in the main fumction but i could not able to get it. pls correct my code in the matrix.cs page and tell me how to call it in the main program. waiting for reply regards, chitra.

                  K Offline
                  K Offline
                  Keshav V Kamat 0
                  wrote on last edited by
                  #8

                  I am not sure but this might help you. this is a simple link explaining, how functions are called in the main class. http://fullycoded.com/?p=203

                  Keshav Kamat :) India

                  C 1 Reply Last reply
                  0
                  • K Keshav V Kamat 0

                    I am not sure but this might help you. this is a simple link explaining, how functions are called in the main class. http://fullycoded.com/?p=203

                    Keshav Kamat :) India

                    C Offline
                    C Offline
                    chitra4sat
                    wrote on last edited by
                    #9

                    Thanks for your help . regards, chitra.

                    K 1 Reply Last reply
                    0
                    • C chitra4sat

                      Thanks for your help . regards, chitra.

                      K Offline
                      K Offline
                      Keshav V Kamat 0
                      wrote on last edited by
                      #10

                      u r welcome :)

                      Keshav Kamat :) India

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups