Re: [eigen] initializing a matrix so that all columns are copies of one column |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] initializing a matrix so that all columns are copies of one column*From*: Douglas Bates <bates@xxxxxxxxxxxxx>*Date*: Sat, 10 Dec 2011 09:38:41 -0600*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=9BUsnSLL9o/On/8OSDe3FpHH9LVMeV57B9oEn7xYakc=; b=p7ZsRBXR0VjtyuOYXYDiEP1zLreyz98//GFU6uJEHCor7qQq5L0GIuR8CFJmhNggb4 1ZaG8a9AZW7VESYQKJ47GLjamqeULw+3gPxoUZcLKN4MgPZCVQ7j9RdsEt/JomtKkEZ0 tDTrUx/B1fCOACBq3x/j4bOO8tSc7YLkIc7TQ=

On Fri, Dec 9, 2011 at 4:15 PM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote: > here you go: > > VectorXd maxdev(pts.colwise() - c).array().abs().rowwise().maxCoeff(); > > You can also use replicate(...) to form an expression of cmat (see the > documentation of replicate). Thank you. > On Fri, Dec 9, 2011 at 10:41 PM, Douglas Bates <bates@xxxxxxxxxxxxx> wrote: >> In an optimization algorithm I have an n by n+1 matrix whose columns >> correspond to parameter vectors. At one point I want to subtract a >> given n vector from each column, convert to absolute values, and find >> the maximum coefficient in each row. The matrix is called pts and the >> position I want to subtract is a centroid called c. If I can think of >> a way of creating another n by n+1 matrix whose columns are copies of >> c, let's call it cmat, then I can write >> >> VectorXd maxdev( (pts - cmat).array().abs().rowwise().maxCoeff() ); >> >> but the best I have been able to come up with for constructing cmat is >> >> MatrixXd cmat(n, n+1); >> for (int i = 0; i <= n; ++i) cmat.col(i) = c; >> >> Is there a more elegant way of doing this? >> >> > >

**References**:**[eigen] initializing a matrix so that all columns are copies of one column***From:*Douglas Bates

**Re: [eigen] initializing a matrix so that all columns are copies of one column***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] initializing a matrix so that all columns are copies of one column** - Next by Date:
**Re: [eigen] Status of AVX support** - Previous by thread:
**Re: [eigen] initializing a matrix so that all columns are copies of one column** - Next by thread:
**[eigen] buildtests fail with gcc, icc, suncc and mingw (3.0.4/Debian/amd64)**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |