Posts

python 3.x - Using c++ complex functions in Cython -

i trying complex exponential in cython. i have been able cobble following code pyx : from libc.math cimport sin, cos, acos, exp, sqrt, fabs, m_pi, floor, ceil cdef extern "complex.h": double complex cexp(double complex z) import numpy np cimport numpy np import cython cython.parallel cimport prange, parallel def try_cexp(): cdef: double complex rr1 double complex rr2 rr1 = 1j rr2 = 2j print(rr1*rr2) #print(cexp(rr1)) note print(cexp(rr1)) commented. when line active, following error when running setup.py : error: command 'c:\\winpython\\winpython-64bit-3.4.3.6\\python-3.4.3.amd64\\scripts\\gcc.exe' failed exit status 1 note when cexp commented out, runs expected... can run setup.py , , when test function prints out product of 2 complex numbers. here setup.py file. note includes code run openmp in cython using g++: from distutils.core import setup cython.build import cythonize distutils.extension import...

arduino - Python doesn't parse Serial data to an array -

i working on project in have collect voltages teensy 2.0(which programming arduino) , send voltages python. have send microsecond data taken on. using pyserial communicate teensy. first read in data array of length 3998. have 2 other arrays, timedata array, keeps track of microseconds, , radardata array, keeps track of voltages. each array carries half data, or 1999 points. sample portion of serialdata: b'1468095384\r\n' b'0.01\r\n' this repeated 1999 times. python code takes these inputs , writes them , array "serialdata". after done reading data separates points 2 arrays so: for in range (0,3998): if(i % 2 == 0): radardata[samples] = float(str(serialdata[i], 'utf-8')) samples = samples + 1 else: timedata[samples1] = float(str(serialdata[i], 'utf-8')) samples1 = samples1 + 1 sample , sample1 counter variables. from printing out float(str(serialdata[i], 'utf-8')) , know parsing s...

pass C++ double array to embedded python efficiently without NumPy -

i extending c++ embedded python. how efficiently pass array of doubles? currently create tuple: std::vector<double> a(len); ... pyobject* pinput = pytuple_new(len); (int i=0; i<len; ++i) pytuple_setitem(pinput, i, pyfloat_fromdouble(a[i])); is there more efficient way large arrays (e.g. len > 1000000 )? not want use numpy. datatype use on python side then? possible construct object of type array.array (binary python array)? or other (python) type should construct in c++ code, converted array.array on python side.

Japanese text in Symfony form titles -

i'm working on project requires using symfony form component, , need able add kanji of field names. using english works fine: $form = $this->createformbuilder() ->add('name', texttype::class) ->add('price', texttype::class) ->getform(); when try name of fields in japanese though, error: fatal error: uncaught exception 'symfony\component\form\exception\invalidargumentexception' message 'the name "名" contains illegal characters. names should start letter, digit or underscore , contain letters, digits, numbers, underscores ("_"), hyphens ("-") , colons (":"). is there way change display name of field? $form = $this->createformbuilder() ->add('name', texttype::class, [ 'label' => '名', ])->... this should job, , or use resource file if avoid including language specific characters. $form = $this->createformbuilder() ->add('name', t...

c++ - glMatrixMode(GL_MODELVIEW) use giving segmentation fault -

i trying implement camera fps project , having trouble when using camera class on main.cpp when calling glmatrixmode(gl_modelview) . here relevant functions: void camera::init() { m_yaw = 0.0; m_pitch = 0.0; set_pos(0,0,0); } void camera::set_pos(float x, float y, float z) { m_x = x; m_y = y; m_z = z; refresh(); } void camera::refresh() { m_lx = cos(m_yaw) * cos(m_pitch); m_ly = sin(m_pitch); m_lz = sin(m_yaw) * cos(m_pitch); m_strafe_lx = cos(m_yaw - m_pi_2); m_strafe_lz = sin(m_yaw - m_pi_2); glmatrixmode(gl_modelview); glloadidentity(); printf("the segmentation fault above!\n"); glulookat(m_x, m_y, m_z, m_x + m_lx, m_y + m_ly, m_z + m_lz, 0.0, 1.0, 0.0); //printf("camera: %f %f %f direction vector: %f %f %f\n", m_x, m_y, m_z, m_lx, m_ly, m_lz); } in case if include glew.h, need initialize beforehand, otherwise gl api calls replaced null function pointers , causes segfaults...

C#: What's the behavior of the fixed statement on empty strings? -

this document , part of c# language spec, says behavior of fixed in c# implementation-defined if used on null/empty array reference. quote it: an expression of array-type elements of unmanaged type t, provided type t* implicitly convertible pointer type given in fixed statement. in case, initializer computes address of first element in array, , entire array guaranteed remain @ fixed address duration of fixed statement. the behavior of fixed statement implementation-defined if array expression null or if array has 0 elements. however, not make same claim empty strings, saying behavior isn't defined if string null. here's next paragraph detailing how works strings: an expression of type string, provided type char* implicitly convertible pointer type given in fixed statement. in case, initializer computes address of first character in string, , entire string guaranteed remain @ fixed address duration of fixed statement. the behavior of fixed statement implementat...

jasper reports - Group several same value field into a single cell -

Image
first of all, records shown in table table component not in report one. the results looks this: years months summonth sumquarter ----- ------ -------- ---------- 2009 jan 130984 432041 feb 146503 mar 154554 apr 147917 435150 may 131822 jun 155411 jul 144000 424806 aug 130369 sep 150437 oct 112137 400114 nov 152057 dec 135920 ===================================== jan-dec 1692111 ===================================== 2010 jan 139927 417564 feb 154940 mar 122697 apr 163257 413305 may 124999 jun 125049 jul 145127 427612 aug 138804 sep 143681 oct 143398 406381 nov 125351 dec 137632 ...