% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/normalize_config.R
\name{normalize_config}
\alias{normalize_config}
\title{Normalize Configuration Matrix}
\usage{
normalize_config(F, center = 1, rotate = 0, A = NULL)
}
\arguments{
\item{F}{n x ndim matrix to be normalized}

\item{A}{nvar x ndim additional matrix to be normalized}

\item{center=0}{not to column center F}

\item{rotate=1}{to rotate F so that F'F = diagonal.}
}
\value{
Normalized \code{F} or a list consisting of \code{F} and \code{A}.
}
\description{
This function normalizes the input matrix.
}
\details{
When \code{center==1}, \code{F} will be column centered. \cr
If \code{rotate==1}, \code{F} will be rotated
 so that \code{t(F)\%*\%F}=diagonal.\cr
When \code{A} is present, and \code{rotate==1} \cr
\preformatted{
 t(F)\%*\%F = nrow(F)*I  and  t(A)\%*\%A = diagonal
}

Note that, given \code{F} and \code{A}, 
the above normalization with center=0
does not change the value of \code{F \%*\%t(A)}.
}
\examples{

n=10; nvar=5; ndim=3
set.seed(1701)
F=matrix(rnorm(n*ndim),n,ndim)
A=matrix(runif(nvar*ndim),n,ndim)
FA=F\%*\%t(A)
meanF=colMeans(F)
Print(F,A,meanF)

F1=normalize_config( F )
temp=mandd(F1)
Print(round(t(F1)\%*\%F1,4), colMeans(F1))

F11=normalize_config( F, rotate=1 )
temp=mandd(F11)
Print(round(t(F11)\%*\%F11,4), colMeans(F11))

F2=normalize_config( F, center=0, rotate=1 )
Print(round(t(F2)\%*\%F2,4), colMeans(F2))

temp=normalize_config( F, center=1, rotate=1, A=A )
F3=temp$F; A3=temp$A
Print(round(t(F3)\%*\%F3,4), colMeans(F3))
Print(round(t(A3)\%*\%A3,4), max(abs(FA-F3\%*\%t(A3))))

temp=normalize_config( F, center=0, rotate=1, A=A )
F4=temp$F; A4=temp$A
Print(round(t(F4)\%*\%F4,4), colMeans(F4))
Print(round(t(A4)\%*\%A4,4), max(abs(FA-F4\%*\%t(A4))))


}
