Hi Eric, In line with existing convention (check out PDL::IO::Misc), I’d suggest an exported “rs2p” function (and if you feel like it, a concomitant “ws2p” to write data – but there are already PDL::IO modules that only read, so no pressure).
I’d also suggest that while it’s handy for humans to have kHz, MHz, etc, to make your code (whose audience is the computer, not a human) scale the frequencies and not return the scaling factor. This implies a signature like: use PDL::IO::Touchstone; ($freqs, $matrix, $format, $z0) = rs2p('foo.s2p'); I confess I don’t know what z0 is here, but assume it’s valuable. Note in this model, the ndarrays come first, with less-important stuff after to allow only taking the most-important parameters and dropping the rest. For broadcasting: fundamentally, it’s just what you think should happen when you do addition (a scalar operation) to a vector (an n-element entity) or matrix (an n,m-element entity). Pthreading is just taking that and splitting it over several CPU/cores. There’s really nothing else to it. Do check out https://metacpan.org/pod/PDL::Broadcasting. These are just my ideas, anyone else who knows better or has others, please speak up :-) Best regards, Ed From: Eric Wheeler<mailto:p...@lists.ewheeler.net> Sent: 09 July 2022 08:03 To: Ed .<mailto:ej...@hotmail.com> Cc: Luis Mochán<mailto:moc...@fis.unam.mx>; Luis Mochan<mailto:moc...@icf.unam.mx>; pdl-general@lists.sourceforge.net<mailto:pdl-general@lists.sourceforge.net> Subject: RE: [Pdl-general] How do you create a set of cdouble matrices from (real, imag) values? > Eric, great work on getting something working! I’d recommend you put it > on CPAN (with suitable tests and test data, obviously) as > PDL::IO::Touchstone (if that last bit is the most meaningful label). Thanks! That is the plan, PDL::IO::Touchstone is probably right. A single touchstone file represents some N-port RF component (like a filter or capacitor would have 2 ports, power splitter is 3, etc). The ports are represented by an NxN "scattering parameter" matrix at each frequency where N is the number of ports. In addition to the matrix data, there are these informational values: # Hz - unit scale, MHz, GHz, etc. - string # S - type of matrix (Z, Y, G, H, ...) - string: a single charectar # DB - complex format representation in the file where ri=real/imag, ma=mag/angle, db=10log_10(mag)/angle - string # R 50 - charectaristic impedance at all ports - scalar int This could be read into simple PDLs and scalars as follows: ($freqs, $hz_scale, $matrix, $format, $z0) = PDL::IO::Touchstone::read('foo.s2p'); where N is the number of ports: - $freqs is a 1xN matrix - $matrix is a NxNxM matrix (M is the number of freqs) - and the rest are scalar Assuming PDL::IO::Touchstone::read() turns each record into a complex-valued matrix, the "$format" value of how the file was original is no longer useful, just noteworthy. Perhaps the user would want to write out to the same format or something. Questions: 1. In my existing code I've been scaling $freqs to Hz from whatever it came so the user can do what they like. If I scale it to Hz _and_ leave the $hz_scale term available then it could be confusing to the user, perhaps thinking they need to scale what I've already scaled. Should PDL::IO::Touchstone be lower-level than that and just return the frequency values verbatim and to let the user scale it based on $hz_scale if they wish, or should I scale it to Hz and drop the $hz_scale term? 2. Are there other PDL::IO best-practices to consider? > From: Luis Mochán > >Questions: > > > >Does PDL parallelize vector arithmetic somehow or do I need to do > >something further to enable threading? > > > >If so, how does it parallelize the work? > > > >Is there anything to consider when building PDL code so it scales for > >parallelization? > > > > I understand that in your case, the range of your row index, the 'broadcast' > dimension, would be split into > subranges and each fed to a different core. > Look at the documentation of PDL::ParallelCPU Thanks, I'll check out PDL::ParallelCPU and wrap my head around it, particularly the difference between broadcasting and pthreading. -Eric > > Regards, > Luis > -- > Enviado desde mi celular; disculpe la horrografía > > > _______________________________________________ > pdl-general mailing list > pdl-general@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pdl-general > > > > >
_______________________________________________ pdl-general mailing list pdl-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-general