File: relInv.R

package info (click to toggle)
r-cran-blockmodeling 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 912 kB
  • sloc: ansic: 2,024; f90: 952; sh: 13; makefile: 5
file content (25 lines) | stat: -rw-r--r-- 761 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#' @encoding UTF-8
#' @title Functions for computing "relative inverse" (\code{x[1]/x}).
#' 
#' @description
#' For a vector x, it computes \code{x[1]/x}. For \code{relInv2}, if certain elements of the result are not finite (e.g. if certain elements of x are 0), these elements are replaced with 0s.
#'
#' @param x A numeric vector. For \code{relInv} it should not contain 0s (while for  \code{relInv2} it can).
#' @return A vector computed as \code{x[1]/x}. For \code{relInv2}, if the non-finite elements are replaced with 0s.
#' 
#' @author \enc{Aleš Žiberna}{Ales Ziberna}
#' 
#' @keywords manip
#' @export
relInv<-function(x)x[1]/x


#' @rdname relInv
#' 
#' @export
relInv2<-function(x){
  x<-x[1]/x
  x[!is.finite(x)]<-0
  x
}