J
jacob navia
In the context of the C Containers library I am now implementing "ValArray"
These containers store the basic numeric types (integers and floats)
of the language.
They support the basic operations that can be done with those types.
The question is:
ValArray A,B,C;
// ...
C = iValArrayDouble.SumTo(B,A);
This is the equivalent of B += A in C++.
The question is, what happens when Size(A) != Size(B). C++
leaves that as "undefined", probably crashing. My library
throws an error and does nothing.
An alternative solution would be to use the length of B for the
operation in question, extending the shorter array if necessary
or discarding results that go beyond the length of B.
Operation Identity elem.
+ 0
- 0
* 1
/ 1
& 1
| 0
% 1 (for integers only)
Xor ????
What do you think?
Which alternative is better?
jacob
These containers store the basic numeric types (integers and floats)
of the language.
They support the basic operations that can be done with those types.
The question is:
ValArray A,B,C;
// ...
C = iValArrayDouble.SumTo(B,A);
This is the equivalent of B += A in C++.
The question is, what happens when Size(A) != Size(B). C++
leaves that as "undefined", probably crashing. My library
throws an error and does nothing.
An alternative solution would be to use the length of B for the
operation in question, extending the shorter array if necessary
or discarding results that go beyond the length of B.
Operation Identity elem.
+ 0
- 0
* 1
/ 1
& 1
| 0
% 1 (for integers only)
Xor ????
What do you think?
Which alternative is better?
jacob