|
Go to the documentation of this file.
19#ifndef MATHLINK_UTILS_H
20#define MATHLINK_UTILS_H
31inline void MLPut(MLINK link, const std::string& s)
33 MLPutSymbol(link, s.c_str());
36inline void MLPut(MLINK link, int c)
38 MLPutInteger(link, c);
41inline void MLPut(MLINK link, double c)
46inline void MLPut(MLINK link, std::complex<double> c)
48 if (std::imag(c) == 0.) {
49 MLPutReal(link, std::real(c));
51 MLPutFunction(link, "Complex", 2);
52 MLPutReal(link, std::real(c));
53 MLPutReal(link, std::imag(c));
58void MLPut(MLINK link, const Eigen::Array<double,M,1>& a)
61 for ( int i = 0; i < M; i++)
63 MLPutRealList(link, v, M);
67void MLPut(MLINK link, const Eigen::Matrix<double,M,1>& m)
69 const Eigen::Array<double,M,1> a(m.array());
73template < int M, int N>
74void MLPut(MLINK link, const Eigen::Matrix<double,M,N>& m)
77 for ( int i = 0; i < M; i++)
78 for ( int k = 0; k < N; k++)
81 long dims[] = { M, N };
82 MLPutDoubleArray(link, ( double*)mat, dims, NULL, 2);
86void MLPut(MLINK link, const Eigen::Array<std::complex<double>, M,1>& a)
88 MLPutFunction(link, "List", M);
89 for ( int i = 0; i < M; i++)
94void MLPut(MLINK link, const Eigen::Matrix<std::complex<double>, M,1>& m)
96 const Eigen::Array<std::complex<double>, M,1> a(m.array());
100template < int M, int N>
101void MLPut(MLINK link, const Eigen::Matrix<std::complex<double>, M,N>& m)
103 MLPutFunction(link, "List", M);
104 for ( int i = 0; i < M; i++) {
105 MLPutFunction(link, "List", N);
106 for ( int k = 0; k < N; k++)
113inline void MLPutHeads(MLINK link, const std::vector<std::string>& heads)
115 for ( const auto& h: heads)
116 MLPutFunction(link, h.c_str(), 1);
121inline void MLPutRule(MLINK link, const std::string& name, const std::vector<std::string>& heads = {})
123 MLPutFunction(link, "Rule", 2);
125 MLPutUTF8Symbol(link, reinterpret_cast<const unsigned char* >(name.c_str()), name.size());
128inline void MLPutRule(MLINK link, int number, const std::vector<std::string>& heads = {})
130 MLPutFunction(link, "Rule", 2);
132 MLPutInteger(link, number);
135inline void MLPutRule(MLINK link, long number, const std::vector<std::string>& heads = {})
137 MLPutFunction(link, "Rule", 2);
139 MLPutLongInteger(link, number);
142template < class T1, class T2>
143void MLPutRuleTo(MLINK link, T1 t, const T2& name, const std::vector<std::string>& heads = {})
151inline void MLGet(MLINK link, int *c)
153 MLGetInteger(link, c);
156inline void MLGet(MLINK link, long *c)
158 MLGetLongInteger(link, c);
161inline void MLGet(MLINK link, short *c)
163 MLGetShortInteger(link, c);
void MLPutHeads(MLINK link, const std::vector< std::string > &heads)
void MLPutRuleTo(MLINK link, T1 t, const T2 &name, const std::vector< std::string > &heads={})
void MLGet(MLINK link, int *c)
void MLPut(MLINK link, const std::string &s)
void MLPutRule(MLINK link, const std::string &name, const std::vector< std::string > &heads={})
|