Top Level Namespace

Defined Under Namespace

Modules: AutoloadPatch, Math, NVector Classes: Array, DataTypeError, NMGCHolder, NMatrix, NotInvertibleError, Object, ShapeError, StorageTypeError, String

Constant Summary collapse

N =

This constant is intended as a simple constructor for NMatrix meant for experimenting.

Examples:

a = N[ 1,2,3,4 ]          =>  1  2  3  4

a = N[ 1,2,3,4, :int32 ]  =>  1  2  3  4

a = N[ [1,2,3], [3,4,5] ] =>  1  2  3
                              3  4  5

a = N[ 3,6,9 ].transpose => 3
                            6
                            9
NMatrix
DTYPES =

A helper file for generating and maintaining template tables.

[
 :uint8_t,
 :int8_t,
 :int16_t,
 :int32_t,
 :int64_t,
 :float32_t,
 :float64_t,
 :'nm::Complex64',
 :'nm::Complex128',
 :'nm::RubyObject'
]
ITYPES =
[
 :uint8_t,
 :uint16_t,
 :uint32_t,
 :uint64_t
]
EWOPS =
[
 :'nm::EW_ADD',
 :'nm::EW_SUB',
 :'nm::EW_MUL',
 :'nm::EW_DIV',
 :'nm::EW_POW',
 :'nm::EW_MOD',
 :'nm::EW_EQEQ',
 :'nm::EW_NEQ',
 :'nm::EW_LT',
 :'nm::EW_GT',
 :'nm::EW_LEQ',
 :'nm::EW_GEQ'
]
LR_ALLOWED =
{
  :uint8_t       => DTYPES,
  :int8_t        => DTYPES,
  :int16_t      => DTYPES,
  :int32_t      => DTYPES,
  :int64_t      => DTYPES,
  :float32_t    => DTYPES,
  :float64_t    => DTYPES,
  :'nm::Complex64'    => DTYPES,
  :'nm::Complex128'    => DTYPES,
  :'nm::RubyObject'    => DTYPES
}

Instance Method Summary collapse

Instance Method Details

#create_conf_h(file) ⇒ Object

Function derived from NArray’s extconf.rb.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nmatrix/mkmf.rb', line 8

def create_conf_h(file) #:nodoc:
  print "creating #{file}\n"
  File.open(file, 'w') do |hfile|
    header_guard = file.upcase.sub(/\s|\./, '_')

    hfile.puts "#ifndef #{header_guard}"
    hfile.puts "#define #{header_guard}"
    hfile.puts

    # FIXME: Find a better way to do this:
    hfile.puts "#define RUBY_2 1" if RUBY_VERSION >= '2.0'

    for line in $defs
      line =~ /^-D(.*)/
      hfile.printf "#define %s 1\n", $1
    end

    hfile.puts
    hfile.puts "#endif"
  end
end

#find_newer_gplusplusObject

:nodoc:



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/nmatrix/mkmf.rb', line 30

def find_newer_gplusplus #:nodoc:
  print "checking for apparent GNU g++ binary with C++0x/C++11 support... "
  [9,8,7,6,5,4,3].each do |minor|
    ver = "4.#{minor}"
    gpp = "g++-#{ver}"
    result = `which #{gpp}`
    next if result.empty?
    CONFIG['CXX'] = gpp
    puts ver
    return CONFIG['CXX']
  end
  false
end

#gplusplus_versionObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/nmatrix/mkmf.rb', line 44

def gplusplus_version
  cxxvar = proc { |n| `#{CONFIG['CXX']} -E -dM - <#{File::NULL} | grep #{n}`.chomp.split(' ')[2] }
  major = cxxvar.call('__GNUC__')
  minor = cxxvar.call('__GNUC_MINOR__')
  patch = cxxvar.call('__GNUC_PATCHLEVEL__')

  raise("unable to determine g++ version (match to get version was nil)") if major.nil? || minor.nil? || patch.nil?

  "#{major}.#{minor}.#{patch}"
end

#nullify(disabled = []) ⇒ Object

:nodoc:



18
19
20
# File 'ext/nmatrix/ttable_helper.rb', line 18

def nullify(disabled = []) #:nodoc:
  DTYPES.map { |t| if disabled.include?(t) then :NULL else t end }
end