Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
quick matrix speed
(version: 0)
massive
Comparing performance of:
3x3 vs 4x4 vs 3x3 old vs 4x4 old vs 8x8 vs 8x8 old vs detRemove 8x8
Created:
7 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function detRemove(matrix, index) { let temp = []; for (let i = 1; i < matrix.length; i++) { // pushing a slice instead of a reference avoids the consequences of reference semantics // when chopping the temp array. temp.push(matrix[i].slice(0)); temp[temp.length - 1].splice(index, 1); } return temp; }
Tests:
3x3
function quickDeterminate(matrix) { let detSum = 0; if (matrix.length !== matrix[0].length || matrix.length === 1) { throw "Invalid matrix input."; } else if (matrix.length === 2) { return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]; } else { for (let i = 0; i < matrix[0].length; i++) { let temp = detRemove(matrix, i); detSum += matrix[0][i] * quickDeterminate(temp) * Math.pow(-1, i); } } return detSum; } quickDeterminate([[1, 3, 2], [0, 1, 16], [5, 25, 1]])
4x4
function quickDeterminate(matrix) { let detSum = 0; if (matrix.length !== matrix[0].length || matrix.length === 1) { throw "Invalid matrix input."; } else if (matrix.length === 2) { return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]; } else { for (let i = 0; i < matrix[0].length; i++) { let temp = detRemove(matrix, i); detSum += matrix[0][i] * quickDeterminate(temp) * Math.pow(-1, i); } } return detSum; } quickDeterminate([[1, 3, 2, 4], [0, 1, 16, 5], [5, 25, 1, 25], [16, 24, 32, 11]])
3x3 old
function quickDeterminate(matrix) { let detSum = 0; if (matrix.length !== matrix[0].length || matrix.length === 1) { throw "Invalid matrix input."; } else if (matrix.length === 2) { return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]; } else { for (let i = 0; i < matrix[0].length; i++) { let babyArray = []; for (let j = 1; j < matrix.length; j++) { let row = []; for (let k = 0; k < matrix.length; k++) { if (i === 0 && i === k) { k++; } row.push(matrix[j][k]); if (k === (i - 1)) { k++; } } babyArray.push(row); } detSum += matrix[0][i] * quickDeterminate(babyArray); } } return detSum; } quickDeterminate([[1, 3, 2], [0, 1, 16], [5, 25, 1]])
4x4 old
function quickDeterminate(matrix) { let detSum = 0; if (matrix.length !== matrix[0].length || matrix.length === 1) { throw "Invalid matrix input."; } else if (matrix.length === 2) { return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]; } else { for (let i = 0; i < matrix[0].length; i++) { let babyArray = []; for (let j = 1; j < matrix.length; j++) { let row = []; for (let k = 0; k < matrix.length; k++) { if (i === 0 && i === k) { k++; } row.push(matrix[j][k]); if (k === (i - 1)) { k++; } } babyArray.push(row); } detSum += matrix[0][i] * quickDeterminate(babyArray); } } return detSum; } quickDeterminate([[1, 3, 2, 4], [0, 1, 16, 5], [5, 25, 1, 25], [16, 24, 32, 11]])
8x8
function quickDeterminate(matrix) { let detSum = 0; if (matrix.length !== matrix[0].length || matrix.length === 1) { throw "Invalid matrix input."; } else if (matrix.length === 2) { return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]; } else { for (let i = 0; i < matrix[0].length; i++) { let temp = detRemove(matrix, i); detSum += matrix[0][i] * quickDeterminate(temp) * Math.pow(-1, i); } } return detSum; } quickDeterminate([[1, 3, 2, 4, 16, 5, 34, 9], [0, 1, 16, 5, 42, 1, -5, 6], [5, 25, 1, 25, 15, 232, 1, 6], [16, 24, 32, 11, 25, 24, 24, -15], [1, 3, 2, 4, 10, 5, 22, -15], [0, 1, 16, 5, -22, 16, 8, 4], [5, 25, 1, 25, 15, 222, -225, 15], [16, 24, 32, 11, 15, 14, 13, 12]])
8x8 old
function quickDeterminate(matrix) { let detSum = 0; if (matrix.length !== matrix[0].length || matrix.length === 1) { throw "Invalid matrix input."; } else if (matrix.length === 2) { return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]; } else { for (let i = 0; i < matrix[0].length; i++) { let babyArray = []; for (let j = 1; j < matrix.length; j++) { let row = []; for (let k = 0; k < matrix.length; k++) { if (i === 0 && i === k) { k++; } row.push(matrix[j][k]); if (k === (i - 1)) { k++; } } babyArray.push(row); } detSum += matrix[0][i] * quickDeterminate(babyArray); } } return detSum; } quickDeterminate([[1, 3, 2, 4, 16, 5, 34, 9], [0, 1, 16, 5, 42, 1, -5, 6], [5, 25, 1, 25, 15, 232, 1, 6], [16, 24, 32, 11, 25, 24, 24, -15], [1, 3, 2, 4, 10, 5, 22, -15], [0, 1, 16, 5, -22, 16, 8, 4], [5, 25, 1, 25, 15, 222, -225, 15], [16, 24, 32, 11, 15, 14, 13, 12]])
detRemove 8x8
detRemove([[1, 3, 2, 4, 16, 5, 34, 9], [0, 1, 16, 5, 42, 1, -5, 6], [5, 25, 1, 25, 15, 232, 1, 6], [16, 24, 32, 11, 25, 24, 24, -15], [1, 3, 2, 4, 10, 5, 22, -15], [0, 1, 16, 5, -22, 16, 8, 4], [5, 25, 1, 25, 15, 222, -225, 15], [16, 24, 32, 11, 15, 14, 13, 12]], 4)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (7)
Previous results
Fork
Test case name
Result
3x3
4x4
3x3 old
4x4 old
8x8
8x8 old
detRemove 8x8
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It seems like you're referring to the benchmark results for a matrix operations library. Let's break down what I can infer from the provided text: **Previous Benchmark** The previous benchmark had two test cases: 1. "detRemove([[1, 3, 2, 4, 16, 5, 34, 9], [0, 1, 16, 5, 42, 1, -5, 6], [5, 25, 1, 25, 15, 232, 1, 6], [16, 24, 32, 11, 25, 24, 24, -15], [1, 3, 2, 4, 10, 5, 22, -15], [0, 1, 16, 5, -22, 16, 8, 4], [5, 25, 1, 25, 15, 222, -225, 15], [16, 24, 32, 11, 15, 14, 13, 12]], 4)" 2. "detRemove([[1, 3, 2, 4, 16, 5, 34, 9], [0, 1, 16, 5, 42, 1, -5, 6], [5, 25, 1, 25, 15, 232, 1, 6], [16, 24, 32, 11, 25, 24, 24, -15], [1, 3, 2, 4, 10, 5, 22, -15], [0, 1, 16, 5, -22, 16, 8, 4], [5, 25, 1, 25, 15, 222, -225, 15], [16, 24, 32, 11, 15, 14, 13, 12]], 8)" The results for these tests are: * "detRemove([[1, 3, 2, 4, 16, 5, 34, 9], [0, 1, 16, 5, 42, 1, -5, 6], [5, 25, 1, 25, 15, 232, 1, 6], [16, 24, 32, 11, 25, 24, 24, -15], [1, 3, 2, 4, 10, 5, 22, -15], [0, 1, 16, 5, -22, 16, 8, 4], [5, 25, 1, 25, 15, 222, -225, 15], [16, 24, 32, 11, 15, 14, 13, 12]], 4)" * "detRemove([[1, 3, 2, 4, 16, 5, 34, 9], [0, 1, 16, 5, 42, 1, -5, 6], [5, 25, 1, 25, 15, 232, 1, 6], [16, 24, 32, 11, 25, 24, 24, -15], [1, 3, 2, 4, 10, 5, 22, -15], [0, 1, 16, 5, -22, 16, 8, 4], [5, 25, 1, 25, 15, 222, -225, 15], [16, 24, 32, 11, 15, 14, 13, 12]], 8)" **Latest Benchmark** The latest benchmark results show the performance of the same test cases, but with different metrics: * "3x3 old" * "detRemove 8x8" * "4x4 old" * "3x3" * "4x4" * "8x8 old" * "8x8" The latest results show that: * The "detRemove" test with a 3x3 matrix is faster than the previous result. * The "detRemove" test with an 8x8 matrix has improved performance compared to the previous result. * The "4x4" and "3x3" tests have decreased execution times. * The "8x8 old" and "8x8" tests show a significant improvement in performance. Please let me know if you'd like me to help with anything else!
Related benchmarks:
Slice vs Splice vs Shift (Large Array)
Slice vs Splice vs Shiftxxxxxx
Splice vs shift to remove at beginning of array (fixed from slice)
Slice vs Splice vs Shift in cycle
Empty array: Splice vs Shift
Comments
Confirm delete:
Do you really want to delete benchmark?