Displaying 20 results from an estimated 56 matches for "max2".
Did you mean:
max
2008 May 09
2
which.max2()
Hello,
which.max() only returns one index value, the one for the
maximum value. If I want the two index values for the two
largest values, is this a decent solution, or is there a
nicer/better R'ish way?
max2 <-function(v)
{
m=which.max(v)
v[m] = -v[m]
m2=which.max(v)
result=c(m, m2)
result
}
Seems to work ok.
Thanks,
Esmail
2009 Jun 04
3
Fast way of finding top-n values of a long vector
...f(1e6, max=1e7); x[1] <- NA;
benchmark(
replications=20,
columns=c("test","elapsed"),
order="elapsed"
, sort = {a<-sort(x, decreasing=TRUE, na.last=NA)[1:2]; a[1]/a[2];}
, max = {m<-max(x, na.rm=TRUE); w<-which(x==m)[1]; m/max(x[-w],
na.rm=TRUE);}
, max2 = {w<-which.max(x); max(x, na.rm=TRUE)/max(x[-w], na.rm=TRUE);}
)
# test elapsed
# 3 max2 0.772
# 2 max 1.732
# 1 sort 4.958
I want to apply this code to a few tens of thousands of vectors so speed
does matter. In C or similar I would of course calculate the result
with a single pa...
2008 Apr 15
1
disturbing seed dependence in optim L-BFGS-B method
...us results. Any help appreciated!
Best,
Bob Reilly
# Code:
V=function(p){
p1=p[1];p2=p[2]
y=p1*p2-.4*(p1+p2)
return(-y)}
p=c(.2,.2) # p=c(.8,.8)
max=optim(p,V,method = "L-BFGS-B",lower=c(0,0),upper=c(1,1))
max1=optim(max$par,V,method = "L-BFGS-B",lower=c(0,0),upper=c(1,1))
max2=optim(max1$par,V,method = "L-BFGS-B",lower=c(0,0),upper=c(1,1))
max$par
max1$par
max2$par
-max2$value
-V(c(1,1)) # true maximum occurs at c(1,1)
# setting the seed to p=c(.8,.8) will find it
2009 Dec 28
2
Modified R Code
Dear R helpers,
I have following input files. (Actually they are more than 10 rates but here i am considering only 2 rates to write my problem)
rate1.csv
min1 max1 min2 max2 min3 max3
1.05 1.30 1.30 1.65 1.65 1.99
rate2.csv
min1 max1 min2 max2 min3 max3
2.05 2.30 2.30 2.65 2.65 2.99
The simple R c...
2016 Apr 18
0
[PATCH v4 06/37] volt: parse the max voltage map entries
...h b/drm/nouveau/include/nvkm/subdev/bios/vmap.h
index 6633c6d..ae2f27b 100644
--- a/drm/nouveau/include/nvkm/subdev/bios/vmap.h
+++ b/drm/nouveau/include/nvkm/subdev/bios/vmap.h
@@ -1,6 +1,9 @@
#ifndef __NVBIOS_VMAP_H__
#define __NVBIOS_VMAP_H__
struct nvbios_vmap {
+ u8 max0;
+ u8 max1;
+ u8 max2;
};
u16 nvbios_vmap_table(struct nvkm_bios *, u8 *ver, u8 *hdr, u8 *cnt, u8 *len);
diff --git a/drm/nouveau/include/nvkm/subdev/volt.h b/drm/nouveau/include/nvkm/subdev/volt.h
index fc68825..285c6bf 100644
--- a/drm/nouveau/include/nvkm/subdev/volt.h
+++ b/drm/nouveau/include/nvkm/subdev/volt.h...
2005 Nov 24
0
htb thingy
...2|... |1:130| |1:204| ... |1:228|
# +-----+ +-----+ +-----+ +-----+
#
so here goes how i build the tree
#first some variables
dev=eth0
total=512
#for first class i define the limits-i have ten users in this
min1=16
max1=$[$min1*10]
#second class-12 users
min2=24
max2=$[$min2*12]
#what''s left of the bandwidth i put into the local upload class
local=$[$total-$max1-$max2]
#the root
tc qdisc add dev $dev root handle 1: htb default 101 r2q 1
#i fixed r2q to 1 because of the warnings i could get from too low/high
#quantums.
#the main class
tc class add de...
2017 Jan 23
1
[PATCH] virtio_net: fix PAGE_SIZE > 64k
I don't have any guests with PAGE_SIZE > 64k but the
code seems to be clearly broken in that case
as PAGE_SIZE / MERGEABLE_BUFFER_ALIGN will need
more than 8 bit and so the code in mergeable_ctx_to_buf_address
does not give us the actual true size.
Cc: John Fastabend <john.fastabend at gmail.com>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
---
Lightly tested on x86
2017 Jan 23
1
[PATCH] virtio_net: fix PAGE_SIZE > 64k
I don't have any guests with PAGE_SIZE > 64k but the
code seems to be clearly broken in that case
as PAGE_SIZE / MERGEABLE_BUFFER_ALIGN will need
more than 8 bit and so the code in mergeable_ctx_to_buf_address
does not give us the actual true size.
Cc: John Fastabend <john.fastabend at gmail.com>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
---
Lightly tested on x86
2014 Jun 15
4
[PATCH v2 0/3] ARB_viewport_array for nvc0
This patch-series implements the ARB_viewport_array for nvc0 and does
a little house-cleanig afterwords.
V2:
Add Release-Notes, mark this in GL3 as done for nvc0
Don't mark the scissors dirty when we don't need to do that
Tobias Klausmann (3):
nvc0: implement multiple viewports/scissors, enable ARB_viewport_array
docs: update GL3.txt, relnotes: mark GL_ARB_viewport_array as done
2006 Aug 24
1
Optim question
This is a very basic question, but I am a bit confused with optim. I
want to get the MLEs using optim which could replace the newton-raphson
code I have below which also gives the MLEs. The function takes as input
a vector x denoting whether a respondent answered an item correctly
(x=1) or not (x=0). It also takes as input a vector b_vector, and these
are parameters of test items (Rasch estimates
2014 Jun 15
0
[PATCH v2 1/3] nvc0: implement multiple viewports/scissors, enable ARB_viewport_array
...p->translate[2]);
- BEGIN_NVC0(push, NVC0_3D(VIEWPORT_SCALE_X(0)), 3);
- PUSH_DATAf(push, vp->scale[0]);
- PUSH_DATAf(push, vp->scale[1]);
- PUSH_DATAf(push, vp->scale[2]);
-
- /* now set the viewport rectangle to viewport dimensions for clipping */
-
- x = util_iround(MAX2(0.0f, vp->translate[0] - fabsf(vp->scale[0])));
- y = util_iround(MAX2(0.0f, vp->translate[1] - fabsf(vp->scale[1])));
- w = util_iround(vp->translate[0] + fabsf(vp->scale[0])) - x;
- h = util_iround(vp->translate[1] + fabsf(vp->scale[1])) - y;
-
- zmin = vp->...
2012 Jan 27
3
Subsetting for the ten highest values by group in a dataframe
...d a data.frame with two groups and then a id variable (y)
df <- data.frame(x=rnorm(400, mean=20), y=1:400, z=c("A","B"))
## So using ddply I can find the highest value of x
df.max1 <- ddply(df, c("z"), subset, x==sort(x, TRUE)[1])
## Or the 2nd highest value
df.max2 <- ddply(df, c("z"), subset, x==sort(x, TRUE)[2])
## And so on.... but when I try to make a series of numbers like so
## to get the top ten values, I don't get a warning message but
## two values that don't really make sense to me
df.max <- ddply(df, c("z"), subse...
2014 Jun 14
0
[PATCH 1/3] nvc0: implement multiple viewports/scissors, enable ARB_viewport_array
...p->translate[2]);
- BEGIN_NVC0(push, NVC0_3D(VIEWPORT_SCALE_X(0)), 3);
- PUSH_DATAf(push, vp->scale[0]);
- PUSH_DATAf(push, vp->scale[1]);
- PUSH_DATAf(push, vp->scale[2]);
-
- /* now set the viewport rectangle to viewport dimensions for clipping */
-
- x = util_iround(MAX2(0.0f, vp->translate[0] - fabsf(vp->scale[0])));
- y = util_iround(MAX2(0.0f, vp->translate[1] - fabsf(vp->scale[1])));
- w = util_iround(vp->translate[0] + fabsf(vp->scale[0])) - x;
- h = util_iround(vp->translate[1] + fabsf(vp->scale[1])) - y;
-
- zmin = vp->...
2014 Jun 14
7
[PATCH 0/3] ARB_viewport_array for nvc0
This patch-series implements the ARB_viewport_array for nvc0 and does
a little house-cleanig afterwords.
Tobias Klausmann (3):
nvc0: implement multiple viewports/scissors, enable ARB_viewport_array
nvc0: mark scissor in nvc0_clear_{}
nv50/ir: Remove NV50_SEMANTIC_VIEWPORTINDEX and its last consumer
.../drivers/nouveau/codegen/nv50_ir_driver.h | 1 -
2016 Nov 08
2
should we have IR intrinsics for integer min/max?
...y wrong. :)
I thought that @max1 vs. @max3 would be viewed as an unknowable trade-off
between reducing the dependency chain and the pseudo-canonical min/max
form, so we'd add intrinsics, and defer that decision to the backend.
I'll wait to see if there are any other arguments presented.
@max2 vs. @max3 is a straightforward commute that we should have been doing
anyway, so I can start there. Assuming we go with @max3, we need to add
something to DAGCombine to turn that back into @max1 (PPC w/ isel and
AArch64 do better with @max1; x86 is the same).
On Mon, Nov 7, 2016 at 2:47 PM, Hal F...
2014 Feb 04
2
[PATCH 1/3] nv50: rework primid logic
Functionally identical but much simpler. Should also better integrate
with future layer/viewport changes/fixes.
Cc: 10.1 <mesa-stable at lists.freedesktop.org>
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
Not *strictly* necessary in stable, but it will make backporting later fixes
easier. No regressions in piglit.
src/gallium/drivers/nouveau/nv50/nv50_program.c | 5
2015 Feb 05
3
Rcurl crash in R-devel
...ges:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RCurl_1.95-4.5 bitops_1.0-6
> filepath <-
"/Users/marc/Documents/Espace_de_travail_R/package_embryogrowth/embryogrowth/DESCRIPTION"
> urlx <-
"ftp://xxxxx:xxxxxxx at max2.ese.u-psud.fr/conservation/embryogrowth/DESCRIPTION"
> ftpUpload(what=filepath, to=urlx)
*** caught segfault ***
address 0x0, cause 'memory not mapped'
Traceback:
1: .Call("R_curl_easy_perform", curl, .opts, isProtected,
.encoding, PACKAGE = "RCurl")...
2015 Aug 24
4
[PATCH] nv50: avoid using inline vertex data submit when gl_VertexID is used
...50_vbo.c b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
index 600b973..fb4305f 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
@@ -301,6 +301,14 @@ nv50_vertex_arrays_validate(struct nv50_context *nv50)
unsigned i;
const unsigned n = MAX2(vertex->num_elements, nv50->state.num_vtxelts);
+ /* A vertexid is not generated for inline data uploads. Have to use a
+ * VBO. This check must come after the vertprog has been validated,
+ * otherwise vertexid may be unset.
+ */
+ assert(nv50->vertprog->translated);
+...
2010 Dec 11
2
break
Hi
I'm trying to utilize the break command for breaking the loop when the
p-value is less than 10 per cent using the urca package. But it does not
break the loop, anyone that can help me?
library(urca)
set.seed(1)
a1 <- runif(100)
lag.max <- function(object, n = 12){
matris <- matrix(NA, nrow = n)
for(i in 1:n) {
matris[i] <- ur.df(object, lags = i,
2016 Nov 07
5
should we have IR intrinsics for integer min/max?
...cs:
Which, if any, of these is the canonical IR?
; ret = x < y ? 0 : x-y
define i32 @max1(i32 %x, i32 %y) {
%sub = sub nsw i32 %x, %y
%cmp = icmp slt i32 %x, %y ; cmp is independent of sub
%sel = select i1 %cmp, i32 0, i32 %sub
ret i32 %sel
}
; ret = (x-y) < 0 ? 0 : x-y
define i32 @max2(i32 %x, i32 %y) {
%sub = sub nsw i32 %x, %y
%cmp = icmp slt i32 %sub, 0 ; cmp depends on sub, but this looks more
like a max?
%sel = select i1 %cmp, i32 0, i32 %sub
ret i32 %sel
}
; ret = (x-y) > 0 ? x-y : 0
define i32 @max3(i32 %x, i32 %y) {
%sub = sub nsw i32 %x, %y
%cmp = icmp sg...