com.ericbarnhill.arrayMath.MathArrayFloat3D.java Source code

Java tutorial

Introduction

Here is the source code for com.ericbarnhill.arrayMath.MathArrayFloat3D.java

Source

/*
 * (c) Eric Barnhill 2016 All Rights Reserved.
 *
 * This file is part of Java ArrayMath. Java ArrayMath 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.
 * 
 * Java ArrayMath 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 copy of 
 * the GNU General Public License along with Java ArrayMath.  If not, see http://www.gnu.org/licenses/ .
 * 
 * This code uses software from the Apache Software Foundation. The Apache Software License can be found at: http://www.apache.org/licenses/LICENSE-2.0.txt .
 */

package com.ericbarnhill.arrayMath;

import org.apache.commons.math4.complex.Complex;

/**
 * Implementation of MathArray for {@code float[][][]} objects.
 * 
 * <p> Note that even operations reserved for doubles in {@code java.util.Math} are available in the {@code float} MathArrays.
 * The object converts the values to {@code double} and back. 
 * @author ericbarnhill
 * @see MathArray
 * @see MathArrayFactory
 * @see ArrayMath
 * @since 0.1
 *
 */

public class MathArrayFloat3D extends MathArray<float[][][]> {

    protected MathArrayFloat3D(float[][][] f, int type, int nDims) {
        super(f, type, nDims);
    }

    @Override
    public float[][][] getArray() {
        return f;
    }

