maths.VectorOperations Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jstat Show documentation
Show all versions of jstat Show documentation
Java Library for Statistical Analysis.
The newest version!
package maths;
import datasets.VectorDouble;
import datastructs.IVector;
import utils.ListMaths;
/**
* Common operations on Vector
*/
public class VectorOperations {
/**
* Adds the two vectors and returns a vector that contains the result
*/
public static VectorDouble add(final VectorDouble v1, final VectorDouble v2){
if(v1.size() != v2.size()){
throw new IllegalStateException("v1 size not equal to v2 size");
}
VectorDouble rslt = new VectorDouble(v1.size(),0.0);
for(int i=0; i v1, final IVector v2){
if(v1.size() != v2.size()){
throw new IllegalStateException("v1 size not equal to v2 size");
}
double rslt = 0.0;
for(int i=0; i