array_group -> list_to_matrix fixes

This commit is contained in:
Adrian Mariano 2021-10-26 23:17:21 -04:00
parent 71dab62432
commit 2eff8ec203
6 changed files with 10 additions and 8 deletions

View File

@ -745,7 +745,7 @@ function group_sort(list, idx) =
// Usage:
// groupings = group_data(groups, values);
// Topics: Array Handling
// See Also: zip(), zip_long(), array_group()
// See Also: zip(), zip_long()
// Description:
// Given a list of integer group numbers, and an equal-length list of values,
// returns a list of groups with the values sorted into the corresponding groups.

View File

@ -321,7 +321,7 @@ function submatrix_set(M,A,m=0,n=0) =
// Description:
// Constructs a matrix by horizontally "stacking" together compatible matrices or vectors. Vectors are treated as columsn in the stack.
// This command is the inverse of `column`. Note: strings given in vectors are broken apart into lists of characters. Strings given
// in matrices are preserved as strings. If you need to combine vectors of strings use array_group as shown below to convert the
// in matrices are preserved as strings. If you need to combine vectors of strings use {{list_to_matrix}} as shown below to convert the
// vector into a column matrix. Also note that vertical stacking can be done directly with concat.
// Arguments:
// M1 = If given with other arguments, the first matrix (or vector) to stack. If given alone, a list of matrices/vectors to stack.
@ -344,7 +344,7 @@ function submatrix_set(M,A,m=0,n=0) =
// strmat = [["three","four"], ["five","six"]];
// e = hstack(strvec,strvec); // Returns [["o", "n", "e", "o", "n", "e"],
// // ["t", "w", "o", "t", "w", "o"]]
// f = hstack(array_group(strvec,1), array_group(strvec,1));
// f = hstack(list_to_matrix(strvec,1), list_to_matrix(strvec,1));
// // Returns [["one", "one"],
// // ["two", "two"]]
// g = hstack(strmat,strmat); // Returns: [["three", "four", "three", "four"],

View File

@ -549,7 +549,7 @@ function gaussian_rands(N=1, mean=0, cov=1, seed=undef) =
L = cholesky(cov)
)
assert(is_def(L), "Supplied covariance matrix is not positive definite")
move(mean,array_group(rdata,dim)*transpose(L));
move(mean,list_to_matrix(rdata,dim)*transpose(L));
// Function: spherical_random_points()

View File

@ -795,7 +795,7 @@ function _path_cut_points(path, dists, closed=false, direction=false) =
dir = _path_cuts_dir(path, cuts, closed),
normals = _path_cuts_normals(path, cuts, dir, closed)
)
hstack(cuts, array_group(dir,1), array_group(normals,1));
hstack(cuts, list_to_matrix(dir,1), list_to_matrix(normals,1));
// Main recursive path cut function
function _path_cut_points_recurse(path, dists, closed=false, pind=0, dtotal=0, dind=0, result=[]) =

View File

@ -1,3 +1,5 @@
include<../std.scad>
module test_sort() {
assert(sort([7,3,9,4,3,1,8]) == [1,3,3,4,7,8,9]);
assert(sort([[4,0],[7],[3,9],20,[4],[3,1],[8]]) == [20,[3,1],[3,9],[4],[4,0],[7],[8]]);

View File

@ -363,7 +363,7 @@ function furthest_point(pt, points) =
// Example: A set of four queries to find points within 1 unit of the query. The circles show the search region and all have radius 1.
// $fn=32;
// k = 2000;
// points = array_group(rands(0,10,k*2,seed=13333),2);
// points = list_to_matrix(rands(0,10,k*2,seed=13333),2);
// queries = [for(i=[3,7],j=[3,7]) [i,j]];
// search_ind = vector_search(queries, points, 1);
// move_copies(points) circle(r=.08);
@ -374,7 +374,7 @@ function furthest_point(pt, points) =
// Example: when a series of search with different radius are needed, its is faster to pre-compute the tree
// $fn=32;
// k = 2000;
// points = array_group(rands(0,10,k*2),2,seed=13333);
// points = list_to_matrix(rands(0,10,k*2),2,seed=13333);
// queries1 = [for(i=[3,7]) [i,i]];
// queries2 = [for(i=[3,7]) [10-i,i]];
// r1 = 1;
@ -517,7 +517,7 @@ function _bt_tree(points, ind, leafsize=25) =
// Example: Four queries to find the 15 nearest points. The circles show the radius defined by the most distant query result. Note they are different for each query.
// $fn=32;
// k = 1000;
// points = array_group(rands(0,10,k*2,seed=13333),2);
// points = list_to_matrix(rands(0,10,k*2,seed=13333),2);
// tree = vector_search_tree(points);
// queries = [for(i=[3,7],j=[3,7]) [i,j]];
// search_ind = [for(q=queries) vector_nearest(q, 15, tree)];