In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how to copy and view vectors in the. Net math library NMath. The content is concise and easy to understand, which will definitely brighten your eyes. 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 serials. the following focuses on implicit vector conversion, how to copy vectors, and new vector views.
Implicit transformation of vector
The implicit conversion operator for the vector class is shown in the following figure, where the arrow indicates implicit promotion.
Copy vector
Vector classes provide three replication methods:
Clone (): returns a deep copy of the vector. The data will be copied, so each vector references different data.
ShallowCopy (): returns a shallow copy of the vector. The data is not copied, and both vectors refer to the same data.
DeepenThisCopy (): copy the data viewed by the vector to the new data block, which ensures that there is only one reference to the underlying data and that the data is in continuous storage.
C # Vector Code sample var v = new DoubleVector ("[1 2 3 4 5]" > VB Vector Code example Dim V As New DoubleVector ("[1 2 3 4 5]") Dim U As DoubleVector = V.ShallowCopy () U (0) = 0'V (0) = U (0) U.DeepenThisCopy () U (1) = 0'V (1) U (1) A common way to create a vector in NMath is to reference Create a new vector view of the data of another object. This is implemented using Slice and Range objects. C # vector code example var v = new DoubleVector (10, 1, 1); / / v = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] var first3Elements = new Slice (0,3); DoubleVector u = v [first3Elements] VB vector code example Dim V As New DoubleVector (10, 1, 1)'v = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Dim First3Elements As New Slice (0,3) Dim U As DoubleVector = v (First3Elements) Note: the vector indexer has been overloaded to accept the indexed object and returns a new view of the indexed data. The behavior of vector u is completely similar to building vectors with the three elements 1, 2, and 3. Example of C# vector code u [0] = = 1; / / trueu [1] = = 2; / / trueu [2] = = 3; / / trueu [3]; / / Index out of bounds exception! VB vector code example U (0) = 1 'trueU (1) = 2' trueU (2) = 3 'trueU (3)' Index out of bounds exception! When the value in u changes, the difference between u and the newly constructed vector becomes clear. This changes the corresponding values in v because they all refer to the same data. C # vector code example u [2] = 99 * * v [2] = = 99; / / true! VB vector code example U (2) = 99V (2) = 99 'true! This is another example of using a Range object: C # vector code example var v = new DoubleVector ("[1 2 3 4 5 6]"); DoubleVector everyOther = v [new Range (0prima Position.EndMagne2)] The VB vector code example Dim V As New DoubleVector ("[1 2 3 4 56]") Dim EveryOther As DoubleVector = V (New Range (0, Position.End, 2)), such as Row (), Column (), Diagonal (), and Slice (), can also create vector views on matrix classes. The above content is how to copy and view vectors in the. Net math library NMath. 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.