Displaying 20 results from an estimated 7000 matches similar to: "pari/gp interface"
2008 Mar 09
2
Bessel functions of complex argument
Dear R users,
I'm porting a piece of Matlab code to R, but I'm now stuck with the
following: I need an equivalent of besselJ(x, nu) that can handle a
complex argument x. I couldn't find any R implementation. I did find
a possible fortran solution in SLATEC (< http://www.netlib.org/slatec/
> , CBESJ-C), however I've never tried to use external C or Fortran
code
2008 Mar 09
2
Bessel functions of complex argument
Dear R users,
I'm porting a piece of Matlab code to R, but I'm now stuck with the
following: I need an equivalent of besselJ(x, nu) that can handle a
complex argument x. I couldn't find any R implementation. I did find
a possible fortran solution in SLATEC (< http://www.netlib.org/slatec/
> , CBESJ-C), however I've never tried to use external C or Fortran
code
2007 Apr 27
2
system() in packages
Hello
Quite often I need higher precision, or larger numbers,
than IEEE double precision allows. One strategy I sometimes
use is to use system() to call pari/gp, which is not constrained by
IEEE.
[pari/gp is a GPL high-level mathematical programming language
geared towards pure mathematics]
Two of my packages contain lines like the following:
> system(" echo '1.12^66' |
2005 Jan 07
1
Visualizing complex analytic functions using domain coloring
Hi
has anyone coded up domain colouring for visualizing complex analytic
functions
(such as elliptic functions)?
[
the idea is to depict a complex function f(z) using a filled.contour()
variant
in which the hue is given by Arg(f(z)), and the saturation by Mod(f(z)).
]
--
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
European Way, Southampton SO14 3ZH, UK
tel
2012 Dec 21
2
Difficulty importing data from PARI/GP
I'm trying to import a matrix created in PARI/GP into R but am having
problems.
The data in the text file has entries separated by commas but the rows
themselves are separated by semicolons rathen than being on a new line. Is
there a way to get R to recognise that ";" means start a new row ?
--
View this message in context:
2006 Feb 22
3
elements that appear only once
Hi.
I have a factor and I want to extract just those elements that appear
exactly once.
How to do this?
Toy example follows.
> a <- as.factor(c(rep("oak",5) ,rep("ash",1),rep("elm",1),rep
("beech",4)))
> a
[1] oak oak oak oak oak ash elm beech beech beech beech
Levels: ash beech elm oak
> table(a)
a
ash beech elm oak
2007 Mar 19
3
character to numeric conversion
Hi.
Is there a straightforward way to convert a character string
containing comma-delimited
numbers to a numeric vector?
In my application, I use
system(executable.string, intern=TRUE)
which returns a string like
"[0.E-38, 2.096751179214927596171268230,
3.678944959657480671183123052, 4.976528845643001020345216157,
6.072390165503099343887569007, 7.007958550337542210168866070,
2006 Jul 27
4
inserting rows into a matrix
Hi
I have a little vector function that takes a vector A of strictly
positive integers
and outputs a matrix M each of whose columns is the vector, modified in
a complicated combinatorical way.
Now I want to generalize the function so that A can include zeroes.
Given A,
I want to strip out the zeroes, pass it to my function, and pad M
with rows at positions corresponding to the zeroes
2008 Mar 26
5
S4 slot with NA default
Hi
How do I specify an S4 class with a slot that is potentially numeric,
but NA
by default? I want the slot to be NA until I calculate its value
(an expensive operation, not needed for all applications). When
its value is
known, I will create a new object with the correct value inserted in
the slot.
I want "NA" to signify "not known".
My attempt fails because
2006 Sep 13
3
functions and strings
Hi
If
string <- "xyz"
f <- function(x){1 + sin(cos(x)) + exp(x^2)}
How do I manipulate "string" and f() to give the string
"1 + sin(cos(xyz)) + exp(xyz^2)"
?
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743
2007 Jan 16
5
"[[" gotcha
The following gotcha caught me off-guard just now.
I have two matrices, a and b:
a <- matrix(1,3,3)
b <- matrix(1,1,1)
(note that both "a" and "b" are matrices).
I want them in a list:
> B <- NULL
> B[[1]] <- a
> B[[2]] <- b
> B
[[1]]
[,1] [,2] [,3]
[1,] 1 1 1
[2,] 1 1 1
[3,] 1 1 1
[[2]]
[,1]
[1,] 1
2006 Oct 13
5
combinatorics
Hi
How do I generate all ways of ordering sets of indistinguishable items?
suppose I have two A's, two B's and a C.
Then I want
AABBC
AABCB
AACBC
ABABC
. . .snip...
BBAAC
. . .snip...
CBBAA
[there are 5!/(2!*2!) = 30 arrangements. Note AABBC != BBAAC]
How do I do this?
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14
2006 Feb 28
2
lines() and recycled colours
Hi
?lines says
For 'type = "h"', 'col' can be a vector and will be recycled as
needed.
Why doesn't lines() recycle colours for other types?
If I type
> plot(0:1,0:1,type="n")
> lines(runif(11),runif(11),col=c("red","green"))
>
then all ten lines are red, with no warning given. Is there a reason
why
2005 Nov 17
3
changing figure size in Sweave
Hi
In Sweave, how does one change the size of the plots?
I tried using a hook:
<<echo=FALSE, print=FALSE, fig=TRUE>>=
options(SweaveHooks=list(fig=function() ps.options(width=1)))
library(graphics)
pairs(iris)
@
but this didn't change the size of the figure. How to make the
figures a
different size?
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre,
2005 Jan 05
4
output from table() in matrix form
Hi
How do I get the output from table() in matrix form?
If I have
R> table(c(1,1,1,1,2,20))
1 2 20
4 1 1
I want
[,1] [,2] [,3]
[1,] 1 2 20
[2,] 4 1 1
The problem is that names(table) is a vector of characters and I need
the numeric values.
I am using
R> rbind(as.integer(names(x)),x)
I thought tabulate() might be better as it takes an
2005 Jun 13
3
extracting components of a list
Hi
how do I extract those components of a list that satisfy a certain
requirement? If
jj <- list(list(a=1,b=4:7),list(a=5,b=3:6),list(a=10,b=4:5))
I want just the components of jj that have b[1] ==4 which in this case
would be the first and
third of jj, viz list (jj[[1]],jj[[3]]).
How to do this efficiently?
My only idea was to loop through jj, and set unwanted components to
NULL,
2005 Jun 20
6
sweep() and recycling
Hi
I had a hard-to-find bug in some of my code the other day, which I
eventually
traced to my misusing of sweep().
I would expect sweep() to give
me a warning if the elements don't recycle nicely, but
X <- matrix(1:36,6,6)
sweep(X,1,1:5,"+")
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 2 9 16 23 30 32
[2,] 4 11 18 25 27 34
[3,] 6 13 20 22
2006 Nov 17
2
do.call("+", ...)
Hi
How do I make do.call() take "+" as a function for a list of more
than two elements?
Toy problem follows:
f <- function(i){matrix((1:6)^i,2,3)}
# Thus f() returns a matrix of size 2x3; I want to add a whole bunch
of such matrices,
# as in f(1) + f(2) + f(3) + f(4)
# But:
> do.call("+",sapply(1:4,f,simplify=FALSE))
Error in do.call("+",
2006 Dec 14
4
two connected graphs
Hi
I have two datasets, A and B, consisting of two columns of numbers
representing x and y coordinates.
They have 10 and 6 rows respectively.
I want to plot two scattergraphs, one above the other.
The lower graph to contain A (10 points) and the upper
graph to contain B (six points).
The x-axes of the two graphs must line up.
I then want to draw straight lines that connect points
of B to a
2005 Jul 12
3
elegant matrix creation
Hi
I want to write a little function that takes a vector of arbitrary
length "n" and returns a matrix of size n+1 by n+1.
I can't easily describe it, but the following function that works for
n=3 should convey what I'm trying to do:
f <- function(x){
matrix(c(
1 , 0 , 0 , 0,
x[1] , 1 , 0 , 0,
x[1]*x[2] , x[2] , 1 , 0,