コード例 #1
0
        /// <summary>
        /// Cascades (embeds) a series of <see cref="NetworkParametersMatrix"/> between subsequently connected ports to render a single composite
        /// <see cref="NetworkParametersMatrix"/> defining the relationship between the ports of the first device and the ports of the final device.
        /// </summary>
        /// <remarks>Cascading is performed by first converting the input matrices to <see cref="TransferParametersMatrix"/> types, and then using
        /// matrix multiplication to combine into a single T-parameter matrix. This matrix is then converted back to the original parameter matrix type.</remarks>
        /// <param name="matrices">A list of matrices to be cascaded.</param>
        /// <returns>A single composite <see cref="NetworkParameter"/> describing the network from the ports of the first device to the ports of the final device.</returns>
        public static TMatrix Cascade <TMatrix>(IEnumerable <TMatrix> matrices) where TMatrix : NetworkParametersMatrix
        {
            if (matrices == null || !matrices.Any())
            {
                throw new ArgumentException("Argument cannot be null or empty", nameof(matrices));
            }

            using IEnumerator <NetworkParametersMatrix> enumer = matrices.GetEnumerator();
            enumer.MoveNext();

            NetworkParametersMatrix p1 = enumer.Current;

            while (enumer.MoveNext())
            {
                NetworkParametersMatrix p2 = enumer.Current;

                TransferParametersMatrix t1 = p1.ToTParameters();
                TransferParametersMatrix t2 = p2.ToTParameters();

                TransferParametersMatrix composite = t1 * t2;

                p1 = composite;
            }

            return(p1.ConvertParameterType <TMatrix>());
        }
コード例 #2
0
        /// <summary>
        /// Cascades (embeds) a series <see cref="NetworkParametersMatrix"/> objects for all common frequencies between subsequently connected ports to render a single composite
        /// <see cref="NetworkParametersCollection{TMatrix}"/> defining the relationship between the ports of the first device and the ports of the final device across frequency.
        /// </summary>
        /// <param name="collections">The array of <see cref="NetworkParametersCollection{TMatrix}"/> objects to cascade.</param>
        /// <returns>A new composite <see cref="NetworkParametersCollection{TMatrix}"/> describing the network from the ports of the first device to the ports of the final device across frequency.</returns>
        public static NetworkParametersCollection <T> Cascade <T>(params INetworkParametersCollection[] collections) where T : NetworkParametersMatrix
        {
            var allFrequencies = collections.SelectMany(c => c.Frequencies).Distinct();

            NetworkParametersCollection <T> collection = new NetworkParametersCollection <T>(collections[0].NumberOfPorts);

            foreach (var frequency in allFrequencies)
            {
                collection[frequency] = (T)NetworkParametersMatrix.Cascade(collections.Select(c => c[frequency]).ToList());
            }
            return(collection);
        }
コード例 #3
0
 /// <summary>
 /// Adds support for the ValueTuple deconstruction syntax for this object.
 /// </summary>
 public void Deconstruct(out double frequency, out NetworkParametersMatrix parameters)
 {
     frequency  = Frequency_Hz;
     parameters = Parameters;
 }
コード例 #4
0
 /// <summary>Creates a new <see cref="FrequencyParametersPair"/> associated a network parameters matrix and the measurement/derived frequency.</summary>
 /// <param name="frequency">The frequency in Hz.</param>
 /// <param name="parameters">The network parameters matrix.</param>
 public FrequencyParametersPair(double frequency, NetworkParametersMatrix parameters)
 {
     Frequency_Hz = frequency;
     Parameters   = parameters;
 }