Home Answers Viewqa Java-Beginners code for multiplication of matrix in java using methods

 
 


kharish
code for multiplication of matrix in java using methods
2 Answer(s)      2 years and 2 months ago
Posted in : Java Beginners

code for multiplication of matrix in java using methods

View Answers

April 20, 2011 at 10:55 AM


   import java.util.*;
    class MatrixMultiplication{

        public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int[][] A = new int[3][3];
    int[][] B = new int[3][3];
    int[][] C = new int[3][3];
    System.out.println("Enter elements for matrix A : ");
    for (int i=0 ; i < A.length ; i++)
    for  (int j=0 ; j < A[i].length ; j++){
    A[i][j] = input.nextInt();
    }
    System.out.println("Enter elements for matrix B : ");
    for (int i=0 ; i < B.length ; i++)
    for  (int j=0 ; j < B[i].length ; j++){
    B[i][j] = input.nextInt();
    }
    System.out.println("Matrix A: ");
            for (int i=0 ; i < A.length ; i++){
                System.out.println();
                for  (int j=0 ; j < A[i].length ; j++){
                    System.out.print(A[i][j]+" ");
                      }
            }
    System.out.println();
    System.out.println();
    System.out.println("Matrix B: ");
            for (int i=0 ; i < B.length ; i++){    
                System.out.println();
                for  (int j=0 ; j < B[i].length ; j++){
                    System.out.print(B[i][j]+" ");
                      }
            }
    System.out.println();
    System.out.println();
    System.out.println("Result is: ");
    System.out.println();

    for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
    for(int k=0;k<3;k++){
    C[i][j]+=A[i][k]*B[k][j];
    }
    }
    }
    for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
    System.out.print(+C[i][j]+" ");
    }
    System.out.println();
    } 
    }
    }

October 28, 2011 at 10:12 PM


for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ for(int k=0;k<3;k++){ C[i][j]+=A[i][k]*B[k][j]; } } } It is a super formula for Multiplication of matrix

I also did this by using the following code

for(int i=1,c=1,d=1,p=1,o=1;o<=3;o++,++c,++p){ for(int j=1,q=1;j<=3;j++,++q){
z[p][q]=x[c][d]y[i][j]+x[c][d+1]y[i+1][j]+x[c][d+2]*y[i+2][j]; } }

the codeing which I done seems to be more complicated but I did with only two "for loops"









