
com.github.chen0040.rl.utils.VectorUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-reinforcement-learning Show documentation
Show all versions of java-reinforcement-learning Show documentation
Classical RL algorithms implemented in Java, including Q-Learn, R-Learn, SARSA, Actor-Critic
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 - 2025 Weber Informatics LLC | Privacy Policy