Tag Archives: code performance

Testing parameters with N_ELEMENTS and !null

The N_ELEMENTS function is typically used to test whether an input parameter has data. For example, here’s a program that doubles a number: function double_it, x compile_opt idl2 on_error, 2 if n_elements(x) eq 0 then $ message, ‘Need input number … Continue reading

Posted in language, programming | Tagged , , , | 6 Comments

An LSD radix sort algorithm in IDL

(Note: I’m at the HDF and HDF-EOS Workshop XV this week, so today I have a guest post by Atle Borsholm, a Senior Consultant in the Exelis VIS Professional Services Group. Atle is an IDL master. I’m trying to persuade … Continue reading

Posted in data analysis, language, programming | Tagged , , , , | 6 Comments

Order of operations in an expression

Given a floating-point array x, which of these two statements: IDL> y1 = 2.0 * x / 3.0 IDL> y2 = x * (2.0 / 3.0) executes faster, the first or the second? Note that both statements produce the same … Continue reading

Posted in language, programming | Tagged , | 3 Comments

The COMPILE_OPT statement; you should use it!

The COMPILE_OPT statement alters IDL’s compile-time behavior. The statement is locally scoped; i.e., it changes IDL’s behavior only within the routine in which it is declared. I use the IDL2 option (a shorthand for the DEFINT32 and STRICTARR options) in all new procedures, functions and methods I write. … Continue reading

Posted in language, programming | Tagged , , | 8 Comments

On the dangers of keyword inheritance

(Note: This is a guest post by Jim Pendleton, an Advisory Consultant in the Exelis VIS Professional Services Group. Jim has been using IDL longer than anyone, including himself, can remember. He’s also my IDL guru—when I have IDL questions, … Continue reading

Posted in language, programming | Tagged , , , , | 3 Comments

Disable window updates to improve (New) Graphics performance

When making a visualization with many graphic elements in NG, you can improve the render speed by disabling updates to the window. For example, this program displays a 3-by-5 grid of sample plots and prints to the console the time … Continue reading

Posted in language, programming, visualization | Tagged , , | 6 Comments