I might have been a bit sloppy with my posts so I'll try to clear things up:
Re: small code segment
I only showed a small segment of code because I'm only seeking general advice about
1. The existence of a specific algorithm for solving the class of problem I presented (lots of linear algebra experts on here so I thought that was a reasonable thing to ask).
2. Direct alternatives to mldivide, such as factorize.m (which, unfortunately, is actually slower for my problem).
3. Whether or not it is possible to inform the mldivide function (or easily modify it) to save it having to decide which algorithm to use every iteration.
To be honest, now I think 1 and 2 are a bit optimistic, and instead I'm hoping someone knows something along the lines of 3 (which I only mentioned in subsequent posts).
Re: Iterations
I'm afraid the "6 million" was from memory (since I didn't think being overly specific mattered for my enquiry)  it shouild actually have been more like 1 million. I was just trying to get the point across that I was using mldivide alot, and that it was necessary to rebuild my matrices every time step using the result of the previous iteration.
Re: while loop
Unfortunately, the code isn't aiming to converge to a single function. It's calculating the y(x,t) for prescribed y(x,t=0)  x is space, t is time. So, I should also have said I need to save each vector every nth time step (every nth rather than every 1 in order to save memory, but this takes up less than 34% of the runtime according to the profiler so I didn't see it as an issue).
So:
I think I may have made the impression that mldivide's speed was a problem  it's not, but since I'm definitely not a Matlab expert, I presumed I hadn't written my code in the optimum way, so I was systematically trying to improve it. I had already seen massive improvements by replacing spdiags, and the profiler results made it obvious that it was time to try with mldivide  except mldivide is builtin and I can't just open it and start deleting if statements....
I would love to hear any suggestions if there are any, but otherwise I'll just hope that in future releases Mathworks allows mldivide to take some options to tell it what not to try...
Thanks for the help anyway Steve.
PLH
"Steven_Lord" <slord@mathworks.com> wrote in message <ibbnug$2rt$1@fred.mathworks.com>...
>
>
> "PLH " <paulhalkyard@googlemail.com> wrote in message
> news:ibb2mb$4s4$1@fred.mathworks.com...
> > Hello and thanks for the reply.
> >
> > I identified the bottleneck using Matlab's profiler, which states that 60%
> > of the runtime is spent in mldivide, 15% is spent in "sparse", and the
> > other 25% is "all other lines" (integrations and the like). Mostly, I've
> > replaced a few Matlab functions (such as spdiags, hence the usage of
> > sparse) with very specific equivalents that are written inline to achieve
> > some speedup. Without using a new approach, I believe the only unit of my
> > code left to attack is mldivide, but I'd appreciate any suggestions along
> > lines too!
>
> Well, you only showed a small segment of your code, so it would be difficult
> to offer suggestions for other avenues of attack.
>
> > Currently, each loops runs for about 10 minutes, which in itself is fine.
> > However, I want to repeat the process for many different parameter sets
> > (the matrix A is a function of 5 parameters set at runtime), so any small
> > speedup will be noticeable  I'm not expecting order of magnitude changes,
> > but a factor of 2 would be nice.
>
> Six million iterations through the loop (based on your posted value of N) in
> 600 seconds is ten thousand iterations per second or one iteration per one
> tenthousandth of a second. That's pretty quick.
>
> Are you iterating that many times through the loop because that's an upper
> bound on how long it'll take to converge or do you really need to iterate
> that many times? If you're just looking for convergence, then use a WHILE
> loop where one of the conditions it tests is your convergence criterion and
> a second condition is the number of iterations (so you don't iterate forever
> if the problem diverges or fails to converge for whatever reason.)
>
> while numberOfIterations <= threshold && <some expression testing
> convergence>
> % solve
> end
>
> > Yes, you're correct  it's an iterativer solver (CrankNicolson with some
> > bells and whistles for a nonlinear PDE). If nothing can be done, then
> > it's not critical  if it was, I'd just spend the next 20 coffees writing
> > it in Fortran. But if someone out there knew the XYZ algorithm for just
> > such a class of banded matrix, or knew some way of informing mldivide of
> > what algorithm to use, then it would have been useful to know.
> >
> > Any suggestions, or should I be happy with what I have?
>
> 
> Steve Lord
> slord@mathworks.com
> comp.softsys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