    @Override
    protected MathArrayFloat3D abs() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.abs(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    protected MathArrayFloat3D absC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.absC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D acos() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.acos(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D acosC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.acosC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    protected MathArrayFloat3D add(double g) {
        return new MathArrayFloat3D(ArrayMath.add(f, (float) g), getType(), getnDims());
    }

    protected MathArrayFloat3D add(float g) {
        return new MathArrayFloat3D(ArrayMath.add(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D add(Complex g) {
        throw new ClassCastException("Cannot add Complex number to double array");
    }

    @Override
    protected MathArrayFloat3D add(MathArray<float[][][]> g) {
        return new MathArrayFloat3D(ArrayMath.add(f, g.getArray()), getType(), getnDims());
    }

    protected MathArrayFloat3D add(float[][][] g) {
        return new MathArrayFloat3D(ArrayMath.add(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D addC(double g) {
        return new MathArrayFloat3D(ArrayMath.addC(f, (float) g), getType(), getnDims());
    }

    protected MathArrayFloat3D addC(float g) {
        return new MathArrayFloat3D(ArrayMath.addC(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D addC(Complex g) {
        throw new ClassCastException("Cannot add Complex number to double array");
    }

    @Override
    protected MathArrayFloat3D addC(MathArray<float[][][]> g) {
        return new MathArrayFloat3D(ArrayMath.addC(f, g.getArray()), getType(), getnDims());
    }

    protected MathArrayFloat3D asin() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.asin(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D asinC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.asinC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D atan() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.atan(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D atanC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.atanC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    protected MathArrayFloat3D ceil() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.ceil(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    protected MathArrayFloat3D ceilC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.ceilC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D cos() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.cos(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D cosC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.cosC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D cosh() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.cosh(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D coshC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.coshC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    protected MathArrayFloat3D divide(double g) {
        return new MathArrayFloat3D(ArrayMath.divide(f, (float) g), getType(), getnDims());
    }

    protected MathArrayFloat3D divide(float g) {
        return new MathArrayFloat3D(ArrayMath.divide(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D divide(Complex g) {
        throw new ClassCastException("Cannot divide Complex number to double array");
    }

    @Override
    protected MathArrayFloat3D divide(MathArray<float[][][]> g) {
        return new MathArrayFloat3D(ArrayMath.divide(f, g.getArray()), getType(), getnDims());
    }

    protected MathArrayFloat3D divide(float[][][] g) {
        return new MathArrayFloat3D(ArrayMath.divide(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D divideC(double g) {
        return new MathArrayFloat3D(ArrayMath.divideC(f, (float) g), getType(), getnDims());
    }

    protected MathArrayFloat3D divideC(float g) {
        return new MathArrayFloat3D(ArrayMath.divideC(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D divideC(Complex g) {
        throw new ClassCastException("Cannot divide Complex number to double array");
    }

    @Override
    protected MathArrayFloat3D divideC(MathArray<float[][][]> g) {
        return new MathArrayFloat3D(ArrayMath.divideC(f, g.getArray()), getType(), getnDims());
    }

    protected MathArrayFloat3D floor() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.floor(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    protected MathArrayFloat3D floorC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.floorC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D log() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.log(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D logC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.logC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    protected MathArrayFloat3D multiply(double g) {
        return new MathArrayFloat3D(ArrayMath.multiply(f, (float) g), getType(), getnDims());
    }

    protected MathArrayFloat3D multiply(float g) {
        return new MathArrayFloat3D(ArrayMath.multiply(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D multiply(Complex g) {
        throw new ClassCastException("Cannot multiply Complex number to double array");
    }

    @Override
    protected MathArrayFloat3D multiply(MathArray<float[][][]> g) {
        return new MathArrayFloat3D(ArrayMath.multiply(f, g.getArray()), getType(), getnDims());
    }

    protected MathArrayFloat3D multiply(float[][][] g) {
        return new MathArrayFloat3D(ArrayMath.multiply(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D multiplyC(double g) {
        return new MathArrayFloat3D(ArrayMath.multiplyC(f, (float) g), getType(), getnDims());
    }

    protected MathArrayFloat3D multiplyC(float g) {
        return new MathArrayFloat3D(ArrayMath.multiplyC(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D multiplyC(Complex g) {
        throw new ClassCastException("Cannot multiply Complex number to double array");
    }

    @Override
    protected MathArrayFloat3D multiplyC(MathArray<float[][][]> g) {
        return new MathArrayFloat3D(ArrayMath.multiplyC(f, g.getArray()), getType(), getnDims());
    }

    protected MathArrayFloat3D reciprocal() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.reciprocal(ArrayMath.float2Double(f))),
                getType(), getnDims());
    }

    @Override
    protected MathArrayFloat3D reciprocalC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.reciprocalC(ArrayMath.float2Double(f))),
                getType(), getnDims());
    }

    protected MathArrayFloat3D round() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.round(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    protected MathArrayFloat3D roundC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.roundC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D sin() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.sin(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D sinC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.sinC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D sinh() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.sinh(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D sinhC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.sinhC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D sqrt() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.sqrt(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D sqrtC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.sqrtC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D square() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.square(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D squareC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.squareC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    protected MathArrayFloat3D subtract(double g) {
        return new MathArrayFloat3D(ArrayMath.subtract(f, (float) g), getType(), getnDims());
    }

    protected MathArrayFloat3D subtract(float g) {
        return new MathArrayFloat3D(ArrayMath.subtract(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D subtract(Complex g) {
        throw new ClassCastException("Cannot subtract Complex number to double array");
    }

    @Override
    protected MathArrayFloat3D subtract(MathArray<float[][][]> g) {
        return new MathArrayFloat3D(ArrayMath.subtract(f, g.getArray()), getType(), getnDims());
    }

    protected MathArrayFloat3D subtract(float[][][] g) {
        return new MathArrayFloat3D(ArrayMath.subtract(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D subtractC(double g) {
        return new MathArrayFloat3D(ArrayMath.subtractC(f, (float) g), getType(), getnDims());
    }

    protected MathArrayFloat3D subtractC(float g) {
        return new MathArrayFloat3D(ArrayMath.subtractC(f, g), getType(), getnDims());
    }

    protected MathArrayFloat3D subtractC(Complex g) {
        throw new ClassCastException("Cannot subtract Complex number to double array");
    }

    @Override
    protected MathArrayFloat3D subtractC(MathArray<float[][][]> g) {
        return new MathArrayFloat3D(ArrayMath.subtractC(f, g.getArray()), getType(), getnDims());
    }

    @Override
    protected MathArrayFloat3D tan() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.tan(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D tanC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.tanC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D tanh() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.tanh(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

    @Override
    protected MathArrayFloat3D tanhC() {
        return new MathArrayFloat3D(ArrayMath.double2Float(ArrayMath.tanhC(ArrayMath.float2Double(f))), getType(),
                getnDims());
    }

}