当前位置: 首页 > news >正文

福建省建设行业企业资质查询网站制作网站南京

福建省建设行业企业资质查询网站,制作网站南京,网站三网合一什么意思,江门seo劳动节闲来无事#xff0c;写了一天程序#xff0c;just for fun.看#xff0c;这是C调用Matlab画图的一段程序。暂时不想多解释了#xff0c;有兴趣的话#xff0c;看看下面的代码吧。以下几段代码由上到下#xff0c;越来越旧。最上面的是最新更新的版本。#include#inc…劳动节闲来无事写了一天程序just for fun.看这是C调用Matlab画图的一段程序。暂时不想多解释了有兴趣的话看看下面的代码吧。以下几段代码由上到下越来越旧。最上面的是最新更新的版本。#include#include#include#include#includeusing namespace std;#include#include#includeclass MatArray{public:MatArray() : _data(NULL){}MatArray(size_t irows, size_t icols){resize(irows, icols);}MatArray(const MatArray obj){if (obj._data){_data  mxCreateDoubleMatrix(obj.rows(), obj.cols(), mxREAL);memcpy(this-ptr(), obj.ptr(), sizeof(double)*rows()*cols());}else{_data  NULL;}}~MatArray(){ mxDestroyArray(_data); _data  NULL; }inline size_t rows() const { return _data ? mxGetM(_data) : 0; }inline size_t cols() const { return _data ? mxGetN(_data) : 0; }inline double* ptr() const { return _data ? mxGetPr(_data) : NULL; }bool resize(size_t irows, size_t icols){if (!_data){_data  mxCreateDoubleMatrix(irows, icols, mxREAL);return (_data ! NULL);}if (rows()  irows || cols()  icols){return true;}mxDestroyArray(_data);_data  mxCreateDoubleMatrix(irows, icols, mxREAL);return (_data ! NULL);}int put(Engine *ep, const char* var_name){return engPutVariable(ep, var_name, _data);}templatevoid copy_from_eigen(const EigenMat emat){if (emat.rows()*emat.cols()  0){mxDestroyArray(_data); _data  NULL;}resize(emat.rows(), emat.cols());for (int c  0; c for (int r  0; r (*this)[r  c*(int)(emat.rows())]  emat(r, c);}}}inline double operator[](int i){return ptr()[i];}private:mxArray *_data;};string rndcolor(){string color  [;color  to_string((rand() % 256) / 255.)  ,;color  to_string((rand() % 256) / 255.)  ,;color  to_string((rand() % 256) / 255.)  ];return color;}class Matlab{private:Matlab(const Matlab obj){}public:Matlab(){_engine  engOpen(NULL);if (!_engine){cerr }else{cout }}~Matlab(){// if you are testing algorithm, you are encouraged to keep the line below bing committed.//engClose(_engine); _engine  NULL;}// line_spec : LineStyle  Marker  Color, e.g. -or// for line// LineStyle  {none, -, :, -.}// LineWidth  0.5// Color  {[0 0.4470 0.7410] (default) | RGB triplet | {y,m,c,r,g,b,w,k} | none}// for Marker// Marker  {none, o, , *, ., x, s, d, ^, v, , // MarkerEdgeColor  auto (default) | none | RGB triplet | {y,m,c,r,g,b,w,k}// MarkerFaceColor  auto (default) | none | RGB triplet | {y,m,c,r,g,b,w,k}// MarkerSize  6templateint plot(const TMatX X, const TMatY Y,string nm0   ,string nm1   , string nm2   ,string nm3   , string nm4   ,string nm5   , string nm6   ,string nm7   , string nm8   ,string nm9   , string nm10  ,string nm11  , string nm12  ,string nm13  , string nm14  ){MatArray MX, MY;MX.copy_from_eigen(X); MX.put(_engine, MX);MY.copy_from_eigen(Y); MY.put(_engine, MY);string plot_code  MX, MY;string code;#define EVL_CODE(_ARG0,_ARG1) code  var_plot_code(nm##_ARG0, nm##_ARG1); if(code ! ){ plot_code  ,   code;}code  var_plot_code(nm0, );if (code ! ){plot_code  ,   code;EVL_CODE(1, 2);EVL_CODE(3, 4);EVL_CODE(5, 6);EVL_CODE(7, 8);EVL_CODE(9, 10);EVL_CODE(11, 12);EVL_CODE(13, 14);}else{EVL_CODE(0, 1);EVL_CODE(2, 3);EVL_CODE(4, 5);EVL_CODE(6, 7);EVL_CODE(8, 9);EVL_CODE(10, 11);EVL_CODE(12, 13);}#undef EVL_CODEplot_code  plot(  plot_code  );;cout exec(plot_code);return 0;}// line_spec : LineStyle  Marker  Color, e.g. -or// for line// LineStyle  {none, -, :, -.}// LineWidth  0.5// Color  {[0 0.4470 0.7410] (default) | RGB triplet | {y,m,c,r,g,b,w,k} | none}// for Marker// Marker  {none, o, , *, ., x, s, d, ^, v, , // MarkerEdgeColor  auto (default) | none | RGB triplet | {y,m,c,r,g,b,w,k}// MarkerFaceColor  auto (default) | none | RGB triplet | {y,m,c,r,g,b,w,k}// MarkerSize  6templateint plot_mask(const TMatX X, const TMatY Y, const TMask mask,string nm0   ,string nm1   , string nm2   ,string nm3   , string nm4   ,string nm5   , string nm6   ,string nm7   , string nm8   ,string nm9   , string nm10  ,string nm11  , string nm12  ,string nm13  , string nm14  ){MatArray MX, MY, MS;MX.copy_from_eigen(X); MX.put(_engine, MX);MY.copy_from_eigen(Y); MY.put(_engine, MY);MS.copy_from_eigen(mask); MS.put(_engine, MS);string plot_code  MX(MS0), MY(MS0);string code;#define EVL_CODE(_ARG0,_ARG1) code  var_plot_code(nm##_ARG0, nm##_ARG1); if(code ! ){ plot_code  ,   code;}code  var_plot_code(nm0, );if (code ! ){plot_code  ,   code;EVL_CODE(1, 2);EVL_CODE(3, 4);EVL_CODE(5, 6);EVL_CODE(7, 8);EVL_CODE(9, 10);EVL_CODE(11, 12);EVL_CODE(13, 14);}else{EVL_CODE(0, 1);EVL_CODE(2, 3);EVL_CODE(4, 5);EVL_CODE(6, 7);EVL_CODE(8, 9);EVL_CODE(10, 11);EVL_CODE(12, 13);}#undef EVL_CODEplot_code  plot(  plot_code  );;cout exec(plot_code);return 0;}string var_plot_code(string nm, string var){boost::trim(nm); boost::trim(var);if (nm  ){return ;}string code    nm  ;if (var  ){return (nm[0]  Z) ? code : ;}if (nm  LineStyle || nm  Marker){ // string// LineStyle, -return code  ,   var  ;}if (nm  LineWidth || nm  MarkerSize){ // positive number// LineWidth, 0.5return code  ,    var;}if (nm  Color || nm  MarkerEdgeColor || nm  MarkerFaceColor){if (var[0]  [){return code  ,    var;}else{return code  ,   var  ;}}return ;}int exec(string cmd){return engEvalString(_engine, cmd.c_str());}private:Engine *_engine;};Matlab mbeng;int main(int argc, char** argv){// random circlesEigen::ArrayXXf data;data  data.Random(1000, 2);//mbeng.exec(figure(1); clf;);mbeng.plot(data.col(0), data.col(1), o, MarkerFaceColor, [0,0,0], MarkerEdgeColor, [0,0,0]);mbeng.exec(axis tight;);// different colorsint K  4;Eigen::ArrayXXi clid;clid  Eigen::abs(clid.Random(1000, 1));for (int i  0; i clid(i, 0)  clid(i, 0) % K;}mbeng.exec(figure(2); clf;);for (int k  0; k string colors  rndcolor();mbeng.plot_mask(data.col(0), data.col(1), (clid  k), o, MarkerFaceColor, colors, MarkerEdgeColor, colors, MarkerSize, 5);mbeng.exec(hold on;);}mbeng.exec(hold off;);mbeng.exec(axis tight;);// plot lineEigen::ArrayXf X;Eigen::ArrayXf Y;X  X.LinSpaced(30,-3.1415926f, 3.1415926f);Y  X.sin()*X.cos();mbeng.exec(figure(3););mbeng.plot(X, Y, LineStyle, -., Marker, o, MarkerSize, 5, MarkerFaceColor, [0,1,0]);mbeng.exec(axis tight;);return EXIT_SUCCESS;}#include#include#include#include#includeusing namespace std;#include#includeclass MatArray{public:MatArray() : _data(NULL){}MatArray(size_t irows, size_t icols){resize(irows, icols);}MatArray(const MatArray obj){if (obj._data){_data  mxCreateDoubleMatrix(obj.rows(), obj.cols(), mxREAL);memcpy(this-ptr(), obj.ptr(), sizeof(double)*rows()*cols());}else{_data  NULL;}}~MatArray(){ mxDestroyArray(_data); _data  NULL; }inline size_t rows() const { return _data ? mxGetM(_data) : 0; }inline size_t cols() const { return _data ? mxGetN(_data) : 0; }inline double* ptr() const { return _data ? mxGetPr(_data) : NULL; }bool resize(size_t irows, size_t icols){if (!_data){_data  mxCreateDoubleMatrix(irows, icols, mxREAL);return (_data ! NULL);}if (rows()  irows || cols()  icols){return true;}mxDestroyArray(_data);_data  mxCreateDoubleMatrix(irows, icols, mxREAL);return (_data ! NULL);}int put(Engine *ep, const char* var_name){return engPutVariable(ep, var_name, _data);}templatevoid copy_from_eigen(const EigenMat emat){if (emat.rows()*emat.cols()  0){mxDestroyArray(_data); _data  NULL;}resize(emat.rows(), emat.cols());for (int c  0; c for (int r  0; r (*this)[r  c*(int)(emat.rows())]  emat(r, c);}}}inline double operator[](int i){return ptr()[i];}private:mxArray *_data;};string rndcolor(){string color  [;color  to_string((rand() % 256) / 255.)  ,;color  to_string((rand() % 256) / 255.)  ,;color  to_string((rand() % 256) / 255.)  ];return color;}class Matlab{private:Matlab(const Matlab obj){}public:Matlab(){_engine  engOpen(NULL);if (!_engine){cerr }else{cout }}~Matlab(){// if you are testing algorithm, you are encouraged to keep the line below bing committed.//engClose(_engine); _engine  NULL;}templateint plot(const TMatX X, const TMatY Y, string line_spec  , int figure_id  1, bool hold_on  false){MatArray MX, MY, ID;MX.copy_from_eigen(X); MX.put(_engine, MX);MY.copy_from_eigen(Y); MY.put(_engine, MY);ID.resize(1, 1); ID[0]  figure_id; ID.put(_engine, ID);string plot_code   figure(ID); plot(MX, MY;if (line_spec ! ){plot_code  plot_code  ,  line_spec;}plot_code  );;plot_code  hold_on ? hold on; : hold off;;return engEvalString(_engine, plot_code.c_str());}templateint plot(const TMatX X, const TMatY Y, const TMatC C, int K, int figure_id  1, int marker_size  5, string line_and_marker  o){MatArray MX, MY, MC, ID;MX.copy_from_eigen(X); MX.put(_engine, MX);MY.copy_from_eigen(Y); MY.put(_engine, MY);MC.copy_from_eigen(C); MC.put(_engine, MC);ID.resize(1, 1); ID[0]  figure_id; ID.put(_engine, ID);exec(figure(ID); clf;);for (int k  0; k string rdc  rndcolor();exec(string(idx  MC)  to_string(k)  ;);exec(plot(MX(idx), MY(idx),   line_and_marker  , MarkerEdgeColor,   rdc  ,MarkerFaceColor,  rdc  , MarkerSize,  to_string(marker_size)  ); hold on;);}exec(hold off;);return 0;}templateint plot(const TMatX X, const TMatY Y, int figure_id  1, int marker_size  5, string line_and_marker  -){MatArray MX, MY, ID;MX.copy_from_eigen(X); MX.put(_engine, MX);MY.copy_from_eigen(Y); MY.put(_engine, MY);ID.resize(1, 1); ID[0]  figure_id; ID.put(_engine, ID);string rdc  rndcolor();exec(figure(ID); clf;);exec(plot(MX, MY,   line_and_marker  , MarkerEdgeColor,   rdc  ,MarkerFaceColor,  rdc  , MarkerSize,  to_string(marker_size)  ); hold on;);exec(hold off;);return 0;}int exec(string cmd){return engEvalString(_engine, cmd.c_str());}private:Engine *_engine;};#if 1int main(int argc, char** argv){Matlab mbeng;// random circlesEigen::ArrayXXf data;data  data.Random(1000, 2);mbeng.plot(data.col(0), data.col(1), 1, 5, o);mbeng.exec(axis tight;);// different colorsint K  4;Eigen::ArrayXXi clid;clid  Eigen::abs(clid.Random(1000, 1));for (int i  0; i clid(i,0)  clid(i,0) % K;}mbeng.plot(data.col(0), data.col(1), clid, K, 2);mbeng.exec(axis tight;);// plot lineEigen::ArrayXXf X(1000,1);Eigen::ArrayXXf Y(1000,1);float fpi  3.1415926f;float sstep  fpi*2 / 1000.f;for (int i  0; i X(i, 0)  -3.1415926f  i*sstep;Y(i, 0)  sin(X(i,0))*cos(X(i,0));}mbeng.plot(X, Y, 3, 5,  - );mbeng.exec(axis tight;);return EXIT_SUCCESS;}#endif跑一下#include#include#include#include#include#includeusing namespace std;#include#includeclass MatArray{public:MatArray() : _data(NULL){}MatArray(size_t irows, size_t icols){resize(irows, icols);}MatArray(const MatArray obj){if (obj._data){_data  mxCreateDoubleMatrix(obj.rows(), obj.cols(), mxREAL);memcpy(this-ptr(), obj.ptr(), sizeof(double)*rows()*cols());}else{_data  NULL;}}~MatArray(){ mxDestroyArray(_data); _data  NULL; }inline size_t rows() const { return _data? mxGetM(_data):0; }inline size_t cols() const { return _data? mxGetN(_data):0; }inline double* ptr() const { return _data? mxGetPr(_data):NULL; }bool resize(size_t irows, size_t icols){if (!_data){_data  mxCreateDoubleMatrix(irows, icols, mxREAL);return (_data ! NULL);}if (rows()  irows || cols()  icols){return true;}mxDestroyArray(_data);_data  mxCreateDoubleMatrix(irows, icols, mxREAL);return (_data ! NULL);}int put(Engine *ep, const char* var_name){return engPutVariable(ep, var_name, _data);}templatevoid copy_from_eigen(const EigenMat emat){if (emat.rows()*emat.cols()  0){mxDestroyArray(_data); _data  NULL;}resize(emat.rows(), emat.cols());for (int c  0; c for (int r  0; r (*this)[r  c*emat.rows()]  emat(r, c);}}}inline double operator[](int i){return ptr()[i];}private:mxArray *_data;};class Matlab{private:Matlab(const Matlab obj){}public:Matlab(){_engine  engOpen(NULL);if (!_engine){cerr }else{cout }}~Matlab(){// if you are testing algorithm, you are encouraged to keep the line below bing committed.//engClose(_engine); _engine  NULL;}templateint plot(const TMatX X, const TMatY Y, string line_spec  , int figure_id  1, bool hold_on  false){MatArray MX, MY, ID;MX.copy_from_eigen(X); MX.put(_engine, MX);MY.copy_from_eigen(Y); MY.put(_engine, MY);ID.resize(1, 1); ID[0]  figure_id; ID.put(_engine, ID);string plot_code   figure(ID); plot(MX, MY;if (line_spec ! ){plot_code  plot_code  ,  line_spec;}plot_code  );;plot_code  hold_on ? hold on; : hold off;;return engEvalString(_engine, plot_code.c_str());}int exec(string cmd){return engEvalString(_engine, cmd.c_str());}private:Engine *_engine;};string rndcolor(){string color  [;color  to_string((rand() % 256) / 255.)  ,;color  to_string((rand() % 256) / 255.)  ,;color  to_string((rand() % 256) / 255.)  ];return color;}int main(int argc, char** argv){Eigen::MatrixXf data;srand((unsigned int)time(0));data  data.Random(1000, 2);Matlab mateng;//mateng.exec(clear all; close all;);mateng.plot(data.col(0), data.col(1), string(s,)  MarkerEdgeColor,  rndcolor()  ,MarkerFaceColor,  rndcolor()  , MarkerSize, 5, 1, true);return EXIT_SUCCESS;}执行一下看看结果
http://www.zqtcl.cn/news/327532/

相关文章:

  • seo网站优化推广怎么做龙岗中心医院
  • 建网站程序智能网站建设平台
  • 建筑公司分几级资质seo入门培训
  • wap类网站上海网站建设免费推
  • 网站建设哪家好公司建设银行网站怎么登陆不
  • 关于建设网站的需求wordpress不能发布文章
  • 如何一键建淘宝客网站中国建设银行金华分行网站
  • 给wordpress添加公告英语seo
  • 佛山市网站建设系统wap浏览器网页版
  • 关于小说网站的一些建设流程学做蛋糕有哪些网站
  • 益阳购物网站开发设计禹城网站制作
  • 教育网站开发文档全网营销推广案例
  • 最流行的网站开发框架wordpress阅读权限
  • 怎么做推广网站创立网站
  • 制作自己的网站需要什么材料网站计费系统怎么做
  • 网站和域名的区别昆山网站开发建设公司
  • 兼职网站推广如何做西安市商标局
  • 打开网站说建设中是什么问题莱芜金点子招小时工
  • 做网站的相关协议秦皇岛解封最新消息今天
  • 网站托管维护方案新闻媒体发稿平台
  • 网站扩展名四平网站建设怎么选
  • 网站制作价格与售后视频网站建设有什么意义
  • 网站建设+太原1核1g可以做几个网站
  • 电商设计网站有哪些内容西安百度推广外包
  • 深圳网站建设价格多少做废旧金属的网站
  • wordpress 文档超级优化空间
  • 湖北seo网站推广官方网站怎么制作
  • 随州网站seo诊断wordpress 只显示一个主题
  • 建站登录可信网站认证 费用
  • 互站网站源码用jsp做网站一般会用到什么