Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Slow matrix operation

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-03-2019
02:46 PM

03-03-2019
02:46 PM

Attached is a little example of a problem I'm seeing - in simplified format only to demonstrate the issue. Background - I'm doing a 2D finite difference problem and during setup mathcad slows down an unacceptable amount and I can't see why it should.

I tried it in 5.0 with no change. On my machine the 'slow' program here takes about 5 seconds, while the 'fast' examples are instantaneous - as expected since there's no real calculation ongoing.

I don't see why it should slow down like this. I suspect it's recalculating the 'node' matrix over and over. Or possibly a bug. Anything I'm doing wrong?

4.0 and pdf attached.

Thanks,

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-03-2019
04:52 PM

03-03-2019
04:52 PM

Your three routines create differently sized matrices ans so the time difference is understandable.

I renamed them and turned them into functions of a dummy argument for timing purposes:

Its always a good idea to let Mathcad preallocate the memory for the full matrix first and dont't let the matrix "grow slowly". A simple modification to your slow routine makes it as fast as the others:

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-03-2019
04:21 PM

03-03-2019
04:21 PM

Re: Slow matrix operation

Why would you index A with a column number from the node matrix?

Have you seen what the values in the node matrix are.

They run up to (Mdiv-1)*Ndiv+Ndiv, that is, the mximum number is 39*70+70=40*70=2800.

So all of a sudden you could be creating an element for A in its 2800th column.

Mathcad slows down when you change size of a matrix, I guess Prime is no exception.

I'm not surprised that Prime 5 shows the same behaviour. There's NO difference between Prime4 and Prime5, other than that Prime5 includes a 3rd party plotting tool.

Success!

Luc

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-03-2019
04:52 PM

03-03-2019
04:52 PM

Your three routines create differently sized matrices ans so the time difference is understandable.

I renamed them and turned them into functions of a dummy argument for timing purposes:

Its always a good idea to let Mathcad preallocate the memory for the full matrix first and dont't let the matrix "grow slowly". A simple modification to your slow routine makes it as fast as the others:

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-03-2019
05:18 PM

03-03-2019
05:18 PM

Re: Slow matrix operation

Thanks Werner, the preallocation does the trick. I realize there are size differences between the examples, but a 2800x2800 matrix should be (and is) lightning fast, as I've played with much bigger ones without issue many times. Lesson learned - although i actually always kinda liked how Mathcad doesn't require matrix definition. First time it's ever gotten me in trouble, to my knowledge.

Top Tags