Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. /*Prints a graphical representation of the matrix to ease understanding*/
  2.     public static void visualizeMatrix(double [][] matrix)
  3.     {
  4.         if(matrix != null)
  5.         {
  6.             for(int i = 0; i < matrix.length; i++)
  7.             {
  8.                 //           Index starts at 1 in mathematical terms
  9.                 String row = (i+1) + ". " ;
  10.                
  11.                 for(int j = 0; j < matrix[i].length; j++)
  12.                 {
  13.                     row += "[" + matrix[i][j] + "]";
  14.                 }
  15.                
  16.                 System.out.println(row);
  17.             }
  18.             System.out.println();
  19.         }else {
  20.             System.out.println("Matrix is null");
  21.         }
  22.     }
  23.    
  24.     /*Prints a graphical representation of the matrix to ease understanding*/
  25.     public static void visualizeMatrix(int [][] matrix)
  26.     {
  27.         if(matrix != null)
  28.         {
  29.             for(int i = 0; i < matrix.length; i++)
  30.             {
  31.                 //           Index starts at 1 in mathematical terms
  32.                 String row = (i+1) + ". ";
  33.                
  34.                 for(int j = 0; j < matrix[i].length; j++)
  35.                 {
  36.                     row += "[" + matrix[i][j] + "]";
  37.                 }
  38.                
  39.                 System.out.println(row);
  40.             }
  41.             System.out.println();
  42.         }else {
  43.             System.out.println("Matrix is null");
  44.         }
  45.     }
  46.    
  47.     /*Prints a graphical representation of vector*/
  48.     public static void visualizeVector(int [] vector)
  49.     {
  50.         if(vector!= null)
  51.         {
  52.             String row = "1. ";
  53.            
  54.             for(int i = 0; i < vector.length; i++)
  55.             {
  56.                 row += "[" + vector[i] + "]";
  57.             }
  58.  
  59.             System.out.println(row + "\n");
  60.         }else {
  61.             System.out.println("Vector is null");
  62.         }
  63.     }
  64.    
  65.     /*Prints a graphical representation of vector*/
  66.     public static void visualizeVector(double [] vector)
  67.     {
  68.         if(vector!= null)
  69.         {
  70.             String row = "1. ";
  71.            
  72.             for(int i = 0; i < vector.length; i++)
  73.             {
  74.                 row += "[" + vector[i] + "]";
  75.             }
  76.            
  77.             System.out.println(row + "\n");
  78.         }else {
  79.             System.out.println("Vector is null");
  80.         }
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement