gsl4r 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,5 +1,7 @@
1
1
  == Description
2
2
 
3
+ ALPHA - ALPHA - ALPHA
4
+
3
5
  GSL4r
4
6
  Ruby GNU Scientific Library via FFI
5
7
 
@@ -9,7 +11,7 @@ This avoids the complications with implementation specific C extensions or Java
9
11
 
10
12
  == Documentation
11
13
 
12
- This project is currently in its alpha stages and as of 11 Feb 2010, I have only pushed a library for using Complex functions in GSL.
14
+ This project is currently in its alpha stages and as of 01 Mar 2010, I have only pushed a library for using Complex functions in GSL, all constants are defined, and some functions for handling blocks and vectors containing blocks.
13
15
 
14
16
  == Getting Started
15
17
 
@@ -19,16 +21,14 @@ git clone git://rubyforge.org/gsl4r.git
19
21
 
20
22
  == Installing gsl4r
21
23
 
22
- There is no installation available at this time.
24
+ gem install -r gsl4r
23
25
 
24
26
  == Examples
25
27
 
26
28
  cd gsl4r/lib
27
- irb -r gsl4r
28
- irb(main):001:0> require 'gsl4r/complex'
29
- => true
30
- irb(main):002:0> include GSL4r
31
- => Object
29
+ irb -r rubygems -r gsl4r -r gsl4r/complex
30
+ irb(main):001:0> include GSL4r::Complex
31
+ => Object
32
32
  irb(main):004:0> a=GSL_Complex.create(1,1)
33
33
  => (1.0,1.0)
34
34
  irb(main):005:0> b=GSL_Complex.create(2,2)
@@ -44,6 +44,17 @@ irb(main):016:0> include GSL4r::Complex::Methods
44
44
  => Object
45
45
  irb(main):015:0> gsl_complex_add(a,b)
46
46
  => (3.0,3.0)
47
+ ...
48
+ irb(main):010:0> require 'gsl4r/const'
49
+ => true
50
+ irb(main):011:0> include GSL4r::PhysicalConstants
51
+ => Object
52
+ irb(main):013:0> p CGS::JOULE
53
+ 10000000.0
54
+ irb(main):014:0> p MKS::ERG
55
+ 1.0e-07
56
+
57
+ ...
47
58
 
48
59
  == Questions and/or Comments
49
60
 
data/Rakefile CHANGED
@@ -17,13 +17,18 @@ SUMMARY = "GSL4r, ruby FFI wrappers around GNU Scientific Library"
17
17
  DESCRIPTION = "Wrappers around the GNU Scientific Library using Foreign Function Interface. This allows all ruby implementations that support FFI to interface to the C based GSL routines."
18
18
  DIRS = [ "lib/**/*", "test/**/*" ]
19
19
 
20
+ gsl_cflags = ""
21
+ gsl_ldflags = ""
22
+ gsl_lib_path = ""
23
+
24
+
20
25
  spec = Gem::Specification.new do |s|
21
26
  s.name = GEM
22
27
  s.rubyforge_project = s.name
23
28
  s.version = GEM_VERSION
24
29
  s.platform = Gem::Platform::RUBY
25
30
  s.has_rdoc = true
26
- s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
31
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO', 'changelog']
27
32
  s.summary = SUMMARY
28
33
  s.description = DESCRIPTION
29
34
  s.author = AUTHOR
@@ -32,7 +37,7 @@ spec = Gem::Specification.new do |s|
32
37
 
33
38
  s.requirements << 'GNU Scientific Library, version 1.13 or greater'
34
39
  s.require_path = 'lib'
35
- s.files = %w{LICENSE LICENSE.LGPLv3 README INSTALL Rakefile TODO}
40
+ s.files = %w{LICENSE LICENSE.LGPLv3 README INSTALL Rakefile TODO changelog}
36
41
  s.files = s.files + DIRS.collect do |dir|
37
42
  Dir.glob( dir )
38
43
  end.flatten.delete_if { |f| f.include?(".git") }
@@ -93,5 +98,4 @@ task :gsl_config do
93
98
  end
94
99
 
95
100
  task :default => [:gsl_config,:package] do
96
-
97
101
  end
