Search Comments and Ratings

go

   
Date File Comment by Comment Rating
09 Oct 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Michael

09 Oct 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Michael

05 Aug 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Jason

03 Jul 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Anders

06 May 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter wei

28 Apr 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Atae

21 Apr 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Petter

Jingyi: I recommend that you start using a 64-bit version.

21 Apr 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Petter

Avnish: I have no idea.

21 Apr 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Jingyi

only has x64 version >_<

05 Apr 2014 Inpainting (coherency sensitive hashing) Image inpainting using coherency sensitive hashing (CSH) Author: Petter Josephine

does this code work for text removal?

01 Apr 2014 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter dmitrii

Hello! Tried to run the script, but there was an error:
int64 plus...
int64 minus...
int64 times...
int64 matrix multiplication...
Internal error 1028 line 163
incorrect char m
leal ( movl -40(%ebp),wildcard??? Error using ==> mex at 218
Unable to complete successfully.

Error in ==> compile_int64 at 10
mex int64matmul.c

Has anyone encountered this? How to avoid?

31 Mar 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Avnish

Will it work on 2010a?

29 Mar 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter Douglas

Thanks for this - works on 2012a :)

23 Mar 2014 Matlab mex support for Visual Studio 2013 (and mbuild) Adds mex support for Microsoft’s latest compiler. Author: Petter TGI

Thanks for it really works on MATLAB 2013B.

30 Mar 2012 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter craq

Great functionality for those of us with pre-2011b versions. I had the same error as Vincent, and his solution worked for me too. Off the top of my head I couldn't figure out how to do the lshift and rshift, but I don't actually need them.

05 Aug 2011 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Jon

Seamless use. Well done Petter and thanks!

17 May 2011 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Petter

Vincent: Interesting. I thought the standard allowed the pasting of operators. Is this not true?

16 Dec 2010 Jacobi and Legendre symbol JACOBI computes the Jacobi symbol (m/n), a generalization of the Legendre symbol. Author: Petter Sean McClintock

There are a couple of bugs in this program...

In line 36, we want to test if n=+/-1 mod8, however, since matlab will return a value from 0 to 7 for mod(n,8),

if abs(mod(n,8))==1 is not adequate,

Perhaps

if mod(n,8)==1
j = jacobi(m/2,n);
elseif mod(n,8)==7
j = jacobi(m/2,n);
etc would be better.

Also, I don't think this program deals with negative m.

11 Nov 2010 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Vincent

Hi Petter,
Thanks for your great package.

It didn't compile out of the box, however.
I tried to compile this on a Debian Stable machine, having gcc-4.3.2 installed.
The compilation of the first mex function aborts with the following error:

int64operation.c:38:1: error: pasting "OPERATOR" and "=" does not give a valid preprocessing token

