>>106747077
he might be just a troll
but i noticed with matrixSetValue for instance you check if rows or cols are inferior or equal to 0
if you could use unsigned ints for your rows and cols you could disincentivize the situation where the value is negative. you could also check for that somewhere else in your code to avoid doing that repeatedly, each time you call matrixSetValue.
or just state in your documentation that the values given have to be positive.
then, if your rows and cols are equal to zero, you wont even enter the for loops
and so you could eliminate these two conditionals from your code entirely
also i dont see anywhere in your code where you use the return value of that function
so we could turn it into a void one
something like this:
void matrixSetValue(float *output,
float value,
unsigned int rows, unsigned int cols){
unsigned int offset;
for(int i = 0; i < rows; i++ ){
for(int j = 0; j < cols; j++){
offset = j + (i * cols);
output[offset] = value;
}
}
}
also since youre propagating just one value throughout your whole output buffer
you could turn the function into something as simple as this:
void matrixSetValue(float *output,
float value,
unsigned int rows, unsigned int cols){
unsigned int size = rows * cols;
for(int i = 0; i < size; i++)
output[i] = value;
}