Giter Club home page Giter Club logo

armadillojava's People

Contributors

bitdeli-chef avatar dkiechle avatar waffle-iron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

armadillojava's Issues

Documentation of arma.Mat

The following methods are missing any documentation:

  • at(int)
  • at(int, int)
  • at(int, Op, double)
  • at(int, int, Op, double)
  • col(int)
  • col(int, Op, Mat)
  • row(int)
  • row(int, Op, Mat)
  • diag()
  • diag(Op, double)
  • diag(Op, Mat)
  • each_col(Op, Mat)
  • each_row(Op, Mat)
  • elem(Mat)
  • elem(Mat, Op, Mat)
  • fill(double)
  • memptr()
  • resize(int, int)
  • t()
  • i()
  • set_size(int, int)
  • toString()
  • zeros(int, int)
  • ones(int, int)
  • eye(int, int)
  • randn(int, int, Random)
  • randu(int, int, Random)
  • plus(double)
  • plus(Mat)
  • minus(double)
  • minus(Mat)
  • times(double)
  • times(Mat)
  • elemTimes(double)
  • elemTimes(Mat)
  • divide(double)
  • divide(Mat)
  • elemDivide(double)
  • elemDivide(Mat)
  • getResult(double, Op, double)
  • updateAttributes()

Test cases for matrix-valued element-wise functions

The project is currently missing test cases for matrix-valued element-wise functions, which is split in trigonometric and miscellaneous functions.

Both cases seem to be well parameterisable but clearly with some differences. A blank test class can already be found at test/Arma/arma/TestMatrixValuedElementWiseFunctions.java, which should be split accordingly into to separate test classes, one for trigonometric and one for miscellaneous functions.

My suggestion would be to split it into test/Arma/arma/TestMatrixValuedElementWiseFunctionsTrigonometric.java and test/Arma/arma/TestMatrixValuedElementWiseFunctionsMiscellaneous.java (quite the long names :D).

Tasks:

  • Add test/Arma/arma/TestMatrixValuedElementWiseFunctionsTrigonometric.java
  • Add test/Arma/arma/TestMatrixValuedElementWiseFunctionsMiscellaneous.java

For the test data, I would like to check the following values with positive and negative sign:

  • Both cases: 0, 1, 2, Datum.eps, Datum.inf
  • Trigonometric functions: 1/12_Datum.pi, 1/10_Datum.pi, 1/8_Datum.pi, 1/6_Datum.pi, 1/4_Datum.pi, 1/2_Datum.pi, Datum.pi, 3/2_Datum.pi, 2_Datum.pi, 3_Datum.pi, 4_Datum.pi, 5_Datum.pi, 10_Datum.pi, 100*Datum.pi
  • Miscellaneous functions: Datum.e, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 0.9, 0.89, 0.789, 0.6789, 0.56789, 0.456789, 0.3456789, 0.23456789, 0.123456789

The 38 test values for the trigonometric functions should be arranged in a non-sqaure (2, 19)-matrix and the 46 test values for the miscellaneous functions in a non-sqaure (2, 23)-matrix.

An example of a parameterised test class for the trigonometric functions:

@RunWith(Parameterized.class)
public class TestMatrixValuedElementWiseFunctionsTrigonometric {

  @Parameters
  public static Collection<Object[]> getTestData() {
    Collection<Object[]> matrices = new ArrayList<Object[]>();

    matrices.add(new Object[]{new Mat(new double[][]{
      {0, 1, 2, Datum.eps, Datum.inf, 1/12*Datum.pi, 1/10*Datum.pi, 1/8*Datum.pi, 1/6*Datum.pi, 1/4*Datum.pi, 1/2*Datum.pi, Datum.pi, 3/2*Datum.pi, 2*Datum.pi, 3*Datum.pi, 4*Datum.pi, 5*Datum.pi, 10*Datum.pi, 100*Datum.pi},
      {-0, -1, -2, -Datum.eps, -Datum.inf, -1/12*Datum.pi, -1/10*Datum.pi, -1/8*Datum.pi, -1/6*Datum.pi, -1/4*Datum.pi, -1/2*Datum.pi, -Datum.pi, -3/2*Datum.pi, -2*Datum.pi, -3*Datum.pi, -4*Datum.pi, -5*Datum.pi, -10*Datum.pi, -100*Datum.pi}
    })});

    return matrices; 
  }

  @Parameter
  public Mat _testData;

  /* some tests */
}

Tasks continued:

  • Parameterise the trigonometric test class with the values above in a (2, 19)-matrix
  • Parameterise the miscellaneous test class with the values above in a (2, 23)-matrix

The expected results of these tests should be pre-calculated and saved to compare always with the same pre-calculated values.

An example for the generation of pre-calculated expected results with native java functions:

public class TestExpectedValues {

  public static void main(String[] args) throws FileNotFoundException {
    testMatrixValuedElementWiseFunctionsTrigonometric();
  }

  protected static void testMatrixValuedElementWiseFunctionsTrigonometric() throws FileNotFoundException {
    Mat testData = (Mat) TestMatrixValuedElementWiseFunctions.getTestData().iterator().next()[0];
    Mat expected =  new Mat(testData.n_rows, testData.n_cols);

    for(int n = 0; n < testData.n_elem; n++) {
      expected.at(n, Op.EQUAL, Math.sqrt(testData.at(n)));
    }

    expected.save("test/data/Arma/TestMatrixValuedElementWiseFunctions/Miscellaneous.sqrt.mat");

    /* generation of other expected results for the same parameterised test class */
  }

  /* generation of other expected results for another parameterised test class */
}

The example code given above should be placed under test/util/arma/TestExpectedValues.java

Tasks continued:

  • Create all testdata-files to be used in the trigonometric test class
  • Create all testdata-files to be used in the miscellaneous test class

Continued example of the actual test case:

@Test
public void testSqrt() {
  Mat expected = new Mat();
  expected.load("test/data/Arma/TestMatrixValuedElementWiseFunctions/Miscellaneous.sqrt.mat");

  Mat actual = Arma.sqrt(_testData);

  for(int n = 0; n < _testData.n_elem; n++) {
    assertEquals(expected.at(n), actual.at(n), TestUtil.NUMERIC_TOLERANCE);
  }
}

Tasks continued:

  • Fill the trigonometric test class with tests for all functions classified as trigonometric.
  • Fill the miscellaneous test class with tests for all functions classified as miscellaneous.

Documentation of arma.Arma

The following methods are missing any documentation:

  • det(Mat)
  • abs(Mat)
  • qr(Mat, Mat, Mat)
  • floor(Mat)
  • sum(Mat)
  • square(Mat)
  • find(Mat, Op, double)
  • find(double, Op, Mat)
  • find(Mat, Op, Mat)
  • any(Mat)
  • norm(Mat, int)

Replace internal use of .at(n) with .get(n)

Using .at(n) requires a conversion of the index n between a major-major-ordered context and a column-major-ordered context.

However, this could completely be skipped by directly using .get(n)

Unexpected results in Arma.find(double a, Op operation, Mat b)

Instead of simple returning find() with switched parameters ...

  public static Mat find(double a, Op operation, Mat b) {
    return find(b, operation, a);
  }

... the operation needs also to be switch if neither Op.EQUAL nor Op.NOT_EQUAL was requested.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.