Przeglądaj źródła

Adding function_evaluation example and fixing Complex type support

Hovsep Papoyan 9 miesięcy temu
rodzic
commit
59e4277e06
5 zmienionych plików z 197 dodań i 49 usunięć
  1. 140 0
      examples/function_evaluation.rs
  2. 6 7
      examples/polynomial_evaluation.rs
  3. 30 17
      src/bindings.cc
  4. 8 5
      src/bindings.hpp
  5. 13 20
      src/lib.rs

+ 140 - 0
examples/function_evaluation.rs

@@ -0,0 +1,140 @@
+#![allow(non_snake_case)]
+use openfhe::cxx::{CxxVector, SharedPtr};
+use openfhe::ffi as ffi;
+
+fn EvalLogisticExample()
+{
+    println!("--------------------------------- EVAL LOGISTIC FUNCTION ---------------------------------");
+    let mut _cc_params_ckksrns = ffi::GetParamsCKKSRNS();
+    _cc_params_ckksrns.pin_mut().SetSecurityLevel(ffi::SecurityLevel::HEStd_NotSet);
+    _cc_params_ckksrns.pin_mut().SetRingDim(1 << 10);
+    // #if NATIVEINT == 128
+    // let _scaling_mod_size: u32 = 78;
+    // let _first_mod_size: u32 = 89;
+    let _scaling_mod_size: u32 = 50;
+    let _first_mod_size: u32 = 60;
+    _cc_params_ckksrns.pin_mut().SetScalingModSize(_scaling_mod_size);
+    _cc_params_ckksrns.pin_mut().SetFirstModSize(_first_mod_size);
+    let _poly_degree: u32 = 16;
+    let _mult_depth: u32 = 6;
+    _cc_params_ckksrns.pin_mut().SetMultiplicativeDepth(_mult_depth);
+
+    let mut _cc = ffi::GenCryptoContextByParamsCKKSRNS(&_cc_params_ckksrns);
+    _cc.Enable(ffi::PKESchemeFeature::PKE);
+    _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
+    _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
+    _cc.Enable(ffi::PKESchemeFeature::ADVANCEDSHE);
+
+    let mut _key_pair = _cc.KeyGen();
+    _cc.EvalMultKeyGen(_key_pair.GetPrivateKey());
+
+    let mut _input = CxxVector::<ffi::ComplexPair>::new();
+    _input.pin_mut().push(ffi::ComplexPair{re: -4.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: -3.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: -2.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: -1.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 0.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 1.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 2.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 3.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 4.0, im: 0.0});
+    let _encoded_length: usize = _input.len();
+    let mut _plain_text = _cc.MakeCKKSPackedPlaintextByVectorOfComplex(&_input, 1, 0, SharedPtr::<ffi::DCRTPolyParams>::null(), 0);
+    let mut _cipher_text = _cc.Encrypt(_key_pair.GetPublicKey(), &_plain_text);
+    let _lower_bound: f64 = -5.0;
+    let _upper_bound: f64 = 5.0;
+    let _result = _cc.EvalLogistic(&_cipher_text, _lower_bound, _upper_bound, _poly_degree);
+
+    let mut _plain_text_dec = ffi::GenEmptyPlainText();
+    _cc.Decrypt(_key_pair.GetPrivateKey(), &_result, _plain_text_dec.pin_mut());
+    _plain_text_dec.SetLength(_encoded_length);
+
+    let mut _expected_output = CxxVector::<ffi::ComplexPair>::new();
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 0.0179885, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 0.0474289, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 0.119205, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 0.268936, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 0.5, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 0.731064, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 0.880795, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 0.952571, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 0.982011, im: 0.0});
+    println!("Expected output\n\t[{} ]", _expected_output.iter().fold(String::new(), |acc, arg| acc + " " + "(" + &arg.re.to_string() + "," + &arg.im.to_string() + ")"));
+
+    let _final_result = _plain_text_dec.GetCopyOfCKKSPackedValue();
+    println!("Actual output\n\t[{} ]", _final_result.iter().fold(String::new(), |acc, arg| acc + " " + "(" + &arg.re.to_string() + "," + &arg.im.to_string() + ")"));
+}
+
+fn GetSqrt(x: f64, ret: &mut f64)
+{
+    *ret = x.sqrt();
+}
+
+fn EvalFunctionExample()
+{
+    println!("--------------------------------- EVAL SQUARE ROOT FUNCTION ---------------------------------");
+    let mut _cc_params_ckksrns = ffi::GetParamsCKKSRNS();
+    _cc_params_ckksrns.pin_mut().SetSecurityLevel(ffi::SecurityLevel::HEStd_NotSet);
+    _cc_params_ckksrns.pin_mut().SetRingDim(1 << 10);
+    // #if NATIVEINT == 128
+    // let _scaling_mod_size: u32 = 78;
+    // let _first_mod_size: u32 = 89;
+    let _scaling_mod_size: u32 = 50;
+    let _first_mod_size: u32 = 60;
+    _cc_params_ckksrns.pin_mut().SetScalingModSize(_scaling_mod_size);
+    _cc_params_ckksrns.pin_mut().SetFirstModSize(_first_mod_size);
+    let _poly_degree: u32 = 50;
+    let _mult_depth: u32 = 7;
+    _cc_params_ckksrns.pin_mut().SetMultiplicativeDepth(_mult_depth);
+
+    let mut _cc = ffi::GenCryptoContextByParamsCKKSRNS(&_cc_params_ckksrns);
+    _cc.Enable(ffi::PKESchemeFeature::PKE);
+    _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
+    _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
+    _cc.Enable(ffi::PKESchemeFeature::ADVANCEDSHE);
+
+    let mut _key_pair = _cc.KeyGen();
+    _cc.EvalMultKeyGen(_key_pair.GetPrivateKey());
+    let mut _input = CxxVector::<ffi::ComplexPair>::new();
+    _input.pin_mut().push(ffi::ComplexPair{re: 1.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 2.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 3.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 4.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 5.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 6.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 7.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 8.0, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 9.0, im: 0.0});
+
+    let _encoded_length: usize = _input.len();
+    let mut _plain_text = _cc.MakeCKKSPackedPlaintextByVectorOfComplex(&_input, 1, 0, SharedPtr::<ffi::DCRTPolyParams>::null(), 0);
+    let mut _cipher_text = _cc.Encrypt(_key_pair.GetPublicKey(), &_plain_text);
+    let _lower_bound: f64 = 0.0;
+    let _upper_bound: f64 = 10.0;
+    let _result = _cc.EvalChebyshevFunction(GetSqrt, &_cipher_text, _lower_bound, _upper_bound, _poly_degree);
+
+    let mut _plain_text_dec = ffi::GenEmptyPlainText();
+    _cc.Decrypt(_key_pair.GetPrivateKey(), &_result, _plain_text_dec.pin_mut());
+    _plain_text_dec.SetLength(_encoded_length);
+
+    let mut _expected_output = CxxVector::<ffi::ComplexPair>::new();
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 1.0, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 1.414213, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 1.732050, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 2.0, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 2.236067, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 2.449489, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 2.645751, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 2.828427, im: 0.0});
+    _expected_output.pin_mut().push(ffi::ComplexPair{re: 3.0, im: 0.0});
+    println!("Expected output\n\t[{} ]", _expected_output.iter().fold(String::new(), |acc, arg| acc + " " + "(" + &arg.re.to_string() + "," + &arg.im.to_string() + ")"));
+
+    let _final_result = _plain_text_dec.GetCopyOfCKKSPackedValue();
+    println!("Actual output\n\t[{} ]", _final_result.iter().fold(String::new(), |acc, arg| acc + " " + "(" + &arg.re.to_string() + "," + &arg.im.to_string() + ")"));
+}
+
+fn main()
+{
+    EvalLogisticExample();
+    EvalFunctionExample();
+}

