public Matrix rMult(Matrix M){
        if (columns==M.getRows()){
            int i=1; int j=1; int k=1;double s=0;
            int c=M.getColumns();
            Matrix S=new Matrix(rows,c);
            while (i<=rows){
                while (j<=c){
                    while (k<=columns){
                        s+=elements[i-1][k-1]*M.get(k, j);
                        k++;
                    }
                    k=1;
                    S.set(i, j, s);
                    s=0;
                    j++;
                }
                j=1;
                i++;
            }
            return S;
        }else{
            System.out.println("Wrong sizes, Matrices can not be multed");
            return null;
        }
    }