cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

To speed up the calculation

TT_12301010
7-Bedrock

To speed up the calculation

The same program takes longer in mathcad prime10 than mathcad14.

This program uses arrays in particular.

So I got the following information:

"The most efficient way to use computer memory when using matrices is to pre-allocate the matrix. To do this, assign 0 to the last element of the matrix. This ensures that there is enough memory for the remaining elements of the matrix. If you dynamically allocate a matrix by filling in the elements of the matrix from the smallest subscript to the largest subscript, it will take longer to calculate and the worksheet will calculate slower."

But I don't know how to improve it.

Can someone please help me?

 

Translated by the moderation using Google Translate
-----------------------------------------------------------------------------------------------

 

同じプログラムでmathcad14よりmathcad prime10のほうが時間がかかります。

このプログラムでは特に配列を使用しています。

そこで私は次の情報を得ました。

行列を使用するときにコンピュータのメモリを最も効率的に使用する方法は、事前に行列を割り当てることです。このためには、行列の最後の要素に 0 を割り当てます。これによって、行列の残りの要素に十分なメモリが確保されます。一番小さな添字から一番大きな添字まで行列の要素を入力することで行列を動的に割り当てた場合、計算に時間がかかり、ワークシートの計算が遅くなります。

しかし私はどのように改善すればよいかわかりません。

どなたかご協力お願いします。

4 REPLIES 4
Werner_E
25-Diamond I
(To:TT_12301010)

Slow speed of Prime is a well known annoyance and PTC is aware of this. They have promised to pay special attention to increasing the speed of Prime in the upcoming version 11. We will then see next year whether the exercise has been successful...

StuartBruff
23-Emerald III
(To:TT_12301010)


@TT_12301010 wrote:

The same program takes longer in mathcad prime10 than mathcad14.

This program uses arrays in particular.

So I got the following information:

"The most efficient way to use computer memory when using matrices is to pre-allocate the matrix. To do this, assign 0 to the last element of the matrix. This ensures that there is enough memory for the remaining elements of the matrix. If you dynamically allocate a matrix by filling in the elements of the matrix from the smallest subscript to the largest subscript, it will take longer to calculate and the worksheet will calculate slower."

But I don't know how to improve it.

Can someone please help me?

 

Translated by the moderation using Google Translate
-----------------------------------------------------------------------------------------------

 

同じプログラムでmathcad14よりmathcad prime10のほうが時間がかかります。

このプログラムでは特に配列を使用しています。

そこで私は次の情報を得ました。

行列を使用するときにコンピュータのメモリを最も効率的に使用する方法は、事前に行列を割り当てることです。このためには、行列の最後の要素に 0 を割り当てます。これによって、行列の残りの要素に十分なメモリが確保されます。一番小さな添字から一番大きな添字まで行列の要素を入力することで行列を動的に割り当てた場合、計算に時間がかかり、ワークシートの計算が遅くなります。

しかし私はどのように改善すればよいかわかりません。

どなたかご協力お願いします。


 

You initialize the arrays by setting the element with estimated or known last index/indices to zero before assigning any values to the array.   This minimizes the time Mathcad spends adding new elements to a dynamic array.   For most purposes it makes little difference.  However, it can give some time savings for large arrays.   This was more of a problem with early versions of Mathcad running on the much slower PCs of the era.

 

Here are a couple of examples from your worksheet:

 

2024 12 12 C.png

 

Some other small savings may be made by precalculating some of Fourier Transforms.  When indexing CFFT(ee_in)j, for example, Mathcad will evaluate CFFT for each j.

 

Also note that CFFT is deprecated in Mathcad Prime 10, and it is recommended that it is replaced with dft. 

 

"The new dft/idft functions replace the functionality of the deprecated cfft/icfft and CFFT/ICFFT functions and offer significant performance improvement, particularly for larger data sets and cases where the size is not a power of 2.

"Functions dft/idft differ from the deprecated fft/ifftFFT/IFFT and cfft/icfftCFFT/ICFFT in both the scaling factor and the exponent sign." - the scaling factor is now 1 for dft.

 

2024 12 12 B.png

 

I hope that gives you a starting point for improving the worksheet's performance.

 

Stuart

StuartBruff
23-Emerald III
(To:StuartBruff)

I've made a few changes in an attempt to improve performance (eg, replace CFFT/ICFFT by dft/idft, replace some loops with vectorization, and take constant term calculations outside of loops).  Sadly, they do nothing to make the main function run faster.

 

I haven't changed the dft/idft scaling, so the results aren't the same as the CFTT/ICFFT results; I was only interested in seeing if the changes improved performance not the accuracy of the results.

 

Note that I've significantly lowered the values of nsam and RT when testing the main function - I generally like to see the result in a few seconds rather than many minutes!

 

I suggest putting timing points within the main function loop to profile the function and see where any bottlenecks occur.  

 

Stuart

Thank you.

It seems that improving the speed is difficult after all.

This is off topic, but I would like to contact a PTC engineer directly, but I couldn't find anything on the website.

How can I get in touch with a PTC engineer directly?

 

Translated by the moderation using Google Translate
-----------------------------------------------------------------------------------------------

 

ありがとうございました。

やはり速度を向上させることが難しいことがわかりました。

 

今の話とずれてしまいますが、PTCの技術者に直接連絡をして相談したいと思うのですがウェブサイトを見てもわかりませんでした。

PTCの技術者と直接連絡を取るにはどうしたらよいでしょうか。

Announcements

Top Tags