I had to apply the following modifications:
Current situation:
One macro in each operator source files (#define OPERATOR +) and the OPERATOR_EQ defined as OPERATOR ## = in the (u)int64operation.c source files.
New situation:
Use two separate macro functions.
For example, the contens of int64plus.c is now:
---
#define UNARY_OPERATOR(a,b) ((a) += (b))
#define BINARY_OPERATOR(a,b) ((a) + (b))
#include "int64operation.c"
---
Where the OPERATOR and OPERATOR_EQ were used in int64operation.c:
---
c[i] OPERATOR_EQ b[i];
becomes
UNARY_OPERATOR(c[i], b[i]);
---
c[i] = a[0] OPERATOR b[i];
becomes
c[i] = BINARY_OPERATOR(a[0], b[i]);
---

I don't know if this works for every compiler around there, but for me, this works like a charm...
If you're interested, I can send you my modified version to the address specified in the README.txt file, so that you can more easily update your package.

05 Nov 2010 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Jan Simon

Although INT64 values can be very large, you can still get an overflow. While Matlab uses saturated arithmetic for integer types, your tools do not. It is important to mention this in the documentation. Implementing a saturation (means: value is the max or min INT value if it exceeds the valid range) is not trivial, and omitting it is no reason to reduce the 5 star rating.

You mention precompiled in the ReadMe - where can I find them?
Following Loren's block about inplace operations, I suggest to replace e.g.:
function c = abs(a) c = a; end
by: function a = abs(a), end

09 Jun 2010 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Jan Simon

Thank you for the fast update!

04 Jun 2010 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Igor

Thanks a lot for this. Could you also add support for _colonobj so that one doesn't get a "Undefined function or method '_colonobj' for input arguments of type 'uint64'" when writing 1:n

25 May 2010 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Petter

1. The reason the check is made in an .m file is that otherwise the MEX files would have to be quite verbose with lots of conversions from various types to int64.
2. I'll implement this optimization
3. Same here
4. OK, I'll change that
5. OK, I guess I could follow Matlab here
6. long long works on GCC, MSVC++ and LCC and feels more standard
7. True, I'll change that

Thanks for the suggestions.

21 May 2010 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Jan Simon

A really needed and useful submission!
The efficiency can be improved significantly:
1. checkinputs: "if length(size(a)) ~= length(size(b)) ... if ~all(size(a) == size(b))" can be combined to: "if isequal(size(a), size(b))". Performing the check in the Mex and omitting the intermediate call of the M-functions would reduce the overhead.
2. (u)int64abs: At first the input is duplicated to plhs[0]. Then it is not necessary to copy positive values from the input to the output. A faster approach:
void mexFunction(...) {
signed long long *c, *cf;
plhs[0] = mxDuplicateArray(prhs[0]);
if (!plhs[0]) ...
c = (signed long long *) mxGetData(plhs[0]); // not mxGetPr
cf = c + mxGetNumberOfElements(plhs[0]);
for ( ; c < cf; c++) {
if (*c < 0L) {*c = -*c; }
}
}
3. Similar improvements for plus, minus, times, rdived: If the 1st input is duplicated already, the operation does not need to access the values from the inputs again. So these lines in (u)int64operations.c:
c[i] = a[i] OPERATOR b[i]
can be changed to the faster:
c[i] OPERATOR b[i]
using e.g. "+=" as operator instead of "+".
4. TMW suggests to use mxGetData instead of mxGetPr to get a pointer to non-DOUBLE arrays. But at least both method works currently.
5. Matlab's MOD can handle 0 as second input, and a user might expect this for the (U)INT64 version also.
6. "long long" is supported by the LCC compiler shipped with Matlab. For (all) other compilers, you can use uint64_T and int64_T as defined in "tmwtypes.h".
7. The check for division by zero can be included in the same loop as the operation to save time.

25 Sep 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Petter

Never mind, I misunderstood what you meant. Implementing a crude A*B is very easy, so I might do that.

24 Sep 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Petter

Array multiplication .* is already implemented.

23 Sep 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter John D'Errico

I can't test this myself, so I cannot rate it. But if it now prevents A*B when A and B are both matrices, neither of which is a scalar, then this is good if it would otherwise have done the wrong thing. Better of course is to implement array multiplication too (perhaps in a future version.) Regardless, there have been a few times recently when I wanted to have int64 operations defined, so this is a good addition to MATLAB.

18 Sep 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Petter

John, the reason the * operator is included at all is because it is desirable to support operations like
a = int64(2);
b = int64( [1 2; 3 4] );
c = a * b

That is the reason * was included. The next update will issue an error if both a and b are matrices. Thank you for your suggestions.

15 Sep 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Derek O'Connor

John -- Thanks for pointing out that Int64 matrix multiplication is element-wise. I should have been more careful, given that the description clearly states that "multiplication and division are element-wise only". This of course explains the O(n^2) behavior.

On a more general point, I wish there was a consistent standard for matrix multiplicaton. For example, in O-Matrix, C= A*B is the same as Matlab, but C=A^2 gives cij = (aij)^2. This is really confusing. In Fortran 90, C=A*B gives cij = aij*bij.

15 Sep 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter John D'Errico

Derek - it points out that even though the function mtimes is provided, this package only claims to support ELEMENTWISE operations.

The quadratic behavior tells me that this code did not do a true matrix multiply. Did you check that A64*B64 was correct in your test? Element wise multiplication will take O(N^2) flops, whereas a matrix multiply (as * is supposed to generate) is O(N^3).

I would have preferred that an error be generated if you use * on a pair of matrices, when that operation will not return the proper result. This would normally make me downrate this code. Since I cannot test it without compiling it, I won't give any rating at all.

15 Sep 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Derek O'Connor

This seems to be an excellent package. I used it to test matrix multiplication
and obtained very surprising results : multiplying two 10^4x10^4 int64 matrices took about 2 secs while two doubles took about 35 secs. The double mat-mult used the Math Kernel and all 8 cores while the int64 did not use the Math Kernel.

Also, a 2-degree polyfit of the int64 mat-mult times was very good, i.e., t(n) is O(n^2)!

Can anyone enlighten me? Here is the test function:

function times = TimesInt64(v,degree);
% Test matrix multiplication using int64arithmetic
% int64arithmetic compiled with Microsoft Visual C++ 2008
% Dell Precision 690, 2xQuadcore Xeon 5345, 2.3GHz, 16GB
% Windows Vista 64
% Example : >> times = TimesInt64(1:15,2);

% Derek O'Connor Sept 2009

nvals = v'*10^3;
times = zeros(length(nvals),1);
c = intmax('int64');
for k = 1:length(nvals)
n = nvals(k);
A64=int64(floor(c*rand(n,n)));
B64=int64(floor(c*rand(n,n)));

tic; A64*B64; times(k) = toc;
end;

p=polyfit(nvals,times,degree);
ptimes = polyval(p,nvals);
plot(nvals,times,'.',nvals,ptimes,'-')

% End Function TimesInt64(v,degree)

% n times (secs)
% 1000 0.0176
% 2000 0.06972
% 3000 0.15354
% 4000 0.34136
% 5000 0.50145
% 6000 0.63655
% 7000 0.9838
% 8000 1.2829
% 9000 1.5717
% 10000 2.0059
% 11000 2.4728
% 12000 3.0439
% 13000 3.4914
% 14000 4.2588
% 15000 4.9525

% p(x) = 0.098649 - 5.6075e-005*x + 2.5027e-008*x^2

15 Jul 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Bruno Luong

What a relief to have finally a basic int64 arithmetic operators supported.

14 Jul 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Petter

I used Microsoft Visual C++ Express 2008 to compile the library. "long long" _is_ supported in later versions of Visual C++. Also, "long long" is more supported by other compilers and will probably end up in the next C++ standard as well.

14 Jul 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Bruno Luong

It is also puzzling this can work

a=int64([0 1; 2 3])
b=int64([4 5 6 7]')
a+b

14 Jul 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Bruno Luong

After a quick look I have few comments that I wish the author could correct:

As stated, the C Mex can't be compiled by the popular MS VISUAL C (type LONG LONG must be replaced by __int64)

It is dangerous when no checking is performed after mxDuplicateArray that could returns NULL and results in a crash if there is not enough memory.

27 Mar 2009 0-1 Knapsack Solves the 0-1 knapsack problem with positive integer weights. Author: Petter Chetan Viraktamath

12 Feb 2009 0-1 Knapsack Solves the 0-1 knapsack problem with positive integer weights. Author: Petter John D'Errico

Fast, it seems to work. Help is good. Problems are repaired. I can't ask for more.

12 Feb 2009 0-1 Knapsack Solves the 0-1 knapsack problem with positive integer weights. Author: Petter Petter

Thanks for the suggestions. A new version has been uploaded.

I am sometimes annoyed by the fact that I have to download and unpacka .zip file before looking at code for an algorithm. Publishing knapsack.m itself provided a way for the user to view the code without downloading anything. But the error looke unprofessional and it has been removed.

10 Feb 2009 0-1 Knapsack Solves the 0-1 knapsack problem with positive integer weights. Author: Petter John D'Errico

Please let others rate your work. Rating your own stuff highly says nothing about the code, but perhaps drops you closer to the level of a spammer on the FEX like Marco. So let the rating system do its job. I know that you think your stuff is good. So does every eager high school student who posts their last homework assignment.

In the particular case of this utility. I'll first suggest that there is no reason to publish the code for knapsack itself. See there was an error generated when you tried it.

How about the help? It too is lacking. It is not terrible, but still lacking. Here is the relevant part of the help block.

% [AMOUNT] = KNAPSACK(WEIGHTS, VALUES, CONSTRAINT)
%
% WEIGHTS : The weight of every item
% VALUES : The value of every item
% CONSTRAINT : The weight constraint of the knapsack
%
% BEST : Value of best possible knapsack
% AMOUNT : The amount to use of each item (0 or 1)

See that there appear to be two return arguments, but your help does not tell us what order they are in. In fact, when only one output argument is returned, it looks to be the second of the two outputs. I won't suggest what your code actually does. That is your job.

There was a nicely written H1 line in the help. Well done in that respect. I also found error checks in the code.

Finally, the best code would include a simple example in the help itself. I know, you will claim there is one in the demo file. But when people actually download this, they will often look to the help rather than search for some other file.

Contact us