/*
 * Copyright 2011-2013, by Vladimir Kostyukov and Contributors.
 * 
 * This file is part of la4j project (http://la4j.org)
 * 
 * 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.
 * 
 * Contributor(s): -
 * 
 */

package org.la4j.matrix.dense;

import java.util.Arrays;

import org.la4j.matrix.AbstractMatrixTest;

public abstract class DenseMatrixTest extends AbstractMatrixTest {

    public void testToArray() {
        double array[][] = new double[][] { 
                { 1.0, 0.0, 0.0 },
                { 0.0, 5.0, 0.0 }, 
                { 0.0, 0.0, 9.0 } 
        };

        DenseMatrix a = (DenseMatrix) factory().createMatrix(array);

        double[][] toArray = a.toArray();

        for (int i = 0; i < a.rows(); i++) {
            assertTrue(Arrays.equals(array[i], toArray[i]));
        }
    }
    
	public void testRotation() {
		double array[][] = new double[][] { 
				{ 1.0, 2.0 }, 
				{ 3.0, 4.0 } 
		};
		
		double array2[][] = new double[][] { 
				{ 3.0, 1.0 }, 
				{ 4.0, 2.0 } 
		};
		Basic2DMatrix m1 = new Basic2DMatrix(array);
		Basic2DMatrix m2 = (Basic2DMatrix) m1.rotate();
		Basic2DMatrix m3 = new Basic2DMatrix(array2);
		
		assertTrue(m2.equals(m3));
		
	}

}

/*
 * Copyright 2011-2013, by Vladimir Kostyukov and Contributors.
 * 
 * This file is part of la4j project (http://la4j.org)
 * 
 * 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.
 * 
 * Contributor(s): -
 * 
 */

package org.la4j.matrix.dense;

import java.util.Arrays;

import org.la4j.matrix.AbstractMatrixTest;

public abstract class DenseMatrixTest extends AbstractMatrixTest {

    public void testToArray() {
        double array[][] = new double[][] { 
                { 1.0, 0.0, 0.0 },
                { 0.0, 5.0, 0.0 }, 
                { 0.0, 0.0, 9.0 } 
        };

        DenseMatrix a = (DenseMatrix) factory().createMatrix(array);

        double[][] toArray = a.toArray();

        for (int i = 0; i < a.rows(); i++) {
            assertTrue(Arrays.equals(array[i], toArray[i]));
        }
    }
    
	public void testRotate_2x2() {
		double array[][] = new double[][] { 
				{ 1.0, 2.0 }, 
				{ 3.0, 4.0 } 
		};
		
		double array2[][] = new double[][] { 
				{ 3.0, 1.0 }, 
				{ 4.0, 2.0 } 
		};
		Basic2DMatrix m1 = new Basic2DMatrix(array);
		Basic2DMatrix m2 = (Basic2DMatrix) m1.rotate();
		Basic2DMatrix m3 = new Basic2DMatrix(array2);
		
		assertTrue(m2.equals(m3));
		
	}

}

rename test method to testRotate_2x2