Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5334
| From | Yasha Gindikin <gindikin@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: A fast way to compare two vectors |
| Date | 2011-10-03 08:22 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j6brc0$8it$1@smc.vnet.net> (permalink) |
| References | <j5m44t$ple$1@smc.vnet.net> <j5mt8t$sn8$1@smc.vnet.net> |
First of all, let me thank both of my interlocutors for being extremely helpful (and also amicable).
>I don't know what range of values of n and M the OP is working with
I would say, n<20 and M<3n.
As a typical example, let's consider the following:
a = Subsets[Range[12], {6}];
Q = Dimensions[a][[1]]
AbsoluteTiming[Do[quick_compare_function[a[[p1]], a[[p2]]], {p1, Q}, {p2, Q}]].
The system is Mathematica 8.0.1 running on desktop Linux x86_64, the compile option is "CompilationTarget" -> "C" (gcc 4.5 used).
For such a setup, I get
compare gives 25.16 sec
poscom gives 25.43 sec
poskom gives 49.55 sec
vcomb gives 4.59 sec
vkom gives 66.06 sec.
The winner is vcomb, which turns out to be a real treasure. It's perfectly OK that it returns all the differences. The number of diffs was checked in the procedure to be <=4 only in the hope to speed-up the calculations (avoiding unnecessary comparisons); however, without these checks, the function is even faster.
>In any case, the parallelization speedup in vcomc is impressive and will be hard to beat.
Actually, I'm planning to utilize CUDA for the parallelization. Hope the structure of the vcomb function allows for a transition to a GPU.
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A fast way to compare two vectors Yasha Gindikin <gindikin@gmail.com> - 2011-09-25 02:37 +0000
Re: A fast way to compare two vectors "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-25 09:44 +0000
Re: A fast way to compare two vectors "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-26 08:16 +0000
Re: A fast way to compare two vectors Yasha Gindikin <gindikin@gmail.com> - 2011-09-26 08:19 +0000
Re: A fast way to compare two vectors "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-27 00:08 +0000
Re: A fast way to compare two vectors Yasha Gindikin <gindikin@gmail.com> - 2011-09-28 06:47 +0000
Re: A fast way to compare two vectors "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-29 06:14 +0000
Re: A fast way to compare two vectors Ray Koopman <koopman@sfu.ca> - 2011-09-25 09:46 +0000
Re: A fast way to compare two vectors Ray Koopman <koopman@sfu.ca> - 2011-09-26 08:16 +0000
Re: A fast way to compare two vectors Yasha Gindikin <gindikin@gmail.com> - 2011-09-26 08:13 +0000
Re: A fast way to compare two vectors Ray Koopman <koopman@sfu.ca> - 2011-09-27 22:52 +0000
Re: A fast way to compare two vectors Ray Koopman <koopman@sfu.ca> - 2011-09-27 10:23 +0000
Re: A fast way to compare two vectors Ray Koopman <koopman@sfu.ca> - 2011-09-29 06:13 +0000
Re: A fast way to compare two vectors "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-30 08:06 +0000
Re: A fast way to compare two vectors Ray Koopman <koopman@sfu.ca> - 2011-10-01 07:13 +0000
Re: A fast way to compare two vectors Yasha Gindikin <gindikin@gmail.com> - 2011-10-03 08:22 +0000
Re: A fast way to compare two vectors Ray Koopman <koopman@sfu.ca> - 2011-10-07 09:09 +0000
csiph-web