Question

write a c++ program that computes the L^2 - Norm (Euclidean norm) of a given vector...

write a c++ program that computes the L^2 - Norm (Euclidean norm) of a given vector (L^2 norm of a vector is the square root of the sum of the squares of all the components of the vector)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <bits/stdc++.h>
using namespace std;
int v[1000000];
int main()
{
int n;//Enter the no of dimensions of the vector
cin>>n;
int i;

int sum=0;
for(i=0;i<n;i++)
{
cin>>v[i];//Enter the coefficient of the vector
sum=sum+abs(v[i]);//Calculating Sum of Vector
}
cout<<" L^1 - Norm of a given vector "<<sum<<" ";
return 0;
}

Input-->

4
-1 -1 2 3

Output-->

 L^1 - Norm of a given vector 7

Any doubt ask in comments section.Please Upvote.Thanks and Regards

Add a comment
Know the answer?
Add Answer to:
write a c++ program that computes the L^2 - Norm (Euclidean norm) of a given vector...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT