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

maths.VectorOperations Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy