This preview shows page 1. Sign up to view the full content.
Unformatted text preview: http://www.mathsisfun.com/combinatorics/combinations permutations.html. Task 2 – Vector Arithmetic In this task, you will be implementing some very basic functions relating to vector arithmetic. For those of you who are taking, or have taken, a course in Linear Algebra, these functions should be self explanatory. float magnitude(float vec, int n); This function should take as input a n dimensional vector, represented as an array of length n, and return the magnitude of the vector. float dot(float vec1, float vec2, int n); This function should take as input two n dimensional vectors, and return their scalar product, otherwise known as “dot product”. These vectors are represented as two arrays of floating point numbers, each of length n, where n is also a parameter to the function. float angle(float vec1, float vec2, int n); This function should take in as input two n dimensional vectors, and return the angle, in radians, between the two vectors. You may want to use functions that you have already implemented above. void normalize(float vec, int n); This function “normalizes” an n dimensional vector, represented by an array of length n. The array passed in as an argument should be modified such that it’s magnitude should become 1, but its direction
should not change. Note that this function does not have a return value. When an array is passed to...
View
Full
Document
This homework help was uploaded on 03/02/2014 for the course CS 200 taught by Professor Fareedzaffar during the Winter '11 term at Lahore University of Management Sciences.
 Winter '11
 FareedZaffar

Click to edit the document details