# doc-cache created by Octave 11.3.0
# name: cache
# type: cell
# rows: 3
# columns: 27
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
abcd2s


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1384
 -- Function File: S = abcd2s (A)
 -- Function File: S = abcd2s (A, Z0)
     Convert 2-port ABCD (chain/transmission) parameters to S-parameters.

     A must be a 2x2xK complex array.  Z0 is the reference impedance in ohms
     (scalar, default 50).  Returns a 2x2xK S-parameter array.  This is the
     inverse of ‘s2abcd’.

     *Conversion formulas:*
       d  = A + B/z0 + C*z0 + D       (common denominator)
     
       S11 = (A + B/z0 - C*z0 - D) / d
       S12 = 2*(A*D - B*C) / d         = 2*det(ABCD) / d
       S21 = 2 / d
       S22 = (-A + B/z0 - C*z0 + D) / d

     *Note*: For reciprocal networks det(ABCD) = AD-BC = 1, so S12 = S21 = 2/d.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Section 3.4.5 "S-Parameters In Terms Of ABCD Parameters",
         Table 3.6, Eq. 3.20 (p.60): S from ABCD — matches this
         implementation element-by-element.
     
       Pozar, D.M., "Microwave Engineering", 4th ed., Wiley, 2012.
         Section 4.4, Eq. 4.69 (p.189): ABCD definition.
         Table 4.2 (p.192): 2-port ABCD-to-S conversion.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.3 "ABCD Parameters" (p.382).

     See also: s2abcd, t2s, z2s.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
Convert 2-port ABCD (chain/transmission) parameters to S-parameters.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
cascadesparams


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2305
 -- Function File: S_OUT = cascadesparams (S1, S2, ...)
     Cascade two or more 2-port S-parameter networks in series.

     Each input is either a sparameters struct or a 2x2xK raw array.  Returns a
     sparameters struct (or raw array if all inputs are raw arrays).  At least
     two inputs are required.

     All inputs must have the same frequency vector and the same reference
     impedance.  Struct inputs carry their reference in the ‘Impedance’ field;
     raw arrays are assumed to be referenced to 50 ohms (the package
     convention).  Mismatched reference impedances raise an error, matching
     MATLAB RF Toolbox behavior; the T-matrix cascade is only valid when the
     joined ports share one reference impedance (Pupalaikis Section 3.7.1).  The
     common reference is propagated to the output struct.

     *Algorithm:* For each pair, convert to T-parameters, multiply, convert back
     to S-parameters.  T-parameters are the natural representation for
     cascading:
       T_cascade = T1 * T2 * ... * Tn
       S_cascade = t2s(T_cascade)

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Section 3.7 "Cascading" (p.69): T_total = TL * TR —
         S-parameters of cascaded 2-port T-parameter devices via
         T-matrix multiplication.
         Section 3.7.1, Eq. 3.35 (p.69): explicit cascade formula.
         Chapter 10 "De-embedding" (p.282) for comprehensive treatment of
         cascade/de-embed operations.
     
       Pozar, D.M., "Microwave Engineering", 4th ed., Wiley, 2012.
         Section 4.4, Eq. 4.71 (p.189): ABCD cascade property
           [ABCD]_cascade = [ABCD]_1 * [ABCD]_2
         (analogous concept — ABCD cascades for two-port networks the same
         way T-parameters do, differing only in which independent/dependent
         variables are used).
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.4 "Cascading S-Parameters" (p.390).
     
       Resso, M. and Bogatin, E., "Signal Integrity Characterization
         Techniques", IEC, 2009.  Chapter on cascade/de-embed.

     See also: deembedsparams, embedsparams, s2t, t2s.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 58
Cascade two or more 2-port S-parameter networks in series.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
deembedsparams


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2050
 -- Function File: S_DUT = deembedsparams (S_MEASURED, S_FIX1, S_FIX2)
     De-embed fixture S-parameters from a measured fixture-DUT-fixture cascade.

     S_MEASURED is the measured cascade (fixture1 - DUT - fixture2), S_FIX1 is
     the left fixture error box, and S_FIX2 is the right fixture error box.  All
     three are either sparameters structs or 2x2xK arrays.  Returns the
     de-embedded DUT as a sparameters struct (or raw array).

     All inputs must share one reference impedance.  Struct inputs carry it in
     the ‘Impedance’ field; raw arrays are assumed 50 ohms.  A mismatch raises
     an error (MATLAB parity); the common reference is propagated to the output
     struct.

     *Algorithm:*
       T_DUT = inv(T_fix1) * T_measured * inv(T_fix2)
     where T = s2t(S) are the corresponding T (chain scattering) parameters.
     Inversion is performed per-frequency using ‘linsolve’ for numerical
     stability.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Section 3.8 "Inverse and Identity Sections" (p.69-70):
         T_identity = I2x2 and inverse section definition.
         Section 3.9 "De-embedding S-Parameters" (p.70): T_R = T_L^-1 * T
         removes a known left section from a cascade.  This implementation
         removes both left and right fixtures symmetrically:
           T_DUT = T_fix1^-1 * T_measured * T_fix2^-1.
         Chapter 10 "De-embedding" (p.282) for comprehensive treatment
         including one-port, two-port, fixture, and two-port-tip cases.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.5 "Calibration and Deembedding" (p.395).
     
       Resso, M. and Bogatin, E., "Signal Integrity Characterization
         Techniques", IEC, 2009.  Chapter on de-embedding for
         measurement-based fixture removal.

     See also: embedsparams, cascadesparams, s2t, t2s.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 74
