Java BigDecimal Calculate calculateLHS(BigDecimal a, Vector Bj, Vector Bj1)

Here you can find the source of calculateLHS(BigDecimal a, Vector Bj, Vector Bj1)

Description

calculate LHS

License

Open Source License

Declaration



public static BigDecimal calculateLHS(BigDecimal a, Vector Bj, Vector Bj1) 

Method Source Code


//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;
    }
}

Related

  1. calculateArithmeticMean(BigDecimal[] values)
  2. calculateDayRate(BigDecimal rate, BigDecimal money)
  3. calculateDeviation(BigDecimal v1, BigDecimal v2)
  4. calculateDivide(BigDecimal numerator, BigDecimal denominator)
  5. calculateGainPercentage(BigDecimal gain, BigDecimal totalGains)
  6. calculateMonthCapital(BigDecimal eachIssueMoney, BigDecimal eachMonthInterest)
  7. calculateMonthInterest(Float interestRate, BigDecimal investmoney)
  8. calculatePercentChange(BigDecimal from, BigDecimal to)
  9. calculateProfit(BigDecimal totalAmt, Integer duration, BigDecimal rate)