Posts

math - what will be python code for runge kutta second method? -

is code ok? def rkn(x, fx, n, hs): k1 = [] k2 = [] k3 = [] k4 = [] xk = [] in range(n): k1.append(fx[i](x)*hs) in range(n): xk.append(x[i] + k1[i]*0.5) in range(n): k2.append(fx[i](xk)*hs) in range(n): xk[i] = x[i] + k2[i]*0.5 in range(n): k3.append(fx[i](xk)*hs) in range(n): xk[i] = x[i] + k3[i] in range(n): k4.append(fx[i](xk)*hs) in range(n): x[i] = x[i] + (k1[i] + 2*(k2[i] + k3[i]) + k4[i])/6 return x with numpy seems more readable: code taken http://www.math-cs.gordon.edu/courses/mat342/python/diffeq.py def rk2a( f, x0, t ): """second-order runge-kutta method solve x' = f(x,t) x(t[0]) = x0. usage: x = rk2a(f, x0, t) input: f - function of x , t equal dx/dt. x may multivalued, in case should list or numpy array. in case f must return numpy array same dimensio...

database - MySQL Indexing Keys Fields -

can explain me happen , best way create third table on next clausule. should : index (id), index (id_producto), index (id_usuario) be removed? create table producto ( id int not null auto_increment, precio decimal, primary key(id) ) engine=innodb; create table usuario ( id int not null auto_increment, nombre varchar(100) not null, primary key (id) ) engine=innodb; create table ordenes_productos ( id int not null auto_increment, id_producto int not null, id_usuario int not null, fecha_hora datetime not null, primary key(id, id_producto, id_usuario), index (id), index (id_producto), index (id_usuario), foreign key (id_producto) references producto(id), foreign key (id_usuario) references usuario(id) ) engine=innodb; thanks all. id int not null auto_increment, primary key(id, id_producto, id_usuario), index (id), index (id_producto), index (id_usuario), foreign key (id_producto) ...

c - Why is the offsetof macro necessary? -

i new c language , learned structs , pointers. my question related offsetof macro saw. know how works , logic behind that. in <stddef.h> file definition follows: #define offsetof(type,member) ((unsigned long) &(((type*)0)->member)) my question is, if have struct shown below: struct test { int field1: int field2: }; struct test var; why cannot directly address of field2 as: char * p = (char *)&var; char *addressoffield2 = p + sizeof(int); rather writing this field2offset = offsetof (struct test, field2); and adding offset value var's starting address? is there difference? using offsetof more efficient? the c compiler add padding bits or bytes between members of struct in order improve efficiency , keep integers word-aligned (which in architectures required avoid bus errors , in architectures required avoid efficiency problems). example, in many compilers, if have struct : struct imlikelypadded { int x; char...

java - How to configure deployment servlet contexts using jersey test framework -

so trying use junit test apis exposed via jersey 2. have on tomcat server using following context.xml connect oracle db: /meta-inf/context.xml : <context> <resource name="jdbc/deliverydb" auth="container" type="javax.sql.datasource" username="usernamee" password="password" driverclassname="oracle.jdbc.oracledriver" url="someurl" maxtotal="3" maxidle="3" /> </context> and below junit code: @override protected testcontainerfactory gettestcontainerfactory() { return new grizzlywebtestcontainerfactory(); } @override protected deploymentcontext configuredeployment(){ return servletdeploymentcontext .forservlet(new servletcontainer( new resourceconfig( myresource.class ) .packages("provider_package") ) ) .cont...

struct - how to access information in a file? C++ -

im having trouble 2 things, first in if statement choice c should take selected record file , change contents, not work reason file contents not change. in choice d need able read , add quantities , sales costs file , add them display them. im not sure start one. know need access info file, lines said data, add them , save them in variable displayed, how can access lines in file have data? #include <iostream> #include <fstream> #include <string> #include "stdafx.h" using namespace std; struct info { // create inventory items info string itemdescription; int quantity; double wholesalecost; double retailcost; string date; }; int main() { //make instance of info , variable user selection info item; char choice; // set functions long bytenum(int); void showrec(info); void changerec(info); //open file ...

python 3.x - using pyqtdeploy with homebrew installation of Qt5 -

i'm trying out pyqdeploy tutorial @ http://pyqt.sourceforge.net/docs/pyqtdeploy/tutorial.html . i'm working on imac, os 10.11, latest xcode installed, , homebrew installations of qt5.5.1, python 3.5, sip, , pyqt5. can run pyqtdeploy gui okay , seems fine until gets "make" step. @ point "make failed" warning. details read ld: library not found -lqtgui clang: error: linker command failed exit code 1 (use -v see invocation) make: ***[pyqtdeploy.app/contents/macos/pyqtdeploy] error 1 i've been banging head against wall several days now, i'd appreciate suggestions people might have this. lets try figuring out - i'm pure newbie here, have ideas, may helpful. so if try opening makefile project , search "lqtgui" string, find libs definition string, (in case): libs = $(sublibs) -f/users/aimsson/applications/qt/5.5/clang_64/lib -l/users/aimsson/desktop/pyqt_test/osx/python/lib/python3.4/site-packages -lsip -l/users/aimsson/de...

html - JavaFX WebView doesn't display masked images in Sencha Touch app -

i working on javafx application uses javafx webview browser display sencha touch webapp. long story short, sencha touch application being accessed through different browser, in future needs accessed on device running javafx webview. makes things little convoluted, it's been pretty seamless transition. the issue i'm having comes our use of -webkit-mask-image css property. using property color number of buttons , other images fit in whatever coloring scheme being used. unfortunately, javafx webview seems pretty confused -webkit-mask-image , , images being distorted. i did homework , came this blog post describes how achieve effects similar -webkit-mask-image in other browsers, using svg's foreignobject. as per article, added following html sencha touch application see how render in javafx webview: <svg width="400px" height="300px"> <defs> <mask id="mask" maskunits="userspaceonuse" maskcontentunits...