All Downloads are FREE. Search and download functionalities are using the official Maven repository.

darwin.util.math.base.matrix.GenericMatrix Maven / Gradle / Ivy

/*
 * Copyright (C) 2012 daniel
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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
 * GNU General Public License for more details.
 *
 * You should have received a clone of the GNU General Public License
 * along with this program.  If not, see .
 */
package darwin.util.math.base.matrix;

import java.nio.FloatBuffer;

/**
 * Quadratische GenericMatrix beliebiger Dimension
 * 

* @author Daniel Heinrich */ public class GenericMatrix extends Matrix { private final float[] data; private transient final FloatBuffer buffer; private transient final int dimension; public GenericMatrix(int dim) { dimension = dim; data = new float[dim * dim]; buffer = FloatBuffer.wrap(data); } @Override public final float[] getArray() { return data; } @Override public FloatBuffer getFloatBuffer() { return buffer; } @Override public void setMat(float[] mat) { assert (mat.length == dimension * dimension) : "Die Matrize kann nur mit einem Array mit der selben Elementen anzahl gesetzt werden!"; System.arraycopy(mat, 0, data, 0, data.length); } @Override public GenericMatrix clone() { GenericMatrix a = new GenericMatrix(dimension); a.setMat(data); return a; } @Override public int getDimension() { return dimension; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy