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

com.github.chen0040.rl.utils.VectorUtils Maven / Gradle / Ivy

package com.github.chen0040.rl.utils;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by xschen on 10/11/2015 0011.
 */
public class VectorUtils {
    public static List removeZeroVectors(Iterable vlist)
    {
        List vstarlist = new ArrayList();
        for (Vec v : vlist)
        {
            if (!v.isZero())
            {
                vstarlist.add(v);
            }
        }

        return vstarlist;
    }

    public static TupleTwo, List> normalize(Iterable vlist)
    {
        List norms = new ArrayList();
        List vstarlist = new ArrayList();
        for (Vec v : vlist)
        {
            norms.add(v.norm(2));
            vstarlist.add(v.normalize());
        }

        return TupleTwo.create(vstarlist, norms);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy