Looks like I answered my own question:

U=calc(my_brick,fun=function(x) { as.vector(t(a_matrix)%*%(x-means_vector))
} )

Is this the most efficient way to do this?

--j

On Mon, Apr 23, 2012 at 4:21 PM, Jonathan Greenberg <jgrn@illinois.edu>wrote:

> Robert and R-sig-geo'ers:
>
> I'm trying to perform a pixel by pixel matrix multiplication and
> subtraction in the following way:
>
> a_matrix=matrix(runif(9),ncol=3,nrow=3)
> means_vector=runif(6)
> my_brick=brick(ncols=400,nrows=400,nl=3)
> values(my_brick) <- runif(400*400*3)
>
> The "array" version of what I'm trying to do is as follows:
> my_brick_array=t(as.matrix(my_brick))
> U=t(a_matrix)%*%(my_brick_array - means_vector)
>
> How would I do this using (e.g.) a calc or overlay statement (e.g. make it
> memory safe)?
>
> --j
>
>
> --
> Jonathan A. Greenberg, PhD
> Assistant Professor
> Department of Geography and Geographic Information Science
> University of Illinois at Urbana-Champaign
> 607 South Mathews Avenue, MC 150
> Urbana, IL 61801
> Phone: 415-763-5476
> AIM: jgrn307, MSN: jgrn307@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
> http://www.geog.illinois.edu/people/JonathanGreenberg.html
>



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn307@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

	[[alternative HTML version deleted]]

