You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* \param n The number of evenly spaced entries to produce (must be greater than 0).
3265
+
* \param end The last value in the sequence if \p endpoint is true; otherwise, \p end is excluded.
3266
+
* \param n The number of evenly spaced entries to produce.
3267
+
* \param endpoint If true (default), \p end is included as the final element; if false, \p end is excluded.
3264
3268
*
3265
-
* \return A vector (RVec<Common_t>) containing \p n evenly spaced values from \p start to \p end inclusive.
3269
+
* \return A vector (RVec<Common_t>) containing \p n evenly spaced values.
3266
3270
*
3267
3271
* \note If \p n is 1, the resulting vector will contain only the value \p start.
3268
3272
* \note The check `if (!n || (n > std::numeric_limits<long long>::max()))` is used to ensure that:
3269
3273
* - n is nonzero, and
3270
3274
* - n does not exceed std::numeric_limits<long long>::max(), which would indicate that a negative range (or other arithmetic issue)
3271
3275
* has resulted in an extremely large unsigned value, thereby preventing an attempt to reserve an absurd
3272
3276
* amount of memory.
3277
+
* \note If the template parameter \c Common_t is explicitly overridden with an integral type, the arithmetic may cause rounding issues. Consequently, the resulting sequence may not end exactly at \p end. To ensure that the sequence ends exactly at \p end, consider casting the result as follows: `RVec<integral_type>(Linspace(...))`. This behavior is different than NumPy in Python.
3278
+
*
3279
+
* \par C++23 Enumerate Support:
3280
+
* With C++23, you can use the range-based enumerate view to iterate over the resulting vector with both the index
3281
+
* and the value, similar to Python's `enumerate`. For example:
@@ -3303,38 +3319,46 @@ inline RVec<Common_t> Linspace(T1 start, T2 end, unsigned long long n = 128)
3303
3319
}
3304
3320
3305
3321
/**
3306
-
* \brief Produce RVec with n log-spaced entries from base^{start} to base^{end} inclusive.
3322
+
* \brief Produce RVec with n log-spaced entries from base^{start} to base^{end}.
3307
3323
*
3308
-
* This function generates a vector of values where the exponents are evenly spaced,
3309
-
* and then returns the corresponding values of base raised to these exponents.
3310
-
* More specifically, it creates a vector with n entries where the first element is
3311
-
* \f$base^{start}\f$ and the last element is \f$base^{end}\f$, with the intermediate
3312
-
* values computed such that the exponents are evenly spaced between start and end.
3324
+
* This function generates a vector of values where the exponents are evenly spaced, and then returns the
3325
+
* corresponding values of base raised to these exponents. If \p endpoint is true (default), the vector
3326
+
* contains \p n values with the last element equal to \f$base^{end}\f$. If \p endpoint is false, the
3327
+
* sequence is computed as if there were n+1 evenly spaced samples over the interval in the exponent space,
3328
+
* and the final value (\f$base^{end}\f$) is excluded, resulting in a sequence of n values.
3313
3329
*
3314
-
* The function is templated to allow for different arithmetic types. The deduced type
3315
-
* \c Common_t is determined as follows: if the common type of \p T1, \p T2, and \p T3 is a
3316
-
* floating point type, that type is used; otherwise, the arithmetic is performed using \c double.
3330
+
* The function is templated to allow for different arithmetic types. The deduced type \c Common_t is determined as follows:
3331
+
* if the common type of \p T1, \p T2, and \p T3 is a floating point type, that type is used; otherwise, the arithmetic is performed using \c double.
3317
3332
*
3318
3333
* \tparam T1 Type of the start exponent. Default is double.
3319
3334
* \tparam T2 Type of the end exponent. Default is double.
3320
3335
* \tparam T3 Type of the base (and auxiliary type for deducing common type). Default is double.
3321
-
* \tparam Common_t Deduced type used for arithmetic, which is
3322
-
* std::common_type_t<T1, T2, T3> if that is a floating point type, or double otherwise.
3336
+
* \tparam Common_t Deduced type used for arithmetic, which is std::common_type_t<T1, T2, T3> if that is a floating point type, or double otherwise.
3323
3337
*
3324
-
* \param start The exponent corresponding to the first element (\f$base^{start}\f$).
3325
-
* \param end The exponent corresponding to the last element (\f$base^{end}\f$).
3338
+
* \param start The exponent corresponding to the first element (i.e., the first element is \f$base^{start}\f$).
3339
+
* \param end The exponent corresponding to the final element if \p endpoint is true; otherwise, \p end is excluded.
3326
3340
* \param n The number of log-spaced entries to produce.
3327
3341
* \param base The base to be used in the exponentiation (default is 10.0).
3342
+
* \param endpoint If true (default), \f$base^{end}\f$ is included as the final element; if false, \f$base^{end}\f$ is excluded.
3328
3343
*
3329
-
* \return A vector (RVec<Common_t>) containing n values, where the i-th element is
3330
-
* computed as \f$base^{(start + i \cdot \text{step})}\f$, with \f$\text{step} = \frac{end - start}{n - 1}\f$.
3344
+
* \return A vector (RVec<Common_t>) containing n log-spaced values.
3331
3345
*
3332
3346
* \note If \p n is 1, the resulting vector will contain only the value \f$base^{start}\f$.
3333
3347
* \note The check `if (!n || (n > std::numeric_limits<long long>::max()))` is used to ensure that:
3334
3348
* - n is nonzero, and
3335
3349
* - n does not exceed std::numeric_limits<long long>::max(), which would indicate that a negative range (or other arithmetic issue)
3336
3350
* has resulted in an extremely large unsigned value, thereby preventing an attempt to reserve an absurd
3337
3351
* amount of memory.
3352
+
* \note If the template parameter \c Common_t is explicitly overridden with an integral type, the arithmetic may introduce rounding errors, and as a consequence, the sequence may not end exactly at \f$base^{end}\f>. To ensure that the final element is exactly \f$base^{end}\f>, consider casting the result as follows: `RVec<integral_type>(Logspace(...))`. This behavior is different than NumPy in Python.
3353
+
*
3354
+
* \par C++23 Enumerate Support:
3355
+
* With C++23, you can use the range-based enumerate view to iterate over the resulting vector with both the index
3356
+
* and the value, similar to Python's `enumerate`. For example:
@@ -3404,6 +3432,16 @@ inline RVec<Common_t> Logspace(T1 start, T2 end, unsigned long long n = 128, T3
3404
3432
* - n does not exceed std::numeric_limits<long long>::max(), which would indicate that a negative range (or other arithmetic issue)
3405
3433
* has resulted in an extremely large unsigned value, thereby preventing an attempt to reserve an absurd
3406
3434
* amount of memory.
3435
+
* \note If the template parameter \c Common_t is explicitly overridden with an integral type, the arithmetic may introduce rounding errors, and as a consequence, the produced sequence may not strictly adhere to the intended progression. If an exact sequence is desired, consider casting the result as follows: `RVec<integral_type>(Arange(...))`. This behavior is different than NumPy in Python.
3436
+
*
3437
+
* \par C++23 Enumerate Support:
3438
+
* With C++23, you can use the range-based enumerate view to iterate over the resulting vector with both the index
3439
+
* and the value, similar to Python's `enumerate`. For example:
0 commit comments