1 | #Region "Microsoft.VisualBasic::0aeddb6512f8b21f214812e00ed8e9f1, Microsoft.VisualBasic.Core\Text\Xml\Models\Vector.vb" |
2 | |
3 | ' Author: |
4 | ' |
5 | ' asuka (amethyst.asuka@gcmodeller.org) |
6 | ' xie (genetics@smrucc.org) |
7 | ' xieguigang (xie.guigang@live.com) |
8 | ' |
9 | ' Copyright (c) 2018 GPL3 Licensed |
10 | ' |
11 | ' |
12 | ' GNU GENERAL PUBLIC LICENSE (GPL3) |
13 | ' |
14 | ' |
15 | ' This program is free software: you can redistribute it and/or modify |
16 | ' it under the terms of the GNU General Public License as published by |
17 | ' the Free Software Foundation, either version 3 of the License, or |
18 | ' (at your option) any later version. |
19 | ' |
20 | ' This program is distributed in the hope that it will be useful, |
21 | ' but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | ' GNU General Public License for more details. |
24 | ' |
25 | ' You should have received a copy of the GNU General Public License |
26 | ' along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | |
28 | |
29 | |
30 | ' /********************************************************************************/ |
31 | |
32 | ' Summaries: |
33 | |
34 | ' Class NumericVector |
35 | ' |
36 | ' Properties: Length, name, vector |
37 | ' |
38 | ' Function: ToString |
39 | ' |
40 | ' Class TermsVector |
41 | ' |
42 | ' Properties: Terms |
43 | ' |
44 | ' Function: ToString |
45 | ' |
46 | ' |
47 | ' /********************************************************************************/ |
48 | |
49 | #End Region |
50 | |
51 | Imports System.Runtime.CompilerServices |
52 | Imports System.Xml.Serialization |
53 | Imports Microsoft.VisualBasic.Serialization.JSON |
54 | |
55 | Namespace Text.Xml.Models |
56 | |
57 | ''' <summary> |
58 | ''' A <see cref="Double"/> type numeric sequence container |
59 | ''' </summary> |
60 | Public Class NumericVector |
61 | |
62 | <XmlAttribute> Public Property name As String |
63 | <XmlAttribute> Public Property vector As Double() |
64 | |
65 | ''' <summary> |
66 | ''' Get/Set Element ``Xi`` |
67 | ''' </summary> |
68 | ''' <param name="i"></param> |
69 | ''' <returns></returns> |
70 | Default Public Property Xi(i As Integer) As Double |
71 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
72 | Get |
73 | Return vector(i) |
74 | End Get |
75 | Set(value As Double) |
76 | vector(i) = value |
77 | End Set |
78 | End Property |
79 | |
80 | ''' <summary> |
81 | ''' The vector length for counting the elements in <see cref="Vector"/> property. |
82 | ''' </summary> |
83 | ''' <returns></returns> |
84 | Public ReadOnly Property Length As Integer |
85 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
86 | Get |
87 | Return CInt(vector?.Length) |
88 | End Get |
89 | End Property |
90 | |
91 | Public Overrides Function ToString() As String |
92 | If name.StringEmpty Then |
93 | Return vector.GetJson |
94 | Else |
95 | Return $"Dim {name} As Vector = {vector.GetJson}" |
96 | End If |
97 | End Function |
98 | End Class |
99 | |
100 | Public Class TermsVector |
101 | |
102 | <XmlAttribute> |
103 | Public Property Terms As String() |
104 | |
105 | Public Overrides Function ToString() As String |
106 | Return Me.GetJson |
107 | End Function |
108 | End Class |
109 | End Namespace |