MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / multiply

Method multiply

JSAT/src/jsat/linear/GenericMatrix.java:125–153  ·  view source on GitHub ↗
(Vec b, double z, Vec c)

Source from the content-addressed store, hash-verified

123 }
124
125 @Override
126 public void multiply(Vec b, double z, Vec c)
127 {
128 if(this.cols() != b.length())
129 throw new ArithmeticException("Matrix dimensions do not agree, [" + rows() +"," + cols() + "] x [" + b.length() + ",1]" );
130 if(this.rows() != c.length())
131 throw new ArithmeticException("Target vector dimension does not agree with matrix dimensions. Matrix has " + rows() + " rows but tagert has " + c.length());
132
133 if (b.isSparse())
134 {
135 for (int i = 0; i < rows(); i++)
136 {
137 double dot = 0;
138 for(IndexValue iv : b)
139 dot += this.get(i, iv.getIndex()) * iv.getValue();
140 c.increment(i, dot * z);
141 }
142 }
143 else
144 {
145 for (int i = 0; i < rows(); i++)
146 {
147 double dot = 0;
148 for (int j = 0; j < cols(); j++)
149 dot += this.get(i, j) * b.get(j);
150 c.increment(i, dot * z);
151 }
152 }
153 }
154
155 @Override
156 public void multiply(Matrix b, Matrix C)

Callers

nothing calls this directly

Calls 11

colsMethod · 0.95
canMultiplyMethod · 0.80
submitMethod · 0.80
lengthMethod · 0.45
rowsMethod · 0.45
isSparseMethod · 0.45
getMethod · 0.45
getIndexMethod · 0.45
getValueMethod · 0.45
incrementMethod · 0.45
awaitMethod · 0.45

Tested by

no test coverage detected