is.num_complex: Checks whether a given vector is either a complex no. or a...

View source: R/is.num_complex.R

is.num_complexR Documentation

Checks whether a given vector is either a complex no. or a numeric array.

Description

returns a boolean TRUE if the vector is a numeric OR complex vector.

Usage

is.num_complex(x)

Arguments

x

The item x must be a vector or a matrix.

Details

Function was introduced to take care of complex vectors and numeric vectors since mathematically a complex and numeric matrix would occupy the same space *C^m,n* space.
In comp. sci. parlancethey are diffrent.
Hence was introduced to ease the build up of mathematical functions.

Value

The value returned is a SINGLE boolean value and NOT a boolean vector or matrix.
This is the case since you can't have a complex no., a numeric and a character in the same vector or matrix in R.
Hence only a single bit is returned indicating the type of vector or matrix being used.

Author(s)

Chitran Ghosal

Examples

 library(StatsChitran) ##Call the library

 M <- matrix(data = c(1, 2, 3+2i, 'a'), nrow=2, ncol=2, byrow=T)
 is.num_complex(M)

 M <- matrix(data = c(1, 2, 3+2i, 4), nrow=2, ncol=2, byrow=T)
 is.num_complex(M)

 M <- matrix(data = c(1, 2, 3, 4), nrow=2, ncol=2, byrow=T)
 is.num_complex(M)

 ###The function is currently defined as
is.num_complex <- function(X){
  return(is.numeric(X) | is.complex(X))
}

Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.