Adding Interactive Data Language (IDL) support.

This commit is contained in:
Michael Galloy
2013-03-07 18:48:27 -07:00
parent 5d5935965a
commit a8b2b0a86b
5 changed files with 121 additions and 0 deletions

View File

@@ -589,6 +589,12 @@ Haxe:
extensions:
- .hxsl
IDL:
type: programming
lexer: Text only
color: "#e3592c"
primary_extension: .pro
INI:
type: data
extensions:

29
samples/IDL/mg_acosh.pro Normal file
View File

@@ -0,0 +1,29 @@
; docformat = 'rst'
;+
; Inverse hyperbolic cosine. Uses the formula:
;
; $$\text{acosh}(z) = \ln(z + \sqrt{z + 1} \sqrt{z - 1})$$
;
; :Examples:
; The arc hyperbolic sine function looks like::
;
; IDL> x = 2.5 * findgen(1000) / 999. + 1.
; IDL> plot, x, mg_acosh(x), xstyle=1
;
; This should look like:
;
; .. image:: acosh.png
;
; :Returns:
; float, double, complex, or double complex depending on the input
;
; :Params:
; z : in, required, type=numeric
; input
;-
function mg_acosh, z
compile_opt strictarr
return, alog(z + sqrt(z + 1) * sqrt(z - 1))
end

View File

@@ -0,0 +1,9 @@
MODULE mg_analysis
DESCRIPTION Tools for analysis
VERSION 1.0
SOURCE mgalloy
BUILD_DATE January 18, 2011
FUNCTION MG_ARRAY_EQUAL 2 2 KEYWORDS
FUNCTION MG_TOTAL 1 1

35
samples/IDL/mg_gcd.pro Normal file
View File

@@ -0,0 +1,35 @@
; docformat = 'rst'
;+
; Find the greatest common denominator (GCD) for two positive integers.
;
; :Returns:
; integer
;
; :Params:
; a : in, required, type=integer
; first integer
; b : in, required, type=integer
; second integer
;-
function mg_gcd, a, b
compile_opt strictarr
on_error, 2
if (n_params() ne 2) then message, 'incorrect number of arguments'
if (~mg_isinteger(a) || ~mg_isinteger(b)) then begin
message, 'integer arguments required'
endif
_a = abs(a)
_b = abs(b)
minArg = _a < _b
maxArg = _a > _b
if (minArg eq 0) then return, maxArg
remainder = maxArg mod minArg
if (remainder eq 0) then return, minArg
return, mg_gcd(minArg, remainder)
end

42
samples/IDL/mg_trunc.pro Normal file
View File

@@ -0,0 +1,42 @@
; docformat = 'rst'
;+
; Truncate argument towards 0.0, i.e., takes the `FLOOR` of positive values
; and the `CEIL` of negative values.
;
; :Examples:
; Try the main-level program at the end of this file. It does::
;
; IDL> print, mg_trunc([1.2, -1.2, 0.0])
; 1 -1 0
; IDL> print, floor([1.2, -1.2, 0.0])
; 1 -2 0
; IDL> print, ceil([1.2, -1.2, 0.0])
; 2 -1 0
;
; :Returns:
; array of same type as argument
;
; :Params:
; x : in, required, type=float/double
; array containing values to truncate
;-
function mg_trunc, x
compile_opt strictarr
result = ceil(x)
posInd = where(x gt 0, nposInd)
if (nposInd gt 0L) then begin
result[posInd] = floor(x[posInd])
endif
return, result
end
; main-level example program
print, mg_trunc([1.2, -1.2, 0.0])
end