Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 90E5F8918 for ; Mon, 22 Aug 2011 20:39:28 +0000 (UTC) Received: (qmail 15438 invoked by uid 500); 22 Aug 2011 20:39:27 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 15240 invoked by uid 500); 22 Aug 2011 20:39:27 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 15226 invoked by uid 99); 22 Aug 2011 20:39:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Aug 2011 20:39:26 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ted.dunning@gmail.com designates 209.85.216.178 as permitted sender) Received: from [209.85.216.178] (HELO mail-qy0-f178.google.com) (209.85.216.178) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Aug 2011 20:39:19 +0000 Received: by qyk30 with SMTP id 30so2763388qyk.9 for ; Mon, 22 Aug 2011 13:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ugZwF8GvDOw5WLgQCYG+Jc8bt8ar2je3fSk3MtZhF+o=; b=Sd2l2Ns7wZHwUgqIQLNFCMOqf3NFmhwdpZO1jY4CYdtmMBrQnru5OrvQGGKZ2auA1z l9hx2pzctzxK854aCtXbYpKzgegsMkDExJrISiq7si8Zk27t1IofZbd0pCwbvGwIoznI oOBUIa77Hra8X6fYyzXbtBb0n3gRMysbPBfVg= Received: by 10.224.76.144 with SMTP id c16mr1677823qak.273.1314045538172; Mon, 22 Aug 2011 13:38:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.89.7 with HTTP; Mon, 22 Aug 2011 13:38:38 -0700 (PDT) In-Reply-To: <4E52BBA9.1000405@gmail.com> References: <4E52BBA9.1000405@gmail.com> From: Ted Dunning Date: Mon, 22 Aug 2011 13:38:38 -0700 Message-ID: Subject: Re: [math] RealMatrix.set(double) To: Commons Developers List Content-Type: multipart/alternative; boundary=20cf3074b76a857ebb04ab1e11ca X-Virus-Checked: Checked by ClamAV on apache.org --20cf3074b76a857ebb04ab1e11ca Content-Type: text/plain; charset=UTF-8 On Mon, Aug 22, 2011 at 1:27 PM, Phil Steitz wrote: > I think it would be good to add this, but it would probably be > better to give it a different name. What name, I am not sure. > Maybe setAll or fill. Might also be useful to have versions that > fill submatrics. > Mahout allows this via overloading of an assign method. Matrix.assign(double) over-writes all cells with a constant value. Matrix.assign(Matrix) copies data into the target. x.assign(Matrix y, BinaryFunction f) does element-wise x_ij = f(x_ij, y_ij) > Here is a little joke to lighten things up a bit. What if we just > allow people to specify negative indices to mean "everything." So > for example, setEntry(-1, -1, 0) sets all entries to 0, setEntry(1, > -1, 0) sets the first row to 0. Just kidding ;) > Can be useful. I find the TCL convention more useful where -1 refers to the last element of a vector. This sort of thing does tend to freak out the more mathematically inclined and it does make it harder to catch errors in mathematical code since it mutes indexing errors. --20cf3074b76a857ebb04ab1e11ca--