|
CS205 S22 Assignment 1
|
Provided struct and functions for SUSTech CS205 (s22) assignment 1. More...
Go to the source code of this file.
Classes | |
| struct | matrix |
| Structure to store a matrix with integers. More... | |
Typedefs | |
| typedef struct matrix | matrix |
| Structure to store a matrix with integers. More... | |
Functions | |
| matrix | create_matrix_all_zero (int row, int col) |
| void | delete_matrix (matrix mat) |
| matrix | copy_matrix (matrix mat) |
| void | set_by_index (matrix mat, int row, int col, int val) |
| int | get_by_index (matrix mat, int row, int col) |
| int | scalar_multiplication (matrix mat_a, int x, matrix mat_res) |
Provided struct and functions for SUSTech CS205 (s22) assignment 1.
The functions defined in this header have been implemented, you NEED NOT modify this file, and DON'T submit this to Blackboard
Structure to store a matrix with integers.
In this assignment, **int**s are stored in the matrix
Hard copy a matrix
| mat | the matrix to be copied |
mat | matrix create_matrix_all_zero | ( | int | row, |
| int | col | ||
| ) |
Create a matrix filled with zeros
| row | the height (row) of the matrix |
| col | the width (col) of the matrix |
| void delete_matrix | ( | matrix | mat | ) |
Free the memory pointed by m_data in matrix mat You MUST destroy every matrix before the program exits properly
| mat | the matrix you not longer need |
| int get_by_index | ( | matrix | mat, |
| int | row, | ||
| int | col | ||
| ) |
Get the value in the entry at row and col of mat
| mat | the matrix to be affected |
row or col is out of bounds, retval will be 0xdeadbeef Scalar multiplication of a matrix and an integer If the size of mat_res does not match the size of mat_a, DO NOT modify the data in mat_res
| mat_a | the matrix |
| x | the constant integer |
| mat_res | the matrix in which the result should be stored |
mat_res does not match the size of mat_a, 0 otherwise | void set_by_index | ( | matrix | mat, |
| int | row, | ||
| int | col, | ||
| int | val | ||
| ) |
Set the entry at row and col of mat to the value of val
| mat | the matrix to be affected |
| val | value will be set to mat[row, col] |
row or col is out of bounds, no action will be taken