Java Utililty Methods Square

List of utility methods to do Square

Description

The list of methods to do Square are organized into topic(s).

Method

doublesquare(double a)
square
return a * a;
double[]square(double[] in, double[] out)
Squares each element of the input vector and puts it into the out vector.
if (out == null) {
    out = new double[in.length];
if (in.length != out.length) {
    throw new IllegalArgumentException("in.length != out.length: " + in.length + " vs. " + out.length);
for (int i = 0; i < in.length; i++) {
    double a = in[i];
...
double[][]square(double[][] m)
Multiply a square matrix by itself
assert (m[0].length == m.length);
int n = m.length;
double[][] res = new double[n][n];
for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
        double sum = 0.0;
        for (int k = 0; k < n; k++)
            sum += m[i][k] * m[j][k];
...
doublesquare(final double num)
Simple square number, just num * num.
return num * num;
floatsquare(float number, int power)
square
float newNumber = 1;
for (int i = 0; i < power; i++) {
    newNumber = newNumber * number;
return newNumber;
intsquare(int n)
Return square of N.
if (n < sqCache.length) {
    return sqCache[n];
return n * n;
intsquare(int value)
square
return value * value;