data/changelog ADDED
@@ -0,0 +1,17 @@
1
+ 0.0.2
2
+
3
+ * Added all GSL constants
4
+ * Block and Vector memory handling
5
+ * Moved method_missing definition into generic AutoPrefix
6
+ * class, so that this code is not duplicated amongst many
7
+ * classes.
8
+
9
+ 0.0.1
10
+
11
+ * Started, huzzah!
12
+ * GSL_Complex functions added, along with convience
13
+ * framework for functions callable on GSL_Complex objects
14
+ * i.e. a.abs instead of a.gsl_complex_abs(a), etc..
15
+ * Tests to check that the FFI wrappered routines produce
16
+ * the same results as natively called C versions.
17
+ * Initial framework behind Rakefile
@@ -0,0 +1,59 @@
1
+ # This file is generated by rake. Do not edit.
2
+
3
+
4
+ #
5
+ # == Other Info
6
+ #
7
+ # Author:: Colby Gutierrez-Kraybill
8
+ # Version:: $Id$
9
+ #
10
+
11
+ require 'rubygems'
12
+ require 'ffi'
13
+
14
+ require 'gsl4r/util'
15
+ require 'gsl4r/harness'
16
+
17
+ module GSL4r
18
+ module Block
19
+
20
+ extend ::FFI::Library
21
+
22
+ class GSL_Block < FFI::Struct
23
+ layout :size, :size_t,
24
+ :data, :pointer
25
+
26
+ def get_size( a_block )
27
+ return a_block.get_ulong(0)
28
+ end
29
+
30
+ def get_data( a_block )
31
+ return a_block.get_array_of_double(1,get_size(a_block))
32
+ end
33
+
34
+ def set_data( a_block, some_data )
35
+ if ( some_data.length >= get_size(a_block) )
36
+ raise "data exceeds size of block"
37
+ end
38
+ a_block.put_array_of_double(1,some_data)
39
+ end
40
+
41
+ include ::GSL4r::Util::AutoPrefix
42
+
43
+ GSL_PREFIX = "gsl_block_"
44
+ GSL_MODULE = ::GSL4r::Block
45
+
46
+ end # class GSL_Block
47
+
48
+ module Methods
49
+ extend ::GSL4r::Util
50
+ extend ::FFI::Library
51
+
52
+ ffi_lib ::GSL4r::GSL_LIB_PATH
53
+
54
+ attach_gsl_function :gsl_block_alloc, [:size_t], :pointer, [:size_t], :pointer, false
55
+ attach_gsl_function :gsl_block_calloc, [:size_t], :pointer, [:size_t], :pointer, false
56
+ attach_gsl_function :gsl_block_free, [:pointer], :void, [:pointer], :void, false
57
+ end
58
+ end # module Block
59
+ end # module GSL4r
data/lib/gsl4r/complex.rb CHANGED
@@ -6,13 +6,13 @@
6
6
  #
7
7
 
8
8
  require 'rubygems'
9
- require 'monitor'
10
9
  require 'ffi'
11
10
 
12
11
  require 'gsl4r/util'
13
12
  require 'gsl4r/harness'
14
13
 
15
14
  module GSL4r
15
+
16
16
  module Complex
17
17
  extend ::FFI::Library
18
18
  # Note, according to
@@ -33,10 +33,13 @@ module GSL4r
33
33
  # back to double. It would be nice if we could guarantee that it
34
34
  # was a 128 quadruple precision value, but... no.
35
35
 
36
- class GSL_Complex < ::FFI::Struct
36
+ class GSL_Complex < ::FFI::Struct
37
37
  layout :dat, [:double, 2]
38
38
 
39
- $globalGSLComplexLock = Monitor.new
39
+ GSL_PREFIX = "gsl_complex_"
40
+ GSL_MODULE = ::GSL4r::Complex
41
+
42
+ include ::GSL4r::Util::AutoPrefix
40
43
 
41
44
  EPSILON = 5.0e-15
42
45
  R = 0
@@ -56,6 +59,7 @@ module GSL4r
56
59
  # issues when copies are created, probably in by_value specifically
57
60
  # TODO: followup with Wayne Meissner to confirm this
58
61
  class << self
62
+
59
63
  #
60
64
  def create( r=0.0, i=0.0 )
61
65
  myComplex = GSL_Complex.new
@@ -145,48 +149,6 @@ module GSL4r
145
149
  return "(#{self[:dat][R]},#{self[:dat][I]})"
146
150
  end
147
151
 
148
-
149
- # This traps method calls intended to create shortened versions
150
- # of the GSL function calls.
151
- #
152
- # This first checks if the called method matches the Module
153
- # function call gsl_complex_#{called_method} (where called_method
154
- # might be 'abs').
155
- #
156
- # If it finds a match (respond_to), it will then create a new
157
- # method for the class as a whole (class_eval), making the method
158
- # available to not just this instance of the class, but all
159
- # existing instances and all those created after.
160
- #
161
- # Finally, the creation is wrapped up in a synchronized call
162
- # to ensure thread safety. It is only unsafe the first time
163
- # the method is invoked (and non-existent at that point). Every
164
- # time the method is invoked after, it should not hit method_missing.
165
- # TODO: Is this true for java threads too, or is it per 'vm' per
166
- # thread?
167
- def method_missing( called_method, *args, &block )
168
-
169
- $globalGSLComplexLock.synchronize do
170
-
171
- prefix = "gsl_complex_"
172
-
173
- if ( ::GSL4r::Complex::Methods.respond_to?("#{prefix}#{called_method}") == false )
174
- prefix = ""
175
- if ( ::GSL4r::Complex::Methods.respond_to?("#{called_method}") == false )
176
- super # NoMethodError
177
- end
178
- end
179
-
180
- self.class.class_eval <<-end_eval
181
- def #{called_method}(*args, &block)
182
- args.insert(0, self)
183
- ::GSL4r::Complex::Methods::#{prefix}#{called_method}( *args, &block )
184
- end
185
- end_eval
186
-
187
- __send__(called_method, *args, &block)
188
- end # globalGSLComplexLock.synchronize
189
- end # method_missing
190
152
  end # GSL_Complex
191
153
 
192
154
 
@@ -220,7 +182,7 @@ module GSL4r
220
182
 
221
183
  extend ::FFI::Library
222
184
 
223
- ffi_lib GSL4r::GSL_LIB_PATH
185
+ ffi_lib ::GSL4r::GSL_LIB_PATH
224
186
 
225
187
  # Returns the argument of the complex number z, arg(z), where -pi < arg(z) <= pi
