Reorders matrix columns according to the specified order.
Syntax
| Visual Basic (Declaration) | |
|---|
Public Sub ReorderCols( _
ByVal pivots() As Integer _
) |
| Visual Basic (Usage) | Copy Code |
|---|
Dim instance As Matrix
Dim pivots() As Integer
instance.ReorderCols(pivots) |
Parameters
- pivots
- An array of integers containing the column dispositions.
Example
The following example uses the
SortCols method to sort a matrix and then synchronizes a second matrix using the
ReorderCols method.
| Visual Basic | Copy Code |
|---|
Imports System
Imports Bluebit.MatrixLibrary
Class Test
Public Shared Sub Main()
'Declaring two random matrices
Dim A As Matrix = New Matrix(3, 3)
A.FillRandom()
Dim B As Matrix = New Matrix(5, 3)
B.FillRandom()
Console.WriteLine("Matrix A =")
Console.WriteLine(A)
Console.WriteLine("Matrix B =")
Console.WriteLine(B)
Dim pivots() As Integer
'sort the columns of matrix A in descending order
' by the elements of its second row (row #1)
A.SortCols(1, SortOrder.Descending, pivots)
'use the pivots to syncronize matrix B with A
B.ReorderCols(pivots)
Console.WriteLine("Matrix A sorted by 2nd row")
Console.WriteLine(A)
Console.WriteLine("Matrix B synchronized with A")
Console.WriteLine(B)
Console.Read()
End Sub
End Class
|
| C# | Copy Code |
|---|
using System;
using Bluebit.MatrixLibrary;
class Test
{
static void Main(string[] args)
{
//Declaring two random matrices
Matrix A = new Matrix(3, 3);
A.FillRandom();
Matrix B = new Matrix(5, 3);
B.FillRandom();
Console.WriteLine("Matrix A =");
Console.WriteLine(A);
Console.WriteLine("Matrix B =");
Console.WriteLine(B);
int[] pivots;
//sort the columns of matrix A in descending order
//by the elements of its second row (row #1)
A.SortCols(1, SortOrder.Descending, out pivots);
//use the pivots to syncronize matrix B with A
B.ReorderCols(pivots);
Console.WriteLine("Matrix A sorted by 2nd row");
Console.WriteLine(A);
Console.WriteLine("Matrix B synchronized with A");
Console.WriteLine(B);
Console.Read();
}
}
|
| C++ | Copy Code |
|---|
#include "stdafx.h"
using namespace System;
using namespace Bluebit::MatrixLibrary;
int main(array<System::String ^> ^args)
{
//Declaring two random matrices
Matrix^ A = gcnew Matrix(3, 3);
A->FillRandom();
Matrix^ B = gcnew Matrix(5, 3);
B->FillRandom();
Console::WriteLine("Matrix A =");
Console::WriteLine(A);
Console::WriteLine("Matrix B =");
Console::WriteLine(B);
array<int> ^pivots;
//sort the columns of matrix A in descending order
//by the elements of its second row (row #1)
A->SortCols(1, SortOrder::Descending, pivots);
//use pivots to syncronize matrix B with A
B->ReorderCols(pivots);
Console::WriteLine("Matrix A sorted by 2nd row");
Console::WriteLine(A);
Console::WriteLine("Matrix B synchronized with A");
Console::WriteLine(B);
Console::Read();
return 0;
}
|
Remarks
Requirements
Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7
See Also