+ 6 - 7
examples/polynomial_evaluation.rs

@@ -16,13 +16,12 @@ fn main()
     _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
     _cc.Enable(ffi::PKESchemeFeature::ADVANCEDSHE);
 
-    let mut _vals = CxxVector::<ffi::ComplexPair>::new();
-    _vals.pin_mut().push(ffi::ComplexPair{re: 0.5, im: 0.0});
-    _vals.pin_mut().push(ffi::ComplexPair{re: 0.7, im: 0.0});
-    _vals.pin_mut().push(ffi::ComplexPair{re: 0.9, im: 0.0});
-    _vals.pin_mut().push(ffi::ComplexPair{re: 0.95, im: 0.0});
-    _vals.pin_mut().push(ffi::ComplexPair{re: 0.93, im: 0.0});
-    let _input = ffi::GenVectorOfComplex(&_vals);
+    let mut _input = CxxVector::<ffi::ComplexPair>::new();
+    _input.pin_mut().push(ffi::ComplexPair{re: 0.5, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 0.7, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 0.9, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 0.95, im: 0.0});
+    _input.pin_mut().push(ffi::ComplexPair{re: 0.93, im: 0.0});
     let _encoded_length = _input.len();
 
     let mut _coefficients_1 = CxxVector::<f64>::new();

