Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Passing Numpy arrays to C code wrapped with Cython -


i have small bit of existing c code want wrap using cython. want able set number of numpy arrays, , pass arrays arguments c code functions take standard c arrays (1d , 2d). i'm little stuck in terms of figuring out how write proper .pyx code handle things.

there handful of functions, typical function in file funcs.h looks like:

double innerproduct(double *a, double **coords1, double **coords2, const int len) 

i have .pyx file has corresponding line:

cdef extern "funcs.h":     double innerproduct(double *a, double **coords1, double **coords2, int len) 

where got rid of const because cython doesn't support it. i'm stuck wrapper code should pass mxn numpy array **coords1 , **coords2 arguments.

i've struggled find correct documentation or tutorials type of problem. suggestions appreciated.

you want cython's "typed memoryviews" feature, can read in full gory detail here. newer, more unified way work numpy or other arrays. these can exposed in python-land numpy arrays, or can export them python (for example, here). have pay attention how striding works , make sure you're consistent e.g. c-contiguous vs. fortran-like arrays, docs pretty clear on how that.

without knowing bit more function it's hard more concrete on best way - i.e., c function read-only arrays? (i think yes based on signature gave, not 100% sure.) if don't need worry making copies if needed c-contiguous states, because c function doesn't need talk python-level numpy array. typed memoryviews let of minimum of fuss.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -