Extreme Optimization™: Complexity made simple.

Numerical Components
for .NET

  • Home
  • •
  • Features
    • Math Library
    • Vector and Matrix Library
    • Statistics Library
    • Performance
    • Usability
  • •
  • Documentation
    • Introduction
    • Math Library User's Guide
    • Vector and Matrix Library User's Guide
    • Statistics Library User's Guide
    • Reference
  • •
  • Support
    • Frequently Asked Questions
    • QuickStart Samples
    • Sample Applications
    • Downloads
  • •
  • Blog
  • •
  • Company
    • About us
    • Testimonials
    • Customers
    • Press Releases
    • Careers
    • Contact us
Introduction
Expand Mathematics Library User's GuideMathematics Library User's Guide
Expand Vector and Matrix Library User's GuideVector and Matrix Library User's Guide
Expand Statistics Library User's GuideStatistics Library User's Guide
Expand ReferenceReference
  • Home
    • Features
    • Solutions
    • Documentation
    • QuickStart Samples
    • Sample Applications
    • Downloads
    • Technical Support
    • Download trial
    • How to buy
    • Blog
    • Company
    • Resources
  • Documentation
    • Introduction
    • Mathematics Library User's Guide
    • Vector and Matrix Library User's Guide
    • Statistics Library User's Guide
    • Reference
  • Vector and Matrix Library User's Guide
    • Vectors
    • Matrices
    • Structured Matrix Types
    • Matrix Decompositions
    • Sparse Vectors and Matrices
    • Complex Linear Algebra
    • Single-Precision Linear Algebra
  • Vectors
    • Vector Basics
    • Constructing Vectors
    • Accessing vector components
    • Mathematical properties
    • Operations on vectors
  • Mathematical properties
Collapse imageExpand ImageCopy imageCopyHover image
       




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# Copy imageCopy
Vector v = Vector.Create(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 Copy imageCopy
Dim v As Vector = Vector.Create(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

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 Norm(Int32) and Norm(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(Int32) or Length (property)
1 Sum of absolute values. OneNorm()()() or Norm(Int32)
2 Euclidean norm. Norm()()() or Norm(Int32)
+Infinity Largest absolute value. Norm(Double)
-Infinity Smallest absolute value. Norm(Double)

The example below illustrates the various norm methods:

C# Copy imageCopy
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 Copy imageCopy
Dim v As Vector = Vector.Create(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} = {1}", a, b*b);Dim v As Vector = Vector.Create(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

Send comments on this topic to support@extremeoptimization.com

Copyright © 2003-2010, Extreme Optimization. All rights reserved.
Extreme Optimization, Complexity made simple, M#, and M Sharp are trademarks of ExoAnalytics Inc.
Microsoft, Visual C#, Visual Basic, Visual Studio, Visual Studio.NET, and the Optimized for Visual Studio logo
are registered trademarks of Microsoft Corporation.