This repository was archived by the owner on Nov 19, 2020. It is now read-only.

Description
A number of linear algebra operations in the library would benefit from being pinned and working directly with pointers. Creating this issue so it can be referenced in git commits. I will pick this up and send a PR once complete.
Vector-Matrix
This shows a comparison of Accord's vector.Dot(matrix, result) versus a proposed change pinning the arrays and using pointer arithmetic.
Size is the size of the matrix (so 32 means a 32 x 32 square matrix). Trials is the number of simulations run. The timings are shown next and then the speed multiplier is shown. So the bottom row shows it is 17 times faster to pin the array than Accord's current method.
| Size |
Trials |
Accord (ms) |
Proposed (ms) |
Multiplier |
| 8 |
4194304 |
750 |
368 |
x2 |
| 16 |
1048576 |
722 |
291 |
x2.5 |
| 32 |
262144 |
684 |
242 |
x2.8 |
| 64 |
65536 |
746 |
242 |
x3.1 |
| 128 |
16384 |
782 |
238 |
x3.3 |
| 256 |
4096 |
1049 |
227 |
x4.6 |
| 512 |
1024 |
1095 |
225 |
x4.9 |
| 1024 |
256 |
2936 |
256 |
x11.5 |
| 2048 |
64 |
3781 |
254 |
x14.9 |
| 4096 |
16 |
4373 |
255 |
x17.1 |
Matrix-Vector
This shows a comparison of Accord's matrix.Dot(vector, result) versus a proposed change pinning the arrays and using pointer arithmetic.
| Size |
Trials |
Accord (ms) |
Proposed (ms) |
Multiplier |
| 8 |
4194304 |
712 |
290 |
x2.5 |
| 16 |
1048576 |
707 |
225 |
x3.1 |
| 32 |
262144 |
714 |
206 |
x3.5 |
| 64 |
65536 |
702 |
199 |
x3.5 |
| 128 |
16384 |
696 |
185 |
x3.8 |
| 256 |
4096 |
688 |
182 |
x3.8 |
| 512 |
1024 |
717 |
179 |
x4 |
| 1024 |
256 |
697 |
205 |
x3.4 |
| 2048 |
64 |
697 |
199 |
x3.5 |
| 4096 |
16 |
698 |
200 |
x3.5 |
Thanks,
Alex