if (index < data.length) {
throw new IllegalArgumentException("Not enough data");
}
Matrix F[] = new Matrix[outerTerms];
Matrix G[] = new Matrix[outerTerms];
Matrix u[][] = new Matrix[outerTerms][];
Matrix v[][] = new Matrix[outerTerms][];
Matrix Fc[] = new Matrix[3];
Matrix Gc[] = new Matrix[3];
index = 0;
for (int i = 0; i < outerTerms; i++) {
F[i] = new Matrix(new MatrixBuffer(
data, thetaOutCount, phiOutCount, index, phiOutCount, 1));
index += thetaOutCount * phiOutCount;
G[i] = new Matrix(new MatrixBuffer(
data, thetaPCount, phiPCount, index, phiPCount, 1));
index += thetaPCount * phiPCount;
u[i] = new Matrix[innerTerms];
v[i] = new Matrix[innerTerms];
for (int j = 0; j < innerTerms; j++) {
u[i][j] = new Matrix(new MatrixBuffer(
data, thetaPCount, 1, index, 1, 1));
index += thetaPCount;
v[i][j] = new Matrix(new MatrixBuffer(
data, phiPCount, 1, index, 1, 1));
index += phiPCount;
}
}
int FcOffset = index;
int GcOffset = index + thetaOutCount * phiOutCount * 3;
for (int i = 0; i < 3; i++) {
Fc[i] = new Matrix(new MatrixBuffer(
data, thetaOutCount, phiOutCount, FcOffset + i, 3 * phiOutCount, 3));
Gc[i] = new Matrix(new MatrixBuffer(
data, thetaPCount, phiPCount, GcOffset + i, 3 * phiPCount, 3));
}
return new FactoredMaterial(F, G, u, v, Fc, Gc, cm);