mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-01-16 21:58:27 +01:00
Minor change in is_matrix_symmetric
This commit is contained in:
parent
c5799d6539
commit
5062ee1605
12
arrays.scad
12
arrays.scad
@ -42,6 +42,7 @@ function is_homogeneous(l, depth=10) =
|
|||||||
|
|
||||||
function is_homogenous(l, depth=10) = is_homogeneous(l, depth);
|
function is_homogenous(l, depth=10) = is_homogeneous(l, depth);
|
||||||
|
|
||||||
|
|
||||||
function _same_type(a,b, depth) =
|
function _same_type(a,b, depth) =
|
||||||
(depth==0) ||
|
(depth==0) ||
|
||||||
(is_undef(a) && is_undef(b)) ||
|
(is_undef(a) && is_undef(b)) ||
|
||||||
@ -97,7 +98,6 @@ function select(list, start, end) =
|
|||||||
|
|
||||||
|
|
||||||
// Function: slice()
|
// Function: slice()
|
||||||
// Topics: List Handling
|
|
||||||
// Usage:
|
// Usage:
|
||||||
// list = slice(list,s,e);
|
// list = slice(list,s,e);
|
||||||
// Description:
|
// Description:
|
||||||
@ -476,7 +476,7 @@ function reverse(x) =
|
|||||||
// l9 = list_rotate([1,2,3,4,5],6); // Returns: [2,3,4,5,1]
|
// l9 = list_rotate([1,2,3,4,5],6); // Returns: [2,3,4,5,1]
|
||||||
function list_rotate(list,n=1) =
|
function list_rotate(list,n=1) =
|
||||||
assert(is_list(list)||is_string(list), "Invalid list or string.")
|
assert(is_list(list)||is_string(list), "Invalid list or string.")
|
||||||
assert(is_finite(n), "Invalid number")
|
assert(is_int(n), "The rotation number should be integer")
|
||||||
let (
|
let (
|
||||||
ll = len(list),
|
ll = len(list),
|
||||||
n = ((n % ll) + ll) % ll,
|
n = ((n % ll) + ll) % ll,
|
||||||
@ -1332,6 +1332,8 @@ function permutations(l,n=2) =
|
|||||||
// pairs = zip(a,b);
|
// pairs = zip(a,b);
|
||||||
// triples = zip(a,b,c);
|
// triples = zip(a,b,c);
|
||||||
// quads = zip([LIST1,LIST2,LIST3,LIST4]);
|
// quads = zip([LIST1,LIST2,LIST3,LIST4]);
|
||||||
|
// Topics: List Handling, Iteration
|
||||||
|
// See Also: zip_long()
|
||||||
// Description:
|
// Description:
|
||||||
// Zips together two or more lists into a single list. For example, if you have two
|
// Zips together two or more lists into a single list. For example, if you have two
|
||||||
// lists [3,4,5], and [8,7,6], and zip them together, you get [[3,8],[4,7],[5,6]].
|
// lists [3,4,5], and [8,7,6], and zip them together, you get [[3,8],[4,7],[5,6]].
|
||||||
@ -1357,6 +1359,8 @@ function zip(a,b,c) =
|
|||||||
// pairs = zip_long(a,b);
|
// pairs = zip_long(a,b);
|
||||||
// triples = zip_long(a,b,c);
|
// triples = zip_long(a,b,c);
|
||||||
// quads = zip_long([LIST1,LIST2,LIST3,LIST4]);
|
// quads = zip_long([LIST1,LIST2,LIST3,LIST4]);
|
||||||
|
// Topics: List Handling, Iteration
|
||||||
|
// See Also: zip()
|
||||||
// Description:
|
// Description:
|
||||||
// Zips together two or more lists into a single list. For example, if you have two
|
// Zips together two or more lists into a single list. For example, if you have two
|
||||||
// lists [3,4,5], and [8,7,6], and zip them together, you get [[3,8],[4,7],[5,6]].
|
// lists [3,4,5], and [8,7,6], and zip them together, you get [[3,8],[4,7],[5,6]].
|
||||||
@ -1526,7 +1530,6 @@ function subindex(M, idx) =
|
|||||||
// [[4,2], 91, false],
|
// [[4,2], 91, false],
|
||||||
// [6, [3,4], undef]];
|
// [6, [3,4], undef]];
|
||||||
// submatrix(A,[0,2],[1,2]); // Returns [[17, "test"], [[3, 4], undef]]
|
// submatrix(A,[0,2],[1,2]); // Returns [[17, "test"], [[3, 4], undef]]
|
||||||
|
|
||||||
function submatrix(M,idx1,idx2) =
|
function submatrix(M,idx1,idx2) =
|
||||||
[for(i=idx1) [for(j=idx2) M[i][j] ] ];
|
[for(i=idx1) [for(j=idx2) M[i][j] ] ];
|
||||||
|
|
||||||
@ -1629,7 +1632,6 @@ function block_matrix(M) =
|
|||||||
assert(badrows==[], "Inconsistent or invalid input")
|
assert(badrows==[], "Inconsistent or invalid input")
|
||||||
bigM;
|
bigM;
|
||||||
|
|
||||||
|
|
||||||
// Function: diagonal_matrix()
|
// Function: diagonal_matrix()
|
||||||
// Usage:
|
// Usage:
|
||||||
// mat = diagonal_matrix(diag, <offdiag>);
|
// mat = diagonal_matrix(diag, <offdiag>);
|
||||||
@ -1855,7 +1857,7 @@ function transpose(arr, reverse=false) =
|
|||||||
// A = matrix to test
|
// A = matrix to test
|
||||||
// eps = epsilon for comparing equality. Default: 1e-12
|
// eps = epsilon for comparing equality. Default: 1e-12
|
||||||
function is_matrix_symmetric(A,eps=1e-12) =
|
function is_matrix_symmetric(A,eps=1e-12) =
|
||||||
approx(A,transpose(A));
|
approx(A,transpose(A), eps);
|
||||||
|
|
||||||
|
|
||||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user