De-embed fixture S-parameters from a measured fixture-DUT-fixture cascade.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
embedsparams


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1217
 -- Function File: S_OUT = embedsparams (S_DUT, S_FIX1, S_FIX2)
     Embed a DUT inside fixture S-parameters (inverse of de-embedding).

     S_DUT is the device under test, S_FIX1 is the left fixture, and S_FIX2 is
     the right fixture.  All three are either sparameters structs or 2x2xK
     arrays.  Returns the embedded (fixture-DUT-fixture) cascade.

     This is the exact inverse of ‘deembedsparams’:
     ‘embedsparams(deembedsparams(S_m, f1, f2), f1, f2) == S_m’

     *Algorithm:*
       T_result = T_fix1 * T_dut * T_fix2
     which is equivalent to ‘cascadesparams(s_fix1, s_dut, s_fix2)’.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Section 3.7 "Cascading" (p.69): T_total = TL * TR.
         Chapter 10 "De-embedding" (p.282): forward cascade
           T_measured = T_left * T_DUT * T_right
         is the inverse operation of de-embedding.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.4 "Cascading S-Parameters" (p.390).

     See also: deembedsparams, cascadesparams.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 66
Embed a DUT inside fixture S-parameters (inverse of de-embedding).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
fromtouchn


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 424
 fromtouchn.m -- Touchstone file reader (S1P through S99P)

 Origin: Francesco de Paulis, UMR-EMC Lab (now Missouri S&T), November 2006.
 Distributed as part of the IEEE P370 open-source repository:
   https://opensource.ieee.org/elec-char/ieee-370/
 Included in octave-rf with attribution to the original author.

 Supports Touchstone 1.0 format (RI, MA, dB; Hz/kHz/MHz/GHz).
 Does NOT support Touchstone 2.0 (.ts) format.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 58
 fromtouchn.m -- Touchstone file reader (S1P through S99P)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
g2s


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 897
 -- Function File: S = g2s (G)
 -- Function File: S = g2s (G, Z0)
     Convert 2-port G-parameters (inverse hybrid parameters) to S-parameters.

     G must be a 2x2xK complex array.  Z0 is the reference impedance (scalar,
     default 50).  Returns a 2x2xK S-parameter array.  This is the inverse of
     ‘s2g’.  Since G = inv(H), this computes H = inv(G) then calls ‘h2s’.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Chapter 1, Section 1.2 (p.16): G-parameter definition.
     
       Bogatin, E., "Signal Integrity Simplified", 3rd ed., Pearson, 2018.
     
       NOTE: Pozar's "Microwave Engineering" 4th ed. Table 4.2 (p.192) does
       NOT include G-parameters.  Algorithm inverts G per frequency to get
       H, then calls h2s (see h2s.m).

     See also: s2g, h2s, s2h.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 72
Convert 2-port G-parameters (inverse hybrid parameters) to S-parameters.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
h2s


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1099
 -- Function File: S = h2s (H)
 -- Function File: S = h2s (H, Z0)
     Convert 2-port H-parameters (hybrid parameters) to S-parameters.

     H must be a 2x2xK complex array.  Z0 is the reference impedance (scalar,
     default 50).  Returns a 2x2xK S-parameter array.  This is the inverse of
     ‘s2h’.

     *Algorithm*: Computed via Z-parameters:
       Z11 = (H11*H22 - H12*H21) / H22 = det(H) / H22
       Z12 =  H12 / H22
       Z21 = -H21 / H22
       Z22 =  1   / H22
       S   = z2s(Z, z0)

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Chapter 1, Section 1.2 (p.16): H-parameter definition.
         H-to-Z conversion via 2x2 matrix partitioning, then z2s.
     
       Bogatin, E., "Signal Integrity Simplified", 3rd ed., Pearson, 2018.
     
       NOTE: Pozar's "Microwave Engineering" 4th ed. Table 4.2 (p.192) does
       NOT include H-parameters.  The algorithm uses Z-parameters as an
       intermediate (see z2s.m for Z-to-S references).

     See also: s2h, g2s, z2s.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 64
