Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix VerticalStacker by Nur Syafi' Maulana Akbar 185150201111060 #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,127 @@
// [2, 3, 4],
// [5, 6, 7]
public class VerticalStacker implements TwoMatricesMapper {


@Override
public byte[][] operate(byte[][] a, byte[][] b) {
byte c[][] = new byte[4][3];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
c[i][j] = a[i][j];
c[i + 2][j] = b[i][j];
}

}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
System.out.printf("%-4s", c[i][j]);
}
System.out.println(" ");
}
return c;
}


@Override
public short[][] operate(short[][] a, short[][] b) {
short c[][] = new short[4][3];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
c[i][j] = a[i][j];
c[i + 2][j] = b[i][j];
}

}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
System.out.printf("%-4s", c[i][j]);
}
System.out.println(" ");
}
return c;
}


@Override
public int[][] operate(int[][] a, int[][] b) {

int c[][] = new int[4][3];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
c[i][j] = a[i][j];
c[i + 2][j] = b[i][j];
}

}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
System.out.printf("%-4s", c[i][j]);
}
System.out.println(" ");
}
return c;
}


@Override
public long[][] operate(long[][] a, long[][] b) {
long c[][] = new long[4][3];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
c[i][j] = a[i][j];
c[i + 2][j] = b[i][j];
}

}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
System.out.printf("%-4s", c[i][j]);
}
System.out.println(" ");
}
return c;


}

@Override
public float[][] operate(float[][] a, float[][] b) {
float c[][] = new float[4][3];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
c[i][j] = a[i][j];
c[i + 2][j] = b[i][j];
}

}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
System.out.printf("%-4s", c[i][j]);
}
System.out.println(" ");
}
return c;


}

@Override
public double[][] operate(double[][] a, double[][] b) {
double c[][] = new double[4][3];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
c[i][j] = a[i][j];
c[i + 2][j] = b[i][j];
}

}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
System.out.printf("%-4s", c[i][j]);
}
System.out.println(" ");
}
return c;
}
}