Top Level Namespace

Defined Under Namespace

Modules: CA, CAMath, CATimeCivil, CATimeGrid, CATimeLiteral, CATimeUnitAlgebra, Kernel Classes: Array, AxisGroup, CABinOp, CABitarray, CABitfield, CABlock, CABlockIterator, CAByteSwap, CACategorical, CACategoricalIterator, CAConstString, CAFake, CAFarray, CAField, CAFixlenString, CAFrame, CAGroupIterator, CAIterator, CALazyMarker, CAMeld, CAMonOp, CAObject, CARefer, CARepeat, CARoll, CASelect, CAShift, CASlabIterator, CAStack, CAStride, CAString, CAStruct, CATile, CATime, CATimedelta, CATranspose, CAUnion, CAView, CAWindow, CAWindowIterator, CAWrap, CArray, CScalar, GroupLabels, GroupedFrame, Range, UndefClass

Data type symbols collapse

CA_FIXLEN =

:fixlen — fixed-length opaque byte blob; element byte size set per array.

:fixlen
CA_BOOLEAN =

:boolean — 8-bit boolean.

:boolean
CA_INT8 =

:int8 — signed 8-bit integer.

:int8
CA_UINT8 =

:uint8 — unsigned 8-bit integer.

:uint8
CA_INT16 =

:int16 — signed 16-bit integer.

:int16
CA_UINT16 =

:uint16 — unsigned 16-bit integer.

:uint16
CA_INT32 =

:int32 — signed 32-bit integer.

:int32
CA_UINT32 =

:uint32 — unsigned 32-bit integer.

:uint32
CA_INT64 =

:int64 — signed 64-bit integer.

:int64
CA_UINT64 =

:uint64 — unsigned 64-bit integer.

:uint64
CA_FLOAT32 =

:float32 — IEEE-754 single-precision float.

:float32
CA_FLOAT64 =

:float64 — IEEE-754 double-precision float.

:float64
CA_CMPLX64 =

:cmplx64 — single-precision complex (two float32 packed).

:cmplx64
CA_CMPLX128 =

:cmplx128 — double-precision complex.

:cmplx128
CA_OBJECT =

:object — boxed Ruby object slot.

:object
CA_BYTE =

Alias of CA_UINT8.

:uint8
CA_SHORT =

Alias of CA_INT16.

:int16
CA_INT =

Alias of CA_INT32.

:int32
CA_FLOAT =

Alias of CA_FLOAT32.

:float32
CA_DOUBLE =

Alias of CA_FLOAT64.

:float64
CA_COMPLEX =

Alias of CA_CMPLX64.

:cmplx64
CA_DCOMPLEX =

Alias of CA_DCOMPLEX.

:cmplx128
CA_SIZE =

Platform-native size type alias; resolves to :int64 on 64-bit builds and :int32 on 32-bit builds.

:int64

Constant Summary collapse

CA_RANK_MAX =

Maximum supported ndim.

nil
CA_ALIGN_VOIDP =

Byte alignment of each element type, used by CArray.wrap and MemoryView interop helpers. Internal, not part of the user surface.

nil
CA_ALIGN_FIXLEN =

:nodoc:

nil
CA_ALIGN_BOOLEAN =

:nodoc:

nil
CA_ALIGN_INT8 =

:nodoc:

nil
CA_ALIGN_INT16 =

:nodoc:

nil
CA_ALIGN_INT32 =

:nodoc:

nil
CA_ALIGN_INT64 =

:nodoc:

nil
CA_ALIGN_FLOAT32 =

:nodoc:

nil
CA_ALIGN_FLOAT64 =

:nodoc:

nil
CA_ALIGN_CMPLX64 =

:nodoc:

nil
CA_ALIGN_CMPLX128 =

:nodoc:

nil
CA_ALIGN_OBJECT =

:nodoc:

nil
UNDEF =

Top-level sentinel used by mask-bearing CArray APIs to mean "masked / no value here" without choosing a numeric sentinel (NaN, -1, etc.) that might collide with valid data.