226
188
  attach_gsl_function :gsl_complex_arg, [ GSL_Complex.by_value ], :double,
@@ -315,12 +277,12 @@ module GSL4r
315
277
  # This function returns the complex square root of the real number x,
316
278
  # where x may be negative.
317
279
  attach_gsl_function :gsl_complex_sqrt_real, [ :double ],
318
- GSL_Complex.by_value, :double, GSL_Complex
280
+ GSL_Complex.by_value, :double, GSL_Complex, false
319
281
 
320
282
 
321
283
  # r= r e^(i theta)
322
284
  attach_gsl_function :gsl_complex_polar, [ :double, :double ],
323
- GSL_Complex.by_value, [ :double, :double ], GSL_Complex
285
+ GSL_Complex.by_value, [ :double, :double ], GSL_Complex, false
324
286
  # r=a^b
325
287
  attach_gsl_function :gsl_complex_pow, [ GSL_Complex.by_value, GSL_Complex.by_value ],
326
288
  GSL_Complex.by_value, [ GSL_Complex, GSL_Complex ], GSL_Complex
@@ -362,25 +324,25 @@ module GSL4r
362
324
  GSL_Complex.by_value, [ GSL_Complex ], GSL_Complex
363
325
  # r=arcsin(a)
364
326
  attach_gsl_function :gsl_complex_arcsin_real, [ :double ],
365
- GSL_Complex.by_value, [ :double ], GSL_Complex
327
+ GSL_Complex.by_value, [ :double ], GSL_Complex, false
366
328
  # r=arccos(a)
367
329
  attach_gsl_function :gsl_complex_arccos, [ GSL_Complex.by_value ],
368
330
  GSL_Complex.by_value, [ GSL_Complex ], GSL_Complex
369
331
  # r=arccos(a)
370
332
  attach_gsl_function :gsl_complex_arccos_real, [ :double ],
371
- GSL_Complex.by_value, [ :double ], GSL_Complex
333
+ GSL_Complex.by_value, [ :double ], GSL_Complex, false
372
334
  # r=arcsec(a)
373
335
  attach_gsl_function :gsl_complex_arcsec, [ GSL_Complex.by_value ],
374
336
  GSL_Complex.by_value, [ GSL_Complex ], GSL_Complex
375
337
  # r=arcsec(a)
376
338
  attach_gsl_function :gsl_complex_arcsec_real, [ :double ],
377
- GSL_Complex.by_value, [ :double ], GSL_Complex
339
+ GSL_Complex.by_value, [ :double ], GSL_Complex, false
378
340
  # r=arccsc(a)
379
341
  attach_gsl_function :gsl_complex_arccsc, [ GSL_Complex.by_value ],
380
342
  GSL_Complex.by_value, [ GSL_Complex ], GSL_Complex
381
343
  # r=arccsc(a)
382
344
  attach_gsl_function :gsl_complex_arccsc_real, [ :double ],
383
- GSL_Complex.by_value, [ :double ], GSL_Complex
345
+ GSL_Complex.by_value, [ :double ], GSL_Complex, false
384
346
  # r=arctan(a)
385
347
  attach_gsl_function :gsl_complex_arctan, [ GSL_Complex.by_value ],
386
348
  GSL_Complex.by_value, [ GSL_Complex ], GSL_Complex
@@ -413,7 +375,7 @@ module GSL4r
413
375
  GSL_Complex.by_value, [ GSL_Complex ], GSL_Complex
414
376
  # r=arccosh(a)
415
377
  attach_gsl_function :gsl_complex_arccosh_real, [ :double ],
416
- GSL_Complex.by_value, [ :double ], GSL_Complex
378
+ GSL_Complex.by_value, [ :double ], GSL_Complex, false
417
379
  # r=arcsech(a)
418
380
  attach_gsl_function :gsl_complex_arcsech, [ GSL_Complex.by_value ],
419
381
  GSL_Complex.by_value, [ GSL_Complex ], GSL_Complex
@@ -425,7 +387,7 @@ module GSL4r
425
387
  GSL_Complex.by_value, [ GSL_Complex ], GSL_Complex
426
388
  # r=arctanh(a)
427
389
  attach_gsl_function :gsl_complex_arctanh_real, [ :double ],
428
- GSL_Complex.by_value, [ :double ], GSL_Complex
390
+ GSL_Complex.by_value, [ :double ], GSL_Complex, false
429
391
  # r=arccoth(a)
430
392
  attach_gsl_function :gsl_complex_arccoth, [ GSL_Complex.by_value ],
431
393
  GSL_Complex.by_value, [ GSL_Complex ], GSL_Complex
