Posts

Showing posts with the label vector inner product

mathajax

Vector Inner product

Image
A matrix product of two vectors X and Y are called inner product that results a scalar output. The two vectors X and Y must have the same number of elements in order to measure inner product these two vectors. A vector X has n elements A vector Y has n elements Inner product of Two vectors X and Y or or Java code - vector inner product The following Java code inner product of two vectors having same number of elements . The vectors can be defined in Java program by a integer array and a double array. import java.util.Arrays; public class Vector { public static double innerproduct( double vec[], double vec2[]) { double inp=0.0; for ( int n=0;n<vec.length;n++) inp = inp + vec[n] * vec2[n]; return inp; } public static int innerproduct( int vec[], int vec2[]) { int inp=0; for ( int n=0;n<vec.length;n++) inp = inp + vec[n] * vec2[n]; return inp;...

Vector Dot Product

Image
The Java code finds the dot product of two vectors v1 and v2 .   it is also called as scalar product or inner product and  defined as sum of  product of  respective axis element of  the two vectors . Their vector's element can be integer or double of java datatype. Dot product of 2-D vectors Dot product of N-D vectors Dot product of 2D vectors A class Vector defined two member functions named " dot-product " with parameter type difference, in order to support  parameters  int or double type 2D vectors.  . Both member function can be invoked with two array parameters, which represents the vectors to be dot-product. These vectors must have 2 elements. for example  below shows how to calculate dot product two vectors A and B using above equation Vector A = [1 5] Vector B = [2 3] A.B = 1x2 + 5x3 = 2 + 15 A.B = 17     import jav...