Skip to content

Instantly share code, notes, and snippets.

View jayemerson's full-sized avatar

Jay Emerson jayemerson

View GitHub Profile
# https://github.com/jayemerson/big.data.frame/blob/master/inst/Jaks.R
@jayemerson
jayemerson / Coke_solves_operator_problem
Created July 16, 2011 00:40
Coke... this Bud's for you!
> a <- c(1,2,3) + c(4,5,6)
> print(a)
5 7 9
> b <- c(1,2,3) + 99
> print(b)
100 101 102
@jayemerson
jayemerson / FixedFloarArray
Created July 14, 2011 01:37
What am I missing with the FixedFloatArray?
sub mean2(*@args) {
# This works, but is Resizable:
#my $vec := pir::new("ResizableFloatArray");
# This works, but... argh.
my $vec := Q:PIR { %r = new ["FixedFloatArray"], 2 };
#my $vec := pir::new("FixedFloatArray", 2);
# Generates: "init_pmc() not implemented in class 'FixedFloatArray'"
@jayemerson
jayemerson / jay_get_number
Created July 13, 2011 23:45
Almost there... I can feel it.
# Line indicated below is generating the error: "get_number() not implemented in class 'FixedFloatArray'"
.sub '' :anon :load
.....
# Documented http://www.gnu.org/software/gsl/manual/html_node/Mean-and-standard-deviation-and-variance.html if you want to check the signature...
dlfunc nci, lib, 'gsl_stats_mean', 'dpll'
set_global ['GSL'], 'gsl_stats_mean', nci
......
.end
@jayemerson
jayemerson / jay_nqr_loadings
Created July 13, 2011 22:07
function loading up front
# NQR/src/nqr.pir
.sub '' :anon :load
load_bytecode 'HLL.pbc'
... # OMITTED STANDARD squaak STUFF
# ATTEMPTED LIBRARY LOADING UP FRONT?
.local pmc lib, nci
loadlib lib, 'libgsl.so'
dlfunc nci, lib, 'gsl_ran_gaussian_pdf', 'ddd'
@jayemerson
jayemerson / nci_thunk_problem
Created July 10, 2011 18:34
Error when running: No NCI thunk available for signature '[ 4, 4, 4 ]'
sub test(*@args) {
my $ans;
ans := Q:PIR {
.local pmc libgsl, gsl_ran_gaussian_pdf
.local num ans, xval, sigma
xval = 0.0
sigma = 1.0
libgsl = loadlib "libgsl"
if libgsl goto HAVELIBRARY
say 'Could not load the library'
@jayemerson
jayemerson / nci_with_pir
Created July 10, 2011 04:32
This works and does what I want...
sub rexp(*@args) {
return Q:PIR {
$P0 = find_lex '@args'
.local num arg1
arg1 = $P0[0]
.local pmc libRmath, rexp
.local num ans
libRmath = loadlib "libRmath"
rexp = dlfunc libRmath, "rexp", "dd"
ans = rexp(arg1)
@jayemerson
jayemerson / Jay_nci_example_result
Created July 9, 2011 23:58
NCI up and running with a non-trivial example
jay@bayesman:~/Desktop/NQR$ ./installable_nqr
Not Quite R for Parrot VM.
> setseeds(1,2)
Seeds have been set.
> a = rexp(1)
Your exponential: 1.41192912698369
> print(a)
1.41192912698369
@jayemerson
jayemerson / NQR_for_attempt
Created July 9, 2011 12:08
a 3.3.0 version of matrixy's 'for_statement'?
Not Quite R for Parrot VM.
> i <- 99
> myfor(i in c(1,2,3)) { print(c(i, i*i)) }
99 9801
99 9801
99 9801
>
rule statement:sym<myfor> {