Subtract two vectors. - CSharp System

CSharp examples for System:Math Vector

Description

Subtract two vectors.

Demo Code

// Licensed under the Apache License, Version 2.0 (the "License");
using System.Collections.Generic;
using System;/*from   w ww . j  a v a  2  s  .  c  om*/

public class Main{
        /// <summary>
        /// Subtract two vectors.
        /// </summary>
        /// <param name="a">First vector.</param>
        /// <param name="b">Second vector.</param>
        /// <returns>Result vector.</returns>
        public static double[] Subtract(double[] a, double[] b)
        {
            double[] result = new double[a.Length];
            for (int i = 0; i < a.Length; i++)
            {
                result[i] = a[i] - b[i];
            }
            return result;
        }
}

Related Tutorials