@@ -0,0 +1,14 @@
1
+ #
2
+ # == Other Info
3
+ #
4
+ # Author:: Colby Gutierrez-Kraybill
5
+ # Version:: $Id$
6
+ #
7
+
8
+
9
+ require 'gsl4r/const_num'
10
+ require 'gsl4r/const_cgs'
11
+ require 'gsl4r/const_cgsm'
12
+ require 'gsl4r/const_mks'
13
+ require 'gsl4r/const_mksa'
14
+
@@ -0,0 +1,102 @@
1
+ # Generated by gsl4r/bin/generate_consts.rb
2
+ # from /opt/local/include/gsl/gsl_const_cgs.h
3
+ module GSL4r
4
+ module PhysicalConstants
5
+ module CGS
6
+ SPEED_OF_LIGHT = (2.99792458e10) # cm / s
7
+ GRAVITATIONAL_CONSTANT = (6.673e-8) # cm^3 / g s^2
8
+ PLANCKS_CONSTANT_H = (6.62606896e-27) # g cm^2 / s
9
+ PLANCKS_CONSTANT_HBAR = (1.05457162825e-27) # g cm^2 / s
10
+ ASTRONOMICAL_UNIT = (1.49597870691e13) # cm
11
+ LIGHT_YEAR = (9.46053620707e17) # cm
12
+ PARSEC = (3.08567758135e18) # cm
13
+ GRAV_ACCEL = (9.80665e2) # cm / s^2
14
+ ELECTRON_VOLT = (1.602176487e-12) # g cm^2 / s^2
15
+ MASS_ELECTRON = (9.10938188e-28) # g
16
+ MASS_MUON = (1.88353109e-25) # g
17
+ MASS_PROTON = (1.67262158e-24) # g
18
+ MASS_NEUTRON = (1.67492716e-24) # g
19
+ RYDBERG = (2.17987196968e-11) # g cm^2 / s^2
20
+ BOLTZMANN = (1.3806504e-16) # g cm^2 / K s^2
21
+ MOLAR_GAS = (8.314472e7) # g cm^2 / K mol s^2
22
+ STANDARD_GAS_VOLUME = (2.2710981e4) # cm^3 / mol
23
+ MINUTE = (6e1) # s
24
+ HOUR = (3.6e3) # s
25
+ DAY = (8.64e4) # s
26
+ WEEK = (6.048e5) # s
27
+ INCH = (2.54e0) # cm
28
+ FOOT = (3.048e1) # cm
29
+ YARD = (9.144e1) # cm
30
+ MILE = (1.609344e5) # cm
31
+ NAUTICAL_MILE = (1.852e5) # cm
32
+ FATHOM = (1.8288e2) # cm
33
+ MIL = (2.54e-3) # cm
34
+ POINT = (3.52777777778e-2) # cm
35
+ TEXPOINT = (3.51459803515e-2) # cm
36
+ MICRON = (1e-4) # cm
37
+ ANGSTROM = (1e-8) # cm
38
+ HECTARE = (1e8) # cm^2
39
+ ACRE = (4.04685642241e7) # cm^2
40
+ BARN = (1e-24) # cm^2
41
+ LITER = (1e3) # cm^3
42
+ US_GALLON = (3.78541178402e3) # cm^3
43
+ QUART = (9.46352946004e2) # cm^3
44
+ PINT = (4.73176473002e2) # cm^3
45
+ CUP = (2.36588236501e2) # cm^3
46
+ FLUID_OUNCE = (2.95735295626e1) # cm^3
47
+ TABLESPOON = (1.47867647813e1) # cm^3
48
+ TEASPOON = (4.92892159375e0) # cm^3
49
+ CANADIAN_GALLON = (4.54609e3) # cm^3
50
+ UK_GALLON = (4.546092e3) # cm^3
51
+ MILES_PER_HOUR = (4.4704e1) # cm / s
52
+ KILOMETERS_PER_HOUR = (2.77777777778e1) # cm / s
53
+ KNOT = (5.14444444444e1) # cm / s
54
+ POUND_MASS = (4.5359237e2) # g
55
+ OUNCE_MASS = (2.8349523125e1) # g
56
+ TON = (9.0718474e5) # g
57
+ METRIC_TON = (1e6) # g
58
+ UK_TON = (1.0160469088e6) # g
59
+ TROY_OUNCE = (3.1103475e1) # g
60
+ CARAT = (2e-1) # g
61
+ UNIFIED_ATOMIC_MASS = (1.660538782e-24) # g
62
+ GRAM_FORCE = (9.80665e2) # cm g / s^2
63
+ POUND_FORCE = (4.44822161526e5) # cm g / s^2
64
+ KILOPOUND_FORCE = (4.44822161526e8) # cm g / s^2
65
+ POUNDAL = (1.38255e4) # cm g / s^2
66
+ CALORIE = (4.1868e7) # g cm^2 / s^2
67
+ BTU = (1.05505585262e10) # g cm^2 / s^2
68
+ THERM = (1.05506e15) # g cm^2 / s^2
69
+ HORSEPOWER = (7.457e9) # g cm^2 / s^3
70
+ BAR = (1e6) # g / cm s^2
71
+ STD_ATMOSPHERE = (1.01325e6) # g / cm s^2
72
+ TORR = (1.33322368421e3) # g / cm s^2
73
+ METER_OF_MERCURY = (1.33322368421e6) # g / cm s^2
74
+ INCH_OF_MERCURY = (3.38638815789e4) # g / cm s^2
75
+ INCH_OF_WATER = (2.490889e3) # g / cm s^2
76
+ PSI = (6.89475729317e4) # g / cm s^2
77
+ POISE = (1e0) # g / cm s
78
+ STOKES = (1e0) # cm^2 / s
79
+ STILB = (1e0) # cd / cm^2
80
+ LUMEN = (1e0) # cd sr
81
+ LUX = (1e-4) # cd sr / cm^2
82
+ PHOT = (1e0) # cd sr / cm^2
83
+ FOOTCANDLE = (1.076e-3) # cd sr / cm^2
84
+ LAMBERT = (1e0) # cd sr / cm^2
85
+ FOOTLAMBERT = (1.07639104e-3) # cd sr / cm^2
86
+ CURIE = (3.7e10) # 1 / s
87
+ ROENTGEN = (2.58e-7) # A s / g
88
+ RAD = (1e2) # cm^2 / s^2
89
+ SOLAR_MASS = (1.98892e33) # g
90
+ BOHR_RADIUS = (5.291772083e-9) # cm
91
+ NEWTON = (1e5) # cm g / s^2
92
+ DYNE = (1e0) # cm g / s^2
93
+ JOULE = (1e7) # g cm^2 / s^2
94
+ ERG = (1e0) # g cm^2 / s^2
95
+ STEFAN_BOLTZMANN_CONSTANT = (5.67040047374e-5) # g / K^4 s^3
96
+ THOMSON_CROSS_SECTION = (6.65245893699e-25) # cm^2
97
+ def all_names
98
+ return ["SPEED_OF_LIGHT","GRAVITATIONAL_CONSTANT","PLANCKS_CONSTANT_H","PLANCKS_CONSTANT_HBAR","ASTRONOMICAL_UNIT","LIGHT_YEAR","PARSEC","GRAV_ACCEL","ELECTRON_VOLT","MASS_ELECTRON","MASS_MUON","MASS_PROTON","MASS_NEUTRON","RYDBERG","BOLTZMANN","MOLAR_GAS","STANDARD_GAS_VOLUME","MINUTE","HOUR","DAY","WEEK","INCH","FOOT","YARD","MILE","NAUTICAL_MILE","FATHOM","MIL","POINT","TEXPOINT","MICRON","ANGSTROM","HECTARE","ACRE","BARN","LITER","US_GALLON","QUART","PINT","CUP","FLUID_OUNCE","TABLESPOON","TEASPOON","CANADIAN_GALLON","UK_GALLON","MILES_PER_HOUR","KILOMETERS_PER_HOUR","KNOT","POUND_MASS","OUNCE_MASS","TON","METRIC_TON","UK_TON","TROY_OUNCE","CARAT","UNIFIED_ATOMIC_MASS","GRAM_FORCE","POUND_FORCE","KILOPOUND_FORCE","POUNDAL","CALORIE","BTU","THERM","HORSEPOWER","BAR","STD_ATMOSPHERE","TORR","METER_OF_MERCURY","INCH_OF_MERCURY","INCH_OF_WATER","PSI","POISE","STOKES","STILB","LUMEN","LUX","PHOT","FOOTCANDLE","LAMBERT","FOOTLAMBERT","CURIE","ROENTGEN","RAD","SOLAR_MASS","BOHR_RADIUS","NEWTON","DYNE","JOULE","ERG","STEFAN_BOLTZMANN_CONSTANT","THOMSON_CROSS_SECTION"]
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,108 @@
1
+ # Generated by gsl4r/bin/generate_consts.rb
2
+ # from /opt/local/include/gsl/gsl_const_cgsm.h
3
+ module GSL4r
4
+ module PhysicalConstants
5
+ module CGSM
6
+ SPEED_OF_LIGHT = (2.99792458e10) # cm / s
7
+ GRAVITATIONAL_CONSTANT = (6.673e-8) # cm^3 / g s^2
8
+ PLANCKS_CONSTANT_H = (6.62606896e-27) # g cm^2 / s
9
+ PLANCKS_CONSTANT_HBAR = (1.05457162825e-27) # g cm^2 / s
10
+ ASTRONOMICAL_UNIT = (1.49597870691e13) # cm
11
+ LIGHT_YEAR = (9.46053620707e17) # cm
12
+ PARSEC = (3.08567758135e18) # cm
13
+ GRAV_ACCEL = (9.80665e2) # cm / s^2
14
+ ELECTRON_VOLT = (1.602176487e-12) # g cm^2 / s^2
15
+ MASS_ELECTRON = (9.10938188e-28) # g
16
+ MASS_MUON = (1.88353109e-25) # g
17
+ MASS_PROTON = (1.67262158e-24) # g
18
+ MASS_NEUTRON = (1.67492716e-24) # g
19
+ RYDBERG = (2.17987196968e-11) # g cm^2 / s^2
20
+ BOLTZMANN = (1.3806504e-16) # g cm^2 / K s^2
21
+ MOLAR_GAS = (8.314472e7) # g cm^2 / K mol s^2
22
+ STANDARD_GAS_VOLUME = (2.2710981e4) # cm^3 / mol
23
+ MINUTE = (6e1) # s
24
+ HOUR = (3.6e3) # s
25
+ DAY = (8.64e4) # s
26
+ WEEK = (6.048e5) # s
27
+ INCH = (2.54e0) # cm
28
+ FOOT = (3.048e1) # cm
29
+ YARD = (9.144e1) # cm
30
+ MILE = (1.609344e5) # cm
31
+ NAUTICAL_MILE = (1.852e5) # cm
32
+ FATHOM = (1.8288e2) # cm
33
+ MIL = (2.54e-3) # cm
34
+ POINT = (3.52777777778e-2) # cm
35
+ TEXPOINT = (3.51459803515e-2) # cm
36
+ MICRON = (1e-4) # cm
37
+ ANGSTROM = (1e-8) # cm
38
+ HECTARE = (1e8) # cm^2
39
+ ACRE = (4.04685642241e7) # cm^2
40
+ BARN = (1e-24) # cm^2
41
+ LITER = (1e3) # cm^3
42
+ US_GALLON = (3.78541178402e3) # cm^3
43
+ QUART = (9.46352946004e2) # cm^3
44
+ PINT = (4.73176473002e2) # cm^3
45
+ CUP = (2.36588236501e2) # cm^3
46
+ FLUID_OUNCE = (2.95735295626e1) # cm^3
47
+ TABLESPOON = (1.47867647813e1) # cm^3
48
+ TEASPOON = (4.92892159375e0) # cm^3
49
+ CANADIAN_GALLON = (4.54609e3) # cm^3
50
+ UK_GALLON = (4.546092e3) # cm^3
51
+ MILES_PER_HOUR = (4.4704e1) # cm / s
52
+ KILOMETERS_PER_HOUR = (2.77777777778e1) # cm / s
53
+ KNOT = (5.14444444444e1) # cm / s
54
+ POUND_MASS = (4.5359237e2) # g
55
+ OUNCE_MASS = (2.8349523125e1) # g
56
+ TON = (9.0718474e5) # g
57
+ METRIC_TON = (1e6) # g
58
+ UK_TON = (1.0160469088e6) # g
59
+ TROY_OUNCE = (3.1103475e1) # g
60
+ CARAT = (2e-1) # g
61
+ UNIFIED_ATOMIC_MASS = (1.660538782e-24) # g
62
+ GRAM_FORCE = (9.80665e2) # cm g / s^2
63
+ POUND_FORCE = (4.44822161526e5) # cm g / s^2
64
+ KILOPOUND_FORCE = (4.44822161526e8) # cm g / s^2
65
+ POUNDAL = (1.38255e4) # cm g / s^2
66
+ CALORIE = (4.1868e7) # g cm^2 / s^2
67
+ BTU = (1.05505585262e10) # g cm^2 / s^2
68
+ THERM = (1.05506e15) # g cm^2 / s^2
69
+ HORSEPOWER = (7.457e9) # g cm^2 / s^3
70
+ BAR = (1e6) # g / cm s^2
71
+ STD_ATMOSPHERE = (1.01325e6) # g / cm s^2
72
+ TORR = (1.33322368421e3) # g / cm s^2
73
+ METER_OF_MERCURY = (1.33322368421e6) # g / cm s^2
74
+ INCH_OF_MERCURY = (3.38638815789e4) # g / cm s^2
75
+ INCH_OF_WATER = (2.490889e3) # g / cm s^2
76
+ PSI = (6.89475729317e4) # g / cm s^2
77
+ POISE = (1e0) # g / cm s
78
+ STOKES = (1e0) # cm^2 / s
79
+ STILB = (1e0) # cd / cm^2
80
+ LUMEN = (1e0) # cd sr
81
+ LUX = (1e-4) # cd sr / cm^2
82
+ PHOT = (1e0) # cd sr / cm^2
83
+ FOOTCANDLE = (1.076e-3) # cd sr / cm^2
84
+ LAMBERT = (1e0) # cd sr / cm^2
85
+ FOOTLAMBERT = (1.07639104e-3) # cd sr / cm^2
86
+ CURIE = (3.7e10) # 1 / s
87
+ ROENTGEN = (2.58e-8) # abamp s / g
88
+ RAD = (1e2) # cm^2 / s^2
89
+ SOLAR_MASS = (1.98892e33) # g
90
+ BOHR_RADIUS = (5.291772083e-9) # cm
91
+ NEWTON = (1e5) # cm g / s^2
92
+ DYNE = (1e0) # cm g / s^2
93
+ JOULE = (1e7) # g cm^2 / s^2
94
+ ERG = (1e0) # g cm^2 / s^2
95
+ STEFAN_BOLTZMANN_CONSTANT = (5.67040047374e-5) # g / K^4 s^3
96
+ THOMSON_CROSS_SECTION = (6.65245893699e-25) # cm^2
97
+ BOHR_MAGNETON = (9.27400899e-21) # abamp cm^2
98
+ NUCLEAR_MAGNETON = (5.05078317e-24) # abamp cm^2
99
+ ELECTRON_MAGNETIC_MOMENT = (9.28476362e-21) # abamp cm^2
100
+ PROTON_MAGNETIC_MOMENT = (1.410606633e-23) # abamp cm^2
101
+ FARADAY = (9.64853429775e3) # abamp s / mol
102
+ ELECTRON_CHARGE = (1.602176487e-20) # abamp s
103
+ def all_names
104
+ return ["SPEED_OF_LIGHT","GRAVITATIONAL_CONSTANT","PLANCKS_CONSTANT_H","PLANCKS_CONSTANT_HBAR","ASTRONOMICAL_UNIT","LIGHT_YEAR","PARSEC","GRAV_ACCEL","ELECTRON_VOLT","MASS_ELECTRON","MASS_MUON","MASS_PROTON","MASS_NEUTRON","RYDBERG","BOLTZMANN","MOLAR_GAS","STANDARD_GAS_VOLUME","MINUTE","HOUR","DAY","WEEK","INCH","FOOT","YARD","MILE","NAUTICAL_MILE","FATHOM","MIL","POINT","TEXPOINT","MICRON","ANGSTROM","HECTARE","ACRE","BARN","LITER","US_GALLON","QUART","PINT","CUP","FLUID_OUNCE","TABLESPOON","TEASPOON","CANADIAN_GALLON","UK_GALLON","MILES_PER_HOUR","KILOMETERS_PER_HOUR","KNOT","POUND_MASS","OUNCE_MASS","TON","METRIC_TON","UK_TON","TROY_OUNCE","CARAT","UNIFIED_ATOMIC_MASS","GRAM_FORCE","POUND_FORCE","KILOPOUND_FORCE","POUNDAL","CALORIE","BTU","THERM","HORSEPOWER","BAR","STD_ATMOSPHERE","TORR","METER_OF_MERCURY","INCH_OF_MERCURY","INCH_OF_WATER","PSI","POISE","STOKES","STILB","LUMEN","LUX","PHOT","FOOTCANDLE","LAMBERT","FOOTLAMBERT","CURIE","ROENTGEN","RAD","SOLAR_MASS","BOHR_RADIUS","NEWTON","DYNE","JOULE","ERG","STEFAN_BOLTZMANN_CONSTANT","THOMSON_CROSS_SECTION","BOHR_MAGNETON","NUCLEAR_MAGNETON","ELECTRON_MAGNETIC_MOMENT","PROTON_MAGNETIC_MOMENT","FARADAY","ELECTRON_CHARGE"]
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,112 @@
1
+ # Generated by gsl4r/bin/generate_consts.rb
2
+ # from /opt/local/include/gsl/gsl_const_mks.h
3
+ module GSL4r
4
+ module PhysicalConstants
5
+ module MKS
6
+ SPEED_OF_LIGHT = (2.99792458e8) # m / s
7
+ GRAVITATIONAL_CONSTANT = (6.673e-11) # m^3 / kg s^2
8
+ PLANCKS_CONSTANT_H = (6.62606896e-34) # kg m^2 / s
9
+ PLANCKS_CONSTANT_HBAR = (1.05457162825e-34) # kg m^2 / s
10
+ ASTRONOMICAL_UNIT = (1.49597870691e11) # m
11
+ LIGHT_YEAR = (9.46053620707e15) # m
12
+ PARSEC = (3.08567758135e16) # m
13
+ GRAV_ACCEL = (9.80665e0) # m / s^2
14
+ ELECTRON_VOLT = (1.602176487e-19) # kg m^2 / s^2
15
+ MASS_ELECTRON = (9.10938188e-31) # kg
16
+ MASS_MUON = (1.88353109e-28) # kg
17
+ MASS_PROTON = (1.67262158e-27) # kg
18
+ MASS_NEUTRON = (1.67492716e-27) # kg
19
+ RYDBERG = (2.17987196968e-18) # kg m^2 / s^2
20
+ BOLTZMANN = (1.3806504e-23) # kg m^2 / K s^2
21
+ MOLAR_GAS = (8.314472e0) # kg m^2 / K mol s^2
22
+ STANDARD_GAS_VOLUME = (2.2710981e-2) # m^3 / mol
23
+ MINUTE = (6e1) # s
24
+ HOUR = (3.6e3) # s
25
+ DAY = (8.64e4) # s
26
+ WEEK = (6.048e5) # s
27
+ INCH = (2.54e-2) # m
28
+ FOOT = (3.048e-1) # m
29
+ YARD = (9.144e-1) # m
30
+ MILE = (1.609344e3) # m
31
+ NAUTICAL_MILE = (1.852e3) # m
32
+ FATHOM = (1.8288e0) # m
33
+ MIL = (2.54e-5) # m
34
+ POINT = (3.52777777778e-4) # m
35
+ TEXPOINT = (3.51459803515e-4) # m
36
+ MICRON = (1e-6) # m
37
+ ANGSTROM = (1e-10) # m
38
+ HECTARE = (1e4) # m^2
39
+ ACRE = (4.04685642241e3) # m^2
40
+ BARN = (1e-28) # m^2
41
+ LITER = (1e-3) # m^3
42
+ US_GALLON = (3.78541178402e-3) # m^3
43
+ QUART = (9.46352946004e-4) # m^3
44
+ PINT = (4.73176473002e-4) # m^3
45
+ CUP = (2.36588236501e-4) # m^3
46
+ FLUID_OUNCE = (2.95735295626e-5) # m^3
47
+ TABLESPOON = (1.47867647813e-5) # m^3
48
+ TEASPOON = (4.92892159375e-6) # m^3
49
+ CANADIAN_GALLON = (4.54609e-3) # m^3
50
+ UK_GALLON = (4.546092e-3) # m^3
51
+ MILES_PER_HOUR = (4.4704e-1) # m / s
52
+ KILOMETERS_PER_HOUR = (2.77777777778e-1) # m / s
53
+ KNOT = (5.14444444444e-1) # m / s
54
+ POUND_MASS = (4.5359237e-1) # kg
55
+ OUNCE_MASS = (2.8349523125e-2) # kg
56
+ TON = (9.0718474e2) # kg
57
+ METRIC_TON = (1e3) # kg
58
+ UK_TON = (1.0160469088e3) # kg
59
+ TROY_OUNCE = (3.1103475e-2) # kg
60
+ CARAT = (2e-4) # kg
61
+ UNIFIED_ATOMIC_MASS = (1.660538782e-27) # kg
62
+ GRAM_FORCE = (9.80665e-3) # kg m / s^2
63
+ POUND_FORCE = (4.44822161526e0) # kg m / s^2
64
+ KILOPOUND_FORCE = (4.44822161526e3) # kg m / s^2
65
+ POUNDAL = (1.38255e-1) # kg m / s^2
66
+ CALORIE = (4.1868e0) # kg m^2 / s^2
67
+ BTU = (1.05505585262e3) # kg m^2 / s^2
68
+ THERM = (1.05506e8) # kg m^2 / s^2
69
+ HORSEPOWER = (7.457e2) # kg m^2 / s^3
70
+ BAR = (1e5) # kg / m s^2
71
+ STD_ATMOSPHERE = (1.01325e5) # kg / m s^2
72
+ TORR = (1.33322368421e2) # kg / m s^2
73
+ METER_OF_MERCURY = (1.33322368421e5) # kg / m s^2
74
+ INCH_OF_MERCURY = (3.38638815789e3) # kg / m s^2
75
+ INCH_OF_WATER = (2.490889e2) # kg / m s^2
76
+ PSI = (6.89475729317e3) # kg / m s^2
77
+ POISE = (1e-1) # kg m^-1 s^-1
78
+ STOKES = (1e-4) # m^2 / s
79
+ STILB = (1e4) # cd / m^2
80
+ LUMEN = (1e0) # cd sr
81
+ LUX = (1e0) # cd sr / m^2
82
+ PHOT = (1e4) # cd sr / m^2
83
+ FOOTCANDLE = (1.076e1) # cd sr / m^2
84
+ LAMBERT = (1e4) # cd sr / m^2
85
+ FOOTLAMBERT = (1.07639104e1) # cd sr / m^2
86
+ CURIE = (3.7e10) # 1 / s
87
+ ROENTGEN = (2.58e-4) # A s / kg
88
+ RAD = (1e-2) # m^2 / s^2
89
+ SOLAR_MASS = (1.98892e30) # kg
90
+ BOHR_RADIUS = (5.291772083e-11) # m
91
+ NEWTON = (1e0) # kg m / s^2
92
+ DYNE = (1e-5) # kg m / s^2
93
+ JOULE = (1e0) # kg m^2 / s^2
94
+ ERG = (1e-7) # kg m^2 / s^2
95
+ STEFAN_BOLTZMANN_CONSTANT = (5.67040047374e-8) # kg / K^4 s^3
96
+ THOMSON_CROSS_SECTION = (6.65245893699e-29) # m^2
97
+ BOHR_MAGNETON = (9.27400899e-24) # A m^2
98
+ NUCLEAR_MAGNETON = (5.05078317e-27) # A m^2
99
+ ELECTRON_MAGNETIC_MOMENT = (9.28476362e-24) # A m^2
100
+ PROTON_MAGNETIC_MOMENT = (1.410606633e-26) # A m^2
101
+ FARADAY = (9.64853429775e4) # A s / mol
102
+ ELECTRON_CHARGE = (1.602176487e-19) # A s
103
+ VACUUM_PERMITTIVITY = (8.854187817e-12) # A^2 s^4 / kg m^3
104
+ VACUUM_PERMEABILITY = (1.25663706144e-6) # kg m / A^2 s^2
105
+ DEBYE = (3.33564095198e-30) # A s^2 / m^2
106
+ GAUSS = (1e-4) # kg / A s^2
107
+ def all_names
108
+ return ["SPEED_OF_LIGHT","GRAVITATIONAL_CONSTANT","PLANCKS_CONSTANT_H","PLANCKS_CONSTANT_HBAR","ASTRONOMICAL_UNIT","LIGHT_YEAR","PARSEC","GRAV_ACCEL","ELECTRON_VOLT","MASS_ELECTRON","MASS_MUON","MASS_PROTON","MASS_NEUTRON","RYDBERG","BOLTZMANN","MOLAR_GAS","STANDARD_GAS_VOLUME","MINUTE","HOUR","DAY","WEEK","INCH","FOOT","YARD","MILE","NAUTICAL_MILE","FATHOM","MIL","POINT","TEXPOINT","MICRON","ANGSTROM","HECTARE","ACRE","BARN","LITER","US_GALLON","QUART","PINT","CUP","FLUID_OUNCE","TABLESPOON","TEASPOON","CANADIAN_GALLON","UK_GALLON","MILES_PER_HOUR","KILOMETERS_PER_HOUR","KNOT","POUND_MASS","OUNCE_MASS","TON","METRIC_TON","UK_TON","TROY_OUNCE","CARAT","UNIFIED_ATOMIC_MASS","GRAM_FORCE","POUND_FORCE","KILOPOUND_FORCE","POUNDAL","CALORIE","BTU","THERM","HORSEPOWER","BAR","STD_ATMOSPHERE","TORR","METER_OF_MERCURY","INCH_OF_MERCURY","INCH_OF_WATER","PSI","POISE","STOKES","STILB","LUMEN","LUX","PHOT","FOOTCANDLE","LAMBERT","FOOTLAMBERT","CURIE","ROENTGEN","RAD","SOLAR_MASS","BOHR_RADIUS","NEWTON","DYNE","JOULE","ERG","STEFAN_BOLTZMANN_CONSTANT","THOMSON_CROSS_SECTION","BOHR_MAGNETON","NUCLEAR_MAGNETON","ELECTRON_MAGNETIC_MOMENT","PROTON_MAGNETIC_MOMENT","FARADAY","ELECTRON_CHARGE","VACUUM_PERMITTIVITY","VACUUM_PERMEABILITY","DEBYE","GAUSS"]
109
+ end
110
+ end
111
+ end
112
+ end