Adds two vectors (a+b). - Android java.lang

Android examples for java.lang:Math Vector

Description

Adds two vectors (a+b).

Demo Code


//package com.java2s;

public class Main {
    /**// w  ww.  j ava2s .co  m
     * Adds two vectors (a+b).
     * @param a The first vector
     * @param b The second vector
     * @param result Storage for the result, if null, do nothing.
     **/
    public static void add(int size, float[] a, int offsetA, float[] b,
            int offsetB, float[] result, int offsetResult) {
        if (result == null) {
            return;
        }
        for (int i = 0; i < size; i++)
            result[offsetResult + i] = a[offsetA + i] + b[offsetB + i];
    }
}

Related Tutorials