python


From C to Python passage by pointer and modification of values [closed]


I should implement this piece of code from C to Python:
#include <R.h>
#include <math.h>
#include <stdlib.h>
#include <memory.h>
#include "mean.circular.h"
#include "median.circular.h"
void MedianCircularRad(double *x,int *n,double *result,double *medians,int *lMedians)
{
double valueOfDev;
int i,k=0;
double minimum = PI;
for(i=0;i<(*n);i++)
{
valueOfDev = dev(x,x[i],n);
if((valueOfDev - minimum)/(*n) < -DOUBLE_EPS)
{
minimum = valueOfDev;
medians[0] = x[i];
k=1;
}
else if(fabs(valueOfDev-minimum) <= pow(10,-8))
{
medians[k++] = x[i];
}
}
MeanCircularRad(medians,&k,result);
*lMedians = k;
}
double dev(double *theta,double xv,int *n)
{
double values=0;
int j;
for(j=0;j<(*n);j++)
{
values += fabs(PI-fabs(theta[j]-xv));
}
values = values / (*n);
values = PI - values;
return(values);
}
There is a line in C where I call MeanCircularRad and I pass medians which is an array, &k and result. Array in C does not store its length, but in Python every array has its length; can I omit the passage of k?

Related Links

python open file error
Dealing with Sprites and Collisions Using Pygame
Pip-installed module does not import
Does a trailing comma after an n-tuple in Python change its value?
Program that either waits for user input or runs at defined intervals?
pexpect for passwordless access does not work
Kivy Widget does not accepts properties and commands
Efficient combinations of combinations
what metric should I monitor for a spider in scrapy
Why is Aptana/Pydev showing “undefined variable” errors for “print” and “__name__” in my helloworld python code?
Python Tkinter: Delete label not working
How to call a function after adding values to an Option Menu?
using python to verify that a shapefile is a shapefile (fiona, ogr)
Identifying largest connected component in a matrix
VBA shell script set environment variable before execution
Embed matplotlib in PyQt

Categories

HOME
google-apps-script
batch-processing
pug
appmaker
specflow
rebol
urlencode
requirejs
onenote-api
android-viewpager
packer
flexbox
xamarin-studio
intellij-plugin
tee
store
webmethods
cosmicmind
pdo
lstm
medium-editor
sql-update
deb
onsen-ui
badge
branch
hash-collision
classpath
websauna
postgresql-9.2
stocks
hawtio
pycparser
geomesa
nunit-3.0
text-files
npm-publish
visualstudio.testtools
nashorn
stereo-3d
pdftk
service-fabric-stateful
pytest-django
archer
floor
sgmlreader
etherpad
paas
onresume
project-template
typhoon
chessboard.js
mongoose-populate
gameanalytics
multiple-file-upload
project-online
sun-codemodel
interactive-brokers
galaxy
cctray
persistence.xml
unity5.3
paypal-nvp
httpie
subversion-edge
virus
musl
android-search
line-numbers
ultrawingrid
iostream
method-overriding
yahoo-boss-api
smartystreets
crystal-reports-10
android-json-rpc
operations
nsmatrix
sql-server-2012-web
jqmobi
haskell-platform
entity-framework-4.1
objcmongodb
qt4.6
trailing-slash
code-conversion
couchdb-lucene
applicationcontext
hobo
driving-directions
shared-objects
noir
ihttphandler
pantheios
svn-hooks
carbide
boost-date-time
winverifytrust
pci-bus
callgrind
weborb

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App