Path: news.mathworks.com!not-for-mail From: "Skirt Zhang" <silence_qunzi@hotmail.com> Newsgroups: comp.soft-sys.matlab Subject: Re: How to reduce the combinations' dimension--speed up my cross product Date: Mon, 11 Jul 2011 15:17:10 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 64 Message-ID: <ivf45m$5qf$1@newscl01ah.mathworks.com> References: <ivevlp$kdi$1@newscl01ah.mathworks.com> <ivf2lq$sq$1@newscl01ah.mathworks.com> Reply-To: "Skirt Zhang" <silence_qunzi@hotmail.com> NNTP-Posting-Host: www-00-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1310397430 5967 172.30.248.45 (11 Jul 2011 15:17:10 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Mon, 11 Jul 2011 15:17:10 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 2029090 Xref: news.mathworks.com comp.soft-sys.matlab:735833 Hi Steven Thanks a lot for your quick and kindly reply. You are correct, it will take toooooo much time to compute, that's why I am think to extract the combinations, or only compute a subset of combinations. The subset may include only 1000 combinations from 2000*1999*19987/3 products. eg m = 6 7 8 1 2 3 4 5 if I select 3 elements there will be 56 combinations. However, I only want to obtain the 10/56 combinations, where the 10 products should be the most representative ones. How should I do this? "Steven_Lord" <slord@mathworks.com> wrote in message <ivf2lq$sq$1@newscl01ah.mathworks.com>... > > > "Skirt Zhang" <silence_qunzi@hotmail.com> wrote in message > news:ivevlp$kdi$1@newscl01ah.mathworks.com... > > > > > > > > I need to calculate the product of 3 elements which are randomly selected > > from a vector with size 2000*1, so that I will have 2000*1999*19987/3 > > different combinations. This process time takes me tremendous > > time........ > > If you were to compute one of these combinations each second, you'd be done > after only: > > >> numCombinations = nchoosek(2000, 3); > >> minutes = (numCombinations/60); > >> hours = minutes/60; > >> days = hours/24; > >> years = days/365 > years = > 42.2163242009132 > > a tad over 42 years. [You'd be able to compute more than one combination per > second, but you're still talking about spending MONTHS or perhaps YEARS > computing.] Storing all the combinations as a big double array would > require: > > >> bytes = 8*(numCombinations*3); > >> kb = bytes/1024; > >> mb = kb/1024; > >> gb = mb/1024 > > gb = > > 29.757633805275 > > close to 30 GB of contiguous memory. > > Rethink your approach. Why are you trying to do this -- what's your goal? > Perhaps (likely) there's a way to do what you want without creating a huge > array and taking a very long time to perform the computations. > > -- > Steve Lord > slord@mathworks.com > To contact Technical Support use the Contact Us link on > http://www.mathworks.com