Matrix inside a matrix

Matrix inside a matrix - Messages

#1 Posted: 11/23/2021 2:33:01 PM
PedS

PedS

0 likes in 6 posts.

Group: User

Hi everyone

I am trying to create a matrix inside a matrix using a for loop.
This is what I did:

Matrix inside a matrix.sm (12 KiB) downloaded 31 time(s).
Matrix inside a matrix.png

This works but my real data is much larger than the one in this example and it takes like 10 minutes to run. Is there a more efficient way to do this?

Thanks.
#2 Posted: 11/23/2021 3:35:19 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

This works but my real data is much larger than the one in this example and it takes like 10 minutes to run. Is there a more efficient way to do this?


Your example runs in 0.5 s [Steam Engine Win 7]

Matrix inside a matrix.sm (12 KiB) downloaded 32 time(s).

#3 Posted: 11/23/2021 5:51:39 PM
Arie

Arie

93 likes in 285 posts.

Group: User

Two things. One move the assignment of p[k to under the k for loop. You're reassigning to p too often. Also, for large datasets, it helps to initialize the size of the matrix rather than just increasing the size over each iteration. See attaached. Matrix inside a matrix_lyles.sm (15 KiB) downloaded 32 time(s).
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
1 users liked this post
sergio 11/24/2021 6:03:00 AM
#4 Posted: 11/23/2021 6:06:24 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Hola Pedro. Please check this version and tell us how long it takes with your data.

Matrix inside a matrix.sm (31 KiB) downloaded 36 time(s).

Best regards.
Alvaro.
1 users liked this post
sergio 11/24/2021 6:03:00 AM
#5 Posted: 11/23/2021 6:54:21 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Two things.


On my Win 7 ... takes 4 times my original SS 6179 doctored version.
Has it dependence with Smath version ?
Cheers ... Jean.

#6 Posted: 11/23/2021 7:00:08 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Hola Pedro. Please check this version and tell us how long it takes with your data.


Timing is about twice my doctored version.
#7 Posted: 11/23/2021 7:20:04 PM
PedS

PedS

0 likes in 6 posts.

Group: User

Wrote

Two things. One move the assignment of p[k to under the k for loop. You're reassigning to p too often. Also, for large datasets, it helps to initialize the size of the matrix rather than just increasing the size over each iteration. See attaached. Matrix inside a matrix_lyles.sm (15 KiB) downloaded 32 time(s).



Thanks a lot, this works perfectly
#8 Posted: 11/23/2021 7:21:22 PM
PedS

PedS

0 likes in 6 posts.

Group: User

Wrote

Hola Pedro. Please check this version and tell us how long it takes with your data.

Matrix inside a matrix.sm (31 KiB) downloaded 36 time(s).

Best regards.
Alvaro.



Gracias, aprecio tu ayuda
#9 Posted: 11/23/2021 9:51:43 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Your example runs in 0.5 s [Steam Engine Win 7]


... annotated attachment ...Cheers ... Jean

Matrix inside a matrix (Proposal).sm (31 KiB) downloaded 40 time(s).
#10 Posted: 11/25/2021 9:15:52 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

This works but my real data is much larger than the one in this example and it takes like 10 minutes to run. Is there a more efficient way to do this?


1. Wait and see your next Monster Big.
2. 10 min on your machine might take 1 hr on mine, but willing.
3. Maybe not not so big and interpolate ?
See you sometimes, Cheers ... Jean

  • New Posts New Posts
  • No New Posts No New Posts