double(length=0) is.double(x) as.double(x)
is.double returns TRUE if x is an object of storage mode "double", and FALSE otherwise.
as.double returns x if x is a simple object of storage mode "double", and otherwise a vector of the same length as x and with data resulting from coercing the elements of x to storage mode double.
These functions are needed when interfacing to Fortran or C algorithms, where it is important to emphasize the exact storage mode of data.
In most S-PLUS expressions it is not necessary to explicitly ensure that data are of a particular storage mode. When testing for data suitable for arithmetic, for example, it is better to use is.numeric(x), which will return TRUE for any numeric object. Normally, S-PLUS does numeric computations with double precision. Explicit reference to storage mode double is usually only relevant when passing arguments to Fortran or C routines that have arguments with double precision or float declarations.
Note the difference between coercing to a vector and setting the storage mode attribute: storage.mode(myobject) <- "double" This changes the storage mode of myobject but leaves all other attributes unchanged (so, e.g., a matrix stays a matrix). The value of as.double(myobject) has no attributes.
z <- double(length(zz)) # double object same length as zz amp;.Fortran("mydsub",as.double(xm))