R/autoVetor.R

Defines functions autoVetor

Documented in autoVetor

#'@title Calculates the eigen vector of matrix
#'@name autoVetor
#'@author Lyncoln Oliveira
#'@description Calculates the eigen vector of matrix
#'@param matriz a paired matrix
#'
#'@return Returns a normalized eigenvector
#'
#'@examples

#'m=diag(16)+2-2*diag(16)
#'m
#'autoVetor(m)
#'
#'@export
#'
autoVetor = function(matriz){
  #Achando o autovetor associado ao maior autovalor
  autoValores = Re(eigen(matriz)$values)
  autoVetores = Re(eigen(matriz)$vectors)
  autoValorMax = which.max(autoValores)
  autoVetorAssociado = autoVetores[,autoValorMax]
  autoVetorNormalizado = autoVetorAssociado/sum(autoVetorAssociado)

  return(autoVetorNormalizado)}

Try the AHPWR package in your browser

Any scripts or data that you put into this service are public.

AHPWR documentation built on Dec. 7, 2022, 1:10 a.m.