00001 // connection.cc 00002 // SuperMix version 1.0 C++ source file 00003 // 00004 // Copyright (c) 1999 California Institute of Technology. 00005 // All rights reserved. 00006 // 00007 // Redistribution and use in source and binary forms for noncommercial 00008 // purposes are permitted provided that the above copyright notice and 00009 // this paragraph are duplicated in all such forms and that any 00010 // documentation and other materials related to such distribution and 00011 // use acknowledge that the software was developed by California 00012 // Institute of Technology. Redistribution and/or use in source or 00013 // binary forms is not permitted for any commercial purpose. Use of 00014 // this software does not include a permitted use of the Institute's 00015 // name or trademark for any purpose. 00016 // 00017 // DISCLAIMER: 00018 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT 00019 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR 00020 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET 00021 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 00022 // LICENSED PRODUCT, HOWEVER USED. IN NO EVENT SHALL CALTECH/JPL BE 00023 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO 00024 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC 00025 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF 00026 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN 00027 // FACT SHALL KNOW OF THE POSSIBILITY. THE USER BEARS ALL RISK 00028 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED 00029 // MATERIALS. 00030 // 00031 // Change history: 00032 // 11/11/98: Changed table access to new syntax 00033 // 9/22/98: Removed constructor for single nport, no connection 00034 // 9/16/98: Moved calculations out of constructor. Devices 00035 // need no longer be treated as temporary. They can 00036 // recalc themselves. 00037 // 8/25/98: optimized (obfuscated?) code 00038 // 7/3/98: added a new constructor: a single nport, no connections 00039 // 6/26/98: modified for sdata::size() 00040 // 12/19/97: modified for matmath classes 00041 00042 #include "connection.h" 00043 #include "error.h" 00044 00045 00046 //************************************************************** 00047 // intraconnection within a single device 00048 00049 connection::connection(nport & d, int p1, int p2) 00050 : dev1(d), dev2(*this), port1(p1), port2(p2), connection_type(INTRA) 00051 { 00052 int devsize = dev1.size(); 00053 00054 // Device should have at least 3 ports 00055 if(devsize < 3) 00056 error::fatal("Device must have at least 3 ports for intraconnection."); 00057 00058 // Make sure the ports exist before we connect them. 00059 if((port1 < 1) || (port1 > devsize) 00060 || (port2 < 1) || (port2 > devsize)) 00061 error::fatal("Illegal port index for intraconnection."); 00062 00063 // Create data for the new device with the appropriate number of ports. 00064 data.resize(devsize - 2); // o.k., since dev1.size() >= 3 00065 portmap = portArray(data.size()); 00066 00067 // Create the port map. 00068 // i is the index on the old device, a is the index for the new device. 00069 int a=0; 00070 for(int i=1; i<=devsize; ++i) 00071 if((i != port1) && (i != port2)) 00072 { 00073 ++a; 00074 portmap.set(a, dev1.get_port(i)); 00075 } 00076 } 00077 00078 void connection::calc_intra() 00079 { 00080 // We will access raw data since it's faster. 00081 register int k = port1; 00082 register int l = port2; 00083 00084 // Get the data from the device 00085 info = dev1.get_data_info(); 00086 const sdata& devdata = (info.noise && info.active && calc_noise) ? 00087 dev1.get_data() : dev1.get_data_S(); 00088 00089 int devdatasize = devdata.size(); 00090 data.set_znorm(devdata.get_znorm()); 00091 00092 register int j; // Inner loop index variable should be registered for speed. 00093 register int i; 00094 int a, b; 00095 00096 // Reduce the amount of pointer arithmetic in the loops. 00097 complex const *const *s = & devdata.S[0]; 00098 complex const *sk = s[k]; 00099 complex const *sl = s[l]; 00100 complex skl = 1.0 - sk[l]; 00101 complex slk = 1.0 - sl[k]; 00102 complex skk = sk[k]; 00103 complex sll = sl[l]; 00104 00105 complex denom = skl*slk - skk*sll; 00106 if (zabs(denom) < Tiny) denom = Tiny; 00107 denom = 1.0/denom; // We don't want to have to divide in inner loops. 00108 00109 complex x, num; 00110 00111 // Calculate S matrix 00112 a = 1; 00113 for(i=1; i<=devdatasize; ++i) if(i != k && i != l) 00114 { 00115 complex const *si = s[i]; 00116 complex sil = si[l]; 00117 complex sik = si[k]; 00118 complex tmp1 = sil*slk + sll*sik; 00119 complex tmp2 = sik*skl + skk*sil; 00120 b = 1; 00121 for(j=1; j<=devdatasize; ++j) if(j != k && j != l) 00122 { 00123 num = (sk[j] * tmp1) + (sl[j] * tmp2); 00124 data.S[a][b] = si[j] + (num*denom); 00125 ++b; 00126 } 00127 ++a; 00128 } 00129 00130 // Calculate C matrix 00131 if(calc_noise) { 00132 if(!info.noise) { 00133 // device is noiseless: 00134 data.C = 0.0; 00135 } 00136 else if(info.active) { 00137 // need the full noise matrix calculation: 00138 complex const *const *c = & devdata.C[0]; 00139 complex const *ck = c[k]; 00140 complex const *cl = c[l]; 00141 complex denom1 = zmagsq(denom); 00142 00143 a = 1; 00144 for(i=1; i<=devdatasize; ++i) if(i != k && i != l) { 00145 complex const *ci = c[i]; 00146 complex const *si = s[i]; 00147 complex sil = si[l]; 00148 complex sik = si[k]; 00149 complex tmp1 = sil*slk + sll*sik; 00150 complex tmp2 = sik*skl + skk*sil; 00151 b = 1; 00152 for(j=1; j<=devdatasize; ++j) if(j != k && j != l) { 00153 complex tmp3 = zconj(s[j][l]*slk+sll*s[j][k]); 00154 complex tmp4 = zconj(s[j][k]*skl+skk*s[j][l]); 00155 x = tmp1 * (ck[l]* tmp4 + ck[k]* tmp3); 00156 x += tmp2 * (cl[k]* tmp3 + cl[l]* tmp4); 00157 x *= denom1; 00158 x += ci[j]; 00159 x += (cl[j]* tmp2 + ck[j]* tmp1) * denom; 00160 x += (ci[l]* tmp4 + ci[k]* tmp3) * zconj(denom); 00161 data.C[a][b] = x; 00162 ++b; 00163 } 00164 ++a; 00165 } 00166 } 00167 00168 else { 00169 // passive noise calculation is sufficient: 00170 data.passive_noise(device::f, device::T); 00171 } 00172 } 00173 00174 // Calculate B (source) vector 00175 if(info.source) { 00176 complex const *const bs = & devdata.B[0]; 00177 a = 1; 00178 for(i=1; i<=devdatasize; ++i) if(i != k && i != l) 00179 { 00180 complex const *si = s[i]; 00181 x = bs[i]; 00182 x += bs[l]*(si[k]*skl+skk*si[l])*denom; 00183 x += bs[k]*(si[l]*slk+sll*si[k])*denom; 00184 data.B[a] = x; 00185 ++a; 00186 } 00187 } 00188 else 00189 data.B = 0.0; 00190 00191 // Finally set up normalizing impedance to device::Z0 (or 0, if input z_norm == 0) 00192 data.change_norm(device::Z0); 00193 00194 } 00195 00196 00197 //************************************************************** 00198 // interconnection between two devices 00199 00200 connection::connection(nport& d1, int p1, nport& d2, int p2) 00201 : dev1(d1), dev2(d2), port1(p1), port2(p2), connection_type(INTER) 00202 { 00203 // Since we access sizes often, store them locally 00204 int dev1size = dev1.size(); 00205 int dev2size = dev2.size(); 00206 00207 // Don't connect two one-ports. 00208 if((dev1size <= 1) && (dev2size <= 1)) 00209 error::fatal("Connecting two one-port devices yields a null matrix."); 00210 00211 // Make sure the ports exist before we connect them. 00212 if((port1 < 1) || (port1 > dev1size) 00213 || (port2 < 1) || (port2 > dev2size)) 00214 error::fatal("Illegal port index for interconnection."); 00215 00216 // Create data for the new device with the appropriate number of ports. 00217 data.resize(dev1size + dev2size - 2); 00218 portmap = portArray(data.size()); 00219 00220 // Create the port map. 00221 int a=0; 00222 int i; 00223 for(i=1; i<=dev1size; ++i) 00224 if(i != port1) 00225 { 00226 ++a; 00227 portmap.set(a, dev1.get_port(i)); 00228 } 00229 for(i=1; i<=dev2size; ++i) 00230 if(i != port2) 00231 { 00232 ++a; 00233 portmap.set(a, dev2.get_port(i)); 00234 } 00235 } 00236 00237 void connection::calc_inter() 00238 { 00239 00240 // We will access raw data since it's faster. 00241 register int k = port1; 00242 register int l = port2; 00243 sdata *pd1 = 0, *pd2 = 0; // we'll use these only if renormalization needed 00244 00245 // Get the data from dev1 and dev2 00246 const data_info & info1 = dev1.get_data_info(); 00247 const data_info & info2 = dev2.get_data_info(); 00248 const sdata& d1ref = (calc_noise && (info1.active || info2.active)) ? 00249 dev1.get_data() : dev1.get_data_S(); 00250 const sdata& d2ref = (calc_noise && (info1.active || info2.active)) ? 00251 dev2.get_data() : dev2.get_data_S(); 00252 00253 // set up normalizing impedance and the references data1 and data2 00254 data.set_znorm(device::Z0); 00255 if(d1ref.get_znorm() != device::Z0 && d1ref.get_znorm() != 0.0) 00256 pd1 = new sdata(d1ref, device::Z0); 00257 if(d2ref.get_znorm() != device::Z0 && d2ref.get_znorm() != 0.0) 00258 pd2 = new sdata(d2ref, device::Z0); 00259 00260 const sdata& data1 = (pd1) ? *pd1 : d1ref; 00261 const sdata& data2 = (pd2) ? *pd2 : d2ref; 00262 00263 // Since we access sizes often, store them locally 00264 int data1size = data1.size(); 00265 int data2size = data2.size(); 00266 00267 register int j; 00268 register int i; 00269 int a, b; 00270 00271 // Reduce the amount of pointer arithmetic in the loops. 00272 complex const *const *s = & data1.S[0]; 00273 complex const *const *t = & data2.S[0]; 00274 complex skk = s[k][k]; 00275 complex tll = t[l][l]; 00276 00277 complex denom = 1 - skk*tll; 00278 if (zabs(denom) < Tiny) denom = Tiny; 00279 denom = 1.0/denom; // We don't want to have to divide in inner loops. 00280 00281 complex x; 00282 00283 00284 // Calculate S matrix, broken up into 4 submatrices 00285 a = 1; 00286 for(i=1; i<=data1size; ++i) if(i != k) 00287 { 00288 b = 1; 00289 for(j=1; j<=data1size; ++j) if(j != k) 00290 { 00291 data.S[a][b] = s[i][j] + s[k][j]*tll*s[i][k]*denom; 00292 ++b; 00293 } 00294 ++a; 00295 } 00296 00297 a = data1size; 00298 for(i=1; i<=data2size; ++i) if(i != l) 00299 { 00300 b = data1size; 00301 for(j=1; j<=data2size; ++j) if(j != l) 00302 { 00303 data.S[a][b] = t[i][j] + t[l][j]*skk*t[i][l]*denom; 00304 ++b; 00305 } 00306 ++a; 00307 } 00308 00309 a = 1; 00310 for(i=1; i<=data1size; ++i) if(i != k) 00311 { 00312 b = data1size; 00313 for(j=1; j<=data2size; ++j) if(j != l) 00314 { 00315 data.S[a][b] = t[l][j]*s[i][k]*denom; 00316 ++b; 00317 } 00318 ++a; 00319 } 00320 00321 a = data1size; 00322 for(i=1; i<=data2size; ++i) if(i != l) 00323 { 00324 b = 1; 00325 for(j=1; j<=data1size; ++j) if(j != k) 00326 { 00327 data.S[a][b] = s[k][j]*t[i][l]*denom; 00328 ++b; 00329 } 00330 ++a; 00331 } 00332 00333 // Calculate C matrix 00334 if(calc_noise) { 00335 if(!info1.noise && !info2.noise) { 00336 // both devices are noiseless 00337 data.C = 0.0; 00338 } 00339 else if(!info1.active && !info2.active) { 00340 // both devices are passive 00341 data.passive_noise(device::f, device::T); 00342 } 00343 // here at least one device has noise and at least one is active: 00344 else if(info1.noise && info2.noise) { 00345 // full noise matrix calculation required 00346 complex const *const *c = & data1.C[0]; 00347 complex const *const *u = & data2.C[0]; 00348 complex ckk = c[k][k]; 00349 complex ull = u[l][l]; 00350 00351 complex denom1 = zmagsq(denom); 00352 00353 a = 1; 00354 for(i=1; i<=data1size; ++i) if(i != k) 00355 { 00356 b = 1; 00357 for(j=1; j<=data1size; ++j) if(j != k) 00358 { 00359 x = c[i][j] + c[i][k]*zconj(s[j][k]*tll*denom); 00360 x += c[k][j]*s[i][k]*tll*denom; 00361 x += (ull + zmagsq(tll)* ckk) * 00362 s[i][k]*zconj(s[j][k])*denom1; 00363 data.C[a][b] = x; 00364 ++b; 00365 } 00366 ++a; 00367 } 00368 00369 a = data1size; 00370 for(i=1; i<=data2size; ++i) if(i != l) 00371 { 00372 b = data1size; 00373 for(j=1; j<=data2size; ++j) if(j != l) 00374 { 00375 x = u[i][j] + u[i][l]*zconj(t[j][l]*skk*denom); 00376 x += u[l][j]*t[i][l]*skk*denom; 00377 x += (ckk + zmagsq(skk)* ull) * 00378 t[i][l]*zconj(t[j][l])*denom1; 00379 data.C[a][b] = x; 00380 ++b; 00381 } 00382 ++a; 00383 } 00384 00385 a = 1; 00386 for(i=1; i<=data1size; ++i) if(i != k) 00387 { 00388 b = data1size; 00389 for(j=1; j<=data2size; ++j) if(j != l) 00390 { 00391 x = c[i][k]*zconj(t[j][l]*denom); 00392 x += u[l][j]*s[i][k]*denom; 00393 x += (tll*ckk + zconj(skk)*ull) * 00394 s[i][k]*zconj(t[j][l])*denom1; 00395 data.C[a][b] = x; 00396 ++b; 00397 } 00398 ++a; 00399 } 00400 00401 a = data1size; 00402 for(i=1; i<=data2size; ++i) if(i != l) 00403 { 00404 b = 1; 00405 for(j=1; j<=data1size; ++j) if(j != k) 00406 { 00407 x = u[i][l]*zconj(s[j][k]*denom); 00408 x += c[k][j]*t[i][l]*denom; 00409 x += (skk*ull + zconj(tll)*ckk) * 00410 t[i][l]*zconj(s[j][k])*denom1; 00411 data.C[a][b] = x; 00412 ++b; 00413 } 00414 ++a; 00415 } 00416 } 00417 else if(info1.noise) { 00418 // dev1 is the culprit; dev2 is noiseless 00419 complex const *const *c = & data1.C[0]; 00420 complex ckk = c[k][k]; 00421 00422 complex denom1 = zmagsq(denom); 00423 00424 a = 1; 00425 for(i=1; i<=data1size; ++i) if(i != k) 00426 { 00427 b = 1; 00428 for(j=1; j<=data1size; ++j) if(j != k) 00429 { 00430 x = c[i][j] + c[i][k]*zconj(s[j][k]*tll*denom); 00431 x += c[k][j]*s[i][k]*tll*denom; 00432 x += zmagsq(tll)*ckk*s[i][k]*zconj(s[j][k])*denom1; 00433 data.C[a][b] = x; 00434 ++b; 00435 } 00436 ++a; 00437 } 00438 00439 a = data1size; 00440 for(i=1; i<=data2size; ++i) if(i != l) 00441 { 00442 b = data1size; 00443 for(j=1; j<=data2size; ++j) if(j != l) 00444 { 00445 data.C[a][b] = ckk*t[i][l]*zconj(t[j][l])*denom1; 00446 ++b; 00447 } 00448 ++a; 00449 } 00450 00451 a = 1; 00452 for(i=1; i<=data1size; ++i) if(i != k) 00453 { 00454 b = data1size; 00455 for(j=1; j<=data2size; ++j) if(j != l) 00456 { 00457 x = c[i][k]*zconj(t[j][l]*denom); 00458 x += tll*ckk*s[i][k]*zconj(t[j][l])*denom1; 00459 data.C[a][b] = x; 00460 ++b; 00461 } 00462 ++a; 00463 } 00464 00465 a = data1size; 00466 for(i=1; i<=data2size; ++i) if(i != l) 00467 { 00468 b = 1; 00469 for(j=1; j<=data1size; ++j) if(j != k) 00470 { 00471 x = c[k][j]*t[i][l]*denom; 00472 x += zconj(tll)*ckk*t[i][l]*zconj(s[j][k])*denom1; 00473 data.C[a][b] = x; 00474 ++b; 00475 } 00476 ++a; 00477 } 00478 } 00479 else { 00480 // dev2 has the noise 00481 complex const *const *u = & data2.C[0]; 00482 complex ull = u[l][l]; 00483 00484 complex denom1 = zmagsq(denom); 00485 00486 a = 1; 00487 for(i=1; i<=data1size; ++i) if(i != k) 00488 { 00489 b = 1; 00490 for(j=1; j<=data1size; ++j) if(j != k) 00491 { 00492 data.C[a][b] = ull*s[i][k]*zconj(s[j][k])*denom1; 00493 ++b; 00494 } 00495 ++a; 00496 } 00497 00498 a = data1size; 00499 for(i=1; i<=data2size; ++i) if(i != l) 00500 { 00501 b = data1size; 00502 for(j=1; j<=data2size; ++j) if(j != l) 00503 { 00504 x = u[i][j] + u[i][l]*zconj(t[j][l]*skk*denom); 00505 x += u[l][j]*t[i][l]*skk*denom; 00506 x += zmagsq(skk)*ull*t[i][l]*zconj(t[j][l])*denom1; 00507 data.C[a][b] = x; 00508 ++b; 00509 } 00510 ++a; 00511 } 00512 00513 a = 1; 00514 for(i=1; i<=data1size; ++i) if(i != k) 00515 { 00516 b = data1size; 00517 for(j=1; j<=data2size; ++j) if(j != l) 00518 { 00519 x = u[l][j]*s[i][k]*denom; 00520 x += zconj(skk)*ull*s[i][k]*zconj(t[j][l])*denom1; 00521 data.C[a][b] = x; 00522 ++b; 00523 } 00524 ++a; 00525 } 00526 00527 a = data1size; 00528 for(i=1; i<=data2size; ++i) if(i != l) 00529 { 00530 b = 1; 00531 for(j=1; j<=data1size; ++j) if(j != k) 00532 { 00533 x = u[i][l]*zconj(s[j][k]*denom); 00534 x += skk*ull*t[i][l]*zconj(s[j][k])*denom1; 00535 data.C[a][b] = x; 00536 ++b; 00537 } 00538 ++a; 00539 } 00540 } 00541 } 00542 00543 // Calculate B (source) vector 00544 if(info1.source && info2.source) { 00545 // both dev1 and dev2 are sources 00546 complex const *bs = & data1.B[0]; 00547 complex const *bt = & data2.B[0]; 00548 a = 1; 00549 for(i=1; i<=data1size; ++i) if(i != k) 00550 { 00551 x = bs[i]; 00552 x += s[i][k]*(tll*bs[k]+bt[l])*denom; 00553 data.B[a] = x; 00554 ++a; 00555 } 00556 for(i=1; i<=data2size; ++i) if(i != l) 00557 { 00558 x = bt[i]; 00559 x += t[i][l]*(skk*bt[l]+bs[k])*denom; 00560 data.B[a] = x; 00561 ++a; 00562 } 00563 } 00564 else if(info1.source) { 00565 // only dev1 has source data 00566 complex const *bs = & data1.B[0]; 00567 a = 1; 00568 for(i=1; i<=data1size; ++i) if(i != k) 00569 { 00570 x = bs[i]; 00571 x += s[i][k]*tll*bs[k]*denom; 00572 data.B[a] = x; 00573 ++a; 00574 } 00575 for(i=1; i<=data2size; ++i) if(i != l) 00576 { 00577 x = t[i][l]*bs[k]*denom; 00578 data.B[a] = x; 00579 ++a; 00580 } 00581 } 00582 else if(info2.source) { 00583 // only dev2 is a source 00584 complex const *bt = & data2.B[0]; 00585 a = 1; 00586 for(i=1; i<=data1size; ++i) if(i != k) 00587 { 00588 x = s[i][k]*bt[l]*denom; 00589 data.B[a] = x; 00590 ++a; 00591 } 00592 for(i=1; i<=data2size; ++i) if(i != l) 00593 { 00594 x = bt[i]; 00595 x += t[i][l]*skk*bt[l]*denom; 00596 data.B[a] = x; 00597 ++a; 00598 } 00599 } 00600 else { 00601 // neither are sources 00602 data.B = 0.0; 00603 } 00604 00605 // release the memory pointed to by pd1 and/or pd2 00606 delete pd1; delete pd2; 00607 00608 } 00609 00610 00611 //************************************************************** 00612 // Join two devices without connecting any ports. 00613 00614 connection::connection(nport & d1, nport & d2) 00615 : dev1(d1), dev2(d2), connection_type(BLOCK) 00616 { 00617 // Since we access sizes often, store them locally 00618 int data1size = dev1.size(); 00619 int data2size = dev2.size(); 00620 00621 // Create data for this object of the appropriate size. 00622 data.resize(data1size + data2size); 00623 portmap = portArray(data.size()); 00624 00625 // Now fill in the portmap. 00626 int a=0; 00627 int i; 00628 for(i=1; i<=data1size; ++i) 00629 { 00630 ++a; 00631 portmap.set(a, dev1.get_port(i)); 00632 } 00633 for(i=1; i<=data2size; ++i) 00634 { 00635 ++a; 00636 portmap.set(a, dev2.get_port(i)); 00637 } 00638 } 00639 00640 void connection::calc_block() 00641 { 00642 sdata *pd1 = 0, *pd2 = 0; // we'll use these only if renormalization needed 00643 00644 // Get the data from the devices to be joined. 00645 const sdata& d1ref = (calc_noise) ? dev1.get_data() : dev1.get_data_S(); 00646 const sdata& d2ref = (calc_noise) ? dev2.get_data() : dev2.get_data_S(); 00647 00648 // set up normalizing impedance and the references data1 and data2 00649 data.set_znorm(device::Z0); 00650 if(d1ref.get_znorm() != device::Z0 && d1ref.get_znorm() != 0.0) 00651 pd1 = new sdata(d1ref, device::Z0); 00652 if(d2ref.get_znorm() != device::Z0 && d2ref.get_znorm() != 0.0) 00653 pd2 = new sdata(d2ref, device::Z0); 00654 00655 const sdata& data1 = (pd1) ? *pd1 : d1ref; 00656 const sdata& data2 = (pd2) ? *pd2 : d2ref; 00657 00658 // Since we access sizes often, store them locally 00659 int data1size = data1.size(); 00660 int data2size = data2.size(); 00661 00662 int a, b, i, j; 00663 00664 // Fill in the S and C matrices. 00665 a=0; 00666 b=0; 00667 for(i=1; i<=data1size; ++i) 00668 { 00669 ++a; 00670 b=0; 00671 for(j=1; j<=data1size; ++j) 00672 { 00673 ++b; 00674 data.S[a][b] = data1.S[i][j]; 00675 data.C[a][b] = data1.C[i][j]; 00676 } 00677 } 00678 00679 for(i=1; i<=data2size; ++i) 00680 { 00681 ++a; 00682 b=data1size; 00683 for(j=1; j<=data2size; ++j) 00684 { 00685 ++b; 00686 data.S[a][b] = data2.S[i][j]; 00687 data.C[a][b] = data2.C[i][j]; 00688 } 00689 } 00690 00691 // Now fill in the B vector. 00692 a=0; 00693 for(i=1; i<=data1size; ++i) 00694 { 00695 ++a; 00696 data.B[a] = data1.B.read(i); 00697 } 00698 for(i=1; i<=data2size; ++i) 00699 { 00700 ++a; 00701 data.B[a] = data2.B.read(i); 00702 } 00703 00704 // release the memory pointed to by pd1 and/or pd2 00705 delete pd1; delete pd2; 00706 00707 } 00708 00709 00710 //************************************************************** 00711 // get info/status; recalc interfaces: 00712 00713 const nport::data_info & connection::get_data_info() 00714 { 00715 info = dev1.get_data_info(); 00716 if(connection_type != INTRA) { 00717 const nport::data_info & info2 = dev2.get_data_info(); 00718 info.noise = info.noise || info2.noise; 00719 info.active = info.active || info2.active; 00720 info.source = info.source || info2.source; 00721 } 00722 return info; 00723 } 00724 00725 port connection::get_port(int index) 00726 { 00727 if((index > 0) && (index <= size())) 00728 return portmap.get(index); 00729 00730 // Subscript out of range, return default port. 00731 error::warning("Port index out of range."); 00732 return port(); 00733 } 00734 00735 int connection::get_port(port p) 00736 { 00737 00738 for(int i=1; i<=size(); ++i) 00739 if(portmap.get(i) == p) 00740 { 00741 return i; 00742 } 00743 00744 return 0; 00745 } 00746 00747 void connection::recalc() 00748 { 00749 calc_noise = true; 00750 switch(connection_type) 00751 { 00752 case INTER: 00753 calc_inter(); 00754 break; 00755 case INTRA: 00756 calc_intra(); 00757 break; 00758 case BLOCK: 00759 calc_block(); 00760 break; 00761 default: 00762 error::fatal("Unknown connection type in connection::recalc()"); 00763 } 00764 } 00765 00766 void connection::recalc_S() 00767 { 00768 calc_noise = false; 00769 switch(connection_type) 00770 { 00771 case INTER: 00772 calc_inter(); 00773 break; 00774 case INTRA: 00775 calc_intra(); 00776 break; 00777 case BLOCK: 00778 calc_block(); 00779 break; 00780 default: 00781 error::fatal("Unknown connection type in connection::recalc()"); 00782 } 00783 } 00784
Please direct comments and corrections to
supermix@submm.caltech.edu
Go to the supermix home page
Generated by
1.2.7