All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliasi.matrix.MatrixBackedVector Maven / Gradle / Ivy

Go to download

This is the original Lingpipe: http://alias-i.com/lingpipe/web/download.html There were not made any changes to the source code.

There is a newer version: 4.1.2-JL1.0
Show newest version
package com.aliasi.matrix;

abstract class MatrixBackedVector extends AbstractVector {

    protected final Matrix mMatrix;
    protected final int mIndex;

    MatrixBackedVector(Matrix m, int index) {
        mMatrix = m;
        mIndex = index;
    }

    static class Row extends MatrixBackedVector implements Vector {
        Row(Matrix m, int index) {
            super(m,index);
        }
        @Override
        public int numDimensions() {
            return mMatrix.numColumns();
        }
        @Override
        public void setValue(int column, double value) {
            mMatrix.setValue(mIndex,column,value);
        }
        @Override
        public double value(int column) {
            return mMatrix.value(mIndex,column);
        }
        @Override
        public Vector add(Vector v) {
            return Matrices.add(this,v);
        }
    }

    static class Column extends MatrixBackedVector implements Vector {
        Column(Matrix m, int index) {
            super(m,index);
        }
        @Override
        public int numDimensions() {
            return mMatrix.numRows();
        }
        @Override
        public void setValue(int row, double value) {
            mMatrix.setValue(row,mIndex,value);
        }
        @Override
        public double value(int row) {
            return mMatrix.value(row,mIndex);
        }
        @Override
        public Vector add(Vector v) {
            return Matrices.add(this,v);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy