topic Matrix preallocation of functions in PTC Mathcad
https://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215779#M84395
<HTML><HEAD></HEAD><BODY><P><SPAN style="font-size: 12pt;">I'm handling matrices that contain large numbers of functions that are symbolically evaluated, and then used to create differential equations for a solver such as Radau to solve.</SPAN></P><P></P><P><SPAN style="font-size: 12pt;">I want to preallocate the matrices in order to speed up the rate that my code executes at, since there are a lot of these functions (about 700). </SPAN></P><P></P><P><SPAN style="font-size: 12pt;">I understand how to preallocate normal matrices of actual number values via this method, where M is a 500 X 1 matrix:</SPAN></P><P></P><P><SPAN style="font-size: 12pt;">M[500,1:=0</SPAN></P><P></P><P><SPAN style="font-size: 12pt;">...and then you would define M via a file upload, or manual entering of data, via calculations from other matrices, or from a programming loop.</SPAN></P><P></P><P><SPAN style="font-size: 12pt;">But...if I want a matrix of functions, how do I do it?</SPAN></P><P></P><P><SPAN style="font-size: 12pt;">If M is a function of x for example, and I enter this into Matcad:</SPAN></P><P></P><P><SPAN style="font-size: 12pt;">M(x)[500,1:=0</SPAN></P><P></P><P><SPAN style="font-size: 12pt;">then Mathcad makes the M red, and says "a name is required here." Also, even if I use an 'x' instead of a zero to define the preallocation, it still gives me the same warning.</SPAN></P><P></P><P><SPAN style="font-size: 12pt;">Does anyone know how or if matrices of functions can be preallocated?</SPAN></P></BODY></HTML>Thu, 03 May 2018 17:56:17 GMTptc-30312212018-05-03T17:56:17ZMatrix preallocation of functions
https://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215779#M84395
I'm handling matrices that contain large numbers of functions that are symbolically evaluated, and then used to create differential equations for a solver such as Radau to solve.I want to preallocate the matrices in order to speed up the rate that my code executes at, since thereThu, 03 May 2018 17:56:17 GMThttps://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215779#M84395ptc-30312212018-05-03T17:56:17ZRe: Matrix preallocation of functions
https://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215780#M84396
<HTML><HEAD></HEAD><BODY><P>It's not 100% clear to me what you are trying to do, but does this help?</P><P></P><P><IMG alt="Array of functions.jpg" class="jive-image" src="https://community.ptc.com/legacyfs/online/35556_Array+of+functions.jpg" /></P></BODY></HTML>Wed, 01 Aug 2012 18:35:36 GMThttps://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215780#M84396RichardJ2012-08-01T18:35:36ZRe: Matrix preallocation of functions
https://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215781#M84397
<HTML><HEAD></HEAD><BODY><P>No, that's not quite what I'm looking for. By preallocate, I mean that if you are working with large matrices, you can speed up your computations if you tell Mathcad ahead of time how large the matrix is going to be. Normally you do this by specifying a value of zero to the last value of the matrix (extreme right, bottom cell). If you don't do this, Mathcad expands the matrix size of the result by one cell every time it repeats a calc, and expands the RAM allocated to storing that matrix as well. This extra activity slows it down significantly when the matrices are large. I have some matrices of functions that are large enough that I would like to preallocate them, but the normal way of preallocating them isn't working.</P><P></P><P>Does that make sense?</P></BODY></HTML>Wed, 01 Aug 2012 21:30:39 GMThttps://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215781#M84397ptc-30312212012-08-01T21:30:39ZRe: Matrix preallocation of functions
https://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215782#M84398
<HTML><HEAD></HEAD><BODY><P>Something like this?</P><P></P><P><IMG alt="matrix.PNG" class="jive-image" src="https://community.ptc.com/legacyfs/online/35566_matrix.PNG" /></P><P></P><P>Alan</P></BODY></HTML>Wed, 01 Aug 2012 21:45:15 GMThttps://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215782#M84398AlanStevens2012-08-01T21:45:15ZRe: Matrix preallocation of functions
https://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215783#M84399
<HTML><HEAD></HEAD><BODY><BLOCKQUOTE><TABLE border="1"><TBODY><TR><TD><P>Normally you do this by specifying a value of zero to the last value of the matrix (extreme right, bottom cell).</P></TD></TR></TBODY></TABLE></BLOCKQUOTE><P>You can enter anything into the last matrix element, it doesn't have to be zero. In the rather trivial example I showed the last element is 2, and I allocated that first. If you delete the lines assigning functions to M0 and M1 you will see you have a three element vector, with the first two elements set to zero.</P><P></P><P>Preallocation actually makes much less difference in the latest version of Mathcad. It used to make a huge difference, but not any more.</P></BODY></HTML>Wed, 01 Aug 2012 21:53:03 GMThttps://community.ptc.com/t5/PTC-Mathcad/Matrix-preallocation-of-functions/m-p/215783#M84399RichardJ2012-08-01T21:53:03Z