[18637] in s-news-athena
Re: [S] query about matrices
daemon@ATHENA.MIT.EDU (ROS Mathieu)
Thu Jul 15 10:24:49 1999
Date: Thu, 15 Jul 1999 16:11:50 +0200 (MET)
From: ROS Mathieu <mim78@cict.fr>
To: SOFIA Stephano <cs0sso@cis.sunderland.ac.uk>
Cc: S-News <s-news@wubios.wustl.edu>
In-Reply-To: <1999Jul14.162129.1814.2829652@missgate.sunderland.ac.uk>
Message-Id: <Pine.SGI.3.95.990715160159.16525B-100000@ondine.cict.fr>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
On Wed, 14 Jul 1999, SOFIA Stephano wrote:
>
> Dear S_PLUS users,
> let me ask you the following question:
> given two square matrices A and B ( whose dimension could differ from each
> other ), is it possible to create automatically a matrix, let us call it C (
> of dimension dimension(A) + dimension(B) ), of the form:
>
> A 0
> 0 B
>
> i.e. where A and B are the diagonal blocks of C and 0 elsewhere else ?
>
> grateful for the eventual help
> Stefano
>
hello stephano,
you can use the following function :
"diagmat"<-
function(A,B)
{
A_as.matrix(A);B_as.matrix(B);
Ap_cbind(A,matrix(0,nrow(A),ncol(B)))
Bp_cbind(matrix(0,nrow(B),ncol(A)),B)
return(rbind(Ap,Bp))
}
-------------------------------------------------------
Mathieu Ros
mathieuros@bigfoot.com
Universite Paul Sabatier, Toulouse.
-------------------------------------------------------
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news