.NET Matrix Library
NormalizeRows Method
See Also  Example Send Feedback



mode
A NormalizeMode enumeration value indicating how the matrix rows will be normalized.

Normalizes the rows of the current matrix according to the specified mode.

Syntax

Visual Basic (Declaration) 
Public Sub NormalizeRows( _
   ByVal mode As NormalizeMode _
) 
Visual Basic (Usage)Copy Code
Dim instance As Matrix
Dim mode As NormalizeMode
 
instance.NormalizeRows(mode)
C# 
public void NormalizeRows( 
   NormalizeMode mode
)
C++/CLI 
public:
void NormalizeRows( 
   NormalizeMode mode
) 

Parameters

mode
A NormalizeMode enumeration value indicating how the matrix rows will be normalized.

Example

The following example uses NormalizeCols and NormalizeRows methods to normalize matrix columns and rows in three different ways.
Visual BasicCopy Code
Imports System
Imports Bluebit.MatrixLibrary

Class Test

    Public Shared Sub Main()

        'Declaring a random 3x3 Matrix
        Dim A As Matrix
        A = New Matrix(3, 3)
        A.FillRandom()
        Console.WriteLine(A)

        'Normalize matrix columns in 3 different ways

        A.NormalizeCols(NormalizeMode.MaximumOne)
        Console.WriteLine("Maximum One (columns)")
        Console.WriteLine(A)

        A.NormalizeCols(NormalizeMode.UnitLength)
        Console.WriteLine("Unit Length (columns)")
        Console.WriteLine(A)

        A.NormalizeCols(NormalizeMode.ZScores)
        Console.WriteLine("ZScores (columns)")
        Console.WriteLine(A)

        'Normalize matrix rows in 3 different ways

        A.NormalizeRows(NormalizeMode.MaximumOne)
        Console.WriteLine("Maximum One (rows)")
        Console.WriteLine(A)

        A.NormalizeRows(NormalizeMode.UnitLength)
        Console.WriteLine("Unit Length (rows)")
        Console.WriteLine(A)

        A.NormalizeRows(NormalizeMode.ZScores)
        Console.WriteLine("ZScores (rows)")
        Console.WriteLine(A)

        Console.Read()

    End Sub

End Class
 Copy Code
using System;
using Bluebit.MatrixLibrary;

class Test
{
    static void Main(string[] args)
    {
        //Declaring a random 3x3 Matrix        
        Matrix A;
        A = new Matrix(3, 3);
        A.FillRandom();
        Console.WriteLine(A);

        //Normalize matrix columns in 3 different ways

        A.NormalizeCols(NormalizeMode.MaximumOne);
        Console.WriteLine("Maximum One (columns)");
        Console.WriteLine(A);

        A.NormalizeCols(NormalizeMode.UnitLength);
        Console.WriteLine("Unit Length (columns)");
        Console.WriteLine(A);

        A.NormalizeCols(NormalizeMode.ZScores);
        Console.WriteLine("ZScores (columns)");
        Console.WriteLine(A);

        //Normalize matrix rows in 3 different ways

        A.NormalizeRows(NormalizeMode.MaximumOne);
        Console.WriteLine("Maximum One (rows)");
        Console.WriteLine(A);

        A.NormalizeRows(NormalizeMode.UnitLength);
        Console.WriteLine("Unit Length (rows)");
        Console.WriteLine(A);

        A.NormalizeRows(NormalizeMode.ZScores);
        Console.WriteLine("ZScores (rows)");
        Console.WriteLine(A);

        Console.Read();
    }
}
C++Copy Code
#include "stdafx.h"

using namespace System;
using namespace Bluebit::MatrixLibrary;

int main(array<System::String ^> ^args)
{
    //Declaring a random 3x3 Matrix    
    Matrix^ A;
    A = gcnew Matrix(3, 3);
    A->FillRandom();
    Console::WriteLine(A);

    //Normalize matrix columns in 3 different ways

    A->NormalizeCols(NormalizeMode::MaximumOne);
    Console::WriteLine("Maximum One (columns)");
    Console::WriteLine(A);

    A->NormalizeCols(NormalizeMode::UnitLength);
    Console::WriteLine("Unit Length (columns)");
    Console::WriteLine(A);

    A->NormalizeCols(NormalizeMode::ZScores);
    Console::WriteLine("ZScores (columns)");
    Console::WriteLine(A);

    //Normalize matrix rows in 3 different ways

    A->NormalizeRows(NormalizeMode::MaximumOne);
    Console::WriteLine("Maximum One (rows)");
    Console::WriteLine(A);

    A->NormalizeRows(NormalizeMode::UnitLength);
    Console::WriteLine("Unit Length (rows)");
    Console::WriteLine(A);

    A->NormalizeRows(NormalizeMode::ZScores);
    Console::WriteLine("ZScores (rows)");
    Console::WriteLine(A);

    Console::Read();
    
	return 0;
}

Remarks

The following table lists the values of NormalizeMode enumeration and their effect on row normalization.

Member Description
MaximumOne Normalizes columns or rows so that their biggest element is 1.
UnitLength Normalizes columns or rows so that they become unit length vectors (their sum of squares is 1).
ZScores Normalizes columns or rows to zscores (values having zero mean and unit standard deviation).

Requirements

Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7

See Also

.NET Matrix Library