Question

While previously attempting to ascertain the dimensions of a matrix, I have used the core.matrix function shape. This function has done exactly what I have asked. I input one nested vector into the function and output the dimension. However, I am looking to input multiple matrices/nested vectors into the function and am running into trouble. Is the shape function capable of handling multiple inputs, or is there another way to determine the dimensions of multiple nested vectors?

An example input would look like: [[1 1] [1 1]] [[2 2 2] [2 2 2]]

the expected output would be: [2 2] for first matrix and [3 3] for second matrix, as both inputs are square matrices.

Was it helpful?

Solution

This sounds a bit like mapping shape over the slices of a matrix.
If you write your input as [[[1 1] [1 1]] [[2 2 2] [2 2 2]]] then call (slices 0 ...) on that it would give you the sequence of matrices that you can then feed to the map function. Or you can skip the slices part and just (map shape list-of-matrices).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top