Posts

Showing posts with the label vector scalar 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;...