NArrayMiss Class

NArrayMiss is a additional class processing of missing value with to NArray for Ruby.

To use NArrayMiss class, you need invoking "require 'narray_miss.rb'" in your script.

Index

Class Constants

NArrayMiss::BYTE

type code for 1 byte unsigned integer.

NArrayMiss::SINT

type code for 2 byte signed integer.

NArrayMiss::INT

type code for 4 byte signed integer.

NArrayMiss::SFLOAT

type code for single precision float.

NArrayMiss::FLOAT

type code for double precision float.

NArrayMiss::SCOMPLEX

type code for single precision complex.

NArrayMiss::COMPLEX

type code for double precision complex.

NArrayMiss::OBJECT

type code for Ruby object.

go back to Index

Class Methods

NArrayMiss.new(typecode, size, ...)

create NArrayMiss of typecode. All elements are initialized with 0.

NArrayMiss.byte(size, ...)

same as NArrayMiss.new(NArrayMiss::BYTE, size, ...).

NArrayMiss.sint(size, ...)

same as NArrayMiss.new(NArrayMiss::SINT, size, ...).

NArrayMiss.int(size, ...)

same as NArrayMiss.new(NArrayMiss::INT, size, ...).

NArrayMiss.sfloat(size, ...)

same as NArrayMiss.new(NArrayMiss::SFLOAT, size, ...).

NArrayMiss.float(size, ...)

same as NArrayMiss.new(NArrayMiss::FLOAT, size, ...).

NArrayMiss.scomplex(size, ...)

same as NArrayMiss.new(NArrayMiss::SCOMPLEX, size, ...).

NArrayMiss.complex(size, ...)

same as NArrayMiss.new(NArrayMiss::COMPLEX, size, ...).

NArrayMiss.object(size, ...)

same as NArrayMiss.new(NArrayMiss::OBJECT, size, ...).

NArrayMiss[](value, ...)

create NArrayMiss form [value, ...].

NArrayMiss.to_nam(array [,mask])

create NArrayMiss from array. array must be Array or NArray.

NArrayMiss.to_nam_no_dup(array [,mask])

convert from array to NArrayMiss.

go back to Index

Class Instance Methods

NArrayMiss information

NArraMiss#dim

return the dimension which is the number of indices.

NArraMiss#rank

same as NArrayMiss#dim.

NArraMiss#shape

return the Array of sizes of each index.

NArraMiss#total

return the number of total elements.

NArraMiss#rank_total

return the number of total of the shape.

NArraMiss#typecode

return the typecode.

Slicing Array

NArrayMiss#[index]

return the value at [index]. index must be Integer, Range, Array, true. Index order is FORTRAN type.

NArrayMiss#slice(index)

same as NArrayMiss#[] but keeps the rank of original array by not elimiting dimensions whose length became equal to 1 (which NArrayMiss#[] dose). This is not the case with the 1-dimensional indexing and masking.

NArrayMiss#[index] = value

replace element at index by value .

Filling values

NArraMiss#indgen!([start[,step]])

set values from start with step increment.

NArraMiss#indgen([start[,step]])

same as NArrayMiss#indgen! but create new object.

NArraMiss#fill!(value)

fill elements with value.

NArraMiss#fill(value)

same as NArrayMiss#fill! but create new object.

NArraMiss#random!(max)

set random values between 0<=x<max.

NArraMiss#random(max)

same as NArrayMiss#random! but create new object.

NArraMiss#randomn(max)

set normally distributed random values with mean=0, dispersion=1 (Box-Muller)

Arithmetic operator

NArraMiss#-@
NArraMiss#+(other)
NArraMiss#-(other)
NArraMiss#*(other)
NArraMiss#/(other)
NArraMiss#%(other)
NArraMiss#**(other)
NArraMiss#abs
NArraMiss#add!(other)
NArraMiss#sbt!(other)
NArraMiss#mul!(other)
NArraMiss#div!(other)
NArraMiss#mod!(other)
NArraMiss#mul_add(other, dim, ...)

Bitwise operator (only for byte, sint and int)

NArraMiss#~@
NArraMiss#&(other)
NArraMiss#|(other)
NArraMiss#^(other)

Comparison

NArraMiss#eq(other)
NArraMiss#ne(other)
NArraMiss#gt(other)
NArraMiss#ge(other)
NArraMiss#lt(other)
NArraMiss#le(other)
NArraMiss#>(other)
NArraMiss#>=(other)
NArraMiss#<(other)
NArraMiss#<=(other)
NArraMiss#and(other)
NArraMiss#or(other)
NArraMiss#xor(other)
NArraMiss#not(other)

Statistics

NArraMiss#sum(dim, ... ["min_count"=>i])

return summation of elements in specified dimensions. Elements at which the number of elements for summation is less than {{|i|}} is invalid.

NArraMiss#accum(dim, ...)

same as NArrayMiss#sum but not elimiting dimensions whose length became equal to 1.

NArraMiss#min(dim, ...)

return minimum in specified dimensions. Elements at which the number of valid elements in the dimension is less than {{|i|}} is invalid.

NArraMiss#max(dim, ...)

return maximum in specified dimensions. Elements at which the number of valid elements in the dimension is less than {{|i|}} is invalid.

NArraMiss#mean(dim, ...)

return mean of elements in specified dimensions. Elements at which the number of elements for then mean is less than {{|i|}} is invalid.

NArraMiss#stddev(dim, ...)

return standard deviation of elements in specified dimensions. Elements at which the number of elements for calculation the standard deviation is less than {{|i|}} is invalid.

Sort

NArraMiss#sort(dim)

sort in the 0..dim (All dimensions if omitted)

NArraMiss#sort_index(dim)

return index of sort result.

Transpose

NArraMiss#transpose(dim0, dim1, ...)

transpose array. The 0-th dimension goes to the dim0-th dimension of new array.

Changing Shapes of indices

NArraMiss#reshape!(size, ...)

change shape of array.

NArraMiss#reshape(size, ...)

same as NArrayMiss#reshape! but create new object.

NArraMiss#shape=(size, ...)

same as NArrayMiss#reshape!.

NArraMiss#newdim!(dim)

insert new dimension with size=1

NArraMiss#newdim(dim)

same as NArrayMiss#newdim! but create new object.

NArraMiss#rewrank!(dim)

same as NArrayMiss#newdim!.

NArraMiss#rewrank=(dim)

same as NArrayMiss#newdim!.

Type conversion

NArraMiss#floor

return NArrayMiss of integer whose elements processed floor.

NArraMiss#ceil

return NArrayMiss of integer whose elements processed ceil.

NArraMiss#round

return NArrayMiss of integer whose elements processed round.

NArraMiss#to_i

return NArrayMiss of integer whose elements processed to_i.

NArraMiss#to_f

return NArrayMiss of float whose elements processed to_f.

NArrayMiss#to_type(typecode)

return NArrayMiss of typecode.

NArraMiss#to_a

convert NArrayMiss to Array

NArraMiss#to_na

convert NArrayMiss to NArray

NArraMiss#to_s

convert NArrayMiss to String as a binary data.

NArraMiss#to_string

create NArrayMiss of object whose elements are processed to_s

Iteration

NArraMiss#each{|i| ...}
NArraMiss#collect{|i| ...}
NArraMiss#collect!{|i| ...}

Boolean / mask related (only for byte, sint and int)

NArraMiss#count_false

return the number of elements whose value==0 and valid.

NArraMiss#count_true

return the number of elements whose value!=0 and valid.

NArraMiss#mask(mask)

return NArrayMiss#get_mask&mask.

NArraMiss#all?

return true if all the valid elements are not 0 else, false.

NArraMiss#any?

return true if any valid element is not 0 else, false.

NArraMiss#none?

return true if none of the valid elements is not 0 else, false.

NArraMiss#where

return NArray of indices where valid elements are not 0.

NArraMiss#where2

return Array including two NArrays of indices, where valid elements are not 0, and 0, respectively.

Complex compound number (only for scomplex and complex)

NArraMiss#real
NArraMiss#imag
NArraMiss#conj
NArraMiss#angle
NArraMiss#imag=(other)
NArraMiss#im

Byte swap

NArraMiss#swap_byte

swap byte order.

NArraMiss#hton

convert to network byte order.

NArraMiss#ntoh

convert from network byte order.

NArraMiss#htov

convert to VAX byte order.

NArraMiss#vtoh

convert from VAX byte order.

Mask and missing value

NArraMiss#set_missing(index)

invalidate element at index. index must be Integer, Range, Array, or ture.

NArraMiss#unset_missing(index)

valiadate element at index. index must be Integer, Range, Array, or ture.

NArraMiss#set_mask(mask)

masking by mask

NArraMiss#set_missing_value(value)

replace invalid elements by value.

NArraMiss#get_mask

return NArray of byte as mask.

NArraMiss#get_array

return NArray as data.

NArraMiss#valid?

return Array whose elements are true or false corresponding to valid or invalid of elements, respectively.

NArraMiss#count_valid

return the number of valid elements.

NArraMiss#count_invalid

return the number of invalid elements.

Others

NArraMiss#integer?

return true if NArrayMiss is byte, sint or int, else false.

NArraMiss#complex?

return true if NArrayMiss is scomplex or complex, else false.

NArraMiss#dup
NArraMiss#coerce(object)
NArraMiss#inspect

go back to Index