/* Matrix.java * * Copyright (c) 2001, Ted Nelson and Tuomas Lukka * * You may use and distribute under the terms of either the GNU Lesser * General Public License, either version 2 of the license or, * at your choice, any later version. Alternatively, you may use and * distribute under the terms of the XPL. * * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of * the licenses. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the README * file for more details. * */ /* * Written by Tero Mäyränen */ package org.gzigzag.module.raytrace; import java.awt.*; /* * "No-one can be told what The Matrix is... you have to see it for yourself" * - Morpheus */ public class Matrix { public static final String rcsid = "$Id: Matrix.java,v 1.1 2002/10/07 12:37:35 tuukkah Exp $"; protected int n, m; protected double[] data; public int getn() { return n; } public int getm() { return m; } public double[] getdata() { return data; } public Matrix(int mn, int mm) { n = mn; m = mm; data = new double[m * n]; int ix = 0; for (int i=0; i S[i]) S[i] = t; } } for (int k=0; k big) { big = t; pivot = i; } } int tmp = O[pivot]; O[pivot] = O[k]; O[k] = tmp; } */ /* // Gauss-Jordan with full pivoting public static void invert(Matrix M1, Matrix M2) throws IndexOutOfBoundsException { M2.set(M1); int mn = M2.getn(); double A[] = M2.getdata(); double big, dum, piv, temp; int icol=0, irow=0; int indxc[] = new int[mn]; int indxr[] = new int[mn]; int ipiv[] = new int[mn]; for (int j=0; j= big) { big = temp; irow = j; icol = k; } } else if (ipiv[k] > 1) throw new IndexOutOfBoundsException(); } } } ipiv[icol]++; if (irow != icol) { for (int l=0; l=0; l--) { if (indxr[l] != indxc[l]) { for (int k=0; k