Question: Define a function lengths that takes two parameters: a three - column matrix of floats ( 2 D array ) and an integer that indicates

Define a function lengths that takes two parameters: a three-column matrix of floats (2D array) and an integer that indicates the number of rows in the matrix. Return a pointer to an array of floats allocated on the heap where each element of the returned array is the length of the vector defined by the corresponding row in the matrix.
For example, given the matrix:
012
345
678
900
the lengths function should return {2.24,7.07,12.21,9.0}.
The length of a vector can be found by the Pythagorean Theorem:
len([a,b,c])= sqrt(a2+b2+c2)
Note: the matrix parameter is not an array of pointers-to-float (float *m[3]), but a matrix with rows of size 3(float m[][3]).
Answer:(penalty regime: 0%)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!