@@ -188,9 +188,10 @@ class PolyMod
188188 NTL::ZZX getG () const ;
189189
190190 /* *
191- * @brief Getter function that returns the data of `PolyMod` as an `NTL::ZZX`.
191+ * @brief Getter function that returns the data of `PolyMod` as an
192+ * `NTL::ZZX` const reference.
192193 **/
193- NTL::ZZX getData () const ;
194+ const NTL::ZZX& getData () const ;
194195
195196 /* *
196197 * @brief Equals operator between two `PolyMod` objects.
@@ -373,6 +374,46 @@ class PolyMod
373374 **/
374375 PolyMod& operator -=(const NTL::ZZX& otherPoly);
375376
377+ /* *
378+ * @brief Deserialize a `PolyMod` object from the input stream `is`.
379+ * @param is Input `std::istream`.
380+ * @param poly Destination `PolyMod` object.
381+ * @throws IOError if the stream is badly formatted (i.e. it is not delimited
382+ * by '[' and ']').
383+ * @note `poly` must be constructed with an appropriate p2r and G @b BEFORE
384+ * calling this function. For example,
385+ * @code
386+ * PolyMod my_poly(p2r, G);
387+ * deserialize(std::cin, my_poly);
388+ * @endcode
389+ *
390+ * The input stream has to be formatted as a comma-separated list surrounded
391+ * by '[' and ']'.\n
392+ * Each element of the list will be deserialized as a coefficient of the
393+ * polynomial.\n
394+ * For example '['coef0', 'coef1', 'coef2']' will be deserialized as a
395+ * `PolyMod` object `poly` where `poly[0]=coef0`, `poly[1]=coef1`,
396+ * `poly[2]=coef2` and `poly[i]=0` for `i>2`.
397+ **/
398+ friend void deserialize (std::istream& is, PolyMod& poly);
399+
400+ /* *
401+ * @brief Serialize a `PolyMod` to the output stream `os`.
402+ * @param os Output `std::ostream`.
403+ * @param poly `PolyMod` object to be written.
404+ * @return Input `std::ostream` post writing.
405+ * @note p2r and G are not serialized, see note of `deserialize`.
406+ *
407+ * The output stream will be formatted as a comma-separated list surrounded by
408+ * '[' and ']'.\n
409+ * Each coefficient of `poly` will be serialized in an element of such list by
410+ * the `>>` operator.\n
411+ * For example if we have a `PolyMod` object `poly` such that `poly[0]=coef0`,
412+ * `poly[1]=coef1`, `poly[2]=coef2`, and `poly[i]=0` for `i>2`, it will be
413+ * serialized as '['coef0', 'coef1', 'coef2']'.
414+ **/
415+ friend void serialize (std::ostream& os, const PolyMod& slot);
416+
376417 /* *
377418 * @brief Input shift operator.
378419 * @param is Input `std::istream`.
@@ -384,6 +425,16 @@ class PolyMod
384425 * PolyMod my_poly(p2r, G);
385426 * std::cin >> my_poly;
386427 * @endcode
428+ *
429+ * The input stream has to be formatted as a comma-separated list surrounded
430+ * by '[' and ']'.\n
431+ * Each element of the list will be deserialized as a coefficient of the
432+ * polynomial.\n
433+ * If the number of tokens in the list is less than the number of
434+ * coefficients, the higher-degree coefficients will be padded by 0.\n
435+ * For example '['coef0', 'coef1', 'coef2']' will be deserialized as a
436+ * `PolyMod` object `poly` where `poly[0]=coef0`, `poly[1]=coef1`,
437+ * `poly[2]=coef2` and `poly[i]=0` for `i>2`.
387438 **/
388439 friend std::istream& operator >>(std::istream& is, PolyMod& poly);
389440
@@ -392,7 +443,15 @@ class PolyMod
392443 * @param os Output `std::ostream`.
393444 * @param poly `PolyMod` object to be written.
394445 * @return Input `std::ostream` post writing.
395- * @note p2r and G are not serialised, see note of `operator>>`.
446+ * @note p2r and G are not serialized, see note of `operator>>`.
447+ *
448+ * The output stream will be formatted as a comma-separated list surrounded by
449+ * '[' and ']'.\n
450+ * Each coefficient of `poly` will be serialized in an element of such list by
451+ * the `>>` operator.\n
452+ * For example if we have a `PolyMod` object `poly` such that `poly[0]=coef0`,
453+ * `poly[1]=coef1`, `poly[2]=coef2`, and `poly[i]=0` for `i>2`, it will be
454+ * serialized as '['coef0', 'coef1', 'coef2']'.
396455 **/
397456 friend std::ostream& operator <<(std::ostream& os, const PolyMod& poly);
398457
0 commit comments