+ 30 - 17
src/bindings.cc

@@ -60,6 +60,17 @@ rust::String Plaintext::GetString() const
     stream << *m_plaintext;
     return rust::String(stream.str());
 }
+std::unique_ptr<std::vector<ComplexPair>> Plaintext::GetCopyOfCKKSPackedValue() const
+{
+    const std::vector<std::complex<double>>& v = m_plaintext->GetCKKSPackedValue();
+    std::vector<ComplexPair> result;
+    result.reserve(v.size());
+    for (const std::complex<double>& elem : v)
+    {
+        result.push_back(ComplexPair{elem.real(), elem.imag()});
+    }
+    return std::make_unique<std::vector<ComplexPair>>(std::move(result));
+}
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -86,14 +97,14 @@ CryptoContextDCRTPoly::CryptoContextDCRTPoly(const ParamsCKKSRNS& params)
     : m_cryptoContextImplSharedPtr(lbcrypto::GenCryptoContext(params))
 { }
 std::unique_ptr<Plaintext> CryptoContextDCRTPoly::MakeCKKSPackedPlaintextByVectorOfComplex(
-    const std::vector<SharedComplex>& value, const size_t scaleDeg, const uint32_t level,
+    const std::vector<ComplexPair>& value, const size_t scaleDeg, const uint32_t level,
     const std::shared_ptr<DCRTPolyParams> params, const uint32_t slots) const
 {
-    std::vector<Complex> v;
+    std::vector<std::complex<double>> v;
     v.reserve(value.size());
-    for (const SharedComplex& elem : value)
+    for (const ComplexPair& elem : value)
     {
-        v.push_back(std::move(*elem.ptr));
+        v.emplace_back(elem.re, elem.im);
     }
     return std::make_unique<Plaintext>(m_cryptoContextImplSharedPtr->MakeCKKSPackedPlaintext(
         v, scaleDeg, level, params, slots));
@@ -188,6 +199,14 @@ std::unique_ptr<CiphertextDCRTPoly> CryptoContextDCRTPoly::EvalChebyshevSeries(
     return std::make_unique<CiphertextDCRTPoly>(m_cryptoContextImplSharedPtr->EvalChebyshevSeries(
         ciphertext.GetInternal(), coefficients, a, b));
 }
+std::unique_ptr<CiphertextDCRTPoly> CryptoContextDCRTPoly::EvalChebyshevFunction(
+    rust::Fn<void(const double x, double& ret)> func, const CiphertextDCRTPoly& ciphertext,
+    const double a, const double b, const uint32_t degree) const
+{
+    return std::make_unique<CiphertextDCRTPoly>(
+        m_cryptoContextImplSharedPtr->EvalChebyshevFunction([&](const double x){
+        double result; func(x, result); return result; }, ciphertext.GetInternal(), a, b, degree));
+}
 std::unique_ptr<CiphertextDCRTPoly> CryptoContextDCRTPoly::EvalBootstrap(
     const CiphertextDCRTPoly& ciphertext, const uint32_t numIterations,
     const uint32_t precision) const
@@ -219,6 +238,13 @@ std::unique_ptr<CiphertextDCRTPoly> CryptoContextDCRTPoly::IntMPBootAdjustScale(
     return std::make_unique<CiphertextDCRTPoly>(m_cryptoContextImplSharedPtr->IntMPBootAdjustScale(
         ciphertext.GetInternal()));
 }
+std::unique_ptr<CiphertextDCRTPoly> CryptoContextDCRTPoly::EvalLogistic(
+    const CiphertextDCRTPoly& ciphertext, const double a, const double b,
+    const uint32_t degree) const
+{
+    return std::make_unique<CiphertextDCRTPoly>(m_cryptoContextImplSharedPtr->EvalLogistic(
+        ciphertext.GetInternal(), a, b, degree));
+}
 std::unique_ptr<CiphertextDCRTPoly> CryptoContextDCRTPoly::IntMPBootRandomElementGen(
     const PublicKeyDCRTPoly& publicKey) const
 {
@@ -271,19 +297,6 @@ std::unique_ptr<CiphertextDCRTPoly> CryptoContextDCRTPoly::EvalPoly(
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-std::unique_ptr<std::vector<SharedComplex>> GenVectorOfComplex(
-    const std::vector<ComplexPair>& vals)
-{
-    std::vector<SharedComplex> result;
-    result.reserve(vals.size());
-    for (const ComplexPair& p : vals)
-    {
-        SharedComplex temp;
-        temp.ptr = std::make_shared<Complex>(p.re, p.im);
-        result.emplace_back(std::move(temp));
-    }
-    return std::make_unique<std::vector<SharedComplex>>(std::move(result));
-}
 std::unique_ptr<Params> GetParamsByScheme(const SCHEME scheme)
 {
     return std::make_unique<Params>(scheme);

+ 8 - 5
src/bindings.hpp

@@ -37,8 +37,6 @@ using DecryptResult = lbcrypto::DecryptResult;
 using DCRTPolyParams = lbcrypto::DCRTPoly::Params;
 using ::SerialMode;
 struct ComplexPair;
-using Complex = std::complex<double>;
-struct SharedComplex;
 
 // not used in the Rust side
 using PlaintextImpl = lbcrypto::PlaintextImpl;
@@ -104,6 +102,7 @@ public:
     void SetLength(const size_t newSize) const;
     [[nodiscard]] double GetLogPrecision() const;
     [[nodiscard]] rust::String GetString() const;
+    [[nodiscard]] std::unique_ptr<std::vector<ComplexPair>> GetCopyOfCKKSPackedValue() const;
 };
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -184,6 +183,9 @@ public:
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalChebyshevSeries(
    	    const CiphertextDCRTPoly& ciphertext, const std::vector<double>& coefficients,
         const double a, const double b) const;
+    [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalChebyshevFunction(
+        rust::Fn<void(const double x, double& ret)> func, const CiphertextDCRTPoly& ciphertext,
+        const double a, const double b, const uint32_t degree) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalBootstrap(
         const CiphertextDCRTPoly& ciphertext, const uint32_t numIterations /* 1 */,
         const uint32_t precision /* 0 */) const;
@@ -195,6 +197,9 @@ public:
         const uint32_t batchSize) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> IntMPBootAdjustScale(
    	    const CiphertextDCRTPoly& ciphertext) const;
+    [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalLogistic(
+        const CiphertextDCRTPoly& ciphertext, const double a, const double b,
+        const uint32_t degree) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> IntMPBootRandomElementGen(
         const PublicKeyDCRTPoly& publicKey) const;
     void EvalBootstrapSetup(const std::vector<uint32_t>& levelBudget /* {5, 4} */,
@@ -213,15 +218,13 @@ public:
         const uint32_t level /* 0 */, const std::shared_ptr<DCRTPolyParams> params /* nullptr */,
         const uint32_t slots /* 0 */) const;
     [[nodiscard]] std::unique_ptr<Plaintext> MakeCKKSPackedPlaintextByVectorOfComplex(
-        const std::vector<SharedComplex>& value, const size_t scaleDeg /* 1 */,
+        const std::vector<ComplexPair>& value, const size_t scaleDeg /* 1 */,
         const uint32_t level /* 0 */, const std::shared_ptr<DCRTPolyParams> params /* nullptr */,
         const uint32_t slots /* 0 */) const;
 };
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-[[nodiscard]] std::unique_ptr<std::vector<SharedComplex>> GenVectorOfComplex(
-    const std::vector<ComplexPair>& vals);
 [[nodiscard]] std::unique_ptr<Params> GetParamsByScheme(const SCHEME scheme);
 [[nodiscard]] std::unique_ptr<Params> GetParamsByVectorOfString(
     const std::vector<std::string>& vals);

+ 13 - 20
src/lib.rs

@@ -148,7 +148,6 @@ pub mod ffi
         type DCRTPolyParams;
         type SerialMode;
         type PublicKeyDCRTPoly;
-        type Complex;
     }
 
     // Params
@@ -461,6 +460,7 @@ pub mod ffi
         fn SetLength(self: &Plaintext, newSize: usize);
         fn GetString(self: &Plaintext) -> String;
         fn GetLogPrecision(self: &Plaintext) -> f64;
+        fn GetCopyOfCKKSPackedValue(self: &Plaintext) -> UniquePtr<CxxVector<ComplexPair>>;
     }
 
     // CiphertextDCRTPoly
@@ -475,17 +475,6 @@ pub mod ffi
         re: f64,
         im: f64,
     }
-    // SharedComplex
-    struct SharedComplex
-    {
-        ptr: SharedPtr<Complex>,
-    }
-    // Vector of SharedComplex
-    unsafe extern "C++"
-    {
-        fn GenVectorOfComplex(vals: &CxxVector<ComplexPair>)
-                              -> UniquePtr<CxxVector<SharedComplex>>;
-    }
 
     // CryptoContextDCRTPoly
     unsafe extern "C++"
@@ -529,6 +518,9 @@ pub mod ffi
         fn EvalChebyshevSeries(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly,
                                coefficients: &CxxVector<f64>, a: f64, b: f64)
                                -> UniquePtr<CiphertextDCRTPoly>;
+        fn EvalChebyshevFunction(self: &CryptoContextDCRTPoly, func: fn(f64, ret: &mut f64),
+                                 ciphertext: &CiphertextDCRTPoly, a: f64, b: f64, degree: u32)
+                                 -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalBootstrap(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly,
                          numIterations: /* 1 */ u32, precision: /* 0 */ u32)
                          -> UniquePtr<CiphertextDCRTPoly>;
@@ -540,6 +532,8 @@ pub mod ffi
                    -> UniquePtr<CiphertextDCRTPoly>;
         fn IntMPBootAdjustScale(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly)
                                 -> UniquePtr<CiphertextDCRTPoly>;
