2014년 8월 17일 일요일
load dll asm
.file "loaddllex.cpp"
.intel_syntax noprefix
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "C:\\work\\dummy.dll\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
LFB6:
lea ecx, [esp+4]
LCFI0:
and esp, -16
push DWORD PTR [ecx-4]
push ebp
LCFI1:
mov ebp, esp
push ecx
LCFI2:
sub esp, 36
call ___main
mov DWORD PTR [esp], OFFSET FLAT:LC0
call _LoadLibraryA@4
sub esp, 4
mov DWORD PTR [ebp-12], eax
mov eax, 0
mov ecx, DWORD PTR [ebp-4]
LCFI3:
leave
LCFI4:
lea esp, [ecx-4]
LCFI5:
ret
LFE6:
.section .eh_frame,"w"
Lframe1:
.long LECIE1-LSCIE1
LSCIE1:
.long 0
.byte 0x3
.ascii "\0"
.uleb128 0x1
.sleb128 -4
.uleb128 0x8
.byte 0xc
.uleb128 0x4
.uleb128 0x4
.byte 0x88
.uleb128 0x1
.align 4
LECIE1:
LSFDE1:
.long LEFDE1-LASFDE1
LASFDE1:
.long LASFDE1-Lframe1
.long LFB6
.long LFE6-LFB6
.byte 0x4
.long LCFI0-LFB6
.byte 0xc
.uleb128 0x1
.uleb128 0
.byte 0x4
.long LCFI1-LCFI0
.byte 0x10
.byte 0x5
.uleb128 0x2
.byte 0x75
.sleb128 0
.byte 0x4
.long LCFI2-LCFI1
.byte 0xf
.uleb128 0x3
.byte 0x75
.sleb128 -4
.byte 0x6
.byte 0x4
.long LCFI3-LCFI2
.byte 0xc
.uleb128 0x1
.uleb128 0
.byte 0x4
.long LCFI4-LCFI3
.byte 0xc5
.byte 0x4
.long LCFI5-LCFI4
.byte 0xc
.uleb128 0x4
.uleb128 0x4
.align 4
LEFDE1:
.ident "GCC: (GNU) 4.8.1"
.def _LoadLibraryA@4; .scl 2; .type 32; .endef
2014년 8월 16일 토요일
k-mean clustering
require(graphics)
beta1<-c(-0.130811881,-0.124113184,-0.111084035,-0.346505179,0.146765992,-0.203682819)
beta2<-c(0.19744896,0.158675025,0.098311959,0.644843941,-0.197478252,0.278922585)
beta1<-c(-0.130811881, -0.124113184, -0.111084035, -0.346505179, 0.146765992, -0.201818799, 0.109229194, -0.203682819, -0.124113184, -0.065281704, -0.089614531)
beta2<-c(0.19744896, 0.158675025, 0.098311959, 0.644843941, -0.197478252, 0.100779252, -0.204082744, 0.278922585, 0.158675025, 0.099221018, 0.136914875)
x <- cbind(beta1, beta2)
colnames(x) <- c("x", "y")
(cl <- kmeans(x, 2))
plot(x, col = cl$cluster)
points(cl$centers, col = 1:2, pch = 8, cex = 2)
# sum of squares
ss <- function(x) sum(scale(x, scale = FALSE)^2)
## cluster centers "fitted" to each obs.:
fitted.x <- fitted(cl); head(fitted.x)
resid.x <- x - fitted(cl)
## Equalities : ----------------------------------
cbind(cl[c("betweenss", "tot.withinss", "totss")], # the same two columns
c(ss(fitted.x), ss(resid.x), ss(x)))
stopifnot(all.equal(cl$ totss, ss(x)),
all.equal(cl$ tot.withinss, ss(resid.x)),
## these three are the same:
all.equal(cl$ betweenss, ss(fitted.x)),
all.equal(cl$ betweenss, cl$totss - cl$tot.withinss),
## and hence also
all.equal(ss(x), ss(fitted.x) + ss(resid.x))
)
kmeans(x,1)$withinss # trivial one-cluster, (its W.SS == ss(x))
## random starts do help here with too many clusters
## (and are often recommended anyway!):
(cl <- kmeans(x, 5, nstart = 25))
plot(x, col = cl$cluster)
points(cl$centers, col = 1:5, pch = 8)


피드 구독하기:
글 (Atom)