unuran.packed-methods function

Pack "unuran" object

Pack "unuran" object

Pack unuran object in package Runuran and report its status (packed/unpacked).

Packed unuran objects can be saved and loaded or sent to other nodes in a computer cluster (which is not possible for unpacked object).

FIXME methods

## S4 method for signature 'unuran' unuran.packed(unr) unuran.packed(unr) <- value

Arguments

  • unr: a unuran object.
  • value: TRUE to pack the object.

Details

A unuran object contains a pointer to an external object in library UNU.RAN. Thus it cannot be saved and restored in later

sessions, nor is it possible to copy such an object to different nodes in a computer cluster.

By packing an unuran object all required data are copied from the external object into an list and stored in the unuran object while the external UNU.RAN object is destroyed. Thus the object can be handled like any other

object. Moreover, it can be still used as argument for ur and uq (which may have even faster execution times then). Packed unuran objects cannot be unpacked any more.

Notice that currently only objects that implement method PINV

can be packed.

Methods

Currently only objects that implement method PINV can be packed.

Note

Note that due to limitations of floating point arithmetic the output of a uq call with the same input value for u may slightly differ for the packed and unpacked version.

See Also

unuran, pinv.new.

Examples

## create a unuran object for half-normal distribution using methed 'PINV' gen <- pinv.new(dnorm,lb=0,ub=Inf) ## status of object unuran.packed(gen) ## draw a random sample of size 10 x <- ur(gen,10) ## pack unuran object unuran.packed(gen) <- TRUE unuran.packed(gen) ## draw a random sample of size 10 x <- ur(gen,10) ## Not run: ## unpacking is not supported unuran.packed(gen) <- FALSE ## results in error ## End(Not run)
  • Maintainer: Josef Leydold
  • License: GPL (>= 2)
  • Last published: 2025-04-07