Does tilda in a function output give any speed up?

2 visualizaciones (últimos 30 días)
Anton
Anton el 12 de Mzo. de 2016
Respondida: Kuba el 25 de Jul. de 2016
If, say, I use
[a,b,~]=svd(d);
instead of
[a,b,c]=svd(d);
should I generally expect any speed up and/or memory saving? Or it depends on the function I use and should be tested each time?

Respuestas (3)

Star Strider
Star Strider el 12 de Mzo. de 2016
Time it and find out!
I doubt it, though. The value is still calculated, but no space is made for it in the calling function workspace.

Jan
Jan el 12 de Mzo. de 2016
From inside the function there is no way to check, if the 3rd agrument is caught in the caller or not. Therefor the runtime for the function must be the same. But the calling function can free the memory for the argument immediately. For huge arrays this can be an advantage under certain circumstances, but not in general.

Kuba
Kuba el 25 de Jul. de 2016
And what about using tilda in input arguments, say:
[a,b,c]=svd(~, e);
Instead of:
[a,b,c]=svd(d, e);
Is there any difference in performance?

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by