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

org.ejml.data.FMatrix3x3 Maven / Gradle / Ivy

Go to download

A fast and easy to use dense and sparse matrix linear algebra library written in Java.

There is a newer version: 0.43.1
Show newest version
/*
 * Copyright (c) 2009-2018, Peter Abeles. All Rights Reserved.
 *
 * This file is part of Efficient Java Matrix Library (EJML).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.ejml.data;

import org.ejml.ops.MatrixIO;

/**
 * Fixed sized 3 by FMatrix3x3 matrix.  The matrix is stored as class variables for very fast read/write.  aXY is the
 * value of row = X and column = Y.
 * 

DO NOT MODIFY. Automatically generated code created by GenerateMatrixFixedNxN

* * @author Peter Abeles */ public class FMatrix3x3 implements FMatrixFixed { public float a11,a12,a13; public float a21,a22,a23; public float a31,a32,a33; public FMatrix3x3() { } public FMatrix3x3( float a11, float a12, float a13, float a21, float a22, float a23, float a31, float a32, float a33) { this.a11 = a11; this.a12 = a12; this.a13 = a13; this.a21 = a21; this.a22 = a22; this.a23 = a23; this.a31 = a31; this.a32 = a32; this.a33 = a33; } public FMatrix3x3( FMatrix3x3 o ) { this.a11 = o.a11; this.a12 = o.a12; this.a13 = o.a13; this.a21 = o.a21; this.a22 = o.a22; this.a23 = o.a23; this.a31 = o.a31; this.a32 = o.a32; this.a33 = o.a33; } public void set( float a11, float a12, float a13, float a21, float a22, float a23, float a31, float a32, float a33) { this.a11 = a11; this.a12 = a12; this.a13 = a13; this.a21 = a21; this.a22 = a22; this.a23 = a23; this.a31 = a31; this.a32 = a32; this.a33 = a33; } @Override public float get(int row, int col) { return unsafe_get(row,col); } @Override public float unsafe_get(int row, int col) { if( row == 0 ) { if( col == 0 ) { return a11; } else if( col == 1 ) { return a12; } else if( col == 2 ) { return a13; } } else if( row == 1 ) { if( col == 0 ) { return a21; } else if( col == 1 ) { return a22; } else if( col == 2 ) { return a23; } } else if( row == 2 ) { if( col == 0 ) { return a31; } else if( col == 1 ) { return a32; } else if( col == 2 ) { return a33; } } throw new IllegalArgumentException("Row and/or column out of range. "+row+" "+col); } @Override public void set(int row, int col, float val) { unsafe_set(row,col,val); } @Override public void unsafe_set(int row, int col, float val) { if( row == 0 ) { if( col == 0 ) { a11 = val; return; } else if( col == 1 ) { a12 = val; return; } else if( col == 2 ) { a13 = val; return; } } else if( row == 1 ) { if( col == 0 ) { a21 = val; return; } else if( col == 1 ) { a22 = val; return; } else if( col == 2 ) { a23 = val; return; } } else if( row == 2 ) { if( col == 0 ) { a31 = val; return; } else if( col == 1 ) { a32 = val; return; } else if( col == 2 ) { a33 = val; return; } } throw new IllegalArgumentException("Row and/or column out of range. "+row+" "+col); } @Override public void set(Matrix original) { if( original.getNumCols() != 3 || original.getNumRows() != 3 ) throw new IllegalArgumentException("Rows and/or columns do not match"); FMatrix m = (FMatrix)original; a11 = m.get(0,0); a12 = m.get(0,1); a13 = m.get(0,2); a21 = m.get(1,0); a22 = m.get(1,1); a23 = m.get(1,2); a31 = m.get(2,0); a32 = m.get(2,1); a33 = m.get(2,2); } @Override public int getNumRows() { return 3; } @Override public int getNumCols() { return 3; } @Override public int getNumElements() { return 9; } @Override public T copy() { return (T)new FMatrix3x3(this); } @Override public void print() { MatrixIO.print(System.out, this); } @Override public T createLike() { return (T)new FMatrix3x3(); } @Override public MatrixType getType() { return MatrixType.UNSPECIFIED; }}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy