Mercurial > hg > jslab
view src/samer/maths/MatrixTransposeTimesVector.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | bf79fb79ee13 |
children |
line wrap: on
line source
/* * Copyright (c) 2000, Samer Abdallah, King's College London. * All rights reserved. * * This software is provided AS iS and WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. */ package samer.maths; import samer.tools.*; public class MatrixTransposeTimesVector extends VectorFunctionOfVector implements SafeTask { int m, n; double [][] a; double [] x, y, arow; public MatrixTransposeTimesVector( Vec out, Matrix matrix, Vec in) { this(out.array(),matrix,in.array()); } public MatrixTransposeTimesVector(Matrix matrix) { m = matrix.getRowDimension(); n = matrix.getColumnDimension(); a = matrix.getArray(); } public MatrixTransposeTimesVector( double[] out, Matrix matrix, double[] in) { this(matrix); x = in; y = out; } public void dispose() {} public void starting() {} public void stopping() {} public void run() { java.util.Arrays.fill(y,0); for (int j=0; j<m; j++) { double t=x[j]; arow=a[j]; for (int i=0; i<n; i++) y[i]+=arow[i]*t; } } public void apply(double [] x, double [] y) { java.util.Arrays.fill(y,0); for (int j=0; j<m; j++) { double t=x[j]; arow=a[j]; for (int i=0; i<n; i++) y[i]+=arow[i]*t; } } }