Extreme Optimization > User's Guide > Vector and Matrix Library > Vectors > Mathematical Properties

Extreme Optimization User's Guide

User's Guide

Up: Vectors Next: Operations on Vectors Previous: Accessing Vector Components Contents

Mathematical properties

The Extreme Optimization Numerical Libraries for .NET provides access to all common mathematical properties of vectors. Because of the cost involved in computing these properties, in particular for large vectors, these properties have been implemented as methods.

General properties

The Length property returns the number of elements in the vector.

The GetComponents property returns a Double array containing the components of a vector. The components are copied from the vector's private storage to a new array.

The following example illustrates these properties:

C# CopyCode imageCopy Code
Vector v = new GeneralVector(1.0, 2.0, 4.0, 8.0);
Console.WriteLine("Length of vector v = {0}", v.Length);
double[] c = v.GetComponents();
Console.WriteLine("Components: {0}, {1}, {2}, {3}", c[0], c[1], c[2], c[3]);
Visual Basic CopyCode imageCopy Code
Dim v As Vector = New GeneralVector(1.0, 2.0, 4.0, 8.0)
Console.WriteLine("Length of vector v = {0}", v.Length)
Dim c As Double() = v.GetComponents()
Console.WriteLine("Components: {0}, {1}, {2}, {3}", c(0), c(1), c(2), c(3));

Vector Norms

The norm of a vector is a measure for the size of the vector. Most common is the two-norm, defined as the sum of the squares of the components of a vector. The two-norm of a three-dimensional vector corresponds to the common Euclidian length of the vector. The Norm method, without arguments, returns the two-norm. The NormSquared method returns the square of the two-norm, which is the same as the sum of the squares of the components.

The one-norm of a vector is the sum of the absolute values of its components. The OneNorm method returns this value.

Other norms can be defined. In general, the p-norm of a vector a with components ai is defined as

Definition of p-norm

The parameter p can be any real number. If p is negative and one of the components is zero, then the norm is always zero. Two overloads of the Norm method provide optimized norm calculation for integer and double arguments. The most commonly used values of p, along with their meaning, are summarized in the table below:

Value of p Meaning Method call
0 Number of components. Norm(0) or Length (property)
1 Sum of absolute values. OneNorm() or Norm(1)
2 Euclidean norm. Norm() or Norm(2)
+Infinity Largest absolute value. Norm(Double.PositiveInfinity)
-Infinity Smallest absolute value. Norm(Double.NegativeInfinity)

The example below illustrates the various norm methods:

C# CopyCode imageCopy Code
Vector v = new Vector(1, 2, 3, 4, 5);
double a, b;
// No arguments: the standard Euclidian norm:
a = v.Norm();
Console.WriteLine("|v| = {0}", a);
// One norm:
a = v.Norm(1);
b = v.OneNorm();
Console.WriteLine("one norm(v) = {0} = {1}", a, b);
// +inf and -inf norms:
a = v.Norm(Double.PositiveInfinity);
Console.WriteLine("+inf norm(v) = {0}", a);
a = v.Norm(Double.NegativeInfinity);
Console.WriteLine("-inf norm(v) = {0}", a);
// Zero norm:
a = v.Norm(0);
b = v.Length;
Console.WriteLine("zero-norm(v) = {0} = {1}", a, b);
// You can get the square of the two norm with the
// NormSquared method.
a = v.NormSquared();
b = v.Norm();
Console.WriteLine("|v|^2 = {0} = {0}", a, b*b);
Visual Basic CopyCode imageCopy Code
Dim v As Vector = New GeneralVector(1, 2, 3, 4, 5)
Dim a, b As Double
' No arguments: the standard Euclidian norm:
a = v.Norm()
Console.WriteLine("|v| = {0}", a)
' One norm:
a = v.Norm(1)
b = v.OneNorm()
Console.WriteLine("one norm(v) = {0} = {1}", a, b)
' +inf and -inf norms:
a = v.Norm(Double.PositiveInfinity)
Console.WriteLine("+inf norm(v) = {0}", a)
a = v.Norm(Double.NegativeInfinity)
Console.WriteLine("-inf norm(v) = {0}", a)
' Zero norm:
a = v.Norm(0)
b = v.Length
Console.WriteLine("zero-norm(v) = {0} = {1}", a, b)
' You can get the square of the two norm with the
' NormSquared method.
a = v.NormSquared()
b = v.Norm()
Console.WriteLine("|v|^2 = {0} = {0}", a, b*b);Dim v As Vector = New GeneralVector(1.0, 2.0, 4.0, 8.0)

In the above example, the variable a always contains the value calculated using the general norm method. The variable b contains the value obtained using the equivalent specialized method, if available.

Extreme values

The Extreme Optimization Numerical Libraries for .NET provides methods for providing extreme values of the components of a vector, as well as the index of the component with the extreme value. The following table summarizes the methods that can be used to obtain the value or index of an extreme value:

Method (value) Method (index) Description
Max MaxIndex Component with largest value
Min MinIndex Component with smallest value
AbsoluteMax AbsoluteMaxIndex Component with largest absolute value
AbsoluteMin AbsoluteMinIndex Component with smallest absolute value

Up: Vectors Next: Operations on Vectors Previous: Accessing Vector Components Contents

Overview
Introduction
Features
Documentation
QuickStart Samples
Sample Applications
Downloads
Get it now!
Download trial version
How to Buy
Information
Resources
Contact Us
Search

"The Extreme Optimization Statistics Library for .NET is a major boon for those doing statistical work in .NET. I strongly recommend this product."
- Marc Brooks

"I have made it my mission to institutionalize the value of good API design.  I strongly believe that this is key to making developers more productive and happy on our platform. It is clear that you value good API design in your work, and take to heart developer productivity and synergy with the .NET framework."
- Brad Abrams,
Lead Program Manager, Microsoft.

This is a partial list of companies who are using our libraries:
ABB Robotics
Allstate
Applied Materials
Arcam
Astra Schedule
Babson College
Canadian Council on Learning
Canyon Associates
Caxton Associates
CECity
Constellation Energy
CreditSights
DeepOcean
Duke University
Dynamotive
Elecsoft
Engelhard Corporation
Epcor
Equipoise Software
Galileo International
GAM UK
Gammex
GlaxoSmithKline
Global Matrix
The Hartford
Infinera Corporation
Intel
JDS Uniphase
LaBranche & Co.
Learning & Skills Council
Jacobs Consultancy
Litman Gregory
Lucas Systems
Malvern Instruments
Medrio
Merck & Co.
Mintera.
Monitor Software
MorningStar
NanoString Technologies
Paletta Invent
Parametric Portfolio Associates
Prosanos
RATA Associates
RiskShield
Ramboll
Standard & Poor's
Strategic Analysis Corporation
Univ. of Alicante
Univ. of South Carolina
vielife
Xerox
US Army