@@ -0,0 +1,2846 @@
+/*%0A * The baseCode project%0A * %0A * Copyright (c) 2013 University of British Columbia%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except in compliance with%0A * the License. You may obtain a copy of the License at%0A * %0A * http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on%0A * an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations under the License.%0A */%0Apackage ubic.basecode.dataStructure.matrix;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport java.io.InputStream;%0Aimport java.util.Arrays;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport ubic.basecode.io.reader.DoubleMatrixReader;%0Aimport ubic.basecode.io.reader.TestDoubleMatrixReader;%0A%0Aimport cern.colt.matrix.DoubleMatrix2D;%0Aimport cern.colt.matrix.impl.DenseDoubleMatrix2D;%0Aimport cern.colt.matrix.linalg.Algebra;%0A%0A/**%0A * @author Paul%0A * @version $Id$%0A */%0Apublic class MatrixUtilTest %7B%0A%0A    DoubleMatrix2D testData;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A%0A        DoubleMatrixReader reader = new DoubleMatrixReader();%0A%0A        InputStream is = TestDoubleMatrixReader.class.getResourceAsStream( %22/data/testdatamissing.txt%22 );%0A        testData = new DenseDoubleMatrix2D( reader.read( is ).asDoubles() );%0A    %7D%0A%0A    @Test%0A    public void testDropColumn() %7B%0A        assertEquals( 12, testData.columns() );%0A        assertEquals( 11, MatrixUtil.dropColumn( testData, 1 ).columns() );%0A    %7D%0A%0A    @Test%0A    public void testSelectColumns() %7B%0A        assertEquals( 12, testData.columns() );%0A        assertEquals( 3, MatrixUtil.selectColumns( testData, Arrays.asList( new Integer%5B%5D %7B 2, 3, 8 %7D ) ).columns() );%0A    %7D%0A%0A    @Test%0A    public void testSelectRows() %7B%0A        assertEquals( 3, MatrixUtil.selectRows( testData, Arrays.asList( new Integer%5B%5D %7B 2, 3, 4 %7D ) ).rows() );%0A    %7D%0A%0A    @Test%0A    public void testSelectColumnsAndRowsBad() %7B%0A        try %7B%0A            MatrixUtil.selectColumnsAndRows( testData, Arrays.asList( new Integer%5B%5D %7B 2, 3, 4 %7D ) );%0A            fail( %22Should have gotten illegalarg ex%22 );%0A        %7D catch ( IllegalArgumentException e ) %7B%0A            // expected%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testSelectColumnsAndRows() %7B%0A        Algebra A = new Algebra();%0A        DoubleMatrix2D square = A.mult( testData, A.transpose( testData ) );%0A        assertEquals( square.rows(), square.columns() );%0A        assertEquals( 3, MatrixUtil.selectColumnsAndRows( square, Arrays.asList( new Integer%5B%5D %7B 2, 3, 4 %7D ) ).rows() );%0A        assertEquals( 3, MatrixUtil.selectColumnsAndRows( square, Arrays.asList( new Integer%5B%5D %7B 2, 3, 4 %7D ) )%0A                .columns() );%0A%0A    %7D%0A%0A%7D%0A

add tests