Android Open Source - renderScriptFFT Matrix Math






From Project

Back to project page renderScriptFFT.

License

The source code is released under:

Copyright (c) 2013 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided...

If you think the Android project renderScriptFFT listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.android.rs.utils;
/*from w ww  .  j a v a  2 s .c om*/
import org.apache.commons.math3.linear.MatrixUtils;
import org.apache.commons.math3.linear.RealMatrix;
import org.apache.commons.math3.util.FastMath;

public class MatrixMath {

  private MatrixMath(){}
    
    public static RealMatrix abs(RealMatrix mat) {
        final int rowCount    = mat.getRowDimension();
        final int columnCount = mat.getColumnDimension();
        final RealMatrix out = MatrixUtils.createRealMatrix(rowCount, columnCount);
        for (int row = 0; row < rowCount; ++row) {
            for (int col = 0; col < columnCount; ++col) {
                out.setEntry(row, col, FastMath.abs(mat.getEntry(row, col)));
            }
        }
        return out;
    }
    
    public static RealMatrix floor(RealMatrix mat){
        final int rowCount    = mat.getRowDimension();
        final int columnCount = mat.getColumnDimension();
        final RealMatrix out = MatrixUtils.createRealMatrix(rowCount, columnCount);
        for (int row = 0; row < rowCount; ++row) {
            for (int col = 0; col < columnCount; ++col) {
                out.setEntry(row, col, FastMath.floor(mat.getEntry(row, col)));
            }
        }
        return out;
    }
    
    public static int[] findFirstElementGreater(RealMatrix mat, double val) {
      int[] index = new int[]{-1,-1};
        final int rowCount    = mat.getRowDimension();
        final int columnCount = mat.getColumnDimension();
        for (int row = 0; row < rowCount; ++row) {
            for (int col = 0; col < columnCount; ++col) {
                if (mat.getEntry(row, col) > val){
                  index[0] = row;
                  index[1] = col;  
                  return index;
                }
            }
        }
        return index;
    }
    
    public static int[] findLastElementLessThan(RealMatrix mat, double val) {
      int[] index = new int[]{-1,-1};
        final int rowCount    = mat.getRowDimension();
        final int columnCount = mat.getColumnDimension();
        for (int row = 0; row < rowCount; ++row) {
            for (int col = 0; col < columnCount; ++col) {
                if (mat.getEntry(row, col) < val){
                  index[0] = row;
                  index[1] = col;  
                } else{
                  return index;
                }
            }
        }
        return index;
    }
    

}




Java Source Code List

com.android.rs.MainActivity.java
com.android.rs.Mel_Test_MicroBench.java
com.android.rs.Mel_Test_Microphone.java
com.android.rs.Mel_Test.java
com.android.rs.mel.DCT.java
com.android.rs.mel.HammingFilter.java
com.android.rs.mel.MelFilterbank.java
com.android.rs.utils.ArrayConversion.java
com.android.rs.utils.MatrixMath.java
com.android.rs.utils.MelMath.java