001 /**
002 * Copyright 2009-2010 by The Broad Institute.
003 *
004
005 */
006 package org.broadinstitute.genee.matrix;
007
008 /**
009 * Dataset implementation using two-dimensional float array.
010 */
011 public class RowMajorArray2DDataset extends FixedSizeAbstractDataset {
012
013 private float[][] array;
014
015 /**
016 * Creates a new dataset with the specified name and array.
017 *
018 * @param the
019 * dataset name
020 * @param array
021 * the data array
022 */
023 public RowMajorArray2DDataset(String name, float[][] array) {
024 super(name, array.length, array[0].length);
025 this.array = array;
026
027 }
028
029 /**
030 * Creates a new dataset
031 *
032 * @param name
033 * the dataset name
034 * @param rows
035 * the number of rows
036 * @param columns
037 * the number of columns
038 */
039 public RowMajorArray2DDataset(String name, int rows, int columns) {
040 super(name, rows, columns);
041 array = new float[rows][columns];
042 }
043
044 /**
045 * Gets the underlying float[][] array
046 *
047 * @return the array
048 */
049 public float[][] getArray() {
050 return array;
051 }
052
053 @Override
054 public float getValue(int row, int column) {
055 return array[row][column];
056 }
057
058 /**
059 * Sets the underlying float[][] array
060 *
061 * @param array
062 * the array
063 */
064 public void setArray(float[][] array) {
065 this.array = array;
066
067 }
068
069 public void setValue(int rowIndex, int columnIndex, float value) {
070 array[rowIndex][columnIndex] = value;
071 }
072
073 }