+        fn EvalLogistic(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly, a: f64,
+                        b: f64, degree: u32) -> UniquePtr<CiphertextDCRTPoly>;
         fn IntMPBootRandomElementGen(self: &CryptoContextDCRTPoly, publicKey: &PublicKeyDCRTPoly)
                                      -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalBootstrapSetup(self: &CryptoContextDCRTPoly,
@@ -558,7 +552,7 @@ pub mod ffi
                                    params: /* null() */ SharedPtr<DCRTPolyParams>,
                                    slots: /* 0 */ u32) -> UniquePtr<Plaintext>;
         fn MakeCKKSPackedPlaintextByVectorOfComplex(self: &CryptoContextDCRTPoly,
-                                                    value: &CxxVector<SharedComplex>,
+                                                    value: &CxxVector<ComplexPair>,
                                                     scaleDeg: /* 1 */ usize, level: /* 0 */ u32,
                                                     params: /* null() */ SharedPtr<DCRTPolyParams>,
                                                     slots: /* 0 */ u32) -> UniquePtr<Plaintext>;
@@ -840,13 +834,12 @@ mod tests
         _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
         _cc.Enable(ffi::PKESchemeFeature::ADVANCEDSHE);
 
-        let mut _vals = CxxVector::<ffi::ComplexPair>::new();
-        _vals.pin_mut().push(ffi::ComplexPair{re: 0.5, im: 0.0});
-        _vals.pin_mut().push(ffi::ComplexPair{re: 0.7, im: 0.0});
-        _vals.pin_mut().push(ffi::ComplexPair{re: 0.9, im: 0.0});
-        _vals.pin_mut().push(ffi::ComplexPair{re: 0.95, im: 0.0});
-        _vals.pin_mut().push(ffi::ComplexPair{re: 0.93, im: 0.0});
-        let _input = ffi::GenVectorOfComplex(&_vals);
+        let mut _input = CxxVector::<ffi::ComplexPair>::new();
+        _input.pin_mut().push(ffi::ComplexPair{re: 0.5, im: 0.0});
+        _input.pin_mut().push(ffi::ComplexPair{re: 0.7, im: 0.0});
+        _input.pin_mut().push(ffi::ComplexPair{re: 0.9, im: 0.0});
+        _input.pin_mut().push(ffi::ComplexPair{re: 0.95, im: 0.0});
+        _input.pin_mut().push(ffi::ComplexPair{re: 0.93, im: 0.0});
         let _encoded_length = _input.len();
 
         let mut _coefficients_1 = CxxVector::<f64>::new();