Identity semantics: every reference to UNDEF is the same Ruby object, pinned against the compacting GC so the C extension can safely use raw pointer comparison to detect it.

Examples:

mask a cell during construction

a = CArray.int32(3) { |i| (i == 1) ? UNDEF : i * 10 }
a.to_a  # => [0, nil, 20]    # UNDEF surfaces as nil after to_a

check whether an element is masked

a[1] == UNDEF  # => true
UndefClass.new

Instance Method Summary collapse

Instance Method Details

#carray_dir_config(name, pkg = name) ⇒ Object

Configure include/library search for a dependency, preferring its own build description over brute-force prefix probing.

If the dependency ships a pkg-config file (<pkg>.pc), use it to obtain cflags / libs and stop. Otherwise fall back to scanning possible_includes / possible_libs (the only option for hand-rolled scientific libraries that do not provide a .pc file, e.g. nn / ngmath / FITPACK).

carray_dir_config("gsl")           # gsl.pc -> done
carray_dir_config("nn")            # no .pc -> possible_* probe
carray_dir_config("foo", "libfoo") # search foo.pc / libfoo.pc as "libfoo"


92
93
94
95
96
# File 'lib/carray/mkmf.rb', line 92

def carray_dir_config (name, pkg = name)
  return true if pkg_config(pkg)
  dir_config(name, possible_includes, possible_libs)
  true
end

#check_fortranvoid

This method returns an undefined value.

Configures the extension to compile Fortran sources, selecting the compiler from --with-fortran (default gfortran) and its flags from --with-fflags. The matching backend registered by #register_fortran_backend links that compiler's runtime; an unmatched compiler warns and leaves the runtime to LIBS / --with-fflags.



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/carray/mkmf.rb', line 145

def check_fortran

  SRC_EXT << "f" << "f90" << "f95"

  fc     = with_config("fortran", "gfortran")
  fflags = with_config("fflags", "-O2 -g -fPIC")

  _pattern, backend = FORTRAN_BACKENDS.find { |pat, _| pat =~ fc }
  if backend
    backend.call(fc)
  else
    warn "carray/mkmf: no backend for fortran '#{fc}'; " \
         "register one with register_fortran_backend or pass the " \
         "runtime via LIBS / --with-fflags"
  end

  at_exit do
    if File.file?("Makefile")
      makefile = File.read("Makefile")
      unless makefile =~ /^FC=/
        makefile.sub!(/^COPY =.*$/,
                      '\0' + "\n\n" +
                      "FC=#{fc}\n" +
                      "FFLAGS=#{fflags}\n")
      end
      File.write("Makefile", makefile)
    end
  end

  return fc
end

#have_carrayBoolean

Locates an installed Ruby/CArray and wires its header (and, on Windows, its import library) into the extension being configured. Call this at the top of a companion gem's extconf.rb.

Returns:

  • (Boolean)

    whether every required piece was found.



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

def have_carray 
  begin
    require 'carray'
  rescue LoadError
    abort "Ruby/CArray is not installed"
  end
  $LOAD_PATH.each do |path|
    if File.exist? File.join(path, 'carray.h')
      dir_config("carray", path, path)
      break
    end
  end
  status = true
  status &= have_header("carray.h")
  if /cygwin|mingw/ =~ RUBY_PLATFORM
    status &= have_library("carray")
  end
  status
end

#register_fortran_backend(pattern) {|fc| ... } ⇒ void

This method returns an undefined value.

Registers a Fortran runtime backend for #check_fortran to pick up. Only gfortran ships out of the box; a companion gem that needs another compiler registers its own before calling #check_fortran. The block receives the compiler command and is responsible only for linking that compiler's runtime library (dir_config + have_library).

Parameters:

  • pattern (Regexp)

    matched against the configured compiler command.

Yield Parameters:

  • fc (String)

    the compiler command.



127
128
129
# File 'lib/carray/mkmf.rb', line 127

def register_fortran_backend (pattern, &block)
  FORTRAN_BACKENDS[pattern] = block
end