This program aims to recognize the number 1 from the MNIST dataset. It uses a similarity approach between two matrices and outputs the five closest images.
X.matrix: the matrix containing the images.ones.matrix: the matrix containing the values of the number 1.main.c: the source code file.
Reads a matrix from a file.
filename: the file containing the matrix.
Returns a matrix structure containing the matrix.
Converts a 2D index to flattened 1D index.
i: the row of the element.j: the column of the element.numcol: the number of columns.
Returns the flattened index.
Retrieves an element from a matrix.
M: the matrix.i: the row of the element.j: the column of the element.
Returns the element at row i and column j.
Retrieves the pointer to a matrix element.
M: the matrix.i: the row of the element.j: the column of the element.
Returns the pointer to the element at row i and column j.
Assigns a value to an element in a matrix.
M: the matrix.i: the row of the element.j: the column of the element.value: the value to be assigned.
Prints an image to the console.
image: an array that stores the flattened image stored in column-major order.Height: the height of the image.Width: the width of the image.
Computes the squared Euclidean distance.
a: an integer array.b: an integer array.len: the length of the two arrays.
Returns the total squared Euclidean distance.
Computes the pairwise squared distance of the i-th row of M1 and the j-th row of M2.
M1: the first matrix.M2: the second matrix.D: a matrixDwhereD_ijis the squared distance between thei-th row ofM1and thej-th row ofM2.
Finds the index of the minimum element in an array.
a: an integer array.len: the length of the array.
Returns the index of the minimum element in the array.
Finds the indices of the 5 minimum elements in an array.
len: the length of the array.a: an integer array.indices: an