summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/prjava/src/arr
diff options
context:
space:
mode:
authortrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-13 18:22:59 +0000
committertrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-13 18:22:59 +0000
commite0265b2c2be3173341bdc2ffacdb6847b30890f5 (patch)
treef3fbb1d3ed534ca9cab8001f0c19527cd2dd861b /gi/posterior-regularisation/prjava/src/arr
parent2eeaa2eb91334bea11d70db1011f1a28ce3bb7d2 (diff)
Cleaning up the PC model.
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@236 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/arr')
-rw-r--r--gi/posterior-regularisation/prjava/src/arr/F.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/gi/posterior-regularisation/prjava/src/arr/F.java b/gi/posterior-regularisation/prjava/src/arr/F.java
index 54dadeac..79de5d1a 100644
--- a/gi/posterior-regularisation/prjava/src/arr/F.java
+++ b/gi/posterior-regularisation/prjava/src/arr/F.java
@@ -56,6 +56,7 @@ public class F {
}
public static double l1norm(double a[]){
+ // FIXME: this isn't the l1 norm for a < 0
double norm=0;
for(int i=0;i<a.length;i++){
norm += a[i];
@@ -63,6 +64,14 @@ public class F {
return norm;
}
+ public static double l2norm(double a[]){
+ double norm=0;
+ for(int i=0;i<a.length;i++){
+ norm += a[i]*a[i];
+ }
+ return Math.sqrt(norm);
+ }
+
public static int argmax(double probs[])
{
double m = Double.NEGATIVE_INFINITY;