Convert 2-port H-parameters (hybrid parameters) to S-parameters.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 4
ifft


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1333
 -- Function File: Y = ifft (X)
 -- Function File: Y = ifft (X, N)
 -- Function File: Y = ifft (X, N, DIM)
 -- Function File: Y = ifft (X, 'symmetric')
 -- Function File: Y = ifft (X, N, 'symmetric')
 -- Function File: Y = ifft (X, N, DIM, 'symmetric')
     Inverse discrete Fourier transform with optional MATLAB-compatible
     ‘'symmetric'’ flag.

     *Form 1* (no ‘'symmetric'’ flag): delegates directly to Octave's built-in
     ‘ifft’ with no overhead beyond a one-pass scan of ‘varargin’.

     *Form 2* (with the literal string ‘'symmetric'’ in any argument position):
     treats the input as conjugate-symmetric and returns a real-valued result,
     matching the behaviour of MATLAB's ‘ifft (X, 'symmetric')’.  Implemented as
     ‘real (builtin ('ifft', X, ...))’ with the flag stripped.

     This shim exists because Octave's built-in ‘ifft’ does not accept the
     ‘'symmetric'’ keyword and throws ‘"invalid conversion from string to real
     scalar"’ when given one.  The IEEE P370 MATLAB reference (e.g.
     ‘IEEEP3702xThru.m’, ‘IEEEP370Zc2xThru.m’) uses the ‘'symmetric'’ form, so
     loading ‘rf’ lets that code run unmodified in Octave.

     See also ‘ifft_symmetric’ for a stand-alone real-ifft helper.

     See also: fft, ifft_symmetric, round.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 82
Inverse discrete Fourier transform with optional MATLAB-compatible ‘'symmetri...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
ifft_symmetric


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1127
 -- Function File: Y = ifft_symmetric (X)
 -- Function File: Y = ifft_symmetric (X, N)
     Compute the inverse FFT treating the input as conjugate-symmetric,
     returning a real-valued result.

     This is an Octave compatibility shim for MATLAB's ‘ifft(x, 'symmetric')’
     syntax, which is not supported in Octave.  The 'symmetric' flag in MATLAB
     forces the result to be real-valued by treating the input as if it were
     exactly conjugate-symmetric (even if numerical noise makes it slightly
     non-symmetric).

     The Octave-compatible equivalent is ‘real(ifft(x))’, which discards the
     imaginary part that arises from floating-point asymmetry.

     *Usage in IEEE P370*: The IEEE P370 MATLAB scripts (‘IEEEP3702xThru.m’,
     ‘IEEEP370Zc2xThru.m’, etc.)  call ‘ifft(makeSymmetric([dc; s]),
     'symmetric')’ to compute real-valued impulse responses from
     conjugate-symmetric spectra.  Replace these calls with
     ‘ifft_symmetric(makeSymmetric([dc; s]))’ for Octave compatibility.

     If N is given, the FFT length is N (zero-padded or truncated).

     See also: ifft.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
Compute the inverse FFT treating the input as conjugate-symmetric, returning ...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
renormsparams


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1831
 -- Function File: S_NEW = renormsparams (S, Z_NEW)
 -- Function File: S_NEW = renormsparams (S, Z_NEW, Z_OLD)
     Renormalize N-port S-parameters to a new reference impedance.

     S is an NxNxK complex array of S-parameters referenced to Z_OLD (scalar,
     default 50 ohms).  Returns S-parameters referenced to Z_NEW (scalar, in
     ohms).

     *Algorithm* (via Z-parameters):
       Z     = z_old * (I + S) * inv(I - S)
       S_new = (Z - z_new*I) * inv(Z + z_new*I)

     This is valid for N-port networks with uniform (scalar) reference
     impedance.  For per-port renormalization with different impedances at each
     port, see Pupalaikis Chapter 5 for the generalized bilinear transform.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Chapter 5, Section 5.1 "Basic Reference Impedance Transformation"
         (p.134): renormalization via Z intermediate:
           Z     = sqrt(Z0)*(I+S)*(I-S)^-1*Z0*sqrt(Z0)^-1
           S_new = sqrt(Z0')^-1*(Z-Z0')*(Z+Z0')^-1*sqrt(Z0')
         reduces to the uniform-Z0 form implemented here when the
         normalization factor is uniform.
     
       Pozar, D.M., "Microwave Engineering", 4th ed., Wiley, 2012.
         Section 4.3, Eq. 4.44-4.45 (p.181): the S<->Z relations used as
         the intermediate step in renormalization.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.6 "Changing the Reference Impedance" (p.399).
     
       Resso, M. and Bogatin, E., "Signal Integrity Characterization
         Techniques", IEC, 2009.  Renormalization from measurement
         reference impedance to system impedance.

     See also: s2z, z2s, sparameters.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 61
Renormalize N-port S-parameters to a new reference impedance.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 7
rfparam


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 540
 -- Function File: V = rfparam (S, I, J)
     Extract a single S-parameter element from a sparameters struct.

     Returns a Kx1 column vector of the SIJ element over all K frequency points,
     where I and J are 1-indexed port numbers.

     Provides the same calling signature as MATLAB RF Toolbox's ‘rfparam’ so
     that code written for either environment runs unmodified.  Equivalent to
     ‘squeeze(s.Parameters(i,j,:))’.

          s21 = rfparam(s, 2, 1);   % extract S21 over all frequencies

     See also: sparameters.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
Extract a single S-parameter element from a sparameters struct.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5
round


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 809
 -- Function File: Y = round (X)
 -- Function File: Y = round (X, N)
     Round to nearest integer, or to N decimal places.

     *Form 1*: ‘round(x)’ — identical to Octave's built-in ‘round’.  Delegates
     directly to the built-in with no overhead.

     *Form 2*: ‘round(x, n)’ — MATLAB-compatible syntax that rounds X to N
     decimal places.  For example, ‘round(3.456, 2)’ returns ‘3.46’.  Negative N
     rounds to the left of the decimal point: ‘round(1234, -2)’ returns ‘1200’.

     This shim exists because Octave's built-in ‘round’ (as of 11.1) does not
     accept a second argument.  IEEE P370 TG3 code (‘qualityCheck.m’) uses
     ‘round(x, n)’, so this function enables that code to run unmodified in
     Octave.

     See also: floor, ceil, fix.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 49
Round to nearest integer, or to N decimal places.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
s2abcd


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1727
 -- Function File: A = s2abcd (S)
 -- Function File: A = s2abcd (S, Z0)
     Convert 2-port S-parameters to ABCD (chain/transmission) parameters.

     S must be a 2x2xK complex array.  Z0 is the reference impedance in ohms
     (scalar, default 50).  Returns a 2x2xK ABCD array.

     The ABCD matrix is defined by:
       [V1]   [A  B] [ V2]
       [I1] = [C  D] [-I2]
     where the sign convention is current flowing INTO port 1 and OUT OF port 2.

     *Conversion formulas:*
       d  = 2 * S21                   (common denominator)
     
       A  = ((1+S11)(1-S22) + S12*S21) / d
       B  = z0 * ((1+S11)(1+S22) - S12*S21) / d
       C  = (1/z0) * ((1-S11)(1-S22) - S12*S21) / d
       D  = ((1-S11)(1+S22) + S12*S21) / d

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Section 3.4.6 "ABCD Parameters In Terms Of S-Parameters",
         Table 3.7 (p.61): ABCD from S — matches this implementation
         element-by-element.
     
       Pozar, D.M., "Microwave Engineering", 4th ed., Wiley, 2012.
         Section 4.4, Eq. 4.69 (p.189): ABCD definition
           V1 = A*V2 + B*I2,  I1 = C*V2 + D*I2
         (sign convention: I2 flows OUT of port 2 for cascading).
         Table 4.2 (p.192): 2-port S-to-ABCD conversion.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.3 "ABCD Parameters" (p.382).
     
       Resso, M. and Bogatin, E., "Signal Integrity Characterization
         Techniques", IEC, 2009.  ABCD in the context of transmission-line
         cascades.

     See also: abcd2s, s2t, s2z.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
Convert 2-port S-parameters to ABCD (chain/transmission) parameters.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
s2g


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1359
 -- Function File: G = s2g (S)
 -- Function File: G = s2g (S, Z0)
     Convert 2-port S-parameters to G-parameters (inverse hybrid parameters).

     S must be a 2x2xK complex array.  Z0 is the reference impedance (scalar,
     default 50).  Returns a 2x2xK G-parameter array.

     G-parameters are the matrix inverse of H-parameters: G = inv(H). They are
     defined by:
       [I1]   [G11  G12] [V1]
       [V2] = [G21  G22] [I2]
     G11 has units of siemens, G22 has units of ohms.

     *Algorithm*: G = inv(H) for each frequency slice:
       H   = s2h(S, z0)
       G11 =  H22 / det(H)
       G12 = -H12 / det(H)
       G21 = -H21 / det(H)
       G22 =  H11 / det(H)

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Chapter 1, Section 1.2 "Network Parameter Models of Circuit
         Elements" (p.16): G-parameter definition as the inverse of the
         H-parameter relation.
     
       Bogatin, E., "Signal Integrity Simplified", 3rd ed., Pearson, 2018.
         Chapter "S-Parameters and Other Parameter Sets".
     
       NOTE: Pozar's "Microwave Engineering" 4th ed. Table 4.2 (p.192)
       does NOT include G-parameters.  The algorithm goes via H-parameters
       (see s2h.m) and inverts per frequency.

     See also: g2s, s2h, h2s.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 72
