Best coding practice

Dear Gauss people,

My colleague and I have different intuition about what is the best way of coding some big calculations. That is, we need both to conserve memory requirements and we need to reduce computing times. Here are three alternatives:

1) Step by step:
a=(big calculation);
b=(another big calculation);
c=(big calculation involving a and b);

2) Reusing b/c space:
a=(big calculation);
c=(another big calculation);
c=(big calculation involving a and b);

3) Let the compiler choose:
c=(big calculation involving (big calculation) and (another big calculation));

Is it possible to say which is generally better? Maybe depends on how big is big?

Thank you,

1 Answer


Option #1 will never be the fastest because GAUSS will not have the option to reuse the memory used for a and b when creating c.

In most cases, #3 will be the fastest. However, if the data size is large compared to your available RAM and the particular big calculation requires lots of extra memory to be allocated for intermediate calculations, then #3 could be slower.

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy