Here you can find the source of calculateLHS(BigDecimal a, Vector Bj, Vector Bj1)
public static BigDecimal calculateLHS(BigDecimal a, Vector Bj, Vector Bj1)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.util.Vector; public class Main { /*** ***/ /* w ww .jav a 2 s .c o m*/ // LHS for checking reduced basis using vector B1[j], B1[j+1] and a scalar public static BigDecimal calculateLHS(BigDecimal a, Vector Bj, Vector Bj1) { return dotProduct(add(Bj1, scalarMult(a, Bj))); } public static BigDecimal dotProduct(Vector a) { Vector b = (Vector) a.clone(); return dotProduct(a, b); } public static BigDecimal dotProduct(Vector a, Vector b) { BigDecimal sum = new BigDecimal("0"); for (int i = 0; i < a.size(); i++) sum = sum.add((((BigDecimal) a.elementAt(i)).multiply((BigDecimal) b.elementAt(i)))); return sum; } /*** ***/ // TODO: write vector class that incorporates most vector operations public static Vector<BigDecimal> add(Vector<BigDecimal> a, Vector<BigDecimal> b) { int m = a.size(); Vector<BigDecimal> c = new Vector(m); for (int i = 0; i < m; i++) { BigDecimal value = ((BigDecimal) a.elementAt(i)).add((BigDecimal) b.elementAt(i)); c.add(value); } return c; } public static Vector<BigDecimal> scalarMult(BigDecimal scalar, Vector<BigDecimal> a) { Vector<BigDecimal> c = (Vector<BigDecimal>) a.clone(); for (int i = 0; i < a.size(); i++) c.set(i, scalar.multiply(((BigDecimal) a.get(i)))); return c; } }