Convert 2-port S-parameters to G-parameters (inverse hybrid parameters).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
s2h


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1651
 -- Function File: H = s2h (S)
 -- Function File: H = s2h (S, Z0)
     Convert 2-port S-parameters to H-parameters (hybrid parameters).

     S must be a 2x2xK complex array.  Z0 is the reference impedance (scalar,
     default 50).  Returns a 2x2xK H-parameter array.

     H-parameters are defined by:
       [V1]   [H11  H12] [I1]
       [I2] = [H21  H22] [V2]
     H11 has units of ohms, H22 has units of siemens, H12 and H21 are
     dimensionless.

     *Algorithm*: Computed via Z-parameters as an intermediate:
       Z   = s2z(S, z0)
       H11 = det(Z) / Z22 = (Z11*Z22 - Z12*Z21) / Z22
       H12 =  Z12 / Z22
       H21 = -Z21 / Z22
       H22 =  1   / Z22

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Chapter 1, Section 1.2 "Network Parameter Models of Circuit
         Elements" (p.16): H-parameter definition
           V1 = H11*I1 + H12*V2,  I2 = H21*I1 + H22*V2.
         Z-to-H conversion via 2x2 matrix partitioning (standard linear
         algebra, as used here).
     
       Bogatin, E., "Signal Integrity Simplified", 3rd ed., Pearson, 2018.
         Chapter "S-Parameters and Other Parameter Sets" — SI-practitioner
         perspective on hybrid (H) parameters and their use in transistor
         models.
     
       NOTE: Pozar's "Microwave Engineering" 4th ed. Table 4.2 (p.192)
       covers only S, Z, Y, and ABCD parameters — it does NOT include
       H-parameters.  Pozar §4.3 (Z-parameters, p.174-181) provides the
       intermediate used by this implementation.

     See also: h2s, s2g, s2z, s2abcd.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 64
Convert 2-port S-parameters to H-parameters (hybrid parameters).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5
s2scc


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1263
 -- Function File: SCC = s2scc (S)
 -- Function File: SCC = s2scc (S, PORTORDER)
     Extract the common-mode sub-block from a 4-port single-ended S-parameter
     matrix.

     S is a 4x4xK complex array.  PORTORDER is ‘[D+1, D-1, D+2, D-2]’
     (1-indexed).  Returns a 2x2xK array of common-mode S-parameters (Scc).  The
     reference impedance for Scc is z0/2 (25 ohms for z0=50).

     Scc is the bottom-right 2x2 block of the full mixed-mode matrix.  See
     ‘s2sdd’ for the mode transformation algorithm.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Chapter 7, Section 7.3 "Differential Signaling" (p.194):
         common-mode voltage V_C = (V_p + V_n)/sqrt(2) for the standard
         mixed-mode converter, Eq. 7.25 (p.197).
         Section 7.3.2 (p.199): Scc is the common-mode sub-block of the
         mixed-mode matrix, with reference impedance Z0/2.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Chapter 7 "Differential Signaling" (p.297).
         Section 9.2.7 "Multimode S-Parameters" (p.400).

     See also: s2sdd, smm2s, s2smm.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
Extract the common-mode sub-block from a 4-port single-ended S-parameter matr...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5
s2sdd


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2012
 -- Function File: SDD = s2sdd (S)
 -- Function File: SDD = s2sdd (S, PORTORDER)
     Extract the differential-mode sub-block from a 4-port single-ended
     S-parameter matrix.

     S is a 4x4xK complex array of single-ended S-parameters.  PORTORDER is a
     1x4 vector of 1-indexed port numbers specifying the differential pair
     assignment: ‘[D+1, D-1, D+2, D-2]’.  Returns a 2x2xK array of
     differential-mode S-parameters (Sdd).

     The reference impedance for Sdd is 2*z0 (100 ohms for z0=50).

     *Algorithm:*
       Reorder columns/rows of S by portorder (puts pairs in [D+1,D-1,D+2,D-2] order)
       Apply mode transformation M = (1/sqrt(2)) * [ 1 -1  0  0 ]
                                                    [ 0  0  1 -1 ]
                                                    [ 1  1  0  0 ]
                                                    [ 0  0  1  1 ]
       S_mm = M * S_reordered * M^H (M is unitary)
       Sdd  = S_mm(1:2, 1:2, :)   (top-left block)

     *Port ordering convention:* The output rows/columns are [d_pair1, d_pair2],
     i.e., the output is the 2-port differential S-parameter matrix of the
     differential signal path.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Chapter 7, Section 7.3 "Differential Signaling" (p.194):
         definition of differential-mode voltage V_D = V_p - V_n.
         Section 7.3.2 (p.199): mixed-mode S-parameter matrix with Sdd
         as the differential-mode sub-block, ref impedance 2*Z0.
         Eq. 7.24-7.27 (p.197), Fig. 7.7: standard mixed-mode converter
         with 1/sqrt(2) normalization (the M matrix used here).
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Chapter 7 "Differential Signaling" (p.297).
         Section 9.2.7 "Multimode S-Parameters" (p.400).

     See also: s2scc, smm2s, s2smm, snp2smp.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
