@@ -123,37 +123,71 @@ macro_rules! dispatch_basevectormut {
123123
124124/// Trait for common methods on vector-type structs.
125125pub trait BaseVector {
126+ /// The characteristic of the underlying field.
126127 fn prime ( & self ) -> ValidPrime ;
128+ /// The length of the vector.
127129 fn len ( & self ) -> usize ;
130+ /// Whether the vector is empty.
128131 fn is_empty ( & self ) -> bool ;
132+ /// The entry at index `index`.
129133 fn entry ( & self , index : usize ) -> u32 ;
134+ /// A slice of the vector starting at entry `start` (inclusive) and ending at entry `end`
135+ /// (exclusive). This means that `v.slice(start, end).len() == end - start`.
130136 fn slice < ' a > ( & self , start : usize , end : usize ) -> Slice < ' a >
131137 where
132138 Self : ' a ;
139+ /// The vector itself as a slice.
133140 fn as_slice ( & self ) -> Slice ;
134- fn into_owned ( self ) -> FpVector ;
141+ /// Whether the vector is zero.
135142 fn is_zero ( & self ) -> bool ;
143+ /// An iterator over the entries in the vector.
136144 fn iter ( & self ) -> FpVectorIterator ;
145+ /// An iterator over the *nonzero* entries in the vector.
137146 fn iter_nonzero ( & self ) -> FpVectorNonZeroIterator ;
147+ /// The position of the first nonzero entry in the vector, together with its value. This returns
148+ /// `None` if and only if the vector is zero.
138149 fn first_nonzero ( & self ) -> Option < ( usize , u32 ) > ;
150+ /// ???
139151 fn sign_rule ( & self , other : & Self ) -> bool ;
152+ /// Copy the contents of the vector into an owned `FpVector`. If the vector is already an
153+ /// `FpVector`, this is a no-op.
154+ fn into_owned ( self ) -> FpVector ;
155+ /// The proportion of non-zero entries.
140156 fn density ( & self ) -> f32 ;
141157}
142158
143159/// Trait for common methods on mutable vector-type structs.
144160pub trait BaseVectorMut : BaseVector {
161+ /// Scale all entries by a factor of `c`. It is assumed that `c < P`.
145162 fn scale ( & mut self , c : u32 ) ;
163+ /// Set the vector to the zero vector.
146164 fn set_to_zero ( & mut self ) ;
165+ /// Set the entry at index `index` to the value `value`. It is assumed that `value < P`.
147166 fn set_entry ( & mut self , index : usize , value : u32 ) ;
167+ /// Copy the contents of `other` into `self`. Both vectors must have the same length.
148168 fn assign < ' a , T : Into < Slice < ' a > > > ( & mut self , other : T ) ;
169+ /// Add `c` times `other` to `self`. Both `other` and `self` must have the same length, and we
170+ /// must have `c < P`.
149171 fn add < ' a , T : Into < Slice < ' a > > > ( & mut self , other : T , c : u32 ) ;
172+ /// Add `c` times `other` to `self`, assuming that all entries of `self` with index less than
173+ /// `offset` are zero. Violating this assumption does not lead to a panic or UB, but is very
174+ /// likely to produce nonsensical results.
150175 fn add_offset < ' a , T : Into < Slice < ' a > > > ( & mut self , other : T , c : u32 , offset : usize ) ;
176+ /// A mutable slice of the vector starting at entry `start` (inclusive) and ending at entry
177+ /// `end` (exclusive). This means that `v.slice_mut(start, end).len() == end - start`.
151178 fn slice_mut ( & mut self , start : usize , end : usize ) -> SliceMut ;
179+ /// The vector itself as a mutable slice.
152180 fn as_slice_mut ( & mut self ) -> SliceMut ;
181+ /// Add `value` to the entry at index `index`.
153182 fn add_basis_element ( & mut self , index : usize , value : u32 ) ;
183+ /// Replace the contents of the vector with the contents of the slice. The two must have the
184+ /// same length.
154185 fn copy_from_slice ( & mut self , slice : & [ u32 ] ) ;
186+ /// Given a mask v, add the `v[i]`th entry of `other` to the `i`th entry of `self`.
155187 fn add_masked < ' a , T : Into < Slice < ' a > > > ( & mut self , other : T , c : u32 , mask : & [ usize ] ) ;
188+ /// Given a mask v, add the `i`th entry of `other` to the `v[i]`th entry of `self`.
156189 fn add_unmasked < ' a , T : Into < Slice < ' a > > > ( & mut self , other : T , c : u32 , mask : & [ usize ] ) ;
190+ /// ???
157191 fn add_truncate < ' a , T : Into < Slice < ' a > > > ( & mut self , other : T , c : u32 ) -> Option < ( ) > ;
158192}
159193
0 commit comments