简体   繁体   中英

How to create a square matrix with infinite rows

I need to create a matrix with an unknown number of cells and rows. It will be determinated on the last iteration of a loop and the matrix must be filled each loop in a triangular shape. I don't care on how can I fill the matrix, but on how can I create it.

Thanks!

If you're doing a loop to create rows, numpy will not be very efficient because it will need to reallocate and copy memory content at each iteration. You might as well create a list of list in regular Python and convert it to a numpy matrix only at the end once you know the size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM