Sha256: b7681606e897787b78befc4b2615d0ae273b4800098ecfaf9a1f70cde49fbeb7
Contents?: true
Size: 990 Bytes
Versions: 1
Compression:
Stored size: 990 Bytes
Contents
/* * (c) 2021 Murata Mitsuharu * Licensed under the MIT License. */ #include "fromfile.h" #include <ruby.h> #include <numo/narray.h> extern VALUE numo_cDFloat; VALUE numo_fromfile(VALUE self, VALUE filename){ char* cfilename = StringValuePtr(filename); long filesize = NUM2LONG(rb_funcall(rb_cFile, rb_intern("size"), 1, filename)); VALUE a = rb_funcall(numo_cDFloat, rb_intern("zeros"), 1, LONG2NUM(filesize / sizeof(double))); dFloatFromFileP(cfilename, (double*)na_get_pointer_for_read(a)); return a; } VALUE numo_tofile(VALUE self, VALUE filename){ char* cfilename = StringValuePtr(filename); DFloat data; data.data = (double*)na_get_pointer_for_read(self); data.size = NUM2LONG(rb_funcall(self, rb_intern("size"), 0)); dFloat2file(cfilename, data); return self; } void Init_fromfile(void){ rb_define_singleton_method(numo_cDFloat, "fromfile", numo_fromfile, 1); rb_define_method(numo_cDFloat, "tofile", numo_tofile, 1); }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
narray-fromfile-0.1.2 | ext/fromfile/fromfile.c |