Posts

Showing posts with the label vector 1-norm

mathajax

Vector norm

Image
To measure the length of a vector is called the vector norm , in which length is measured from the origin (0,0) to the vector point on a plane. The following equation are used to measure length of a vector by 1-norm and 2-norm respectively. 1-norm Equation The vector length is measured by the absolute sum of the vector's elements or 2-norm Equation The 2-norm is also called as euclidean norm and is measured by root of squared sum of the vector's elements. or Java code - vector norm The following Java code finds a vector norm1 and norm2 . A vector is defined in Java program by a integer array and a double array. import java.util.Arrays; public class Vector { public static double norm1( double vec[]) { double nrm =0.0; for ( int n=0;n<vec.length;n++) nrm += Math.abs(vec[n]); return nrm; } public static int norm1( int vec[]) { int nrm =0; for ( int n=0;n<vec.length;n++) nrm += Math.abs(vec[n]); ...