Displaying 20 results from an estimated 8000 matches similar to: "Math ops behaviour with multiple classes"
2017 Jun 08
0
Math ops behaviour with multiple classes
I think you may be confusing (S3) class and ?mode.
> x <- seq.int(1:3)
> class(x)
[1] "integer"
> mode(x)
[1] "numeric"
> class(x+.5) ## coercion
[1] "numeric"
> mode(x+.5)
[1] "numeric"
But note:
> y <- as.integer(1)
> class(y)
[1] "integer"
> class(y) <- "foo"
> mode(y)
[1] "numeric"
>
2017 Jun 08
1
Math ops behaviour with multiple classes
Thanks Bert, I think we agree on the current behaviour, but I'm still not sure if it's desirable. The mode isn't used for method dispatch. In the following example, I have to write `log.foo` in order for the correct method to be called.
> x <- seq.int(5)
> class(x) <- c("integer", "foo")
> half <- function(x) UseMethod("half")
>
2008 May 27
4
help with simple function
I have a matrix of frequency counts from 0-160.
x<-as.matrix(c(0,1,0,0,1,0,0,0,1,0,0,0,0,1))
I would like to apply a function creating a new column (x[,2])containing
values equal to:
a) log(x[m,1]) if x[m,1] > 0; and
b) for all x[m,1]= 0, log(next x[m,1] > 0 / count of preceding zero values
+1)
for example, x[1,2] should equal log(x[2,1]/2) = log(1/2) = -0.6931472
whereas x[3,2] should
2009 Nov 15
2
Relase positive with log and zero of negative with 0
This is a very simple question but I couldn't form a site search quesry that would return a reasonable result set.
Say I have a vector:
x <- c(0,2,3,4,5,-1,-2)
I want to replace all of the values in 'x' with the log of x. Naturally this runs into problems since some of the values are negative or zero. So how can I replace all of the positive elements of x with the log(x) and the
2009 Jul 30
3
Looping through R objects with $ operator and tags
Hi all,
Suppose I want to set the values in a column to the log of the values
of another column like so:
object$LogDist <- log10(object$Distance)
How do I loop through the objects if I have object1, object2, etc to
perform this function?
object1$LogDist <- log10(object1$Distance)
object2$LogDist <- log10(object2$Distance)
object3$LogDist <- log10(object3$Distance)
I was trying to
2010 Dec 15
1
lmList and lapply(... lm) different std. errors
Am I trying to perform multiple linear regressions on each 'VARIABLE2'. I
figured out that there are different ways, using the following code: (data
is given at the end of this message)
reg <- lapply(split(TRY, VARIABLE2), function(X){lm(X2 ~ X3, data=X)})
lapply(reg, summary)
Which produces the following:
$`1`
Call:
lm(formula = X2 ~ X3, data = X)
Residuals:
Min
2012 Jan 23
2
[LLVMdev] Pointer aliasing
Hi LLVMers,
I would like to ask a question regarding aliasing. Suppose I have the
following program:
double f(double** p )
{
double a,b,c;
double * x = &a;
double * y = &b;
double * z = &c;
*x = 1;
*y = *x + 2;
*z = *x + 3;
return *x+*y+*z;
}
LLVM can tell that the three pointers do not alias each other so can
perform the constant folding at compile time.
2008 Apr 29
1
A Maze Generator
I had some fun this afternoon coding up a 'maze generator' in R. I
thought I'd pass along the fruits of my labor for everyone's amusement.
As written, every point is connected to every other point, so feel free
to 'start' and 'finish' anywhere you like.
Have fun!
--Robert
PS. Feel free to pass along suggestions or comments.
2012 Jan 31
1
[LLVMdev] Pointer aliasing
Hi Dan and Others ,
I'm newbie to LLVM and Clang ,But has experience on compiler optimization
and VM .
Everyone talking about the LLVM in my organisation so thought of peeking
into it and where this discussion is stalled me ...
so i tried to simulate the problem ,which is discussed here .
vi sample.c
double f(double** p )
{
double a,b,c;
double * x = &a;
double * y =
2008 Dec 23
2
Bash Script for Beginners! oh dear :'(
Hey guys,
I'm a bit of a beginner (understatement!) with shell scripting and
seek help! I am setting up our new squid proxy. Its working a treat
and squidGuard is the icing on the cake. But, I am trying to write a
shell script to search through our black list category's for
squidGuard and remove the parsed value;
Scenario:
/some/directory/where/blacklist/is/stored contains about 40-50
2012 Jan 24
2
[LLVMdev] Pointer aliasing
Hi Roel,
the code you list below is precisely what I expect to get (of course
the stores must happen but the constant folding should happen as
well).
It all looks very strange. LLVM is behaving as if the __restrict__
keyword was not used at all. Even more strange is the fact that for
this function:
double f(double *__restrict__ x, double *__restrict__ y, double *__restrict__ z)
{
*x = 1.0;
2012 Jan 26
0
[LLVMdev] Pointer aliasing
On Jan 24, 2012, at 8:58 PM, Brent Walker wrote:
> Thank you for your reply. The compromise you describe below, is it a
> compromise in the LLVM back end or in clang? I run into this while
> building a compiler for a small DSL language for which I generate
> functions that receive a context from which they extract a bunch of
> pointers to doubles from which inputs are passed to
2012 Apr 19
1
combining large list of data.frames
It's normal for me to create a list of data.frames and then use
do.call('rbind', list(...)) to create a single data.frame. However,
I've noticed as the size of the list grows large, it is perhaps better
to do this in chunks. As an example here's a list of 20,000 similar
data.frames.
# create list of data.frames
dat <- vector("list", 20000)
for(i in
2012 Jan 24
0
[LLVMdev] Pointer aliasing
Hi Brent,
Looking at your code I can see at least one reason why some of the store
operations remain in the output since you are (through x, y, and z)
writing in memory which exists outside of your function (p).
Constant propagation also seems to work in the first few lines, *y = *x
+1 (%3) is stored directly.
The strange thing to me is that the same doesn't happen for *z = *x + 2.
Here
2009 May 13
3
Shell Script Pointers?
Hey Listee's
I am trying to write a shell script to sort and compare my blacklist
for squidGuard with the nightly updates that come down in a tar ball.
It should be rather simple but I'm not to grate at this. The script is
to run nightly, it will download the latest blacklist tarball, un tar
it and then add any new entries to the existing black list. The
blacklists work by having a folder
2013 May 22
5
Radio player for FirefoxOS
Hi, Emilis,
I have two working Icecast players which implement client-side parsing of
yp.xml and searching then through it:
- Python, can either transform the yp.xml into SQLite database and then
search inside, or can store the yp.xml locally and transfer in into DOM,
then search it.
http://www.zavedil.com/software-xbmc-icecast
- Java (Android), same algorithm as Python but only the SQLite
2012 Jan 24
2
[LLVMdev] Pointer aliasing
I think the problem here is that the IR doesn't have any way to attach restrict information to loads/stores/pointers.
It works on arguments because they can be given the 'noalias' attribute, and then the alias analyzer must understand what that means.
Pete
On Jan 24, 2012, at 7:47 AM, Roel Jordans wrote:
> I have no clue, I didn't have time to look into that example yet.
2005 Oct 05
2
Trillian?
Has anybody got Trillian to work?
If so, how?
Dex
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d--(+)@ s-:+ a- C+++(++++) UL+>++++ P+>++ L+++>++++ E-- W++ N o? K-
w--(---) !O M+ V- PS++(+) PE(-) Y+ PGP(-) t++(---)@ 5 X+(++) R+(++) tv--(+)@
b+(+++) DI+++ D G++ e* h>++ r%>* y?
------END GEEK CODE BLOCK------
http://www.againsttcpa.com - nothing fights like the opposition
2012 Jan 24
4
[LLVMdev] Pointer aliasing
Can you explain please why it works for this version of the function:
double f(double *__restrict__ x, double *__restrict__ y, double
*__restrict__ z);
What is different here? There are stores here as well.
Brent
On Wed, Jan 25, 2012 at 12:34 AM, Roel Jordans <r.jordans at tue.nl> wrote:
> Hi Brent,
>
> I think this is a problem in the easy-cse transform. In this transform
2005 Jun 02
1
DEM calculation
Hello R-World,
i am trying to calculate data for a DEM (Digital Elavation Model) which i
also want to plot in R. i have the coordinates for the lower left corner
which look something like this:
x<-42,2
y<-50,5
besides i have the cellsize of the grid, which is:
z<-1,1
what i do is to calculate the corrdinates of the cells to the right and top,
what i can do by specifying the number of