Displaying 20 results from an estimated 2000 matches similar to: "Memory allocation"
2003 Sep 21
1
3 basic questions
I have 3 basic questions (sorry, but R is a bit new to me)
First)
The following code will work on C, but something happens with R:
> x<-c(0,1,1,0,0,1,0,0,1)
> dim(x)<-c(3,3)
> types<-numeric(3)
> for (i in 1:3) {
+ j<-1
+ while (x[i,j]!=1) j<-j+1
+ if (j==4) types[i]<-0
+ else types[i]<-1
+ }
Error: subscript out of bounds
Any ideas about what is wrong?
2005 Jul 05
2
Derivative of a function
Suppose I have a simple function that returns a matrix, such as:
test <- function(x){ return(matrix(c(x,x^2,x^3,x^4),2,2)) }
so that test returns:
[ x x^3 ]
[ x^2 x^4 ]
Is it possible for me to get the derivative of an expression such as:
c(1,0) %*% test() %*% c(0,1)
The vectors are used just to "index" the matrix.
I don't want a value, but the expression to work with
2008 Nov 22
2
[LLVMdev] MachineCodeEmitter Patch
Hi,
The following code:
#include<stdio.h>
char bigArray[0x1000000];
int main(int argc, char **argv) {
printf("mem: 0x%x\n", (unsigned) bigArray);
return 0;
}
causes lli to silently fail, even though it compiles correctly with
llc. The reason is that in JITEmitter.cpp only checks to see if
CurBufferPtr == BufferEnd at the beginning of the function and not after
all
2008 Nov 22
3
[LLVMdev] MachineCodeEmitter Patch
Here is the corrected version.
Thomas Jablin wrote:
> Actually, there is a problem with the patch. Please delay review.
>
> Thomas Jablin wrote:
>
>> Hi,
>> The following code:
>>
>> #include<stdio.h>
>>
>> char bigArray[0x1000000];
>>
>> int main(int argc, char **argv) {
>> printf("mem: 0x%x\n", (unsigned)
2008 Nov 22
0
[LLVMdev] MachineCodeEmitter Patch
Actually, there is a problem with the patch. Please delay review.
Thomas Jablin wrote:
> Hi,
> The following code:
>
> #include<stdio.h>
>
> char bigArray[0x1000000];
>
> int main(int argc, char **argv) {
> printf("mem: 0x%x\n", (unsigned) bigArray);
> return 0;
> }
>
> causes lli to silently fail, even though it compiles correctly with
2008 Dec 08
0
[LLVMdev] MachineCodeEmitter Patch
Looks good. Do you have commit privilege?
Evan
On Nov 22, 2008, at 1:19 PM, Thomas Jablin wrote:
> Here is the corrected version.
>
> Thomas Jablin wrote:
>> Actually, there is a problem with the patch. Please delay review.
>>
>> Thomas Jablin wrote:
>>
>>> Hi,
>>> The following code:
>>>
>>> #include<stdio.h>
2010 Mar 31
2
Simplifying particular piece of code
Hello, everyone
I have a piece of code that looks like this:
mrets <- merge(mrets, BMM.SR=apply(mrets, 1, MyFunc, ret="BMM.AV120",
stdev="BMM.SD120"))
mrets <- merge(mrets, GM1.SR=apply(mrets, 1, MyFunc, ret="GM1.AV120",
stdev="GM1.SD120"))
mrets <- merge(mrets, IYC.SR=apply(mrets, 1, MyFunc, ret="IYC.AV120",
2008 Dec 08
1
[LLVMdev] MachineCodeEmitter Patch
Thanks. I do not have commit privilege.
Tom
----- Original Message -----
From: "Evan Cheng" <evan.cheng at apple.com>
To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
Sent: Monday, December 8, 2008 5:39:33 PM GMT -05:00 US/Canada Eastern
Subject: Re: [LLVMdev] MachineCodeEmitter Patch
Looks good. Do you have commit privilege?
Evan
On Nov 22, 2008, at
2011 Feb 18
1
debugger() fails if "..." in function arguments
Dear all,
I'm having a problem with debugger() in both R 2.8.0 and R 2.12.0.
Probably also versions in-between.
I don't see it logged in the bug database, but it's hard for me to
imagine that no-one else has encountered it. So my question is whether
it's a known problem with a workaround, or do I log it as a new problem?
The situation is that if I use
2004 Sep 09
4
scoping rules
Can someone help me with this simple example?
sq <- function() {
y <- x^2
y
}
myfunc <- function() {
x <- 10
sq()
}
myfunc()
executing the above in R yields:
> myfunc()
Error in sq() : Object "x" not found
I understand that R's scoping rules cause it to look for "x" in the
environment in which "sq" was defined (the global environment in
2002 Aug 06
1
re| `By reference'
David Brahm <brahm at alum.mit.edu> wrote:
>VBMorozov at lbl.gov wrote:
>> I would like to pass variables to a function in R in "by reference"...
>Just in case the ensuing discussion got too esoteric, here's one simple
answer:
>R> x <- 1:10
>R> MyFunc <- function(x, zz) assign(deparse(substitute(zz)), sum(x), 1)
>R> MyFunc(x,y)
>R>
2009 Aug 06
1
Using 'field names' of a data.frame in a function
I may be doing this wrong! but I have a function which I have simplified a lot below. I want to pass some 'field names' of a data-frame to the function for it to then do some manipulation of.
Here's my code:
#build a simple dataset
mydataset = data.frame (
2002 Aug 03
2
variable scope
Dear R-guRus:
I would like to pass variables to a function in R in "by reference",
e.g Fortran style.
For example, suppose I have the following code
x<-c(1:10)
y<-1
MyFunc<-function(x,y) {y<-sum(x); return(NULL)}
MyFunc(x,y)
print(y)
in this case print(y) will produce "1" instead of 55 (which is sum(x)) -
how do I make sure that afte the function is run, y
2002 Aug 03
2
variable scope
Dear R-guRus:
I would like to pass variables to a function in R in "by reference",
e.g Fortran style.
For example, suppose I have the following code
x<-c(1:10)
y<-1
MyFunc<-function(x,y) {y<-sum(x); return(NULL)}
MyFunc(x,y)
print(y)
in this case print(y) will produce "1" instead of 55 (which is sum(x)) -
how do I make sure that afte the function is run, y
2011 Jan 10
2
Integration in R
Dear all,
It has been ages since I studied integration in college. Right now I
try to recover all this kind of knowledge and then try to understand how
integration works.
Thus I am doing some first 'experiments' and I would like to request your help and comments.
I have the function:
p2<-function(x){0.5*(3*x^2-1)}
# I found the square of p2 by using some pencil and
2006 Nov 09
3
function
R-help,
I am trying to create a function that i pass a data set to and have the
function return some calculations based on data.
Allow me to illustrate:
myfunc <- function(lst,mn,sd){
lst <- sort(lst)
mn <- mean(lst)
sd <- sqrt(var(lst))
return(lst,mn,sd)
}
data1 <-c (1,2,3,4,5)
data2 <- c(6,7,8,9,10)
myfunc(data1,data1mn,data1sd)
myfunc(data2,data2mn,data2sd)
2012 Aug 29
5
Extracting the name of a function (inverse of match.fun("myFun"))
Hi all,
is there a way to extract the name of a function, i.e. do the reverse
of match.fun applied to a character string? I would like to print out
the name of a function supplied to another function as an argument.
For example:
myFunc = function(x) { x+1 }
applyFunc = function(fnc, x)
{
fnc = match.fun(fnc)
fnc(x)
}
Is there a way to obtain "myFunc" from the argument fnc in
2008 Mar 27
1
A faster way to compute finite-difference gradient of a scalar function of a large number of variables
Hi All,
I would like to compute the simple finite-difference approximation to the
gradient of a scalar function of a large number of variables (on the order
of 1000). Although a one-time computation using the following function
grad() is fast and simple enough, the overhead for repeated evaluation of
gradient in iterative schemes is quite significant. I was wondering whether
there are
2012 Jul 20
3
Execute a function
Hi,
I would like to evaluate a function, with 3 arguments, for instance,
myfunc<-function(a,b,c) { sqrt(a)-exp(b)+4*c
}
How to execute myfunc(x,y,z), for all x, all y and all z, where x,y,z are
vectors?
Thank you very much in advance
--
View this message in context: http://r.789695.n4.nabble.com/Execute-a-function-tp4637182.html
Sent from
2011 Aug 24
1
Passing a large amount of parameters to a function
Hello,
I have a function with a long list of parameters (of different types,
numeric and string)
myFunc <-function(p1, p2, p3, p4, p5...etc)
{
do.something(p1,p2,....)
}
I want to loop over this to provide a different set of parameters to the
list every time.
for (ii in 1:N)
{
myFunc(p1(ii), p2(ii),....etc)
}
I would like to simplify the notation and use some kind of structure, maybe