简体   繁体   中英

Is there a better way to copy a matrix in Julia than copy()?

I just realized that the "=" operator in Julia acts more like a pointer for matrices than an assignment. For example, if I have a matrix A and I set a new matrix B with B=A , then any modification to B will also apply to A . Instead, I want to initialize B with A , but any changes that I make to B I do not want to apply to A . My current solution is to use Julia's copy() function, but it seems to take a non-negligible amount of time, and it seems like using copy() is a clunky solution. Any solutions/work-arounds would be greatly appreciated. Thank you!

I have a solution to my problem [copy()], but I assume there is a better solution out there.

similar(A) creates the array without copying the values.

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