Related Pages:
code for multiplication of matrix in java using methods
code for multiplication of matrix in java using methods  code for multiplication of matrix in java using methods
parallel dense matrix multiplication
using dense parallel matrix multiplication. I request you to kindly provide me a code for Parallel Matrix multiplication on distributed systems using Java...parallel dense matrix multiplication  hi friends, i am a final year
Multiplication of two Matrix
Multiplication of Two Matrix   .... The Java two dimensional array  program is operate to the two matrix number. In this program also provided Java source code with understanding the Java
Multiplication of two Matrix
for multiplying two matrix to each other. Here providing you Java source code... by using the array1.length. After getting both matrix then multiply to it. Both matrix will be multiplied to each other by using 'for' loop. So the output
multiplication
multiplication  multiplication of two number numbers entered by user minimum 100digits using GUI   Java Multiplication of two 100 digits number import java.awt.*; import java.math.*; import javax.swing.*; import
multiplication
multiplication  multiplication of two number numbers entered by user minimum 100digits using GUI   Java Multiplication of two 100 digits number import java.awt.*; import java.math.*; import javax.swing.*; import
Matrix multiplication in java
Matrix multiplication in java In this section we will learn about multiplication of two matrices. In java this is a simple program to multiply two matrices... two-dimensional array. Here we are going to develop a Java code for matrices
Matrix multiplication
Matrix multiplication  program to read the elements of the given two matrices of order n*n and to perform the matrix multiplication
Matrix Addition using RMI in Java
Matrix Addition using RMI in Java  Source Code for Matrix Addition using RMI in Java
determinant of n*n matrix using java code
determinant of n*n matrix using java code  Here is my code... Scanner(System.in); System.out.println("enter dimension of matrix"); N...]; } System.out.println("enter the elements of matrix"); for(int i=0;i<N;i
Find sum of all the elements of matrix using Java
Find sum of all the elements of matrix using Java A matrix is a rectangular array of numbers. The numbers in the matrix are called its entries or its elements. A matrix with m rows and n columns is called m-by-n matrix or m × n matrix
Java, matrix
"); System.out.println("3. Multiplication Of Matrix"); System.out.println("4. Exit"); boolean quit...Java, matrix  java program to get output on the basis of users choice of switch statement perform operations addition, subtraction and multiplication
Java Transpose of a matrix
Java Transpose of a matrix In this section, you will learn how to determine... to create a matrix. Then using the for loop statements, turn all the rows of the matrix into columns and vice-versa. Here is the code: import java.util.
java program_big digits multiplication..
java program_big digits multiplication..  i want program about big digits multiplication program using java..plz tel me answer
matrix calculator - Java Beginners
matrix calculator  hi..... can you help me in writing source code of matrix calculator in java... i know you are the best you can do it!!! show yourself
Java Matrix Multiplication Example
Java Matrix Multiplication Example In this tutorial, you will learn how... the multiplication of two matrices of any order. In the given program, firstly we have... and then accept the matrix elements as array elements. We have declared two
Dividing of two Matrix in Java
Dividing of two Matrix in Java   ...;Here you will learn how to use two matrix array for developing Java program.  The java two dimensional array program is operate the two matrix. Now we
Get the color values as a matrix of color image
Get the color values as a matrix of color image  I am new to java... image for giving input to the compression algorithm by using java. plz provide the java code for the above mentioned process
Matrix Example in Java
Matrix Example in Java       In Java tutorial, you will learn about array and matrix. An array... int data type. Matrix: A matrix is a collection of data in rows and columns format
using class and methods - Java Beginners
using class and methods  Sir,Plz help me to write this below pgm. here is the question: Assume a table for annual examination results for 10... the following code: import java.util.*; public class Student{ int rollNo
Create Multiplication Table from 1 to 10
Create Multiplication Table in Java In this section, you will learn how to create multiplication table from 1 to 10. For this purpose, we have created 2-dimensional Array 'array[][]' and using the for loop, we have stored the product
Matrix - Java Beginners
Matrix  give me the Matrix program   Hi friend, Code for Matrix Example in Java class MatrixExample{ public static void main...(" ]"); } System.out.println(); } } For more information on java visit to : http
Functions and Methods
the frequency of each vowel. (5) Write a program in Java to input a string using...Functions and Methods  (1) Write a program in java to input 10... in java to input day number. Use a function daysofweek(int dysno) to accept
Multiplication of two polynomials using linked list in java
Multiplication of two polynomials using linked list in java  I am doing a program "Multiplication of two polynomials using linked list in java" for our curriculum, can you please help me in this. Rajesh    //Class
How to Create Create Matrix of any order
Create Matrix of any order Java Program A matrix is a rectangular array of numbers.The numbers in the matrix are called its entries or its elements. A matrix... Matrix: 1 2 3 4 3x3 Matrix: 1 2 3 2 3 4 4 5 6 Here is the code
Sum of two Matrix
the matrix. The both matrix will be added by using the for loop with array[i][j... Sum of  two Matrix       In this section, we are going to calculate the sum of two matrix
Multiplication table
Multiplication table  Using Net beans Design and develop a program... number than Display that particular multiplication table   import java.util.Scanner; class Multiplication { public static void main(String args
Multiplication table
Multiplication table Net Beans  Using Net beans Design and develop... for ending number than Display that particular multiplication table   import java.util.Scanner; class Multiplication { public static void main
Display tow dimensional array by matrix form using one for loop in java
Display tow dimensional array by matrix form using one for loop in java  Display tow dimensional array by matrix form using one for loop in java
Object-Oriented Implementation of Numerical Methods - Java Tutorials
Object-Oriented Implementation of Numerical Methods 2002-04-01 The Java...-written Java code, Dr. Besset also tackles issues such as the problems that happen... of Numerical Methods Author: Dr. Heinz M. Kabutz If you are reading
matrix adddition
matrix adddition   how to write a program matrix addition in java
How to Create Multiplication Table from 1 to 10?
to 10 using in Java programming language. I had read an articles last month where...How to Create Multiplication Table from 1 to 10?  Hi, I want to develop an small application store products. So, i how to create multiplication
Java create Identity matrix
Java create Identity matrix In this tutorial, you will learn how to create an identity or unit matrix. An identity matrix is a square matrix, of size n x n... dimensions say (n*n). The given code accepts the size(n) of unit matrix
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........  code for a simple java...,multiplication,division
Callback Methods
to the system to the request is calling back from, But java performs the same thing by using... Callback Methods       Callbacks methods are the way of managing life cycle of an instance. Callback
An application using swings and vector methods
An application using swings and vector methods   Hi, I want an application in Java swings which uses good selection of Vectors methods
Multiplication problem - Java Beginners
Multiplication problem  I am facing a peculiar problem in java regarding a multiplication. Please see below: 19300 * 0.001 = 19.3 19400 * 0.001 = 19.400000000000002 (why is this ??) 19500 * 0.001 = 19.5 Can anybody help
transpose matrix
transpose matrix  write a program in java to declare a square... integers into the matrix and print the transpose of it. for this program u r given answer but if i entered 2 by 3 matrix it will not give answer ple check it once
native methods
native methods  what is native methods in java?   A native method is a method that is implemented in a language other than Java. The Java... into Java. To use Java as a scientific and high performance language, when
matrix determination in java
matrix determination in java  hai
RIAs Methods And Techniques
RIAs Methods And Techniques JavaScript It is the first major client side language technology that has the ability to run code and installed on several major... in DHTML makes possible to piece together an RIA system without using unified client
transpose of matrix
transpose of matrix  write a program in java to declare a square matrices 'A' or order n which is less than 20.allow in user to input only positive integers into the matrix and print the transpose
java code - Java Beginners
java code  2x2 matrix multiplication code  Hi Friend, Here is the java code into which we have created two 2 x 2 Matrices array1[2][2] and array2[2][2] and result matrix after multiplication is being saved
how to enter matrix data into a table of swings - Java Beginners
and insert the data into that table using swings...........matrix can be anything...how to enter matrix data into a table of swings   Hi frends, I want to display a matrix data into a particular table...... Actually if the user
Find determinant of a matrix in Java Programming
Find determinant of a matrix in Java Programming A determinant is a real number associated with every square matrix or, you can say it is a rectangular array... for measure when the matrix is regarded as a linear transformation. Here we
Functions and Methods
Functions and Methods  Write a Java program to input the sides of a triangle. Pass the sides to a function decide(int x,int y,int z) which checks...;The given code accepts the sides of triangle from the user. Pass the sides
Overriding methods
Overriding methods  How to use overriding method in the java progrem?   The overriding method are define in the subclass that has same name...:- The above code demonstrates you the overriding method.we have created a class
java string multiplication
java string multiplication  Is there any simple method of string multiplication in java ..?   public class StringMultiplication { public static void main(String[] args) { String number1 = "17"; String number2
multiplication algorithms in java divide and conquer
multiplication algorithms in java divide and conquer  I need multiplication algorithms in java divide and conquer ask from user input two numbers in binary then the program multiply two number use multiplication algorithm in java
multiplication algorithms in java divide and conquer
multiplication algorithms in java divide and conquer  I need multiplication algorithms in java divide and conquer ask from user input two numbers in binary then the program multiply two number use multiplication algorithm in java