Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [native-code]

Machine code and assembly code is sometimes called native code when referring to platform-dependent parts of language features or libraries.

2
votes
0answers
27 views

Wrapping C++ library in C++/CLI using shared_ptr

Background: I'm writing C++ code after a fairly long time, so I may not be up to date on the best practices, so please bear with me. I'm only trying to improve and learn. Problem I need to write a ...
0
votes
0answers
44 views

JNI: porting a semaphore data type to Windows

I have this JNI code to review. The demo driver + irrelevant porting code is here. semaphore_impl.h: ...
4
votes
2answers
233 views

Passing bitmap from C# to C++ via a struct

First, I've read the a few questions regarding this issue, the most helpful being: https://stackoverflow.com/questions/27463876/passing-bitmap-from-c-sharp-to-c I was unable to get the provided ...
3
votes
1answer
80 views

Expand every bit into a byte

I have the following code: ...
5
votes
1answer
62 views

Plain C implementation of 'Cumulative All' operation for R

I want to implement a cumulative all through R's C interface. I was able to hack something together that produces the correct results, but I have little idea what idiomatic C should look like. The ...
3
votes
0answers
57 views

C++ Trie implementation with Python wrapper

I'm just starting to use C++ so beginner feedback is fine here. CPP code (main.cpp, node.h, node.cpp, trie.h, trie.cpp, utils.h) main.cpp ...
3
votes
0answers
59 views

Launcher for python.exe within a self-contained application package

Below is code modified from the source code for python.exe. The motivation is to be able to build a suite of python applications that can be distributed with an installer, that share an isolated run-...
6
votes
2answers
203 views

Moving average function in C++ for use with R

I am trying to improve the code and speed up in C++ (Rcpp) a (centered) weighted moving average function I coded. An example of what the roll_mean function does. Note that the function works no ...
6
votes
1answer
105 views

Fastest way to find a string delimited by two words

Motivated by this question, I created a simple benchmark for investigating what is the fastest way to extract a substring given two delimiting words: ...
3
votes
2answers
85 views

Safe, simultaneous string replacement

I've written a function which takes as an input: a string to be modified a vector of regular expressions on which to match a vector of replacements option to ignore case in the match statements The ...
1
vote
0answers
44 views

RFID card reader validation routine in 8051 assembly

I came up with the following code to check to see if the last 2 bytes of a 12-byte value read in from a RDM6300 card reader is actually the checksum of the first 10 bytes. ...
3
votes
1answer
121 views

Transform a vector with the FFI in Haskell

In Haskell, I want to apply a transformation to each element of a vector using the FFI. I am rather ignorant in C, I am more or less novice in Haskell and this is the first time I use storable vectors ...
3
votes
1answer
547 views

Correction for barrel and pincushion distortion

I have a c++ dll I am calling (PInvoking) from C# which corrects barrel and pincushion distortion. Basically I call a method which generates a set of look up arrays and I adjust the pixels of the ...
6
votes
2answers
2k views

C# to C++ function call that fills and auto resize array if size is not enough

I have a C# function that calls a C++ function to fill the array with pixel data from a camera. This is better than allocating memory on the C++ side and marshaling it on C# side each time the ...
8
votes
0answers
174 views

.NET DLL Injector in C++

I built a DLL Injector with User-Interface. The program lists all processes, the user chooses one of them and a DLL, and inject it. It's my first project in C++, and I know it's not exactly C++ ...
3
votes
1answer
116 views

Reading a string-to-string map from an archive

I have a CArchive Which contains a serialized CMapStringToString. From my research it is my understanding that it is quite ...
11
votes
2answers
554 views

Call a lua function - the C++ way

I'm not that good when it comes to templates, especially when it comes to variadic templates. I want to show you some code where I use both - templates and variadic templates - to call a lua function. ...
2
votes
1answer
125 views

Two knot-removal function for curve and surface

Recently, I have been using the Wolfram LibraryLink wrapper. By that technique, I could call the function written in C from Wolfram Mathematica. Here are two C wrapper functions, ...
2
votes
2answers
172 views

How do I write my multithreading code correctly so that it is faster than a single thread? [closed]

I have the following code that I am trying to optimize. I am running it on a Linux machine with 24 cores. I thought I could use multithreading to make it faster, but it's somehow making it way slower ...
3
votes
1answer
178 views

Counting matrix elements that have “4” or “5” as a neighbor

I have a matrix (500x500) of integers. For each entry, I need to look at its surrounding neighbours (so 8 elements) and determine what the integers are, and run a function on these integers. Here ...
3
votes
0answers
134 views

Reduce encoded length of UTF-8 encoded Ruby string in C extension

I'm writing a Ruby extension in C. It's a string processing module working on UTF-8 encoded strings only. One method, full_width_to_ascii!, converts full width ...
5
votes
0answers
450 views

Calculating complex exponential numbers using OpenMP in Cython

I am trying to create a function that can either beat numexpr or perform comparably for the vectorized mathematical operation ...
4
votes
1answer
592 views

Same PyObject for a shared_ptr C++ object

I have a similar problem as in this mail. I want that every time I return the same C++ managed object to Python, I get the same PyObject. With the standard ...
3
votes
2answers
366 views

Hello World using Python embedded in C++, with RAII library initialization

I have written a small Hello World application that uses Python's C-API. The C library requires some functions to be called for global library (de-)initialization and the objects created by the ...
5
votes
1answer
116 views

Mean of the squares of differences for a large matrix

I have tried to obtain speed gains by transferring Matlab calculations to C and call it using .mex. My goal is to operate on a matrix \$B\$ which has roughly the dimension 10000x1000 $$ \frac{1}{\...
7
votes
3answers
5k views

k-nearest neighbors using MATLAB with MEX

I have implemented kNN (k-nearest neighbors) as follows, but it is very slow. I want to get an exact k-nearest-neighbor, not the approximate ones, so I didn't use the FLANN or ANN libraries. ...
7
votes
2answers
259 views

Linspace method build in Python's C API

Today I built a linspace function in Python's C API: ...