In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how to create vectors from numerical values in the. Net math library NMath, which is concise and easy to understand. I hope you can get something through the detailed introduction of this article.
NMath is a math library for all .NET languages, such as C #, Visual Basic, F# and .NET. It contains the basic classes for object-oriented digital computing on the .NET platform. We will introduce you to the practical tutorials of NMath in the form of a serial. The following focuses on the basics of how to create vectors from numerical values.
You can construct vector objects numerically in a variety of ways, all of which create a new view of the new data block. A single passed non-negative integer creates a vector of that length, with all values initialized to zero. For example, the following example creates a floating-point value vector with 10 elements:
C # vector code example var v = new FloatVector (10); VB vector code sample Dim V As New FloatVector (10)
Another constructor allows you to set the initial values of all elements in the vector:
C # vector code example var v = new DoubleVector (10,2.0); / / v [I] = = 2 for all ivar u = new FloatComplexVector (10, new FloatComplex (1.0,2.0)); / / u [j] = = 1-2i for all jVB vector code sample Dim V As New DoubleVector (10,2.0)'V (I) = 2 for all iDim U As New FloatComplexVector (10, New FloatComplex (1.0,2.0)) U (j) = 1-2i for all j
Similarly, the vector class provides a constructor that allows you to set the length, the value of the first element, and the amount incremented by each successive element in the vector. So the I-th element of the vector has the value of initialValue + I * increment. For example, the following example creates a vector [1, 1, 3, 5, 5, 7, 9]:
C # vector code example var v = new FloatVector (5, 1, 2); VB vector code example Dim V As New FloatVector (5, 1, 2)
You can also create vectors from an array of values:
C # vector code example double [] dblArray = {1.12,-2.0,3.88,1.2, 15.345}; var v = new DoubleVector (dblArray); VB vector code example Dim DblArray () As Double = {1.12,2.0,3.88,1.2, 15.345} Dim V As New DoubleVector (DblArray)
Or a comma-separated list:
C # vector code example var v = new FloatVector (3.5,6.7,0.0,3.11,8.90,5.0); VB vector code sample Dim V As New FloatVector (3.5,6.7,0.0,3.11,8.9,5.0)
You can also create complex vector types from polar coordinates:
C # vector code example var magnitudes = new FloatVector (1,2,3,6); var angles = new FloatVector (1,2,3,3); var v = FloatComplexVector.FromPolar (magnitudes, angles) VB vector code example Dim Magnitudes As New FloatVector (1, 2, 3, 6) Dim Angles as New FloatVector (1, 2, 3,-3) Dim V = FloatComplexVector.FromPolar (magnitudes, angles) the above is how to create vectors from numerical values in the math library NMath of .NET. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.