Path: news.mathworks.com!not-for-mail
From: "Tom Lane" <tlane@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Vectorization for Quadratic Polynomial Regression
Date: Tue, 1 Jul 2008 16:32:51 -0400
Organization: The MathWorks, Inc
Lines: 13
Message-ID: <g4e49j$cj1$1@fred.mathworks.com>
References: <cddc4bd3-1f78-4fad-90d2-a7cde7ec5189@e39g2000hsf.googlegroups.com> <8b006283-5c06-43fb-a736-e2615f37e3ac@z66g2000hsc.googlegroups.com>
Reply-To: "Tom Lane" <tlane@mathworks.com>
NNTP-Posting-Host: lanet.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1214944372 12897 172.31.57.151 (1 Jul 2008 20:32:52 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 1 Jul 2008 20:32:52 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Xref: news.mathworks.com comp.soft-sys.matlab:476977


>> Can the double loop be vectorized?

Greg, I offer this not as an example of good programming, but of something 
that works and that might give you some ideas:

terms = fullfact([3 3 3])-1;
terms(sum(terms,2)>2,:) = []
x=[  1 2 3; 4 5 6]
exp(log(x)*terms')

-- Tom