mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
Adding Interactive Data Language (IDL) support.
This commit is contained in:
@@ -589,6 +589,12 @@ Haxe:
|
|||||||
extensions:
|
extensions:
|
||||||
- .hxsl
|
- .hxsl
|
||||||
|
|
||||||
|
IDL:
|
||||||
|
type: programming
|
||||||
|
lexer: Text only
|
||||||
|
color: "#e3592c"
|
||||||
|
primary_extension: .pro
|
||||||
|
|
||||||
INI:
|
INI:
|
||||||
type: data
|
type: data
|
||||||
extensions:
|
extensions:
|
||||||
|
|||||||
29
samples/IDL/mg_acosh.pro
Normal file
29
samples/IDL/mg_acosh.pro
Normal 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
|
||||||
9
samples/IDL/mg_analysis.dlm
Normal file
9
samples/IDL/mg_analysis.dlm
Normal 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
35
samples/IDL/mg_gcd.pro
Normal 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
42
samples/IDL/mg_trunc.pro
Normal 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
|
||||||
Reference in New Issue
Block a user