From hb at stat.berkeley.edu  Thu Jul 17 17:15:27 2008
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Thu, 17 Jul 2008 08:15:27 -0700
Subject: [Rd] rowSums()/colSums() don't preserve the 'integer' storage
	mode
In-Reply-To: <B998A44C8986644EA8029CFE6396A92401528AD5@exqld2-bne.nexus.csiro.au>
References: <487EDD10.8020907@fhcrc.org>
	<B998A44C8986644EA8029CFE6396A92401528AD5@exqld2-bne.nexus.csiro.au>
Message-ID: <59d7961d0807170815y6c7c0e36g198e96fbc154b621@mail.gmail.com>

I had a look at the source code and the coercion to double is only
done one the sum of each row/column, so the "overhead" (e.g. memory)
is only on the summed result.  The integer matrix is *not*coerced to
double before summing, which could be case if done before calling the
native code.  The latter would be consume lots of memory.

My $.02

Henrik

On Wed, Jul 16, 2008 at 11:57 PM,  <Bill.Venables at csiro.au> wrote:
> I don't see the cost of doing so paying off.
>
> storage.mode is really only important if you are passing arguments to
> compiled code.
>
> If you are passing to compiled code, you really need to ensure the
> storage mode is what you think it is, anyway.
>
> Bill Venables.
>
>
>
> -----Original Message-----
> From: r-devel-bounces at r-project.org
> [mailto:r-devel-bounces at r-project.org] On Behalf Of Herve Pages
> Sent: Thursday, 17 July 2008 3:48 PM
> To: R-devel at r-project.org
> Subject: [Rd] rowSums()/colSums() don't preserve the 'integer' storage
> mode
>
> Hi,
>
> Wouldn't that make sense to have rowSums()/colSums() to preserve the
> storage mode?
>
> m <- matrix(1:15, nrow=5)
>
>  > storage.mode(m)
> [1] "integer"
>
>  > storage.mode(sum(m))
> [1] "integer"
>
>  > storage.mode(rowSums(m))
> [1] "double" <------------------- surprising!
>
> Cheers,
> H.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] rowSums()/colSums() don't preserve the 'integer' storage mode
Henrik Bengtsson