Extract the differential-mode sub-block from a 4-port single-ended S-paramete...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5
s2smm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2031
 -- Function File: S_MM = s2smm (S)
 -- Function File: S_MM = s2smm (S, PORTORDER)
 -- Function File: [SDD, SDC, SCD, SCC] = s2smm (...)
     Convert a 4-port single-ended S-parameter matrix to the full mixed-mode
     matrix.

     S is a 4x4xK complex array.  PORTORDER is ‘[D+1,D-1,D+2,D-2]’ (1-indexed).
     Returns a 4x4xK mixed-mode S-parameter matrix where the row/column ordering
     is ‘[d_pair1, d_pair2, c_pair1, c_pair2]’.

     The blocks are:
       S_mm = [ Sdd  Sdc ]   rows/cols: [d1,d2,c1,c2]
              [ Scd  Scc ]

     *Algorithm:*
       Reorder S by portorder (rows and cols)
       S_mm = M * S_reordered * M^H
       M = (1/sqrt(2)) * [ 1 -1  0  0 ]   <- differential pair 1
                         [ 0  0  1 -1 ]   <- differential pair 2
                         [ 1  1  0  0 ]   <- common-mode pair 1
                         [ 0  0  1  1 ]   <- common-mode pair 2

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Chapter 7, Section 7.3 "Differential Signaling" (p.194).
         Section 7.3.2 "Mixed-Mode S-Parameters" (p.199): 4-port
         single-ended to mixed-mode conversion.
         Eq. 7.24-7.27 (p.197), Fig. 7.7: "standard mixed-mode converter"
         with 1/sqrt(2) normalization:
           V_D = (V_p - V_n)/sqrt(2),  V_C = (V_p + V_n)/sqrt(2)
         — this is the M matrix used here.
         Fig. 7.8 (p.198): block diagram of the 4-port <-> mixed-mode
         conversion (mirrors this implementation's reorder + M*S*M^H).
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Chapter 7 "Differential Signaling" (p.297) — SI-engineering
         perspective on mode conversion and differential crosstalk.
         Section 9.2.7 "Multimode S-Parameters" (p.400) — full
         mixed-mode matrix derivation from single-ended 4-port.

     See also: smm2s, s2sdd, s2scc.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 79
Convert a 4-port single-ended S-parameter matrix to the full mixed-mode matrix.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
s2t


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1575
 -- Function File: T = s2t (S)
     Convert 2-port S-parameters to T-parameters (chain scattering parameters).

     S must be a 2x2xK complex array where K is the number of frequency points.
     Returns a 2x2xK array of T-parameters.

     *Conversion formulas:*
       T11 =  1   / S21
       T12 = -S22 / S21
       T21 =  S11 / S21
       T22 = -(S11*S22 - S12*S21) / S21 = -det(S) / S21

     *Convention:* T-parameter element ordering follows Pupalaikis (Cambridge,
     2020) and is compatible with MATLAB RF Toolbox, so code using ‘s2t’ and
     ‘t2s’ produces identical results in both.

     *Cascade property:* For two 2-port networks in series, ‘T_cascade = T1 *
     T2’.  This is the mathematical basis for ‘cascadesparams’ and
     ‘deembedsparams’.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.
         Section 3.6 "T-Parameters", Eq. 3.21 (p.65).
         NOTE: Pupalaikis presents two equivalent element orderings for
         the T-matrix (his Eq. 3.32 vs the convention used here).  This
         implementation uses the ordering that is compatible with MATLAB
         RF Toolbox.  Both orderings are related by a 180-degree rotation
         and the cascade property T1*T2 holds identically in either.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.4 "Cascading S-Parameters" (p.390).

     See also: t2s, cascadesparams, deembedsparams.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 74
Convert 2-port S-parameters to T-parameters (chain scattering parameters).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
s2y


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1386
 -- Function File: Y = s2y (S)
 -- Function File: Y = s2y (S, Z0)
     Convert N-port S-parameters to Y-parameters (admittance matrix).

     S is an NxNxK complex array of S-parameters.  Z0 is the reference impedance
     in ohms (scalar, default 50).  Returns an NxNxK array of Y-parameters
     (units: siemens).

     *Conversion formula (N-port, uniform Z0):*
       Y = (1/z0) * (I - S) * inv(I + S)
     where I is the NxN identity matrix.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Section 3.4.4 "Y-Parameters In Terms Of S-Parameters",
         Table 3.5 (p.59): Y = (1/Z0) * (I - S) * (I + S)^-1 — matches
         this implementation exactly for the uniform-Z0 case.
     
       Pozar, D.M., "Microwave Engineering", 4th ed., Wiley, 2012.
         Section 4.2, Eq. 4.26-4.27 (p.175): [I] = [Y][V]; [Y] = [Z]^-1
         defines Y-parameters.  Table 4.2 (p.192) gives the 2-port S-to-Y
         conversion.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.1 "Impedance Matrix" (p.355) — Y as the inverse of Z.
     
       Balanis, C.A., "Advanced Engineering Electromagnetics",
         2nd ed., Wiley, 2012.  Chapter 10.

     See also: y2s, s2z, s2abcd.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 64
Convert N-port S-parameters to Y-parameters (admittance matrix).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
s2z


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1603
 -- Function File: Z = s2z (S)
 -- Function File: Z = s2z (S, Z0)
     Convert N-port S-parameters to Z-parameters (impedance matrix).

     S is an NxNxK complex array of S-parameters.  Z0 is the reference impedance
     in ohms (scalar, default 50).  Returns an NxNxK array of Z-parameters.

     *Conversion formula (N-port, uniform Z0):*
       Z = z0 * (I + S) * inv(I - S)
     where I is the NxN identity matrix.

     For a 1-port network this reduces to the familiar expression: ‘Z =
     z0*(1+S11)/(1-S11)’.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Section 3.4.2 "Z-Parameters In Terms Of S-Parameters",
         Table 3.3 (p.56): Z = (I + S) * inv(I - S) * Z0 — matches this
         implementation exactly for the uniform-Z0 case.
     
       Pozar, D.M., "Microwave Engineering", 4th ed., Wiley, 2012.
         Section 4.3, Eq. 4.45 (p.181): [Z] = ([U] + [S]) * ([U] - [S])^-1
         (normalized, Z0=1).  Table 4.2 (p.192) gives the 2-port S-to-Z
         conversion with explicit Z0.
         Section 4.2, Eq. 4.25 (p.175): [V] = [Z][I] defines Z-parameters.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.1 "Impedance Matrix" (p.355).
     
       Balanis, C.A., "Advanced Engineering Electromagnetics",
         2nd ed., Wiley, 2012.  Chapter 10: electromagnetic first-principles
         derivation of the impedance matrix.

     See also: z2s, s2y, s2abcd.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
Convert N-port S-parameters to Z-parameters (impedance matrix).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5
smm2s


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1499
 -- Function File: S = smm2s (SDD, SDC, SCD, SCC, PORTORDER)
     Convert mixed-mode sub-matrices back to a 4-port single-ended S-parameter
     matrix.

     Inputs are 2x2xK arrays:
        • SDD — differential-differential block
        • SDC — differential-to-common-mode coupling
        • SCD — common-to-differential-mode coupling
        • SCC — common-common block
     PORTORDER is ‘[D+1,D-1,D+2,D-2]’ (1-indexed, same as in ‘s2smm’).

     Returns a 4x4xK single-ended S-parameter array.  This is the inverse of
     ‘s2smm’.

     *Algorithm:*
       Assemble S_mm = [Sdd Sdc; Scd Scc]
       S_reordered   = M^H * S_mm * M   (M is unitary: M^H = inv(M))
       S             = inverse port reordering (undo portorder permutation)

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Chapter 7, Section 7.3.2 "Mixed-Mode S-Parameters" (p.199).
         Eq. 7.24-7.27 (p.197): standard mixed-mode converter with
         1/sqrt(2) normalization.  M is unitary (M^H = inv(M)), so the
         inverse transform is S_reordered = M^H * S_mm * M.
         Fig. 7.8(b) (p.198): mixed-mode to single-ended block diagram.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Chapter 7 (p.297); Section 9.2.7 "Multimode S-Parameters" (p.400).

     See also: s2smm, s2sdd, s2scc.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
Convert mixed-mode sub-matrices back to a 4-port single-ended S-parameter
mat...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 7
snp2smp


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1030
 -- Function File: S_OUT = snp2smp (S, PORTORDER)
 -- Function File: S_OUT = snp2smp (S, Z0, PORTORDER, Z0_TERM)
     Reorder the ports of an N-port S-parameter matrix.

     *Form 1* (octave-rf native): ‘snp2smp(S, portorder)’ — pure row/column
     permutation.

     *Form 2* (MATLAB RF Toolbox compatible): ‘snp2smp(S, z0, portorder,
     z0_term)’ — the Z0 and Z0_TERM arguments are accepted for compatibility but
     are not used when they are equal scalars (the typical matched-termination
     case).

     S is an NxNxK complex array.  PORTORDER is a 1xN (or 1xM, M<=N) vector of
     1-indexed port numbers specifying the new port ordering.  Returns an NxNxK
     (or MxMxK) array with rows and columns permuted.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.
         Chapter 3, Section 3.1 (p.41): port numbering convention.
         Port reorder is P * S * P^T for a permutation matrix P.

     See also: s2smm, smm2s.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 50
Reorder the ports of an N-port S-parameter matrix.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
sparameters


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1518
 -- Function File: S = sparameters (FILENAME)
 -- Function File: S = sparameters (PARAMS, FREQ)
 -- Function File: S = sparameters (PARAMS, FREQ, Z0)
 -- Function File: S = sparameters (S_OBJ, Z0_NEW)
     Create an S-parameter object (struct) from a Touchstone file, from raw
     arrays, or renormalize an existing one.

     *Form 1* (MATLAB compatible): ‘sparameters(filename)’ reads a Touchstone
     file (.s1p, .s2p, .s4p, etc.)  and returns the S-parameter struct.  Uses
     the bundled ‘fromtouchn’ reader.  Reference impedance is read from the
     Touchstone header (defaults to 50 ohms).

     *Form 2*: ‘sparameters(params, freq)’ creates an S-parameter object from a
     raw NxNxK parameter array and a Kx1 frequency vector.  Reference impedance
     defaults to 50 ohms.

     *Form 3*: ‘sparameters(params, freq, z0)’ creates an object with reference
     impedance Z0 (scalar, in ohms).  If Z0 != 50, the S-parameters are
     renormalized to a 50-ohm reference before storing.

     *Form 4*: ‘sparameters(s_obj, z0_new)’ renormalizes an existing S-parameter
     object to new reference impedance Z0_NEW.

     The returned struct has four fields (matching MATLAB RF Toolbox):
        • ‘Parameters’ -- NxNxK complex array
        • ‘Frequencies’ -- Kx1 column vector (Hz)
        • ‘Impedance’ -- reference impedance (scalar, ohms)
        • ‘NumPorts’ -- number of ports (integer)

     See also: rfparam, cascadesparams, deembedsparams, embedsparams.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
Create an S-parameter object (struct) from a Touchstone file, from raw arrays...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
t2s


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 929
 -- Function File: S = t2s (T)
     Convert 2-port T-parameters (chain scattering parameters) to S-parameters.

     T must be a 2x2xK complex array.  Returns a 2x2xK S-parameter array.  This
     is the inverse of ‘s2t’.

     *Conversion formulas:*
       S11 =  T21 / T11
       S12 =  (T11*T22 - T12*T21) / T11   =  det(T) / T11
       S21 =  1   / T11
       S22 = -T12 / T11

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.
         Section 3.6 "T-Parameters", Eq. 3.21 (p.65).
         Uses the element ordering compatible with MATLAB RF Toolbox
         (see s2t.m for the convention note).
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.4 "Cascading S-Parameters" (p.390).

     See also: s2t, cascadesparams, deembedsparams.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 74
Convert 2-port T-parameters (chain scattering parameters) to S-parameters.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
y2s


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1164
 -- Function File: S = y2s (Y)
 -- Function File: S = y2s (Y, Z0)
     Convert N-port Y-parameters (admittance matrix) to S-parameters.

     Y is an NxNxK complex array.  Z0 is the reference impedance in ohms
     (scalar, default 50).  Returns an NxNxK S-parameter array.  This is the
     inverse of ‘s2y’.

     *Conversion formula (N-port, uniform Z0):*
       S = (I - z0*Y) * inv(I + z0*Y)

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Section 3.4.3 "S-Parameters In Terms Of Y-Parameters",
         Table 3.4, Eq. 3.18 (p.57): S = (I + Z0*Y)^-1 * (I - Z0*Y) —
         matches this implementation exactly for the uniform-Z0 case.
     
       Pozar, D.M., "Microwave Engineering", 4th ed., Wiley, 2012.
         Section 4.2, Eq. 4.26-4.27 (p.175).  Table 4.2 (p.192): 2-port
         Y-to-S conversion.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.1 "Impedance Matrix" (p.355); Section 9.2.2 (p.358).

     See also: s2y, z2s, abcd2s.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 64
Convert N-port Y-parameters (admittance matrix) to S-parameters.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
z2s


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1391
 -- Function File: S = z2s (Z)
 -- Function File: S = z2s (Z, Z0)
     Convert N-port Z-parameters (impedance matrix) to S-parameters.

     Z is an NxNxK complex array.  Z0 is the reference impedance in ohms
     (scalar, default 50).  Returns an NxNxK S-parameter array.

     *Conversion formula (N-port, uniform Z0):*
       S = (Z - z0*I) * inv(Z + z0*I)
     where I is the NxN identity matrix.

     *Mathematical basis:*
       Pupalaikis, P.J., "S-Parameters for Signal Integrity",
         Cambridge University Press, 2020.  [PRIMARY]
         Section 3.4.1 "S-Parameters In Terms Of Z-Parameters",
         Table 3.2, Eq. 3.16 (p.55): S = (Z - Z0*I) * (Z + Z0*I)^-1 —
         matches this implementation exactly for the uniform-Z0 case.
     
       Pozar, D.M., "Microwave Engineering", 4th ed., Wiley, 2012.
         Section 4.3, Eq. 4.44 (p.181): [S] = ([Z] + [U])^-1 * ([Z] - [U])
         (normalized, Z0=1).  Table 4.2 (p.192) gives the 2-port Z-to-S
         conversion with explicit Z0.
     
       Hall, S.H. and Heck, H.L., "Advanced Signal Integrity for High-Speed
         Digital Designs", Wiley-IEEE Press, 2009.
         Section 9.2.1 "Impedance Matrix" (p.355); Section 9.2.2
         "Scattering Matrix" (p.358).
     
       Balanis, C.A., "Advanced Engineering Electromagnetics",
         2nd ed., Wiley, 2012.  Chapter 10.

     See also: s2z, z2y, z2abcd.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
Convert N-port Z-parameters (impedance matrix) to S-parameters.





