t0xicv4p0r

Untitled

Feb 5th, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package learningjava;
  2.  
  3. public class SMatrix {
  4.  
  5.     private int order;
  6.     private double[][] values = new double[order][order];
  7.  
  8.     // private static double[] column;
  9.     public SMatrix(int order, double[][] values) {
  10.         this.order = order;
  11.         this.values = values;
  12.     }
  13.  
  14.     public SMatrix(SMatrix m) {
  15.         this(m.order, m.values);
  16.     }
  17.  
  18.     public String toString() {
  19.         String s = "";
  20.         for (int i = 0; i < order; i++) {
  21.             for (int j = 0; j < order; j++) {
  22.                 s += values[i][j] + "\t";
  23.                 if (j == order - 1)
  24.                     s += "\n\n";
  25.             }
  26.  
  27.         }
  28.         return s;
  29.     }
  30.  
  31.     public static void main(String[] args) {
  32.         double[][] test = { { 1, 2 ,3 }, { 3, 4, 5 } , {5,6,7}};
  33.  
  34.         SMatrix m = new SMatrix(3, test);
  35.         System.out.println(m.toString());
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment