# 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
- Class Methods
- Class Instance Methods
  - NArrayMiss information
  - Slicing Array
  - Filling values
  - Arithmetic operator
  - Bitwise operator
  - Comparison
  - Statistics
  - Sort
  - Transpose
  - Changing Shapes of indices
  - Type conversion
  - Iteration
  - Boolean and mask related
  - Complex compound number
  - Byte swap
  - Mask and missing value
  - Others

## 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 `Numeric` `Array` or `NArray`.
`NArrayMiss.to_nam_no_dup(array [,mask])`
  convert from array to `NArrayMiss`.

go back to Index

## Class Instance Methods

### NArrayMiss information

`NArrayMiss#dim`
  return the dimension which is the number of indices.
`NArrayMiss#rank`
  same as `NArrayMiss#dim`.
`NArrayMiss#shape`
  return the `Array` of sizes of each index.
`NArrayMiss#size`
  return the number of total elements.
`NArrayMiss#total`
  alias to size
`NArrayMiss#length`
  alias to size
`NArrayMiss#rank_total`
  return the number of total of the shape.
`NArrayMiss#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#set_without_validation(index,value)`
  replace elements at index by value.
`NArrayMiss#[index] = value`
  replace elements at index by value and make replaced elements valid.

### Filling values

`NArrayMiss#indgen!([start[,step]])`
  set values from start with step increment.
`NArrayMiss#indgen([start[,step]])`
  same as `NArrayMiss#indgen!` but create new object.
`NArrayMiss#fill!(value)`
  fill elements with value.
`NArrayMiss#fill(value)`
  same as `NArrayMiss#fill!` but create new object.
`NArrayMiss#random!(max)`
  set random values between 0<=x<max.
`NArrayMiss#random(max)`
  same as `NArrayMiss#random!` but create new object.
`NArrayMiss#randomn(max)`
  set normally distributed random values with mean=0, dispersion=1 (Box-Muller)

### Arithmetic operator

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

### Bitwise operator (only for byte, sint and int)

`NArrayMiss#~@`
`NArrayMiss#&(other)`
`NArrayMiss#|(other)`
`NArrayMiss#^(other)`

### Comparison

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

### Statistics

`NArrayMiss#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.
`NArrayMiss#accum(dim, ...)`
  same as `NArrayMiss#sum` but not elimiting dimensions whose length became equal to 1.
`NArrayMiss#min(dim, ...)`
  return minimum in specified dimensions. Elements at which the number of valid elements in the dimension is less than i is invalid.
`NArrayMiss#max(dim, ...)`
  return maximum in specified dimensions. Elements at which the number of valid elements in the dimension is less than i is invalid.
`NArrayMiss#median(dim, ...)`
  return median in specified dimensions. Elements at which the number of valid elements in the dimension is less than i is invalid.
`NArrayMiss#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.
`NArrayMiss#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.
`NArrayMiss#rms(dim, ...)`
  return root mean square of elements in specified dimensions. Elements at which the number of elements for calculation the RMS is less than i is invalid.
`NArrayMiss#rmsdev(dim, ...)`
  return root mean square deviation of elements in specified dimensions. Elements at which the number of elements for calculation the RMS deviation is less than i is invalid.

### Sort

`NArrayMiss#sort(dim)`
  sort in the 0..dim (All dimensions if omitted)
`NArrayMiss#sort_index(dim)`
  return index of sort result.

### Transpose

`NArrayMiss#transpose(dim0, dim1, ...)`
  transpose array. The 0-th dimension goes to the dim0-th dimension of new array.

### Changing Shapes of indices

`NArrayMiss#reshape!(size, ...)`
  change shape of array.
`NArrayMiss#reshape(size, ...)`
  same as `NArrayMiss#reshape!` but create new object.
`NArrayMiss#shape=(size, ...)`
  same as `NArrayMiss#reshape!`.
`NArrayMiss#newdim!(dim)`
  insert new dimension with size=1
`NArrayMiss#newdim(dim)`
  same as `NArrayMiss#newdim!` but create new object.
`NArrayMiss#rewrank!(dim)`
  same as `NArrayMiss#newdim!`.
`NArrayMiss#rewrank=(dim)`
  same as `NArrayMiss#newdim!`.

### Type conversion

`NArrayMiss#floor`
  return `NArrayMiss` of integer whose elements processed `floor`.
`NArrayMiss#ceil`
  return `NArrayMiss` of integer whose elements processed `ceil`.
`NArrayMiss#round`
  return `NArrayMiss` of integer whose elements processed `round`.
`NArrayMiss#to_i`
  return `NArrayMiss` of integer whose elements processed `to_i`.
`NArrayMiss#to_f`
  return `NArrayMiss` of float whose elements processed `to_f`.
`NArrayMiss#to_type(typecode)`
  return `NArrayMiss` of typecode.
`NArrayMiss#to_a`
  convert `NArrayMiss` to `Array`.
`NArrayMiss#to_na!([missing_value])`
  convert `NArrayMiss` to `NArray`. if there is argument, set missing_value for invalid elements.
`NArrayMiss#to_na([missing_value])`
  convert `NArrayMiss` to `NArray`. if there is argument, set missing_value for invalid elements.
`NArrayMiss#to_s`
  convert `NArrayMiss` to `String` as a binary data.
`NArrayMiss#to_string`
  create `NArrayMiss` of object whose elements are processed `to_s`

### Iteration

`NArrayMiss#each{|x| ...}`
`NArrayMiss#each_valid{|x| ...}`
`NArrayMiss#each_valid_with_index{|x,i| ...}`
`NArrayMiss#collect{|x| ...}`
`NArrayMiss#collect!{|x| ...}`

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

`NArrayMiss#count_false`
  return the number of elements whose value==0 and valid.
`NArrayMiss#count_true`
  return the number of elements whose value!=0 and valid.
`NArrayMiss#mask(mask)`
  return `NArrayMiss#get_mask!&mask`.
`NArrayMiss#all?`
  return true if all the valid elements are not 0, else false.
`NArrayMiss#any?`
  return true if any valid element is not 0, else false.
`NArrayMiss#none?`
  return true if none of the valid elements is not 0, else false.
`NArrayMiss#where`
  return `NArray` of indices where valid elements are not 0.
`NArrayMiss#where2`
  return `Array` including two `NArray`s of indices, where valid elements are not 0, and 0, respectively.

### Complex compound number (only for scomplex and complex)

`NArrayMiss#real`
`NArrayMiss#imag`
`NArrayMiss#conj`
`NArrayMiss#angle`
`NArrayMiss#imag=(other)`
`NArrayMiss#im`

### Byte swap

`NArrayMiss#swap_byte`
  swap byte order.
`NArrayMiss#hton`
  convert to network byte order.
`NArrayMiss#ntoh`
  convert from network byte order.
`NArrayMiss#htov`
  convert to VAX byte order.
`NArrayMiss#vtoh`
  convert from VAX byte order.

### Mask and missing value

`NArrayMiss#set_valid(index)`
  validate element at index. index must be `Integer, Range, Array, or ture`.
`NArrayMiss#validation(index)`
  alias to set_valid
`NArrayMiss#set_invalid(index)`
  invaliadate element at index. index must be `Integer, Range, Array, or ture`.
`NArrayMiss#invalidation(index)`
  alias to set_invalid
`NArrayMiss#all_valid`
  set all elements valid
`NArrayMiss#all_invalid`
  set all elements invalid
`NArrayMiss#set_mask(mask)`
  masking by mask
`NArrayMiss#set_missing_value(value)`
  replace invalid elements by value.
`NArrayMiss#get_mask!`
  return `NArray` of byte as mask.
`NArrayMiss#get_mask`
  return `NArray` of byte as mask.
`NArrayMiss#get_array!`
  return `NArray` as data.
`NArrayMiss#get_array`
  return `NArray` as data.
`NArrayMiss#valid?(index)`
  return `Array` whose elements are true or false, or `True`/`False` corresponding to validity of the specified element(s) by the index
`NArrayMiss#all_valid?`
  return true if all elements are valid, else false.
`NArrayMiss#none_valid?`
  return true if all elements are invalid, else false.
`NArrayMiss#all_invalid?`
  alias to none_valid?
`NArrayMiss#any_valid?`
  return true if any elements are valid, else false.
`NArrayMiss#count_valid`
  return the number of valid elements.
`NArrayMiss#count_invalid`
  return the number of invalid elements.

### Others

`NArrayMiss#integer?`
  return true if `NArrayMiss` is byte, sint or int, else false.
`NArrayMiss#complex?`
  return true if `NArrayMiss` is scomplex or complex, else false.
`NArrayMiss#dup`
`NArrayMiss#coerce(object)`
`NArrayMiss#inspect`

go back to Index