(Vec v)
| 248 | } |
| 249 | |
| 250 | @Override |
| 251 | public double dot(Vec v) |
| 252 | { |
| 253 | if(this.length() != v.length()) |
| 254 | throw new ArithmeticException("Vectors must have the same length"); |
| 255 | |
| 256 | if(v.isSparse()) |
| 257 | return v.dot(this); |
| 258 | |
| 259 | double dot = 0; |
| 260 | for(int i = startIndex; i < endIndex; i++) |
| 261 | dot += array[i] * v.get(i-startIndex); |
| 262 | |
| 263 | return dot; |
| 264 | } |
| 265 | |
| 266 | public DenseVector deepCopy() |
| 267 | { |