Learn R Programming

Rmpfr (version 0.4-2)

mpfrMatrix: Classes "mpfrMatrix" and "mpfrArray"

Description

The classes "mpfrMatrix" and "mpfrArray" are, analogously to the base matrix and array functions and classes simply numbers of class mpfr with an additional Dim and Dimnames slot.

Arguments

Objects from the Class

Objects can be created by calls of the form new("mpfrMatrix", ...) or new("mpfrArray", ...), or also by dim(x) <- dd or t(x) where x is a an mpfr number vector.

A (slightly more) alternative to dim(x) <- dd is mpfr2array(x, dd, dimnames).

Extends

Class "mpfrMatrix" extends "mpfrArray", directly.

Class "mpfrArray" extends class "mpfr", by class "mpfrArray", distance 2; class "list", by class "mpfrArray", distance 3; class "vector", by class "mpfrArray", distance 4.

Examples

Run this code
showClass("mpfrMatrix")

validObject(mm <- new("mpfrMatrix"))
validObject(aa <- new("mpfrArray"))

v6 <- mpfr(1:6, 128)
m6 <- new("mpfrMatrix", v6, Dim = c(2L, 3L))
validObject(m6)
m6
which(m6 == 3, arr.ind = TRUE) # |-->  (1, 2)
## Coercion back to "vector": Both of these work:
stopifnot(identical(as(m6, "mpfr"), v6),
          identical(as.vector(m6), v6)) # < but this is a "coincidence"

Run the code above in your browser using DataLab