Skip to content

Commit 3a9ace9

Browse files
committed
Updated readme [skip ci]
1 parent 24c3844 commit 3a9ace9

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

README.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,38 +84,56 @@ Use `std::optional<pgvector::Vector>` if the value could be `NULL`
8484

8585
### Vectors
8686

87-
Create a vector from a `std::vector<float>`
87+
Create a vector from a `std::vector`
8888

8989
```cpp
9090
pgvector::Vector vec{std::vector<float>{1, 2, 3}};
9191
```
9292
93-
Convert to a `std::vector<float>`
93+
Or a span
9494
9595
```cpp
96-
auto float_vec = static_cast<std::vector<float>>(vec);
96+
pgvector::Vector vec{std::span<const float>{{1, 2, 3}}};
97+
```
98+
99+
Convert to a `std::vector`
100+
101+
```cpp
102+
std::vector<float> float_vec = static_cast<std::vector<float>>(vec);
97103
```
98104

99105
### Half Vectors
100106

101-
Create a half vector from a `std::vector<float>`
107+
Create a half vector from a `std::vector`
102108

103109
```cpp
104110
pgvector::HalfVector vec{std::vector<float>{1, 2, 3}};
105111
```
106112
107-
Convert to a `std::vector<float>`
113+
Or a span
114+
115+
```cpp
116+
pgvector::HalfVector vec{std::span<const float>{{1, 2, 3}}};
117+
```
118+
119+
Convert to a `std::vector`
108120

109121
```cpp
110-
auto float_vec = static_cast<std::vector<float>>(vec);
122+
std::vector<float> float_vec = static_cast<std::vector<float>>(vec);
111123
```
112124

113125
### Sparse Vectors
114126

115-
Create a sparse vector from a `std::vector<float>`
127+
Create a sparse vector from a `std::vector`
128+
129+
```cpp
130+
pgvector::SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
131+
```
132+
133+
Or a span
116134
117135
```cpp
118-
pgvector::SparseVector vec{{1, 0, 2, 0, 3, 0}};
136+
pgvector::SparseVector vec{std::span<const float>{{1, 0, 2, 0, 3, 0}}};
119137
```
120138

121139
Or a map of non-zero elements

0 commit comments

Comments
 (0)