Posts

Showing posts with the label vector norm

mathajax

Orthonormal vector

Image
A two vectors can be orthonormal to one another in other words, These vectors are perpendicular to each other and also their vector length equal to 1. To detect whether these two vectors are orthonormal or not , the vectors inner-product and vector length are used. If the result the inner-product is 0 (zero) and norm is 1 (one), the two vectors are orthonormal , otherwise not. Vector X Vector Y Vector Inner Product Vector norm or length Java code - Orthonormal The following Java code finds two vectors X and Y are orthonormal or not to each other by inner-product and norm of these two vector. A vector is defined in Java program by a integer array or a double array. Vector X = [1, 0] Vector Y = [0, 1] find inner product of vector X and Y X.Y = 0 find norm of vector X |X| = 1 find norm of vector Y |Y| = 1 if |X| = 1,|Y| = 1 and X .Y = 0 vector X and Y are orthonormal imp...

Orthogonal vector

Image
A two or more vectors can be orthogonal to one another in other words, These vectors are perpendicular to each other. To detect whether these two vectors are orthogonal or not , inner-product of these two vectors is used. If the result the inner-product return 0 (zero), these two vectors are orthogonal, otherwise not. vector X vector Y Two vectors X and Y Orthogonal Java code - Orthogonal The following Java code finds two vectors X and Y are orthogonal or not to each other by inner-product of these two vector. A vector is defined in Java program by a integer array or a double array. import java.util.Arrays; public class Vector { public static boolean isorthogonal( double vec[], double vec2[]) { boolean ortho =false; double inp=0.0; for ( int n=0;n<vec.length;n++) inp = inp + vec[n] * vec2[n]; if ( inp ==0 ) ortho=true; return ortho; } public static boolean isorthogonal( int...

Vector normalization - Unit vector

Image
A vector can converted into unit vector by vector normalization in which each elements of the vector is divided by that vector's norm or length . Vector X Unit Vector X Java code - vector normalization The following code converts a vector into unit vector by vector normalization . A vector is defined in Java program by a integer array or a double array. Example Vector X = [5.0, 1.2, 2.0] , find unit vector of X by normalization. 1. find vector X norm || X || = sqrt ( 5.0^2 + 1.2^2 + 2.0 ^2 ) = sqrt ( 25.0 + 1.44 + 4.0 ) = sqrt ( 30.44) = 5.5172 2 Unit vector X = [ 5.0/5.5172 , 1.2/5.5172 , 2.0/5.5172] = [ 0.9062, 0.2175, 0.3625]. import java.util.Arrays; public class Vector { public static double [] unit_vector( double vec[]) { int nelement = vec.length; double uvec[] = new double [nelement]; double nrm =0...

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]); ...