public ITwoPortNetwork Copy() { TwoPortNetwork copy = new TwoPortNetwork(); copy.p = new Complex[2, 2]; for (int row = 0; row < 2; row++) { for (int col = 0; col < 2; col++) { copy.p[row, col] = this.p[row, col]; } } copy.state = this.state; copy.Zo = this.Zo; return(copy); }
public void toS() { if (this.state == STATE.Z) //Conversion from Z to S Param. { for (int freq_ind = 0; freq_ind < this.freq.Count; freq_ind++) { //Copy those parameters. Complex[,] temp_params = MenialOperations.CopyMatrix <Complex>(this.p[freq_ind]); //Make a new temp object w/those parmeters. TwoPortNetwork temp_tpn = new TwoPortNetwork(temp_params, this.state, this.Zo); //Convert that new temp object (TwoPortNetwork at this frequency) to new parameters. temp_tpn.toS(); //Reassign into this object. this.p[freq_ind] = MenialOperations.CopyMatrix <Complex>(temp_tpn.p); } } this.state = STATE.S; }
public double ExtractTwoPortNetwork(double d_freq, out TwoPortNetwork tpn) { //Search for frequency that this.p holds which is closest to desired frequency being queried. //Return closest frequency found. double min_error = double.MaxValue; int min_error_ind = -1; //For each in this.freq. for (int n = 0; n < this.freq.Count; n++) { //If this freq is the closest we've seen to the desired frequency, move on. if (Math.Abs(this.freq[n] - d_freq) < min_error) { min_error = Math.Abs(this.freq[n] - d_freq); min_error_ind = n; } } tpn = new TwoPortNetwork(this.p[min_error_ind], this.state, this.Zo); return(this.freq[min_error_ind]); }