Wednesday, December 09, 2009

A MINOR POINT BUT A TYPICAL SYMPTOM OF WINGER THINKING

Wingnuts can rarely be bothered to dig down enough to know what they are talking about and this post by Vladimir at Red State provides a good example. Vlad tries to make some sense of this IDL code:
yrloc=[1400,findgen(19)*5.+1904]
valadj=[0.,0.,0.,0.,0.,-0.1,-0.25,-0.3,0.,-0.1,0.3,0.8,1.2,1.7,2.5,2.6,2.6,
2.6,2.6,2.6]*0.75 ;

Vlad ignores the seemingly important "*.75" operation and does not alter the values in the array.

Now, it's easy to go to IDL's site and look at what the tutorial says about operations on arrays:
Use the INDGEN function to set the value for each element of the array to its one-dimensional subscript (notice that IDL is a row-major language) :
8. IDL> array = indgen (5, 5)
9. IDL> help, array
ARRAY INT = Array[5, 5]
10. IDL> print, array
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24

Since IDL is an array-oriented language, any operation that is applied to an array variable will automatically affect every element of the array without having to utilize FOR loops.
For example, every element within the variable “array” can be multiplied by the scalar value (2) that is currently stored in the variable “a” with one simple statement :

11. IDL> array = array * a
12. IDL> print, array
0 2 4 6 8
10 12 14 16 18
20 22 24 26 28
30 32 34 36 38
40 42 44 46 48

No comments: