mex

CF1292C Xenon's Attack on the Gangs

匆匆过客 提交于 2020-04-12 17:58:49
题目链接: https://codeforces.com/problemset/problem/1292/C 题意 在一颗有n个节点的树上,给每个边赋值,所有的值都在 \([0,n-2]\) 内并且不重复,也就是一条边一个权值,令 \(mex(u,v)\) 表示从 \(u到v\) 这条简单路径上没有出现过的最小自然数,要求使所有路径的 \(mex\) 之和最大。 分析 最开始我一看这个题,统计答案的时候好像就需要 \(O(N^2)\) ,那这个题好像统计个答案就可能会T?当我看见时限是 \(3s\) 的时候我就知道我想多了,分析时间复杂度的时候提前看一下时限,防止因看错时限分析错时间复杂度。 首先这个边的权值肯定有规律,不然枚举权值时间复杂度会很高,最开始我想的是从每个边开始 \(dfs\) 一下把经过次数最多的边设成0,然后依次类推,每次 \(dfs\) 不访问重复经过的点,发现存在一个什么问题呢,就是从不同的点开始 \(dfs\) 造成的结果不一样,所以这样不可行,不妨先画一条链来看看。 如果已经放好了 \(0~x-1\) ,考虑 \(x\) 放哪个位置,如果我把 \(x\) 放到 \(5-v\) 上,那么 \(mex(u,5)\) 就会是 \(x\) ,然后只有 \(mex(u,v)\) 会等于 \(x+1\) ,但要是把 \(x\) 放到 \(u-1\) 或 \(4-5\)

Build a mex file under Visual Studio ultimate 2012

穿精又带淫゛_ 提交于 2020-02-02 11:42:52
问题 I had some code (c++) and I would like to generate the mex files. is there any tutorial which tech how to setup visual studio ultimate 2012 how to build mex files? thanks a lot 回答1: I can confirm that the same steps as described in this question work for Visual Studio 2012 (and for Visual Studio 2013 too). Starting with an empty project the following settings in the project's Property Pages are necessary and sufficient to build a working .mexw64 file: Configuration properties -> General: Set

Build a mex file under Visual Studio ultimate 2012

落爺英雄遲暮 提交于 2020-02-02 11:41:50
问题 I had some code (c++) and I would like to generate the mex files. is there any tutorial which tech how to setup visual studio ultimate 2012 how to build mex files? thanks a lot 回答1: I can confirm that the same steps as described in this question work for Visual Studio 2012 (and for Visual Studio 2013 too). Starting with an empty project the following settings in the project's Property Pages are necessary and sufficient to build a working .mexw64 file: Configuration properties -> General: Set

Return values from a C++ MEX file to MATLAB

大城市里の小女人 提交于 2020-01-30 03:44:30
问题 I am coding a MATLAB program that retrieves data from C++ code. To do so, I have created a MEX-file in MATLAB and a gateway mexFunction. Although the read value can be read in MATLAB, I cannot retrieve it to work with it. If this is unclear, I have quite the same problem as here (How to return a float value from a mex function, and how to retrieve it from m-file?) but I want to retrieve a value displayed by my C++ program. Here is my C++ code: #define _AFXDLL #define _tprintf mexPrintf

run time error when using a mex file, maybe due to memory allocation

混江龙づ霸主 提交于 2020-01-25 21:24:12
问题 I've written a mex function named mx_minimum_power that I'm calling it in MATLAB as follows: [Fs,Fd,pow_remained] = mx_minimum_power(A11,A12_real,A12_imag,A13_real,A13_imag,A22,A23_real,A23_imag,A33,MatSize); A11, A12_real, A13_real, A22, A23_real, A33 are 30555x1 single matrices A12_imag, A13_imag, A23_imag are 1x1 single variables MatSize is a 1x1 double variable with the value 30555 , that is the size of matrices In an iteration, each time the hermitian matrix A is constructed and

Mex type for Microsoft Visual C++ 2008 and R2007b

守給你的承諾、 提交于 2020-01-24 12:20:07
问题 i want to use mex type for vs2008 and matlab2007b.i tried code below. #include<iostream> #include <matrix.h> #include<mex.h> using namespace std; void hello(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mexPrintf("Hello World!\n"); } and get this error 'matrix.h': No such file or directory and i wrote below in matlab commond win mex -setup Please choose your compiler for building external interface (MEX) files: Would you like mex to locate installed compilers [y]/n? y Select a

Why is str2double so slow in matlab as compared to a mex-function?

与世无争的帅哥 提交于 2020-01-21 08:57:06
问题 my question is the title. Why is str2double so slow in matlab as compared to a mex function made in C/C++? Does matlab just not have good string handling capabilities? Can anyone give me some factual reasons as to why a mex function runs so many orders of magnitude faster? I was hoping to do a running time analysis of this difference but I don't have any concrete reasons from the code for matlab. Can you explain to me how I would open to file and actually look at the code written for the

how to read an integer array in MEX-function

此生再无相见时 提交于 2020-01-20 05:45:08
问题 I am passing an integer array of uint8 type from MATLAB to a MEX-function. How do I read these values? I tried using: int *n; n = (int * ) mxGetData(prhs[0]); but the values come out as junk. I also tried double *n; n= mxGetPr(prhs[0]); and in this case junk values also appear. What is the solution to this? Basically I want to read the integer value in the MEX-function but mxGetPr returns double type. 回答1: Take a look at the demo MEX-function explore.c, which you can open in MATLAB using edit

mcc -mv in linux machine R2013a

守給你的承諾、 提交于 2020-01-17 08:34:31
问题 When I am trying to make executable files of my .m -files on a Linux machine, some of the the .m -files are working absolutely fine. However, one file which has camera input inside the .m -file is giving me this error: Depfun error: 'Unexpected Standard exception from MEX file. What() is: ..' Error using mcc Error executing mcc, return status = 1 (0x1). But when I use the same .m -file on Windows and R2012a it is working properly without any error. I found a bug report here - is this a

Using glmnet with MATLAB R2016a

倖福魔咒の 提交于 2020-01-17 04:36:20
问题 i'm trying to use glmnet vignette in MATLAB R2016a on windows 10 (64bit). I downloaded the version from here. Every time that I try to use a function (like cvglmnet ) MATLAB crashes. The glmnet version for MATLAB was tested only on MATLAB 2013b (64-bit), but I wanted to know if someone was able to use it on other versions of MATLAB and how to do that. I think the problem is the mex file that maybe should be recompiled since the error on the MATLAB crash says This error was detected while a