Questions tagged [mixed-programming]

Short for Mixed-Language Programming, which is the process of building programs in which the source code is written in two or more languages (e.g. call existing code that may be written in another language).

Short for Mixed-Language Programming.

Mixed-language programming is the process of building programs in which the source code is written in two or more languages. Although mixed-language programming presents some additional challenges, it is worthwhile because it enables you to call existing code that may be written in another language.

To learn more:

27 questions
7
votes
1 answer

Speeding up Matlab Engine calls

I'm interfacing MATLAB with C/C++ using the MATLAB Engine API. In my particular case MATLAB is used to calculate something and result is printed in C. However, throughout various test on both sides I noticed significant performance losses in C.…
Dave
  • 71
  • 4
3
votes
1 answer

Calling Fortran functions which return KIND=10 complex values from C++

I have a bunch of old F77 source code (usually compiled on a x86_64 with gfortran -std=legacy). It contains quite a few functions in form: double complex function f(x, y, i) double precision x, y integer i f = cmplx(x, y) *…
Wile E.
  • 31
  • 2
3
votes
1 answer

Default arguments for pointer in C++ and mixed programming

The usage of default arguments for pointers in C++ can be demonstrated with following code #include void myfunc_(int var, double* arr = 0) { if (arr == 0) { std::cout << "1 arg" << std::endl; } else { std::cout << "2 arg" <<…
2
votes
2 answers

minimum modification to make a visual studio FORTRAN-C mixed code gfortran-gcc compatible

I'm trying to modify this code (gist as back up) to become gfortran-gcc compatible. I removed the [VALUE] tags used POINTER with -fcray-pointer flag for gfortran, instead of the [REFERENCE] tag removed the __stdcall , because tried the #define…
Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
2
votes
1 answer

Calling a global string variable from Fortran in C causes segmentation fault

I'm trying to call a global string variable which is defined in a Fortran subroutine, in C. the C code is Cfile.c: #include typedef struct { int length; char* string; } fstring; extern fstring stringf_; void…
Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
2
votes
1 answer

Pthread Wrapper for Fortran

I am newbie to both Fortran and C++, working on a task to couple two programs written in Fortran and C++. I am trying to create a pthread(detached) wrapper and call it from my Fortran subroutine and pass a cpp function to it. I wrote some code by…
raghu
  • 83
  • 2
  • 12
2
votes
0 answers

Calling Fortran subroutine from C++ OpenMP parallel for should work?

When calling a Fortran subroutine from a C++ function, and the C++ function is called inside an OpenMP parallel for construct, the Fortran subroutine returns different values from time to time. It is a blackbox subroutine that should return the same…
sugus
  • 21
  • 4
2
votes
1 answer

i cant compile matlab generated code, it gives me a linker error what is the correct step i have to follow?

i was trying to learn matlab to C workflow and i used a matlab coder to generate C/C++ code from this .m file function c = simpleProduct(a,b) %#codegen c=a*b; and after the code has been generated my visual win32 c++ project looks like…
1
vote
2 answers

Are there C like pre-processor directives for Octave and Scilab to be used for intercompatible code?

In C / C++ languages one can use macros or as called "per-processor directives" to instruct the compiler how the code should be read. The simple commands of #def, #ifdef, #ifndef, #else, #endif ... give the compiler the ability to check for…
1
vote
0 answers

Inconsistent Memory Reference

I am doing some mixed programming between C++ and FORTRAN. A problem comes up about passing a character array from FORTRAN to C++ as shown in the code. CDll.h: // CDll.h #pragma once #ifdef __cplusplus extern "C" { #endif #define DLLEXPORT…
Blane John
  • 65
  • 6
1
vote
2 answers

Convert OpenCV Mat file to Matlab matrix

I create a Matlab engine to covert OpenCV Mat file to Matlab matrix. However, I got wrong results. I attached my code so that you can directly test it. #pragma comment (lib, "libmat.lib") #pragma comment (lib, "libmx.lib") #pragma comment (lib,…
SimaGuanxing
  • 673
  • 2
  • 10
  • 29
1
vote
2 answers

Call MATLAB directly (multiple threading) in Visual Studio

Currently I am trying to call MATLAB directly in Visual Studio, but it seems not working. To be clear, take the following demo case as an example, i.e. use MATLAB to compute 2+3. It is expected that the result, i.e. ans = 5, should be printed in…
herohuyongtao
  • 49,413
  • 29
  • 133
  • 174
1
vote
1 answer

Linking Error between matlab R2013a and MS VC++ 2013

I am writing a BCI game application in VC++ and require to implement Common Spatial Pattern Filtering (CSP) for feature extraction. Due to the hefty coding involved, I prefer to use an existing CSP Matlab function that I have. I followed the steps…
Adee_lib
  • 39
  • 1
  • 8
1
vote
4 answers

How to run a MATLAB file (.m file) from java?

I am trying to figure out a way to run a .m file from java. When the .m file is run it outputs a text file that I need to retrieve. I already have the code to retrieve the text file in java but I still cannot figure out how to start and run the .m…
user3578954
  • 13
  • 1
  • 3
1
vote
1 answer

How to execute a Matlab function in MS Visual C++?

I have 2 separate functions which one is in MS visual C++ and another is in Matlab. How do I execute the Matlab file in MS VISUAL? Is there a windows function to load the .m file and execute it straightly?
user3396218
  • 255
  • 2
  • 8
  • 20
1
2