Add two vectors. - CSharp System

CSharp examples for System:Math Vector

Description

Add two vectors.

Demo Code

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

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

Related Tutorials