diff options
Diffstat (limited to 'lib')
344 files changed, 5919 insertions, 33115 deletions
diff --git a/lib/77bit/77bit.txt b/lib/77bit/77bit.txt new file mode 100644 index 00000000..ef370c11 --- /dev/null +++ b/lib/77bit/77bit.txt @@ -0,0 +1,89 @@ +Starting with WSJT-X 2.0, the FT8 and MSK144 protocols convey a 77-bit +payload. For most purposes these bits are interpreted as 3 bits (i3) +for message type and 74 for user information. Any message type that +uses fewer than 74 information bits can assign the remaining bits to +define message subtypes. For example, Type i3=0 uses 71 information +bits and the remaining 3 bits, here called n3, define 8 possible +subtypes. + +---------------------------------------------------------------------------------- +i3.n3 Example message Bits Total Purpose +---------------------------------------------------------------------------------- +0.0 FREE TEXT MSG 71 71 Free text +0.1 K1ABC RR73; W9XYZ <KH1/KH7Z> -12 28 28 10 5 71 DXpedition Mode +0.2 PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 70 EU VHF contest +0.3 WA9XYZ KA1ABC R 16A EMA 28 28 1 4 3 7 71 ARRL Field Day +0.4 WA9XYZ KA1ABC R 32A EMA 28 28 1 4 3 7 71 ARRL Field Day +0.5 123456789ABCDEF012 71 71 Telemetry (18 hex) +0.6 K1ABC RR73; CQ W9XYZ EN37 28 28 15 71 Contesting +0.7 ... tbd + +1 WA9XYZ/R KA1ABC/R R FN42 28 1 28 1 1 15 74 Standard msg +2 PA3XYZ/P GM4ABC/P R JO22 28 1 28 1 1 15 74 EU VHF contest +3 TU; W9XYZ K1ABC R 579 MA 1 28 28 1 3 13 74 ARRL RTTY Roundup +4 <WA9XYZ> PJ4/KA1ABC RR73 12 58 1 2 1 74 Nonstandard calls +5 ... tbd +6 ... tbd +7 ... tbd +---------------------------------------------------------------------------------- +In case we need them, later: + +5 TU; W9XYZ K1ABC R 579 8 MA 1 28 28 1 3 6 7 74 CQ WW RTTY +6 TU; W9XYZ K1ABC R 579 MA 1 28 28 1 3 13 74 CQ WPX RTTY +---------------------------------------------------------------------------------- +NB: three 74-bit message types and two 71-bit message subtypes are still TBD. +---------------------------------------------------------------------------------- + +The 28-bit fields normally used for callsigns are configured rather +differently from before. + +Facts about the 28-bit integers used to encode standard callsigns: + 2^28 = 268,435,456 Available values + 37*36*10*27*27*27 = 262,177,560 Used for standard callsigns + ----------- + 6,257,896 Difference + 2^22 = 4,194,304 Used for 22-bit hash codes + ----------- + 2,063,592 available for CQ, CQ nnn, CQ xxxx, QRZ, ... + + +Further details on message types: +----------------------------------------------------------------------------- +i3.n3 +----------------------------------------------------------------------------- +0.0 Free text, up to 13 characters. + +0.1 DXpedition mode, as developed for KH1/KH7Z. + +0.2 Report, QSO serial number from 0001 to 4095, 6-character grid, and Roger + for EU VHF contests. + +0.3 ARRL Field Day exchange (1-16 transmitters). + +0.4 ARRL Field Day exchange (17-32 transmitters). + +0.5 Telemetry, 71 bits + +1. Two callsigns, Roger, and grid or report. Each callsign may have + an appended "/R" to indicate Rover status for NA VHF contests. + Either callsign may be nonstandard if enclosed in angle brackets, + for example <YW18FIFA>. + +2. Same as Type 1, but uses /P instead of /R. For European VHF contests. + +3. Standard message for ARRL RTTY Roundup. Optional "TU;" at + beginning to finish a previous QSO; then two standard callsigns, + optional "R", a 3-bit report (529 to 599), and 13 bits to indicate + US state, Canadian province/territory, or DX serial number from + 0001 to 7999. + +4. One hashed call or "CQ"; one compound or nonstandard call with up + to 11 characters; and (if not "CQ") an optional RRR, RR73, or 73. + +--------------------------------------------------------------------------- +The following are tentative and not included in first release. + +5. CQ WW RTTY - US/Can: RST CQZ state/prov R 579 5 NJ R1 r3 z6 u7 + DX: RST + CQzone R 559 15 R1 r3 z6 + +6. CQ WPX RTTY - RST + serial R 589 0013 R1 r3 n12 diff --git a/lib/77bit/CQ_messages.txt b/lib/77bit/CQ_messages.txt new file mode 100644 index 00000000..f131f9fb --- /dev/null +++ b/lib/77bit/CQ_messages.txt @@ -0,0 +1,12 @@ +CQ K1ABC FN42 +DE K1ABC FN42 +QRZ K1ABC FN42 +CQ AA K1ABC FN42 +CQ ZZ K1ABC FN42 +CQ 000 K1ABC FN42 +CQ 313 K1ABC FN42 +CQ 999 K1ABC FN42 +CQ AAA K1ABC FN42 +CQ ZZZ K1ABC FN42 +CQ AAAA K1ABC FN42 +CQ ZZZZ K1ABC FN42 diff --git a/lib/77bit/NewCode.txt b/lib/77bit/NewCode.txt new file mode 100644 index 00000000..99b3603e --- /dev/null +++ b/lib/77bit/NewCode.txt @@ -0,0 +1,49 @@ +i3 n3 isync Operating activity, Message Type +----------------------------------------------------------- + 0 0 1 Std QSO msg (bit 72=0) + 0 0 1 Free text (bit 72=1) + 0 1 1 Fox DXpedition msg with "RR73;" +----------------------------------------------------------- + 1 0 2 Std QSO msg + 0 1 2 Fox DXpedition msg with "RR73;" + 1 * 2 NA VHF contest + 2 * 2 EU VHF contest (Tx1, Tx6) + 0 2 2 EU VHF contest (Tx2, Tx3) + 0 3 2 ARRL Field Day (1-16 transmitters) + 0 4 2 ARRL Field Day (17-32 transmitters) + 3 * 2 ARRL RTTY Roundup + 4 * 2 Compound and non-standard calls +----------------------------------------------------------- +* ==> "don't care" (types i3=1,2,3,4 do not have subtypes) +----------------------------------------------------------- + +A. Required GUI Additions (after July 3): + + 1. Entry widgets for fixed parts of contest exchanges: comboBoxes + for ARRL section, US State/Canadian Province, number of + transmitters and entry Class for Field Day. + + 2. Spinner control for serial numbers: used for EU_VHF_Contest, + and for DX stations in RTTYroundup. + +B. Code near the end of GenStdMsgs(): + + 1. if(m_config.bNA_VHF_Contest()): do as with present checkbox + 2. if(m_config.bEU_VHF_Contest()): make EU_VHF messages + 3. if(m_config.bFieldDay()): make FD messages + 4. if(m_config.bRTTYroundup()): make RR messages + 5. if MyCall or DXcall is compound or nonstandard, make new msgs + +C. Code just before calling genft8_(): + + 1. m_i3=0, m_n3=0, m_isync=1 + 2. if(check m_config.bGenerate77()) m_isync=2 + 3. if msg is not an old-style standard msg, see if it's valid + as a 77-bit msg + 4. if NO: transmit as Free Text + if YES: set i3, n3, and isync=2 + +D. Auto-sequencer code + + 1. Probably lots of changes needed: details TBD, after we make the + new messages work with Auto-Seq off. diff --git a/lib/77bit/New_Features_WSJT-X_2.0.txt b/lib/77bit/New_Features_WSJT-X_2.0.txt new file mode 100644 index 00000000..55d5f3c7 --- /dev/null +++ b/lib/77bit/New_Features_WSJT-X_2.0.txt @@ -0,0 +1,263 @@ + New Features in WSJT-X 2.0 + September 17, 2018 + -------------------------- + +This document is an update to the white paper "Plans for WSJT-X +Version 2.0" that was publicly distributed on July 26, 2018. It +describes the most important enhancements in WSJT-X 2.0 relative to +version 1.9.1. + +A majority of new program features involve the FT8 and MSK144 +protocols. Both modes have been upgraded to use use 77-bit +information payloads rather than the 75 bits of the older FT8 protocol +or 72 bits of JT4, JT9, JT65, MSK144, and QRA64. Cyclic redundancy +checks (CRCs) that protect against false decodes have been increased +from 12 to 14 bits (FT8) and from 8 to 13 bits (MSK144). These +changes bring many benefits, including support of structured messages +optimized for the following special types of QSOs and exchanged +information: + +1. NA VHF Contest operation with full and transparent support of grid + locators and "/R" (Rover) callsigns + +2. EU VHF Contest operation with the exchange of 6-digit locators, QSO + serial numbers, and "/P" (portable) callsigns + +3. ARRL Field Day operation with standard Field Day exchanges such as + "6A SNJ" + +4. ARRL RTTY Roundup operation with standard contest exchanges such as + "579 NJ" or "559 0071" + +5. Compound and nonstandard callsigns (up tp 11 characters); no need + for distinctions about "Type 1" or "Type 2" prefixes/suffixes + +6. A special "telemetry" message format for exchange of arbitrary + information up to 71 bits + +7. All features of FT8 DXpedition mode, as in WSJT-X v1.9.1 + +Conveying more information in the same bandwidth, using the same +modulation scheme, necessarily means a higher code rate and less +energy per information bit. Nevertheless, the decoding threshold S/N +for the new FT8 is slightly lower than for the old version, because of +improvements in the decoding algorithm. Decoding threshold for MSK144 +is a fraction of a dB higher than before. Symbol rates and occupied +bandwidths for both modes are the same as before, and false-decode +rates are significantly lower. + +OTHER PROGRAM ENHANCEMENTS: WSJT-X 2.0 has several other new features +and capabilities. The WSPR decoder has significantly better +sensitivity, by about 1 dB. Color highlighting of decoded messages +provides worked-before status for callsigns, grid locators, and DXCC +entities on a "by band" basis. Color highlighting can also identify +stations that have (or have not) uploaded their logs to "Logbook of +the World" (LoTW) within the past year. (Recent information from LoTW +for this purpose can be downloaded from the ARRL web site.) + +WSJT-X 2.0 introduces no significant changes to any of the modes JT4, +JT9, JT65, QRA64, ISCAT, Echo, or FreqCal. + +IMPORTANT: For the convenience of beta-testers, the first and second +release candidates -- releases with "-rc1" or "-rc2" in their names -- +will have Rx and Tx capability for both the new FT8 protocol and the +older one. Starting with the third release candidate ("-rc3"), and in +the general-availability full release of WSJT-X 2.0, only the new +protocol will be supported. In contrast, the new MSK144 protocol +replaces the old one from the outset, without backward compatibility. +To minimize on-the-air confusion, it's important that users be aware +of these distinctions and the schedule for release of WSJT-X 2.0, as +detailed below. + +MESSAGE FORMATS: The following table shows examples of message formats +supported by the new FT8 and MSK144 protocols. Parameters i3 and n3 +(shown in the first column) are used in the software to define major +and minor 77-bit message types. + +---------------------------------------------------------------------------------- +i3.n3 Example Messages Comments +---------------------------------------------------------------------------------- + 0.0 TNX BOB 73 GL Free text + 0.1 K1ABC RR73; W9XYZ <KH1/KH7Z> -08 DXpedition Mode + 0.2 PA9XYZ 590003 IO91NP EU VHF Contest + 0.2 G4ABC/P R 570007 JO22DB EU VHF Contest + 0.3 K1ABC W9XYZ 6A WI ARRL Field Day + 0.3 W9XYZ K1ABC R 2B EMA ARRL Field Day + 0.5 123456789ABCDEF012 Telemetry (71 bits, 18 hex digits) + 1. CQ FD K1ABC FN42 ARRL Field Day + 1. CQ RU K1ABC FN42 ARRL RTTY Roundup + 1. CQ K1ABC FN42 + 1. CQ TEST K1ABC FN42 NA VHF Contest + 1. CQ TEST K1ABC/R FN42 NA VHF Contest + 1. K1ABC W9XYZ EN37 + 1. K1ABC W9XYZ -09 + 1. K1ABC W9XYZ R-17 + 1. K1ABC W9XYZ RRR + 1. K1ABC W9XYZ 73 + 1. K1ABC W9XYZ RR73 + 1. K1ABC/R W9XYZ EN37 NA VHF Contest + 1. K1ABC W9XYZ/R RR73 NA VHF Contest + 1. K1ABC/R W9XYZ/R RR73 NA VHF Contest + 1. <PJ4/K1ABC> W9XYZ Compound call + 1. W9XYZ <PJ4/K1ABC> 73 Compound call + 1. W9XYZ <YW18FIFA> -13 Nonstandard call + 1. <YW18FIFA> W9XYZ R+02 Nonstandard call + 1. W9XYZ <YW18FIFA> RRR Nonstandard call + 1. <YW18FIFA> W9XYZ RR73 Nonstandard call + 2. CQ G4ABC/P IO91 EU VHF contest + 2. G4ABC/P PA9XYZ JO22 EU VHF contest + 2. PA9XYZ G4ABC/P RR73 EU VHF contest + 3. K1ABC KA0DEF 559 MO ARRL RTTY Roundup + 3. K1ABC W9XYZ 579 WI ARRL RTTY Roundup + 3. KA1ABC G3AAA 529 0013 ARRL RTTY Roundup + 3. TU; KA0DEF K1ABC R 569 MA ARRL RTTY Roundup + 3. TU; K1ABC G3AAA R 559 0194 ARRL RTTY Roundup + 3. W9XYZ K1ABC R 589 MA ARRL RTTY Roundup + 4. CQ PJ4/K1ABC + 4. CQ YW18FIFA Nonstandard call + 4. <KA1ABC> YW18FIFA RR73 Nonstandard call + 4. <W9XYZ> PJ4/K1ABC RRR Nonstandard call + 4. <W9XYZ> YW18FIFA Nonstandard call + 4. <W9XYZ> YW18FIFA 73 Nonstandard call + 4. PJ4/K1ABC <W9XYZ> Nonstandard call + 4. PJ4/K1ABC <W9XYZ> 73 Nonstandard call + 4. YW18FIFA <W9XYZ> RRR Nonstandard call +---------------------------------------------------------------------------------- + +In the above list, callsigns enclosed in angle brackets (e.g., +<PJ4/K1ABC>, <YW18FIFA>) are transmitted as hash codes. They will be +displayed correctly by receiving stations that have copied the full +callsign without brackets in a previous transmissiion. Otherwise the +receiving software will display <...>. Hash collisions are possible +but should be rare, and extremely rare within a particular QSO. + +Some minimal message sequences that take advantage of the new 77-bit +formats are illustrated below. Model QSOs 1 and 2 are the same as +those used by the old FT8 and MSK144 protocols, and QSO number 3 is +the same as the existing FT8 DXpedition Mode. Model QSOs 4 through 9 +were not possible with the old protocols. + +---------------------------------------------------------------------------------- +1. Standard QSO +---------------------------------------------------------------------------------- +CQ K1ABC FN42 + K1ABC W9XYZ EN37 +W9XYZ K1ABC -11 + K1ABC W9XYZ R-09 +W9XYZ K1ABC RRR + K1ABC W9XYZ 73 + +---------------------------------------------------------------------------------- +2. Short-cycle QSO +---------------------------------------------------------------------------------- +CQ K1ABC FN42 + K1ABC W9XYZ -09 +W9XYZ K1ABC R-11 + K1ABC W9XYZ RR73 +W9XYZ K1ABC 73 + +---------------------------------------------------------------------------------- +3. FT8 DXpedition Mode +---------------------------------------------------------------------------------- +CQ KH1/KH7Z + KH7Z K1ABC FN42 +K1ABC KH7Z -12 + KH7Z K1ABC R-14 + KH7Z W9XYZ EN37 + ... possibly other callers ... +K1ABC RR73; W9XYZ <KH1/KH7Z> -08 + +---------------------------------------------------------------------------------- +4. ARRL Field Day +---------------------------------------------------------------------------------- +CQ FD K1ABC FN42 + K1ABC W9XYZ 6A WI +W9XYZ K1ABC R 2B EMA + K1ABC W9XYZ RR73 + +---------------------------------------------------------------------------------- +5. ARRL VHF Contests +---------------------------------------------------------------------------------- +CQ TEST K1ABC/R FN42 "/R" is optional + K1ABC/R W9XYZ EN37 on either callsign +W9XYZ K1ABC/R R FN42 + K1ABC/R W9XYZ RR73 + +---------------------------------------------------------------------------------- +6. ARRL RTTY Roundup +---------------------------------------------------------------------------------- +CQ TEST K1ABC FN42 + K1ABC W9XYZ 579 WI +W9XYZ K1ABC R 589 MA + K1ABC KA0DEF 559 MO +TU; KA0DEF K1ABC R 569 MA + KA1ABC G3AAA 529 0013 +TU; G3AAA K1ABC R 559 MA + +---------------------------------------------------------------------------------- +7. EU VHF Contest +---------------------------------------------------------------------------------- +CQ TEST G4ABC/P IO91 "/P" is optional + G4ABC/P PA9XYZ JO22 on either callsign +PA9XYZ 590003 IO91NP + G4ABC/P R 570007 JO22DB +PA9XYZ G4ABC/P RR73 + +---------------------------------------------------------------------------------- +8. Compound or nonstandard callsign calling CQ +---------------------------------------------------------------------------------- +CQ PJ4/K1ABC + PJ4/K1ABC <W9XYZ> +W9XYZ <PJ4/K1ABC> -11 + <PJ4/K1ABC> W9XYZ R-09 +<W9XYZ> PJ4/K1ABC RRR + PJ4/K1ABC <W9XYZ> 73 + +---------------------------------------------------------------------------------- +9. Compound or nonstandard callsign answering CQ +---------------------------------------------------------------------------------- +CQ W9XYZ EN37 + <W9XYZ> YW18FIFA +<YW18FIFA> W9XYZ -11 + W9XYZ <YW18FIFA> R-09 +YW18FIFA <W9XYZ> RRR + <W9XYZ> YW18FIFA 73 +---------------------------------------------------------------------------------- + + +RELEASE SCHEDULE: Candidate releases of WSJT-X 2.0 will have built-in +expiration dates after which they cannot be used. Target dates for +planned releases are as follows: + +September 17: -rc1 (expires Oct 31) +October 15: -rc2 (expires Nov 30) +November 12: -rc3 (expires Dec 31) +December 10: GA Full release of WSJT-X 2.0 + +WSJT-X 2.0-rc1 provides the first chance for beta testers to use the +new 77-bit messages. It supports the old (v1.9.1) FT8 protocol as +well as the new message types illustrated above. To avoid QRMing +legacy FT8 users with incompatible messages they can't decode, and to +help concentrate testing activity into a few sub-bands, we recommend +using the new FT8 capabilities on the 40- or 20-meter bands at dial +frequencies 7.078 or 14.078 MHz. These frequencies are offered as FT8 +alternatives on the drop-down frequency-selection control on the main +window. + +The new MSK144 is fully functional for QSOs between any two stations +using a WSJT-X v2.0 release. MSK144 is not backward compatible with +earlier program versions. Therefore during the testing period, +approximately Sept 17 through December 10, we recommend using the new +MSK144 capabilities on 50.380 MHz (IARU Region 1) or 50.280 (Regions 2 +and 3). By specific arrangement, or as soon as most regular users +have upgraded to a v2.0 release, MSK144 activity can be moved back to +50.360 (Region 1) or 50.260 (Regions 2 and 3). + +By design, our proposed release schedule will make WSJT-X 2.0 usable +for all relevant ARRL operating events and Eurpoean VHF contests after +January 1, 2019. + +Dates of relevant upcoming ARRL contests +---------------------------------------- +RTTY Roundup: January 5-6, 2019 +VHF Sweepstakes: January 19-21, 2019 diff --git a/lib/77bit/all28.txt b/lib/77bit/all28.txt new file mode 100644 index 00000000..2a6e2781 --- /dev/null +++ b/lib/77bit/all28.txt @@ -0,0 +1,40 @@ +<KH1/KH7Z> +<VP2E/KA1ABC> +5B1ABC +999ABC +9Y4AB +9Y4XYZ +A00A +A0A +A0AA +A0AAA +A0AAB +AA0AAA +CQ +CQ_000 +CQ_313 +CQ_999 +CQ_A +CQ_AAAA +CQ_AB +CQ_ABC +CQ_ABCD +CQ_DX +CQ_ZZZZ +DE +EI30T +HA70BAY +HB9GOLD +K1ABC +K1JT +KA0ABC +KA1ABC +KA1JT +KH1/KH7Z +QRZ +W2000XYZ +WB9XYZ +YB50ST +YW18FIFA +ZM90DX +ZS9YOTA diff --git a/lib/77bit/arrl_sec.txt b/lib/77bit/arrl_sec.txt new file mode 100644 index 00000000..b97b64f4 --- /dev/null +++ b/lib/77bit/arrl_sec.txt @@ -0,0 +1,83 @@ +AB +AK +AL +AR +AZ +BC +CO +CT +DE +EB +EMA +ENY +EPA +EWA +GA +GTA +IA +ID +IL +IN +KS +KY +LA +LAX +MAR +MB +MDC +ME +MI +MN +MO +MS +MT +NC +ND +NE +NFL +NH +NL +NLI +NM +NNJ +NNY +NT +NTX +NV +OH +OK +ONE +ONN +ONS +OR +ORG +PAC +PR +QC +RI +SB +SC +SCV +SD +SDG +SF +SFL +SJV +SK +SNJ +STX +SV +TN +UT +VA +VI +VT +WCF +WI +WMA +WNY +WPA +WTX +WV +WWA +WY diff --git a/lib/77bit/calls.txt b/lib/77bit/calls.txt new file mode 100644 index 00000000..c542c9b6 --- /dev/null +++ b/lib/77bit/calls.txt @@ -0,0 +1,5 @@ +KA1ABC +WB9XYZ +KH1/KH7Z +<KH1/KH7Z> +CQ DX K1ABC diff --git a/lib/77bit/calls1.txt b/lib/77bit/calls1.txt new file mode 100644 index 00000000..888b4555 --- /dev/null +++ b/lib/77bit/calls1.txt @@ -0,0 +1,21 @@ +<KH1/KH7Z> +<VP2E/KA1ABC> +K1ABC +WB9XYZ +KA1ABC +WB9XYZ +K1JT +KA1JT +5B1ABC +9Y4XYZ +9Y4AB +999ABC +ZM90DX +EI30T +ZS9YOTA +HA70BAY +HB9GOLD +YW18FIFA +YB50ST +WB2000XYZ +WB2000XYZABCD diff --git a/lib/77bit/calls2.txt b/lib/77bit/calls2.txt new file mode 100644 index 00000000..b1f48774 --- /dev/null +++ b/lib/77bit/calls2.txt @@ -0,0 +1,7 @@ +A0A +A00A +A0AA +A0AAA +KA0ABC +5B1ABC +9Y4XYZ diff --git a/lib/77bit/calls3.txt b/lib/77bit/calls3.txt new file mode 100644 index 00000000..69a81bb9 --- /dev/null +++ b/lib/77bit/calls3.txt @@ -0,0 +1,4 @@ +AA0AAA +A0AAA +A0AAB +A0AA diff --git a/lib/77bit/encode77.f90 b/lib/77bit/encode77.f90 new file mode 100644 index 00000000..987efc4f --- /dev/null +++ b/lib/77bit/encode77.f90 @@ -0,0 +1,49 @@ +program encode77 + + use packjt77 + + character*80 msg0 + character msg*37,cerr*1 + character*77 c77 + character*80 infile + logical unpk77_success + + nargs=iargc() + if(nargs.ne.1 .and.nargs.ne.2) then + print*,'Usage: encode77 "message"' + print*,' encode77 -f <infile>' + go to 999 + endif + call getarg(1,msg0) + if(nargs.eq.2) then + call getarg(2,infile) + open(10,file=infile,status='old') + write(*,1000) +1000 format('i3.n3 Err Message to be encoded Decoded message' & + /80('-')) + endif + + do iline=1,999 + if(nargs.eq.2) read(10,1002,end=999) msg0 +1002 format(a80) + if(msg0(1:1).eq.'$') exit + if(msg0.eq.' ') cycle + if(msg0(2:2).eq.'.' .or. msg0(3:3).eq.'.') cycle + if(msg0(1:3).eq.'---') cycle + msg0=adjustl(msg0) + i3=-1 + n3=-1 + call pack77(msg0(1:37),i3,n3,c77) + call unpack77(c77,msg,unpk77_success) + cerr=' ' + if(msg.ne.msg0(1:37)) cerr='*' + if(i3.eq.0) write(*,1004) i3,n3,cerr,msg0(1:37),msg +1004 format(i2,'.',i1,2x,a1,3x,a37,1x,a37) + if(i3.ge.1) write(*,1005) i3,cerr,msg0(1:37),msg +1005 format(i2,'.',3x,a1,3x,a37,1x,a37) + if(nargs.eq.1) exit + enddo + +999 end program encode77 + +include '../chkcall.f90' diff --git a/lib/77bit/encode77.out b/lib/77bit/encode77.out new file mode 100644 index 00000000..2d0f7d4c --- /dev/null +++ b/lib/77bit/encode77.out @@ -0,0 +1,41 @@ +i3.n3 Err Message to be encoded Decoded message +-------------------------------------------------------------------------------- + 1. CQ K1ABC FN42 CQ K1ABC FN42 + 1. K1ABC W9XYZ EN37 K1ABC W9XYZ EN37 + 1. W9XYZ K1ABC -11 W9XYZ K1ABC -11 + 1. K1ABC W9XYZ R-09 K1ABC W9XYZ R-09 + 1. W9XYZ K1ABC RRR W9XYZ K1ABC RRR + 1. K1ABC W9XYZ 73 K1ABC W9XYZ 73 + 1. CQ K1ABC FN42 CQ K1ABC FN42 + 1. K1ABC W9XYZ -09 K1ABC W9XYZ -09 + 1. W9XYZ K1ABC R-11 W9XYZ K1ABC R-11 + 1. K1ABC W9XYZ RR73 K1ABC W9XYZ RR73 + 1. W9XYZ K1ABC 73 W9XYZ K1ABC 73 + 4. CQ KH1/KH7Z CQ KH1/KH7Z + 1. KH7Z K1ABC FN42 KH7Z K1ABC FN42 + 1. K1ABC KH7Z -12 K1ABC KH7Z -12 + 1. KH7Z K1ABC R-14 KH7Z K1ABC R-14 + 0.1 K1ABC RR73; W9XYZ <KH1/KH7Z> -08 K1ABC RR73; W9XYZ <KH1/KH7Z> -08 + 1. CQ FD K1ABC FN42 CQ FD K1ABC FN42 + 0.3 K1ABC W9XYZ 6A WI K1ABC W9XYZ 6A WI + 0.3 W9XYZ K1ABC R 2B EMA W9XYZ K1ABC R 2B EMA + 1. K1ABC W9XYZ RR73 K1ABC W9XYZ RR73 + 1. CQ TEST K1ABC/R FN42 CQ TEST K1ABC/R FN42 + 1. K1ABC/R W9XYZ EN37 K1ABC/R W9XYZ EN37 + 1. W9XYZ K1ABC/R R FN42 W9XYZ K1ABC/R R FN42 + 1. K1ABC/R W9XYZ RR73 K1ABC/R W9XYZ RR73 + 1. CQ TEST K1ABC FN42 CQ TEST K1ABC FN42 + 3. K1ABC W9XYZ 579 WI K1ABC W9XYZ 579 WI + 3. W9XYZ K1ABC R 589 MA W9XYZ K1ABC R 589 MA + 1. K1ABC W9XYZ RR73 K1ABC W9XYZ RR73 + 2. CQ G4ABC/P IO91 CQ G4ABC/P IO91 + 2. G4ABC/P PA9XYZ JO22 G4ABC/P PA9XYZ JO22 + 0.2 PA9XYZ 590003 IO91NP PA9XYZ 590003 IO91NP + 0.2 G4ABC/P R 570007 JO22DB G4ABC/P R 570007 JO22DB + 2. PA9XYZ G4ABC/P RR73 PA9XYZ G4ABC/P RR73 + 4. CQ PJ4/K1ABC CQ PJ4/K1ABC + 4. <PJ4/K1ABC> W9XYZ <PJ4/K1ABC> W9XYZ + 1. W9XYZ K1ABC -11 W9XYZ K1ABC -11 + 1. K1ABC W9XYZ R-09 K1ABC W9XYZ R-09 + 4. W9XYZ <PJ4/K1ABC> RRR W9XYZ <PJ4/K1ABC> RRR + 4. <PJ4/K1ABC> W9XYZ 73 <PJ4/K1ABC> W9XYZ 73 diff --git a/lib/77bit/g2 b/lib/77bit/g2 new file mode 100644 index 00000000..9c19b3a2 --- /dev/null +++ b/lib/77bit/g2 @@ -0,0 +1,6 @@ +gfortran -c ../packjt.f90 +gfortran -c packjt77.f90 +gfortran -o encode77 -fbounds-check -Wall -Wno-conversion \ + encode77.f90 ../deg2grid.f90 ../grid2deg.f90 ../fix_contest_msg.f90 \ + ../to_contest_msg.f90 ../fmtmsg.f90 ../azdist.f90 ../geodist.f90 \ + packjt.o packjt77.o diff --git a/lib/77bit/g8 b/lib/77bit/g8 new file mode 100644 index 00000000..2258817d --- /dev/null +++ b/lib/77bit/g8 @@ -0,0 +1,2 @@ +gfortran -o test28 -fbounds-check -Wall -Wno-conversion test28.f90 pack28.f90 \ + unpack28.f90 ihashcall.f90 hash22.f90 save_hash_call.f90 diff --git a/lib/77bit/messages.txt b/lib/77bit/messages.txt new file mode 100644 index 00000000..54fd44b0 --- /dev/null +++ b/lib/77bit/messages.txt @@ -0,0 +1,84 @@ +1. Standard QSO +----------------------------------------------------------- +CQ K1ABC FN42 + K1ABC W9XYZ EN37 +W9XYZ K1ABC -11 + K1ABC W9XYZ R-09 +W9XYZ K1ABC RRR + K1ABC W9XYZ 73 + +2. Short-cycle QSO +----------------------------------------------------------- +CQ K1ABC FN42 + K1ABC W9XYZ -09 +W9XYZ K1ABC R-11 + K1ABC W9XYZ RR73 +W9XYZ K1ABC 73 + +3. FT8 DXpedition Mode +----------------------------------------------------------- +CQ KH1/KH7Z + KH7Z K1ABC FN42 +K1ABC KH7Z -12 + KH7Z K1ABC R-14 +K1ABC RR73; W9XYZ <KH1/KH7Z> -08 + +4. ARRL Field Day +----------------------------------------------------------- +CQ FD K1ABC FN42 + K1ABC W9XYZ 6A WI +W9XYZ K1ABC R 2B EMA + K1ABC W9XYZ RR73 + +5. ARRL VHF Contests +----------------------------------------------------------- +CQ TEST K1ABC/R FN42 + K1ABC/R W9XYZ EN37 +W9XYZ K1ABC/R R FN42 + K1ABC/R W9XYZ RR73 + +6. ARRL RTTY Contest +----------------------------------------------------------- +CQ TEST K1ABC FN42 + K1ABC W9XYZ 579 WI +W9XYZ K1ABC R 589 MA + K1ABC KA0DEF 559 MO +TU; KA0DEF K1ABC R 569 MA + KA1ABC G3AAA 529 0013 +TU; G3AAA K1ABC R 559 MA + +7. EU VHF Contest +----------------------------------------------------------- +CQ G4ABC/P IO91 + G4ABC/P PA9XYZ JO22 +PA9XYZ 590003 IO91NP + G4ABC/P R 570007 JO22DB +PA9XYZ G4ABC/P RR73 + +8. Compound or nonstandard calls CQ +----------------------------------------------------------- +CQ PJ4/K1ABC + PJ4/K1ABC <W9XYZ> +W9XYZ <PJ4/K1ABC> -11 + <PJ4/K1ABC> W9XYZ R-09 +<W9XYZ> PJ4/K1ABC RRR + PJ4/K1ABC <W9XYZ> 73 + +9. Compound or nonstandard answers CQ +----------------------------------------------------------- +CQ W9XYZ EN37 + <W9XYZ> YW18FIFA +<YW18FIFA> W9XYZ -11 + W9XYZ <YW18FIFA> R-09 +YW18FIFA <W9XYZ> RRR + <W9XYZ> YW18FIFA 73 +10. Other stuff +----------------------------------------------------------- +TNX BOB 73 GL +CQ YW18FIFA +<YW18FIFA> KA1ABC +KA1ABC <YW18FIFA> -11 +<YW18FIFA> KA1ABC R-17 +<KA1ABC> YW18FIFA RR73 +<YW18FIFA> KA1ABC 73 +123456789ABCDEF012 diff --git a/lib/77bit/messages_2.txt b/lib/77bit/messages_2.txt new file mode 100644 index 00000000..38399e69 --- /dev/null +++ b/lib/77bit/messages_2.txt @@ -0,0 +1,49 @@ +FREE TEXT MSG 71 0 71 +CQ YW18FIFA +K1ABC RR73; W9XYZ <KH1/KH7Z> -12 28 28 10 5 1 71 DXpedition Mode +PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 2 70 EU VHF contest (2) +PA3XYZ 520093 IO91NP 28 1 1 3 12 25 2 70 EU VHF contest (2) +WA9XYZ KA1ABC R 16A EMA 28 28 1 4 3 7 3 71 ARRL Field Day +WA9XYZ KA1ABC 7D EMA 28 28 1 4 3 7 3 71 ARRL Field Day +WA9XYZ G8ABC 1D DX 28 28 1 4 3 7 3 71 ARRL Field Day +WA9XYZ KA1ABC R 32A EMA 28 28 1 4 3 7 4 71 ARRL Field Day +123456789ABCDEF012 71 71 Telemetry (18 hex) +71234567 71 71 Telemetry (18 hex) +81234567 71 71 Telemetry (18 hex) +7123456789ABCDEF01 71 71 Telemetry (18 hex) +8123456789ABCDEF01 71 71 Telemetry (18 hex) +WA9XYZ/R KA1ABC/R R FN42 28 1 28 1 1 15 74 Standard msg +WA9XYZ KA1ABC R-19 28 1 28 1 1 15 74 Standard msg +WA9XYZ KA1ABC +03 28 1 28 1 1 15 74 Standard msg +WA9XYZ KA1ABC -30 28 1 28 1 1 15 74 Standard msg +WA9XYZ KA1ABC +30 28 1 28 1 1 15 74 Standard msg +CQ K1ABC FN42 +DE K1ABC FN42 +QRZ K1ABC FN42 +CQ AA K1ABC FN42 +CQ ZZ K1ABC FN42 +CQ 000 K1ABC FN42 +CQ 313 K1ABC FN42 +CQ 999 K1ABC FN42 +CQ AAA K1ABC FN42 +CQ ZZZ K1ABC FN42 +CQ AAAA K1ABC FN42 +CQ ZZZZ K1ABC FN42 +CQ KH1/KH7Z +CQ YW18FIFA +CQ W4/YW18FIFA +PA1XYZ/P GM4ABC/P R FN42 28 1 28 1 1 15 74 EU VHF Contest +TU; W9XYZ K1ABC R 579 MA 1 28 28 1 3 13 74 ARRL RTTY contest +TU; W9XYZ G8ABC R 559 0013 1 28 28 1 3 13 74 ARRL RTTY (DX) +W9XYZ K1ABC 519 MA 1 28 28 1 3 13 74 ARRL RTTY contest +W9XYZ K1ABC 529 MA 1 28 28 1 3 13 74 ARRL RTTY contest +W9XYZ K1ABC 599 MA 1 28 28 1 3 13 74 ARRL RTTY contest +W9XYZ K1ABC 599 SNJ 1 28 28 1 3 13 74 ARRL RTTY contest +W9XYZ G8ABC 529 0013 1 28 28 1 3 13 74 ARRL RTTY (DX) +W9XYZ G8ABC 599 0013 1 28 28 1 3 13 74 ARRL RTTY (DX) +<WA9XYZ> PJ4/KA1ABC 13 58 1 2 74 Nonstandard call +PJ4/KA1ABC <WA9XYZ> RRR 13 58 1 2 74 Nonstandard call +<WA9XYZ> PJ4/KA1ABC RR73 13 58 1 2 74 Nonstandard call +PJ4/KA1ABC <WA9XYZ> 73 13 58 1 2 74 Nonstandard call +<WA9XYZ> PJ4/KA1ABC 73 13 58 1 2 74 Nonstandard call +CQ 313 YW18FIFA diff --git a/lib/77bit/msgtypes.txt b/lib/77bit/msgtypes.txt new file mode 100644 index 00000000..0cb0044f --- /dev/null +++ b/lib/77bit/msgtypes.txt @@ -0,0 +1,23 @@ +i3 n3 Bits Total Message type +--------------------------------------------------------------------------------------- +0 0 FREE TEXT MSG 71 71 +0 1 K1ABC RR73; W9XYZ <KH1/KH7Z> -12 28 28 10 5 71 DXpedition Mode +0 2 PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 70 EU VHF contest (2) +0 2 PA3XYZ 520093 IO91NP 28 1 1 3 12 25 70 EU VHF contest (2) +0 3 WA9XYZ KA1ABC R 16A EMA 28 28 1 4 3 7 71 ARRL Field Day +0 3 WA9XYZ KA1ABC 7D EMA 28 28 1 4 3 7 71 ARRL Field Day +0 3 WA9XYZ G8ABC 1D DX 28 28 1 4 3 7 71 ARRL Field Day +0 4 WA9XYZ KA1ABC R 32A EMA 28 28 1 4 3 7 71 ARRL Field Day +0 5 123456789ABCDEF012 71 71 Telemetry (18 hex) +0 5 7123456789ABCDEF01 71 71 Telemetry (18 hex) +0 5 71234567 71 71 Telemetry (18 hex) +0 5 81234567 71 71 Telemetry (18 hex) +0 5 8123456789ABCDEF01 71 71 Telemetry (18 hex) +1 WA9XYZ/R KA1ABC/R R FN42 28 1 28 1 1 15 74 Standard msg +1 WA9XYZ KA1ABC R-11 28 1 28 1 1 15 74 Standard msg +2 PA1XYZ/P GM4ABC/P R FN42 28 1 28 1 1 15 74 EU VHF Contest +3 TU; W9XYZ K1ABC R 579 MA 1 28 28 1 3 13 74 ARRL RTTY contest +3 TU; W9XYZ G8ABC R 559 0013 1 28 28 1 3 13 74 ARRL RTTY (DX) +4 <WA9XYZ> PJ4/KA1ABC RR73 13 58 1 2 74 Nonstandard call +4 <WA9XYZ> PJ4/KA1ABC 13 58 1 2 74 Nonstandard call +4 PJ4/KA1ABC <WA9XYZ> RRR 13 58 1 2 74 Nonstandard call diff --git a/lib/77bit/msgtypes.txt.0 b/lib/77bit/msgtypes.txt.0 new file mode 100644 index 00000000..a1ab61f6 --- /dev/null +++ b/lib/77bit/msgtypes.txt.0 @@ -0,0 +1,23 @@ +i3 n3 +-------------------------------------------------------------------------------------- +0 0 FREE TEXT MSG 71 0 71 +0 1 K1ABC RR73; W9XYZ <KH1/KH7Z> -11 28 28 10 5 1 71 DXpedition Mode +0 2 PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 2 70 EU VHF contest (2) +0 3 WA9XYZ KA1ABC R 16A EMA 28 28 1 4 3 7 3 71 ARRL Field Day +0 4 WA9XYZ KA1ABC R 32A EMA 28 28 1 4 3 7 4 71 ARRL Field Day +1 WA9XYZ/R KA1ABC/R R FN42 28 1 28 1 1 15 74 Standard msg +2 TU; W9XYZ K1ABC R 579 MA 1 28 28 1 3 13 74 ARRL RTTY contest +3 <WA9XYZ> PJ4/KA1ABC R-11 13 53 1 1 6 74 Nonstandard calls +4 PA3XYZ/P GM4ABC/P R IO91 28 1 28 1 1 15 74 EU VHF contest + +0 0 HELLO WORLD 1 +0 0 hello world 2 + +0 1 K1ABC RR73; W9XYZ <VP2E/KA1ABC> -11 +0 2 PA3XYZ 590003 IO91NP +0 3 WA9XYZ KA1ABC 16A EMA +0 4 WA9XYZ KA1ABC 32A EMA +1 WA9XYZ/R KA1ABC/R R FN42 +2 W9XYZ K1ABC 579 MA +3 PJ4/KA1ABC <WA9XYZ> -11 +4 PA3XYZ/P GM4ABC/P R IO91 diff --git a/lib/77bit/my_hash.f90 b/lib/77bit/my_hash.f90 new file mode 100644 index 00000000..4e1a6c6c --- /dev/null +++ b/lib/77bit/my_hash.f90 @@ -0,0 +1,11 @@ +subroutine my_hash(mycall) + + use packjt77 + character*(*) mycall + character*13 c13 + + c13=mycall//' ' + call save_hash_call(c13,n10,n12,n22) + + return +end subroutine my_hash diff --git a/lib/77bit/packjt77.f90 b/lib/77bit/packjt77.f90 new file mode 100644 index 00000000..645da5bf --- /dev/null +++ b/lib/77bit/packjt77.f90 @@ -0,0 +1,1222 @@ +module packjt77 + +! These variables are accessible from outside via "use packjt77": + parameter (MAXHASH=1000,MAXRECENT=10) + character*13 callsign(MAXHASH) + integer ihash10(MAXHASH),ihash12(MAXHASH),ihash22(MAXHASH) + integer n28a,n28b,nzhash + character*13 recent_calls(MAXRECENT) + + contains + +subroutine hash10(n10,c13) + + character*13 c13 + + c13='<...>' + do i=1,nzhash + if(ihash10(i).eq.n10) then + c13=callsign(i) + c13='<'//trim(c13)//'>'//' ' + go to 900 + endif + enddo + +900 return +end subroutine hash10 + +subroutine hash12(n12,c13) + + character*13 c13 + + c13='<...>' + do i=1,nzhash + if(ihash12(i).eq.n12) then + c13=callsign(i) + c13='<'//trim(c13)//'>'//' ' + go to 900 + endif + enddo + +900 return +end subroutine hash12 + + +subroutine hash22(n22,c13) + + character*13 c13 + + c13='<...>' + do i=1,nzhash + if(ihash22(i).eq.n22) then + c13=callsign(i) + c13='<'//trim(c13)//'>'//' ' + go to 900 + endif + enddo + +900 return +end subroutine hash22 + + +integer function ihashcall(c0,m) + + integer*8 n8 + character*13 c0 + character*38 c + data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ/'/ + + n8=0 + do i=1,11 + j=index(c,c0(i:i)) - 1 + n8=38*n8 + j + enddo + ihashcall=ishft(47055833459_8*n8,m-64) + + return +end function ihashcall + +subroutine save_hash_call(c13,n10,n12,n22) + + character*13 c13,cw + logical first + data first/.true./ + save first + + if(first) then + ihash10=-1 + ihash12=-1 + ihash22=-1 + callsign=' ' + nzhash=0 + first=.false. + endif + + cw=c13 + if(cw(1:1).eq.' ' .or. cw(1:5).eq.'<...>') return + if(cw(1:1).eq.'<') cw=cw(2:) + i=index(cw,'>') + if(i.gt.0) cw(i:)=' ' + + n10=ihashcall(cw,10) + n12=ihashcall(cw,12) + n22=ihashcall(cw,22) + do i=1,nzhash + if(ihash22(i).eq.n22) go to 900 !This one is already in the table + enddo + +! New entry: move table down, making room for new one at the top + ihash10(MAXHASH:2:-1)=ihash10(MAXHASH-1:1:-1) + ihash12(MAXHASH:2:-1)=ihash12(MAXHASH-1:1:-1) + ihash22(MAXHASH:2:-1)=ihash22(MAXHASH-1:1:-1) + +! Add the new entry + callsign(MAXHASH:2:-1)=callsign(MAXHASH-1:1:-1) + ihash10(1)=n10 + ihash12(1)=n12 + ihash22(1)=n22 + callsign(1)=cw + if(nzhash.lt.MAXHASH) nzhash=nzhash+1 + +900 return +end subroutine save_hash_call + +subroutine pack77(msg0,i3,n3,c77) + + use packjt + character*37 msg,msg0 + character*18 c18 + character*13 w(19) + character*77 c77 + integer nw(19) + integer ntel(3) + + msg=msg0 + if(i3.eq.0 .and. n3.eq.5) go to 5 + +! Convert msg to upper case; collapse multiple blanks; parse into words. + call split77(msg,nwords,nw,w) + i3=-1 + n3=-1 + if(msg(1:3).eq.'CQ ' .or. msg(1:3).eq.'DE ' .or. msg(1:4).eq.'QRZ ') go to 100 + +! Check 0.1 (DXpedition mode) + call pack77_01(nwords,w,i3,n3,c77) + if(i3.ge.0 .or. n3.ge.1) go to 900 +! Check 0.2 (EU VHF contest exchange) + call pack77_02(nwords,w,i3,n3,c77) + if(i3.ge.0) go to 900 + +! Check 0.3 and 0.4 (ARRL Field Day exchange) + call pack77_03(nwords,w,i3,n3,c77) + if(i3.ge.0) go to 900 + if(nwords.ge.2) go to 100 + + ! Check 0.5 (telemetry) +5 i0=index(msg,' ') + c18=msg(1:i0-1)//' ' + c18=adjustr(c18) + ntel=-99 + read(c18,1005,err=6) ntel +1005 format(3z6) + if(ntel(1).ge.2**23) go to 800 +6 if(ntel(1).ge.0 .and. ntel(2).ge.0 .and. ntel(3).ge.0) then + i3=0 + n3=5 + write(c77,1006) ntel,n3,i3 +1006 format(b23.23,2b24.24,2b3.3) + go to 900 + endif + +! Check Type 1 (Standard 77-bit message) or Type 2, with optional "/P" +100 call pack77_1(nwords,w,i3,n3,c77) + if(i3.ge.0) go to 900 + +! Check Type 3 (ARRL RTTY contest exchange) + call pack77_3(nwords,w,i3,n3,c77) + if(i3.ge.0) go to 900 + +! Check Type 4 (One nonstandard call and one hashed call) + call pack77_4(nwords,w,i3,n3,c77) + if(i3.ge.0) go to 900 + +! It defaults to free text +800 i3=0 + n3=0 + msg(14:)=' ' + call packtext77(msg(1:13),c77(1:71)) + write(c77(72:77),'(2b3.3)') n3,i3 + +900 return +end subroutine pack77 + +subroutine unpack77(c77,msg,unpk77_success) + + parameter (NSEC=84) !Number of ARRL Sections + parameter (NUSCAN=65) !Number of US states and Canadian provinces + parameter (MAXGRID4=32400) + integer*8 n58 + integer ntel(3) + character*77 c77 + character*37 msg + character*13 call_1,call_2,call_3 + character*11 c11 + character*3 crpt,cntx + character*3 cmult(NUSCAN) + character*6 cexch,grid6 + character*4 grid4,cserial + character*3 csec(NSEC) + character*38 c + logical unpk28_success,unpk77_success + + data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ/'/ + data csec/ & + "AB ","AK ","AL ","AR ","AZ ","BC ","CO ","CT ","DE ","EB ", & + "EMA","ENY","EPA","EWA","GA ","GTA","IA ","ID ","IL ","IN ", & + "KS ","KY ","LA ","LAX","MAR","MB ","MDC","ME ","MI ","MN ", & + "MO ","MS ","MT ","NC ","ND ","NE ","NFL","NH ","NL ","NLI", & + "NM ","NNJ","NNY","NT ","NTX","NV ","OH ","OK ","ONE","ONN", & + "ONS","OR ","ORG","PAC","PR ","QC ","RI ","SB ","SC ","SCV", & + "SD ","SDG","SF ","SFL","SJV","SK ","SNJ","STX","SV ","TN ", & + "UT ","VA ","VI ","VT ","WCF","WI ","WMA","WNY","WPA","WTX", & + "WV ","WWA","WY ","DX "/ + data cmult/ & + "AL ","AK ","AZ ","AR ","CA ","CO ","CT ","DE ","FL ","GA ", & + "HI ","ID ","IL ","IN ","IA ","KS ","KY ","LA ","ME ","MD ", & + "MA ","MI ","MN ","MS ","MO ","MT ","NE ","NV ","NH ","NJ ", & + "NM ","NY ","NC ","ND ","OH ","OK ","OR ","PA ","RI ","SC ", & + "SD ","TN ","TX ","UT ","VT ","VA ","WA ","WV ","WI ","WY ", & + "NB ","NS ","QC ","ON ","MB ","SK ","AB ","BC ","NWT","NF ", & + "LB ","NU ","YT ","PEI","DC "/ + + unpk77_success=.true. + +! Check for bad data + do i=1,77 + if(c77(i:i).ne.'0' .and. c77(i:i).ne.'1') then + msg='failed unpack' + unpk77_success=.false. + return + endif + enddo + + read(c77(72:77),'(2b3)') n3,i3 + msg=repeat(' ',37) + if(i3.eq.0 .and. n3.eq.0) then +! 0.0 Free text + call unpacktext77(c77(1:71),msg(1:13)) + msg(14:)=' ' + msg=adjustl(msg) + + else if(i3.eq.0 .and. n3.eq.1) then +! 0.1 K1ABC RR73; W9XYZ <KH1/KH7Z> -11 28 28 10 5 71 DXpedition Mode + read(c77,1010) n28a,n28b,n10,n5 +1010 format(2b28,b10,b5) + irpt=2*n5 - 30 + write(crpt,1012) irpt +1012 format(i3.2) + if(irpt.ge.0) crpt(1:1)='+' + call unpack28(n28a,call_1,unpk28_success) + if(.not.unpk28_success .or. n28a.le.2) unpk77_success=.false. + call unpack28(n28b,call_2,unpk28_success) + if(.not.unpk28_success .or. n28b.le.2) unpk77_success=.false. + call hash10(n10,call_3) + if(call_3(1:1).eq.'<') then + msg=trim(call_1)//' RR73; '//trim(call_2)//' '//trim(call_3)// & + ' '//crpt + else + msg=trim(call_1)//' RR73; '//trim(call_2)//' <'//trim(call_3)// & + '> '//crpt + endif + else if(i3.eq.0 .and. n3.eq.2) then +! 0.2 PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 70 EU VHF contest + read(c77,1020) n28a,ip,ir,irpt,iserial,igrid6 +1020 format(b28,2b1,b3,b12,b25) + call unpack28(n28a,call_1,unpk28_success) + if(.not.unpk28_success .or. n28a.le.2) unpk77_success=.false. + nrs=52+irpt + if(ip.eq.1) call_1=trim(call_1)//'/P'//' ' + write(cexch,1022) nrs,iserial +1022 format(i2,i4.4) + n=igrid6 + j1=n/(18*10*10*24*24) + n=n-j1*18*10*10*24*24 + j2=n/(10*10*24*24) + n=n-j2*10*10*24*24 + j3=n/(10*24*24) + n=n-j3*10*24*24 + j4=n/(24*24) + n=n-j4*24*24 + j5=n/24 + j6=n-j5*24 + grid6(1:1)=char(j1+ichar('A')) + grid6(2:2)=char(j2+ichar('A')) + grid6(3:3)=char(j3+ichar('0')) + grid6(4:4)=char(j4+ichar('0')) + grid6(5:5)=char(j5+ichar('A')) + grid6(6:6)=char(j6+ichar('A')) + msg=trim(call_1)//' '//cexch//' '//grid6 + if(ir.eq.1) msg=trim(call_1)//' R '//cexch//' '//grid6 + + else if(i3.eq.0 .and. (n3.eq.3 .or. n3.eq.4)) then +! 0.3 WA9XYZ KA1ABC R 16A EMA 28 28 1 4 3 7 71 ARRL Field Day +! 0.4 WA9XYZ KA1ABC R 32A EMA 28 28 1 4 3 7 71 ARRL Field Day + read(c77,1030) n28a,n28b,ir,intx,nclass,isec +1030 format(2b28,b1,b4,b3,b7) + if(isec.gt.NSEC .or. isec.lt.1) then + unpk77_success=.false. + isec=1 + endif + call unpack28(n28a,call_1,unpk28_success) + if(.not.unpk28_success .or. n28a.le.2) unpk77_success=.false. + call unpack28(n28b,call_2,unpk28_success) + if(.not.unpk28_success .or. n28b.le.2) unpk77_success=.false. + ntx=intx+1 + if(n3.eq.4) ntx=ntx+16 + write(cntx(1:2),1032) ntx +1032 format(i2) + cntx(3:3)=char(ichar('A')+nclass) + if(ir.eq.0 .and. ntx.lt.10) msg=trim(call_1)//' '//trim(call_2)// & + cntx//' '//csec(isec) + if(ir.eq.1 .and. ntx.lt.10) msg=trim(call_1)//' '//trim(call_2)// & + ' R'//cntx//' '//csec(isec) + if(ir.eq.0 .and. ntx.ge.10) msg=trim(call_1)//' '//trim(call_2)// & + ' '//cntx//' '//csec(isec) + if(ir.eq.1 .and. ntx.ge.10) msg=trim(call_1)//' '//trim(call_2)// & + ' R '//cntx//' '//csec(isec) + + else if(i3.eq.0 .and. n3.eq.5) then +! 0.5 0123456789abcdef01 71 71 Telemetry (18 hex) + read(c77,1006) ntel +1006 format(b23,2b24) + write(msg,1007) ntel +1007 format(3z6.6) + do i=1,18 + if(msg(i:i).ne.'0') exit + msg(i:i)=' ' + enddo + msg=adjustl(msg) + + else if(i3.eq.1 .or. i3.eq.2) then +! Type 1 (standard message) or Type 2 ("/P" form for EU VHF contest) + read(c77,1000) n28a,ipa,n28b,ipb,ir,igrid4,i3 +1000 format(2(b28,b1),b1,b15,b3) + call unpack28(n28a,call_1,unpk28_success) + if(.not.unpk28_success) unpk77_success=.false. + call unpack28(n28b,call_2,unpk28_success) + if(.not.unpk28_success) unpk77_success=.false. + if(call_1(1:3).eq.'CQ_') call_1(3:3)=' ' + if(index(call_1,'<').le.0) then + i=index(call_1,' ') + if(i.ge.4 .and. ipa.eq.1 .and. i3.eq.1) call_1(i:i+1)='/R' + if(i.ge.4 .and. ipa.eq.1 .and. i3.eq.2) call_1(i:i+1)='/P' + if(i.ge.4) call add_call_to_recent_calls(call_1) + endif + if(index(call_2,'<').le.0) then + i=index(call_2,' ') + if(i.ge.4 .and. ipb.eq.1 .and. i3.eq.1) call_2(i:i+1)='/R' + if(i.ge.4 .and. ipb.eq.1 .and. i3.eq.2) call_2(i:i+1)='/P' + if(i.ge.4) call add_call_to_recent_calls(call_2) + endif + if(igrid4.le.MAXGRID4) then + n=igrid4 + j1=n/(18*10*10) + n=n-j1*18*10*10 + j2=n/(10*10) + n=n-j2*10*10 + j3=n/10 + j4=n-j3*10 + grid4(1:1)=char(j1+ichar('A')) + grid4(2:2)=char(j2+ichar('A')) + grid4(3:3)=char(j3+ichar('0')) + grid4(4:4)=char(j4+ichar('0')) + if(ir.eq.0) msg=trim(call_1)//' '//trim(call_2)//' '//grid4 + if(ir.eq.1) msg=trim(call_1)//' '//trim(call_2)//' R '//grid4 + if(msg(1:3).eq.'CQ ' .and. ir.eq.1) unpk77_success=.false. + else + irpt=igrid4-MAXGRID4 + if(irpt.eq.1) msg=trim(call_1)//' '//trim(call_2) + if(irpt.eq.2) msg=trim(call_1)//' '//trim(call_2)//' RRR' + if(irpt.eq.3) msg=trim(call_1)//' '//trim(call_2)//' RR73' + if(irpt.eq.4) msg=trim(call_1)//' '//trim(call_2)//' 73' + if(irpt.ge.5) then + write(crpt,'(i3.2)') irpt-35 + if(crpt(1:1).eq.' ') crpt(1:1)='+' + if(ir.eq.0) msg=trim(call_1)//' '//trim(call_2)//' '//crpt + if(ir.eq.1) msg=trim(call_1)//' '//trim(call_2)//' R'//crpt + endif + if(msg(1:3).eq.'CQ ' .and. irpt.ge.2) unpk77_success=.false. + endif + + else if(i3.eq.3) then +! Type 3: ARRL RTTY Contest + read(c77,1040) itu,n28a,n28b,ir,irpt,nexch,i3 +1040 format(b1,2b28.28,b1,b3.3,b13.13,b3.3) + write(crpt,1042) irpt+2 +1042 format('5',i1,'9') + nserial=nexch + imult=-1 + if(nexch.gt.8000) then + imult=nexch-8000 + nserial=-1 + endif + call unpack28(n28a,call_1,unpk28_success) + if(.not.unpk28_success) unpk77_success=.false. + call unpack28(n28b,call_2,unpk28_success) + if(.not.unpk28_success) unpk77_success=.false. + imult=0 + nserial=0 + if(nexch.gt.8000) imult=nexch-8000 + if(nexch.lt.8000) nserial=nexch + + if(imult.ge.1 .and.imult.le.NUSCAN) then + if(itu.eq.0 .and. ir.eq.0) msg=trim(call_1)//' '//trim(call_2)// & + ' '//crpt//' '//cmult(imult) + if(itu.eq.1 .and. ir.eq.0) msg='TU; '//trim(call_1)//' '//trim(call_2)// & + ' '//crpt//' '//cmult(imult) + if(itu.eq.0 .and. ir.eq.1) msg=trim(call_1)//' '//trim(call_2)// & + ' R '//crpt//' '//cmult(imult) + if(itu.eq.1 .and. ir.eq.1) msg='TU; '//trim(call_1)//' '//trim(call_2)// & + ' R '//crpt//' '//cmult(imult) + else if(nserial.ge.1 .and. nserial.le.7999) then + write(cserial,'(i4.4)') nserial + if(itu.eq.0 .and. ir.eq.0) msg=trim(call_1)//' '//trim(call_2)// & + ' '//crpt//' '//cserial + if(itu.eq.1 .and. ir.eq.0) msg='TU; '//trim(call_1)//' '//trim(call_2)// & + ' '//crpt//' '//cserial + if(itu.eq.0 .and. ir.eq.1) msg=trim(call_1)//' '//trim(call_2)// & + ' R '//crpt//' '//cserial + if(itu.eq.1 .and. ir.eq.1) msg='TU; '//trim(call_1)//' '//trim(call_2)// & + ' R '//crpt//' '//cserial + endif + else if(i3.eq.4) then + read(c77,1050) n12,n58,iflip,nrpt,icq +1050 format(b12,b58,b1,b2,b1) + do i=11,1,-1 + j=mod(n58,38)+1 + c11(i:i)=c(j:j) + n58=n58/38 + enddo + call hash12(n12,call_3) + if(iflip.eq.0) then + call_1=call_3 + call_2=adjustl(c11)//' ' + call add_call_to_recent_calls(call_2) + else + call_1=adjustl(c11)//' ' + call_2=call_3 + call add_call_to_recent_calls(call_1) + endif + if(icq.eq.0) then + if(nrpt.eq.0) msg=trim(call_1)//' '//trim(call_2) + if(nrpt.eq.1) msg=trim(call_1)//' '//trim(call_2)//' RRR' + if(nrpt.eq.2) msg=trim(call_1)//' '//trim(call_2)//' RR73' + if(nrpt.eq.3) msg=trim(call_1)//' '//trim(call_2)//' 73' + else + msg='CQ '//trim(call_2) + endif + endif + if(msg(1:4).eq.'CQ <') unpk77_success=.false. + + return +end subroutine unpack77 + +subroutine pack28(c13,n28) + +! Pack a special token, a 22-bit hash code, or a valid base call into a 28-bit +! integer. + + parameter (NTOKENS=2063592,MAX22=4194304) + logical is_digit,is_letter + character*13 c13 + character*6 callsign + character*1 c + character*4 c4 + character*37 a1 + character*36 a2 + character*10 a3 + character*27 a4 + data a1/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/ + data a2/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/ + data a3/'0123456789'/ + data a4/' ABCDEFGHIJKLMNOPQRSTUVWXYZ'/ + + is_digit(c)=c.ge.'0' .and. c.le.'9' + is_letter(c)=c.ge.'A' .and. c.le.'Z' + + n28=-1 +! Work-around for Swaziland prefix: + if(c13(1:4).eq.'3DA0') callsign='3D0'//c13(5:7) +! Work-around for Guinea prefixes: + if(c13(1:2).eq.'3X' .and. c13(3:3).ge.'A' .and. & + c13(3:3).le.'Z') callsign='Q'//c13(3:6) + +! Check for special tokens first + if(c13(1:3).eq.'DE ') then + n28=0 + go to 900 + endif + + if(c13(1:4).eq.'QRZ ') then + n28=1 + go to 900 + endif + + if(c13(1:3).eq.'CQ ') then + n28=2 + go to 900 + endif + + if(c13(1:3).eq.'CQ_') then + n=len(trim(c13)) + if(n.ge.4 .and. n.le.7) then + nlet=0 + nnum=0 + do i=4,n + c=c13(i:i) + if(c.ge.'A' .and. c.le.'Z') nlet=nlet+1 + if(c.ge.'0' .and. c.le.'9') nnum=nnum+1 + enddo + if(nnum.eq.3 .and. nlet.eq.0) then + read(c13(4:3+nnum),*) nqsy + n28=3+nqsy + go to 900 + endif + if(nlet.ge.1 .and. nlet.le.4 .and. nnum.eq.0) then + c4=c13(4:n)//' ' + c4=adjustr(c4) + m=0 + do i=1,4 + j=0 + c=c4(i:i) + if(c.ge.'A' .and. c.le.'Z') j=ichar(c)-ichar('A')+1 + m=27*m + j + enddo + n28=3+1000+m + go to 900 + endif + endif + endif + +! Check for <...> callsign + if(c13(1:1).eq.'<')then + call save_hash_call(c13,n10,n12,n22) !Save callsign in hash table + n28=NTOKENS + n22 + go to 900 + endif + +! Check for standard callsign + iarea=-1 + n=len(trim(c13)) + do i=n,2,-1 + if(is_digit(c13(i:i))) exit + enddo + iarea=i !Call-area digit + npdig=0 !Digits before call area + nplet=0 !Letters before call area + do i=1,iarea-1 + if(is_digit(c13(i:i))) npdig=npdig+1 + if(is_letter(c13(i:i))) nplet=nplet+1 + enddo + nslet=0 + do i=iarea+1,n + if(is_letter(c13(i:i))) nslet=nslet+1 + enddo + if(iarea.lt.2 .or. iarea.gt.3 .or. nplet.eq.0 .or. & + npdig.ge.iarea-1 .or. nslet.gt.3) then +! Treat this as a nonstandard callsign: compute its 22-bit hash + call save_hash_call(c13,n10,n12,n22) !Save callsign in hash table + n28=NTOKENS + n22 + go to 900 + endif + + n=len(trim(c13)) +! This is a standard callsign + call save_hash_call(c13,n10,n12,n22) !Save callsign in hash table + if(iarea.eq.2) callsign=' '//c13(1:5) + if(iarea.eq.3) callsign=c13(1:6) + i1=index(a1,callsign(1:1))-1 + i2=index(a2,callsign(2:2))-1 + i3=index(a3,callsign(3:3))-1 + i4=index(a4,callsign(4:4))-1 + i5=index(a4,callsign(5:5))-1 + i6=index(a4,callsign(6:6))-1 + n28=36*10*27*27*27*i1 + 10*27*27*27*i2 + 27*27*27*i3 + 27*27*i4 + & + 27*i5 + i6 + n28=n28 + NTOKENS + MAX22 + +900 n28=iand(n28,ishft(1,28)-1) + return +end subroutine pack28 + + +subroutine unpack28(n28_0,c13,success) + + parameter (NTOKENS=2063592,MAX22=4194304) + logical success + character*13 c13 + character*37 c1 + character*36 c2 + character*10 c3 + character*27 c4 + data c1/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/ + data c2/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/ + data c3/'0123456789'/ + data c4/' ABCDEFGHIJKLMNOPQRSTUVWXYZ'/ + + success=.true. + n28=n28_0 + if(n28.lt.NTOKENS) then +! Special tokens DE, QRZ, CQ, CQ_nnn, CQ_aaaa + if(n28.eq.0) c13='DE ' + if(n28.eq.1) c13='QRZ ' + if(n28.eq.2) c13='CQ ' + if(n28.le.2) go to 900 + if(n28.le.1002) then + write(c13,1002) n28-3 +1002 format('CQ_',i3.3) + go to 900 + endif + if(n28.le.532443) then + n=n28-1003 + n0=n + i1=n/(27*27*27) + n=n-27*27*27*i1 + i2=n/(27*27) + n=n-27*27*i2 + i3=n/27 + i4=n-27*i3 + c13=c4(i1+1:i1+1)//c4(i2+1:i2+1)//c4(i3+1:i3+1)//c4(i4+1:i4+1) + c13=adjustl(c13) + c13='CQ_'//c13(1:10) + go to 900 + endif + endif + n28=n28-NTOKENS + if(n28.lt.MAX22) then +! This is a 22-bit hash of a callsign + n22=n28 + call hash22(n22,c13) !Retrieve callsign from hash table + go to 900 + endif + +! Standard callsign + n=n28 - MAX22 + i1=n/(36*10*27*27*27) + n=n-36*10*27*27*27*i1 + i2=n/(10*27*27*27) + n=n-10*27*27*27*i2 + i3=n/(27*27*27) + n=n-27*27*27*i3 + i4=n/(27*27) + n=n-27*27*i4 + i5=n/27 + i6=n-27*i5 + c13=c1(i1+1:i1+1)//c2(i2+1:i2+1)//c3(i3+1:i3+1)//c4(i4+1:i4+1)// & + c4(i5+1:i5+1)//c4(i6+1:i6+1)//' ' + c13=adjustl(c13) + +900 i0=index(c13,' ') + if(i0.ne.0 .and. i0.lt.len(trim(c13))) then + c13='QU1RK' + success=.false. + endif + return +end subroutine unpack28 + +subroutine split77(msg,nwords,nw,w) + +! Convert msg to upper case; collapse multiple blanks; parse into words. + + character*37 msg + character*13 w(19) + character*1 c,c0 + character*6 bcall_1 + logical ok1 + integer nw(19) + + iz=len(trim(msg)) + j=0 + k=0 + n=0 + c0=' ' + w=' ' + do i=1,iz + if(ichar(msg(i:i)).eq.0) msg(i:i)=' ' + c=msg(i:i) !Single character + if(c.eq.' ' .and. c0.eq.' ') cycle !Skip leading/repeated blanks + if(c.ne.' ' .and. c0.eq.' ') then + k=k+1 !New word + n=0 + endif + j=j+1 !Index in msg + n=n+1 !Index in word + msg(j:j)=c + if(c.ge.'a' .and. c.le.'z') msg(j:j)=char(ichar(c)-32) !Force upper case + if(n.le.13) w(k)(n:n)=c !Copy character c into word + c0=c + enddo + iz=j !Message length + nwords=k !Number of words in msg + if(nwords.le.0) go to 900 + nw(k)=len(trim(w(k))) + msg(iz+1:)=' ' + if(nwords.lt.3) go to 900 + call chkcall(w(3),bcall_1,ok1) + if(ok1 .and. w(1)(1:3).eq.'CQ ') then + w(1)='CQ_'//w(2)(1:10) !Make "CQ " into "CQ_" + w(2:12)=w(3:13) !Move all remeining words down by one + nwords=nwords-1 + endif + +900 return +end subroutine split77 + + +subroutine pack77_01(nwords,w,i3,n3,c77) + +! Pack a Type 0.1 message: DXpedition mode +! Example message: "K1ABC RR73; W9XYZ <KH1/KH7Z> -11" 28 28 10 5 + + character*13 w(19) + character*77 c77 + character*6 bcall_1,bcall_2 + logical ok1,ok2 + + if(nwords.ne.5) go to 900 !Must have 5 words + if(trim(w(2)).ne.'RR73;') go to 900 !2nd word must be "RR73;" + if(w(4)(1:1).ne.'<') go to 900 !4th word must have <...> + if(index(w(4),'>').lt.1) go to 900 + n=-99 + read(w(5),*,err=1) n +1 if(n.eq.-99) go to 900 !5th word must be a valid report + n5=(n+30)/2 + if(n5.lt.0) n5=0 + if(n5.gt.31) n5=31 + call chkcall(w(1),bcall_1,ok1) + if(.not.ok1) go to 900 !1st word must be a valid basecall + call chkcall(w(3),bcall_2,ok2) + if(.not.ok2) go to 900 !3rd word must be a valid basecall + +! Type 0.1: K1ABC RR73; W9XYZ <KH1/KH7Z> -11 28 28 10 5 71 DXpedition Mode + i3=0 + n3=1 + call pack28(w(1),n28a) + call pack28(w(3),n28b) + call save_hash_call(w(4),n10,n12,n22) + write(c77,1010) n28a,n28b,n10,n5,n3,i3 +1010 format(2b28.28,b10.10,b5.5,2b3.3) + +900 return +end subroutine pack77_01 + + +subroutine pack77_02(nwords,w,i3,n3,c77) + + character*13 w(19),c13 + character*77 c77 + character*6 bcall_1,grid6 + logical ok1,is_grid6 + + is_grid6(grid6)=len(trim(grid6)).eq.6 .and. & + grid6(1:1).ge.'A' .and. grid6(1:1).le.'R' .and. & + grid6(2:2).ge.'A' .and. grid6(2:2).le.'R' .and. & + grid6(3:3).ge.'0' .and. grid6(3:3).le.'9' .and. & + grid6(4:4).ge.'0' .and. grid6(4:4).le.'9' .and. & + grid6(5:5).ge.'A' .and. grid6(5:5).le.'X' .and. & + grid6(6:6).ge.'A' .and. grid6(6:6).le.'X' + + call chkcall(w(1),bcall_1,ok1) + if(.not.ok1) return !bcall_1 must be a valid basecall + if(nwords.lt.3 .or. nwords.gt.4) return !nwords must be 3 or 4 + nx=-1 + if(nwords.ge.2) read(w(nwords-1),*,err=2) nx +2 if(nx.lt.520001 .or. nx.gt.594095) return !Exchange between 520001 - 594095 + if(.not.is_grid6(w(nwords)(1:6))) return !Last word must be a valid grid6 + +! Type 0.2: PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 70 EU VHF contest + i3=0 + n3=2 + ip=0 + c13=w(1) + i=index(w(1),'/P') + if(i.ge.4) then + ip=1 + c13=w(1)(1:i-1)//' ' + endif + call pack28(c13,n28a) + ir=0 + if(w(2)(1:2).eq.'R ') ir=1 + irpt=nx/10000 - 52 + iserial=mod(nx,10000) + grid6=w(nwords)(1:6) + j1=(ichar(grid6(1:1))-ichar('A'))*18*10*10*24*24 + j2=(ichar(grid6(2:2))-ichar('A'))*10*10*24*24 + j3=(ichar(grid6(3:3))-ichar('0'))*10*24*24 + j4=(ichar(grid6(4:4))-ichar('0'))*24*24 + j5=(ichar(grid6(5:5))-ichar('A'))*24 + j6=(ichar(grid6(6:6))-ichar('A')) + igrid6=j1+j2+j3+j4+j5+j6 + write(c77,1010) n28a,ip,ir,irpt,iserial,igrid6,n3,i3 +1010 format(b28.28,2b1,b3.3,b12.12,b25.25,b4.4,b3.3) + + return +end subroutine pack77_02 + + +subroutine pack77_03(nwords,w,i3,n3,c77) +! Check 0.3 and 0.4 (ARRL Field Day exchange) + + parameter (NSEC=84) !Number of ARRL Sections + character*13 w(19) + character*77 c77 + character*6 bcall_1,bcall_2 + character*3 csec(NSEC) + logical ok1,ok2 + data csec/ & + "AB ","AK ","AL ","AR ","AZ ","BC ","CO ","CT ","DE ","EB ", & + "EMA","ENY","EPA","EWA","GA ","GTA","IA ","ID ","IL ","IN ", & + "KS ","KY ","LA ","LAX","MAR","MB ","MDC","ME ","MI ","MN ", & + "MO ","MS ","MT ","NC ","ND ","NE ","NFL","NH ","NL ","NLI", & + "NM ","NNJ","NNY","NT ","NTX","NV ","OH ","OK ","ONE","ONN", & + "ONS","OR ","ORG","PAC","PR ","QC ","RI ","SB ","SC ","SCV", & + "SD ","SDG","SF ","SFL","SJV","SK ","SNJ","STX","SV ","TN ", & + "UT ","VA ","VI ","VT ","WCF","WI ","WMA","WNY","WPA","WTX", & + "WV ","WWA","WY ","DX "/ + + if(nwords.lt.4 .or. nwords.gt.5) return + call chkcall(w(1),bcall_1,ok1) + call chkcall(w(2),bcall_2,ok2) + if(.not.ok1 .or. .not.ok2) return + isec=-1 + do i=1,NSEC + if(csec(i).eq.w(nwords)(1:3)) then + isec=i + exit + endif + enddo + if(isec.eq.-1) return + if(nwords.eq.5 .and. trim(w(3)).ne.'R') return + + ntx=-1 + j=len(trim(w(nwords-1)))-1 + read(w(nwords-1)(1:j),*,err=1) ntx !Number of transmitters +1 if(ntx.lt.1 .or. ntx.gt.32) return + nclass=ichar(w(nwords-1)(j+1:j+1))-ichar('A') + + m=len(trim(w(nwords))) !Length of section abbreviation + if(m.lt.2 .or. m.gt.3) return + +! 0.3 WA9XYZ KA1ABC R 16A EMA 28 28 1 4 3 7 71 ARRL Field Day +! 0.4 WA9XYZ KA1ABC R 32A EMA 28 28 1 4 3 7 71 ARRL Field Day + + i3=0 + n3=3 !Type 0.3 ARRL Field Day + intx=ntx-1 + if(intx.ge.16) then + n3=4 !Type 0.4 ARRL Field Day + intx=ntx-17 + endif + call pack28(w(1),n28a) + call pack28(w(2),n28b) + ir=0 + if(w(3)(1:2).eq.'R ') ir=1 + write(c77,1010) n28a,n28b,ir,intx,nclass,isec,n3,i3 +1010 format(2b28.28,b1,b4.4,b3.3,b7.7,2b3.3) + + return +end subroutine pack77_03 + +subroutine pack77_1(nwords,w,i3,n3,c77) +! Check Type 1 (Standard 77-bit message) and Type 2 (ditto, with a "/P" call) + + parameter (MAXGRID4=32400) + character*13 w(19),c13 + character*77 c77 + character*6 bcall_1,bcall_2 + character*4 grid4 + character c1*1,c2*2 + logical is_grid4 + logical ok1,ok2 + is_grid4(grid4)=len(trim(grid4)).eq.4 .and. & + grid4(1:1).ge.'A' .and. grid4(1:1).le.'R' .and. & + grid4(2:2).ge.'A' .and. grid4(2:2).le.'R' .and. & + grid4(3:3).ge.'0' .and. grid4(3:3).le.'9' .and. & + grid4(4:4).ge.'0' .and. grid4(4:4).le.'9' + + if(nwords.lt.2 .or. nwords.gt.4) return + call chkcall(w(1),bcall_1,ok1) + call chkcall(w(2),bcall_2,ok2) + if(w(1)(1:3).eq.'DE ' .or. w(1)(1:3).eq.'CQ_' .or. w(1)(1:3).eq.'CQ ' .or. & + w(1)(1:4).eq.'QRZ ') ok1=.true. + if(w(1)(1:1).eq.'<' .and. index(w(1),'>').ge.5) ok1=.true. + if(w(2)(1:1).eq.'<' .and. index(w(2),'>').ge.5) ok2=.true. + if(.not.ok1 .or. .not.ok2) return + if(w(1)(1:1).eq.'<' .and. index(w(2),'/').gt.0) return + if(w(2)(1:1).eq.'<' .and. index(w(1),'/').gt.0) return + if(nwords.eq.2 .and. (.not.ok2 .or. index(w(2),'/').ge.2)) return + if(nwords.eq.2) go to 10 + + c1=w(nwords)(1:1) + c2=w(nwords)(1:2) + if(.not.is_grid4(w(nwords)(1:4)) .and. c1.ne.'+' .and. c1.ne.'-' & + .and. c2.ne.'R+' .and. c2.ne.'R-' .and. trim(w(nwords)).ne.'RRR' .and. & + trim(w(nwords)).ne.'RR73' .and. trim(w(nwords)).ne.'73') return + if(c1.eq.'+' .or. c1.eq.'-') then + ir=0 + read(w(nwords),*,err=900) irpt + irpt=irpt+35 + else if(c2.eq.'R+' .or. c2.eq.'R-') then + ir=1 + read(w(nwords)(2:),*) irpt + irpt=irpt+35 + else if(trim(w(nwords)).eq.'RRR') then + ir=0 + irpt=2 + else if(trim(w(nwords)).eq.'RR73') then + ir=0 + irpt=3 + else if(trim(w(nwords)).eq.'73') then + ir=0 + irpt=4 + endif + +! 1 WA9XYZ/R KA1ABC/R R FN42 28 1 28 1 1 15 74 Standard msg +! 2 PA3XYZ/P GM4ABC/P R JO22 28 1 28 1 1 15 74 EU VHF contest + +10 if(nwords.eq.2 .or. nwords.eq.3 .or. (nwords.eq.4 .and. & + w(3)(1:2).eq.'R ')) then + n3=0 + i3=1 !Type 1: Standard message, possibly with "/R" + if(index(w(1),'/P').ge.4 .or. index(w(2),'/P').ge.4) i3=2 !Type 2, with "/P" + endif + c13=bcall_1//' ' + if(c13(1:3).eq.'CQ_' .or. w(1)(1:1).eq.'<') c13=w(1) + call pack28(c13,n28a) + c13=bcall_2//' ' + if(w(2)(1:1).eq.'<') c13=w(2) + call pack28(c13,n28b) + ipa=0 + ipb=0 + if(index(w(1),'/P').ge.4 .or. index(w(1),'/R').ge.4) ipa=1 + if(index(w(2),'/P').ge.4 .or. index(w(2),'/R').ge.4) ipb=1 + + grid4=w(nwords)(1:4) + if(is_grid4(grid4)) then + ir=0 + if(w(3).eq.'R ') ir=1 + j1=(ichar(grid4(1:1))-ichar('A'))*18*10*10 + j2=(ichar(grid4(2:2))-ichar('A'))*10*10 + j3=(ichar(grid4(3:3))-ichar('0'))*10 + j4=(ichar(grid4(4:4))-ichar('0')) + igrid4=j1+j2+j3+j4 + else + igrid4=MAXGRID4 + irpt + endif + if(nwords.eq.2) then + ir=0 + irpt=1 + igrid4=MAXGRID4+irpt + endif + write(c77,1000) n28a,ipa,n28b,ipb,ir,igrid4,i3 +1000 format(2(b28.28,b1),b1,b15.15,b3.3) + return + +900 return +end subroutine pack77_1 + + +subroutine pack77_3(nwords,w,i3,n3,c77) +! Check Type 2 (ARRL RTTY contest exchange) +!ARRL RTTY - US/Can: rpt state/prov R 579 MA +! - DX: rpt serial R 559 0013 + + parameter (NUSCAN=65) !Number of US states and Canadian provinces/territories + character*13 w(19) + character*77 c77 + character*6 bcall_1,bcall_2 + character*3 cmult(NUSCAN),mult + character crpt*3 + logical ok1,ok2 + data cmult/ & + "AL ","AK ","AZ ","AR ","CA ","CO ","CT ","DE ","FL ","GA ", & + "HI ","ID ","IL ","IN ","IA ","KS ","KY ","LA ","ME ","MD ", & + "MA ","MI ","MN ","MS ","MO ","MT ","NE ","NV ","NH ","NJ ", & + "NM ","NY ","NC ","ND ","OH ","OK ","OR ","PA ","RI ","SC ", & + "SD ","TN ","TX ","UT ","VT ","VA ","WA ","WV ","WI ","WY ", & + "NB ","NS ","QC ","ON ","MB ","SK ","AB ","BC ","NWT","NF ", & + "LB ","NU ","YT ","PEI","DC "/ + + if(nwords.eq.4 .or. nwords.eq.5 .or. nwords.eq.6) then + i1=1 + if(trim(w(1)).eq.'TU;') i1=2 + call chkcall(w(i1),bcall_1,ok1) + call chkcall(w(i1+1),bcall_2,ok2) + if(.not.ok1 .or. .not.ok2) go to 900 + crpt=w(nwords-1)(1:3) + if(crpt(1:1).eq.'5' .and. crpt(2:2).ge.'2' .and. crpt(2:2).le.'9' .and. & + crpt(3:3).eq.'9') then + nserial=0 + read(w(nwords),*,err=1) nserial +!1 i3=3 +! n3=0 + endif +1 mult=' ' + imult=-1 + do i=1,NUSCAN + if(cmult(i).eq.w(nwords)) then + imult=i + mult=cmult(i) + exit + endif + enddo + nexch=0 + if(nserial.gt.0) nexch=nserial + if(imult.gt.0) nexch=8000+imult + if(mult.ne.' ' .or. nserial.gt.0) then + i3=3 + n3=0 + itu=0 + if(trim(w(1)).eq.'TU;') itu=1 + call pack28(w(1+itu),n28a) + call pack28(w(2+itu),n28b) + ir=0 + if(w(3+itu)(1:2).eq.'R ') ir=1 + read(w(3+itu+ir),*,err=900) irpt + irpt=(irpt-509)/10 - 2 + if(irpt.lt.0) irpt=0 + if(irpt.gt.7) irpt=7 +! 3 TU; W9XYZ K1ABC R 579 MA 1 28 28 1 3 13 74 ARRL RTTY contest +! 3 TU; W9XYZ G8ABC R 559 0013 1 28 28 1 3 13 74 ARRL RTTY (DX) + write(c77,1010) itu,n28a,n28b,ir,irpt,nexch,i3 +1010 format(b1,2b28.28,b1,b3.3,b13.13,b3.3) + endif + endif + +900 return +end subroutine pack77_3 + +subroutine pack77_4(nwords,w,i3,n3,c77) +! Check Type 3 (One nonstandard call and one hashed call) + + integer*8 n58 + logical ok1,ok2 + character*13 w(19) + character*77 c77 + character*13 call_1,call_2 + character*11 c11 + character*6 bcall_1,bcall_2 + character*38 c + data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ/'/ + + iflip=0 + i3=-1 + if(nwords.eq.2 .or. nwords.eq.3) then + call_1=w(1) + if(call_1(1:1).eq.'<') call_1=w(1)(2:len(trim(w(1)))-1) + call_2=w(2) + if(call_2(1:1).eq.'<') call_2=w(2)(2:len(trim(w(2)))-1) + call chkcall(call_1,bcall_1,ok1) + call chkcall(call_2,bcall_2,ok2) + icq=0 + if(trim(w(1)).eq.'CQ' .or. (ok1.and.ok2)) then + if(trim(w(1)).eq.'CQ' .and. len(trim(w(2))).le.4) go to 900 + i3=4 + n3=0 + if(trim(w(1)).eq.'CQ') icq=1 + endif + + if(icq.eq.1) then + iflip=0 + n12=0 + c11=adjustr(call_2(1:11)) + call save_hash_call(w(2),n10,n12,n22) + else if(w(1)(1:1).eq.'<') then + iflip=0 + i3=4 + call save_hash_call(w(1),n10,n12,n22) + c11=adjustr(call_2(1:11)) + else if(w(2)(1:1).eq.'<') then + iflip=1 + i3=4 + call save_hash_call(w(2),n10,n12,n22) + c11=adjustr(call_1(1:11)) + endif + n58=0 + do i=1,11 + n58=n58*38 + index(c,c11(i:i)) - 1 + enddo + nrpt=0 + if(trim(w(3)).eq.'RRR') nrpt=1 + if(trim(w(3)).eq.'RR73') nrpt=2 + if(trim(w(3)).eq.'73') nrpt=3 + if(icq.eq.1) then + iflip=0 + nrpt=0 + endif + write(c77,1010) n12,n58,iflip,nrpt,icq,i3 +1010 format(b12.12,b58.58,b1,b2.2,b1,b3.3) + do i=1,77 + if(c77(i:i).eq.'*') c77(i:i)='0' !### Clean up any illegal chars ### + enddo + endif + +900 return +end subroutine pack77_4 + +subroutine packtext77(c13,c71) + + character*13 c13,w + character*71 c71 + character*42 c + character*1 qa(10),qb(10) + data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+-./?'/ + + call mp_short_init + qa=char(0) + w=adjustr(c13) + do i=1,13 + j=index(c,w(i:i))-1 + if(j.lt.0) j=0 + call mp_short_mult(qb,qa(2:10),9,42) !qb(1:9)=42*qa(2:9) + call mp_short_add(qa,qb(2:10),9,j) !qa(1:9)=qb(2:9)+j + enddo + + write(c71,1010) qa(2:10) +1010 format(b7.7,8b8.8) + + return +end subroutine packtext77 + +subroutine unpacktext77(c71,c13) + + integer*1 ia(10) + character*1 qa(10),qb(10) + character*13 c13 + character*71 c71 + character*42 c + equivalence (qa,ia),(qb,ib) + data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+-./?'/ + + qa(1)=char(0) + read(c71,1010) qa(2:10) +1010 format(b7.7,8b8.8) + + do i=13,1,-1 + call mp_short_div(qb,qa(2:10),9,42,ir) + c13(i:i)=c(ir+1:ir+1) + qa(2:10)=qb(1:9) + enddo + + return +end subroutine unpacktext77 + +subroutine mp_short_ops(w,u) + character*1 w(*),u(*) + integer i,ireg,j,n,ir,iv,ii1,ii2 + character*1 creg(4) + save ii1,ii2 + equivalence (ireg,creg) + + entry mp_short_init + ireg=256*ichar('2')+ichar('1') + do j=1,4 + if (creg(j).eq.'1') ii1=j + if (creg(j).eq.'2') ii2=j + enddo + return + + entry mp_short_add(w,u,n,iv) + ireg=256*iv + do j=n,1,-1 + ireg=ichar(u(j))+ichar(creg(ii2)) + w(j+1)=creg(ii1) + enddo + w(1)=creg(ii2) + return + + entry mp_short_mult(w,u,n,iv) + ireg=0 + do j=n,1,-1 + ireg=ichar(u(j))*iv+ichar(creg(ii2)) + w(j+1)=creg(ii1) + enddo + w(1)=creg(ii2) + return + + entry mp_short_div(w,u,n,iv,ir) + ir=0 + do j=1,n + i=256*ir+ichar(u(j)) + w(j)=char(i/iv) + ir=mod(i,iv) + enddo + return + + return +end subroutine mp_short_ops + +subroutine add_call_to_recent_calls(callsign) + + character*13 callsign + logical ladd +! only add if the callsign is not already on the list + ladd=.true. + do i=1,MAXRECENT-1 ! if callsign is at the end of the list add it again + if(recent_calls(i).eq.callsign) ladd=.false. + enddo + + if(ladd) then + do i=MAXRECENT,2,-1 + recent_calls(i)=recent_calls(i-1) + enddo + recent_calls(1)=callsign + endif + +! Make sure that callsign is hashed + call save_hash_call(callsign,n10,n12,n22) + + return +end subroutine add_call_to_recent_calls + +end module packjt77 diff --git a/lib/77bit/parse77.f90 b/lib/77bit/parse77.f90 new file mode 100644 index 00000000..a0a8b861 --- /dev/null +++ b/lib/77bit/parse77.f90 @@ -0,0 +1,11 @@ +subroutine parse77(msg,i3,n3) + + use packjt77 + character msg*37,c77*77 + + i3=-1 + n3=-1 + call pack77(msg,i3,n3,c77) + + return +end subroutine parse77 diff --git a/lib/77bit/test28.f90 b/lib/77bit/test28.f90 new file mode 100644 index 00000000..67bde4af --- /dev/null +++ b/lib/77bit/test28.f90 @@ -0,0 +1,43 @@ +program test28 + + parameter (NTOKENS=2063592,MAX22=4194304) + character*13 call_0,call_1,bare_call_1 + character*1 cerr + + nargs=iargc() + open(10,file='test28.txt',status='old') + + write(*,1000) +1000 format('Encoded text Recovered text n28 Err? Type'/60('-')) + + do iline=1,999999 + if(nargs.eq.0) then + read(10,'(a13)',end=999) call_0 + else + call getarg(1,call_0) + endif + if(call_0.eq.' ') exit + if(call_0(1:3).eq.'CQ ' .and. call_0(4:4).ne.' ') call_0(3:3)='_' + call_1=' ' + call pack28(call_0,n28) + call unpack28(n28,call_1) + cerr=' ' + if(call_0.ne.call_1) cerr='*' + if(call_1(1:1).eq.'<') then + i=index(call_1,'>') + bare_call_1=call_1(2:i-1)//' ' + endif + if(call_0.eq.bare_call_1) cerr=' ' + if(call_0(1:3).eq.'CQ_') call_0(3:3)=' ' + if(call_1(1:3).eq.'CQ_') call_1(3:3)=' ' + if(n28.lt.NTOKENS) write(*,1010) call_0,call_1,n28,cerr +1010 format(a13,2x,a13,i10,2x,a1,2x,'Special token') + if(n28.ge.NTOKENS .and. n28.lt.NTOKENS+MAX22) write(*,1012) call_0, & + call_1,n28,cerr +1012 format(a13,2x,a13,i10,2x,a1,2x,'22-bit hash') + if(n28.ge.NTOKENS+MAX22) write(*,1014) call_0,call_1,n28,cerr +1014 format(a13,2x,a13,i10,2x,a1,2x,'Standard callsign') + if(nargs.gt.0) exit + enddo + +999 end program test28 diff --git a/lib/77bit/test28.txt b/lib/77bit/test28.txt new file mode 100644 index 00000000..442215b6 --- /dev/null +++ b/lib/77bit/test28.txt @@ -0,0 +1,42 @@ +DE +QRZ +CQ +CQ_000 +CQ_001 +CQ_999 +CQ_A +CQ_Z +CQ_AA +CQ_ZZ +CQ_AAA +CQ_ZZZ +CQ_AAAA +CQ_ZZZZ +EI30T +YW18FIFA +KH1/KH7Z +<KH1/KH7Z> +ZS9YOTA +YB50ST +00A +99ZZZ +000A +009ZZZ +999ZZZ +HA70BAY +WB2000XYZ +WB2000XYZABCD +ZM90DX +<VP2E/KA1ABC> +HB9GOLD +A0 +A0A +K1ABC +K1JT +5B1ABC +9Y4AB +9Y4XYZ +KA1ABC +KA1JT +WB9XYZ +ZZ9ZZZ diff --git a/lib/77bit/todo.txt b/lib/77bit/todo.txt new file mode 100644 index 00000000..dcc78e1c --- /dev/null +++ b/lib/77bit/todo.txt @@ -0,0 +1,59 @@ + To Do for FT8++ + --------------- + +The following list is for informtion and general guidance. Everything +is subject to change, and not all ideas are necessarily good ones! + +1. Nomenclature and parameters for message types + - Old-style = classic 72-bit JT-style source-encoding + FT8: (174,87) code: 72-bit info, i3bit, CRC12, isync=1 + MSK144: (128,80) code: 72-bit info, CRC8 + - New-style + FT8: (174,91) code: 74+3+14, sync uses isync=2 + MSK144: (128,90) code: 74+3+13 + +2. (K1JT) For backward compatibility (good for, say, 6 months only?), +by default we'll generate old-style messages where possible, new-style +messages where they are needed. We'll decode both old and new types. + +3. (K1JT -- DONE) Two new checkboxes on Advanced tab to enable 77-bit +messages: + - "Always generate new-style (77-bit) messages." + - "Decode only 77-bit messages + +4. (K9AN -- MOSTLY DONE) New-style messages can be as long as 37 +characters. We'll need to allow for that in a number of places. + +5. (K9AN -- DONE) Subroutine genft8() will need to parse the message to be +transmitted, determine the effective message type i3 and possibly +subtype, n3. It will then generate itone, calling genft8_174_91(() if +needed. + +6. (K1JT) Code to generate the user-readable messages for each +specialized type of operating, e.g., NA VHF contest, EU VHF contest, +ARRL Field Day, ARRL RTTY Roundup, use of nonstandard calls. + +7. (??) Code to do the necessary auto-sequencing for each specialized +type of operating. + +8. (K9AN -- MOSTLY DONE) What's needed for MSK144 with LDPC(128,90) ? +Still need to work on Sh messages. How will genmsk_128_90 know when to +generate a Sh message? + +9. (K9AN) Work on the implementation of AP decoding. For which message types +should AP be implemented? For each message type/QSO state that will use +AP decoding, need to create an AP decoding table that defines the number and +type of AP decoding passes. + +========================================================================== +The following are just ideas: + +- Options to sort/filter decoded signals + +- New Fox message type using constant-envelope waveform and higher + symbol rate to accommodate multiple simultaneous QSOs. RR73 sent to + 0-5 calls, report sent to 0-5 calls. Decoding uses AP for missing + calls, thereby effectively making lower-rate codes when not all + slots are used. + +- Hound should send spots of Fox to PSK Reporter. diff --git a/lib/77bit/tokens.txt b/lib/77bit/tokens.txt new file mode 100644 index 00000000..bb514204 --- /dev/null +++ b/lib/77bit/tokens.txt @@ -0,0 +1,12 @@ +DE +QRZ +CQ +CQ_000 +CQ_313 +CQ_999 +CQ_A +CQ_AAAA +CQ_AB +CQ_ABC +CQ_ABCD +CQ_ZZZZ diff --git a/lib/77bit/wsjt-x_v2.0.txt b/lib/77bit/wsjt-x_v2.0.txt new file mode 100644 index 00000000..59464dae --- /dev/null +++ b/lib/77bit/wsjt-x_v2.0.txt @@ -0,0 +1,213 @@ + Plans for WSJT-X Version 2.0 + ---------------------------- + +This white paper describes a number of important enhancements planned +for WSJT-X Version 2.0. Most of them involve the FT8 and MSK144 +protocols, which will be upgraded to use use 77-bit information +payloads rather than the present 72 or 75 bits. This modest increase +in information content will make possible new message types that +support the following special types of QSOs and exchanged information: + +1. NA VHF Contest operation with full and transparent support of grid + locators and "/R" (Rover) callsigns + +2. EU VHF Contest operation with the exchange of 6-digit locators, QSO + serial numbers, and "/P" (portable) callsigns + +3. ARRL Field Day operation with standard Field Day exchanges + +4. ARRL RTTY Roundup operation with standard contest exchanges + +5. Better and more user-friendly support for compound and nonstandard + callsigns + +6. A special "telemetry" message format for exchange of arbitrary + information (up to 71 bits) + +Decoding sensitivity for the new messages will be essentially the same +as for the FT8 and MSK144 modes presently in WSJT-X v1.9.1. The +existing FT8 DXpedition mode will still be supported, and a more +powerful DXpedition mode may be offered as well. + +In this document we'll call the new FT8 protocol "FT8+". It will be a +superset of the FT8 implemented in v1.9.1, providing at least +temporary compatibility and inter-operability with older program +versions. We may decide to remove support for old-style 72- and +75-bit messages after a specified switchover interval. + +In contrast, the new MSK144 protocol will replace the old one without +backward compatibility. We believe the smaller and more specialized +group of MSK144 users will upgrade quickly and not find this +restriction to be a problem. + +Here are some examples of message formats that will be supported by +FT8+ and MSK144 in WSJT-X v2.0. The list is not exhaustive. +Parameters i3 and n3 (shown in column 1) are used in the software to +define major and minor 77-bit message types. + +---------------------------------------------------------------------------------- +i3.n3 Example Messages Comments +---------------------------------------------------------------------------------- + 0.0 TNX BOB 73 GL Free text + 0.1 K1ABC RR73; W9XYZ <KH1/KH7Z> -08 DXpedition Mode (sent only by Fox) + 0.2 G4ABC/P R 570007 JO22DB EU VHF Contest + 0.2 PA9XYZ 590003 IO91NP EU VHF Contest + 0.3 K1ABC W9XYZ 6A WI ARRL Field Day + 0.3 W9XYZ K1ABC R 2B EMA ARRL Field Day + 0.5 123456789ABCD Telemetry (18 hex digits) + 1. <PJ4/K1ABC> W9XYZ Compound call + 1. W9XYZ <PJ4/K1ABC> 73 + 1. CQ FD K1ABC FN42 + 1. CQ K1ABC FN42 + 1. CQ TEST K1ABC FN42 NA VHF Contest ("TEST" is optional) + 1. CQ TEST K1ABC/R FN42 + 1. K1ABC W9XYZ EN37 + 1. K1ABC W9XYZ -09 + 1. K1ABC W9XYZ R-17 + 1. K1ABC W9XYZ RRR + 1. K1ABC W9XYZ 73 + 1. K1ABC W9XYZ RR73 + 1. K1ABC/R W9XYZ EN37 + 1. K1ABC W9XYZ/R RR73 + 1. W9XYZ <YW18FIFA> -13 Nonstandard call + 1. <YW18FIFA> W9XYZ R+02 + 1. W9XYZ <YW18FIFA> RRR + 1. <YW18FIFA> W9XYZ RR73 + 2. CQ G4ABC/P IO91 + 2. G4ABC/P PA9XYZ JO22 + 2. PA9XYZ G4ABC/P RR73 + 3. K1ABC KA0DEF 559 MO ARRL RTTY Roundup + 3. K1ABC W9XYZ 579 WI ARRL RTTY Roundup + 3. KA1ABC G3AAA 529 0013 ARRL RTTY Roundup + 3. TU; G3AAA K1ABC R 559 MA ARRL RTTY Roundup + 3. TU; KA0DEF K1ABC R 569 MA ARRL RTTY Roundup + 3. W9XYZ K1ABC R 589 MA ARRL RTTY Roundup + 4. CQ KH1/KH7Z Compound call + 4. CQ YW18FIFA Nonstandard call +---------------------------------------------------------------------------------- + + +Here are some examples of minimal QSO sequences that take advantage +(where necessary) of the new protocol capabilities. Model QSOs number +1 and 2 are supported already, with the present FT8 and MSK144 +protocols, and number 3 with the existing FT8 DXpedition Mode. Model +QSOs 4-8 (and others not illustrated here) require the new protocols +with 77-bit messages. + +---------------------------------------------------------------------------------- +1. Standard QSO +---------------------------------------------------------------------------------- +CQ K1ABC FN42 + K1ABC W9XYZ EN37 +W9XYZ K1ABC -11 + K1ABC W9XYZ R-09 +W9XYZ K1ABC RRR + K1ABC W9XYZ 73 + +---------------------------------------------------------------------------------- +2. Short-cycle QSO +---------------------------------------------------------------------------------- +CQ K1ABC FN42 + K1ABC W9XYZ -09 +W9XYZ K1ABC R-11 + K1ABC W9XYZ RR73 +W9XYZ K1ABC 73 + +---------------------------------------------------------------------------------- +3. FT8 DXpedition Mode +---------------------------------------------------------------------------------- +CQ KH1/KH7Z + KH7Z K1ABC FN42 +K1ABC KH7Z -12 + KH7Z K1ABC R-14 + KH7Z W9XYZ EN37 + ... possibly other callers ... +K1ABC RR73; W9XYZ <KH1/KH7Z> -08 + +---------------------------------------------------------------------------------- +4. ARRL Field Day +---------------------------------------------------------------------------------- +CQ FD K1ABC FN42 + K1ABC W9XYZ 6A WI +W9XYZ K1ABC R 2B EMA + K1ABC W9XYZ RR73 + +---------------------------------------------------------------------------------- +5. ARRL VHF Contests +---------------------------------------------------------------------------------- +CQ TEST K1ABC/R FN42 + K1ABC/R W9XYZ EN37 +W9XYZ K1ABC/R R FN42 + K1ABC/R W9XYZ RR73 + +---------------------------------------------------------------------------------- +6. ARRL RTTY Contest +---------------------------------------------------------------------------------- +CQ TEST K1ABC FN42 + K1ABC W9XYZ 579 WI +W9XYZ K1ABC R 589 MA + K1ABC W9XYZ RR73 + +---------------------------------------------------------------------------------- +7. EU VHF Contest +---------------------------------------------------------------------------------- +CQ TEST G4ABC/P IO91 + G4ABC/P PA9XYZ JO22 +PA9XYZ 590003 IO91NP + G4ABC/P R 570007 JO22DB +PA9XYZ G4ABC/P RRR + G4ABC/P PA9XYZ 73 + +---------------------------------------------------------------------------------- +8. Compound call +---------------------------------------------------------------------------------- +CQ PJ4/K1ABC + <PJ4/K1ABC> W9XYZ +W9XYZ K1ABC -11 + K1ABC W9XYZ R-09 +W9XYZ <PJ4/K1ABC> RRR + <PJ4/K1ABC> W9XYZ 73 +---------------------------------------------------------------------------------- + + +To minimize confusion that's likely to arise during a switchover from +v1.9.1 to v2.0, we propose to follow a well advertised schedule: + +"RC1 Date" -- perhaps as early as September 15, 2018? +------------------------------------------------------- + +This will be the first chance for beta testers to try WSJT-X using the +77-bit messages. We may restrict this opportunity to specific +volunteer testers, and we'll probably include an "upgrade by +xxxx_date" message to remind people that they are using a release +intended only for testing. + +FT8+ will support the old (v1.9.1) protocol as well as the new message +types outlined above. To avoid QRMing legacy FT8 users with messages +they can't decode, we'll recommend testing FT8+ on frequencies +formerly used for JT9. + +MSK144 will be fully functional between any two stations using the RC1 +software, but it will not be backward compatible with earlier program +versions. + +"RC2, RC3,... Date" -- perhaps in October? +-------------------------------------------- + +As needed, depending on results of testing. + +GA Release Date -- perhaps in November? +--------------------------------------------- + +Official General Availability release of WSJT-X v2.0.0. The original +MSK144 protocol will be declared obsolete. + + +For reference: Dates of relevant upcoming ARRL contests +------------------------------------------------------- +VHF QSO Party: September 8-10, 2018 +RTTY Roundup: January 5-6, 2019 +VHF SS: January 19-21, 2019 + +Our proposed schedule should make WSJT-X Version 2.0 usable for +relevant ARRL operating events in 2019. diff --git a/lib/Fast_Modes.txt b/lib/Fast_Modes.txt deleted file mode 100644 index da6e27b9..00000000 --- a/lib/Fast_Modes.txt +++ /dev/null @@ -1,395 +0,0 @@ - Fast Modes in WSJT-X - -------------------- - -####################################################################### - -IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - -Third-party individuals (i.e., others not part of the WSJT development -team) have been compiling WSJT-X from the open source code and making -unauthorized "releases" of their builds. I do NOT reccommend use of -unauthorized builds on the air. If a program revision has been released -in an official way, you will see it listed here. - -If you operate with an unauthorized "rXXXX" code revisions in our -experimental code branch you have no idea what you've got. Quite -possibly, the program was built from an intermediate temporary "save" -of various files, and was not even supposed to produce a usable -program. Your observetions about what works or does not work are then -worse than useless -- they waste your time and ours. - -So please, PLEASE, *PLEASE*: use *authorized*, "released* revisions -of this still-in-development software, like the revisions described here. - -*ALSO:* If you choose to try an experimental release of JTMSK, please -accept the responsibility of reporting on your results. You can send -reports to the "wsjtgroup" reflector, wsjtgroup@yahoogroups.com, or -email them directly to me. All suggestions for improvements are -welcome! - -Bug reports should include details on how to reproduce the undesirable -program behavior. Reports on decoding performance are especially -useful when accompanied by example *.wav files with signals that -you think should have decoded, but did not. - -####################################################################### - -September 18, 2015 ------------------ - -New alpha release of experimental WSJT-X v1.6.1, r5910 ------------------------------------------------------- -Changes since revision 5889 include the following: - -1. Improved behavior for auto-QSY with "CQ nnn ..." feature. (May not -be exactly correct, yet, for all radios. Please report if you find -problems with your rig.) - -2. Allow optional use of Wide Graph in fast modes. - -3. Add UTC labels to Fast Graph spectrograms. - -4. Display correct DXCC entiry for "CQ nnn ..." messages. - -5. Implement "Save Decoded" for fast modes. - -6. Select Tx6 when "CQ Rx nnn" is enabled. - -7. Fix bug in setting of TRperiod after switch to ISCAT mode. - -8. Display proper symbol '&' in Tx messages in JTMSK mode. - - -To download this alpha release for Windows, paste the following link -into your browser: -http://physics.princeton.edu/pulsar/K1JT/wsjtx-1.6.1-r5910-win32.exe - - -- 73, Joe, K1JT - -####################################################################### - -September 12, 2015 ------------------ - -New alpha release of experimental WSJT-X v1.6.1, r5889 ------------------------------------------------------- - -A principal new feature in this release is designed to promote the use -of an agreed "calling frequency" for transmissions of the form - - CQ 265 K1ABC FN42 - -signifying that K1ABC will listen for replies on 50.265 (or 144.265, -or whatever) and will complete the QSO there. The feature uses the -rig-control features of WSJT-X to handle the necessary frequency -switching. - -########################################################################## -Changes since revision 5865 include the following: - -1. New features that allow automatic rig control when you transmit or -respond to messages of the form "CQ 265 K1ABC FN42" on an agreed -calling frequency. This feature should be especially useful for -meteor scatter. - -2. Yellow-highlighted "Tx" messages in the right text window are now -properly labeled with 6-digit UTC (hhmmss) in all fast modes. - -3. Fixed a bug (introduced in r5865) that inhibited transmitting in -JT4 mode. - -4. Fixed a bug that caused Wide Graph to continue issuing green -separator lines at short (e.g. 15 s) intervals after you have switched -to a slow mode. - -5. Fixed several more GUI appearance bugs associated with changing -modes or submodes. - -6. Fixed a bug in which double-clicking on the Fast Graph could cause -program crashes. - -7. Fixed a bug that sometimes caused "high tones" to be emitted in -JTMSK mode. - -####################################################################### -Here's a brief description of how to use the "CQ nnn ..." features. - -1. On program startup, go to the Settings | General tab and tick the -box labeled 'Rx frequency offset with "CQ nnn ..."' - -2. Select JTMSK mode and 50.280 (or your some other agreed calling -frequency) from the drop-down band menu. Remember that this menu is -not pre-populated with preferred frequencies for all modes on all -bands. Use Settings | Frequencies to add your desired modes and -frequencies to the list. - -3. Tick the unlabeled checkbox just under the "Report: spinner to -activate the "CQ Rx nnn" spinner. Set this control to your desired -QSO frequency in kHz above the nominal band edge. On 6 meters, for -example, "265" means "50.265". - -4. Your transceiver dial frequency should now show 50.265. Changes to -the "CQ Rx nnn" spinner value should be reflected immediately in the -transceiver dial frequency, the displayed value on the WSJT-X main -screen, and in Tx message #6, the "CQ nnn... " message. - -5. When you transmit the Tx6 message, the Tx frequency will be set at -the calling frequency. Otherwise (when receiving, or when -transmitting any of the messages Tx1 through Tx5) the offset frequency -(50.265 in my example) will be used. - -6. If you double-click on a received "CQ nnn ..." message on the -calling frequency, your rig will QSY to specified response frequency, -e.g. 50.265, for both Rx and Tx. - -7. To go back to listening on the calling frequency, uncheck the box -that activated the "CQ Rx nnn" spinner. - -####################################################################### - -Fair warning: I have not yet tested all possible combinations of -"Split Operation" configuration (i.e., "None", "Rig", and "Fake it"). -If you normally use Split operation, that should be OK for the "CQ -nnn ..." feature. - - -As always, please report any bugs that you find in r5889, including -pertinent details on your settings and the exact series of steps -required to reproduce the bug. - - -To download this alpha release for Windows, paste the following link -into your browser: -http://physics.princeton.edu/pulsar/K1JT/wsjtx-1.6.1-r5889-win32.exe - - - -- 73, Joe, K1JT - -####################################################################### - -New alpha release of experimental WSJT-X v1.6.1, r5865 ------------------------------------------------------- - -This alpha release of WSJT-X includes major improvements to the JTMSK -decoder. Changes since revision 5823 include the following: - -1. On-screen controls labeled "Rx nnnn Hz" and "F Tol" (Rx frequency -and tolerance) now function as expected in JTMSK mode. The frequency -search range can be up to 500 Hz, but note that sensitivity is -necessarily reduced for signals off frequency by more than about 250 -Hz. Normally you should leave Rx Freq set at 1500 Hz; suitable values -for F Tol are 100 to 500 Hz. - -2. The JTMSK decoder now makes good use of strong, short pings (as -short as 0.1 s) as well as weak pings several times longer. - -3. Improved calculation of S/N and frequency of decoded signals. - -4. Unified appearance of window titles on all non-modal windows. - -5. CW ID is disabled (for now, at least) when operating in any of the -WSJT fast modes. - -6. In WSPR mode, display of "Receiving ... <band>" messages is -disabled when band-hopping is not in use. - -7. Fixed several bugs affecting status and visibility of certain -on-screen controls after changes in operating mode. - -8. Fixed a bug allowing display of duplicate decodes for the same -signal. - -9. Fixed a bug preventing compilation on 64-bit systems, and cleaned -up some harmless compiler warnings. - -####################################################################### - Summary Description of JTMSK Protocol - -JTMSK uses the same standard message structure as slow modes JT4, JT9, -and JT65. User information is "source encoded" to 72 bits. A 15-bit -CRC is appended and a convolutional code with constraint length K=13 -and rate r=1/2 is applied, making a total of (72+15+12)*2 = 198 -information bits. Three copies of the "Barker-11" code and three -even-parity bits are added for synchronization, making a total of -198+33+3 = 234 channel symbols. Modulation uses a constant-envelope, -continuous-phase "minimum-shift keying" (MSK) waveform, with tone -frequencies of 1000 and 2000 Hz. - -####################################################################### - -To download this alpha release for Windows, paste the following link -into your browser: -http://physics.princeton.edu/pulsar/K1JT/wsjtx-1.6.1-r5865-win32.exe - - -- 73, Joe, K1JT - -August 28, 2015 ---------------- - -New release of experimental WSJT-X v1.6.1, r5823 ------------------------------------------------- - -To download for Windows, paste the following link into your browser: -http://physics.princeton.edu/pulsar/K1JT/wsjtx-1.6.1-r5823-win32.exe - -This experimental version of WSJT-X introduces a new fast mode called -JTMSK. The letters MS, of course, imply meteor scatter; the three -letters MSK mean "Minimum Shift Keying", the modulation scheme used in -this mode. - -Revision 5823 also includes a number of (mostly minor) bug fixes -relative to r5789. - -IMPORTANT: If you choose to try JTMSK, please accept the -responsibility of reporting on your results. You can send reports to -the "wsjtgroup" reflector, wsjtgroup@yahoogroups.com or email them -directly to me. All suggestions for improvements are welcome! Bug -reports should include details on how to reproduce the undesirable -program behavior. - -The present JTMSK decoder has been optimized for short pings. It does -not yet do a wide search for proper frequency alignment; you and your -QSO partner need to be "on frequency" to within +/- 100 Hz or better. -The decoder does not (yet) attempt to make optimal use of weak, slowly -varying signals. These and other characteristics may be improved in -coming revisions. - -KNOWN BUG: At present you should use T/R sequence lengths 15 s in -JTMSK mode. If you have a program crash, open Windows Task Manager, -select the "Processes" tab, right-click on wsjtx.exe, and select "End -Process Tree". Then restart the program. - -I view JTMSK as a candidate for replacing both FSK441 and JTMS for all -meteor scatter work. JTMSK has the major advantage of including -strong forward error correction (FEC), similar in usage to the schemes -used for many years in JT4, JT9, and JT65. The structure of user -messages and the format of minimal QSOs is also identical to those -other modes. But JTMSK is very fast, transmitting its full encoded -message content in 0.117 s, in a 2 kHz bandwidth. JTMSK therefore -makes much better use of short pings than (for example) JT9H can do. - -The Tx waveform of JTMSK has been carefully designed to have a number -of desirable features. All messages are exactly the same length: 72 -bits of user information are followed by a 15-bit CRC and encoded into -198 channel bits with a convolutional code (constraint length K=13, -rate r=1/2). Three sequences of the "Barker-11" code are added, along -with three parity bits, making a total of 234 channel bits in each -message. The MSK symbols for these bits are transmitted at 2000 baud, -and the full encoded message is repeated every 117 ms. - -A summary description of modulation parameters for all WSJT(-X) modes -is shown in a table posted here: -http://physics.princeton.edu/pulsar/K1JT/wsjt_modes.txt and -illustrated graphically here: -http://physics.princeton.edu/pulsar/K1JT/wsjt_modes.pdf - - -- 73, Joe, K1jT - -August 15, 2015 ---------------- - -New release of experimental WSJT-X v1.6.1, r5789 - -Changes since WSJT-X v1.6.1, revision 5779: - -1. Major speedup (5x) of fast-JT9 decoder. -2. Corrected logic for Auto-Sequencing operation. -3. Stop after sending 73 five times in auto-sequence mode. -4. Add an "Auto-Level" control to Fast Graph window. -5. Send fast-mode decodes to PSKreporter web site. -6. Support automatic logging via JTAlert-X. -7. Send fast-mode output to file ALL.TXT. -8. Better definition of dB levels for fast-JT9 signals. -9. Rationalize the GUI behavior when changing mode, submode, fast/slow - status, and T/R period. -10. Correct a flaw in the display of multiple decodes in a single - fast-JT9 sequence. -11. Fix minor bugs reported by G3WDG, ND0B, OZ1PIF, and others. - -To download for Windows, paste the following link into your browser: -http://physics.princeton.edu/pulsar/K1JT/wsjtx-1.6.1-r5789-win32.exe - -Please keep in mind that this is an experimental version of WSJT-X. -Bug reports and other feedback will be much appreciated, and will help -to make the program better! - - -- 73, Joe, K1JT - - -August 11, 2015 ---------------- - -Since its origin in the dark ages (ca. 2001) WSJT has supported "fast" -modes (designed for meteor scatter, etc.) and "slow" modes (optimized -for EME and other weak-signal propagation types). The most recent new -mode, JT9, now has *both* fast and slow submodes. - -JT9A (the "original" JT9) is like JT65 and JT4: its T/R sequences are -one minute long, and its primary goal is best possible sensitivity for -very weak, approximately steady signals. The new experimental JT9 -submodes use the same message structure, encoding, and modulation type -(9-tone FSK) as JT9A, but wider tone spacing and (optionally) faster -keying rates. - -You can download an experimental version of WSJT-X (v1.6.1, r5779) here: -http://physics.princeton.edu/pulsar/K1JT/wsjtx-1.6.1-r5779-win32.exe - -The fast submodes currently being tested, JT9E - JT9H, have been found -highly effective for meteors and ionoscatter propagation on 6 and 10 -meters. Sensitivity is similar to ISCAT, or slightly better. -Decoding is much more reliable, because the JT9 protocol includes -strong forward error correction. Decoding results are like those for -all the WSJT "slow" modes: you should see messages exactly as they -were transmitted, or nothing at all. A potential side benefit is -automatic reporting of decodes to PSKreporter. - -For details on the modulation parameters of the JT9 submodes, see the -table posted at -http://physics.princeton.edu/pulsar/K1JT/wsjt_modes.txt. - -WSJT-X v1.6.1 r5779 has the following changes from r5769: - -1. Numerous bug fixes -2. Double-click on decoded message now behaves properly -3. Faster decoding (further optimization still to come) -4. Decoded text is highlighted as in WSJT-X slow modes -5. Optional auto-sequencing - -Fair warning: auto-sequencing is basically functional, but scarcely -tested. Please watch what it is doing, and tell us how you think it -should be improved! - -If you use WSJT-X also for other modes and other purposes, you may -want to save several different sets of configuration settings. In -that case it's convenient to use the "-r xxx" option and start the -program from a command-prompt window. For example: - -C:\Users\joe> cd \wsjt\wsjtx\bin -C:\WSJT\wsjtx\bin> wsjtx -r xxx - -... where "xxx" can be anything you like, for example "ISCAT", -"FAST9", etc. - -Proper configuration for the JT9 fast modes includes the following -settings: - -On the Settings | General tab: - - - check "Enable VHF/UHF/Microwave features" - -Main window settings: - - - Mode JT9 - - Tx 700 Hz - - Rx 700 Hz - - Sync 0 - - Submode G ... or E, F, and H (H not legal in US on 10m) - - Tick "Fast" - - T/R 30 s (also 5, 10, 15 s) - - FTol 500 - -Please keep in mind that this is an experimental version of WSJT-X. -It still has some rough edges, and no doubt some bugs. Your feedback -will be much appreciated, and will help to make the program better! - - -- 73, Joe, K1JT diff --git a/lib/Makefile.mskWin b/lib/Makefile.mskWin deleted file mode 100644 index 9d5e6e62..00000000 --- a/lib/Makefile.mskWin +++ /dev/null @@ -1,75 +0,0 @@ - -# Set paths -EXE_DIR = ..\\..\\wsjtx_install -QT_DIR = C:/wsjt-env/Qt5/5.2.1/mingw48_32 -FFTW3_DIR = .. - -INCPATH = -I${QT_DIR}/include/QtCore -I${QT_DIR}/include - -# Compilers -CC = gcc -CXX = g++ -FC = gfortran -AR = ar cr -RANLIB = ranlib -MKDIR = mkdir -p -CP = cp -RM = rm -f - -FFLAGS = -O2 -fbounds-check -Wall -Wno-conversion -CFLAGS = -O2 -I. - -# Default rules -%.o: %.c - ${CC} ${CFLAGS} -c $< -%.o: %.f - ${FC} ${FFLAGS} -c $< -%.o: %.F - ${FC} ${FFLAGS} -c $< -%.o: %.f90 - ${FC} ${FFLAGS} -c $< -%.o: %.F90 - ${FC} ${FFLAGS} -c $< - -#all: jt9code JTMSKcode.exe -all: jtmsk.exe JTMSKsim.exe JTMSKcode.exe fixwav.exe - -OBJS3 = JTMSKsim.o wavhdr.o gran.o four2a.o db.o -JTMSKsim.exe: $(OBJS3) - $(FC) -o JTMSKsim.exe $(OBJS3) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS4 = jt9code.o packjt.o fmtmsg.o gen9.o deg2grid.o grid2deg.o \ - entail.o encode232.o interleave9.o graycode.o igray.o -jt9code: $(OBJS4) - $(FC) -o jt9code $(OBJS4) - -OBJS5 = JTMSKcode.o packjt.o fmtmsg.o genmsk.o deg2grid.o grid2deg.o \ - entail.o tab.o vit213.o hashing.o nhash.o -JTMSKcode.exe: $(OBJS5) - $(FC) -o JTMSKcode.exe $(OBJS5) - -OBJS6 = jtmsk.o analytic.o four2a.o db.o pctile.o \ - shell.o tweak1.o syncmsk.o genmsk.o packjt.o fmtmsg.o indexx.o \ - deg2grid.o grid2deg.o entail.o hashing.o nhash.o tab.o vit213.o \ - mskdt.o rectify_msk.o timer.o jtmsk_decode.o genmsk_short.o \ - jtmsk_short.o golay24_table.o hash.o - -jtmsk.exe: $(OBJS6) - $(FC) -o jtmsk.exe $(OBJS6) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS1 = fixwav.o wavhdr.o -fixwav.exe: $(OBJS1) - $(FC) -o fixwav.exe $(OBJS1) - -OBJS2 = t2.o four2a.o db.o -t2: $(OBJS2) - $(FC) -o t2 $(OBJS2) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS6 = t6.o four2a.o db.o -t6: $(OBJS6) - $(FC) -o t6 $(OBJS6) C:\JTSDK\fftw3f\libfftw3f-3.dll - -.PHONY : clean - -clean: - $(RM) *.o JTMSKcode JTMSKcode.exe diff --git a/lib/bpdecode128_90.f90 b/lib/bpdecode128_90.f90 new file mode 100644 index 00000000..c48ba1fa --- /dev/null +++ b/lib/bpdecode128_90.f90 @@ -0,0 +1,116 @@ +subroutine bpdecode128_90(llr,apmask,maxiterations,message77,cw,nharderror,iter) +! +! A log-domain belief propagation decoder for the (128,90) code. +! + use iso_c_binding, only: c_loc,c_size_t + use crc + integer, parameter:: N=128, K=90, M=N-K + integer*1 cw(N),apmask(N) + integer*1 decoded(K) + integer*1 message77(77) + integer Nm(11,M) + integer Mn(3,N) + integer nrw(M) + integer synd(M) + real tov(4,N) + real toc(11,M) + real tanhtoc(11,M) + real zn(N) + real llr(N) + real Tmn + + include "ldpc_128_90_reordered_parity.f90" + + decoded=0 + toc=0 + tov=0 + tanhtoc=0 +! initialize messages to checks + do j=1,M + do i=1,nrw(j) + toc(i,j)=llr((Nm(i,j))) + enddo + enddo + + ncnt=0 + + do iter=0,maxiterations + +! Update bit log likelihood ratios (tov=0 in iteration 0). + do i=1,N + if( apmask(i) .ne. 1 ) then + zn(i)=llr(i)+sum(tov(1:ncw,i)) + else + zn(i)=llr(i) + endif + enddo + +! Check to see if we have a codeword (check before we do any iteration). + cw=0 + where( zn .gt. 0. ) cw=1 + ncheck=0 + do i=1,M + synd(i)=sum(cw(Nm(1:nrw(i),i))) + if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1 +! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied' + enddo +! write(*,*) 'number of unsatisfied parity checks ',ncheck + if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it + decoded=cw(1:K) + call chkcrc13a(decoded,nbadcrc) + if(nbadcrc.eq.0) then + message77=decoded(1:77) + nharderror=count( (2*cw-1)*llr .lt. 0.0 ) + return + endif + endif + + if( iter.gt.0 ) then ! this code block implements an early stopping criterion +! if( iter.gt.10000 ) then ! this code block implements an early stopping criterion + nd=ncheck-nclast + if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased + ncnt=0 ! reset counter + else + ncnt=ncnt+1 + endif +! write(*,*) iter,ncheck,nd,ncnt + if( ncnt .ge. 3 .and. iter .ge. 5 .and. ncheck .gt. 10) then + nharderror=-1 + return + endif + endif + nclast=ncheck + +! Send messages from bits to check nodes + do j=1,M + do i=1,nrw(j) + ibj=Nm(i,j) + toc(i,j)=zn(ibj) + do kk=1,ncw ! subtract off what the bit had received from the check + if( Mn(kk,ibj) .eq. j ) then + toc(i,j)=toc(i,j)-tov(kk,ibj) + endif + enddo + enddo + enddo + +! send messages from check nodes to variable nodes + do i=1,M + tanhtoc(1:11,i)=tanh(-toc(1:11,i)/2) + enddo + + do j=1,N + do i=1,ncw + ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j + Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) + call platanh(-Tmn,y) +! y=atanh(-Tmn) + tov(i,j)=2*y + enddo + enddo + + enddo + nharderror=-1 + return + +end subroutine bpdecode128_90 diff --git a/lib/bpdecode128_90.f90.save b/lib/bpdecode128_90.f90.save new file mode 100644 index 00000000..69537afb --- /dev/null +++ b/lib/bpdecode128_90.f90.save @@ -0,0 +1,116 @@ +subroutine bpdecode128_90(llr,apmask,maxiterations,message77,cw,nharderror,iter) +! +! A log-domain belief propagation decoder for the (128,90) code. +! + use iso_c_binding, only: c_loc,c_size_t + use crc + integer, parameter:: N=128, K=90, M=N-K + integer*1 cw(N),apmask(N) + integer*1 decoded(K) + integer*1 message77(77) + integer Nm(12,M) + integer Mn(4,N) + integer nrw(M),ncw(N) + integer synd(M) + real tov(4,N) + real toc(12,M) + real tanhtoc(12,M) + real zn(N) + real llr(N) + real Tmn + + include "ldpc_128_90_b_reordered_parity.f90" + + decoded=0 + toc=0 + tov=0 + tanhtoc=0 +! initialize messages to checks + do j=1,M + do i=1,nrw(j) + toc(i,j)=llr((Nm(i,j))) + enddo + enddo + + ncnt=0 + + do iter=0,maxiterations + +! Update bit log likelihood ratios (tov=0 in iteration 0). + do i=1,N + if( apmask(i) .ne. 1 ) then + zn(i)=llr(i)+sum(tov(1:ncw(i),i)) + else + zn(i)=llr(i) + endif + enddo + +! Check to see if we have a codeword (check before we do any iteration). + cw=0 + where( zn .gt. 0. ) cw=1 + ncheck=0 + do i=1,M + synd(i)=sum(cw(Nm(1:nrw(i),i))) + if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1 +! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied' + enddo +! write(*,*) 'number of unsatisfied parity checks ',ncheck + if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it + decoded=cw(1:K) + call chkcrc13a(decoded,nbadcrc) + if(nbadcrc.eq.0) then + message77=decoded(1:77) + nharderror=count( (2*cw-1)*llr .lt. 0.0 ) + return + endif + endif + + if( iter.gt.0 ) then ! this code block implements an early stopping criterion +! if( iter.gt.10000 ) then ! this code block implements an early stopping criterion + nd=ncheck-nclast + if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased + ncnt=0 ! reset counter + else + ncnt=ncnt+1 + endif +! write(*,*) iter,ncheck,nd,ncnt + if( ncnt .ge. 3 .and. iter .ge. 5 .and. ncheck .gt. 10) then + nharderror=-1 + return + endif + endif + nclast=ncheck + +! Send messages from bits to check nodes + do j=1,M + do i=1,nrw(j) + ibj=Nm(i,j) + toc(i,j)=zn(ibj) + do kk=1,4 ! subtract off what the bit had received from the check + if( Mn(kk,ibj) .eq. j ) then + toc(i,j)=toc(i,j)-tov(kk,ibj) + endif + enddo + enddo + enddo + +! send messages from check nodes to variable nodes + do i=1,M + tanhtoc(1:12,i)=tanh(-toc(1:12,i)/2) + enddo + + do j=1,N + do i=1,ncw(j) + ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j + Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) + call platanh(-Tmn,y) +! y=atanh(-Tmn) + tov(i,j)=2*y + enddo + enddo + + enddo + nharderror=-1 + return + +end subroutine bpdecode128_90 diff --git a/lib/crc.f90 b/lib/crc.f90 index 423f5492..f0cd17e3 100644 --- a/lib/crc.f90 +++ b/lib/crc.f90 @@ -10,7 +10,7 @@ module crc integer (c_int), value :: length end function crc14 - function crc14_check (data, length) bind (C, name="crc16_check") + function crc14_check (data, length) bind (C, name="crc14_check") use, intrinsic :: iso_c_binding, only: c_bool, c_ptr, c_int implicit none logical (c_bool) :: crc14_check @@ -18,21 +18,21 @@ module crc integer (c_int), value :: length end function crc14_check - function crc12 (data, length) bind (C, name="crc12") + function crc13 (data, length) bind (C, name="crc13") use, intrinsic :: iso_c_binding, only: c_short, c_ptr, c_int implicit none - integer (c_short) :: crc12 + integer (c_short) :: crc13 type (c_ptr), value :: data integer (c_int), value :: length - end function crc12 + end function crc13 - function crc12_check (data, length) bind (C, name="crc12_check") + function crc13_check (data, length) bind (C, name="crc13_check") use, intrinsic :: iso_c_binding, only: c_bool, c_ptr, c_int implicit none - logical (c_bool) :: crc12_check + logical (c_bool) :: crc13_check type (c_ptr), value :: data integer (c_int), value :: length - end function crc12_check + end function crc13_check function crc10 (data, length) bind (C, name="crc10") use, intrinsic :: iso_c_binding, only: c_short, c_ptr, c_int diff --git a/lib/crc12.cpp b/lib/crc12.cpp deleted file mode 100644 index 44e50fe7..00000000 --- a/lib/crc12.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include <boost/crc.hpp> -#include <boost/config.hpp> - -extern "C" -{ - short crc12 (unsigned char const * data, int length); - bool crc12_check (unsigned char const * data, int length); -} - -#define POLY 0xc06 - -#ifdef BOOST_NO_CXX11_CONSTEXPR -#define TRUNCATED_POLYNOMIAL POLY -#else -namespace -{ - unsigned long constexpr TRUNCATED_POLYNOMIAL = POLY; -} -#endif - -// assumes CRC is last 16 bits of the data and is set to zero -// caller should assign the returned CRC into the message in big endian byte order -short crc12 (unsigned char const * data, int length) -{ - return boost::augmented_crc<12, TRUNCATED_POLYNOMIAL> (data, length); -} - -bool crc12_check (unsigned char const * data, int length) -{ - return !boost::augmented_crc<12, TRUNCATED_POLYNOMIAL> (data, length); -} diff --git a/lib/crc13.cpp b/lib/crc13.cpp new file mode 100644 index 00000000..03265088 --- /dev/null +++ b/lib/crc13.cpp @@ -0,0 +1,31 @@ +#include <boost/crc.hpp> +#include <boost/config.hpp> + +extern "C" +{ + short crc13 (unsigned char const * data, int length); + bool crc13_check (unsigned char const * data, int length); +} + +#define POLY 0x15D7 + +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define TRUNCATED_POLYNOMIAL POLY +#else +namespace +{ + unsigned long constexpr TRUNCATED_POLYNOMIAL = POLY; +} +#endif + +// assumes CRC is last 13 bits of the data and is set to zero +// caller should assign the returned CRC into the message in big endian byte order +short crc13 (unsigned char const * data, int length) +{ + return boost::augmented_crc<13, TRUNCATED_POLYNOMIAL> (data, length); +} + +bool crc13_check (unsigned char const * data, int length) +{ + return !boost::augmented_crc<13, TRUNCATED_POLYNOMIAL> (data, length); +} diff --git a/lib/decoder.f90 b/lib/decoder.f90 index d5607ebd..730c59d1 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -67,20 +67,6 @@ subroutine multimode_decoder(ss,id2,params,nfsample) else open(13,file=trim(temp_dir)//'/decoded.txt',status='unknown',iostat=ios) endif - if(params%nmode.eq.8) then - inquire(file=trim(temp_dir)//'/houndcallers.txt',exist=ex) - if(.not.ex) then - c2fox=' ' - g2fox=' ' - nsnrfox=-99 - nfreqfox=-99 - n30z=0 - nwrap=0 - nfox=0 - endif - open(19,file=trim(temp_dir)//'/houndcallers.txt',status='unknown') - endif - if(ios.ne.0) then nfail=nfail+1 if(nfail.le.3) then @@ -91,46 +77,67 @@ subroutine multimode_decoder(ss,id2,params,nfsample) if(params%nmode.eq.8) then ! We're in FT8 mode + + if(ncontest.eq.5) then +! Fox mode: initialize and open houndcallers.txt + inquire(file=trim(temp_dir)//'/houndcallers.txt',exist=ex) + if(.not.ex) then + c2fox=' ' + g2fox=' ' + nsnrfox=-99 + nfreqfox=-99 + n30z=0 + nwrap=0 + nfox=0 + endif + open(19,file=trim(temp_dir)//'/houndcallers.txt',status='unknown') + endif + call timer('decft8 ',0) newdat=params%newdat + ncontest=iand(params%nexp_decode,7) call my_ft8%decode(ft8_decoded,id2,params%nQSOProgress,params%nfqso, & params%nftx,newdat,params%nutc,params%nfa,params%nfb, & - params%nexp_decode,params%ndepth,logical(params%nagain), & - logical(params%lft8apon),logical(params%lapcqonly),params%napwid, & - mycall,mygrid,hiscall,hisgrid) + params%ndepth,ncontest,logical(params%nagain), & + logical(params%lft8apon),logical(params%lapcqonly), & + params%napwid,mycall,hiscall,hisgrid) call timer('decft8 ',1) if(nfox.gt.0) then n30min=minval(n30fox(1:nfox)) n30max=maxval(n30fox(1:nfox)) endif j=0 - rewind 19 - if(nfox.eq.0) then - endfile 19 + + if(ncontest.eq.5) then +! Fox mode: save decoded Hound calls for possible selection by FoxOp rewind 19 - else - do i=1,nfox - n=n30fox(i) - if(n30max-n30fox(i).le.4) then - j=j+1 - c2fox(j)=c2fox(i) - g2fox(j)=g2fox(i) - nsnrfox(j)=nsnrfox(i) - nfreqfox(j)=nfreqfox(i) - n30fox(j)=n - m=n30max-n - if(len(trim(g2fox(j))).eq.4) then - call azdist(mygrid,g2fox(j),0.d0,nAz,nEl,nDmiles,nDkm, & - nHotAz,nHotABetter) - else - nDkm=9999 + if(nfox.eq.0) then + endfile 19 + rewind 19 + else + do i=1,nfox + n=n30fox(i) + if(n30max-n30fox(i).le.4) then + j=j+1 + c2fox(j)=c2fox(i) + g2fox(j)=g2fox(i) + nsnrfox(j)=nsnrfox(i) + nfreqfox(j)=nfreqfox(i) + n30fox(j)=n + m=n30max-n + if(len(trim(g2fox(j))).eq.4) then + call azdist(mygrid,g2fox(j),0.d0,nAz,nEl,nDmiles,nDkm, & + nHotAz,nHotABetter) + else + nDkm=9999 + endif + write(19,1004) c2fox(j),g2fox(j),nsnrfox(j),nfreqfox(j),nDkm,m +1004 format(a12,1x,a4,i5,i6,i7,i3) endif - write(19,1004) c2fox(j),g2fox(j),nsnrfox(j),nfreqfox(j),nDkm,m -1004 format(a12,1x,a4,i5,i6,i7,i3) - endif - enddo - nfox=j - flush(19) + enddo + nfox=j + flush(19) + endif endif go to 800 endif @@ -463,8 +470,8 @@ contains real, intent(in) :: dt real, intent(in) :: freq character(len=37), intent(in) :: decoded - character c1*12,c2*12,g2*4,w*4,ctmp*12 - integer i0,i1,i2,i3,i4,i5,i6,n30,nwrap + character c1*12,c2*12,g2*4,w*4 + integer i0,i1,i2,i3,i4,i5,n30,nwrap integer, intent(in) :: nap real, intent(in) :: qual character*2 annot @@ -493,16 +500,20 @@ contains decoded0=decoded annot=' ' - if(nap.ne.0) then + if(ncontest.eq.0 .and. nap.ne.0) then write(annot,'(a1,i1)') 'a',nap - if(qual.lt.0.17) decoded0(22:22)='?' + if(qual.lt.0.17) decoded0(37:37)='?' endif - i0=index(decoded0,';') +! i0=index(decoded0,';') +! Always print 37 characters? Or, send i3,n3 up to here from ft8b_2 and use them +! to decide how many chars to print? +!TEMP + i0=1 if(i0.le.0) write(*,1000) params%nutc,snr,dt,nint(freq),decoded0(1:22),annot 1000 format(i6.6,i4,f5.1,i5,' ~ ',1x,a22,1x,a2) - if(i0.gt.0) write(*,1001) params%nutc,snr,dt,nint(freq),decoded0 -1001 format(i6.6,i4,f5.1,i5,' ~ ',1x,a37) + if(i0.gt.0) write(*,1001) params%nutc,snr,dt,nint(freq),decoded0,annot +1001 format(i6.6,i4,f5.1,i5,' ~ ',1x,a37,1x,a2) write(13,1002) params%nutc,nint(sync),snr,dt,freq,0,decoded0 1002 format(i6.6,i4,i5,f6.1,f8.0,i4,3x,a37,' FT8') diff --git a/lib/digi-contest.txt b/lib/digi-contest.txt new file mode 100644 index 00000000..b0eafaec --- /dev/null +++ b/lib/digi-contest.txt @@ -0,0 +1,277 @@ + Possible FT8 Enhancements for Contesting + ---------------------------------------- + +In addition to all the standard FT8 messages, FT8 DXpedition Mode +defines a new message type to convey messages like this example +acknowledging completion of a QSO with K1ABC and initiating a QSO with +W9XYZ: + + K1ABC RR73; W9XYZ <KH1/KH7Z> -11 + +With 15s T/R sequencing and otherwise using standard FT8 messages, +this feature allows QSO rates up to 120/hour with one Tx signal. The +callsign enclosed in angle brackets is sent as a 10-bit hash code. + +High QSO rates are also desirable for contest operating, but some +details are quite different from the DXpedition case. Contesting is a +many-to-many (as opposed to many-to-one) activity. We distinguish +between "Run stations" and "S+P stations" rather than between "Fox" +and "Hounds". + +An optimal sequence of messages suitable for contesting looks +something like the list in Table 1, where {exch} represents the +required contest exchange. With 15 s transmissions and a steady +stream of callers, messages like these can support QSO rates +approaching 120/hour. + +Table 1. Example sequence of FT8 contest messages +------------------------------------------------------------------------- + Run station S+P stations +------------------------------------------------------------------------- +1. CQ K1ABC +2. K1ABC W9XYZ, K1ABC G4AAA, ... +3. W9XYZ K1ABC {exch} +4. K1ABC W9XYZ {exch} +5. TU; G4AAA K1ABC {exch} +6. K1ABC G4AAA {exch} +7. TU; VE2BBB K1ABC {exch} +8. K1ABC VE2BBB {exch} +9. ... +------------------------------------------------------------------------- + +In some circumstances one or both station callsigns may safely be +taken as known by context. High-rate contest transmissions in SSB, +CW, and RTTY can therefore be considerably shortened with no resulting +ambiguity for attentive operators. CQing stations need not include +their own callsign in every transmission, while S+P stations may send +only their own callsign at first, as in line 2 of Table 2, and then +only the contest exchange, as in line 4. + +Table 2. Abbreviated contest messages +------------------------------------------------------------------------- + Run station S+P stations +------------------------------------------------------------------------- +1. CQ K1ABC +2. W9XYZ, G4AAA, ... +3. W9XYZ {exch} +4. {exch} (sent by W9XYZ) +5. TU; G4AAA {exch} +6. {exch} (sent by G4AAA) +7. TU; VE2BBB {exch} +8. {exch} (sent by VE2BBB) +9. TU; CQ K1ABC +10. ... +------------------------------------------------------------------------- + +There would be no advantage to such message brevity with FT8. FT8 +transmissions are of fixed duration, by design; and the AP decoder can +treat the home callsign and previously decoded callsigns as +hypothetically given, thereby making the effective code rate lower and +sensitivity up to 4 dB better. + +Required exchange information for some relevant contests is +illustrated in Table 3, along with a breakdown of bit requirements for +each component of the exchange. Lower-case letter-number combinations +such as r1, r3, s7,... in the table suggest the meanings and indicate +the number of bits required to convey each part of the exchange. +Further details are given below the Table. Parameter T1 is the total +number of exchange bits, and T2=T1+56 is the number of bits for the +full message, including two standard 28-bit callsigns. + +Table 3. Examples of required contest exchanges {exch} +------------------------------------------------------------------------------ +Event Exchange Example Bits T1 T2 +------------------------------------------------------------------------------ +ARRL RTTY US/Can: rpt state/prov R 579 MA r1 r3 s7 11 67 + DX: rpt serial R 559 0013 r1 r3 n12 16 72 + +Field Day US/Can: OpClass Section R 6A EMA r1 n5 c3 s7 16 72 + DX: OpClass DX R 1A DX r1 n5 c3 s7 16 72 + +CQ WPX RTTY RST + serial R 589 0013 r1 r3 n12 16 72 + +CQ WW RTTY US/Can: RST CQZ state/prov R 579 8 NJ r1 r3 z6 s6 16 72 + DX: RST + CQzone R 559 3 r1 r3 z6 10 66 + +ARRL VHF+ grid4 R FN42 r1 g15 16 72 + +EU VHF+ rpt serial grid6 R 590013 IO91NP r1 r3 n12 g25 41 97 +------------------------------------------------------------------------------ +Meaning and number of bits for each exchange component: + +c3 Operating class (A-F) +g15 grid4 +g25 grid6 +n12 Serial number +n5 Number of transmitters (0-31) +r1 acknowledgment of received exchange +r3 3-bit report (0-7 ==> -24 to +18 dB, effectively "S2 to "S9") +s6 US state or Canadian province (48+14=62) +s7 ARRL/RAC Section (83 sections) +z6 CQ zone +------------------------------------------------------------------------------ + +How best to accommodate all these possibilities within the 72+3-bit +FT8 message payload? Let i3 (aka "i3bit") denote message type, with +available range 0-7. Type 0 is already used for standard JT-style +structured messages and free text, and type 1 for DXpedition mode. +Examples of suggested new message types 2 through 6 are summarized in +the Table 4. + +Table 4. Proposed FT8 message types +------------------------------------------------------------------------------ +i3 Example message Bits i72 Total Special purpose +------------------------------------------------------------------------------ +0 K1ABC W9XYZ EN37 28 28 15 0 72 Standard message +0 FREE TEXT 71 1 72 Free text +1 K1ABC RR73; W9XYZ <KH1/KH7Z> -11 28 28 10 6 72 DXpedition Mode +2 W9XYZ K1ABC x16 28 28 16 72 Contesting +3 TU; G4AAA K1ABC x16 28 28 16 72 Contesting with "TU;" +4 <K1ABC> W9XYZ/R R x25 17 28 1 1 25 72 Rovers, Grid6 +5 <K1ABC> PJ4/W9XYZ 17 49 66 Compound TxCall +6 PA9XYZ R 590003 IO91NP 28 1 3 12 24 68 EU VHF contest +7 tbd... + +The first callsign in a message can also be "CQ" and a few other +special tokens. Type 3 messages are the same as type 2 except for +including "TU;", the completion-of-QSO indicator. Message fragments +x16 and x25 represent generic contest exchanges. A "contest template" +will define the specific source encoding/decoding needed for each +event. + +Suggested message types 4 and 5 use a 17-bit hash for the first +callsign. I'm imagining that we'd start with a 32-bit crc and then +use its remainder after dividing by the prime number 131063. Values +less than 131063 will be the desired hash code, and the nine values +131063-131071 can be assigned special meanings such as CQ, QRZ, etc. +Type 4 messages identify the transmitting station as a Rover and can +also accommodate 6-digit grid locators. Type 5 messages allow the +transmitting station to send a full compound callsign with add-on +prefixes up to 4 characters and suffixes up to 3. Compound callsigns +are also permissible for the hashed callsigns in message types 4 and +5. + +Contest Operating +----------------- + +Operating in this proposed FT8 Contest Mode would be similar to that +in current RTTY contests. CQing stations will be distributed over 20 +kHz or more on each band, perhaps at ~500 Hz separation. They will +respond to callers on their own frequency +/- ~200 Hz. Thus, a CQing +station and callers should occupy no more than 500 Hz total bandwidth. +CQers might always transmit at Tx audio frequency 1750 Hz and +configure their FT8 decoders to respond to signals between 1500 and +2000 Hz. S+P stations will typically work their way up or down the +band, perhaps in steps of 2 or 3 kHz, looking for unworked CQers. The +FT8 Contest GUI will offer special features for CQ mode and S+P mode +that make such conventions easy to follow. + +Some Pertinent Questions +------------------------ + +1. FT8 is a good mode, but does it make for a good contesting mode? + +The model described above maxes out at 120 QSOs/hour. (One can +imagine SO2R or even SO3R extensions, doubling or tripling that +limit.) Should we consider T/R sequences of 10s, or even 5s, to get +potentially higher rates? Should we consider giving up synchronized, +fixed-length sequences entirely, and use operator-determined start +times and transmission lengths? That's a significant departure from +all existing WSJT-X modes. + +2. How much automation should be permissible? + +We're not aiming to make a contesting robot. We want something that +rewards operator and station performance. The recently introduced FT8 +DXpedition Mode offers the "Fox" operator a list of decoded "Hounds" +sorted by Call, Grid, S/N, Distance, or Random order. Hounds must +initiate their calls to Fox, and Fox must manually select each Hound +to be called. Otherwise, QSOs proceed with standard FT8 +"auto-sequencing". Is this model acceptable? + +3. How much bandwidth? How much sensitivity? + +RTTY signals use bandwidth ~220 Hz and require S/N around -5 dB or +better, measured in a 2500 Hz bandwidth. FT8 uses signal bandwidth 50 +Hz and reaches threshold sensitivity between -20 and -24 dB, depending +on how much a priori (AP) information is available. Shorter +transmissions conveying the same messages would increase the +bandwidth, S/N threshold, and potential QSO rate proportionally. Has +FT8 already hit the "sweet spot" of such trade-offs? + +4. Suitable power limits? + +WSJT-X modes are designed as weak-signal modes. They have strong FEC +and don't suffer from partial or corrupted copy. Sensitivity already +beats RTTY by 15-19 dB, so arguably it makes sense for an FT8 contest +or contest category to be limited to 100 W or even QRP power levels. + +5. What software should provide the operator's GUI? + +Things are described above as though WSJT-X, the software that +introduced FT8, would be used for contest operating. WSJT-X can send +QSO information to N1MM+ and other logging programs, so they could be +used in combination with WSJT-X. Alternatively, we could set things +up so that N1MM+ is the control program and FT8 encoding/decoding is +provided by a plug-in "MMFT8" similar to MMTTY. Operators already +into serious RTTY contesting would probably like the N1MM-in-control +option. However, existing FT8 users might be more comfortable with +WSJT-X in full control. Moreover, WSJT-X offers full support for +Linux and MacOS, which N1MM+ does not. + +######################################################################## + +More thinking, beyond the above... + +FT8 currently uses LDPC(174,87), where 87=72+3+12. Suggest going to +LDPC(174,91), with 91=72+5+14. This would give us 32 message types +rather than 7, and stronger suppression of false decodes. SNR penalty +would be 10log(91/87)=0.2 dB. + +MSK144 currently uses LDPC(128,80), where 80=72+8. Suggest going to +LDPC(128,87), with 87=72+5+10. SNR penalty is 0.4 dB. + +ARRL RTTY Roundup +------------------------------------------------------------------------- + Run station S+P stations +------------------------------------------------------------------------- +1. CQ K1ABC +2. K1ABC W9XYZ, K1ABC G4AAA, ... +3. W9XYZ K1ABC 579 MA +4. K1ABC W9XYZ 599 WI +5. TU; G4AAA K1ABC 559 MA +6. K1ABC G4AAA 579 0013 +7. TU; VE2BBB K1ABC 599 MA +8. K1ABC VE2BBB 599 QC +9. TU; CQ K1ABC +------------------------------------------------------------------------- + + +NA VHF Contest +------------------------------------------------------------------------- + Run station S+P station i3 +------------------------------------------------------------------------- +1. CQ K1ABC/R FN54 0 +2. K1ABC W9XYZ EN37 0 +3. W9XYZ K1ABC R FN54 2 +4. K1ABC W9XYZ RR73 0 +5. CQ K1ABC/R FN54 0 +------------------------------------------------------------------------- +1. CQ K1ABC FN42 0 +2. <K1ABC> W9XYZ/R EN47 5 +3. W9XYZ K1ABC R FN42 0 +4. DE W9XYZ/R RR73 0 +5. CQ K1ABC FN42 0 +------------------------------------------------------------------------- + + + +EU VHF+ Contest +------------------------------------------------------------------------- + Run station S+P station i3 +------------------------------------------------------------------------- +1. CQ G4ABC IO91 0 +2. G4ABC PA9XYZ JO22 0 +3. PA9XYZ 590003 IO91NP 6 +4. G4ABC R 570007 JO22DB 6 +5. PA9XYZ G4ABC RR73 0 diff --git a/lib/emedop.dat b/lib/emedop.dat new file mode 100644 index 00000000..c37d5b85 --- /dev/null +++ b/lib/emedop.dat @@ -0,0 +1,8 @@ +Lat_A 40.35417 +WLong_A 75.62500 +Lat_B 45.1875 +WLong_B -1.541667 +TxFreqMHz 143.05 +StartTime 20180907 08:00:00 +StopTime 20180907 09:00:00 +StepSec 60.0 diff --git a/lib/emedop.f90 b/lib/emedop.f90 new file mode 100644 index 00000000..4a95fb87 --- /dev/null +++ b/lib/emedop.f90 @@ -0,0 +1,67 @@ +program emedop + + real*8 txfreq8 + real*8 rxfreq8 + real*4 LST + real*4 lat_a + real*4 lat_b + character*80 infile + character*256 jpleph_file_name + common/jplcom/jpleph_file_name + data jpleph_file_name/'JPLEPH'/ + + nargs=iargc() + if(nargs.ne.1) then + print*,'Usage: emedop <infile>' + go to 999 + endif + + call getarg(1,infile) + open(10,file=infile,status='old',err=900) + read(10,1001) lat_a +1001 format(10x,f12.0) + read(10,1001) wlon_a + read(10,1001) lat_b + read(10,1001) wlon_b + read(10,1001) txfreq8 + read(10,1002) nyear,month,nday,ih,im,is +1002 format(10x,i4,2i2,1x,i2,1x,i2,1x,i2) + sec_start=3600.0*ih + 60.0*im + is + read(10,1002) nyear,month,nday,ih,im,is + sec_stop=3600.0*ih + 60.0*im + is + read(10,1001) sec_step + + write(*,1005) +1005 format(' Date UTC Tx Freq Rx Freq Doppler'/ & + '------------------------------------------------------') + + sec=sec_start + ncalc=(sec_stop - sec_start)/sec_step + + do icalc=1,ncalc + uth=sec/3600.0 + call MoonDopJPL(nyear,month,nday,uth,-wlon_a,lat_a,RAMoon,DecMoon, & + LST,HA,AzMoon,ElMoon,vr_a,techo) + + call MoonDopJPL(nyear,month,nday,uth,-wlon_b,lat_b,RAMoon,DecMoon, & + LST,HA,AzMoon,ElMoon,vr_b,techo) + + dop_a=-txfreq8*vr_a/2.99792458e5 !One-way Doppler from a + dop_b=-txfreq8*vr_b/2.99792458e5 !One-way Doppler to b + doppler=1.e6*(dop_a + dop_b) + rxfreq8=txfreq8 + dop_a + dop_b + + ih=sec/3600.0 + im=(sec-ih*3600.0)/60.0 + is=nint(mod(sec,60.0)) + write(*,1010) nyear,month,nday,ih,im,is,txFreq8,rxFreq8,doppler +1010 format(i4,2i2.2,2x,i2.2,':',i2.2,':',i2.2,2f13.7,f8.1) + + sec=sec + sec_step + enddo + go to 999 +900 print*,'Cannot open file ',trim(infile) +999 end program emedop + + + diff --git a/lib/encode4.f90 b/lib/encode4.f90 index 4e73699b..bf1f0a8f 100644 --- a/lib/encode4.f90 +++ b/lib/encode4.f90 @@ -9,7 +9,7 @@ subroutine encode4(message,ncode) integer*1 data0(13),symbol(216) call chkmsg(message,cok,nspecial,flip) - call packmsg(message,dgen,itype,.false.) !Pack 72-bit message into 12 six-bit symbols + call packmsg(message,dgen,itype) !Pack 72-bit message into 12 six-bit symbols call entail(dgen,data0) call encode232(data0,206,symbol) !Convolutional encoding call interleave4(symbol,1) !Apply JT4 interleaving diff --git a/lib/encode_128_90.f90 b/lib/encode_128_90.f90 new file mode 100644 index 00000000..e59cf11b --- /dev/null +++ b/lib/encode_128_90.f90 @@ -0,0 +1,58 @@ +subroutine encode_128_90(message77,codeword) +! +! Add a 13-bit CRC to a 77-bit message and return a 128-bit codeword +! +use, intrinsic :: iso_c_binding +use iso_c_binding, only: c_loc,c_size_t +use crc + +integer, parameter:: N=128, K=90, M=N-K +character*90 tmpchar +integer*1 codeword(N) +integer*1 gen(M,K) +integer*1 message77(77),message(K) +integer*1 pchecks(M) +integer*1, target :: i1MsgBytes(12) +include "ldpc_128_90_generator.f90" +logical first +data first/.true./ +save first,gen + +if( first ) then ! fill the generator matrix + gen=0 + do i=1,M + do j=1,23 + read(g(i)(j:j),"(Z1)") istr + ibmax=4 + if(j.eq.23) ibmax=2 + do jj=1, ibmax + icol=(j-1)*4+jj + if( btest(istr,4-jj) ) gen(i,icol)=1 + enddo + enddo + enddo +first=.false. +endif + +! Add 13 bit CRC to form 90-bit message+CRC13 +write(tmpchar,'(77i1)') message77 +tmpchar(78:80)='000' +i1MsgBytes=0 +read(tmpchar,'(10b8)') i1MsgBytes(1:10) +ncrc13 = crc13 (c_loc (i1MsgBytes), 12) +write(tmpchar(78:90),'(b13)') ncrc13 +read(tmpchar,'(90i1)') message + +do i=1,M + nsum=0 + do j=1,K + nsum=nsum+message(j)*gen(i,j) + enddo + pchecks(i)=mod(nsum,2) +enddo + +codeword(1:K)=message +codeword(K+1:N)=pchecks + +return +end subroutine encode_128_90 diff --git a/lib/encode_msk144.f90 b/lib/encode_msk144.f90 deleted file mode 100644 index 4e4d8968..00000000 --- a/lib/encode_msk144.f90 +++ /dev/null @@ -1,111 +0,0 @@ -subroutine encode_msk144(message,codeword) -! Encode an 80-bit message and return a 128-bit codeword. -! The generator matrix has dimensions (48,80). -! The code is a (128,80) regular ldpc code with column weight 3. -! The code was generated using the PEG algorithm. -! After creating the codeword, the columns are re-ordered according to -! "colorder" to make the codeword compatible with the parity-check -! matrix stored in Radford Neal's "pchk" format. -! -character*20 g(48) -integer*1 codeword(128) -integer*1 colorder(128) -integer*1 gen144(48,80) -integer*1 itmp(128) -integer*1 message(80) -integer*1 pchecks(48) -logical first -data first/.true./ -data g/ & !parity-check generator matrix for (128,80) code - "24084000800020008000", & - "b39678f7ccdb1baf5f4c", & - "10001000400408012000", & - "08104000100002010800", & - "dc9c18f61ea0e4b7f05c", & - "42c040160909ca002c00", & - "cc50b52b9a80db0d7f9e", & - "dde5ace80780bae74740", & - "00800080020000890080", & - "01020040010400400040", & - "20008010020000100030", & - "80400008004000040050", & - "a4b397810915126f5604", & - "04040100001040200008", & - "00800006000888000800", & - "00010c00000104040001", & - "cc7cd7d953cdc204eba0", & - "0094abe7dd146beb16ce", & - "5af2aec8c7b051c7544a", & - "14040508801840200088", & - "7392f5e720f8f5a62c1e", & - "503cc2a06bff4e684ec9", & - "5a2efd46f1efbb513b80", & - "ac06e9513fd411f1de03", & - "16a31be3dd3082ca2bd6", & - "28542e0daf62fe1d9332", & - "00210c002001540c0401", & - "0ed90d56f84298706a98", & - "939670f7ecdf9baf4f4c", & - "cfe41dec47a433e66240", & - "16d2179c2d5888222630", & - "408000160108ca002800", & - "808000830a00018900a0", & - "9ae2ed8ef3afbf8c3a52", & - "5aaafd86f3efbfc83b02", & - "f39658f68cdb0baf1f4c", & - "9414bb6495106261366a", & - "71ba18670c08411bf682", & - "7298f1a7217cf5c62e5e", & - "86d7a4864396a981369b", & - "a8042c01ae22fe191362", & - "9235ae108b2d60d0e306", & - "dfe5ade807a03be74640", & - "d2451588e6e27ccd9bc4", & - "12b51ae39d20e2ea3bde", & - "a49387810d95136fd604", & - "467e7578e51d5b3b8a0e", & - "f6ad1ac7cc3aaa3fe580"/ - -data colorder/0,1,2,3,4,5,6,7,8,9, & - 10,11,12,13,14,15,24,26,29,30, & - 32,43,44,47,60,77,79,97,101,111, & - 96,38,64,53,93,34,59,94,74,90, & - 108,123,85,57,70,25,69,62,48,49, & - 50,51,52,33,54,55,56,21,58,36, & - 16,61,23,63,20,65,66,67,68,46, & - 22,71,72,73,31,75,76,45,78,17, & - 80,81,82,83,84,42,86,87,88,89, & - 39,91,92,35,37,95,19,27,98,99, & - 100,28,102,103,104,105,106,107,40,109, & - 110,18,112,113,114,115,116,117,118,119, & - 120,121,122,41,124,125,126,127/ - -save first,gen144 - -if( first ) then ! fill the generator matrix - gen144=0 - do i=1,48 - do j=1,5 - read(g(i)( (j-1)*4+1:(j-1)*4+4 ),"(Z4)") istr - do jj=1,16 - icol=(j-1)*16+jj - if( btest(istr,16-jj) ) gen144(i,icol)=1 - enddo - enddo - enddo -first=.false. -endif - -do i=1,48 - nsum=0 - do j=1,80 - nsum=nsum+message(j)*gen144(i,j) - enddo - pchecks(i)=mod(nsum,2) -enddo -itmp(1:48)=pchecks -itmp(49:128)=message(1:80) -codeword(colorder+1)=itmp(1:128) - -return -end subroutine encode_msk144 diff --git a/lib/extract.f90 b/lib/extract.f90 index a6514fe0..d1a483d3 100644 --- a/lib/extract.f90 +++ b/lib/extract.f90 @@ -73,27 +73,27 @@ subroutine extract(s3,nadd,mode65,ntrials,naggressive,ndepth,nflip, & apsymbols(1,1:4)=(/62,32,32,49/) ! CQ if(len_trim(mycall).gt.0) then apmessage=mycall//" "//mycall//" RRR" - call packmsg(apmessage,ap,itype,.false.) + call packmsg(apmessage,ap,itype) if(itype.ne.1) ap=-1 apsymbols(2,1:4)=ap(1:4) !write(*,*) 'mycall symbols ',ap(1:4) if(len_trim(hiscall).gt.0) then apmessage=mycall//" "//hiscall//" RRR" - call packmsg(apmessage,ap,itype,.false.) + call packmsg(apmessage,ap,itype) if(itype.ne.1) ap=-1 apsymbols(3,1:9)=ap(1:9) apsymbols(4,:)=ap apmessage=mycall//" "//hiscall//" 73" - call packmsg(apmessage,ap,itype,.false.) + call packmsg(apmessage,ap,itype) if(itype.ne.1) ap=-1 apsymbols(5,:)=ap if(len_trim(hisgrid(1:4)).gt.0) then apmessage=mycall//' '//hiscall//' '//hisgrid(1:4) - call packmsg(apmessage,ap,itype,.false.) + call packmsg(apmessage,ap,itype) if(itype.ne.1) ap=-1 apsymbols(6,:)=ap apmessage='CQ'//' '//hiscall//' '//hisgrid(1:4) - call packmsg(apmessage,ap,itype,.false.) + call packmsg(apmessage,ap,itype) if(itype.ne.1) ap=-1 apsymbols(7,:)=ap endif @@ -211,7 +211,7 @@ subroutine extract(s3,nadd,mode65,ntrials,naggressive,ndepth,nflip, & correct(1:63)=tmp(1:63) call interleave63(correct,63,1) call graycode65(correct,63,1) - call unpackmsg(dat4,decoded,.false.,' ') !Unpack the user message + call unpackmsg(dat4,decoded) !Unpack the user message ncount=0 if(iand(dat4(10),8).ne.0) ltext=.true. endif diff --git a/lib/extract4.f90 b/lib/extract4.f90 index 46c317c2..ce8fb86a 100644 --- a/lib/extract4.f90 +++ b/lib/extract4.f90 @@ -57,7 +57,7 @@ subroutine extract4(sym0,ncount,decoded) read(c72,1102) data4 1102 format(12b6) - call unpackmsg(data4,decoded,.false.,' ') + call unpackmsg(data4,decoded) if(decoded(1:6).eq.'000AAA') then ! decoded='***WRONG MODE?***' decoded=' ' diff --git a/lib/extractmessage144.f90 b/lib/extractmessage144.f90 deleted file mode 100644 index a5dadb0b..00000000 --- a/lib/extractmessage144.f90 +++ /dev/null @@ -1,51 +0,0 @@ -subroutine extractmessage144(decoded,msgreceived,nhashflag,recent_calls,nrecent) - use iso_c_binding, only: c_loc,c_size_t - use packjt - use hashing - - character*22 msgreceived - character*12 call1,call2 - character*12 recent_calls(nrecent) - integer*1 decoded(80) - integer*1, target:: i1Dec8BitBytes(10) - integer*1 i1hashdec - integer*4 i4Dec6BitWords(12) - -! Collapse 80 decoded bits to 10 bytes. Bytes 1-9 are the message, byte 10 is the hash - do ibyte=1,10 - itmp=0 - do ibit=1,8 - itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit)) - enddo - i1Dec8BitBytes(ibyte)=itmp - enddo - -! Calculate the hash using the first 9 bytes. - ihashdec=nhash(c_loc(i1Dec8BitBytes),int(9,c_size_t),146) - ihashdec=2*iand(ihashdec,255) - -! Compare calculated hash with received byte 10 - if they agree, keep the message. - i1hashdec=ihashdec - if( i1hashdec .eq. i1Dec8BitBytes(10) ) then -! Good hash --- unpack 72-bit message - do ibyte=1,12 - itmp=0 - do ibit=1,6 - itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*6+ibit)) - enddo - i4Dec6BitWords(ibyte)=itmp - enddo - call unpackmsg144(i4Dec6BitWords,msgreceived,call1,call2) - nhashflag=1 - if( call1(1:2) .ne. 'CQ' .and. call1(1:2) .ne. ' ' ) then - call update_recent_calls(call1,recent_calls,nrecent) - endif - if( call2(1:2) .ne. ' ' ) then - call update_recent_calls(call2,recent_calls,nrecent) - endif - else - msgreceived=' ' - nhashflag=-1 - endif - return - end subroutine extractmessage144 diff --git a/lib/extractmessage77.f90 b/lib/extractmessage77.f90 new file mode 100644 index 00000000..d2b41e32 --- /dev/null +++ b/lib/extractmessage77.f90 @@ -0,0 +1,17 @@ +subroutine extractmessage77(decoded77,msgreceived) + use packjt + + character*22 msgreceived + character*77 cbits + integer*1 decoded77(77) + integer*4 i4Dec6BitWords(12) + + write(cbits,'(77i1)') decoded77 +!**** Temporary: For now, just handle i5bit=0. + read(cbits,'(12b6)') i4Dec6BitWords + read(cbits,'(72x,i5.5)') i5bit + if( i5bit .eq. 0 ) then + call unpackmsg(i4Dec6BitWords,msgreceived) + endif + return +end subroutine extractmessage77 diff --git a/lib/fmtmsg.f90 b/lib/fmtmsg.f90 index 2ceb8155..81789e2a 100644 --- a/lib/fmtmsg.f90 +++ b/lib/fmtmsg.f90 @@ -1,16 +1,16 @@ subroutine fmtmsg(msg,iz) - character*22 msg + character*(*) msg ! Convert all letters to upper case - iz=22 - do i=1,22 + iz=len(msg) + do i=1,iz if(msg(i:i).ge.'a' .and. msg(i:i).le.'z') & msg(i:i)= char(ichar(msg(i:i))+ichar('A')-ichar('a')) if(msg(i:i).ne.' ') iz=i enddo - do iter=1,5 !Collapse multiple blanks into one + do iter=1,37 !Collapse multiple blanks into one ib2=index(msg(1:iz),' ') if(ib2.lt.1) go to 100 msg=msg(1:ib2)//msg(ib2+2:) diff --git a/lib/fsk4hf/Makefile b/lib/fsk4hf/Makefile deleted file mode 100644 index 9372821b..00000000 --- a/lib/fsk4hf/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# Compilers -CC = gcc -CXX = g++ -FC = gfortran - -FFLAGS = -O2 -fbounds-check -Wall -Wno-conversion -CFLAGS = -O2 -I. - -# Default rules -%.o: %.c - ${CC} ${CFLAGS} -c $< -%.o: %.f - ${FC} ${FFLAGS} -c $< -%.o: %.F - ${FC} ${FFLAGS} -c $< -%.o: %.f90 - ${FC} ${FFLAGS} -c $< -%.o: %.F90 - ${FC} ${FFLAGS} -c $< - -all: wsprlf - -OBJS0 = testpsk.o four2a.o bpfilter.o nonlinear.o tweak1.o spectrum.o smo.o -testpsk: $(OBJS0) - $(FC) -o testpsk $(OBJS0) -lfftw3f - -OBJS1 = gmsk8.o four2a.o gaussfilt.o -gmsk8: $(OBJS1) - $(FC) -o gmsk8 $(OBJS1) -lfftw3f - -OBJS2 = testfsk.o four2a.o smo.o -testfsk: $(OBJS2) - $(FC) -o testfsk $(OBJS2) -lfftw3f - -OBJS3 = fsk2sim.o four2a.o smo.o wavhdr.o gran.o -fsk2sim: $(OBJS3) - $(FC) -o fsk2sim $(OBJS3) -lfftw3f - -OBJS4 = fsk4sim.o four2a.o wavhdr.o gran.o tweak1.o -fsk4sim: $(OBJS4) - $(FC) -o fsk4sim $(OBJS4) -lfftw3f - -OBJS5 = wsprlf.o four2a.o -wsprlf: $(OBJS5) - $(FC) -o wsprlf $(OBJS5) -lfftw3f - -.PHONY : clean - -clean: - $(RM) *.o testpsk testfsk fsk2sim fsk4sim wsprlf diff --git a/lib/fsk4hf/Makefile.win b/lib/fsk4hf/Makefile.win deleted file mode 100644 index ab383557..00000000 --- a/lib/fsk4hf/Makefile.win +++ /dev/null @@ -1,84 +0,0 @@ -# Compilers -CC = gcc -CXX = g++ -FC = gfortran - -FFLAGS = -O2 -fbounds-check -Wall -Wno-conversion -CFLAGS = -O2 -I. - -# Default rules -%.o: %.c - ${CC} ${CFLAGS} -c $< -%.o: %.f - ${FC} ${FFLAGS} -c $< -%.o: %.F - ${FC} ${FFLAGS} -c $< -%.o: %.f90 - ${FC} ${FFLAGS} -c $< -%.o: %.F90 - ${FC} ${FFLAGS} -c $< - -all: dbpsksim.exe - -OBJS0 = testpsk.o four2a.o bpfilter.o nonlinear.o tweak1.o spectrum.o smo.o -testpsk: $(OBJS0) - $(FC) -o testpsk $(OBJS0) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS1 = gmsk8.o four2a.o gaussfilt.o -gmsk8: $(OBJS1) - $(FC) -o gmsk8 $(OBJS1) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS2 = testfsk.o four2a.o smo.o -testfsk: $(OBJS2) - $(FC) -o testfsk $(OBJS2) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS3 = fsk2sim.o four2a.o smo.o wavhdr.o gran.o -fsk2sim: $(OBJS3) - $(FC) -o fsk2sim $(OBJS3) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS4 = fsk4sim.o four2a.o gran.o genfsk4.o smo.o getsnr.o spec4.o \ - watterson.o db.o snr2_wsprlf.o pctile.o shell.o snr_wsprlf.o -fsk4sim.exe: $(OBJS4) - $(FC) -o fsk4sim.exe $(OBJS4) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS5 = wsprlf.o four2a.o downsample.o -wsprlf.exe: $(OBJS5) - $(FC) -o wsprlf.exe $(OBJS5) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS6 = wspr_gmsk.o four2a.o gaussfilt.o -wspr_gmsk.exe: $(OBJS6) - $(FC) -o wspr_gmsk.exe $(OBJS6) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS7 = wspr_msk.o four2a.o bpfilter.o -wspr_msk.exe: $(OBJS7) - $(FC) -o wspr_msk.exe $(OBJS7) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS8 = dbpsksim.o four2a.o gran.o genbpsk.o watterson.o db.o \ - encode120.o bpdecode120.o platanh.o -dbpsksim.exe: $(OBJS8) - $(FC) -o dbpsksim.exe $(OBJS8) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS9 = fsk4a.o four2a.o gran.o genfsk4a.o spec4.o \ - watterson.o db.o -fsk4a.exe: $(OBJS9) - $(FC) -o fsk4a.exe $(OBJS9) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS10 = gmsk8.o gaussfilt.o four2a.o -gmsk8.exe: $(OBJS10) - $(FC) -o gmsk8.exe $(OBJS10) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS11 = gmsksim.o four2a.o gran.o gengmsk.o genbpsk.o watterson.o db.o \ - encode168.o bpdecode168.o platanh.o gaussfilt.o tweak1.o smo121.o -gmsksim.exe: $(OBJS11) - $(FC) -o gmsksim.exe $(OBJS11) C:\JTSDK\fftw3f\libfftw3f-3.dll - -OBJS12 = mskhfsim.o four2a.o gran.o genmskhf.o watterson.o db.o \ - encode168.o bpdecode168.o platanh.o twkfreq1.o smo121.o \ - polyfit4.o -mskhfsim.exe: $(OBJS12) - $(FC) -o mskhfsim.exe $(OBJS12) C:\JTSDK\fftw3f\libfftw3f-3.dll - -.PHONY : clean - -clean: - $(RM) *.o testpsk.exe testfsk.exe fsk2sim.exe fsk4sim.exe wsprlf.exe diff --git a/lib/fsk4hf/bpdecode120.f90 b/lib/fsk4hf/bpdecode120.f90 deleted file mode 100644 index c9b11ac3..00000000 --- a/lib/fsk4hf/bpdecode120.f90 +++ /dev/null @@ -1,306 +0,0 @@ -subroutine bpdecode120(llr,apmask,maxiterations,decoded,niterations,cw) - -! A log-domain belief propagation decoder for the (120,60) code. - -integer, parameter:: N=120, K=60, M=N-K -integer*1 codeword(N),cw(N),apmask(N) -integer colorder(N) -integer*1 decoded(K) -integer Nm(7,M) ! 5, 6, or 7 bits per check -integer Mn(3,N) ! 3 checks per bit -integer synd(M) -real tov(3,N) -real toc(7,M) -real tanhtoc(7,M) -real zn(N) -real llr(N) -real Tmn -integer nrw(M) - -data colorder/ & - 0,1,2,21,3,4,5,6,7,8,20,10,9,11,12,23,13,28,14,31, & - 15,16,22,26,17,30,18,29,25,32,41,34,19,33,27,36,38,43,42,24, & - 37,39,45,40,35,44,47,46,50,51,53,48,52,56,54,57,55,49,58,61, & - 60,59,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79, & - 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99, & - 100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119/ - -data Mn/ & - 1, 18, 48, & - 2, 4, 51, & - 3, 23, 47, & - 5, 36, 42, & - 6, 43, 49, & - 7, 24, 55, & - 8, 35, 60, & - 9, 26, 30, & - 10, 29, 45, & - 11, 13, 46, & - 12, 53, 54, & - 14, 20, 57, & - 15, 16, 58, & - 17, 39, 44, & - 19, 37, 41, & - 21, 28, 34, & - 22, 50, 59, & - 25, 31, 52, & - 27, 32, 38, & - 33, 40, 56, & - 1, 11, 47, & - 2, 10, 16, & - 3, 12, 27, & - 4, 24, 28, & - 5, 23, 60, & - 6, 29, 39, & - 7, 31, 54, & - 8, 50, 56, & - 9, 13, 14, & - 15, 22, 41, & - 17, 26, 40, & - 18, 25, 45, & - 19, 20, 55, & - 21, 30, 36, & - 32, 49, 59, & - 33, 53, 58, & - 34, 38, 46, & - 29, 35, 57, & - 37, 43, 48, & - 42, 51, 52, & - 7, 11, 44, & - 1, 42, 58, & - 2, 13, 49, & - 3, 20, 40, & - 4, 18, 56, & - 5, 45, 55, & - 6, 21, 31, & - 8, 46, 52, & - 9, 12, 48, & - 10, 37, 38, & - 14, 15, 25, & - 16, 17, 60, & - 19, 39, 53, & - 22, 44, 51, & - 23, 28, 41, & - 24, 32, 35, & - 26, 45, 59, & - 27, 33, 36, & - 30, 47, 54, & - 34, 50, 57, & - 33, 43, 55, & - 1, 41, 57, & - 2, 40, 54, & - 3, 6, 24, & - 4, 11, 59, & - 5, 13, 56, & - 7, 16, 34, & - 8, 19, 26, & - 9, 31, 58, & - 10, 21, 53, & - 12, 22, 60, & - 14, 38, 51, & - 15, 43, 46, & - 17, 48, 50, & - 18, 27, 39, & - 20, 28, 44, & - 23, 25, 49, & - 4, 29, 36, & - 30, 32, 52, & - 35, 37, 47, & - 39, 42, 59, & - 1, 21, 40, & - 2, 50, 55, & - 3, 8, 10, & - 5, 31, 37, & - 6, 14, 60, & - 7, 36, 49, & - 9, 34, 39, & - 11, 19, 25, & - 12, 52, 57, & - 13, 22, 29, & - 15, 30, 56, & - 16, 18, 20, & - 17, 24, 46, & - 23, 38, 58, & - 26, 28, 43, & - 2, 27, 41, & - 5, 32, 44, & - 33, 47, 51, & - 35, 48, 53, & - 42, 43, 54, & - 34, 45, 47, & - 1, 8, 49, & - 3, 14, 59, & - 4, 31, 46, & - 6, 20, 50, & - 7, 26, 53, & - 9, 10, 36, & - 11, 58, 60, & - 12, 21, 45, & - 13, 28, 33, & - 15, 17, 35, & - 16, 38, 52, & - 18, 41, 54, & - 19, 23, 32, & - 22, 40, 55, & - 24, 25, 42, & - 26, 27, 56, & - 29, 44, 54, & - 30, 37, 55/ - -data Nm/ & - 1, 21, 42, 62, 82, 103, 0, & - 2, 22, 43, 63, 83, 97, 0, & - 3, 23, 44, 64, 84, 104, 0, & - 2, 24, 45, 65, 78, 105, 0, & - 4, 25, 46, 66, 85, 98, 0, & - 5, 26, 47, 64, 86, 106, 0, & - 6, 27, 41, 67, 87, 107, 0, & - 7, 28, 48, 68, 84, 103, 0, & - 8, 29, 49, 69, 88, 108, 0, & - 9, 22, 50, 70, 84, 108, 0, & - 10, 21, 41, 65, 89, 109, 0, & - 11, 23, 49, 71, 90, 110, 0, & - 10, 29, 43, 66, 91, 111, 0, & - 12, 29, 51, 72, 86, 104, 0, & - 13, 30, 51, 73, 92, 112, 0, & - 13, 22, 52, 67, 93, 113, 0, & - 14, 31, 52, 74, 94, 112, 0, & - 1, 32, 45, 75, 93, 114, 0, & - 15, 33, 53, 68, 89, 115, 0, & - 12, 33, 44, 76, 93, 106, 0, & - 16, 34, 47, 70, 82, 110, 0, & - 17, 30, 54, 71, 91, 116, 0, & - 3, 25, 55, 77, 95, 115, 0, & - 6, 24, 56, 64, 94, 117, 0, & - 18, 32, 51, 77, 89, 117, 0, & - 8, 31, 57, 68, 96, 107, 118, & - 19, 23, 58, 75, 97, 118, 0, & - 16, 24, 55, 76, 96, 111, 0, & - 9, 26, 38, 78, 91, 119, 0, & - 8, 34, 59, 79, 92, 120, 0, & - 18, 27, 47, 69, 85, 105, 0, & - 19, 35, 56, 79, 98, 115, 0, & - 20, 36, 58, 61, 99, 111, 0, & - 16, 37, 60, 67, 88, 102, 0, & - 7, 38, 56, 80, 100, 112, 0, & - 4, 34, 58, 78, 87, 108, 0, & - 15, 39, 50, 80, 85, 120, 0, & - 19, 37, 50, 72, 95, 113, 0, & - 14, 26, 53, 75, 81, 88, 0, & - 20, 31, 44, 63, 82, 116, 0, & - 15, 30, 55, 62, 97, 114, 0, & - 4, 40, 42, 81, 101, 117, 0, & - 5, 39, 61, 73, 96, 101, 0, & - 14, 41, 54, 76, 98, 119, 0, & - 9, 32, 46, 57, 102, 110, 0, & - 10, 37, 48, 73, 94, 105, 0, & - 3, 21, 59, 80, 99, 102, 0, & - 1, 39, 49, 74, 100, 0, 0, & - 5, 35, 43, 77, 87, 103, 0, & - 17, 28, 60, 74, 83, 106, 0, & - 2, 40, 54, 72, 99, 0, 0, & - 18, 40, 48, 79, 90, 113, 0, & - 11, 36, 53, 70, 100, 107, 0, & - 11, 27, 59, 63, 101, 114, 119, & - 6, 33, 46, 61, 83, 116, 120, & - 20, 28, 45, 66, 92, 118, 0, & - 12, 38, 60, 62, 90, 0, 0, & - 13, 36, 42, 69, 95, 109, 0, & - 17, 35, 57, 65, 81, 104, 0, & - 7, 25, 52, 71, 86, 109, 0/ - -data nrw/ & -6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, & -6,6,6,6,6,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6, & -6,6,6,6,6,6,6,5,6,6,5,6,6,7,7,6,5,6,6,6/ - -ncw=3 - -toc=0 -tov=0 -tanhtoc=0 -!write(*,*) llr -! initialize messages to checks -do j=1,M - do i=1,nrw(j) - toc(i,j)=llr((Nm(i,j))) - enddo -enddo - -ncnt=0 - -do iter=0,maxiterations - -! Update bit log likelihood ratios (tov=0 in iteration 0). - do i=1,N - if( apmask(i) .ne. 1 ) then - zn(i)=llr(i)+sum(tov(1:ncw,i)) - else - zn(i)=llr(i) - endif - enddo - -! Check to see if we have a codeword (check before we do any iteration). - cw=0 - where( zn .gt. 0. ) cw=1 - ncheck=0 - do i=1,M - synd(i)=sum(cw(Nm(1:nrw(i),i))) - if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1 -! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied' - enddo -!write(*,*) 'number of unsatisfied parity checks ',ncheck - if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it - niterations=iter - codeword=cw(colorder+1) - decoded=codeword(M+1:N) - return - endif - - if( iter.gt.0 ) then ! this code block implements an early stopping criterion - nd=ncheck-nclast - if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased - ncnt=0 ! reset counter - else - ncnt=ncnt+1 - endif -! write(*,*) iter,ncheck,nd,ncnt - if( ncnt .ge. 3 .and. iter .ge. 5 .and. ncheck .gt. 10) then - niterations=-1 - return - endif - endif - nclast=ncheck - -! Send messages from bits to check nodes - do j=1,M - do i=1,nrw(j) - ibj=Nm(i,j) - toc(i,j)=zn(ibj) - do kk=1,ncw ! subtract off what the bit had received from the check - if( Mn(kk,ibj) .eq. j ) then - toc(i,j)=toc(i,j)-tov(kk,ibj) - endif - enddo - enddo - enddo - -! send messages from check nodes to variable nodes - do i=1,M - tanhtoc(1:7,i)=tanh(-toc(1:7,i)/2) - enddo - - do j=1,N - do i=1,ncw - ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j - Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) - call platanh(-Tmn,y) -! y=atanh(-Tmn) - tov(i,j)=2*y - enddo - enddo - -enddo -niterations=-1 -return -end subroutine bpdecode120 diff --git a/lib/fsk4hf/bpdecode168.f90 b/lib/fsk4hf/bpdecode168.f90 deleted file mode 100644 index d527f71d..00000000 --- a/lib/fsk4hf/bpdecode168.f90 +++ /dev/null @@ -1,380 +0,0 @@ -subroutine bpdecode168(llr,apmask,maxiterations,decoded,niterations) -! -! A log-domain belief propagation decoder for the (168,84) code. -! -integer, parameter:: N=168, K=84, M=N-K -integer*1 codeword(N),cw(N),apmask(N) -integer colorder(N) -integer*1 decoded(K) -integer Nm(7,M) ! 5, 6, or 7 bits per check -integer Mn(3,N) ! 3 checks per bit -integer synd(M) -real tov(3,N) -real toc(7,M) -real tanhtoc(7,M) -real zn(N) -real llr(N) -real Tmn -integer nrw(M) - -data colorder/0,1,2,3,28,4,5,6,7,8,9,10,11,34,12,32,13,14,15,16,17, & - 18,36,29,42,31,20,21,41,40,30,38,22,19,47,37,46,35,44,33,49,24, & - 43,51,25,26,27,50,52,57,69,54,55,45,59,58,56,61,60,53,48,23,62, & - 63,64,67,66,65,68,39,70,71,72,74,73,75,76,77,80,81,78,82,79,83, & - 84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104, & - 105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, & - 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146, & - 147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167/ - -data Mn/ & - 1,24,67, & - 2,5,71, & - 3,31,66, & - 4,50,58, & - 6,60,65, & - 7,32,76, & - 8,49,83, & - 9,36,41, & - 10,40,63, & - 11,14,62, & - 12,72,75, & - 13,23,78, & - 15,16,80, & - 17,54,64, & - 18,51,59, & - 19,30,48, & - 20,68,81, & - 21,29,70, & - 22,25,43, & - 26,34,73, & - 27,35,37, & - 28,39,44, & - 33,53,55, & - 38,52,84, & - 42,56,57, & - 45,74,82, & - 46,69,79, & - 47,61,77, & - 1,4,5, & - 2,48,52, & - 3,47,82, & - 6,26,76, & - 7,9,16, & - 8,10,78, & - 11,36,56, & - 12,38,65, & - 13,43,81, & - 14,33,68, & - 15,18,44, & - 17,59,77, & - 19,27,69, & - 20,21,58, & - 22,45,79, & - 23,34,54, & - 24,28,40, & - 25,80,84, & - 29,37,51, & - 30,42,83, & - 31,63,72, & - 32,50,66, & - 35,67,73, & - 39,55,74, & - 41,61,71, & - 46,60,62, & - 49,70,74, & - 53,64,75, & - 25,57,67, & - 1,46,64, & - 2,51,63, & - 3,14,80, & - 4,15,78, & - 5,27,74, & - 6,13,70, & - 7,19,20, & - 8,38,77, & - 9,75,83, & - 10,36,69, & - 11,22,29, & - 12,58,82, & - 16,35,60, & - 17,32,43, & - 18,42,45, & - 21,53,84, & - 23,39,48, & - 24,52,68, & - 26,33,61, & - 28,56,76, & - 30,65,66, & - 31,34,49, & - 37,47,81, & - 16,40,54, & - 41,44,65, & - 50,73,79, & - 55,59,60, & - 54,57,71, & - 23,62,72, & - 1,36,47, & - 2,32,70, & - 3,28,69, & - 4,7,33, & - 5,20,26, & - 6,14,63, & - 8,22,68, & - 9,13,67, & - 10,55,71, & - 11,15,19, & - 12,51,56, & - 17,27,52, & - 18,34,46, & - 21,41,42, & - 24,50,80, & - 25,39,75, & - 29,54,76, & - 30,40,84, & - 31,35,58, & - 37,79,83, & - 38,43,73, & - 44,72,81, & - 7,45,62, & - 47,48,49, & - 53,57,78, & - 20,59,66, & - 28,61,64, & - 11,75,77, & - 33,54,82, & - 1,14,44, & - 2,62,73, & - 3,9,26, & - 4,37,84, & - 5,56,80, & - 6,45,71, & - 8,67,72, & - 10,76,81, & - 12,32,78, & - 13,59,82, & - 15,17,79, & - 16,42,69, & - 18,61,70, & - 19,31,64, & - 21,39,63, & - 22,30,58, & - 23,27,66, & - 24,41,49, & - 25,36,60, & - 29,65,67, & - 34,36,53, & - 35,48,76, & - 15,38,55, & - 40,43,74, & - 46,52,57, & - 50,63,77, & - 51,68,69, & - 2,44,83, & - 1,30,55, & - 3,29,78, & - 4,34,65, & - 5,31,38, & - 6,52,58, & - 7,25,51, & - 8,16,66, & - 9,46,74, & - 10,70,75, & - 11,32,84, & - 12,48,79, & - 13,50,64, & - 14,37,57, & - 17,42,72, & - 18,43,48, & - 19,24,60, & - 20,54,83, & - 21,47,62, & - 22,28,59, & - 23,61,80, & - 8,26,39, & - 27,44,53, & - 33,49,56, & - 35,68,71, & - 12,26,40/ - -data Nm/ & - 1,29,58,87,116,144,0,& - 2,30,59,88,117,143,0,& - 3,31,60,89,118,145,0,& - 4,29,61,90,119,146,0,& - 2,29,62,91,120,147,0,& - 5,32,63,92,121,148,0,& - 6,33,64,90,109,149,0,& - 7,34,65,93,122,150,164,& - 8,33,66,94,118,151,0,& - 9,34,67,95,123,152,0,& - 10,35,68,96,114,153,0,& - 11,36,69,97,124,154,168,& - 12,37,63,94,125,155,0,& - 10,38,60,92,116,156,0,& - 13,39,61,96,126,138,0,& - 13,33,70,81,127,150,0,& - 14,40,71,98,126,157,0,& - 15,39,72,99,128,158,0,& - 16,41,64,96,129,159,0,& - 17,42,64,91,112,160,0,& - 18,42,73,100,130,161,0,& - 19,43,68,93,131,162,0,& - 12,44,74,86,132,163,0,& - 1,45,75,101,133,159,0,& - 19,46,57,102,134,149,0,& - 20,32,76,91,118,164,168,& - 21,41,62,98,132,165,0,& - 22,45,77,89,113,162,0,& - 18,47,68,103,135,145,0,& - 16,48,78,104,131,144,0,& - 3,49,79,105,129,147,0,& - 6,50,71,88,124,153,0,& - 23,38,76,90,115,166,0,& - 20,44,79,99,136,146,0,& - 21,51,70,105,137,167,0,& - 8,35,67,87,134,136,0,& - 21,47,80,106,119,156,0,& - 24,36,65,107,138,147,0,& - 22,52,74,102,130,164,0,& - 9,45,81,104,139,168,0,& - 8,53,82,100,133,0,0,& - 25,48,72,100,127,157,0,& - 19,37,71,107,139,158,0,& - 22,39,82,108,116,143,165,& - 26,43,72,109,121,0,0,& - 27,54,58,99,140,151,0,& - 28,31,80,87,110,161,0,& - 16,30,74,110,137,154,158,& - 7,55,79,110,133,166,0,& - 4,50,83,101,141,155,0,& - 15,47,59,97,142,149,0,& - 24,30,75,98,140,148,0,& - 23,56,73,111,136,165,0,& - 14,44,81,85,103,115,160,& - 23,52,84,95,138,144,0,& - 25,35,77,97,120,166,0,& - 25,57,85,111,140,156,0,& - 4,42,69,105,131,148,0,& - 15,40,84,112,125,162,0,& - 5,54,70,84,134,159,0,& - 28,53,76,113,128,163,0,& - 10,54,86,109,117,161,0,& - 9,49,59,92,130,141,0,& - 14,56,58,113,129,155,0,& - 5,36,78,82,135,146,0,& - 3,50,78,112,132,150,0,& - 1,51,57,94,122,135,0,& - 17,38,75,93,142,167,0,& - 27,41,67,89,127,142,0,& - 18,55,63,88,128,152,0,& - 2,53,85,95,121,167,0,& - 11,49,86,108,122,157,0,& - 20,51,83,107,117,0,0,& - 26,52,55,62,139,151,0,& - 11,56,66,102,114,152,0,& - 6,32,77,103,123,137,0,& - 28,40,65,114,141,0,0,& - 12,34,61,111,124,145,0,& - 27,43,83,106,126,154,0,& - 13,46,60,101,120,163,0,& - 17,37,80,108,123,0,0,& - 26,31,69,115,125,0,0,& - 7,48,66,106,143,160,0,& - 24,46,73,104,119,153,0/ - -data nrw/ & -6,6,6,6,6,6,6,7,6,6,6,7,6,6,6,6,6,6,6,6,6, & -6,6,6,6,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,6, & -6,7,5,6,6,7,6,6,6,6,6,7,6,6,6,6,6,6,6,6,6, & -6,6,6,6,6,6,6,6,6,5,6,6,6,5,6,6,6,5,5,6,6/ - -ncw=3 - -toc=0 -tov=0 -tanhtoc=0 -!write(*,*) llr -! initialize messages to checks -do j=1,M - do i=1,nrw(j) - toc(i,j)=llr((Nm(i,j))) - enddo -enddo - -ncnt=0 - -do iter=0,maxiterations - -! Update bit log likelihood ratios (tov=0 in iteration 0). - do i=1,N - if( apmask(i) .ne. 1 ) then - zn(i)=llr(i)+sum(tov(1:ncw,i)) - else - zn(i)=llr(i) - endif - enddo - -! Check to see if we have a codeword (check before we do any iteration). - cw=0 - where( zn .gt. 0. ) cw=1 - ncheck=0 - do i=1,M - synd(i)=sum(cw(Nm(1:nrw(i),i))) - if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1 -! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied' - enddo -!write(*,*) 'number of unsatisfied parity checks ',ncheck - if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it - niterations=iter - codeword=cw(colorder+1) - decoded=codeword(M+1:N) - return - endif - - if( iter.gt.0 ) then ! this code block implements an early stopping criterion - nd=ncheck-nclast - if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased - ncnt=0 ! reset counter - else - ncnt=ncnt+1 - endif -! write(*,*) iter,ncheck,nd,ncnt - if( ncnt .ge. 3 .and. iter .ge. 5 .and. ncheck .gt. 10) then - niterations=-1 - return - endif - endif - nclast=ncheck - -! Send messages from bits to check nodes - do j=1,M - do i=1,nrw(j) - ibj=Nm(i,j) - toc(i,j)=zn(ibj) - do kk=1,ncw ! subtract off what the bit had received from the check - if( Mn(kk,ibj) .eq. j ) then - toc(i,j)=toc(i,j)-tov(kk,ibj) - endif - enddo - enddo - enddo - -! send messages from check nodes to variable nodes - do i=1,M - tanhtoc(1:7,i)=tanh(-toc(1:7,i)/2) - enddo - - do j=1,N - do i=1,ncw - ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j - Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) - call platanh(-Tmn,y) -! y=atanh(-Tmn) - tov(i,j)=2*y - enddo - enddo - -enddo -niterations=-1 -return -end subroutine bpdecode168 diff --git a/lib/fsk4hf/bpdecode204.f90 b/lib/fsk4hf/bpdecode204.f90 deleted file mode 100644 index 160b51a9..00000000 --- a/lib/fsk4hf/bpdecode204.f90 +++ /dev/null @@ -1,482 +0,0 @@ -subroutine bpdecode204(llr,apmask,maxiterations,decoded,cw,nharderror,iter) -! -! A log-domain belief propagation decoder for the (204,68) code. -! -integer, parameter:: N=204, K=68, M=N-K -integer*1 codeword(N),cw(N),apmask(N) -integer colorder(N) -integer*1 decoded(K) -integer Nm(6,M) ! 4, 5, or 6 bits per check -integer Mn(3,N) ! 3 checks per bit -integer synd(M) -real tov(3,N) -real toc(6,M) -real tanhtoc(6,M) -real zn(N) -real llr(N) -real Tmn -integer nrw(M) - -data colorder/ & - 0, 1, 2, 3, 4, 5, 47, 6, 7, 8, 9, 10, 11, 12, 58, 55, 13, & - 14, 15, 46, 17, 18, 60, 19, 20, 21, 22, 23, 24, 25, 57, 26, 27, 49, & - 28, 52, 65, 16, 50, 73, 59, 68, 63, 29, 30, 31, 32, 51, 62, 56, 66, & - 45, 33, 34, 53, 67, 35, 36, 37, 61, 69, 54, 38, 71, 82, 39, 77, 80, & - 83, 78, 84, 48, 41, 85, 40, 64, 75, 96, 74, 72, 76, 86, 87, 89, 90, & - 79, 70, 92, 99, 93,101, 95,100, 97, 94, 42, 98,103,105,102, 43,104, & - 88, 44,106, 81,107,110,108,111,112,109,113,114,117,118,116,121,115, & - 119,122,120,125,129,124,127,126,128, 91,123,133,131,130,134,135,137, & - 136,132,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152, & - 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169, & - 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186, & - 187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203/ - -data Mn/ & - 1, 38, 107, & - 2, 7, 114, & - 3, 48, 106, & - 4, 79, 94, & - 5, 97, 108, & - 6, 50, 122, & - 8, 78, 134, & - 9, 55, 65, & - 10, 62, 100, & - 11, 16, 99, & - 12, 113, 119, & - 13, 31, 125, & - 14, 15, 127, & - 17, 87, 103, & - 18, 81, 98, & - 19, 43, 77, & - 20, 102, 130, & - 21, 36, 111, & - 22, 23, 60, & - 24, 39, 112, & - 25, 37, 42, & - 26, 41, 51, & - 27, 67, 70, & - 28, 64, 136, & - 29, 61, 68, & - 30, 91, 124, & - 32, 80, 121, & - 33, 40, 117, & - 34, 35, 90, & - 44, 88, 93, & - 45, 128, 133, & - 46, 56, 69, & - 47, 49, 52, & - 53, 76, 131, & - 54, 104, 116, & - 57, 84, 86, & - 58, 120, 135, & - 59, 75, 92, & - 63, 71, 109, & - 66, 74, 126, & - 72, 85, 105, & - 73, 82, 95, & - 83, 89, 123, & - 96, 115, 118, & - 101, 110, 129, & - 52, 99, 132, & - 1, 3, 20, & - 2, 77, 89, & - 4, 72, 75, & - 5, 34, 79, & - 6, 24, 130, & - 7, 48, 88, & - 8, 36, 116, & - 9, 71, 114, & - 10, 87, 101, & - 11, 22, 121, & - 12, 50, 64, & - 13, 39, 53, & - 14, 41, 78, & - 15, 68, 96, & - 16, 83, 90, & - 17, 23, 45, & - 18, 47, 126, & - 19, 70, 91, & - 21, 57, 76, & - 25, 110, 117, & - 26, 82, 135, & - 27, 46, 58, & - 28, 37, 56, & - 29, 66, 102, & - 30, 62, 125, & - 31, 85, 93, & - 32, 104, 113, & - 33, 81, 92, & - 35, 100, 118, & - 38, 95, 133, & - 40, 86, 109, & - 42, 61, 124, & - 43, 59, 119, & - 44, 49, 134, & - 51, 97, 122, & - 54, 105, 107, & - 55, 128, 136, & - 60, 67, 84, & - 63, 112, 115, & - 65, 74, 131, & - 69, 80, 94, & - 73, 98, 123, & - 103, 130, 134, & - 46, 106, 111, & - 1, 84, 108, & - 120, 129, 132, & - 65, 75, 127, & - 2, 80, 101, & - 3, 118, 119, & - 4, 52, 124, & - 5, 13, 68, & - 6, 27, 81, & - 7, 51, 76, & - 8, 77, 108, & - 9, 31, 58, & - 10, 18, 57, & - 11, 63, 105, & - 12, 14, 132, & - 15, 56, 123, & - 16, 21, 128, & - 17, 37, 59, & - 19, 85, 126, & - 20, 71, 91, & - 22, 26, 117, & - 23, 79, 98, & - 24, 32, 95, & - 25, 90, 93, & - 28, 49, 109, & - 29, 116, 120, & - 30, 54, 136, & - 33, 53, 107, & - 34, 64, 103, & - 35, 39, 67, & - 36, 71, 73, & - 38, 47, 125, & - 40, 66, 94, & - 41, 70, 104, & - 42, 55, 112, & - 43, 44, 82, & - 29, 45, 88, & - 48, 86, 127, & - 50, 72, 135, & - 60, 74, 96, & - 61, 121, 131, & - 62, 78, 92, & - 69, 100, 133, & - 83, 122, 129, & - 87, 97, 106, & - 89, 102, 113, & - 24, 99, 108, & - 20, 72, 110, & - 111, 115, 117, & - 35, 52, 114, & - 1, 44, 94, & - 2, 23, 107, & - 3, 81, 136, & - 4, 8, 96, & - 5, 37, 70, & - 6, 43, 131, & - 7, 103, 115, & - 9, 94, 122, & - 10, 68, 82, & - 11, 56, 88, & - 12, 46, 126, & - 13, 16, 75, & - 14, 79, 112, & - 15, 47, 110, & - 17, 36, 39, & - 18, 63, 120, & - 19, 22, 55, & - 21, 49, 113, & - 25, 54, 57, & - 26, 89, 125, & - 27, 101, 109, & - 28, 31, 60, & - 30, 74, 97, & - 32, 92, 93, & - 33, 83, 91, & - 34, 58, 121, & - 38, 65, 111, & - 40, 99, 118, & - 3, 41, 61, & - 42, 50, 100, & - 45, 78, 106, & - 48, 95, 129, & - 51, 85, 133, & - 53, 59, 69, & - 11, 62, 66, & - 64, 73, 124, & - 67, 123, 134, & - 76, 104, 132, & - 77, 100, 127, & - 36, 80, 119, & - 84, 102, 135, & - 86, 105, 124, & - 4, 87, 128, & - 90, 106, 116, & - 65, 98, 130, & - 92, 108, 114, & - 1, 52, 121, & - 2, 84, 117, & - 5, 83, 105, & - 6, 15, 63, & - 7, 28, 82, & - 8, 32, 135, & - 9, 104, 134, & - 9, 10, 89, & - 12, 62, 107, & - 13, 40, 103, & - 14, 31, 95, & - 16, 27, 74, & - 17, 90, 132, & - 18, 34, 69, & - 19, 103, 129, & - 20, 76, 87, & - 21, 22, 130, & - 23, 25, 99, & - 24, 101, 126/ - -data Nm/ & - 1, 47, 91, 140, 186, 0, & - 2, 48, 94, 141, 187, 0, & - 3, 47, 95, 142, 168, 0, & - 4, 49, 96, 143, 182, 0, & - 5, 50, 97, 144, 188, 0, & - 6, 51, 98, 145, 189, 0, & - 2, 52, 99, 146, 190, 0, & - 7, 53, 100, 143, 191, 0, & - 8, 54, 101, 147, 192, 193, & - 9, 55, 102, 148, 193, 0, & - 10, 56, 103, 149, 174, 0, & - 11, 57, 104, 150, 194, 0, & - 12, 58, 97, 151, 195, 0, & - 13, 59, 104, 152, 196, 0, & - 13, 60, 105, 153, 189, 0, & - 10, 61, 106, 151, 197, 0, & - 14, 62, 107, 154, 198, 0, & - 15, 63, 102, 155, 199, 0, & - 16, 64, 108, 156, 200, 0, & - 17, 47, 109, 137, 201, 0, & - 18, 65, 106, 157, 202, 0, & - 19, 56, 110, 156, 202, 0, & - 19, 62, 111, 141, 203, 0, & - 20, 51, 112, 136, 204, 0, & - 21, 66, 113, 158, 203, 0, & - 22, 67, 110, 159, 0, 0, & - 23, 68, 98, 160, 197, 0, & - 24, 69, 114, 161, 190, 0, & - 25, 70, 115, 126, 0, 0, & - 26, 71, 116, 162, 0, 0, & - 12, 72, 101, 161, 196, 0, & - 27, 73, 112, 163, 191, 0, & - 28, 74, 117, 164, 0, 0, & - 29, 50, 118, 165, 199, 0, & - 29, 75, 119, 139, 0, 0, & - 18, 53, 120, 154, 179, 0, & - 21, 69, 107, 144, 0, 0, & - 1, 76, 121, 166, 0, 0, & - 20, 58, 119, 154, 0, 0, & - 28, 77, 122, 167, 195, 0, & - 22, 59, 123, 168, 0, 0, & - 21, 78, 124, 169, 0, 0, & - 16, 79, 125, 145, 0, 0, & - 30, 80, 125, 140, 0, 0, & - 31, 62, 126, 170, 0, 0, & - 32, 68, 90, 150, 0, 0, & - 33, 63, 121, 153, 0, 0, & - 3, 52, 127, 171, 0, 0, & - 33, 80, 114, 157, 0, 0, & - 6, 57, 128, 169, 0, 0, & - 22, 81, 99, 172, 0, 0, & - 33, 46, 96, 139, 186, 0, & - 34, 58, 117, 173, 0, 0, & - 35, 82, 116, 158, 0, 0, & - 8, 83, 124, 156, 0, 0, & - 32, 69, 105, 149, 0, 0, & - 36, 65, 102, 158, 0, 0, & - 37, 68, 101, 165, 0, 0, & - 38, 79, 107, 173, 0, 0, & - 19, 84, 129, 161, 0, 0, & - 25, 78, 130, 168, 0, 0, & - 9, 71, 131, 174, 194, 0, & - 39, 85, 103, 155, 189, 0, & - 24, 57, 118, 175, 0, 0, & - 8, 86, 93, 166, 184, 0, & - 40, 70, 122, 174, 0, 0, & - 23, 84, 119, 176, 0, 0, & - 25, 60, 97, 148, 0, 0, & - 32, 87, 132, 173, 199, 0, & - 23, 64, 123, 144, 0, 0, & - 39, 54, 109, 120, 0, 0, & - 41, 49, 128, 137, 0, 0, & - 42, 88, 120, 175, 0, 0, & - 40, 86, 129, 162, 197, 0, & - 38, 49, 93, 151, 0, 0, & - 34, 65, 99, 177, 201, 0, & - 16, 48, 100, 178, 0, 0, & - 7, 59, 131, 170, 0, 0, & - 4, 50, 111, 152, 0, 0, & - 27, 87, 94, 179, 0, 0, & - 15, 74, 98, 142, 0, 0, & - 42, 67, 125, 148, 190, 0, & - 43, 61, 133, 164, 188, 0, & - 36, 84, 91, 180, 187, 0, & - 41, 72, 108, 172, 0, 0, & - 36, 77, 127, 181, 0, 0, & - 14, 55, 134, 182, 201, 0, & - 30, 52, 126, 149, 0, 0, & - 43, 48, 135, 159, 193, 0, & - 29, 61, 113, 183, 198, 0, & - 26, 64, 109, 164, 0, 0, & - 38, 74, 131, 163, 185, 0, & - 30, 72, 113, 163, 0, 0, & - 4, 87, 122, 140, 147, 0, & - 42, 76, 112, 171, 196, 0, & - 44, 60, 129, 143, 0, 0, & - 5, 81, 134, 162, 0, 0, & - 15, 88, 111, 184, 0, 0, & - 10, 46, 136, 167, 203, 0, & - 9, 75, 132, 169, 178, 0, & - 45, 55, 94, 160, 204, 0, & - 17, 70, 135, 180, 0, 0, & - 14, 89, 118, 146, 195, 200, & - 35, 73, 123, 177, 192, 0, & - 41, 82, 103, 181, 188, 0, & - 3, 90, 134, 170, 183, 0, & - 1, 82, 117, 141, 194, 0, & - 5, 91, 100, 136, 185, 0, & - 39, 77, 114, 160, 0, 0, & - 45, 66, 137, 153, 0, 0, & - 18, 90, 138, 166, 0, 0, & - 20, 85, 124, 152, 0, 0, & - 11, 73, 135, 157, 0, 0, & - 2, 54, 139, 185, 0, 0, & - 44, 85, 138, 146, 0, 0, & - 35, 53, 115, 183, 0, 0, & - 28, 66, 110, 138, 187, 0, & - 44, 75, 95, 167, 0, 0, & - 11, 79, 95, 179, 0, 0, & - 37, 92, 115, 155, 0, 0, & - 27, 56, 130, 165, 186, 0, & - 6, 81, 133, 147, 0, 0, & - 43, 88, 105, 176, 0, 0, & - 26, 78, 96, 175, 181, 0, & - 12, 71, 121, 159, 0, 0, & - 40, 63, 108, 150, 204, 0, & - 13, 93, 127, 178, 0, 0, & - 31, 83, 106, 182, 0, 0, & - 45, 92, 133, 171, 200, 0, & - 17, 51, 89, 184, 202, 0, & - 34, 86, 130, 145, 0, 0, & - 46, 92, 104, 177, 198, 0, & - 31, 76, 132, 172, 0, 0, & - 7, 80, 89, 176, 192, 0, & - 37, 67, 128, 180, 191, 0, & - 24, 83, 116, 142, 0, 0/ - -data nrw/ & - 5,5,5,5,5,5,5,5,6,5,5,5,5,5,5,5,5, & - 5,5,5,5,5,5,5,5,4,5,5,4,4,5,5,4,5, & - 4,5,4,4,4,5,4,4,4,4,4,4,4,4,4,4,4, & - 5,4,4,4,4,4,4,4,4,4,5,5,4,5,4,4,4, & - 5,4,4,4,4,5,4,5,4,4,4,4,4,5,5,5,4, & - 4,5,4,5,5,4,5,4,5,5,4,4,4,5,5,5,4, & - 6,5,5,5,5,5,4,4,4,4,4,4,4,4,5,4,4, & - 4,5,4,4,5,4,5,4,4,5,5,4,5,4,5,5,4/ - -ncw=3 - -decoded=0 -toc=0 -tov=0 -tanhtoc=0 -! initialize messages to checks -do j=1,M - do i=1,nrw(j) - toc(i,j)=llr((Nm(i,j))) - enddo -enddo - -ncnt=0 - -do iter=0,maxiterations - -! Update bit log likelihood ratios (tov=0 in iteration 0). - do i=1,N - if( apmask(i) .ne. 1 ) then - zn(i)=llr(i)+sum(tov(1:ncw,i)) - else - zn(i)=llr(i) - endif - enddo - -! Check to see if we have a codeword (check before we do any iteration). - cw=0 - where( zn .gt. 0. ) cw=1 - ncheck=0 - do i=1,M - synd(i)=sum(cw(Nm(1:nrw(i),i))) - if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1 -! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied' - enddo -! write(*,*) 'number of unsatisfied parity checks ',ncheck - if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it - codeword=cw(colorder+1) - decoded=codeword(M+1:N) - nerr=0 - do i=1,N - if( (2*cw(i)-1)*llr(i) .lt. 0.0 ) nerr=nerr+1 - enddo - nharderror=nerr - return - endif - - if( iter.gt.0 ) then ! this code block implements an early stopping criterion -! if( iter.gt.10000 ) then ! this code block implements an early stopping criterion - nd=ncheck-nclast - if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased - ncnt=0 ! reset counter - else - ncnt=ncnt+1 - endif -! write(*,*) iter,ncheck,nd,ncnt - if( ncnt .ge. 5 .and. iter .ge. 10 .and. ncheck .gt. 15) then - nharderror=-1 - return - endif - endif - nclast=ncheck - -! Send messages from bits to check nodes - do j=1,M - do i=1,nrw(j) - ibj=Nm(i,j) - toc(i,j)=zn(ibj) - do kk=1,ncw ! subtract off what the bit had received from the check - if( Mn(kk,ibj) .eq. j ) then - toc(i,j)=toc(i,j)-tov(kk,ibj) - endif - enddo - enddo - enddo - -! send messages from check nodes to variable nodes - do i=1,M - tanhtoc(1:6,i)=tanh(-toc(1:6,i)/2) - enddo - - do j=1,N - do i=1,ncw - ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j - Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) - call platanh(-Tmn,y) -! y=atanh(-Tmn) - tov(i,j)=2*y - enddo - enddo - -enddo -nharderror=-1 -return -end subroutine bpdecode204 diff --git a/lib/fsk4hf/bpdecode300.f90 b/lib/fsk4hf/bpdecode300.f90 deleted file mode 100644 index 22f7f885..00000000 --- a/lib/fsk4hf/bpdecode300.f90 +++ /dev/null @@ -1,708 +0,0 @@ -subroutine bpdecode300(llr,apmask,maxiterations,decoded,niterations,cw) - -! A log-domain belief propagation decoder for the (300,60) code. - -integer, parameter:: N=300, K=60, M=N-K -integer*1 codeword(N),cw(N),apmask(N) -integer colorder(N) -integer*1 decoded(K) -integer Nm(5,M) ! 4, or 5 bits per check -integer Mn(7,N) ! 2, 3, or 7 checks per bit -integer synd(M) -real tov(7,N) -real toc(5,M) -real tanhtoc(5,M) -real zn(N) -real llr(N) -real Tmn -integer nrw(M) -integer ncw(N) - -data colorder/ & -0,1,2,3,4,5,6,7,8,9,10,11,123,12,13,14,15,16,17,18, & -19,20,21,22,23,24,25,138,26,145,27,28,29,30,31,32,33,34,35,36, & -37,154,38,39,40,41,42,43,44,144,46,47,48,49,50,51,52,53,143,54, & -125,56,57,58,124,59,120,140,157,160,55,60,61,62,156,162,141,64,65,153, & -181,183,66,170,67,68,69,130,70,164,71,72,73,74,75,63,76,77,135,78, & -79,80,176,169,82,83,84,167,180,85,136,158,129,166,175,142,134,146,121,165, & -88,89,192,90,45,91,92,93,182,189,94,95,96,173,81,97,98,178,122,126, & -132,99,100,152,186,193,101,102,151,103,104,172,159,168,150,190,147,148,201,107, & -205,177,108,198,197,174,127,109,185,110,202,87,199,171,179,187,139,137,106,131, & -206,194,112,149,155,113,128,184,196,86,114,203,212,195,208,105,188,161,163,191, & -200,209,214,204,115,218,133,111,207,117,213,216,211,217,116,215,219,220,210,221, & -118,222,223,225,224,228,226,229,231,227,233,119,234,235,232,230,237,239,236,238, & -240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259, & -260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, & -280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299/ - -data Mn/ & - 1, 67, 0, 0, 0, 0, 0, & - 2, 189, 0, 0, 0, 0, 0, & - 3, 201, 0, 0, 0, 0, 0, & - 4, 13, 0, 0, 0, 0, 0, & - 5, 84, 0, 0, 0, 0, 0, & - 6, 188, 0, 0, 0, 0, 0, & - 7, 140, 0, 0, 0, 0, 0, & - 8, 167, 0, 0, 0, 0, 0, & - 9, 187, 0, 0, 0, 0, 0, & - 10, 173, 0, 0, 0, 0, 0, & - 11, 88, 0, 0, 0, 0, 0, & - 12, 213, 0, 0, 0, 0, 0, & - 14, 141, 0, 0, 0, 0, 0, & - 15, 236, 0, 0, 0, 0, 0, & - 16, 117, 0, 0, 0, 0, 0, & - 17, 99, 0, 0, 0, 0, 0, & - 18, 111, 0, 0, 0, 0, 0, & - 19, 178, 0, 0, 0, 0, 0, & - 20, 28, 0, 0, 0, 0, 0, & - 21, 177, 0, 0, 0, 0, 0, & - 22, 199, 0, 0, 0, 0, 0, & - 23, 209, 0, 0, 0, 0, 0, & - 24, 220, 0, 0, 0, 0, 0, & - 25, 59, 0, 0, 0, 0, 0, & - 26, 224, 0, 0, 0, 0, 0, & - 27, 30, 0, 0, 0, 0, 0, & - 29, 157, 0, 0, 0, 0, 0, & - 31, 184, 0, 0, 0, 0, 0, & - 32, 179, 0, 0, 0, 0, 0, & - 33, 149, 0, 0, 0, 0, 0, & - 34, 144, 0, 0, 0, 0, 0, & - 35, 80, 0, 0, 0, 0, 0, & - 36, 228, 0, 0, 0, 0, 0, & - 37, 185, 0, 0, 0, 0, 0, & - 38, 197, 0, 0, 0, 0, 0, & - 39, 69, 0, 0, 0, 0, 0, & - 40, 42, 0, 0, 0, 0, 0, & - 41, 112, 0, 0, 0, 0, 0, & - 43, 70, 0, 0, 0, 0, 0, & - 44, 198, 0, 0, 0, 0, 0, & - 45, 76, 0, 0, 0, 0, 0, & - 46, 68, 0, 0, 0, 0, 0, & - 47, 90, 0, 0, 0, 0, 0, & - 48, 75, 0, 0, 0, 0, 0, & - 49, 118, 0, 0, 0, 0, 0, & - 50, 125, 0, 0, 0, 0, 0, & - 51, 114, 0, 0, 0, 0, 0, & - 52, 239, 0, 0, 0, 0, 0, & - 53, 108, 0, 0, 0, 0, 0, & - 54, 120, 0, 0, 0, 0, 0, & - 55, 162, 0, 0, 0, 0, 0, & - 56, 218, 0, 0, 0, 0, 0, & - 57, 138, 0, 0, 0, 0, 0, & - 58, 212, 0, 0, 0, 0, 0, & - 60, 207, 0, 0, 0, 0, 0, & - 61, 71, 0, 0, 0, 0, 0, & - 62, 65, 0, 0, 0, 0, 0, & - 63, 161, 0, 0, 0, 0, 0, & - 64, 166, 0, 0, 0, 0, 0, & - 66, 158, 0, 0, 0, 0, 0, & - 72, 235, 0, 0, 0, 0, 0, & - 73, 225, 0, 0, 0, 0, 0, & - 74, 116, 0, 0, 0, 0, 0, & - 77, 96, 0, 0, 0, 0, 0, & - 78, 81, 0, 0, 0, 0, 0, & - 79, 82, 0, 0, 0, 0, 0, & - 83, 229, 0, 0, 0, 0, 0, & - 85, 134, 0, 0, 0, 0, 0, & - 86, 176, 0, 0, 0, 0, 0, & - 87, 203, 0, 0, 0, 0, 0, & - 89, 145, 0, 0, 0, 0, 0, & - 91, 152, 0, 0, 0, 0, 0, & - 92, 237, 0, 0, 0, 0, 0, & - 93, 215, 0, 0, 0, 0, 0, & - 94, 130, 0, 0, 0, 0, 0, & - 95, 156, 0, 0, 0, 0, 0, & - 97, 104, 0, 0, 0, 0, 0, & - 98, 182, 0, 0, 0, 0, 0, & - 100, 222, 0, 0, 0, 0, 0, & - 101, 123, 0, 0, 0, 0, 0, & - 102, 181, 0, 0, 0, 0, 0, & - 103, 135, 0, 0, 0, 0, 0, & - 105, 146, 0, 0, 0, 0, 0, & - 106, 115, 0, 0, 0, 0, 0, & - 107, 109, 0, 0, 0, 0, 0, & - 110, 194, 0, 0, 0, 0, 0, & - 113, 164, 0, 0, 0, 0, 0, & - 119, 172, 0, 0, 0, 0, 0, & - 121, 190, 0, 0, 0, 0, 0, & - 122, 169, 0, 0, 0, 0, 0, & - 124, 211, 0, 0, 0, 0, 0, & - 126, 165, 0, 0, 0, 0, 0, & - 127, 139, 0, 0, 0, 0, 0, & - 128, 129, 0, 0, 0, 0, 0, & - 131, 205, 0, 0, 0, 0, 0, & - 132, 196, 0, 0, 0, 0, 0, & - 133, 193, 0, 0, 0, 0, 0, & - 136, 200, 0, 0, 0, 0, 0, & - 137, 159, 0, 0, 0, 0, 0, & - 142, 204, 0, 0, 0, 0, 0, & - 143, 154, 0, 0, 0, 0, 0, & - 147, 238, 0, 0, 0, 0, 0, & - 148, 175, 0, 0, 0, 0, 0, & - 150, 216, 0, 0, 0, 0, 0, & - 151, 171, 0, 0, 0, 0, 0, & - 153, 231, 0, 0, 0, 0, 0, & - 155, 208, 0, 0, 0, 0, 0, & - 160, 230, 0, 0, 0, 0, 0, & - 163, 223, 0, 0, 0, 0, 0, & - 168, 217, 0, 0, 0, 0, 0, & - 170, 180, 0, 0, 0, 0, 0, & - 174, 233, 0, 0, 0, 0, 0, & - 183, 202, 0, 0, 0, 0, 0, & - 186, 214, 0, 0, 0, 0, 0, & - 191, 206, 0, 0, 0, 0, 0, & - 192, 219, 0, 0, 0, 0, 0, & - 195, 227, 0, 0, 0, 0, 0, & - 210, 226, 0, 0, 0, 0, 0, & - 221, 234, 0, 0, 0, 0, 0, & - 232, 240, 0, 0, 0, 0, 0, & - 1, 106, 0, 0, 0, 0, 0, & - 2, 119, 0, 0, 0, 0, 0, & - 3, 139, 0, 0, 0, 0, 0, & - 4, 14, 0, 0, 0, 0, 0, & - 5, 65, 0, 0, 0, 0, 0, & - 6, 61, 0, 0, 0, 0, 0, & - 7, 223, 0, 0, 0, 0, 0, & - 8, 171, 0, 0, 0, 0, 0, & - 9, 136, 0, 0, 0, 0, 0, & - 10, 113, 0, 0, 0, 0, 0, & - 11, 104, 0, 0, 0, 0, 0, & - 12, 175, 0, 0, 0, 0, 0, & - 13, 203, 0, 0, 0, 0, 0, & - 15, 149, 0, 0, 0, 0, 0, & - 16, 226, 0, 0, 0, 0, 0, & - 17, 219, 0, 0, 0, 0, 0, & - 18, 98, 0, 0, 0, 0, 0, & - 19, 211, 0, 0, 0, 0, 0, & - 20, 49, 0, 0, 0, 0, 0, & - 21, 214, 0, 0, 0, 0, 0, & - 22, 68, 0, 0, 0, 0, 0, & - 23, 77, 0, 0, 0, 0, 0, & - 24, 116, 0, 0, 0, 0, 0, & - 25, 235, 0, 0, 0, 0, 0, & - 26, 50, 0, 0, 0, 0, 0, & - 27, 124, 0, 0, 0, 0, 0, & - 28, 229, 0, 0, 0, 0, 0, & - 29, 83, 0, 0, 0, 0, 0, & - 30, 158, 0, 0, 0, 0, 0, & - 31, 220, 0, 0, 0, 0, 0, & - 32, 155, 0, 0, 0, 0, 0, & - 33, 152, 0, 0, 0, 0, 0, & - 34, 231, 0, 0, 0, 0, 0, & - 35, 207, 0, 0, 0, 0, 0, & - 36, 40, 0, 0, 0, 0, 0, & - 37, 142, 0, 0, 0, 0, 0, & - 38, 75, 0, 0, 0, 0, 0, & - 39, 90, 167, 0, 0, 0, 0, & - 41, 55, 125, 0, 0, 0, 0, & - 42, 153, 196, 0, 0, 0, 0, & - 43, 72, 112, 0, 0, 0, 0, & - 44, 183, 233, 0, 0, 0, 0, & - 45, 81, 178, 0, 0, 0, 0, & - 46, 187, 230, 0, 0, 0, 0, & - 47, 133, 176, 0, 0, 0, 0, & - 48, 54, 186, 0, 0, 0, 0, & - 51, 150, 224, 0, 0, 0, 0, & - 52, 53, 190, 0, 0, 0, 0, & - 56, 143, 228, 0, 0, 0, 0, & - 57, 97, 197, 0, 0, 0, 0, & - 58, 62, 89, 0, 0, 0, 0, & - 59, 174, 194, 0, 0, 0, 0, & - 60, 91, 93, 0, 0, 0, 0, & - 63, 85, 96, 0, 0, 0, 0, & - 64, 92, 205, 0, 0, 0, 0, & - 66, 67, 164, 0, 0, 0, 0, & - 69, 103, 159, 0, 0, 0, 0, & - 70, 117, 122, 0, 0, 0, 0, & - 71, 88, 160, 0, 0, 0, 0, & - 73, 148, 180, 0, 0, 0, 0, & - 74, 108, 109, 0, 0, 0, 0, & - 76, 102, 151, 0, 0, 0, 0, & - 78, 128, 206, 0, 0, 0, 0, & - 79, 215, 239, 0, 0, 0, 0, & - 80, 138, 221, 0, 0, 0, 0, & - 82, 162, 195, 0, 0, 0, 0, & - 84, 161, 184, 0, 0, 0, 0, & - 86, 213, 218, 0, 0, 0, 0, & - 87, 120, 240, 0, 0, 0, 0, & - 94, 100, 157, 0, 0, 0, 0, & - 95, 202, 217, 0, 0, 0, 0, & - 99, 199, 201, 0, 0, 0, 0, & - 101, 127, 225, 0, 0, 0, 0, & - 105, 168, 185, 0, 0, 0, 0, & - 107, 182, 237, 0, 0, 0, 0, & - 110, 147, 208, 0, 0, 0, 0, & - 111, 118, 172, 0, 0, 0, 0, & - 114, 140, 165, 0, 0, 0, 0, & - 115, 130, 141, 0, 0, 0, 0, & - 121, 144, 173, 0, 0, 0, 0, & - 123, 204, 209, 0, 0, 0, 0, & - 126, 137, 188, 0, 0, 0, 0, & - 129, 179, 189, 0, 0, 0, 0, & - 131, 192, 210, 0, 0, 0, 0, & - 132, 200, 238, 0, 0, 0, 0, & - 134, 177, 191, 0, 0, 0, 0, & - 135, 145, 222, 0, 0, 0, 0, & - 146, 229, 236, 0, 0, 0, 0, & - 154, 169, 232, 0, 0, 0, 0, & - 124, 156, 163, 0, 0, 0, 0, & - 166, 223, 234, 0, 0, 0, 0, & - 1, 11, 170, 0, 0, 0, 0, & - 3, 181, 227, 0, 0, 0, 0, & - 193, 198, 220, 0, 0, 0, 0, & - 10, 16, 212, 0, 0, 0, 0, & - 42, 96, 216, 0, 0, 0, 0, & - 2, 6, 215, 0, 0, 0, 0, & - 4, 208, 219, 0, 0, 0, 0, & - 5, 22, 35, 0, 0, 0, 0, & - 7, 12, 20, 0, 0, 0, 0, & - 8, 15, 75, 0, 0, 0, 0, & - 9, 74, 83, 0, 0, 0, 0, & - 13, 37, 50, 0, 0, 0, 0, & - 14, 52, 86, 0, 0, 0, 0, & - 17, 30, 177, 0, 0, 0, 0, & - 18, 25, 97, 0, 0, 0, 0, & - 19, 72, 157, 0, 0, 0, 0, & - 21, 58, 116, 0, 0, 0, 0, & - 23, 111, 226, 0, 0, 0, 0, & - 24, 26, 180, 0, 0, 0, 0, & - 27, 34, 39, 0, 0, 0, 0, & - 28, 32, 161, 0, 0, 0, 0, & - 29, 36, 60, 0, 0, 0, 0, & - 31, 76, 154, 0, 0, 0, 0, & - 33, 101, 238, 0, 0, 0, 0, & - 38, 95, 162, 0, 0, 0, 0, & - 40, 164, 183, 0, 0, 0, 0, & - 41, 92, 196, 0, 0, 0, 0, & - 43, 48, 99, 165, 190, 198, 204, & - 44, 129, 138, 145, 160, 203, 237, & - 45, 65, 66, 98, 127, 137, 146, & - 46, 131, 149, 181, 211, 218, 224, & - 47, 49, 55, 191, 194, 207, 232, & - 51, 69, 106, 109, 119, 184, 217, & - 53, 62, 104, 155, 166, 206, 231, & - 54, 61, 63, 73, 118, 151, 163, & - 56, 94, 110, 117, 185, 189, 214, & - 57, 81, 91, 115, 173, 175, 227, & - 59, 79, 103, 136, 171, 201, 212, & - 24, 64, 77, 93, 202, 235, 236, & - 67, 132, 142, 150, 156, 176, 222, & - 68, 153, 159, 169, 170, 186, 221, & - 70, 84, 89, 113, 174, 197, 205, & - 71, 125, 130, 140, 158, 200, 210, & - 8, 78, 143, 182, 192, 193, 216, & - 23, 80, 82, 90, 108, 139, 228, & - 85, 122, 123, 128, 141, 187, 188, & - 25, 87, 100, 152, 209, 213, 234, & - 88, 134, 147, 167, 172, 178, 239, & - 18, 40, 102, 114, 133, 144, 179, & - 4, 105, 108, 112, 148, 230, 240, & - 29, 33, 50, 62, 107, 195, 199, & - 3, 83, 113, 120, 126, 177, 216, & - 11, 55, 116, 121, 135, 168, 225, & - 1, 27, 28, 76, 187, 226, 233, & - 2, 4, 7, 10, 22, 75, 222, & - 5, 30, 131, 152, 156, 168, 215, & - 6, 13, 19, 58, 196, 228, 229, & - 9, 26, 144, 147, 158, 223, 240, & - 12, 31, 66, 79, 92, 96, 155, & - 14, 54, 103, 173, 202, 232, 238, & - 15, 17, 37, 69, 129, 164, 209, & - 16, 72, 91, 114, 163, 169, 237, & - 20, 45, 89, 99, 143, 180, 208, & - 21, 39, 60, 141, 171, 198, 234, & - 21, 32, 52, 78, 95, 148, 199, & - 34, 73, 84, 157, 200, 221, 236, & - 35, 36, 63, 97, 105, 119, 220, & - 38, 46, 93, 111, 136, 191, 203, & - 41, 51, 151, 160, 213, 214, 231, & - 42, 57, 65, 161, 167, 194, 204, & - 43, 109, 162, 175, 189, 210, 212, & - 44, 74, 100, 149, 170, 188, 197, & - 47, 64, 88, 107, 122, 165, 211, & - 48, 139, 179, 184, 218, 233, 239, & - 49, 94, 106, 112, 138, 142, 205, & - 53, 59, 102, 115, 134, 182, 225, & - 56, 68, 101, 150, 166, 178, 207, & - 61, 117, 126, 154, 195, 219, 224, & - 67, 80, 118, 174, 185, 190, 235, & - 70, 77, 86, 125, 153, 172, 193, & - 32, 71, 87, 90, 98, 110, 135, & - 41, 75, 81, 85, 124, 133, 201, & - 82, 120, 128, 140, 159, 176, 183, & - 22, 72, 104, 130, 146, 181, 217, & - 25, 89, 96, 121, 132, 186, 230, & - 118, 123, 145, 192, 196, 227, 240, & - 1, 14, 35, 38, 114, 127, 192, & - 7, 23, 43, 63, 116, 137, 206, & - 2, 37, 52, 57, 64, 76, 120/ - -data Nm/ & - 1, 121, 212, 265, 298, & - 2, 122, 217, 266, 300, & - 3, 123, 213, 263, 0, & - 4, 124, 218, 261, 266, & - 5, 125, 219, 267, 0, & - 6, 126, 217, 268, 0, & - 7, 127, 220, 266, 299, & - 8, 128, 221, 255, 0, & - 9, 129, 222, 269, 0, & - 10, 130, 215, 266, 0, & - 11, 131, 212, 264, 0, & - 12, 132, 220, 270, 0, & - 4, 133, 223, 268, 0, & - 13, 124, 224, 271, 298, & - 14, 134, 221, 272, 0, & - 15, 135, 215, 273, 0, & - 16, 136, 225, 272, 0, & - 17, 137, 226, 260, 0, & - 18, 138, 227, 268, 0, & - 19, 139, 220, 274, 0, & - 20, 140, 228, 275, 276, & - 21, 141, 219, 266, 295, & - 22, 142, 229, 256, 299, & - 23, 143, 230, 250, 0, & - 24, 144, 226, 258, 296, & - 25, 145, 230, 269, 0, & - 26, 146, 231, 265, 0, & - 19, 147, 232, 265, 0, & - 27, 148, 233, 262, 0, & - 26, 149, 225, 267, 0, & - 28, 150, 234, 270, 0, & - 29, 151, 232, 276, 292, & - 30, 152, 235, 262, 0, & - 31, 153, 231, 277, 0, & - 32, 154, 219, 278, 298, & - 33, 155, 233, 278, 0, & - 34, 156, 223, 272, 300, & - 35, 157, 236, 279, 298, & - 36, 158, 231, 275, 0, & - 37, 155, 237, 260, 0, & - 38, 159, 238, 280, 293, & - 37, 160, 216, 281, 0, & - 39, 161, 239, 282, 299, & - 40, 162, 240, 283, 0, & - 41, 163, 241, 274, 0, & - 42, 164, 242, 279, 0, & - 43, 165, 243, 284, 0, & - 44, 166, 239, 285, 0, & - 45, 139, 243, 286, 0, & - 46, 145, 223, 262, 0, & - 47, 167, 244, 280, 0, & - 48, 168, 224, 276, 300, & - 49, 168, 245, 287, 0, & - 50, 166, 246, 271, 0, & - 51, 159, 243, 264, 0, & - 52, 169, 247, 288, 0, & - 53, 170, 248, 281, 300, & - 54, 171, 228, 268, 0, & - 24, 172, 249, 287, 0, & - 55, 173, 233, 275, 0, & - 56, 126, 246, 289, 0, & - 57, 171, 245, 262, 0, & - 58, 174, 246, 278, 299, & - 59, 175, 250, 284, 300, & - 57, 125, 241, 281, 0, & - 60, 176, 241, 270, 0, & - 1, 176, 251, 290, 0, & - 42, 141, 252, 288, 0, & - 36, 177, 244, 272, 0, & - 39, 178, 253, 291, 0, & - 56, 179, 254, 292, 0, & - 61, 161, 227, 273, 295, & - 62, 180, 246, 277, 0, & - 63, 181, 222, 283, 0, & - 44, 157, 221, 266, 293, & - 41, 182, 234, 265, 300, & - 64, 142, 250, 291, 0, & - 65, 183, 255, 276, 0, & - 66, 184, 249, 270, 0, & - 32, 185, 256, 290, 0, & - 65, 163, 248, 293, 0, & - 66, 186, 256, 294, 0, & - 67, 148, 222, 263, 0, & - 5, 187, 253, 277, 0, & - 68, 174, 257, 293, 0, & - 69, 188, 224, 291, 0, & - 70, 189, 258, 292, 0, & - 11, 179, 259, 284, 0, & - 71, 171, 253, 274, 296, & - 43, 158, 256, 292, 0, & - 72, 173, 248, 273, 0, & - 73, 175, 238, 270, 0, & - 74, 173, 250, 279, 0, & - 75, 190, 247, 286, 0, & - 76, 191, 236, 276, 0, & - 64, 174, 216, 270, 296, & - 77, 170, 226, 278, 0, & - 78, 137, 241, 292, 0, & - 16, 192, 239, 274, 0, & - 79, 190, 258, 283, 0, & - 80, 193, 235, 288, 0, & - 81, 182, 260, 287, 0, & - 82, 177, 249, 271, 0, & - 77, 131, 245, 295, 0, & - 83, 194, 261, 278, 0, & - 84, 121, 244, 286, 0, & - 85, 195, 262, 284, 0, & - 49, 181, 256, 261, 0, & - 85, 181, 244, 282, 0, & - 86, 196, 247, 292, 0, & - 17, 197, 229, 279, 0, & - 38, 161, 261, 286, 0, & - 87, 130, 253, 263, 0, & - 47, 198, 260, 273, 298, & - 84, 199, 248, 287, 0, & - 63, 143, 228, 264, 299, & - 15, 178, 247, 289, 0, & - 45, 197, 246, 290, 297, & - 88, 122, 244, 278, 0, & - 50, 189, 263, 294, 300, & - 89, 200, 264, 296, 0, & - 90, 178, 257, 284, 0, & - 80, 201, 257, 297, 0, & - 91, 146, 210, 293, 0, & - 46, 159, 254, 291, 0, & - 92, 202, 263, 289, 0, & - 93, 193, 241, 298, 0, & - 94, 183, 257, 294, 0, & - 94, 203, 240, 272, 0, & - 75, 199, 254, 295, 0, & - 95, 204, 242, 267, 0, & - 96, 205, 251, 296, 0, & - 97, 165, 260, 293, 0, & - 68, 206, 259, 287, 0, & - 82, 207, 264, 292, 0, & - 98, 129, 249, 279, 0, & - 99, 202, 241, 299, 0, & - 53, 185, 240, 286, 0, & - 93, 123, 256, 285, 0, & - 7, 198, 254, 294, 0, & - 13, 199, 257, 275, 0, & - 100, 156, 251, 286, 0, & - 101, 169, 255, 274, 0, & - 31, 200, 260, 269, 0, & - 71, 207, 240, 297, 0, & - 83, 208, 241, 295, 0, & - 102, 196, 259, 269, 0, & - 103, 180, 261, 276, 0, & - 30, 134, 242, 283, 0, & - 104, 167, 251, 288, 0, & - 105, 182, 246, 280, 0, & - 72, 152, 258, 267, 0, & - 106, 160, 252, 291, 0, & - 101, 209, 234, 289, 0, & - 107, 151, 245, 270, 0, & - 76, 210, 251, 267, 0, & - 27, 190, 227, 277, 0, & - 60, 149, 254, 269, 0, & - 99, 177, 252, 294, 0, & - 108, 179, 240, 280, 0, & - 58, 187, 232, 281, 0, & - 51, 186, 236, 282, 0, & - 109, 210, 246, 273, 0, & - 87, 176, 237, 272, 0, & - 92, 198, 239, 284, 0, & - 59, 211, 245, 288, 0, & - 8, 158, 259, 281, 0, & - 110, 194, 264, 267, 0, & - 90, 209, 252, 273, 0, & - 111, 212, 252, 283, 0, & - 105, 128, 249, 275, 0, & - 88, 197, 259, 291, 0, & - 10, 200, 248, 271, 0, & - 112, 172, 253, 290, 0, & - 103, 132, 248, 282, 0, & - 69, 165, 251, 294, 0, & - 20, 206, 225, 263, 0, & - 18, 163, 259, 288, 0, & - 29, 203, 260, 285, 0, & - 111, 180, 230, 274, 0, & - 81, 213, 242, 295, 0, & - 78, 195, 255, 287, 0, & - 113, 162, 237, 294, 0, & - 28, 187, 244, 285, 0, & - 34, 194, 247, 290, 0, & - 114, 166, 252, 296, 0, & - 9, 164, 257, 265, 0, & - 6, 202, 257, 283, 0, & - 2, 203, 247, 282, 0, & - 89, 168, 239, 290, 0, & - 115, 206, 243, 279, 0, & - 116, 204, 255, 297, 298, & - 97, 214, 255, 291, 0, & - 86, 172, 243, 281, 0, & - 117, 186, 262, 289, 0, & - 96, 160, 238, 268, 297, & - 35, 170, 253, 283, 0, & - 40, 214, 239, 275, 0, & - 21, 192, 262, 276, 0, & - 98, 205, 254, 277, 0, & - 3, 192, 249, 293, 0, & - 113, 191, 250, 271, 0, & - 70, 133, 240, 279, 0, & - 100, 201, 239, 281, 0, & - 95, 175, 253, 286, 0, & - 115, 183, 245, 299, 0, & - 55, 154, 243, 288, 0, & - 107, 196, 218, 274, 0, & - 22, 201, 258, 272, 0, & - 118, 204, 254, 282, 0, & - 91, 138, 242, 284, 0, & - 54, 215, 249, 282, 0, & - 12, 188, 258, 280, 0, & - 114, 140, 247, 280, 0, & - 74, 184, 217, 267, 0, & - 104, 216, 255, 263, 0, & - 110, 191, 244, 295, 0, & - 52, 188, 242, 285, 0, & - 116, 136, 218, 289, 0, & - 23, 150, 214, 278, 0, & - 119, 185, 252, 277, 0, & - 79, 207, 251, 266, 0, & - 109, 127, 211, 269, 0, & - 25, 167, 242, 289, 0, & - 62, 193, 264, 287, 0, & - 118, 135, 229, 265, 0, & - 117, 213, 248, 297, 0, & - 33, 169, 256, 268, 0, & - 67, 147, 208, 268, 0, & - 108, 164, 261, 296, 0, & - 106, 153, 245, 280, 0, & - 120, 209, 243, 271, 0, & - 112, 162, 265, 285, 0, & - 119, 211, 258, 275, 0, & - 61, 144, 250, 290, 0, & - 14, 208, 250, 277, 0, & - 73, 195, 240, 273, 0, & - 102, 205, 235, 271, 0, & - 48, 184, 259, 285, 0, & - 120, 189, 261, 269, 297/ - -data nrw/ & -5,5,4,5,4,4,5,4,4,4,4,4,4,5,4,4,4,4,4,4, & -5,5,5,4,5,4,4,4,4,4,4,5,4,4,5,4,5,5,4,4, & -5,4,5,4,4,4,4,4,4,4,4,5,4,4,4,4,5,4,4,4, & -4,4,5,5,4,4,4,4,4,4,4,5,4,4,5,5,4,4,4,4, & -4,4,4,4,4,4,4,4,5,4,4,4,4,4,4,5,4,4,4,4, & -4,4,4,4,4,4,4,4,4,4,4,4,4,5,4,5,4,5,4,5, & -4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, & -4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, & -4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, & -4,4,4,4,4,4,4,4,4,4,4,5,4,4,4,5,4,4,4,4, & -4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, & -4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5/ - -data ncw/ & -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, & -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, & -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, & -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, & -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, & -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, & -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, & -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3, & -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,7,7, & -7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, & -7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, & -7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7/ - -!ncw=3 - -toc=0 -tov=0 -tanhtoc=0 -!write(*,*) llr -! initialize messages to checks -do j=1,M - do i=1,nrw(j) - toc(i,j)=llr((Nm(i,j))) - enddo -enddo - -ncnt=0 - -do iter=0,maxiterations - -! Update bit log likelihood ratios (tov=0 in iteration 0). - do i=1,N - if( apmask(i) .ne. 1 ) then - zn(i)=llr(i)+sum(tov(1:ncw(i),i)) - else - zn(i)=llr(i) - endif - enddo - -! Check to see if we have a codeword (check before we do any iteration). - cw=0 - where( zn .gt. 0. ) cw=1 - ncheck=0 - do i=1,M - synd(i)=sum(cw(Nm(1:nrw(i),i))) - if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1 -! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied' - enddo -!write(*,*) 'number of unsatisfied parity checks ',ncheck - if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it -! niterations=iter - codeword=cw(colorder+1) - decoded=codeword(M+1:N) - nerr=0 - do i=1,N - if( (2*cw(i)-1)*llr(i) .lt. 0.0 ) nerr=nerr+1 - enddo - niterations=nerr - return - endif - - if( iter.gt.0 ) then ! this code block implements an early stopping criterion - nd=ncheck-nclast - if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased - ncnt=0 ! reset counter - else - ncnt=ncnt+1 - endif -! write(*,*) iter,ncheck,nd,ncnt - if( ncnt .ge. 5 .and. iter .ge. 15 .and. ncheck .gt. 50) then - niterations=-1 - return - endif - endif - nclast=ncheck - -! Send messages from bits to check nodes - do j=1,M - do i=1,nrw(j) - ibj=Nm(i,j) - toc(i,j)=zn(ibj) -! do kk=1,ncw(ibj) ! subtract off what the bit had received from the check - do kk=1,7 ! subtract off what the bit had received from the check - if( Mn(kk,ibj) .eq. j ) then - toc(i,j)=toc(i,j)-tov(kk,ibj) - endif - enddo - enddo - enddo - -! send messages from check nodes to variable nodes - do i=1,M - tanhtoc(1:5,i)=tanh(-toc(1:5,i)/2) - enddo - - do j=1,N - do i=1,ncw(j) - ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j - Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) - call platanh(-Tmn,y) -! y=atanh(-Tmn) - tov(i,j)=2*y - enddo - enddo - -enddo -niterations=-1 -return -end subroutine bpdecode300 diff --git a/lib/fsk4hf/chkcrc10.f90 b/lib/fsk4hf/chkcrc10.f90 deleted file mode 100644 index abe7bd79..00000000 --- a/lib/fsk4hf/chkcrc10.f90 +++ /dev/null @@ -1,27 +0,0 @@ -subroutine chkcrc10(decoded,nbadcrc)
-
- use crc
- integer*1 decoded(60)
- integer*1, target:: i1Dec8BitBytes(9)
-
-! Check the CRC
- do ibyte=1,6
- itmp=0
- do ibit=1,8
- itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit))
- enddo
- i1Dec8BitBytes(ibyte)=itmp
- enddo
- i1Dec8BitBytes(7)=decoded(49)*128+decoded(50)*64
-
-! Pack received CRC into bytes 8 and 9 for crc10_check
- i1Dec8BitBytes(8)=decoded(51)*2+decoded(52)
- i1Dec8BitBytes(9)=decoded(53)*128 + decoded(54)*64+decoded(55)*32 + &
- decoded(56)*16
- i1Dec8BitBytes(9)=i1Dec8BitBytes(9) + decoded(57)*8+decoded(58)*4 + &
- decoded(59)*2+decoded(60)*1
- nbadcrc=1
- if(crc10_check(c_loc(i1Dec8BitBytes),9)) nbadcrc=0
-
- return
-end subroutine chkcrc10
diff --git a/lib/fsk4hf/chkcrc12.f90 b/lib/fsk4hf/chkcrc12.f90 deleted file mode 100644 index a177fa11..00000000 --- a/lib/fsk4hf/chkcrc12.f90 +++ /dev/null @@ -1,27 +0,0 @@ -subroutine chkcrc12(decoded,nbadcrc)
-
- use crc
- integer*1 decoded(84)
- integer*1, target:: i1Dec8BitBytes(11)
-
-! Check the CRC
-! Collapse 84 decoded bits to 11 bytes. Bytes 1-9 are the message,
-! byte 10 and first half of byte 11 is the crc
- do ibyte=1,9
- itmp=0
- do ibit=1,8
- itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit))
- enddo
- i1Dec8BitBytes(ibyte)=itmp
- enddo
-
-! Pack the crc into bytes 10 and 11 for crc12_check
- i1Dec8BitBytes(10)=decoded(73)*8 + decoded(74)*4 + decoded(75)*2 + decoded(76)
- i1Dec8BitBytes(11)=decoded(77)*128 + decoded(78)*64 + &
- decoded(79)*32 + decoded(80)*16 + decoded(81)*8 + decoded(82)*4 + &
- decoded(83)*2 + decoded(84)
- nbadcrc=1
- if( crc12_check(c_loc (i1Dec8BitBytes), 11) ) nbadcrc=0
-
- return
-end subroutine chkcrc12
diff --git a/lib/fsk4hf/cpolyfit.f90 b/lib/fsk4hf/cpolyfit.f90 deleted file mode 100644 index fd0d5987..00000000 --- a/lib/fsk4hf/cpolyfit.f90 +++ /dev/null @@ -1,76 +0,0 @@ -subroutine cpolyfit(c,pp,id,maxn,aa,bb,zz,nhardsync)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (N13=13*N2) !Samples in central sync vector (416)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
- complex c(0:NZ-1) !Complex waveform
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z,z0
- real x(NS),yi(NS),yq(NS) !For complex polyfit
- real pp(2*NSPS) !Shaped pulse for OQPSK
- real aa(20),bb(20) !Fitted polyco's
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
-
- ib=NSPS-1
- ib2=N2-1
- n=0
- do j=1,117 !First-pass demodulation
- ia=ib+1
- ib=ia+N2-1
- zz(j)=sum(pp*c(ia:ib))/NSPS
- if(abs(id(j)).eq.2) then !Save all sync symbols
- n=n+1
- x(n)=float(ia+ib)/NZ - 1.0
- yi(n)=real(zz(j))*0.5*id(j)
- yq(n)=aimag(zz(j))*0.5*id(j)
-! write(54,1225) n,x(n),yi(n),yq(n)
-!1225 format(i5,3f12.4)
- endif
- if(j.le.116) then
- zz(j+117)=sum(pp*c(ia+NSPS:ib+NSPS))/NSPS
- endif
- enddo
-
- aa=0.
- bb=0.
- nterms=0
- chisqa=0.
- chisqb=0.
- if(maxn.gt.0) then
- npts=n
- mode=0
- nterms=maxn
- call polyfit4(x,yi,yi,npts,nterms,mode,aa,chisqa)
- call polyfit4(x,yq,yq,npts,nterms,mode,bb,chisqb)
- endif
-
- nhardsync=0
- do j=1,117
- if(abs(id(j)).ne.2) cycle
- xx=j*2.0/117.0 - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=real(z)
- if(p*id(j).lt.0) nhardsync=nhardsync+1
- enddo
-
- return
-end subroutine cpolyfit
diff --git a/lib/fsk4hf/cpolyfitw.f90 b/lib/fsk4hf/cpolyfitw.f90 deleted file mode 100644 index 561052f8..00000000 --- a/lib/fsk4hf/cpolyfitw.f90 +++ /dev/null @@ -1,68 +0,0 @@ -subroutine cpolyfitw(c,pp,id,maxn,aa,bb,zz,nhardsync)
-
- include 'wsprlf_params.f90'
-
- complex c(0:NZ-1) !Complex waveform
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z,z0
- real x(NS),yi(NS),yq(NS) !For complex polyfit
- real pp(2*NSPS) !Shaped pulse for OQPSK
- real aa(20),bb(20) !Fitted polyco's
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
-
- ib=NSPS-1
- ib2=N2-1
- n=0
- jz=(NS+ND+1)/2
- do j=1,jz !First-pass demodulation
- ia=ib+1
- ib=ia+N2-1
- zz(j)=sum(pp*c(ia:ib))/NSPS
- if(abs(id(j)).eq.2) then !Save all sync symbols
- n=n+1
- x(n)=float(ia+ib)/NZ - 1.0
- yi(n)=real(zz(j))*0.5*id(j)
- yq(n)=aimag(zz(j))*0.5*id(j)
-! write(54,1225) n,x(n),yi(n),yq(n)
-!1225 format(i5,3f12.4)
- endif
- if(j.lt.jz) then
- zz(j+jz)=sum(pp*c(ia+NSPS:ib+NSPS))/NSPS
- endif
- enddo
-
- aa=0.
- bb=0.
- nterms=0
- chisqa=0.
- chisqb=0.
- if(maxn.gt.0) then
- npts=n
- mode=0
- nterms=maxn
- call polyfit4(x,yi,yi,npts,nterms,mode,aa,chisqa)
- call polyfit4(x,yq,yq,npts,nterms,mode,bb,chisqb)
- endif
-
- nhardsync=0
- do j=1,205
- if(abs(id(j)).ne.2) cycle
- xx=j*2.0/205.0 - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=real(z)
- if(p*id(j).lt.0) nhardsync=nhardsync+1
- enddo
-
- return
-end subroutine cpolyfitw
diff --git a/lib/fsk4hf/dbpsksim.f90 b/lib/fsk4hf/dbpsksim.f90 deleted file mode 100644 index 8b9ea12c..00000000 --- a/lib/fsk4hf/dbpsksim.f90 +++ /dev/null @@ -1,241 +0,0 @@ -program dbpsksim - - parameter (ND=121) !Data symbols: LDPC (120,60), r=1/2 - parameter (NN=ND) !Total symbols (121) - parameter (NSPS=28800) !Samples per symbol at 12000 sps - parameter (NZ=NSPS*NN) !Samples in waveform (3484800) - parameter (NFFT1=65536,NH1=NFFT1/2) - parameter (NFFT2=128,NH2=NFFT2/2) - - character*8 arg - complex c(0:NZ-1) !Complex waveform - complex c2(0:NFFT1-1) !Short spectra - complex cr(0:NZ-1) - complex ct(0:NZ-1) - complex cz(0:NFFT2-1) - complex z0,z,zp - real s(-NH1+1:NH1) - real s2(-NH2+1:NH2) - real xnoise(0:NZ-1) !Generated random noise - real ynoise(0:NZ-1) !Generated random noise - real rxdata(120),llr(120) - integer id(NN) !Encoded NRZ data (values +/-1) - integer id1(NN) !Recovered data (1st pass) - integer id2(NN) !Recovered data (2nd pass) -! integer icw(NN) - integer*1 msgbits(60),decoded(60),codeword(120),apmask(120),cw(120) - data msgbits/0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,& - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,0,1,0,1,1,0,1,0/ - - nnn=0 - nargs=iargc() - if(nargs.ne.6) then - print*,'Usage: dbpsksim f0(Hz) delay(ms) fspread(Hz) ndiff iters snr(dB)' - print*,'Example: dbpsksim 1500 0 0 10 -35' - print*,'Set snr=0 to cycle through a range' - go to 999 - endif - call getarg(1,arg) - read(arg,*) f0 !Low tone frequency - call getarg(2,arg) - read(arg,*) delay - call getarg(3,arg) - read(arg,*) fspread - call getarg(4,arg) - read(arg,*) ndiff - call getarg(5,arg) - read(arg,*) iters - call getarg(6,arg) - read(arg,*) snrdb - - twopi=8.d0*atan(1.d0) - fs=12000.d0 - dt=1.0/fs - ts=NSPS*dt - baud=1.d0/ts - txt=NZ*dt - bandwidth_ratio=2500.0/6000.0 - write(*,1000) baud,5*baud,txt,delay,fspread,ndiff -1000 format('Baud:',f6.3,' BW:',f4.1,' TxT:',f6.1,' Delay:',f5.2, & - ' fSpread:',f5.2,' ndiff:',i2/) - - write(*,1004) -1004 format(' SNR err ber fer fsigma'/35('-')) - - call encode120(msgbits,codeword) !Encode the test message - isna=-28 - isnb=-40 - if(snrdb.ne.0.0) then - isna=nint(snrdb) - isnb=isna - endif - do isnr=isna,isnb,-1 - snrdb=isnr - sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - nhard=0 - nhardc=0 - nfe1=0 - nfe2=0 - sqf=0. - do iter=1,iters - nnn=nnn+1 - id(1)=1 !First bit is always 1 - id(2:NN)=2*codeword-1 - call genbpsk(id,f0,ndiff,0,c) !Generate the 4-FSK waveform - if(delay.ne.0.0 .or. fspread.ne.0.0) call watterson(c,delay,fspread) - c=sig*c !Scale to requested SNR - if(snrdb.lt.90) then - do i=0,NZ-1 !Generate gaussian noise - xnoise(i)=gran() - ynoise(i)=gran() - enddo - c=c + cmplx(xnoise,ynoise) !Add noise to signal - endif - -! First attempt at finding carrier frequency fc: 64k FFTs ==> avg power spectra - nspec=NZ/NFFT1 - df1=12000.0/NFFT1 - s=0. - do k=1,nspec - ia=(k-1)*NSPS - ib=ia+NSPS-1 - c2(0:NSPS-1)=c(ia:ib) - c2(NSPS:)=0. - call four2a(c2,NFFT1,1,-1,1) - do i=0,NFFT1-1 - j=i - if(j.gt.NH1) j=j-NFFT1 - s(j)=s(j) + real(c2(i))**2 + aimag(c2(i))**2 - enddo - enddo - s=1.e-6*s - smax=0. - ipk=0 - ia=(1400.0)/df1 - ib=(1600.0)/df1 - do i=ia,ib - f=i*df1 - if(s(i).gt.smax) then - smax=s(i) - ipk=i - fc=f - endif - enddo - a=(s(ipk+1)-s(ipk-1))/2.0 - b=(s(ipk+1)+s(ipk-1)-2.0*s(ipk))/2.0 - dx=-a/(2.0*b) - fc=fc + df1*dx !Estimated carrier frequency - sqf=sqf + (fc-f0)**2 - -! The following is for testing SNR calibration: -! sp5n=(s(ipk-2)+s(ipk-1)+s(ipk)+s(ipk+1)+s(ipk+2)) !Sig + 5*noise -! base=(sum(s)-sp5n)/(NFFT1-5.0) !Noise per bin -! psig=sp5n-5*base !Sig only -! pnoise=(2500.0/df1)*base !Noise in 2500 Hz -! xsnrdb=db(psig/pnoise) - - call genbpsk(id,fc,ndiff,1,cr) !Generate reference carrier - c=c*conjg(cr) !Mix signal to baseband - - z0=1.0 - do j=1,NN !Demodulate - ia=(j-1)*NSPS - ib=ia+NSPS-1 - z=sum(c(ia:ib)) - cz(j-1)=z - zp=z*conjg(z0) - p=1.e-4*real(zp) - id1(j)=-1 - if(p.ge.0.0) id1(j)=1 - if(j.ge.2) rxdata(j-1)=p - z0=z - enddo - - rxav=sum(rxdata)/120 - rx2av=sum(rxdata*rxdata)/120 - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - ss=0.84 - llr=2.0*rxdata/(ss*ss) - apmask=0 - max_iterations=10 - call bpdecode120(llr,apmask,max_iterations,decoded,niterations,cw) - -! Count frame errors - if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0) nfe1=nfe1+1 - -! Find carrier frequency from squared cz array. - cz(121:)=0. - cz=cz*cz - call four2a(cz,NFFT2,1,-1,1) - s2max=0. - do i=0,NFFT2-1 - j=i - if(i.gt.NH2) j=j-NFFT2 - s2(j)=real(cz(i))**2 + aimag(cz(i))**2 - if(s2(j).gt.s2max) then - s2max=s2(j) - jpk=j - endif -! write(16,1200) j*baud/NFFT2,1.e-12*s2(j) -!1200 format(2f12.3) - enddo - a=(s2(jpk+1)-s2(jpk-1))/2.0 - b=(s2(jpk+1)+s2(jpk-1)-2.0*s2(jpk))/2.0 - dx=-a/(2.0*b) - fc2=0.5*(jpk+dx)*baud/NFFT2 - - call genbpsk(id,fc2,ndiff,1,cr) !Generate new ref carrier at fc2 - c=c*conjg(cr) - z0=1.0 - do j=1,NN !Demodulate - ia=(j-1)*NSPS - ib=ia+NSPS-1 - z=sum(c(ia:ib)) - if(j.eq.1) z0=z - zp=z*conjg(z0) - p=1.e-4*real(zp) - id2(j)=-1 - if(p.ge.0.0) id2(j)=1 - if(j.ge.2) rxdata(j-1)=p - ierr=0 - if(id2(j).ne.id(j)) ierr=1 - id3=-1 - if(real(z).ge.0.0) id3=1 - if(j.ge.2 .and. id3.ne.id(j)) nhardc=nhardc+1 - if(j.ge.2 .and. ndiff.eq.0) rxdata(j-1)=real(z) - z0=z - enddo - nhard=nhard + count(id2.ne.id) !Count hard errors - - rxav=sum(rxdata)/120 - rx2av=sum(rxdata*rxdata)/120 - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - ss=0.84 - llr=2.0*rxdata/(ss*ss) !Soft symbols - apmask=0 - max_iterations=10 - decoded=0 - call bpdecode120(llr,apmask,max_iterations,decoded,niterations,cw) -! if(niterations.lt.0) then -! llr=-llr -! call bpdecode120(llr,apmask,max_iterations,decoded,niterations,cw) -! if(niterations.ge.0) nhard=NN*iters-nhard -! endif - if(niterations.ge.0) call chkcrc10(decoded,nbadcrc) - if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0 .or. & - nbadcrc.ne.0) nfe2=nfe2+1 - enddo - - if(ndiff.eq.0) nhard=nhardc - fsigma=sqrt(sqf/iters) - ber=float(nhard)/(NN*iters) - fer=float(nfe2)/iters - write(*,1050) snrdb,nhard,ber,fer,fsigma - write(14,1050) snrdb,nhard,ber,fer,fsigma -1050 format(f6.1,i5,f8.4,f7.3,f8.2) - enddo - -999 end program dbpsksim diff --git a/lib/fsk4hf/dopspread.f90 b/lib/fsk4hf/dopspread.f90 deleted file mode 100644 index cadfbecc..00000000 --- a/lib/fsk4hf/dopspread.f90 +++ /dev/null @@ -1,62 +0,0 @@ -subroutine dopspread(c,fspread)
-
- parameter (NFFT=268800,NH=NFFT/2)
- complex c(0:NFFT-1)
- complex cspread(0:NFFT-1)
-
- df=12000.0/nfft
- twopi=8*atan(1.0)
- cspread(0)=1.0
- cspread(NH)=0.
- b=6.0 !Lorenzian 3/28 onward
- do i=1,NH
- f=i*df
- x=b*f/fspread
- z=0.
- a=0.
- if(x.lt.3.0) then !Cutoff beyond x=3
- a=sqrt(1.111/(1.0+x*x)-0.1) !Lorentzian
- call random_number(r1)
- phi1=twopi*r1
- z=a*cmplx(cos(phi1),sin(phi1))
- endif
- cspread(i)=z
- z=0.
- if(x.lt.50.0) then
- call random_number(r2)
- phi2=twopi*r2
- z=a*cmplx(cos(phi2),sin(phi2))
- endif
- cspread(NFFT-i)=z
- enddo
-
- izh=fspread/df
- do i=-izh,izh
- f=i*df
- j=i
- if(j.lt.0) j=j+nfft
- s=real(cspread(j))**2 + aimag(cspread(j))**2
-! write(23,3000) f,s,cspread(j)
-!3000 format(f10.3,3f12.6)
- enddo
-
- call four2a(cspread,NFFT,1,1,1) !Transform to time domain
-
- sum=0.
- do i=0,NFFT-1
- p=real(cspread(i))**2 + aimag(cspread(i))**2
- sum=sum+p
- enddo
- avep=sum/NFFT
- fac=sqrt(1.0/avep)
- cspread=fac*cspread !Normalize to constant avg power
- c=cspread*c !Apply Rayleigh fading to c()
-
- do i=0,NFFT-1
- p=real(cspread(i))**2 + aimag(cspread(i))**2
-! write(24,3010) i,p,cspread(i)
-!3010 format(i8,3f12.6)
- enddo
-
- return
-end subroutine dopspread
diff --git a/lib/fsk4hf/encode120.f90 b/lib/fsk4hf/encode120.f90 deleted file mode 100644 index 577bbe86..00000000 --- a/lib/fsk4hf/encode120.f90 +++ /dev/null @@ -1,116 +0,0 @@ -subroutine encode120(message,codeword) -! Encode an 60-bit message and return a 120-bit codeword. -! The generator matrix has dimensions (60,60). -! The code is a (120,60) regular ldpc code with column weight 3. -! The code was generated using the PEG algorithm. -! After creating the codeword, the columns are re-ordered according to -! "colorder" to make the codeword compatible with the parity-check matrix -! -character*15 g(60) -integer*1 codeword(120) -integer colorder(120) -integer*1 gen(60,60) -integer*1 itmp(120) -integer*1 message(60) -integer*1 pchecks(60) -logical first -data first/.true./ -data g/ & - "65541ad98feab6e",& - "27249940a5895a3",& - "c80eac7506bf794",& - "aa50393e3e18d3f",& - "28527e87d47dced",& - "5da0dcaf8db048c",& - "d6509a43ca9b01a",& - "9a7dadd9c94f1d4",& - "bb673d3ba07cf29",& - "65e190f2fbed447",& - "bc2062a4e520969",& - "9e357f3feed059b",& - "aa6b59212036a57",& - "f78a326722d6565",& - "416754bc34c6405",& - "f77000b3f04ff67",& - "d48fbd7d48c5ab9",& - "031ffb5db3a70cb",& - "125964e358c4df5",& - "bd02c32a5a241ea",& - "4c15ecdd8561abd",& - "7f0f1b352c7413e",& - "26edb94dfd0ae79",& - "ca1ba1ee0f8fb24",& - "49878a58cb4544c",& - "3dbcd0ff821b203",& - "c1f4440160d5345",& - "b5ea9dc7a5a70ab",& - "cebcf7d94976be4",& - "0968265f5977c88",& - "c5a36937faa78c3",& - "f0d4fef11e01c10",& - "e35fc0c779bebfe",& - "cf49c3eb41a31d5",& - "3f0b19352c7013e",& - "0e15eccd8521abd",& - "dda8dcaf9d3048c",& - "fee31438fba59ed",& - "ad74a27e939189c",& - "736ac01b439106e",& - "ab5d2729b29bfa1",& - "edf11fb02e5a426",& - "5f38be1c93ecc83",& - "1e4b3b8dc516b3e",& - "84443d8bee614c6",& - "d854d9f355ceac4",& - "a476b5ece51f0ea",& - "831c2b36c4c2f68",& - "f485c97a91615ae",& - "e9376d828ade9ba",& - "cac586f089d3185",& - "b8f8c67613dafe2",& - "1a3142b401b315d",& - "87dbedc43265d2e",& - "bb64ec6e652e7da",& - "e71bfd4c95dfd38",& - "31209af07ad4f75",& - "cff1a8ccc5f4978",& - "742eded1e1dfefd",& - "1cd7154a904dac4"/ - -data colorder/ & - 0,1,2,21,3,4,5,6,7,8,20,10,9,11,12,23,13,28,14,31, & - 15,16,22,26,17,30,18,29,25,32,41,34,19,33,27,36,38,43,42,24, & - 37,39,45,40,35,44,47,46,50,51,53,48,52,56,54,57,55,49,58,61, & - 60,59,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79, & - 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99, & - 100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119/ - -save first,gen - -if( first ) then ! fill the generator matrix - gen=0 - do i=1,60 - do j=1,15 - read(g(i)(j:j),"(Z1)") istr - do jj=1, 4 - icol=(j-1)*4+jj - if( btest(istr,4-jj) ) gen(i,icol)=1 - enddo - enddo - enddo -first=.false. -endif - -do i=1, 60 - nsum=0 - do j=1, 60 - nsum=nsum+message(j)*gen(i,j) - enddo - pchecks(i)=mod(nsum,2) -enddo -itmp(1:60)=pchecks -itmp(61:120)=message(1:60) -codeword(colorder+1)=itmp(1:120) - -return -end subroutine encode120 diff --git a/lib/fsk4hf/encode168.f90 b/lib/fsk4hf/encode168.f90 deleted file mode 100644 index bf121215..00000000 --- a/lib/fsk4hf/encode168.f90 +++ /dev/null @@ -1,141 +0,0 @@ -subroutine encode168(message,codeword) -! Encode an 84-bit message and return a 168-bit codeword. -! The generator matrix has dimensions (84,84). -! The code is a (168,84) regular ldpc code with column weight 3. -! The code was generated using the PEG algorithm. -! After creating the codeword, the columns are re-ordered according to -! "colorder" to make the codeword compatible with the parity-check matrix -! -character*21 g(84) -integer*1 codeword(168) -integer colorder(168) -integer*1 gen(84,168) -integer*1 itmp(168) -integer*1 message(84) -integer*1 pchecks(84) -logical first -data first/.true./ -data g/ & !parity generator matrix for (168,84) code - "25c5bf31ef6710fde9a5a", & - "18038ef7899cd97a77d96", & - "270dde504dad076c02b1f", & - "ed37fe12616565bd7d500", & - "12b99aa49b5367aff3838", & - "41cc27f2fac8b228aac21", & - "2265b233a3cff0b9cee24", & - "292760cd4f7f4a526a2f1", & - "2b3db4c8bd831911680cc", & - "cef2b24ce203bdc60b266", & - "5045a24f9340915d807ab", & - "3592b7fc60ba85139502e", & - "9318023145637bd798f0e", & - "ad796023c3d58d1e6509c", & - "3da5eab57f040e75d7413", & - "27466d1d2734d0ff64830", & - "2ed50bb1ce313bbfb1ab0", & - "9a616bda01b25b7e6eeaf", & - "a84c8c1e9df103169d10d", & - "a40da29b4aca9234a8942", & - "dd258d02d79a5f209d3d0", & - "bdfdc06713511997b5621", & - "25c58f12f4096cd8ead1a", & - "b2638a478f21e10fe97de", & - "4051020f43c605d458156", & - "f651aad14322a526dae35", & - "a1c147e31bcc9d87330bf", & - "7524b53d996d48284647b", & - "a72e7d25ce31b27282e56", & - "a97f53b019022350b7519", & - "56106c6340c0810790984", & - "c63b8e03a57208635992b", & - "43a3de2aa3a2b1afb65dc", & - "9baa64847ead03b77fecc", & - "251cbd1895c8839c46b0d", & - "2858107dde2d173e13530", & - "20096f6a870f636b704e7", & - "7f833ccbceec52dd6eb79", & - "a9108dd77b8015b75242a", & - "689666a79e5579c916236", & - "aa5dff46459787f69911f", & - "794558c13138d08171089", & - "c937042857b291cee8dfd", & - "6f0bf3248bb9a231366b8", & - "1c09e756ef1656c96f2d2", & - "073b875b6774e71fba549", & - "f7d840aafc037febd2d5c", & - "dcc0e7d0da5fe17c99ad3", & - "98238ef7819cd97a77d94", & - "177c2594743477421a262", & - "7d01a833c19374fbaaa6e", & - "7bb800216660482ffd1c4", & - "39a92e2dba0d4cfda98d2", & - "44b8d88622698816456a8", & - "791db2334d6d86639229b", & - "ba6004b086bd38559ea48", & - "f94558e13138d18170089", & - "08ba145302cfbed7845ae", & - "fb8e64b6da3602168ed38", & - "1045a2cf1340915d8072b", & - "7592b6fc64ba85139582e", & - "3eb238a11bc6654452bae", & - "b69d8d23b1ea170f70214", & - "0123dfae84fb20462a614", & - "4131066ad52a339b3c0d7", & - "fd2cc26850951c43ed737", & - "a644d4eb7e56c40f0d050", & - "0c3bd9d5dab7c9ee2c8fc", & - "4a198b37af56d7ceffb56", & - "b6e946c429294cf0eed8b", & - "98384d75e758774f5ff3b", & - "5c58e5d9a4d0531d37384", & - "7a0af02719afed521fd06", & - "8cd5b2e694e7854abbc70", & - "1a2f061912d0ea19702d3", & - "6ffbce557d8fa691a50e8", & - "d43438e2e2ed5d9f14011", & - "8d502106083b809adba00", & - "67e22f9b9983aa715964d", & - "b31f3a3f3c1f406b1fd58", & - "529f60ac291f827d97331", & - "476a815424f2e2cbe641f", & - "81c82c89bcc3feec42458", & - "2c882d0e281b178e80364"/ - -data colorder/0,1,2,3,28,4,5,6,7,8,9,10,11,34,12,32,13,14,15,16,17, & - 18,36,29,42,31,20,21,41,40,30,38,22,19,47,37,46,35,44,33,49,24, & - 43,51,25,26,27,50,52,57,69,54,55,45,59,58,56,61,60,53,48,23,62, & - 63,64,67,66,65,68,39,70,71,72,74,73,75,76,77,80,81,78,82,79,83, & - 84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104, & - 105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, & - 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146, & - 147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167/ - -save first,gen - -if( first ) then ! fill the generator matrix - gen=0 - do i=1,84 - do j=1,21 - read(g(i)(j:j),"(Z1)") istr - do jj=1, 4 - icol=(j-1)*4+jj - if( btest(istr,4-jj) ) gen(i,icol)=1 - enddo - enddo - enddo -first=.false. -endif - -do i=1, 84 - nsum=0 - do j=1, 84 - nsum=nsum+message(j)*gen(i,j) - enddo - pchecks(i)=mod(nsum,2) -enddo -itmp(1:84)=pchecks -itmp(85:168)=message(1:84) -codeword(colorder+1)=itmp(1:168) - -return -end subroutine encode168 diff --git a/lib/fsk4hf/encode204.f90 b/lib/fsk4hf/encode204.f90 deleted file mode 100644 index b824196a..00000000 --- a/lib/fsk4hf/encode204.f90 +++ /dev/null @@ -1,48 +0,0 @@ -subroutine encode204(message,codeword) -! Encode an 68-bit message and return a 204-bit codeword. -! The generator matrix has dimensions (136,68). -! The code is a (204,68) regular ldpc code with column weight 3. -! The code was generated using the PEG algorithm. -! After creating the codeword, the columns are re-ordered according to -! "colorder" to make the codeword compatible with the parity-check matrix -! - -include "ldpc_204_68_params.f90" - -integer*1 codeword(N) -integer*1 gen(M,K) -integer*1 itmp(N) -integer*1 message(K) -integer*1 pchecks(M) -logical first -data first/.true./ - -save first,gen - -if( first ) then ! fill the generator matrix - gen=0 - do i=1,M - do j=1,17 - read(g(i)(j:j),"(Z1)") istr - do jj=1, 4 - icol=(j-1)*4+jj - if( btest(istr,4-jj) ) gen(i,icol)=1 - enddo - enddo - enddo -first=.false. -endif - -do i=1,M - nsum=0 - do j=1,K - nsum=nsum+message(j)*gen(i,j) - enddo - pchecks(i)=mod(nsum,2) -enddo -itmp(1:M)=pchecks -itmp(M+1:N)=message(1:K) -codeword(colorder+1)=itmp(1:N) - -return -end subroutine encode204 diff --git a/lib/fsk4hf/encode300.f90 b/lib/fsk4hf/encode300.f90 deleted file mode 100644 index f1d3bbae..00000000 --- a/lib/fsk4hf/encode300.f90 +++ /dev/null @@ -1,308 +0,0 @@ -subroutine encode300(message,codeword) -! Encode an 60-bit message and return a 300-bit codeword. -! The generator matrix has dimensions (240,60). -! The code is a (300,60) irregular ldpc code with column weights: -! 52% column weight 2 -! 27% column weight 3 -! 21% column weight 7 -! The code was generated using the PEG algorithm. -! After creating the codeword, the columns are re-ordered according to -! "colorder" to make the codeword compatible with the parity-check matrix -! -character*15 g(240) -integer*1 codeword(300) -integer colorder(300) -integer*1 gen(240,60) -integer*1 itmp(300) -integer*1 message(60) -integer*1 pchecks(240) -logical first -data first/.true./ -data g/ & - "316fd3bb18bcefd", & - "a9c1c984f91244e", & - "9e04bd3d5d78d89", & - "f81617089621bd4", & - "12997ce2f44dbf4", & - "3ebddaf9b0fa1fc", & - "d0c114b0b0ef162", & - "f8c4f115f98bd92", & - "d0a79c0c5b8ca19", & - "477f6712f357b3b", & - "fa28b2444a7e66b", & - "bedcd4df8d95c64", & - "da30de73e57022c", & - "bc099bbb90fe09e", & - "cffc1e47e5708e8", & - "713d808563ca9a3", & - "70fcf1741d5d5d7", & - "32e80bc15112008", & - "804cef4df9b18ec", & - "3736881819d1033", & - "f4e37db7f9c5efe", & - "9e84b93d4d78d09", & - "2250c3518ec830a", & - "55a529a92e18021", & - "1cb80b14c9f6eae", & - "80c504b031ef926", & - "ece6636d0ac9c6d", & - "5d50a1690782cd0", & - "3d54a1fb30937a2", & - "ba8fe8006318041", & - "02917ce2fc45bf4", & - "abc1d984f95a44e", & - "fc05b4c4ab2d850", & - "467f7718f357b3b", & - "472cc094546c6b2", & - "fcdd94cf8c9cc64", & - "4dbc1647e970cc8", & - "6caa465c442aed1", & - "aead5af8b0da1be", & - "d8e1fa45a2e8431", & - "9d4dc4cc63abb7f", & - "9b2df6b48264637", & - "7335808563ca3a3", & - "36bf8d5cd93e6cc", & - "004ccf4db9b08ec", & - "90a71c8c598ca19", & - "f8c5d115f90bc92", & - "b95546c4e3f7934", & - "7d50a1690786cd0", & - "c90939921a0d7c6", & - "d0c504b030ef126", & - "ce3e6f9396fc542", & - "a0072a59f3707f5", & - "532d0a8fe3da1ea", & - "68b9e5cd7d142db", & - "fedc94df8c9dc64", & - "6da2465c448aed0", & - "3574aa19cb273c0", & - "1e54768c6bc6843", & - "691f65654498186", & - "fe2c92444a6ef6b", & - "9caad933e038cc4", & - "ad4e6f4defb28ec", & - "4f3d80947c6d2b2", & - "1caad933e0b8cc4", & - "b14fd3bf18bcafd", & - "ad091bbbb0f809e", & - "90b71c8c598da19", & - "f8c4d115f90bd92", & - "9d4dcccc63afb7f", & - "fa2c92444a6e76b", & - "1e14768c6bc6c43", & - "d1baf5aacb86087", & - "bdf762b92ee51c7", & - "caacec06ad8a90c", & - "804ccf4df9b08ec", & - "69e969f9da5cbd8", & - "814ccf4df9b086c", & - "cebe4f9796f4542", & - "491f65654499186", & - "8fbf5b9796f6d2a", & - "ce3e4f9396f4542", & - "47558560e7debc3", & - "94aadd33e038cc4", & - "a94eef4debb286e", & - "d8e5d115f91bcd2", & - "532d488fe3da0ab", & - "664e7bc4e23a80c", & - "94a2dd33a038cd4", & - "d8c5d115f91bc92", & - "0fef071eee60bd5", & - "9a89a09163c2b97", & - "0eaf071e6c60bd5", & - "bc0d1bbbb0fe0be", & - "f9babd3d12d0f31", & - "69a969f9da5c9d8", & - "6e4e7bc4e23a82c", & - "b0042659f3227f5", & - "2d51418f0f28347", & - "be0d5bbbb0da0be", & - "225003508ec8302", & - "8fbf4b9796f4d2a", & - "bead5af9b0da1be", & - "6ca2465c440aed1", & - "4fbc1e47ed708c8", & - "bd091bbbb0fc09e", & - "b0062259f3307f5", & - "a8072a59f3727f5", & - "a0062259f3707f5", & - "3c380b14c974eae", & - "30042659f3226f5", & - "48b9e4cd7d142db", & - "728bcd4b38308fb", & - "c0c504b031ef126", & - "314fd3bb18bcafd", & - "1c29148305faec1", & - "44c92a9c28ada63", & - "88e99b370aae32b", & - "695081690386ad8", & - "572d0a8de3da1ea", & - "467f6610f357b2b", & - "733d008563da1a3", & - "d1baf4aacb84087", & - "4315551d71c8ff0", & - "48bde4cd7d140db", & - "3ebd58f9b0da9fc", & - "51baf4aacb84083", & - "814e4f4de9b082c", & - "814ecf4de9b086c", & - "be0d1bbbb0fa0be", & - "4f7580947c792b3", & - "cdf2dce48c39c3b", & - "d8c5c115f91bc12", & - "a94e6f4debb28ee", & - "be2d5afbb0da1be", & - "cdd6dce48439c2b", & - "bebd5af9b0da1fe", & - "fa2892444a6e66b", & - "51bbf4aacb8c083", & - "baa73d81eebcd83", & - "79a2ce47f138cc9", & - "cc28cf198e6dbd4", & - "fcde94dfcc9cc64", & - "1016fcf59286717", & - "12917ce2fc4dbf4", & - "4fbc1647e9708c8", & - "3e382b1cc974fae", & - "d5bafdaad386087", & - "0fef473eee60bd5", & - "c0e504b031ee126", & - "8bbf5b9797f6d2a", & - "0eef071e6e60bd5", & - "1806fcf59386517", & - "fcdc94df8c9cc64", & - "141eca2bfa25656", & - "5fbc1767e9708e8", & - "5aa4c7803a6bdf1", & - "b14bd3b718bcafd", & - "3ebd5af9b0da1fc", & - "d0a7148c5b8ca09", & - "a94ecf4debb086e", & - "733d808563ca1a3", & - "fd9abd1d92d0f31", & - "bc091bbbb0fe09e", & - "d0c514b0b0ef122", & - "4f7d80947c7d2b3", & - "8b3f5b97b7f6d2a", & - "4fbc1767e9708c8", & - "cebf4f9796f4502", & - "9c76c880a864e67", & - "abc1c984f95244e", & - "795081690786ad8", & - "467f6710f357b3b", & - "1c380b14c9f4eae", & - "d5baf5aac386087", & - "bedc94df8c95c64", & - "553d0a8de2da1fa", & - "0315551d71d8ff0", & - "1c1eca2ffa25656", & - "d4bafdaad3c6087", & - "be2d5bfbb0da0be", & - "b0062659f3207f5", & - "5ffc1765e9708e8", & - "8d62e8bcd303e33", & - "cc08cf198e69bd4", & - "573d0a8de3da1fa", & - "cd56dce48639c2b", & - "472dc094546c2b2", & - "7950a16907868d8", & - "7283cf4b38308fb", & - "894ecf4de9b086e", & - "0f7580b47c792b3", & - "cfbf4b9796f4d0a", & - "3e380b14c974fae", & - "732d0085e3da1a3", & - "1816fcf59386717", & - "532d088fe3da1ab", & - "1c300b94c9fcaae", & - "d0a71c8c5b8ca19", & - "9e84bd3d5d78d09", & - "225083508ec830a", & - "f99abd1d12d0f31", & - "35f4aa19cb673c0", & - "cdd2dce48c39c2b", & - "0f7780b47c792bf", & - "0e33a5f114f5730", & - "bc05b4c4ab0d850", & - "1c300b14c9f4aae", & - "cfbc1e47ed708e8", & - "0f7180b47c392b3", & - "d8c7c115f91be12", & - "c09148adfa94e97", & - "9c66c880a844e67", & - "2226c13b73519f8", & - "cebf4b9796f4d02", & - "c0e706b031ee126", & - "6a6629715e53ce3", & - "73f9aa824e7d0b8", & - "473d80947c6c2b2", & - "1df140e0ddb5632", & - "473dc0945c6c2b2", & - "81b4d95f671971d", & - "663945ca758e2b6", & - "02ec3d98a2306fd", & - "5dadb0fa1275690", & - "4bb8aaa854948d0", & - "8359ba40886971c", & - "49cc3d2a2be2ee0", & - "bfdf13af137f318", & - "a1de773a2b1ff04", & - "8ff3945a2f465c7", & - "532d0087e3da1a3", & - "f3eaf7fa454d385", & - "a606aa5aeba07d9", & - "67f0627b0af8a53", & - "56698bed69d1c2c", & - "d5f420011fbf924", & - "2a8f86c810e2c62", & - "43cc1cf1208c206", & - "ee784c4900258de"/ - -data colorder/ & -0,1,2,3,4,5,6,7,8,9,10,11,123,12,13,14,15,16,17,18, & -19,20,21,22,23,24,25,138,26,145,27,28,29,30,31,32,33,34,35,36, & -37,154,38,39,40,41,42,43,44,144,46,47,48,49,50,51,52,53,143,54, & -125,56,57,58,124,59,120,140,157,160,55,60,61,62,156,162,141,64,65,153, & -181,183,66,170,67,68,69,130,70,164,71,72,73,74,75,63,76,77,135,78, & -79,80,176,169,82,83,84,167,180,85,136,158,129,166,175,142,134,146,121,165, & -88,89,192,90,45,91,92,93,182,189,94,95,96,173,81,97,98,178,122,126, & -132,99,100,152,186,193,101,102,151,103,104,172,159,168,150,190,147,148,201,107, & -205,177,108,198,197,174,127,109,185,110,202,87,199,171,179,187,139,137,106,131, & -206,194,112,149,155,113,128,184,196,86,114,203,212,195,208,105,188,161,163,191, & -200,209,214,204,115,218,133,111,207,117,213,216,211,217,116,215,219,220,210,221, & -118,222,223,225,224,228,226,229,231,227,233,119,234,235,232,230,237,239,236,238, & -240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259, & -260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, & -280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299/ - -save first,gen - -if( first ) then ! fill the generator matrix - gen=0 - do i=1,240 - do j=1,15 - read(g(i)(j:j),"(Z1)") istr - do jj=1, 4 - icol=(j-1)*4+jj - if( btest(istr,4-jj) ) gen(i,icol)=1 - enddo - enddo - enddo -first=.false. -endif - -do i=1, 240 - nsum=0 - do j=1, 60 - nsum=nsum+message(j)*gen(i,j) - enddo - pchecks(i)=mod(nsum,2) -enddo -itmp(1:240)=pchecks -itmp(241:300)=message(1:60) -codeword(colorder+1)=itmp(1:300) - -return -end subroutine encode300 diff --git a/lib/fsk4hf/extractmessage168.f90 b/lib/fsk4hf/extractmessage168.f90 deleted file mode 100644 index 466d2a63..00000000 --- a/lib/fsk4hf/extractmessage168.f90 +++ /dev/null @@ -1,48 +0,0 @@ -subroutine extractmessage168(decoded,msgreceived,ncrcflag,recent_calls,nrecent) - use iso_c_binding, only: c_loc,c_size_t - use crc - use packjt - - character*22 msgreceived - character*12 call1,call2 - character*12 recent_calls(nrecent) - integer*1 decoded(84) - integer*1, target:: i1Dec8BitBytes(11) - integer*4 i4Dec6BitWords(12) - -! Collapse 84 decoded bits to 11 bytes. Bytes 1-9 are the message, byte 10 and first half of byte 11 is the crc - do ibyte=1,9 - itmp=0 - do ibit=1,8 - itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit)) - enddo - i1Dec8BitBytes(ibyte)=itmp - enddo -! Need to pack the crc into bytes 10 and 11 for crc12_check - i1Dec8BitBytes(10)=decoded(73)*8+decoded(74)*4+decoded(75)*2+decoded(76) - i1Dec8BitBytes(11)=decoded(77)*128+decoded(78)*64+decoded(79)*2*32+decoded(80)*16 - i1Dec8BitBytes(11)=i1Dec8BitBytes(11)+decoded(81)*8+decoded(82)*4+decoded(83)*2+decoded(84) - - if( crc12_check(c_loc (i1Dec8BitBytes), 11) ) then -! CRC12 checks out --- unpack 72-bit message - do ibyte=1,12 - itmp=0 - do ibit=1,6 - itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*6+ibit)) - enddo - i4Dec6BitWords(ibyte)=itmp - enddo - call unpackmsg144(i4Dec6BitWords,msgreceived,call1,call2) - ncrcflag=1 - if( call1(1:2) .ne. 'CQ' .and. call1(1:2) .ne. ' ' ) then - call update_recent_calls(call1,recent_calls,nrecent) - endif - if( call2(1:2) .ne. ' ' ) then - call update_recent_calls(call2,recent_calls,nrecent) - endif - else - msgreceived=' ' - ncrcflag=-1 - endif - return - end subroutine extractmessage168 diff --git a/lib/fsk4hf/fftw3.f90 b/lib/fsk4hf/fftw3.f90 deleted file mode 100644 index 440ccc28..00000000 --- a/lib/fsk4hf/fftw3.f90 +++ /dev/null @@ -1,64 +0,0 @@ - INTEGER FFTW_R2HC - PARAMETER (FFTW_R2HC=0) - INTEGER FFTW_HC2R - PARAMETER (FFTW_HC2R=1) - INTEGER FFTW_DHT - PARAMETER (FFTW_DHT=2) - INTEGER FFTW_REDFT00 - PARAMETER (FFTW_REDFT00=3) - INTEGER FFTW_REDFT01 - PARAMETER (FFTW_REDFT01=4) - INTEGER FFTW_REDFT10 - PARAMETER (FFTW_REDFT10=5) - INTEGER FFTW_REDFT11 - PARAMETER (FFTW_REDFT11=6) - INTEGER FFTW_RODFT00 - PARAMETER (FFTW_RODFT00=7) - INTEGER FFTW_RODFT01 - PARAMETER (FFTW_RODFT01=8) - INTEGER FFTW_RODFT10 - PARAMETER (FFTW_RODFT10=9) - INTEGER FFTW_RODFT11 - PARAMETER (FFTW_RODFT11=10) - INTEGER FFTW_FORWARD - PARAMETER (FFTW_FORWARD=-1) - INTEGER FFTW_BACKWARD - PARAMETER (FFTW_BACKWARD=+1) - INTEGER FFTW_MEASURE - PARAMETER (FFTW_MEASURE=0) - INTEGER FFTW_DESTROY_INPUT - PARAMETER (FFTW_DESTROY_INPUT=1) - INTEGER FFTW_UNALIGNED - PARAMETER (FFTW_UNALIGNED=2) - INTEGER FFTW_CONSERVE_MEMORY - PARAMETER (FFTW_CONSERVE_MEMORY=4) - INTEGER FFTW_EXHAUSTIVE - PARAMETER (FFTW_EXHAUSTIVE=8) - INTEGER FFTW_PRESERVE_INPUT - PARAMETER (FFTW_PRESERVE_INPUT=16) - INTEGER FFTW_PATIENT - PARAMETER (FFTW_PATIENT=32) - INTEGER FFTW_ESTIMATE - PARAMETER (FFTW_ESTIMATE=64) - INTEGER FFTW_ESTIMATE_PATIENT - PARAMETER (FFTW_ESTIMATE_PATIENT=128) - INTEGER FFTW_BELIEVE_PCOST - PARAMETER (FFTW_BELIEVE_PCOST=256) - INTEGER FFTW_DFT_R2HC_ICKY - PARAMETER (FFTW_DFT_R2HC_ICKY=512) - INTEGER FFTW_NONTHREADED_ICKY - PARAMETER (FFTW_NONTHREADED_ICKY=1024) - INTEGER FFTW_NO_BUFFERING - PARAMETER (FFTW_NO_BUFFERING=2048) - INTEGER FFTW_NO_INDIRECT_OP - PARAMETER (FFTW_NO_INDIRECT_OP=4096) - INTEGER FFTW_ALLOW_LARGE_GENERIC - PARAMETER (FFTW_ALLOW_LARGE_GENERIC=8192) - INTEGER FFTW_NO_RANK_SPLITS - PARAMETER (FFTW_NO_RANK_SPLITS=16384) - INTEGER FFTW_NO_VRANK_SPLITS - PARAMETER (FFTW_NO_VRANK_SPLITS=32768) - INTEGER FFTW_NO_VRECURSE - PARAMETER (FFTW_NO_VRECURSE=65536) - INTEGER FFTW_NO_SIMD - PARAMETER (FFTW_NO_SIMD=131072) diff --git a/lib/fsk4hf/four2a.f90 b/lib/fsk4hf/four2a.f90 deleted file mode 100644 index 57c7239e..00000000 --- a/lib/fsk4hf/four2a.f90 +++ /dev/null @@ -1,115 +0,0 @@ -subroutine four2a(a,nfft,ndim,isign,iform) - -! IFORM = 1, 0 or -1, as data is -! complex, real, or the first half of a complex array. Transform -! values are returned in array DATA. They are complex, real, or -! the first half of a complex array, as IFORM = 1, -1 or 0. - -! The transform of a real array (IFORM = 0) dimensioned N(1) by N(2) -! by ... will be returned in the same array, now considered to -! be complex of dimensions N(1)/2+1 by N(2) by .... Note that if -! IFORM = 0 or -1, N(1) must be even, and enough room must be -! reserved. The missing values may be obtained by complex conjugation. - -! The reverse transformation of a half complex array dimensioned -! N(1)/2+1 by N(2) by ..., is accomplished by setting IFORM -! to -1. In the N array, N(1) must be the true N(1), not N(1)/2+1. -! The transform will be real and returned to the input array. - -! This version of four2a makes calls to the FFTW library to do the -! actual computations. - - parameter (NPMAX=2100) !Max numberf of stored plans - parameter (NSMALL=16384) !Max size of "small" FFTs - complex a(nfft) !Array to be transformed - complex aa(NSMALL) !Local copy of "small" a() - integer nn(NPMAX),ns(NPMAX),nf(NPMAX) !Params of stored plans - integer*8 nl(NPMAX),nloc !More params of plans - integer*8 plan(NPMAX) !Pointers to stored plans - logical found_plan - data nplan/0/ !Number of stored plans - common/patience/npatience,nthreads !Patience and threads for FFTW plans - include 'fftw3.f90' !FFTW definitions - save plan,nplan,nn,ns,nf,nl - - if(nfft.lt.0) go to 999 - - nloc=loc(a) - - found_plan = .false. - !$omp critical(four2a_setup) - do i=1,nplan - if(nfft.eq.nn(i) .and. isign.eq.ns(i) .and. & - iform.eq.nf(i) .and. nloc.eq.nl(i)) then - found_plan = .true. - exit - end if - enddo - - if(i.ge.NPMAX) stop 'Too many FFTW plans requested.' - - if (.not. found_plan) then - nplan=nplan+1 - i=nplan - - nn(i)=nfft - ns(i)=isign - nf(i)=iform - nl(i)=nloc - -! Planning: FFTW_ESTIMATE, FFTW_ESTIMATE_PATIENT, FFTW_MEASURE, -! FFTW_PATIENT, FFTW_EXHAUSTIVE - nflags=FFTW_ESTIMATE - if(npatience.eq.1) nflags=FFTW_ESTIMATE_PATIENT - if(npatience.eq.2) nflags=FFTW_MEASURE - if(npatience.eq.3) nflags=FFTW_PATIENT - if(npatience.eq.4) nflags=FFTW_EXHAUSTIVE - - if(nfft.le.NSMALL) then - jz=nfft - if(iform.eq.0) jz=nfft/2 - aa(1:jz)=a(1:jz) - endif - - !$omp critical(fftw) ! serialize non thread-safe FFTW3 calls - if(isign.eq.-1 .and. iform.eq.1) then - call sfftw_plan_dft_1d(plan(i),nfft,a,a,FFTW_FORWARD,nflags) - else if(isign.eq.1 .and. iform.eq.1) then - call sfftw_plan_dft_1d(plan(i),nfft,a,a,FFTW_BACKWARD,nflags) - else if(isign.eq.-1 .and. iform.eq.0) then - call sfftw_plan_dft_r2c_1d(plan(i),nfft,a,a,nflags) - else if(isign.eq.1 .and. iform.eq.-1) then - call sfftw_plan_dft_c2r_1d(plan(i),nfft,a,a,nflags) - else - stop 'Unsupported request in four2a' - endif - !$omp end critical(fftw) - - if(nfft.le.NSMALL) then - jz=nfft - if(iform.eq.0) jz=nfft/2 - a(1:jz)=aa(1:jz) - endif - end if - !$omp end critical(four2a_setup) - - call sfftw_execute(plan(i)) - return - -999 continue - - !$omp critical(four2a) - do i=1,nplan -! The test is only to silence a compiler warning: - if(ndim.ne.-999) then - !$omp critical(fftw) ! serialize non thread-safe FFTW3 calls - call sfftw_destroy_plan(plan(i)) - !$omp end critical(fftw) - end if - enddo - - nplan=0 - !$omp end critical(four2a) - - return -end subroutine four2a diff --git a/lib/fsk4hf/fsk4hf.f90 b/lib/fsk4hf/fsk4hf.f90 deleted file mode 100644 index 191e05c3..00000000 --- a/lib/fsk4hf/fsk4hf.f90 +++ /dev/null @@ -1,145 +0,0 @@ -program fsk4hf - -! Simulate characteristics of a potential mode using LDPC (168,84) code, -! 4-FSK modulation, and 30 s T/R sequences. - - parameter (KK=84) !Information bits (72 + CRC12) - parameter (ND=84) !Data symbols: LDPC (168,84), r=1/2 - parameter (NS=12) !Sync symbols (3 @ 4x4 Costas arrays) - parameter (NR=2) !Ramp up/down - parameter (NN=NR+NS+ND) !Total symbols (98) - parameter (NSPS=2688/84) !Samples per symbol (32) - parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760) - - character*8 arg - complex c0(0:NZ-1) !Complex waveform - complex c(0:NZ-1) !Complex waveform - real xnoise(0:NZ-1) !Generated random noise - real ynoise(0:NZ-1) !Generated random noise - real rxdata(2*ND),llr(2*ND) !Soft symbols - real s(0:NSPS,NN) - real savg(0:NSPS) - real ps(0:3) - integer id(ND) !Symbol values (0-3), data only - integer id1(ND) !Recovered data values - integer*1 msgbits(KK),decoded(KK),apmask(ND),cw(ND) - data msgbits/0,0,1,0,0,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,1, & - 1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,1,1,0,1,0,1,1,1,0,1,1,0,1,1, & - 1,1,0,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,1,0/ - - nargs=iargc() - if(nargs.ne.5) then - print*,'Usage: fsk4hf f0(Hz) delay(ms) fspread(Hz) iters snr(dB)' - print*,'Example: fsk4hf 20 0 0 10 -20' - print*,'Set snr=0 to cycle through a range' - go to 999 - endif - call getarg(1,arg) - read(arg,*) f0 !Generated carrier frequency - call getarg(2,arg) - read(arg,*) delay !Delta_t (ms) for Watterson model - call getarg(3,arg) - read(arg,*) fspread !Fspread (Hz) for Watterson model - call getarg(4,arg) - read(arg,*) iters !Iterations at each SNR - call getarg(5,arg) - read(arg,*) snrdb !Specified SNR_2500 - - twopi=8.0*atan(1.0) - fs=12000.0/84.0 !Sample rate = 142.857... Hz - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - bandwidth_ratio=2500.0/(fs/2.0) - write(*,1000) f0,delay,fspread,iters,baud,4*baud,txt -1000 format('f0:',f5.1,' Delay:',f4.1,' fSpread:',f5.2, & - ' Iters:',i6/'Baud:',f7.3,' BW:',f5.1,' TxT:',f5.1,f5.2/) - write(*,1004) -1004 format(/' SNR sym bit ser ber fer fsigma'/50('-')) - - call genfsk4hf(msgbits,f0,id,c0) !Generate baseband waveform - isna=-10 - isnb=-30 - if(snrdb.ne.0.0) then - isna=nint(snrdb) - isnb=isna - endif - do isnr=isna,isnb,-1 !Loop over SNR range - snrdb=isnr - sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - nhard=0 - nbit=0 - nfe=0 - sqf=0. - do iter=1,iters !Loop over requested iterations - c=c0 - if(delay.ne.0.0 .or. fspread.ne.0.0) then - call watterson(c,NZ,fs,delay,fspread) - endif - c=sig*c !Scale to requested SNR - if(snrdb.lt.90) then - do i=0,NZ-1 !Generate gaussian noise - xnoise(i)=gran() - ynoise(i)=gran() - enddo - c=c + cmplx(xnoise,ynoise) !Add AWGN noise - endif - df=fs/(2*NSPS) - i0=nint(f0/df) - call spec4(c,s,savg) - do i=0,NSPS - write(12,3001) i*df,savg(i),db(savg(i)) -3001 format(3f15.3) - enddo - - do j=1,ND - nlo=0 - nhi=0 - k=j+5 - if(j.ge.43) k=j+9 - ps=s(i0:i0+6:2,k) - ps=sqrt(ps) !### - rlo=max(ps(1),ps(3))-max(ps(0),ps(2)) - rhi=max(ps(2),ps(3))-max(ps(0),ps(1)) - if(rlo.ge.0.0) nlo=1 - if(rhi.ge.0.0) nhi=1 - rxdata(2*j-1)=rhi - rxdata(2*j)=rlo - id1(j)=2*nhi+nlo - enddo -! write(*,1001) id(1:70) -! write(*,1001) id1(1:70) -!1001 format(70i1) - nhard=nhard+count(id.ne.id1) - nbit=nbit + count(iand(id,1).ne.iand(id1,1)) + & - count(iand(id,2).ne.iand(id1,2)) - - rxav=sum(rxdata)/ND - rx2av=sum(rxdata*rxdata)/ND - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - ss=0.84 - llr=2.0*rxdata/(ss*ss) - apmask=0 - max_iterations=40 - ifer=0 - call bpdecode168(llr,apmask,max_iterations,decoded,niterations,cw) - nbadcrc=0 - if(niterations.ge.0) call chkcrc12(decoded,nbadcrc) - if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0 .or. & - nbadcrc.ne.0) ifer=1 - nfe=nfe+ifer - enddo - - fsigma=sqrt(sqf/iters) - ser=float(nhard)/(ND*iters) - ber=float(nbit)/(2*ND*iters) - fer=float(nfe)/iters - write(*,1050) snrdb,nhard,nbit,ser,ber,fer,fsigma -! write(60,1050) snrdb,nhard,ber,fer,fsigma -1050 format(f6.1,2i6,2f8.4,f7.3,f8.2) - enddo - -999 end program fsk4hf diff --git a/lib/fsk4hf/fsk4sim.f90 b/lib/fsk4hf/fsk4sim.f90 deleted file mode 100644 index 9800616e..00000000 --- a/lib/fsk4hf/fsk4sim.f90 +++ /dev/null @@ -1,185 +0,0 @@ -program fsk4sim - - parameter (ND=60) !Data symbols: LDPC (120,60), r=1/2 - parameter (NN=ND) !Total symbols (60) - parameter (NSPS=57600) !Samples per symbol at 12000 sps - parameter (NZ=NSPS*NN) !Samples in waveform (3456000) - - character*8 arg - complex c(0:NZ-1) !Complex waveform - complex cr(0:NZ-1) - complex cs(NSPS,NN) - complex cps(0:3) - complex ct(0:2*NN-1) - complex z,w,zsum - real r(0:NZ-1) - real s(NSPS,NN) - real savg(NSPS) - real tmp(NN) !For generating random data - real xnoise(0:NZ-1) !Generated random noise - real ps(0:3) - integer id(NN) !Encoded 2-bit data (values 0-3) - integer id2(NN) !Recovered data - equivalence (r,cr) - - nnn=0 - nargs=iargc() - if(nargs.ne.6) then - print*,'Usage: fsk8sim f0 delay(ms) fspread(Hz) nts iters snr(dB)' - go to 999 - endif - call getarg(1,arg) - read(arg,*) f0 !Low tone frequency - call getarg(2,arg) - read(arg,*) delay - call getarg(3,arg) - read(arg,*) fspread - call getarg(4,arg) - read(arg,*) nts - call getarg(5,arg) - read(arg,*) iters - call getarg(6,arg) - read(arg,*) snrdb - - twopi=8.d0*atan(1.d0) - fs=12000.d0 - dt=1.0/fs - ts=NSPS*dt - baud=1.d0/ts - txt=NZ*dt - bandwidth_ratio=2500.0/6000.0 - write(*,1000) baud,5*baud,txt,delay,fspread,nts -1000 format('Baud:',f6.3,' BW:',f5.1,' TxT:',f5.1,' Delay:',f5.2, & - ' fSpread:',f5.2,' nts:',i3/) - - write(*,1004) -1004 format(' SNR Sym Bit SER BER Sym Bit SER BER'/59('-')) - - isna=-25 - isnb=-40 - if(snrdb.ne.0.0) then - isna=nint(snrdb) - isnb=isna - endif - do isnr=isna,isnb,-1 - snrdb=isnr - sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - nhard1=0 - nhard2=0 - nbit1=0 - nbit2=0 - nh2=0 - nb2=0 - do iter=1,iters - nnn=nnn+1 - id=0 - call random_number(tmp) - where(tmp.ge.0.25 .and. tmp.lt.0.50) id=1 - where(tmp.ge.0.50 .and. tmp.lt.0.75) id=2 - where(tmp.ge.0.75) id=3 - - call genfsk4(id,f0,nts,c) !Generate the 4-FSK waveform - call watterson(c,delay,fspread) - if(sig.ne.1.0) c=sig*c !Scale to requested SNR - if(snrdb.lt.90) then - do i=0,NZ-1 !Generate gaussian noise - xnoise(i)=gran() - enddo - endif - r(0:NZ-1)=real(c(0:NZ-1)) + xnoise !Add noise to signal - - call snr2_wsprlf(r,freq,snr2500,width,1) - write(*,3001) freq,snr2500,width -3001 format(40x,3f10.3) - - df=12000.0/(2*NSPS) -! i0=nint(f0/df) -! i0=nint((1500.0+freq)/df) - i0=nint((f0+freq)/df) - call spec4(r,cs,s,savg) - - do j=1,NN - nlo=0 - nhi=0 - ps=s(i0:i0+6*nts:2*nts,j) - cps=cs(i0:i0+6*nts:2*nts,j) - if(max(ps(1),ps(3)).ge.max(ps(0),ps(2))) nlo=1 - if(max(ps(2),ps(3)).ge.max(ps(0),ps(1))) nhi=1 - id2(j)=2*nhi+nlo - z=cps(id2(j)) - ct(j-1)=z - enddo - nh1=count(id.ne.id2) - nb1=count(iand(id,1).ne.iand(id2,1)) + count(iand(id,2).ne.iand(id2,2)) - - ct(NN:)=0. - call four2a(ct,2*NN,1,-1,1) - df2=baud/(2*NN) - ct=cshift(ct,NN) - ppmax=0. - dfpk=0. - do i=0,2*NN-1 - f=(i-NN)*df2 - pp=real(ct(i))**2 + aimag(ct(i))**2 - if(pp.gt.ppmax) then - ppmax=pp - dfpk=f - endif - enddo - - zsum=0. - do j=1,NN - phi=(j-1)*twopi*dfpk*ts - w=cmplx(cos(phi),sin(phi)) - cps=cs(i0:i0+6*nts:2*nts,j)*conjg(w) - z=cps(id2(j)) - ct(j)=z - zsum=zsum+z - write(12,1042) j,id(j),id2(j),20*ps,atan2(aimag(z),real(z)), & - atan2(aimag(zsum),real(zsum)),zsum -1042 format(3i2,6f8.3,2f8.1) - enddo - - phi0=atan2(aimag(zsum),real(zsum)) - zsum=0. - do j=1,NN - phi=(j-1)*twopi*dfpk*ts + phi0 - w=cmplx(cos(phi),sin(phi)) - nlo=0 - nhi=0 - cps=cs(i0:i0+6*nts:2*nts,j)*conjg(w) - ps=real(cps) - if(max(ps(1),ps(3)).ge.max(ps(0),ps(2))) nlo=1 - if(max(ps(2),ps(3)).ge.max(ps(0),ps(1))) nhi=1 - id2(j)=2*nhi+nlo - z=cps(id2(j)) - ct(j)=z - zsum=zsum+z - enddo - - nh2=count(id.ne.id2) - nb2=count(iand(id,1).ne.iand(id2,1)) + count(iand(id,2).ne.iand(id2,2)) - nhard1=nhard1+nh1 - nhard2=nhard2+nh2 - nbit1=nbit1+nb1 - nbit2=nbit2+nb2 - - fdiff=1500.0+freq - f0 - write(13,1040) snrdb,snr2500,f0,fdiff,width,nh1,nb1,nh2,nb2 -1040 format(2f7.1,f9.2,f7.2,f6.1,2(i8,i6)) -40 continue - enddo - - ser1=float(nhard1)/(NN*iters) - ser2=float(nhard2)/(NN*iters) - ber1=float(nbit1)/(2*NN*iters) - ber2=float(nbit2)/(2*NN*iters) - write(*,1050) snrdb,nhard1,nbit1,ser1,ber1,nhard2,nbit2,ser2,ber2 - write(14,1050) snrdb,nhard1,nbit1,ser1,ber1,nhard2,nbit2,ser2,ber2 -1050 format(f6.1,2(2i5,2f8.4)) - enddo - write(*,1060) NN*iters,2*NN*iters -1060 format(59('-')/'Max: ',2i5) - -999 end program fsk4sim diff --git a/lib/fsk4hf/genbpsk.f90 b/lib/fsk4hf/genbpsk.f90 deleted file mode 100644 index 6c283e72..00000000 --- a/lib/fsk4hf/genbpsk.f90 +++ /dev/null @@ -1,44 +0,0 @@ -subroutine genbpsk(id,f00,ndiff,nref,c) - - parameter (ND=121) !Data symbols: LDPC (120,60), r=1/2 - parameter (NN=ND) !Total symbols (121) - parameter (NSPS=28800) !Samples per symbol at 12000 sps - parameter (NZ=NSPS*NN) !Samples in waveform (3456000) - - complex c(0:NZ-1) !Complex waveform - real*8 twopi,dt,fs,baud,f0,dphi,phi - integer id(NN) !Encoded NRZ data (values +/-1) - integer ie(NN) !Differentially encoded data - - f0=f00 - twopi=8.d0*atan(1.d0) - fs=12000.d0 - dt=1.0/fs - baud=1.d0/(NSPS*dt) - - if(ndiff.ne.0) then - ie(1)=1 !First bit is always 1 - do i=2,NN !Differentially encode - ie(i)=id(i)*ie(i-1) - enddo - endif - -! Generate the BPSK waveform - phi=0.d0 - k=-1 - do j=1,NN - dphi=twopi*f0*dt - x=id(j) - if(ndiff.ne.0) x=ie(j) !Differential - if(nref.ne.0) x=1.0 !Generate reference carrier - do i=1,NSPS - k=k+1 - phi=phi+dphi - if(phi.gt.twopi) phi=phi-twopi - xphi=phi - c(k)=x*cmplx(cos(xphi),sin(xphi)) - enddo - enddo - - return -end subroutine genbpsk diff --git a/lib/fsk4hf/genfsk4.f90 b/lib/fsk4hf/genfsk4.f90 deleted file mode 100644 index d8b0394b..00000000 --- a/lib/fsk4hf/genfsk4.f90 +++ /dev/null @@ -1,36 +0,0 @@ -subroutine genfsk4(id,f00,nts,c) - - parameter (ND=60) !Data symbols: LDPC (120,60), r=1/2 - parameter (NN=ND) !Total symbols (60) - parameter (NSPS=57600) !Samples per symbol at 12000 sps - parameter (NZ=NSPS*NN) !Samples in waveform (3456000) - parameter (NFFT=NZ) !Full length FFT - - complex c(0:NFFT-1) !Complex waveform - real*8 twopi,dt,fs,baud,f0,dphi,phi - integer id(NN) !Encoded 2-bit data (values 0-3) - - f0=f00 - twopi=8.d0*atan(1.d0) - fs=12000.d0 - dt=1.0/fs - baud=1.d0/(NSPS*dt) - -! Generate the 4-FSK waveform - x=0. - c=0. - phi=0.d0 - k=-1 - do j=1,NN - dphi=twopi*(f0 + nts*id(j)*baud)*dt - do i=1,NSPS - k=k+1 - phi=phi+dphi - if(phi.gt.twopi) phi=phi-twopi - xphi=phi - c(k)=cmplx(cos(xphi),sin(xphi)) - enddo - enddo - - return -end subroutine genfsk4 diff --git a/lib/fsk4hf/genfsk4hf.f90 b/lib/fsk4hf/genfsk4hf.f90 deleted file mode 100644 index 924e9793..00000000 --- a/lib/fsk4hf/genfsk4hf.f90 +++ /dev/null @@ -1,51 +0,0 @@ -subroutine genfsk4hf(msgbits,f0,id,c) - - parameter (KK=84) !Information bits (72 + CRC12) - parameter (ND=84) !Data symbols: LDPC (168,84), r=1/2 - parameter (NS=12) !Sync symbols (3 @ 4x4 Costas arrays) - parameter (NR=2) !Ramp up/down - parameter (NN=NR+NS+ND) !Total symbols (98) - parameter (NSPS=2688/84) !Samples per symbol (32) - parameter (NZ=NSPS*NN) !Samples in baseband waveform (3136) - - complex c(0:NZ-1) !Complex waveform - integer id0(NN) !2-bit data (values 0-3), all symbols - integer id(ND) !2-bit data (values 0-3), data only - integer*1 msgbits(KK),codeword(2*ND) - integer icos4(4) !4x4 Costas array - data icos4/0,1,3,2/ - - twopi=8.0*atan(1.0) - fs=12000.0/84.0 - dt=1.0/fs - baud=1.0/(NSPS*dt) - call encode168(msgbits,codeword) !Encode the test message - id0(1)=0 !Ramp-up - id0(2:5)=icos4 !First Costas array - id0(48:51)=icos4 !Second - id0(94:97)=icos4 !Third - id0(98)=0 !Ramp down - j=5 - do i=1,84 !Data symbols - id(i)=2*codeword(2*i-1) + codeword(2*i) - j=j+1 - if(i.eq.43) j=j+4 - id0(j)=id(i) - enddo - -! Generate the 4-FSK waveform, low tone at f=0 - c=0. - phi=0.d0 - k=-1 - do j=1,NN - dphi=twopi*(f0+id0(j)*baud)*dt - do i=1,NSPS - k=k+1 - phi=phi+dphi - if(phi.gt.twopi) phi=phi-twopi - c(k)=cmplx(cos(phi),sin(phi)) - enddo - enddo - - return -end subroutine genfsk4hf diff --git a/lib/fsk4hf/genmskhf.f90 b/lib/fsk4hf/genmskhf.f90 deleted file mode 100644 index 7d4b0838..00000000 --- a/lib/fsk4hf/genmskhf.f90 +++ /dev/null @@ -1,126 +0,0 @@ -subroutine genmskhf(msgbits,id,icw,cbb,csync)
-
-!Encode an MSK-HF message, produce baseband waveform and sync vector.
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
-
- complex cbb(0:NZ-1)
- complex csync(0:NZ-1)
- real x(0:NZ-1)
- real y(0:NZ-1)
- real pp(N2)
- logical first
- integer*1 msgbits(KK),codeword(ND)
- integer icw(ND)
- integer id(NS+ND)
- integer isync(26) !Long sync vector
- integer ib13(13) !Barker 13 code
- data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/
- data first/.true./
- save first,isync,twopi,pp
-
- if(first) then
- n=z'2c1aeb1'
- do i=1,26
- isync(i)=-1
- if(iand(n,1).eq.1) isync(i)=1
- n=n/2
- enddo
-
- twopi=8.0*atan(1.0)
- do i=1,N2 !Half-sine shaped pulse
- pp(i)=sin(0.5*(i-1)*twopi/N2)
- enddo
- first=.false.
- endif
-
- call encode168(msgbits,codeword) !Encode the test message
- icw=2*codeword - 1
-
-! Message structure: R1 26*(S1+D1) S13 26*(D1+S1) R1
-! Generate QPSK without any offset; then shift the y array to get OQPSK.
-
-! Do the I channel first: results in array x
- n=0
- k=0
- ia=0
- ib=NSPS-1
- x(ia:ib)=0. !Ramp up (half-symbol; shape TBD)
- do j=1,26 !Insert group of 26*(S1+D1)
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*isync(j)
- x(ia:ib)=isync(j)*pp !Insert Sync bit
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- x(ia:ib)=id(n)*pp !Insert data bit
- enddo
-
- do j=1,13 !Insert Barker 13 code
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*ib13(j)
- x(ia:ib)=ib13(j)*pp
- enddo
-
- do j=1,26 !Insert group of 26*(S1+D1)
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- x(ia:ib)=id(n)*pp !Insert data bit
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*isync(j)
- x(ia:ib)=isync(j)*pp !Insert Sync bit
- enddo
- ia=ib+1
- ib=ia+NSPS-1
- x(ia:ib)=0. !Ramp down (half-symbol; shape TBD)
-
-! Now do the Q channel: results in array y
- ia=0
- ib=NSPS-1
- y(ia:ib)=0. !Ramp up (half-symbol; shape TBD)
- do j=1,116
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- y(ia:ib)=id(n)*pp
- enddo
- ia=ib+1
- ib=ia+NSPS-1
- y(ia:ib)=0. !Ramp down (half-symbol; shape TBD)
- y=cshift(y,-NSPS) !Shift Q array to get OQPSK
- cbb=cmplx(x,y) !Complex baseband waveform
-
- ib=NSPS-1
- ib2=NSPS-1+64*N2
- do j=1,26 !Zero all data symbols in x
- ia=ib+1+N2
- ib=ia+N2-1
- x(ia:ib)=0.
- ia2=ib2+1+N2
- ib2=ia2+N2-1
- x(ia2:ib2)=0.
- enddo
- csync=x
-
- return
-end subroutine genmskhf
diff --git a/lib/fsk4hf/genwspr5.f90 b/lib/fsk4hf/genwspr5.f90 deleted file mode 100644 index e09bcd6f..00000000 --- a/lib/fsk4hf/genwspr5.f90 +++ /dev/null @@ -1,107 +0,0 @@ -subroutine genwspr5(msg,msgsent,itone)
-
-! Encode a WSPR-LF message, producing array itone().
-
- use crc
- include 'wsprlf_params.f90'
-
- character*22 msg,msgsent
- character*60 cbits
- integer*1,target :: idat(9)
- integer*1 msgbits(KK),codeword(ND)
- logical first
- integer icw(ND)
- integer id(NS+ND)
- integer jd(NS+ND)
- integer isync(48) !Long sync vector
- integer ib13(13) !Barker 13 code
- integer itone(NN)
- integer*8 n8
- data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/
- data first/.true./
- save first,isync
-
- if(first) then
- n8=z'cbf089223a51'
- do i=1,48
- isync(i)=-1
- if(iand(n8,1).eq.1) isync(i)=1
- n8=n8/2
- enddo
- first=.false.
- endif
-
- idat=0
- call wqencode(msg,ntype0,idat) !Source encoding
- id7=idat(7)
- if(id7.lt.0) id7=id7+256
- id7=id7/64
- icrc=crc10(c_loc(idat),9) !Compute the 10-bit CRC
- idat(8)=icrc/256 !Insert CRC into idat(8:9)
- idat(9)=iand(icrc,255)
- call wqdecode(idat,msgsent,itype)
-
- write(cbits,1004) idat(1:6),id7,icrc
-1004 format(6b8.8,b2.2,b10.10)
- read(cbits,1006) msgbits
-1006 format(60i1)
-
-! call chkcrc10(msgbits,nbadcrc)
-! print*,msgsent,itype,crc10_check(c_loc(idat),9),nbadcrc
-
- call encode300(msgbits,codeword) !Encode the test message
- icw=2*codeword - 1 !NRZ codeword
-
-! Message structure:
-! I channel: R1 48*(S1+D1) S13 48*(D1+S1) R1
-! Q channel: R1 D204 R1
-! Generate QPSK with no offset, then shift the y array to get OQPSK.
-
-! I channel:
- n=0
- k=0
- do j=1,48 !Insert group of 48*(S1+D1)
- n=n+1
- id(n)=2*isync(j)
- k=k+1
- n=n+1
- id(n)=icw(k)
- enddo
-
- do j=1,13 !Insert Barker 13 code
- n=n+1
- id(n)=2*ib13(j)
- enddo
-
- do j=1,48 !Insert group of 48*(S1+D1)
- k=k+1
- n=n+1
- id(n)=icw(k)
- n=n+1
- id(n)=2*isync(j)
- enddo
-
-! Q channel
- do j=1,204
- k=k+1
- n=n+1
- id(n)=icw(k)
- enddo
-
-! Map I and Q to tones.
- n=0
- jz=(NS+ND+1)/2
- do j=1,jz-1
- jd(2*j-1)=id(j)/abs(id(j))
- jd(2*j)=id(j+jz)/abs(id(j+jz))
- enddo
- jd(NS+ND)=id(jz)/abs(id(jz))
- itone=0
- do j=1,jz-1
- itone(2*j+1)=(jd(2*j)*jd(2*j-1)+1)/2;
- itone(2*j+2)=-(jd(2*j)*jd(2*j+1)-1)/2;
- enddo
- itone(NS+ND+2)=jd(NS+ND) !### Is this correct ??? ###
-
- return
-end subroutine genwspr5
diff --git a/lib/fsk4hf/genwspr_fsk8.f90 b/lib/fsk4hf/genwspr_fsk8.f90 deleted file mode 100644 index 2ef6ace3..00000000 --- a/lib/fsk4hf/genwspr_fsk8.f90 +++ /dev/null @@ -1,45 +0,0 @@ -subroutine genwspr_fsk8(msg,msgsent,itone)
-
-! Encode a WSPR-LF 8-FSK message, producing array itone().
-
- use crc
- include 'wspr_fsk8_params.f90'
-
- character*22 msg,msgsent
- character*60 cbits
- integer*1,target :: idat(9)
- integer*1 msgbits(KK),codeword(3*ND)
- integer itone(NN)
- integer icos7(0:6)
- data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
-
- idat=0
- call wqencode(msg,ntype0,idat) !Source encoding
- id7=idat(7)
- if(id7.lt.0) id7=id7+256
- id7=id7/64
- icrc=crc10(c_loc(idat),9) !Compute the 10-bit CRC
- idat(8)=icrc/256 !Insert CRC into idat(8:9)
- idat(9)=iand(icrc,255)
- call wqdecode(idat,msgsent,itype)
-
- write(cbits,1004) idat(1:6),id7,icrc
-1004 format(6b8.8,b2.2,b10.10)
- read(cbits,1006) msgbits
-1006 format(60i1)
-
-! call chkcrc10(msgbits,nbadcrc)
-! print*,msgsent,itype,crc10_check(c_loc(idat),9),nbadcrc
-
- call encode300(msgbits,codeword) !Encode the test message
-
-! Message structure: S7 D100 S7
- itone(1:7)=icos7
- itone(NN-6:NN)=icos7
- do j=1,ND
- i=3*j -2
- itone(j+7)=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2)
- enddo
-
- return
-end subroutine genwspr_fsk8
diff --git a/lib/fsk4hf/genwsprcpm.f90 b/lib/fsk4hf/genwsprcpm.f90 deleted file mode 100644 index 49d30a25..00000000 --- a/lib/fsk4hf/genwsprcpm.f90 +++ /dev/null @@ -1,70 +0,0 @@ -subroutine genwsprcpm(msg,msgsent,itone)
-
-! Encode a WSPRCPM message, producing array itone().
-!
- use crc
- include 'wsprcpm_params.f90'
-
- character*22 msg,msgsent
- character*64 cbits
- character*32 sbits
- integer iuniqueword0
- integer*1,target :: idat(9)
- integer*1 msgbits(68),codeword(ND)
- logical first
- integer icw(ND)
- integer id(NS+ND)
- integer jd(NS+ND)
- integer ipreamble(16) !Freq estimation preamble
- integer isync(200) !Long sync vector
- integer itone(NN)
- data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
- data first/.true./
- data iuniqueword0/z'30C9E8AD'/
- save first,isync,ipreamble
-
- if(first) then
- write(sbits,'(b32.32)') iuniqueword0
- read(sbits,'(32i1)') isync(1:32)
- read(sbits,'(32i1)') isync(33:64)
- read(sbits,'(32i1)') isync(65:96)
- read(sbits,'(32i1)') isync(97:128)
- read(sbits,'(32i1)') isync(129:160)
- read(sbits,'(32i1)') isync(161:192)
- read(sbits,'(8i1)') isync(193:200)
- first=.false.
- endif
-
- idat=0
- call wqencode(msg,ntype0,idat) !Source encoding
- id7=idat(7)
- if(id7.lt.0) id7=id7+256
- id7=id7/64
-write(*,*) 'idat ',idat
- icrc=crc14(c_loc(idat),9)
-write(*,*) 'icrc: ',icrc
-write(*,'(a6,b16.16)') 'icrc: ',icrc
- call wqdecode(idat,msgsent,itype)
- print*,msgsent,itype
- write(cbits,1004) idat(1:6),id7,iand(icrc,z'3FFF')
-1004 format(6b8.8,b2.2,b14.14)
- msgbits=0
- read(cbits,1006) msgbits(1:64)
-1006 format(64i1)
-
-write(*,'(50i1,1x,14i1,1x,4i1)') msgbits
-
- call encode204(msgbits,codeword) !Encode the test message
-
-! Message structure:
-! d100 p16 d100
- itone(1:100)=isync(1:100)+2*codeword(1:100)
- itone(101:116)=ipreamble+1
- itone(117:216)=isync(101:200)+2*codeword(101:200)
- itone=2*itone-3
- do i=1,216
- write(*,*) i,itone(i)
- enddo
-
- return
-end subroutine genwsprcpm
diff --git a/lib/fsk4hf/genwsprdpsk.f90 b/lib/fsk4hf/genwsprdpsk.f90 deleted file mode 100644 index 1b6c58b1..00000000 --- a/lib/fsk4hf/genwsprdpsk.f90 +++ /dev/null @@ -1,63 +0,0 @@ -subroutine genwsprdpsk(msg,msgsent,imsgde)
-
-! Encode a WSPRDPSK message, producing array txwave().
-!
- use crc
- include 'wsprdpsk_params.f90'
-
- character*22 msg,msgsent
- character*64 cbits
- character*32 sbits
- integer iuniqueword0
- integer*1,target :: idat(9)
- integer*1 msgbits(68),codeword(ND)
- logical first
- integer ipreamble(16) !Freq estimation preamble
- integer isync(32) !Long sync vector
- integer imsg(NN),imsgde(NN)
- data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
- data first/.true./
- data iuniqueword0/z'30C9E8AD'/
- save first,isync,ipreamble
-
- if(first) then
- write(sbits,'(b32.32)') iuniqueword0
- read(sbits,'(32i1)') isync(1:32)
- first=.false.
- endif
-
- idat=0
- call wqencode(msg,ntype0,idat) !Source encoding
- id7=idat(7)
- if(id7.lt.0) id7=id7+256
- id7=id7/64
-write(*,*) 'idat ',idat
- icrc=crc14(c_loc(idat),9)
-write(*,*) 'icrc: ',icrc
-write(*,'(a6,b16.16)') 'icrc: ',icrc
- call wqdecode(idat,msgsent,itype)
- print*,msgsent,itype
- write(cbits,1004) idat(1:6),id7,iand(icrc,z'3FFF')
-1004 format(6b8.8,b2.2,b14.14)
- msgbits=0
- read(cbits,1006) msgbits(1:64)
-1006 format(64i1)
-
-write(*,'(50i1,1x,14i1,1x,4i1)') msgbits
-
- call encode204(msgbits,codeword) !Encode the test message
-
- imsg(1)=1 !reference bit
- imsg(2:101)=codeword(1:100)
- imsg(102:132)=isync(1:31) !only use 31 of the sync bits
- imsg(133:232)=codeword(101:200)
-write(*,'(232i1)') imsg(1:232)
- imsgde(1)=1
- do i=2,232
- imsgde(i)=mod(imsgde(i-1)+imsg(i),2)
- enddo
-
-write(*,*) '-------------'
-write(*,'(232i1)') imsgde(1:232)
- return
-end subroutine genwsprdpsk
diff --git a/lib/fsk4hf/genwsprlf.f90 b/lib/fsk4hf/genwsprlf.f90 deleted file mode 100644 index 4c5b31cf..00000000 --- a/lib/fsk4hf/genwsprlf.f90 +++ /dev/null @@ -1,137 +0,0 @@ -subroutine genwsprlf(msgbits,id,icw,cbb,csync,itone)
-
-!Encode a WSPR-LF message, produce baseband waveform and sync vector.
-
- include 'wsprlf_params.f90'
-
- complex cbb(0:NZ-1)
- complex csync(0:NZ-1)
- real x(0:NZ-1)
- real y(0:NZ-1)
- real pp(N2)
- logical first
- integer*1 msgbits(KK),codeword(ND)
- integer icw(ND)
- integer id(NS+ND)
- integer jd(NS+ND)
- integer isync(48) !Long sync vector
- integer ib13(13) !Barker 13 code
- integer itone(NN)
- integer*8 n8
- data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/
- data first/.true./
- save first,isync,twopi,pp
-
- if(first) then
- n8=z'cbf089223a51'
- do i=1,48
- isync(i)=-1
- if(iand(n8,1).eq.1) isync(i)=1
- n8=n8/2
- enddo
-
- twopi=8.0*atan(1.0)
- do i=1,N2 !Half-sine shaped pulse
- pp(i)=sin(0.5*(i-1)*twopi/N2)
- enddo
- first=.false.
- endif
-
- call encode300(msgbits,codeword) !Encode the test message
- icw=2*codeword - 1
-
-! Message structure: R1 48*(S1+D1) S13 48*(D1+S1) R1
-! Generate QPSK without any offset; then shift the y array to get OQPSK.
-
-! Do the I channel first: results in array x
- n=0
- k=0
- ia=0
- ib=NSPS-1
- x(ia:ib)=0. !Ramp up (half-symbol; shape TBD)
- do j=1,48 !Insert group of 48*(S1+D1)
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*isync(j)
- x(ia:ib)=isync(j)*pp !Insert Sync bit
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- x(ia:ib)=id(n)*pp !Insert data bit
- enddo
-
- do j=1,13 !Insert Barker 13 code
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*ib13(j)
- x(ia:ib)=ib13(j)*pp
- enddo
-
- do j=1,48 !Insert group of 48*(S1+D1)
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- x(ia:ib)=id(n)*pp !Insert data bit
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*isync(j)
- x(ia:ib)=isync(j)*pp !Insert Sync bit
- enddo
- ia=ib+1
- ib=ia+NSPS-1
- x(ia:ib)=0. !Ramp down (half-symbol; shape TBD)
-
-! Now do the Q channel: results in array y
- ia=0
- ib=NSPS-1
- y(ia:ib)=0. !Ramp up (half-symbol; shape TBD)
- do j=1,204
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- y(ia:ib)=id(n)*pp
- enddo
- ia=ib+1
- ib=ia+NSPS-1
- y(ia:ib)=0. !Ramp down (half-symbol; shape TBD)
- y=cshift(y,-NSPS) !Shift Q array to get OQPSK
- cbb=cmplx(x,y) !Complex baseband waveform
-
- ib=NSPS-1
- ib2=NSPS-1+64*N2
- do j=1,48 !Zero all data symbols in x
- ia=ib+1+N2
- ib=ia+N2-1
- x(ia:ib)=0.
- ia2=ib2+1+N2
- ib2=ia2+N2-1
- x(ia2:ib2)=0.
- enddo
- csync=x
-
-! Map I and Q to tones.
- n=0
- jz=(NS+ND+1)/2
- do j=1,jz-1
- jd(2*j-1)=id(j)/abs(id(j))
- jd(2*j)=id(j+jz)/abs(id(j+jz))
- enddo
- jd(NS+ND)=id(jz)/abs(id(jz))
- itone=0
- do j=1,jz-1
- itone(2*j-1)=(jd(2*j)*jd(2*j-1)+1)/2;
- itone(2*j)=-(jd(2*j)*jd(2*j+1)-1)/2;
- enddo
- itone(NS+ND)=jd(NS+ND) !### Is this correct ??? ###
-
- return
-end subroutine genwsprlf
diff --git a/lib/fsk4hf/getfc1.f90 b/lib/fsk4hf/getfc1.f90 deleted file mode 100644 index b82b0303..00000000 --- a/lib/fsk4hf/getfc1.f90 +++ /dev/null @@ -1,58 +0,0 @@ -subroutine getfc1(c,fc1)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (N13=13*N2) !Samples in central sync vector (416)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
- complex c(0:NZ-1) !Complex waveform
- complex c2(0:NFFT1-1) !Short spectra
- real s(-NH1+1:NH1) !Coarse spectrum
-
- nspec=NZ/NFFT1
- fs=12000.0/72.0
- df1=fs/NFFT1
- s=0.
- do k=1,nspec
- ia=(k-1)*N2
- ib=ia+N2-1
- c2(0:N2-1)=c(ia:ib)
- c2(N2:)=0.
- call four2a(c2,NFFT1,1,-1,1)
- do i=0,NFFT1-1
- j=i
- if(j.gt.NH1) j=j-NFFT1
- s(j)=s(j) + real(c2(i))**2 + aimag(c2(i))**2
- enddo
- enddo
-! call smo121(s,NFFT1)
- smax=0.
- ipk=0
- fc1=0.
- ia=nint(40.0/df1)
- do i=-ia,ia
- f=i*df1
- if(s(i).gt.smax) then
- smax=s(i)
- ipk=i
- fc1=f
- endif
-! write(51,3001) f,s(i),db(s(i))
-! 3001 format(f10.3,e12.3,f10.3)
- enddo
-
-! The following is for testing SNR calibration:
-! sp3n=(s(ipk-1)+s(ipk)+s(ipk+1)) !Sig + 3*noise
-! base=(sum(s)-sp3n)/(NFFT1-3.0) !Noise per bin
-! psig=sp3n-3*base !Sig only
-! pnoise=(2500.0/df1)*base !Noise in 2500 Hz
-! xsnrdb=db(psig/pnoise)
-
- return
-end subroutine getfc1
diff --git a/lib/fsk4hf/getfc1w.f90 b/lib/fsk4hf/getfc1w.f90 deleted file mode 100644 index 532b9837..00000000 --- a/lib/fsk4hf/getfc1w.f90 +++ /dev/null @@ -1,47 +0,0 @@ -subroutine getfc1w(c,fs,fa,fb,fc1,xsnr)
-
- include 'wsprlf_params.f90'
- complex c(0:NZ-1) !Complex waveform
- complex c2(0:NFFT1-1) !Short spectra
- real s(-NH1+1:NH1) !Coarse spectrum
- nspec=NZ/NFFT1
- df1=fs/NFFT1
- s=0.
- do k=1,nspec
- ia=(k-1)*N2
- ib=ia+N2-1
- c2(0:N2-1)=c(ia:ib)
- c2(N2:)=0.
- call four2a(c2,NFFT1,1,-1,1)
- do i=0,NFFT1-1
- j=i
- if(j.gt.NH1) j=j-NFFT1
- s(j)=s(j) + real(c2(i))**2 + aimag(c2(i))**2
- enddo
- enddo
-! call smo121(s,NFFT1)
- smax=0.
- ipk=0
- fc1=0.
- ia=nint(fa/df1)
- ib=nint(fb/df1)
- do i=ia,ib
- f=i*df1
- if(s(i).gt.smax) then
- smax=s(i)
- ipk=i
- fc1=f
- endif
-! write(51,3001) f,s(i),db(s(i))
-! 3001 format(f10.3,e12.3,f10.3)
- enddo
-
-! The following is for testing SNR calibration:
- sp3n=(s(ipk-1)+s(ipk)+s(ipk+1)) !Sig + 3*noise
- base=(sum(s)-sp3n)/(NFFT1-3.0) !Noise per bin
- psig=sp3n-3*base !Sig only
- pnoise=(2500.0/df1)*base !Noise in 2500 Hz
- xsnr=db(psig/pnoise)
-
- return
-end subroutine getfc1w
diff --git a/lib/fsk4hf/getfc2.f90 b/lib/fsk4hf/getfc2.f90 deleted file mode 100644 index 9506168d..00000000 --- a/lib/fsk4hf/getfc2.f90 +++ /dev/null @@ -1,74 +0,0 @@ -subroutine getfc2(c,csync,fc1,fc2,fc3)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (N13=13*N2) !Samples in central sync vector (416)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
- complex c(0:NZ-1) !Complex waveform
- complex cs(0:NZ-1) !For computing spectrum
- complex csync(0:NZ-1) !Sync symbols only, from cbb
- real a(5)
-
- fs=12000.0/72.0
- df=fs/NZ
- baud=fs/NSPS
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1
-
-! Filter, square, then FFT to get refined carrier frequency fc2.
- call four2a(cs,NZ,1,-1,1) !To freq domain
- ia=nint(0.75*baud/df)
- cs(ia:NZ-1-ia)=0. !Save only freqs around fc1
- call four2a(cs,NZ,1,1,1) !Back to time domain
- cs=cs/NZ
- cs=cs*cs !Square the data
- call four2a(cs,NZ,1,-1,1) !Compute squared spectrum
-
-! Find two peaks separated by baud
- pmax=0.
- fc2=0.
- ic=nint(baud/df)
- ja=nint(0.5*baud/df)
- do j=-ja,ja
- f2=j*df
- ia=nint((f2-0.5*baud)/df)
- if(ia.lt.0) ia=ia+NZ
- ib=nint((f2+0.5*baud)/df)
- p=real(cs(ia))**2 + aimag(cs(ia))**2 + &
- real(cs(ib))**2 + aimag(cs(ib))**2
- if(p.gt.pmax) then
- pmax=p
- fc2=0.5*f2
- endif
-! write(52,1200) f2,p,db(p)
-!1200 format(f10.3,2f15.3)
- enddo
-
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1
- cs=cs*conjg(csync)
- call four2a(cs,NZ,1,-1,1) !To freq domain
- pmax=0.
- do i=0,NZ-1
- f=i*df
- if(i.gt.NZ/2) f=(i-NZ)*df
- p=real(cs(i))**2 + aimag(cs(i))**2
-! write(51,3001) f,p,db(p)
-!3001 format(f10.3,e12.3,f10.3)
- if(p.gt.pmax) then
- pmax=p
- fc3=f
- endif
- enddo
-
- return
-end subroutine getfc2
diff --git a/lib/fsk4hf/getfc2w.f90 b/lib/fsk4hf/getfc2w.f90 deleted file mode 100644 index 0d100ee5..00000000 --- a/lib/fsk4hf/getfc2w.f90 +++ /dev/null @@ -1,82 +0,0 @@ -subroutine getfc2w(c,csync,npeaks,fs,fc1,fpks)
-
- include 'wsprlf_params.f90'
-
- complex c(0:NZ-1) !Complex waveform
- complex cs(0:NZ-1) !For computing spectrum
- complex csync(0:NZ-1) !Sync symbols only, from cbb
- real a(5)
- real freqs(413),sp2(413),fpks(npeaks)
- integer pkloc(1)
-
- df=fs/NZ
- baud=fs/NSPS
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1
-
-! Filter, square, then FFT to get refined carrier frequency fc2.
- call four2a(cs,NZ,1,-1,1) !To freq domain
-
- ia=nint(0.75*baud/df)
- cs(ia:NZ-1-ia)=0. !Save only freqs around fc1
- call four2a(cs,NZ,1,1,1) !Back to time domain
- cs=cs/NZ
- cs=cs*cs !Square the data
- call four2a(cs,NZ,1,-1,1) !Compute squared spectrum
-
-! Find two peaks separated by baud
- pmax=0.
- fc2=0.
- ja=nint(0.3*baud/df)
- k=1
- do j=-ja,ja
- f2=j*df
- ia=nint((f2-0.5*baud)/df)
- if(ia.lt.0) ia=ia+NZ
- ib=nint((f2+0.5*baud)/df)
- p=real(cs(ia))**2 + aimag(cs(ia))**2 + &
- real(cs(ib))**2 + aimag(cs(ib))**2
- if(p.gt.pmax) then
- pmax=p
- fc2=0.5*f2
- endif
- freqs(k)=0.5*f2
- sp2(k)=p
- k=k+1
-! write(52,1200) f2,p,db(p)
-!1200 format(f10.3,2f15.3)
- enddo
-
- do i=1,npeaks
- pkloc=maxloc(sp2)
- ipk=pkloc(1)
- fpks(i)=freqs(ipk)
- ipk0=max(1,ipk-1)
- ipk1=min(413,ipk+1)
-! ipk0=ipk
-! ipk1=ipk
- sp2(ipk0:ipk1)=0.0
-!write(*,*) i,fpks(i),fc2
- enddo
-
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1
- cs=cs*conjg(csync)
- call four2a(cs,NZ,1,-1,1) !To freq domain
- pmax=0.
- do i=0,NZ-1
- f=i*df
- if(i.gt.NZ/2) f=(i-NZ)*df
- p=real(cs(i))**2 + aimag(cs(i))**2
-! write(51,3001) f,p,db(p)
-!3001 format(f10.3,e12.3,f10.3)
- if(p.gt.pmax) then
- pmax=p
- fc3=f
- endif
- enddo
-
- return
-end subroutine getfc2w
diff --git a/lib/fsk4hf/gran.c b/lib/fsk4hf/gran.c deleted file mode 100644 index 24b98650..00000000 --- a/lib/fsk4hf/gran.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <stdlib.h> -#include <math.h> - -/* Generate gaussian random float with mean=0 and std_dev=1 */ -float gran_() -{ - float fac,rsq,v1,v2; - static float gset; - static int iset; - - if(iset){ - /* Already got one */ - iset = 0; - return gset; - } - /* Generate two evenly distributed numbers between -1 and +1 - * that are inside the unit circle - */ - do { - v1 = 2.0 * (float)rand() / RAND_MAX - 1; - v2 = 2.0 * (float)rand() / RAND_MAX - 1; - rsq = v1*v1 + v2*v2; - } while(rsq >= 1.0 || rsq == 0.0); - fac = sqrt(-2.0*log(rsq)/rsq); - gset = v1*fac; - iset++; - return v2*fac; -} diff --git a/lib/fsk4hf/ldpc_204_68_params.f90 b/lib/fsk4hf/ldpc_204_68_params.f90 deleted file mode 100644 index 6e75ef11..00000000 --- a/lib/fsk4hf/ldpc_204_68_params.f90 +++ /dev/null @@ -1,154 +0,0 @@ -integer, parameter:: N=204, K=68, M=N-K -character*17 g(136) -integer colorder(N) -data g/ & !parity generator matrix for (204,68) code - "2de7435fd27c0031d", & - "f331b40671e20ea80", & - "48bd3f8cb9a24392f", & - "d4ed71c935162aa2a", & - "c437a3284ec58bce7", & - "35a806dd5be35627c", & - "396e797c33a4739a6", & - "768f331a59c15487b", & - "c214eac24ae5e1732", & - "0b5c53ff3a6da1192", & - "99624981d2703fb97", & - "e9f5447ef7f1ff6af", & - "bd8c730f0cfdf0727", & - "26f61e63e1e098f7f", & - "ef826566137b6526f", & - "af0e4fa251e9b4926", & - "75974a8b2a24292c5", & - "71caf0f2cd10f6d4f", & - "b1103f1f26e6898b7", & - "67ceb7d6f490da64f", & - "ee0e8fbefec23008a", & - "11cc2227e8bd676ca", & - "6e71626ba1e278046", & - "005d28da267e50e13", & - "a9ae4a130aaba8219", & - "d8ab72e0158d0da70", & - "56009d42b37bd66ff", & - "c39a75eca99b0e996", & - "6886de0bf7c0bf4bb", & - "1046cd8f64162f7b5", & - "da0f15843ac21e3a5", & - "e9bf9cd19f3db3913", & - "2fb9cb42d650f47a7", & - "a2b6c5a378fa75a65", & - "41a88f3cd60b79d6c", & - "fcf175794cc3ac96a", & - "8677a3447d40a9f71", & - "97a1f08c250b4bf12", & - "0168f090a1df6e8ea", & - "418a06bf372cc67d9", & - "0f17b880c1ff51239", & - "b2afd6d585deb961b", & - "60298ac5b58dbeee0", & - "8350c03c40119feff", & - "b29c964a8accf6af4", & - "9b46f036a5c178b5d", & - "917398bff051c300a", & - "5e52c03b2f8c5128c", & - "beae6c33c87ba38ab", & - "20843f7b056a02ebf", & - "66690d65acd9de598", & - "8f025841af5b54331", & - "b43cd869d3be2c3db", & - "c9c342fe63c18df50", & - "d331b40671e28ea80", & - "62406a0f4947e6ce9", & - "d67b1495883b22e1b", & - "734534c372408895b", & - "d88750e33d9677dcd", & - "6f96964da55138687", & - "80bee98bb75d50ef2", & - "c428ef3e3f06f4c56", & - "b1a1499b125883a35", & - "ac892d4b37fa9e395", & - "458dbda0f95ab11a5", & - "6f93c9e95b1094eed", & - "2e370d713914f848e", & - "758806dd5be35627c", & - "8c52e01caec798b49", & - "c286cc25bae3669cf", & - "87c56fb895c100884", & - "e89cb1376a18fd911", & - "156ffe5f30dc354e0", & - "f20d0b121d6a6b3ee", & - "7db08891b491a95d2", & - "191fac548d5077bdf", & - "023a37d7ea5660bbc", & - "6781668b363fee682", & - "bbfaf262cab7370da", & - "feea557965b7e474f", & - "c094eb223e1d305b8", & - "2be051abdd5beea35", & - "0790449880fda9d00", & - "f9029a39ec869e7b4", & - "5a29f48926ec9a552", & - "e0463306dc1470f87", & - "9251058334d790f86", & - "3019e1d4578e8a4dc", & - "887e46631502fa111", & - "c25fcd7a42465d326", & - "cf64bcc1056b555c4", & - "3e71c0fe5f0ad733b", & - "11055ec43b076e5b2", & - "3440f64dfa3c30a96", & - "2b73885b4d3299f60", & - "2e71627ba1e268046", & - "ad23743d5e6e5b80c", & - "c9757b05f29bfdc10", & - "f7112bea739247b51", & - "3664062387998b2b1", & - "90897a3b8785aefba", & - "29e126e3201fc1d46", & - "96c9001c84d5257fc", & - "067723447d40a9f71", & - "1a019cc68f7511402", & - "4bd48eb2330032763", & - "d139a5da936b37647", & - "765ab46a4dec5f04f", & - "706f475ad19b91955", & - "1755c988fa8a55e5c", & - "2fd9ed5777eb01d6a", & - "bec27d85b954d3fe8", & - "7135a3b92c45b3f8d", & - "353237872f002163a", & - "e31e4a97aef10c729", & - "da527d5e1cbc4edb6", & - "6e33cdede17c3207e", & - "ef2d2062e84dc401f", & - "8217c84c50c1bf833", & - "12ffbac7b2219c9e0", & - "3729178706f66881f", & - "2fdd748c382a608a1", & - "dd0a00076f9dcec73", & - "46b1d37bced447035", & - "7316f33a9c05ef178", & - "152c39a6de8954cc3", & - "16efffb7b62e12ba3", & - "9d9ec2bb467affd83", & - "467723445d40a9f61", & - "87994762b3bf50697", & - "b1bfa5b51526dde9b", & - "b0a6a19d709a96148", & - "990d567c0aba31a14", & - "171f190792461b1e0", & - "166011c27d2b6b8a4", & - "170c15831244ae73e"/ - -data colorder/ & - 0, 1, 2, 3, 4, 5, 47, 6, 7, 8, 9, 10, 11, 12, 58, 55, 13, & - 14, 15, 46, 17, 18, 60, 19, 20, 21, 22, 23, 24, 25, 57, 26, 27, 49, & - 28, 52, 65, 16, 50, 73, 59, 68, 63, 29, 30, 31, 32, 51, 62, 56, 66, & - 45, 33, 34, 53, 67, 35, 36, 37, 61, 69, 54, 38, 71, 82, 39, 77, 80, & - 83, 78, 84, 48, 41, 85, 40, 64, 75, 96, 74, 72, 76, 86, 87, 89, 90, & - 79, 70, 92, 99, 93,101, 95,100, 97, 94, 42, 98,103,105,102, 43,104, & - 88, 44,106, 81,107,110,108,111,112,109,113,114,117,118,116,121,115, & - 119,122,120,125,129,124,127,126,128, 91,123,133,131,130,134,135,137, & - 136,132,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152, & - 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169, & - 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186, & - 187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203/ diff --git a/lib/fsk4hf/ldpc_300_60_params.f90 b/lib/fsk4hf/ldpc_300_60_params.f90 deleted file mode 100644 index 53ee994e..00000000 --- a/lib/fsk4hf/ldpc_300_60_params.f90 +++ /dev/null @@ -1,262 +0,0 @@ -integer, parameter:: N=300, K=60, M=N-K -character*15 g(M) -integer colorder(N) -data g/ & - "316fd3bb18bcefd", & - "a9c1c984f91244e", & - "9e04bd3d5d78d89", & - "f81617089621bd4", & - "12997ce2f44dbf4", & - "3ebddaf9b0fa1fc", & - "d0c114b0b0ef162", & - "f8c4f115f98bd92", & - "d0a79c0c5b8ca19", & - "477f6712f357b3b", & - "fa28b2444a7e66b", & - "bedcd4df8d95c64", & - "da30de73e57022c", & - "bc099bbb90fe09e", & - "cffc1e47e5708e8", & - "713d808563ca9a3", & - "70fcf1741d5d5d7", & - "32e80bc15112008", & - "804cef4df9b18ec", & - "3736881819d1033", & - "f4e37db7f9c5efe", & - "9e84b93d4d78d09", & - "2250c3518ec830a", & - "55a529a92e18021", & - "1cb80b14c9f6eae", & - "80c504b031ef926", & - "ece6636d0ac9c6d", & - "5d50a1690782cd0", & - "3d54a1fb30937a2", & - "ba8fe8006318041", & - "02917ce2fc45bf4", & - "abc1d984f95a44e", & - "fc05b4c4ab2d850", & - "467f7718f357b3b", & - "472cc094546c6b2", & - "fcdd94cf8c9cc64", & - "4dbc1647e970cc8", & - "6caa465c442aed1", & - "aead5af8b0da1be", & - "d8e1fa45a2e8431", & - "9d4dc4cc63abb7f", & - "9b2df6b48264637", & - "7335808563ca3a3", & - "36bf8d5cd93e6cc", & - "004ccf4db9b08ec", & - "90a71c8c598ca19", & - "f8c5d115f90bc92", & - "b95546c4e3f7934", & - "7d50a1690786cd0", & - "c90939921a0d7c6", & - "d0c504b030ef126", & - "ce3e6f9396fc542", & - "a0072a59f3707f5", & - "532d0a8fe3da1ea", & - "68b9e5cd7d142db", & - "fedc94df8c9dc64", & - "6da2465c448aed0", & - "3574aa19cb273c0", & - "1e54768c6bc6843", & - "691f65654498186", & - "fe2c92444a6ef6b", & - "9caad933e038cc4", & - "ad4e6f4defb28ec", & - "4f3d80947c6d2b2", & - "1caad933e0b8cc4", & - "b14fd3bf18bcafd", & - "ad091bbbb0f809e", & - "90b71c8c598da19", & - "f8c4d115f90bd92", & - "9d4dcccc63afb7f", & - "fa2c92444a6e76b", & - "1e14768c6bc6c43", & - "d1baf5aacb86087", & - "bdf762b92ee51c7", & - "caacec06ad8a90c", & - "804ccf4df9b08ec", & - "69e969f9da5cbd8", & - "814ccf4df9b086c", & - "cebe4f9796f4542", & - "491f65654499186", & - "8fbf5b9796f6d2a", & - "ce3e4f9396f4542", & - "47558560e7debc3", & - "94aadd33e038cc4", & - "a94eef4debb286e", & - "d8e5d115f91bcd2", & - "532d488fe3da0ab", & - "664e7bc4e23a80c", & - "94a2dd33a038cd4", & - "d8c5d115f91bc92", & - "0fef071eee60bd5", & - "9a89a09163c2b97", & - "0eaf071e6c60bd5", & - "bc0d1bbbb0fe0be", & - "f9babd3d12d0f31", & - "69a969f9da5c9d8", & - "6e4e7bc4e23a82c", & - "b0042659f3227f5", & - "2d51418f0f28347", & - "be0d5bbbb0da0be", & - "225003508ec8302", & - "8fbf4b9796f4d2a", & - "bead5af9b0da1be", & - "6ca2465c440aed1", & - "4fbc1e47ed708c8", & - "bd091bbbb0fc09e", & - "b0062259f3307f5", & - "a8072a59f3727f5", & - "a0062259f3707f5", & - "3c380b14c974eae", & - "30042659f3226f5", & - "48b9e4cd7d142db", & - "728bcd4b38308fb", & - "c0c504b031ef126", & - "314fd3bb18bcafd", & - "1c29148305faec1", & - "44c92a9c28ada63", & - "88e99b370aae32b", & - "695081690386ad8", & - "572d0a8de3da1ea", & - "467f6610f357b2b", & - "733d008563da1a3", & - "d1baf4aacb84087", & - "4315551d71c8ff0", & - "48bde4cd7d140db", & - "3ebd58f9b0da9fc", & - "51baf4aacb84083", & - "814e4f4de9b082c", & - "814ecf4de9b086c", & - "be0d1bbbb0fa0be", & - "4f7580947c792b3", & - "cdf2dce48c39c3b", & - "d8c5c115f91bc12", & - "a94e6f4debb28ee", & - "be2d5afbb0da1be", & - "cdd6dce48439c2b", & - "bebd5af9b0da1fe", & - "fa2892444a6e66b", & - "51bbf4aacb8c083", & - "baa73d81eebcd83", & - "79a2ce47f138cc9", & - "cc28cf198e6dbd4", & - "fcde94dfcc9cc64", & - "1016fcf59286717", & - "12917ce2fc4dbf4", & - "4fbc1647e9708c8", & - "3e382b1cc974fae", & - "d5bafdaad386087", & - "0fef473eee60bd5", & - "c0e504b031ee126", & - "8bbf5b9797f6d2a", & - "0eef071e6e60bd5", & - "1806fcf59386517", & - "fcdc94df8c9cc64", & - "141eca2bfa25656", & - "5fbc1767e9708e8", & - "5aa4c7803a6bdf1", & - "b14bd3b718bcafd", & - "3ebd5af9b0da1fc", & - "d0a7148c5b8ca09", & - "a94ecf4debb086e", & - "733d808563ca1a3", & - "fd9abd1d92d0f31", & - "bc091bbbb0fe09e", & - "d0c514b0b0ef122", & - "4f7d80947c7d2b3", & - "8b3f5b97b7f6d2a", & - "4fbc1767e9708c8", & - "cebf4f9796f4502", & - "9c76c880a864e67", & - "abc1c984f95244e", & - "795081690786ad8", & - "467f6710f357b3b", & - "1c380b14c9f4eae", & - "d5baf5aac386087", & - "bedc94df8c95c64", & - "553d0a8de2da1fa", & - "0315551d71d8ff0", & - "1c1eca2ffa25656", & - "d4bafdaad3c6087", & - "be2d5bfbb0da0be", & - "b0062659f3207f5", & - "5ffc1765e9708e8", & - "8d62e8bcd303e33", & - "cc08cf198e69bd4", & - "573d0a8de3da1fa", & - "cd56dce48639c2b", & - "472dc094546c2b2", & - "7950a16907868d8", & - "7283cf4b38308fb", & - "894ecf4de9b086e", & - "0f7580b47c792b3", & - "cfbf4b9796f4d0a", & - "3e380b14c974fae", & - "732d0085e3da1a3", & - "1816fcf59386717", & - "532d088fe3da1ab", & - "1c300b94c9fcaae", & - "d0a71c8c5b8ca19", & - "9e84bd3d5d78d09", & - "225083508ec830a", & - "f99abd1d12d0f31", & - "35f4aa19cb673c0", & - "cdd2dce48c39c2b", & - "0f7780b47c792bf", & - "0e33a5f114f5730", & - "bc05b4c4ab0d850", & - "1c300b14c9f4aae", & - "cfbc1e47ed708e8", & - "0f7180b47c392b3", & - "d8c7c115f91be12", & - "c09148adfa94e97", & - "9c66c880a844e67", & - "2226c13b73519f8", & - "cebf4b9796f4d02", & - "c0e706b031ee126", & - "6a6629715e53ce3", & - "73f9aa824e7d0b8", & - "473d80947c6c2b2", & - "1df140e0ddb5632", & - "473dc0945c6c2b2", & - "81b4d95f671971d", & - "663945ca758e2b6", & - "02ec3d98a2306fd", & - "5dadb0fa1275690", & - "4bb8aaa854948d0", & - "8359ba40886971c", & - "49cc3d2a2be2ee0", & - "bfdf13af137f318", & - "a1de773a2b1ff04", & - "8ff3945a2f465c7", & - "532d0087e3da1a3", & - "f3eaf7fa454d385", & - "a606aa5aeba07d9", & - "67f0627b0af8a53", & - "56698bed69d1c2c", & - "d5f420011fbf924", & - "2a8f86c810e2c62", & - "43cc1cf1208c206", & - "ee784c4900258de"/ - -data colorder/ & -0,1,2,3,4,5,6,7,8,9,10,11,123,12,13,14,15,16,17,18, & -19,20,21,22,23,24,25,138,26,145,27,28,29,30,31,32,33,34,35,36, & -37,154,38,39,40,41,42,43,44,144,46,47,48,49,50,51,52,53,143,54, & -125,56,57,58,124,59,120,140,157,160,55,60,61,62,156,162,141,64,65,153, & -181,183,66,170,67,68,69,130,70,164,71,72,73,74,75,63,76,77,135,78, & -79,80,176,169,82,83,84,167,180,85,136,158,129,166,175,142,134,146,121,165, & -88,89,192,90,45,91,92,93,182,189,94,95,96,173,81,97,98,178,122,126, & -132,99,100,152,186,193,101,102,151,103,104,172,159,168,150,190,147,148,201,107, & -205,177,108,198,197,174,127,109,185,110,202,87,199,171,179,187,139,137,106,131, & -206,194,112,149,155,113,128,184,196,86,114,203,212,195,208,105,188,161,163,191, & -200,209,214,204,115,218,133,111,207,117,213,216,211,217,116,215,219,220,210,221, & -118,222,223,225,224,228,226,229,231,227,233,119,234,235,232,230,237,239,236,238, & -240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259, & -260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, & -280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299/ - diff --git a/lib/fsk4hf/ldpcsim120.f90 b/lib/fsk4hf/ldpcsim120.f90 deleted file mode 100644 index 0b7d9286..00000000 --- a/lib/fsk4hf/ldpcsim120.f90 +++ /dev/null @@ -1,238 +0,0 @@ -program ldpcsim120 -! End to end test of the (120,60)/crc10 encoder and decoder. -use crc -use packjt - -parameter(NRECENT=10) -character*12 recent_calls(NRECENT) -character*22 msg,msgsent,msgreceived -character*8 arg -integer*1, allocatable :: codeword(:), decoded(:), message(:) -integer*1, target:: i1Msg8BitBytes(9) -integer*1, target:: i1Dec8BitBytes(9) -integer*1 msgbits(60) -integer*1 apmask(120) -integer*1 cw(120) -integer*2 checksum -integer colorder(120) -integer nerrtot(120),nerrdec(120),nmpcbad(60) -logical checksumok,fsk,bpsk -real*8, allocatable :: rxdata(:) -real, allocatable :: llr(:) -real dllr(120),llrd(120) - -data colorder/ & - 0,1,2,21,3,4,5,6,7,8,20,10,9,11,12,23,13,28,14,31, & - 15,16,22,26,17,30,18,29,25,32,41,34,19,33,27,36,38,43,42,24, & - 37,39,45,40,35,44,47,46,50,51,53,48,52,56,54,57,55,49,58,61, & - 60,59,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79, & - 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99, & - 100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119/ - -do i=1,NRECENT - recent_calls(i)=' ' -enddo -nerrtot=0 -nerrdec=0 -nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword - -nargs=iargc() -if(nargs.ne.3) then - print*,'Usage: ldpcsim niter #trials s ' - print*,'eg: ldpcsim 10 1000 0.84' - print*,'If s is negative, then value is ignored and sigma is calculated from SNR.' - return -endif -call getarg(1,arg) -read(arg,*) max_iterations -call getarg(2,arg) -read(arg,*) ntrials -call getarg(3,arg) -read(arg,*) s - -fsk=.false. -bpsk=.true. - -! don't count crc bits as data bits -N=120 -K=60 -! scale Eb/No for a (120,50) code -rate=real(50)/real(N) - -write(*,*) "rate: ",rate -write(*,*) "niter= ",max_iterations," s= ",s - -allocate ( codeword(N), decoded(K), message(K) ) -allocate ( rxdata(N), llr(N) ) - -! The message should be packed into the first 7 bytes - i1Msg8BitBytes(1:6)=85 - i1Msg8BitBytes(7)=64 -! The CRC will be put into the last 2 bytes - i1Msg8BitBytes(8:9)=0 - checksum = crc10 (c_loc (i1Msg8BitBytes), 9) -! For reference, the next 3 lines show how to check the CRC - i1Msg8BitBytes(8)=checksum/256 - i1Msg8BitBytes(9)=iand (checksum,255) - checksumok = crc10_check(c_loc (i1Msg8BitBytes), 9) - if( checksumok ) write(*,*) 'Good checksum' -write(*,*) i1Msg8BitBytes(1:9) - - mbit=0 - do i=1, 7 - i1=i1Msg8BitBytes(i) - do ibit=1,8 - mbit=mbit+1 - msgbits(mbit)=iand(1,ishft(i1,ibit-8)) - enddo - enddo - i1=i1Msg8BitBytes(8) ! First 2 bits of crc10 are LSB of this byte - do ibit=1,2 - msgbits(50+ibit)=iand(1,ishft(i1,ibit-2)) - enddo - i1=i1Msg8BitBytes(9) ! Now shift in last 8 bits of the CRC - do ibit=1,8 - msgbits(52+ibit)=iand(1,ishft(i1,ibit-8)) - enddo - - write(*,*) 'message' - write(*,'(9(8i1,1x))') msgbits - - call encode120(msgbits,codeword) - call init_random_seed() - call sgran() - - write(*,*) 'codeword' - write(*,'(15(8i1,1x))') codeword - -write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma" -do idb = -10, 24 - db=idb/2.0-1.0 -! sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) ! to make db represent Eb/No - sigma=1/sqrt( 2*(10**(db/10.0)) ) ! db represents Es/No - ngood=0 - nue=0 - nbadcrc=0 - nberr=0 - do itrial=1, ntrials -! Create a realization of a noisy received word - do i=1,N - if( bpsk ) then - rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran() - elseif( fsk ) then - if( codeword(i) .eq. 1 ) then - r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r2=(sigma*gran())**2 + (sigma*gran())**2 - elseif( codeword(i) .eq. 0 ) then - r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r1=(sigma*gran())**2 + (sigma*gran())**2 - endif - rxdata(i)=0.35*(sqrt(r1)-sqrt(r2)) -! rxdata(i)=0.35*(exp(r1)-exp(r2)) -! rxdata(i)=0.12*(log(r1)-log(r2)) - endif - enddo - nerr=0 - do i=1,N - if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1 - enddo - nerrtot(nerr)=nerrtot(nerr)+1 - nberr=nberr+nerr - -! Correct signal normalization is important for this decoder. -! rxav=sum(rxdata)/N -! rx2av=sum(rxdata*rxdata)/N -! rxsig=sqrt(rx2av-rxav*rxav) -! rxdata=rxdata/rxsig -! To match the metric to the channel, s should be set to the noise standard deviation. -! For now, set s to the value that optimizes decode probability near threshold. -! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of -! magnitude in UER - if( s .lt. 0 ) then - ss=sigma - else - ss=s - endif - - llr=2.0*rxdata/(ss*ss) - apmask=0 - -! max_iterations is max number of belief propagation iterations - call bpdecode120(llr, apmask, max_iterations, decoded, niterations, cw) - n2err=0 - do i=1,N - if( cw(i)*(2*codeword(i)-1.0) .lt. 0 ) n2err=n2err+1 - enddo -!write(*,*) nerr,niterations,n2err - damp=0.75 - ndither=0 - if( niterations .lt. 0 ) then - do i=1, ndither - do in=1,N - dllr(in)=damp*gran() - enddo - llrd=llr+dllr - call bpdecode120(llrd, apmask, max_iterations, decoded, niterations, cw) - if( niterations .ge. 0 ) exit - enddo - endif - -! If the decoder finds a valid codeword, niterations will be .ge. 0. - if( niterations .ge. 0 ) then -! Check the CRC - do ibyte=1,6 - itmp=0 - do ibit=1,8 - itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit)) - enddo - i1Dec8BitBytes(ibyte)=itmp - enddo - i1Dec8BitBytes(7)=decoded(49)*128+decoded(50)*64 -! Need to pack the received crc into bytes 8 and 9 for crc10_check - i1Dec8BitBytes(8)=decoded(51)*2+decoded(52) - i1Dec8BitBytes(9)=decoded(53)*128+decoded(54)*64+decoded(55)*32+decoded(56)*16 - i1Dec8BitBytes(9)=i1Dec8BitBytes(9)+decoded(57)*8+decoded(58)*4+decoded(59)*2+decoded(60)*1 - ncrcflag=0 - if( crc10_check( c_loc( i1Dec8BitBytes ), 9 ) ) ncrcflag=1 - - if( ncrcflag .ne. 1 ) then - nbadcrc=nbadcrc+1 - endif - nueflag=0 - - nerrmpc=0 - do i=1,K ! find number of errors in message+crc part of codeword - if( msgbits(i) .ne. decoded(i) ) then - nueflag=1 - nerrmpc=nerrmpc+1 - endif - enddo - nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1 ! This histogram should inform our selection of CRC poly - if( ncrcflag .eq. 1 .and. nueflag .eq. 0 ) then - ngood=ngood+1 - nerrdec(nerr)=nerrdec(nerr)+1 - else if( ncrcflag .eq. 1 .and. nueflag .eq. 1 ) then - nue=nue+1; - endif - endif - enddo - snr2500=db+10*log10(0.4166/2500.0) - pberr=real(nberr)/(real(ntrials*N)) - write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr - -enddo - -open(unit=23,file='nerrhisto.dat',status='unknown') -do i=1,120 - write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10) -enddo -close(23) -open(unit=25,file='nmpcbad.dat',status='unknown') -do i=1,60 - write(25,'(i4,2x,i10)') i,nmpcbad(i) -enddo -close(25) - - - -end program ldpcsim120 diff --git a/lib/fsk4hf/ldpcsim168.f90 b/lib/fsk4hf/ldpcsim168.f90 deleted file mode 100644 index a1aee3eb..00000000 --- a/lib/fsk4hf/ldpcsim168.f90 +++ /dev/null @@ -1,233 +0,0 @@ -program ldpcsim168 -! End to end test of the (168,84)/crc12 encoder and decoder. -use crc -use packjt - -parameter(NRECENT=10) -character*12 recent_calls(NRECENT) -character*22 msg,msgsent,msgreceived -character*8 arg -integer*1, allocatable :: codeword(:), decoded(:), message(:) -integer*1, target:: i1Msg8BitBytes(11) -integer*1 msgbits(84) -integer*1 apmask(168), cw(168) -integer*2 checksum -integer*4 i4Msg6BitWords(13) -integer colorder(168) -integer nerrtot(168),nerrdec(168),nmpcbad(84) -logical checksumok,fsk,bpsk -real*8, allocatable :: rxdata(:) -real, allocatable :: llr(:) - -data colorder/0,1,2,3,28,4,5,6,7,8,9,10,11,34,12,32,13,14,15,16,17, & - 18,36,29,42,31,20,21,41,40,30,38,22,19,47,37,46,35,44,33,49,24, & - 43,51,25,26,27,50,52,57,69,54,55,45,59,58,56,61,60,53,48,23,62, & - 63,64,67,66,65,68,39,70,71,72,74,73,75,76,77,80,81,78,82,79,83, & - 84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104, & - 105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, & - 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146, & - 147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167/ - -do i=1,NRECENT - recent_calls(i)=' ' -enddo -nerrtot=0 -nerrdec=0 -nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword - -nargs=iargc() -if(nargs.ne.3) then - print*,'Usage: ldpcsim niter #trials s ' - print*,'eg: ldpcsim 10 1000 0.84' - print*,'If s is negative, then value is ignored and sigma is calculated from SNR.' - return -endif -call getarg(1,arg) -read(arg,*) max_iterations -call getarg(2,arg) -read(arg,*) ntrials -call getarg(3,arg) -read(arg,*) s - -fsk=.false. -bpsk=.true. - -! don't count crc bits as data bits -N=168 -K=84 -! scale Eb/No for a (168,72) code -rate=real(72)/real(N) - -write(*,*) "rate: ",rate -write(*,*) "niter= ",max_iterations," s= ",s - -allocate ( codeword(N), decoded(K), message(K) ) -allocate ( rxdata(N), llr(N) ) - -! msg="K1JT K9AN EN50" - msg="G4WJS K9AN EN50" - call packmsg(msg,i4Msg6BitWords,itype,.false.) !Pack into 12 6-bit bytes - call unpackmsg(i4Msg6BitWords,msgsent,.false.,'') !Unpack to get msgsent - write(*,*) "message sent ",msgsent - - i4=0 - ik=0 - im=0 - do i=1,12 - nn=i4Msg6BitWords(i) - do j=1, 6 - ik=ik+1 - i4=i4+i4+iand(1,ishft(nn,j-6)) - i4=iand(i4,255) - if(ik.eq.8) then - im=im+1 -! if(i4.gt.127) i4=i4-256 - i1Msg8BitBytes(im)=i4 - ik=0 - endif - enddo - enddo - - i1Msg8BitBytes(10:11)=0 - checksum = crc12 (c_loc (i1Msg8BitBytes), 11) -! For reference, the next 3 lines show how to check the CRC - i1Msg8BitBytes(10)=checksum/256 - i1Msg8BitBytes(11)=iand (checksum,255) - checksumok = crc12_check(c_loc (i1Msg8BitBytes), 11) - if( checksumok ) write(*,*) 'Good checksum' - - mbit=0 - do i=1, 9 - i1=i1Msg8BitBytes(i) - do ibit=1,8 - mbit=mbit+1 - msgbits(mbit)=iand(1,ishft(i1,ibit-8)) - enddo - enddo - i1=i1Msg8BitBytes(10) ! First 4 bits of crc12 are LSB of this byte - do ibit=1,4 - msgbits(72+ibit)=iand(1,ishft(i1,ibit-4)) - enddo - i1=i1Msg8BitBytes(11) ! Now shift in last 8 bits of the CRC - do ibit=1,8 - msgbits(76+ibit)=iand(1,ishft(i1,ibit-8)) - enddo - - write(*,*) 'message' - write(*,'(11(8i1,1x))') msgbits - - call encode168(msgbits,codeword) - call init_random_seed() - call sgran() - - write(*,*) 'codeword' - write(*,'(21(8i1,1x))') codeword - -write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma" -do idb = 6,-6,-1 - db=idb/2.0-1.0 - sigma=1/sqrt( 2*(10**(db/10.0)) ) - ngood=0 - nue=0 - nbadcrc=0 - nberr=0 - do itrial=1, ntrials -! Create a realization of a noisy received word - do i=1,N - if( bpsk ) then - rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran() - elseif( fsk ) then - if( codeword(i) .eq. 1 ) then - r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r2=(sigma*gran())**2 + (sigma*gran())**2 - elseif( codeword(i) .eq. 0 ) then - r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r1=(sigma*gran())**2 + (sigma*gran())**2 - endif - rxdata(i)=0.35*(sqrt(r1)-sqrt(r2)) -! rxdata(i)=0.35*(exp(r1)-exp(r2)) -! rxdata(i)=0.12*(log(r1)-log(r2)) - endif - enddo - nerr=0 - do i=1,N - if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1 - enddo - nerrtot(nerr)=nerrtot(nerr)+1 - nberr=nberr+nerr - -! Correct signal normalization is important for this decoder. -! rxav=sum(rxdata)/N -! rx2av=sum(rxdata*rxdata)/N -! rxsig=sqrt(rx2av-rxav*rxav) -! rxdata=rxdata/rxsig -! To match the metric to the channel, s should be set to the noise standard deviation. -! For now, set s to the value that optimizes decode probability near threshold. -! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of -! magnitude in UER - if( s .lt. 0 ) then - ss=sigma - else - ss=s - endif - - llr=2.0*rxdata/(ss*ss) - nap=0 ! number of AP bits - llr(colorder(168-84+1:168-84+nap)+1)=5*(2.0*msgbits(1:nap)-1.0) - apmask=0 - apmask(colorder(168-84+1:168-84+nap)+1)=1 - -! max_iterations is max number of belief propagation iterations - call bpdecode168(llr, apmask, max_iterations, decoded, niterations) -! if( niterations .eq. -1 ) then -! norder=3 -! call osd168(llr, norder, decoded, niterations, cw) -! endif -! If the decoder finds a valid codeword, niterations will be .ge. 0. - if( niterations .ge. 0 ) then - call extractmessage168(decoded,msgreceived,ncrcflag,recent_calls,nrecent) - if( ncrcflag .ne. 1 ) then - nbadcrc=nbadcrc+1 - endif - - nueflag=0 - nerrmpc=0 - do i=1,K ! find number of errors in message+crc part of codeword - if( msgbits(i) .ne. decoded(i) ) then - nueflag=1 - nerrmpc=nerrmpc+1 - endif - enddo - -write(37,*) niterations, ncrcflag, nueflag - nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1 - if( ncrcflag .eq. 1 ) then - if( nueflag .eq. 0 ) then - ngood=ngood+1 - nerrdec(nerr)=nerrdec(nerr)+1 - else if( nueflag .eq. 1 ) then - nue=nue+1; - endif - endif - endif - enddo - snr2500=db+10*log10(10.417/2500.0) - pberr=real(nberr)/(real(ntrials*N)) - write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr - -enddo - -open(unit=23,file='nerrhisto.dat',status='unknown') -do i=1,168 - write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10) -enddo -close(23) -open(unit=25,file='nmpcbad.dat',status='unknown') -do i=1,84 - write(25,'(i4,2x,i10)') i,nmpcbad(i) -enddo -close(25) - - - -end program ldpcsim168 diff --git a/lib/fsk4hf/ldpcsim204.f90 b/lib/fsk4hf/ldpcsim204.f90 deleted file mode 100644 index 794b1476..00000000 --- a/lib/fsk4hf/ldpcsim204.f90 +++ /dev/null @@ -1,249 +0,0 @@ -program ldpcsim204 - -! End-to-end test of the (300,60)/crc10 encoder and decoders. - -use crc -use packjt - -parameter(NRECENT=10) -character*12 recent_calls(NRECENT) -character*8 arg -integer*1, allocatable :: codeword(:), decoded(:), message(:) -integer*1, target:: i1Msg8BitBytes(9) -integer*1, target:: i1Dec8BitBytes(9) -integer*1 msgbits(68) -integer*1 apmask(204) -integer*1 cw(204) -integer*2 checksum -integer colorder(204) -integer nerrtot(204),nerrdec(204),nmpcbad(68) -logical checksumok,fsk,bpsk -real*8, allocatable :: rxdata(:) -real, allocatable :: llr(:) -real dllr(204),llrd(204) - -data colorder/ & - 0, 1, 2, 3, 4, 5, 47, 6, 7, 8, 9, 10, 11, 12, 58, 55, 13, & - 14, 15, 46, 17, 18, 60, 19, 20, 21, 22, 23, 24, 25, 57, 26, 27, 49, & - 28, 52, 65, 16, 50, 73, 59, 68, 63, 29, 30, 31, 32, 51, 62, 56, 66, & - 45, 33, 34, 53, 67, 35, 36, 37, 61, 69, 54, 38, 71, 82, 39, 77, 80, & - 83, 78, 84, 48, 41, 85, 40, 64, 75, 96, 74, 72, 76, 86, 87, 89, 90, & - 79, 70, 92, 99, 93,101, 95,100, 97, 94, 42, 98,103,105,102, 43,104, & - 88, 44,106, 81,107,110,108,111,112,109,113,114,117,118,116,121,115, & - 119,122,120,125,129,124,127,126,128, 91,123,133,131,130,134,135,137, & - 136,132,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152, & - 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169, & - 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186, & - 187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203/ - -do i=1,NRECENT - recent_calls(i)=' ' -enddo -nerrtot=0 -nerrdec=0 -nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword - -nargs=iargc() -if(nargs.ne.4) then - print*,'Usage: ldpcsim niter ndeep #trials s ' - print*,'eg: ldpcsim 100 4 1000 0.84' - print*,'If s is negative, then value is ignored and sigma is calculated from SNR.' - return -endif -call getarg(1,arg) -read(arg,*) max_iterations -call getarg(2,arg) -read(arg,*) ndeep -call getarg(3,arg) -read(arg,*) ntrials -call getarg(4,arg) -read(arg,*) s - -fsk=.false. -bpsk=.true. - -N=204 -K=68 -rate=real(K)/real(N) - -write(*,*) "rate: ",rate -write(*,*) "niter= ",max_iterations," s= ",s - -allocate ( codeword(N), decoded(K), message(K) ) -allocate ( rxdata(N), llr(N) ) - -! The message should be packed into the first 7 bytes - i1Msg8BitBytes(1:6)=85 - i1Msg8BitBytes(7)=64 -! The CRC will be put into the last 2 bytes - i1Msg8BitBytes(8:9)=0 - checksum = crc10 (c_loc (i1Msg8BitBytes), 9) -! For reference, the next 3 lines show how to check the CRC - i1Msg8BitBytes(8)=checksum/256 - i1Msg8BitBytes(9)=iand (checksum,255) - checksumok = crc10_check(c_loc (i1Msg8BitBytes), 9) - if( checksumok ) write(*,*) 'Good checksum' -write(*,*) i1Msg8BitBytes(1:9) - - mbit=0 - do i=1, 7 - i1=i1Msg8BitBytes(i) - do ibit=1,8 - mbit=mbit+1 - msgbits(mbit)=iand(1,ishft(i1,ibit-8)) - enddo - enddo - i1=i1Msg8BitBytes(8) ! First 2 bits of crc10 are LSB of this byte - do ibit=1,2 - msgbits(50+ibit)=iand(1,ishft(i1,ibit-2)) - enddo - i1=i1Msg8BitBytes(9) ! Now shift in last 8 bits of the CRC - do ibit=1,8 - msgbits(52+ibit)=iand(1,ishft(i1,ibit-8)) - enddo - - write(*,*) 'message' - write(*,'(9(8i1,1x))') msgbits - - call encode204(msgbits,codeword) - call init_random_seed() - call sgran() - - write(*,*) 'codeword' - write(*,'(204i1)') codeword - -write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma" -do idb = 20,-18,-1 -!do idb = -16, -16, -1 - db=idb/2.0-1.0 -! sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) ! to make db represent Eb/No - sigma=1/sqrt( 2*(10**(db/10.0)) ) ! db represents Es/No - ngood=0 - nue=0 - nbadcrc=0 - nberr=0 - do itrial=1, ntrials -! Create a realization of a noisy received word - do i=1,N - if( bpsk ) then - rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran() - elseif( fsk ) then - if( codeword(i) .eq. 1 ) then - r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r2=(sigma*gran())**2 + (sigma*gran())**2 - elseif( codeword(i) .eq. 0 ) then - r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r1=(sigma*gran())**2 + (sigma*gran())**2 - endif - rxdata(i)=0.35*(sqrt(r1)-sqrt(r2)) -! rxdata(i)=0.35*(exp(r1)-exp(r2)) -! rxdata(i)=0.12*(log(r1)-log(r2)) - endif - enddo - nerr=0 - do i=1,N - if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1 - enddo - if(nerr.ge.1) nerrtot(nerr)=nerrtot(nerr)+1 - nberr=nberr+nerr - -! Correct signal normalization is important for this decoder. - rxav=sum(rxdata)/N - rx2av=sum(rxdata*rxdata)/N - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig -! To match the metric to the channel, s should be set to the noise standard deviation. -! For now, set s to the value that optimizes decode probability near threshold. -! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of -! magnitude in UER - if( s .lt. 0 ) then - ss=sigma - else - ss=s - endif - - llr=2.0*rxdata/(ss*ss) - apmask=0 -! max_iterations is max number of belief propagation iterations - call bpdecode204(llr,apmask,max_iterations,decoded,cw,nharderror,niterations) - if( (nharderror .lt. 0) .and. (ndeep .ge. 0) ) then - call osd204(llr, apmask, ndeep, decoded, cw, nhardmin, dmin) - niterations=nhardmin - endif - n2err=0 - do i=1,N - if( cw(i)*(2*codeword(i)-1.0) .lt. 0 ) n2err=n2err+1 - enddo -!write(*,*) nerr,niterations,n2err - damp=0.75 - ndither=0 - if( niterations .lt. 0 ) then - do i=1, ndither - do in=1,N - dllr(in)=damp*gran() - enddo - llrd=llr+dllr - call bpdecode300(llrd, apmask, max_iterations, decoded, cw, nharderror, niterations) - if( niterations .ge. 0 ) exit - enddo - endif - -! If the decoder finds a valid codeword, niterations will be .ge. 0. - if( niterations .ge. 0 ) then -! Check the CRC - do ibyte=1,6 - itmp=0 - do ibit=1,8 - itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit)) - enddo - i1Dec8BitBytes(ibyte)=itmp - enddo - i1Dec8BitBytes(7)=decoded(49)*128+decoded(50)*64 -! Need to pack the received crc into bytes 8 and 9 for crc10_check - i1Dec8BitBytes(8)=decoded(51)*2+decoded(52) - i1Dec8BitBytes(9)=decoded(53)*128+decoded(54)*64+decoded(55)*32+decoded(56)*16 - i1Dec8BitBytes(9)=i1Dec8BitBytes(9)+decoded(57)*8+decoded(58)*4+decoded(59)*2+decoded(60)*1 - ncrcflag=0 - if( crc10_check( c_loc( i1Dec8BitBytes ), 9 ) ) ncrcflag=1 - - if( ncrcflag .ne. 1 ) then - nbadcrc=nbadcrc+1 - endif - nueflag=0 - - nerrmpc=0 - do i=1,K ! find number of errors in message+crc part of codeword - if( msgbits(i) .ne. decoded(i) ) then - nueflag=1 - nerrmpc=nerrmpc+1 - endif - enddo - if(nerrmpc.ge.1) nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1 ! This histogram should inform our selection of CRC poly - if( ncrcflag .eq. 1 .and. nueflag .eq. 0 ) then - ngood=ngood+1 - if(nerr.ge.1) nerrdec(nerr)=nerrdec(nerr)+1 - else if( ncrcflag .eq. 1 .and. nueflag .eq. 1 ) then - nue=nue+1; - endif - endif - enddo - snr2500=db+10*log10(200.0/116.0/2500.0) - pberr=real(nberr)/(real(ntrials*N)) - write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr - -enddo - -open(unit=23,file='nerrhisto.dat',status='unknown') -do i=1,120 - write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10) -enddo -close(23) -open(unit=25,file='nmpcbad.dat',status='unknown') -do i=1,68 - write(25,'(i4,2x,i10)') i,nmpcbad(i) -enddo -close(25) - - - -end program ldpcsim204 diff --git a/lib/fsk4hf/ldpcsim300.f90 b/lib/fsk4hf/ldpcsim300.f90 deleted file mode 100644 index cfd28a78..00000000 --- a/lib/fsk4hf/ldpcsim300.f90 +++ /dev/null @@ -1,254 +0,0 @@ -program ldpcsim300 - -! End-to-end test of the (300,60)/crc10 encoder and decoders. - -use crc -use packjt - -parameter(NRECENT=10) -character*12 recent_calls(NRECENT) -character*8 arg -integer*1, allocatable :: codeword(:), decoded(:), message(:) -integer*1, target:: i1Msg8BitBytes(9) -integer*1, target:: i1Dec8BitBytes(9) -integer*1 msgbits(60) -integer*1 apmask(300) -integer*1 cw(300) -integer*2 checksum -integer colorder(300) -integer nerrtot(300),nerrdec(300),nmpcbad(60) -logical checksumok,fsk,bpsk -real*8, allocatable :: rxdata(:) -real, allocatable :: llr(:) -real dllr(300),llrd(300) - -data colorder/ & -0,1,2,3,4,5,6,7,8,9,10,11,123,12,13,14,15,16,17,18, & -19,20,21,22,23,24,25,138,26,145,27,28,29,30,31,32,33,34,35,36, & -37,154,38,39,40,41,42,43,44,144,46,47,48,49,50,51,52,53,143,54, & -125,56,57,58,124,59,120,140,157,160,55,60,61,62,156,162,141,64,65,153, & -181,183,66,170,67,68,69,130,70,164,71,72,73,74,75,63,76,77,135,78, & -79,80,176,169,82,83,84,167,180,85,136,158,129,166,175,142,134,146,121,165, & -88,89,192,90,45,91,92,93,182,189,94,95,96,173,81,97,98,178,122,126, & -132,99,100,152,186,193,101,102,151,103,104,172,159,168,150,190,147,148,201,107, & -205,177,108,198,197,174,127,109,185,110,202,87,199,171,179,187,139,137,106,131, & -206,194,112,149,155,113,128,184,196,86,114,203,212,195,208,105,188,161,163,191, & -200,209,214,204,115,218,133,111,207,117,213,216,211,217,116,215,219,220,210,221, & -118,222,223,225,224,228,226,229,231,227,233,119,234,235,232,230,237,239,236,238, & -240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259, & -260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, & -280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299/ - -do i=1,NRECENT - recent_calls(i)=' ' -enddo -nerrtot=0 -nerrdec=0 -nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword - -nargs=iargc() -if(nargs.ne.4) then - print*,'Usage: ldpcsim niter ndeep #trials s ' - print*,'eg: ldpcsim 100 4 1000 0.84' - print*,'If s is negative, then value is ignored and sigma is calculated from SNR.' - return -endif -call getarg(1,arg) -read(arg,*) max_iterations -call getarg(2,arg) -read(arg,*) ndeep -call getarg(3,arg) -read(arg,*) ntrials -call getarg(4,arg) -read(arg,*) s - -fsk=.false. -bpsk=.true. - -! don't count crc bits as data bits -N=300 -K=60 -! scale Eb/No for a (300,50) code -rate=real(50)/real(N) - -write(*,*) "rate: ",rate -write(*,*) "niter= ",max_iterations," s= ",s - -allocate ( codeword(N), decoded(K), message(K) ) -allocate ( rxdata(N), llr(N) ) - -! The message should be packed into the first 7 bytes - i1Msg8BitBytes(1:6)=85 - i1Msg8BitBytes(7)=64 -! The CRC will be put into the last 2 bytes - i1Msg8BitBytes(8:9)=0 - checksum = crc10 (c_loc (i1Msg8BitBytes), 9) -! For reference, the next 3 lines show how to check the CRC - i1Msg8BitBytes(8)=checksum/256 - i1Msg8BitBytes(9)=iand (checksum,255) - checksumok = crc10_check(c_loc (i1Msg8BitBytes), 9) - if( checksumok ) write(*,*) 'Good checksum' -write(*,*) i1Msg8BitBytes(1:9) - - mbit=0 - do i=1, 7 - i1=i1Msg8BitBytes(i) - do ibit=1,8 - mbit=mbit+1 - msgbits(mbit)=iand(1,ishft(i1,ibit-8)) - enddo - enddo - i1=i1Msg8BitBytes(8) ! First 2 bits of crc10 are LSB of this byte - do ibit=1,2 - msgbits(50+ibit)=iand(1,ishft(i1,ibit-2)) - enddo - i1=i1Msg8BitBytes(9) ! Now shift in last 8 bits of the CRC - do ibit=1,8 - msgbits(52+ibit)=iand(1,ishft(i1,ibit-8)) - enddo - - write(*,*) 'message' - write(*,'(9(8i1,1x))') msgbits - - call encode300(msgbits,codeword) - call init_random_seed() - call sgran() - - write(*,*) 'codeword' - write(*,'(38(8i1,1x))') codeword - -write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma" -do idb = 20,-16,-1 -!do idb = -16, -16, -1 - db=idb/2.0-1.0 -! sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) ! to make db represent Eb/No - sigma=1/sqrt( 2*(10**(db/10.0)) ) ! db represents Es/No - ngood=0 - nue=0 - nbadcrc=0 - nberr=0 - do itrial=1, ntrials -! Create a realization of a noisy received word - do i=1,N - if( bpsk ) then - rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran() - elseif( fsk ) then - if( codeword(i) .eq. 1 ) then - r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r2=(sigma*gran())**2 + (sigma*gran())**2 - elseif( codeword(i) .eq. 0 ) then - r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r1=(sigma*gran())**2 + (sigma*gran())**2 - endif - rxdata(i)=0.35*(sqrt(r1)-sqrt(r2)) -! rxdata(i)=0.35*(exp(r1)-exp(r2)) -! rxdata(i)=0.12*(log(r1)-log(r2)) - endif - enddo - nerr=0 - do i=1,N - if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1 - enddo - if(nerr.ge.1) nerrtot(nerr)=nerrtot(nerr)+1 - nberr=nberr+nerr - -! Correct signal normalization is important for this decoder. - rxav=sum(rxdata)/N - rx2av=sum(rxdata*rxdata)/N - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig -! To match the metric to the channel, s should be set to the noise standard deviation. -! For now, set s to the value that optimizes decode probability near threshold. -! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of -! magnitude in UER - if( s .lt. 0 ) then - ss=sigma - else - ss=s - endif - - llr=2.0*rxdata/(ss*ss) - apmask=0 -! max_iterations is max number of belief propagation iterations - call bpdecode300(llr, apmask, max_iterations, decoded, niterations, cw) - if( (niterations .lt. 0) .and. (ndeep .ge. 0) ) then - call osd300(llr, apmask, ndeep, decoded, cw, nhardmin, dmin) - niterations=nhardmin - endif - n2err=0 - do i=1,N - if( cw(i)*(2*codeword(i)-1.0) .lt. 0 ) n2err=n2err+1 - enddo -!write(*,*) nerr,niterations,n2err - damp=0.75 - ndither=0 - if( niterations .lt. 0 ) then - do i=1, ndither - do in=1,N - dllr(in)=damp*gran() - enddo - llrd=llr+dllr - call bpdecode300(llrd, apmask, max_iterations, decoded, niterations, cw) - if( niterations .ge. 0 ) exit - enddo - endif - -! If the decoder finds a valid codeword, niterations will be .ge. 0. - if( niterations .ge. 0 ) then -! Check the CRC - do ibyte=1,6 - itmp=0 - do ibit=1,8 - itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit)) - enddo - i1Dec8BitBytes(ibyte)=itmp - enddo - i1Dec8BitBytes(7)=decoded(49)*128+decoded(50)*64 -! Need to pack the received crc into bytes 8 and 9 for crc10_check - i1Dec8BitBytes(8)=decoded(51)*2+decoded(52) - i1Dec8BitBytes(9)=decoded(53)*128+decoded(54)*64+decoded(55)*32+decoded(56)*16 - i1Dec8BitBytes(9)=i1Dec8BitBytes(9)+decoded(57)*8+decoded(58)*4+decoded(59)*2+decoded(60)*1 - ncrcflag=0 - if( crc10_check( c_loc( i1Dec8BitBytes ), 9 ) ) ncrcflag=1 - - if( ncrcflag .ne. 1 ) then - nbadcrc=nbadcrc+1 - endif - nueflag=0 - - nerrmpc=0 - do i=1,K ! find number of errors in message+crc part of codeword - if( msgbits(i) .ne. decoded(i) ) then - nueflag=1 - nerrmpc=nerrmpc+1 - endif - enddo - if(nerrmpc.ge.1) nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1 ! This histogram should inform our selection of CRC poly - if( ncrcflag .eq. 1 .and. nueflag .eq. 0 ) then - ngood=ngood+1 - if(nerr.ge.1) nerrdec(nerr)=nerrdec(nerr)+1 - else if( ncrcflag .eq. 1 .and. nueflag .eq. 1 ) then - nue=nue+1; - endif - endif - enddo - snr2500=db+10*log10(1.389/2500.0) - pberr=real(nberr)/(real(ntrials*N)) - write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr - -enddo - -open(unit=23,file='nerrhisto.dat',status='unknown') -do i=1,120 - write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10) -enddo -close(23) -open(unit=25,file='nmpcbad.dat',status='unknown') -do i=1,60 - write(25,'(i4,2x,i10)') i,nmpcbad(i) -enddo -close(25) - - - -end program ldpcsim300 diff --git a/lib/fsk4hf/mskhfsim.f90 b/lib/fsk4hf/mskhfsim.f90 deleted file mode 100644 index 86140e1c..00000000 --- a/lib/fsk4hf/mskhfsim.f90 +++ /dev/null @@ -1,194 +0,0 @@ -program msksim - -! Simulate characteristics of a potential "MSK10" mode using LDPC (168,84) -! code, OQPDK modulation, and 30 s T/R sequences. - -! Reception and Demodulation algorithm: -! 1. Compute coarse spectrum; find fc1 = approx carrier freq -! 2. Mix from fc1 to 0; LPF at +/- 0.75*R -! 3. Square, FFT; find peaks near -R/2 and +R/2 to get fc2 -! 4. Mix from fc2 to 0 -! 5. Fit cb13 (central part of csync) to c -> lag, phase -! 6. Fit complex ploynomial for channel equalization -! 7. Get soft bits from equalized data - - parameter (KK=84) !Information bits (72 + CRC12) - parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2 - parameter (NS=65) !Sync symbols (2 x 26 + Barker 13) - parameter (NR=3) !Ramp up/down - parameter (NN=NR+NS+ND) !Total symbols (236) - parameter (NSPS=1152/72) !Samples per MSK symbol (16) - parameter (N2=2*NSPS) !Samples per OQPSK symbol (32) - parameter (N13=13*N2) !Samples in central sync vector (416) - parameter (NZ=NSPS*NN) !Samples in baseband waveform (3776) - parameter (NFFT1=4*NSPS,NH1=NFFT1/2) - - character*8 arg - complex cbb(0:NZ-1) !Complex baseband waveform - complex csync(0:NZ-1) !Sync symbols only, from cbb - complex cb13(0:N13-1) !Barker 13 waveform - complex c(0:NZ-1) !Complex waveform - complex c0(0:NZ-1) !Complex waveform - complex zz(NS+ND) !Complex symbol values (intermediate) - complex z - real xnoise(0:NZ-1) !Generated random noise - real ynoise(0:NZ-1) !Generated random noise - real rxdata(ND),llr(ND) !Soft symbols - real pp(2*NSPS) !Shaped pulse for OQPSK - real a(5) !For twkfreq1 - real aa(20),bb(20) !Fitted polyco's - integer id(NS+ND) !NRZ values (+/-1) for Sync and Data - integer ierror(NS+ND) - integer icw(NN) - integer*1 msgbits(KK),decoded(KK),apmask(ND),cw(ND) -! integer*1 codeword(ND) - data msgbits/0,0,1,0,0,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,1, & - 1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,1,1,0,1,0,1,1,1,0,1,1,0,1,1, & - 1,1,0,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,1,0/ - - nargs=iargc() - if(nargs.ne.6) then - print*,'Usage: mskhfsim f0(Hz) delay(ms) fspread(Hz) maxn iters snr(dB)' - print*,'Example: mskhfsim 0 0 0 5 10 -20' - print*,'Set snr=0 to cycle through a range' - go to 999 - endif - call getarg(1,arg) - read(arg,*) f0 !Generated carrier frequency - call getarg(2,arg) - read(arg,*) delay !Delta_t (ms) for Watterson model - call getarg(3,arg) - read(arg,*) fspread !Fspread (Hz) for Watterson model - call getarg(4,arg) - read(arg,*) maxn !Max nterms for polyfit - call getarg(5,arg) - read(arg,*) iters !Iterations at each SNR - call getarg(6,arg) - read(arg,*) snrdb !Specified SNR_2500 - - twopi=8.0*atan(1.0) - fs=12000.0/72.0 !Sample rate = 166.6666667 Hz - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - ts=2*NSPS*dt !Duration of OQPSK symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - bandwidth_ratio=2500.0/(fs/2.0) - write(*,1000) f0,delay,fspread,maxn,iters,baud,3*baud,txt -1000 format('f0:',f5.1,' Delay:',f4.1,' fSpread:',f5.2,' maxn:',i3, & - ' Iters:',i6/'Baud:',f7.3,' BW:',f5.1,' TxT:',f5.1,f5.2/) - write(*,1004) -1004 format(/' SNR err ber fer fsigma'/37('-')) - - do i=1,N2 !Half-sine pulse shape - pp(i)=sin(0.5*(i-1)*twopi/(2*NSPS)) - enddo - - call genmskhf(msgbits,id,icw,cbb,csync)!Generate baseband waveform and csync - cb13=csync(1680:2095) !Copy the Barker 13 waveform - a=0. - a(1)=f0 - call twkfreq1(cbb,NZ,fs,a,cbb) !Mix to specified frequency - - isna=-10 - isnb=-30 - if(snrdb.ne.0.0) then - isna=nint(snrdb) - isnb=isna - endif - do isnr=isna,isnb,-1 !Loop over SNR range - snrdb=isnr - sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - nhard=0 - nhardsync=0 - nfe=0 - sqf=0. - do iter=1,iters !Loop over requested iterations - c=cbb - if(delay.ne.0.0 .or. fspread.ne.0.0) then - call watterson(c,NZ,fs,delay,fspread) - endif - c=sig*c !Scale to requested SNR - if(snrdb.lt.90) then - do i=0,NZ-1 !Generate gaussian noise - xnoise(i)=gran() - ynoise(i)=gran() - enddo - c=c + cmplx(xnoise,ynoise) !Add AWGN noise - endif - - call getfc1(c,fc1) !First approx for freq - call getfc2(c,csync,fc1,fc2,fc3) !Refined freq - sqf=sqf + (fc1+fc2-f0)**2 - -!NB: Measured performance is about equally good using fc2 or fc3 here: - a(1)=-(fc1+fc2) - a(2:5)=0. - call twkfreq1(c,NZ,fs,a,c) !Mix c down by fc1+fc2 - -! The following may not be necessary? -! z=sum(c(1680:2095)*cb13)/208.0 !Get phase from Barker 13 vector -! z0=z/abs(z) -! c=c*conjg(z0) - -!---------------------------------------------------------------- DT -! Not presently used: - amax=0. - jpk=0 - do j=-20*NSPS,20*NSPS !Get jpk - z=sum(c(1680+j:2095+j)*cb13)/208.0 - if(abs(z).gt.amax) then - amax=abs(z) - jpk=j - endif - enddo - xdt=jpk/fs - - nterms=maxn - c0=c - do itry=1,10 - idf=itry/2 - if(mod(itry,2).eq.0) idf=-idf - nhard0=0 - nhardsync0=0 - ifer=1 - a(1)=idf*0.01 - a(2:5)=0. - call twkfreq1(c0,NZ,fs,a,c) !Mix c0 into c - call cpolyfit(c,pp,id,maxn,aa,bb,zz,nhs) - call msksoftsym(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0) - if(nhardsync0.gt.12) cycle - rxav=sum(rxdata)/ND - rx2av=sum(rxdata*rxdata)/ND - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - ss=0.84 - llr=2.0*rxdata/(ss*ss) - apmask=0 - max_iterations=40 - ifer=0 - call bpdecode168(llr,apmask,max_iterations,decoded,niterations,cw) - nbadcrc=0 - if(niterations.ge.0) call chkcrc12(decoded,nbadcrc) - if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0 .or. & - nbadcrc.ne.0) ifer=1 -! if(ifer.eq.0) write(67,1301) snrdb,itry,idf,niterations, & -! nhardsync0,nhard0 -!1301 format(f6.1,5i6) - if(ifer.eq.0) exit - enddo !Freq dither loop - nhard=nhard+nhard0 - nhardsync=nharsdync+nhardsync0 - nfe=nfe+ifer - enddo - - fsigma=sqrt(sqf/iters) - ber=float(nhard)/((NS+ND)*iters) - fer=float(nfe)/iters - write(*,1050) snrdb,nhard,ber,fer,fsigma -! write(60,1050) snrdb,nhard,ber,fer,fsigma -1050 format(f6.1,i7,f8.4,f7.3,f8.2) - enddo - -999 end program msksim diff --git a/lib/fsk4hf/msksoftsym.f90 b/lib/fsk4hf/msksoftsym.f90 deleted file mode 100644 index 016b23e1..00000000 --- a/lib/fsk4hf/msksoftsym.f90 +++ /dev/null @@ -1,81 +0,0 @@ -subroutine msksoftsym(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (N13=13*N2) !Samples in central sync vector (416)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z,z0
- real rxdata(ND) !Soft symbols
- real aa(20),bb(20) !Fitted polyco's
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
- integer ierror(NS+ND)
-
- n=0
- ierror=0
- do j=1,117
- xx=j*2.0/117.0 - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=real(z)
- if(abs(id(j)).eq.2) then
- if(real(z)*id(j).lt.0) then !Sync bit
- nhardsync0=nhardsync0+1
- ierror(j)=2
- endif
- else
- n=n+1 !Data bit
- rxdata(n)=p
- ierr=0
- if(id(j)*p.lt.0) then
- ierr=1
- ierror(j)=1
- endif
- nhard0=nhard0+ierr
- endif
- enddo
-
- do j=118,233
- xx=(j-116.5)*2.0/117.0 - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=aimag(z)
- n=n+1
- rxdata(n)=p
- ierr=0
- if(id(j)*p.lt.0) then
- ierr=1
- ierror(j)=1
- endif
- nhard0=nhard0+ierr
- enddo
-
- return
-end subroutine msksoftsym
diff --git a/lib/fsk4hf/msksoftsymw.f90 b/lib/fsk4hf/msksoftsymw.f90 deleted file mode 100644 index c7402ec4..00000000 --- a/lib/fsk4hf/msksoftsymw.f90 +++ /dev/null @@ -1,78 +0,0 @@ -subroutine msksoftsymw(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0)
-
- include 'wsprlf_params.f90'
-
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z,z0
- real rxdata(ND) !Soft symbols
- real aa(20),bb(20) !Fitted polyco's
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
- integer ierror(NS+ND)
-
- n=0
- ierror=0
- ierr=0
- jz=(NS+ND+1)/2
- do j=1,jz
- xx=j*2.0/jz - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=real(z)
- if(abs(id(j)).eq.2) then
- if(real(z)*id(j).lt.0) then !Sync bit
- nhardsync0=nhardsync0+1
- ierror(j)=2
- endif
- else
- n=n+1 !Data bit
- rxdata(n)=p
- ierr=0
- if(id(j)*p.lt.0) then
- ierr=1
- ierror(j)=1
- endif
- nhard0=nhard0+ierr
- endif
-! write(41,3301) j,id(j),ierror(j),ierr,n,p,p*id(j)
-!3301 format(5i6,2f10.3)
- enddo
-
- do j=jz+1,NS+ND
- xx=(j-jz+0.5)*2.0/jz - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=aimag(z)
- n=n+1
- if(n.gt.ND) exit
- rxdata(n)=p
- ierr=0
- if(id(j)*p.lt.0) then
- ierr=1
- ierror(j)=1
- endif
- nhard0=nhard0+ierr
-! write(41,3301) j,id(j),ierror(j),ierr,n,p,p*id(j)
- enddo
-
- return
-end subroutine msksoftsymw
diff --git a/lib/fsk4hf/polyfit4.f90 b/lib/fsk4hf/polyfit4.f90 deleted file mode 100644 index 892cd2cd..00000000 --- a/lib/fsk4hf/polyfit4.f90 +++ /dev/null @@ -1,109 +0,0 @@ -subroutine polyfit4(x,y,sigmay,npts,nterms,mode,a,chisqr) - - parameter (MAXN=20) - implicit real*8 (a-h,o-z) - real x(npts), y(npts), sigmay(npts), a(nterms),chisqr - real*8 sumx(2*MAXN-1), sumy(MAXN), array(MAXN,MAXN) - -! Accumulate weighted sums - nmax = 2*nterms-1 - sumx=0. - sumy=0. - chisq=0. - do i=1,npts - xi=x(i) - yi=y(i) - if(mode.lt.0) then - weight=1./abs(yi) - else if(mode.eq.0) then - weight=1 - else - weight=1./sigmay(i)**2 - end if - xterm=weight - do n=1,nmax - sumx(n)=sumx(n)+xterm - xterm=xterm*xi - enddo - yterm=weight*yi - do n=1,nterms - sumy(n)=sumy(n)+yterm - yterm=yterm*xi - enddo - chisq=chisq+weight*yi**2 - enddo - -! Construct matrices and calculate coefficients - do j=1,nterms - do k=1,nterms - n=j+k-1 - array(j,k)=sumx(n) - enddo - enddo - - delta=determ4(array,nterms) - if(delta.eq.0) then - chisqr=0. - a=0. - else - do l=1,nterms - do j=1,nterms - do k=1,nterms - n=j+k-1 - array(j,k)=sumx(n) - enddo - array(j,l)=sumy(j) - enddo - a(l)=determ4(array,nterms)/delta - enddo - -! Calculate chi square - - do j=1,nterms - chisq=chisq-2*a(j)*sumy(j) - do k=1,nterms - n=j+k-1 - chisq=chisq+a(j)*a(k)*sumx(n) - enddo - enddo - free=npts-nterms - chisqr=chisq/free - end if - - return -end subroutine polyfit4 - -real*8 function determ4(array,norder) - - parameter (MAXN=20) - implicit real*8 (a-h,o-z) - real*8 array(MAXN,MAXN) - - determ4=1. - do k=1,norder - if (array(k,k).ne.0) go to 41 - do j=k,norder - if(array(k,j).ne.0) go to 31 - enddo - determ4=0. - go to 60 - -31 do i=k,norder - s8=array(i,j) - array(i,j)=array(i,k) - array(i,k)=s8 - enddo - determ4=-1.*determ4 -41 determ4=determ4*array(k,k) - if(k.lt.norder) then - k1=k+1 - do i=k1,norder - do j=k1,norder - array(i,j)=array(i,j)-array(i,k)*array(k,j)/array(k,k) - enddo - enddo - end if - enddo - -60 return -end function determ4 diff --git a/lib/fsk4hf/spb.m b/lib/fsk4hf/spb.m deleted file mode 100644 index ed176192..00000000 --- a/lib/fsk4hf/spb.m +++ /dev/null @@ -1,89 +0,0 @@ -clear all; -global N -global R -global A - -#------------------------------------------------------------------------------- -function retval = f1(theta) - global N; - global R; - retval=0.0; - gterm = gammaln(N/2) - gammaln((N+1)/2) - log(2*sqrt(pi)); - rhs = -N*R*log(2); - lhs=gterm + (N-1)*log(sin(theta)) + log(1-(tan(theta).^2)/N) - log(cos(theta)); - retval = rhs-real(lhs); -endfunction -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -function retval = d(N,i,x) - t1=(x.^2)/2; - t2=gammaln(N/2); - t3=-gammaln(i/2+1); - t4=-gammaln(N-i); - t5=(N-1-i)*log(sqrt(2)*x); - t6=-log(2)/2; - t7arg=1+(-1)^i * gammainc((x.^2)/2.0,(i+1)/2); - t7=log(t7arg); - retval=t1+t2+t3+t4+t5+t6+t7; -endfunction -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -function retval = maxstar(x1,x2) - retval = max(x1,x2)+log(1+exp(-abs(x1-x2))); -endfunction -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -function retval = spb_integrand(x) - global N; - global A; - - t1=log(N-1); - t2=-N*(A^2)/2; - t3=-0.5*log(2*pi); - t4=(N-2)*log(sin(x)); - - arg=sqrt(N)*A*cos(x); - t5=maxstar(d(N,0,arg),d(N,1,arg)); - for i=2:N-1 - t5=maxstar(t5,d(N,i,arg)); - endfor - - retval=exp(t1+t2+t3+t4+t5); -endfunction -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -function retval = qfunc(x) - retval = 0.5 * erfc(x/sqrt(2)); -endfunction -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Calculate sphere packing lower bound on the probability of word error -# given block length (N), code rate (R), and Eb/No. -# -# Ref: -# "Log-Domain Calculation of the 1959 Sphere-Packing Bound with Application to -# M-ary PSK Block Coded Modulation," Igal Sason and Gil Weichman, -# doi: 10.1109/EEEI.2006.321097 -#------------------------------------------------------------------------------- -N=174 -K=75 -R=K/N - -delta=0.01; -[ths,fval,info,output]=fzero(@f1,[delta,pi/2-delta], optimset ("jacobian", "off")); - -for ebnodb=-6:0.5:4 - ebno=10^(ebnodb/10.0); - esno=ebno*R; - A=sqrt(2*esno); - term1=quadcc(@spb_integrand,ths,pi/2); - term2=qfunc(sqrt(N)*A); - pe=term1+term2; - ps=1-pe; - printf("%f %f\n",ebnodb,ps); -endfor diff --git a/lib/fsk4hf/spec4.f90 b/lib/fsk4hf/spec4.f90 deleted file mode 100644 index e0588950..00000000 --- a/lib/fsk4hf/spec4.f90 +++ /dev/null @@ -1,35 +0,0 @@ -subroutine spec4(c,s,savg)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=84) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=12) !Sync symbols (3 @ 4x4 Costas arrays)
- parameter (NR=2) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (98)
- parameter (NSPS=2688/84) !Samples per symbol (32)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT=2*NSPS,NH=NSPS)
-
- complex c(0:NZ-1)
- complex c1(0:NFFT-1)
- real s(0:NH,NN)
- real savg(0:NH)
-
- fs=12000.0/84.0
- df=fs/NFFT
- savg=0.
- do j=1,NN
- ia=(j-1)*NSPS
- ib=ia + NSPS-1
- c1(0:NSPS-1)=c(ia:ib)
- c1(NSPS:)=0.
- call four2a(c1,NFFT,1,-1,1)
- do k=1,NSPS
- s(k,j)=real(c1(k))**2 + aimag(c1(k))**2
- enddo
- savg=savg+s(0:NH,j)
- enddo
- s=s/NZ
- savg=savg/(NN*NZ)
-
- return
-end subroutine spec4
diff --git a/lib/fsk4hf/spec8.f90 b/lib/fsk4hf/spec8.f90 deleted file mode 100644 index 43fbc7ee..00000000 --- a/lib/fsk4hf/spec8.f90 +++ /dev/null @@ -1,31 +0,0 @@ -subroutine spec8(c,s,savg)
-
- include 'wspr_fsk8_params.f90'
- complex c(0:NMAXD-1)
- complex c1(0:NSPS-1)
- real s(0:NH2,NN)
- real savg(0:NH2)
-
- fs=12000.0/NDOWN
- df=fs/NSPS
- savg=0.
- do j=1,NN
- ia=(j-1)*NSPS
- ib=ia + NSPS-1
- c1(0:NSPS-1)=c(ia:ib)
- c1(NSPS:)=0.
- call four2a(c1,NSPS,1,-1,1)
- do i=0,NH2
- s(i,j)=real(c1(i))**2 + aimag(c1(i))**2
- enddo
- savg=savg+s(0:NH2,j)
- enddo
- s=s/NZ
- savg=savg/(NN*NZ)
-! do i=0,NH2
-! write(31,3101) i*df,savg(i)
-!3101 format(f10.3,f12.3)
-! enddo
-
- return
-end subroutine spec8
diff --git a/lib/fsk4hf/tweak1.f90 b/lib/fsk4hf/tweak1.f90 deleted file mode 100644 index c62c4087..00000000 --- a/lib/fsk4hf/tweak1.f90 +++ /dev/null @@ -1,23 +0,0 @@ -subroutine tweak1(ca,jz,f0,cb) - -! Shift frequency of analytic signal ca, with output to cb - - complex ca(jz),cb(jz) - real*8 twopi - complex*16 w,wstep - complex w4 - data twopi/0.d0/ - save twopi - - if(twopi.eq.0.d0) twopi=8.d0*atan(1.d0) - w=1.d0 - dphi=twopi*f0/12000.d0 - wstep=cmplx(cos(dphi),sin(dphi)) - do i=1,jz - w=w*wstep - w4=w - cb(i)=w4*ca(i) - enddo - - return -end subroutine tweak1 diff --git a/lib/fsk4hf/wavhdr.f90 b/lib/fsk4hf/wavhdr.f90 deleted file mode 100644 index b54fba78..00000000 --- a/lib/fsk4hf/wavhdr.f90 +++ /dev/null @@ -1,110 +0,0 @@ -module wavhdr - type hdr - character*4 ariff - integer*4 lenfile - character*4 awave - character*4 afmt - integer*4 lenfmt - integer*2 nfmt2 - integer*2 nchan2 - integer*4 nsamrate - integer*4 nbytesec - integer*2 nbytesam2 - integer*2 nbitsam2 - character*4 adata - integer*4 ndata - end type hdr - - contains - - function default_header(nsamrate,npts) - type(hdr) default_header,h - h%ariff='RIFF' - h%awave='WAVE' - h%afmt='fmt ' - h%lenfmt=16 - h%nfmt2=1 - h%nchan2=1 - h%nsamrate=nsamrate - h%nbitsam2=16 - h%nbytesam2=h%nbitsam2 * h%nchan2 / 8 - h%adata='data' - h%nbytesec=h%nsamrate * h%nbitsam2 * h%nchan2 / 8 - h%ndata=2*npts - h%lenfile=h%ndata + 44 - 8 - default_header=h - end function default_header - - subroutine set_wsjtx_wav_params(fMHz,mode,nsubmode,ntrperiod,id2) - - parameter (NBANDS=23,NMODES=11) - character*8 mode,modes(NMODES) - integer*2 id2(4) - integer iperiod(7) - real fband(NBANDS) - data fband/0.137,0.474,1.8,3.5,5.1,7.0,10.14,14.0,18.1,21.0,24.9, & - 28.0,50.0,144.0,222.0,432.0,902.0,1296.0,2304.0,3400.0, & - 5760.0,10368.0,24048.0/ - data modes/'Echo','FSK441','ISCAT','JT4','JT65','JT6M','JT9', & - 'JT9+JT65','JTMS','JTMSK','WSPR'/ - data iperiod/5,10,15,30,60,120,900/ - - dmin=1.e30 - iband=0 - do i=1,NBANDS - if(abs(fMHz-fband(i)).lt.dmin) then - dmin=abs(fMHz-fband(i)) - iband=i - endif - enddo - - imode=0 - do i=1,NMODES - if(mode.eq.modes(i)) imode=i - enddo - - ip=0 - do i=1,7 - if(ntrperiod.eq.iperiod(i)) ip=i - enddo - - id2(1)=iband - id2(2)=imode - id2(3)=nsubmode - id2(4)=ip - - return - end subroutine set_wsjtx_wav_params - - subroutine get_wsjtx_wav_params(id2,band,mode,nsubmode,ntrperiod,ok) - - parameter (NBANDS=23,NMODES=11) - character*8 mode,modes(NMODES) - character*6 band,bands(NBANDS) - integer*2 id2(4) - integer iperiod(7) - logical ok - data modes/'Echo','FSK441','ISCAT','JT4','JT65','JT6M','JT9', & - 'JT9+JT65','JTMS','JTMSK','WSPR'/ - data iperiod/5,10,15,30,60,120,900/ - data bands/'2190m','630m','160m','80m','60m','40m','30m','20m', & - '17m','15m','12m','10m','6m','2m','1.25m','70cm','33cm', & - '23cm','13cm','9cm','6cm','3cm','1.25cm'/ - - ok=.true. - if(id2(1).lt.1 .or. id2(1).gt.NBANDS) ok=.false. - if(id2(2).lt.1 .or. id2(2).gt.NMODES) ok=.false. - if(id2(3).lt.1 .or. id2(3).gt.8) ok=.false. - if(id2(4).lt.1 .or. id2(4).gt.7) ok=.false. - - if(ok) then - band=bands(id2(1)) - mode=modes(id2(2)) - nsubmode=id2(3) - ntrperiod=iperiod(id2(4)) - endif - - return - end subroutine get_wsjtx_wav_params - -end module wavhdr diff --git a/lib/fsk4hf/wspr5_downsample.f90 b/lib/fsk4hf/wspr5_downsample.f90 deleted file mode 100644 index 6fdb9021..00000000 --- a/lib/fsk4hf/wspr5_downsample.f90 +++ /dev/null @@ -1,29 +0,0 @@ -subroutine wspr5_downsample(iwave,c)
-
-! Input: i*2 data in iwave() at sample rate 12000 Hz
-! Output: Complex data in c(), sampled at 400 Hz
-
- include 'wsprlf_params.f90'
- parameter (NMAX=300*12000,NFFT2=NMAX/30)
- integer*2 iwave(NMAX)
- complex c(0:NZ-1)
- complex c1(0:NFFT2-1)
- complex cx(0:NMAX/2)
- real x(NMAX)
- equivalence (x,cx)
-
- df=12000.0/NMAX
- x=iwave
- call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
- i0=nint(1500.0/df)
- c1(0)=cx(i0)
- do i=1,NFFT2/2
- c1(i)=cx(i0+i)
- c1(NFFT2-i)=cx(i0-i)
- enddo
- c1=c1/NFFT2
- call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain
- c=c1(0:NZ-1)
-
- return
-end subroutine wspr5_downsample
diff --git a/lib/fsk4hf/wspr5_wav.f90 b/lib/fsk4hf/wspr5_wav.f90 deleted file mode 100644 index 0b09ccde..00000000 --- a/lib/fsk4hf/wspr5_wav.f90 +++ /dev/null @@ -1,48 +0,0 @@ -subroutine wspr5_wav(baud,xdt,f0,itone,snrdb,iwave)
-
-! Generate iwave() from itone().
-
- include 'wsprlf_params.f90'
- parameter (NMAX=300*12000)
- integer itone(NN)
- integer*2 iwave(NMAX)
- real*8 twopi,dt,dphi0,dphi1,dphi,phi
- real dat(NMAX)
-
- twopi=8.d0*atan(1.d0)
- dt=1.d0/12000.d0
-
- dat=0.
- if(snrdb.lt.90) then
- do i=1,NMAX
- dat(i)=gran() !Generate gaussian noise
- enddo
- bandwidth_ratio=2500.0/6000.0
- sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
- else
- sig=1.0
- endif
-
- dphi0=twopi*(f0-0.25d0*baud)*dt
- dphi1=twopi*(f0+0.25d0*baud)*dt
- phi=0.d0
- k=nint(xdt/dt)
- do j=1,NN
- dphi=dphi0
- if(itone(j).eq.1) dphi=dphi1
- if(k.eq.0) phi=-dphi
- do i=1,NSPS0
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi)
- enddo
- enddo
- fac=32767.0
- rms=100.0
- if(snrdb.ge.90.0) iwave=nint(fac*dat)
- if(snrdb.lt.90.0) iwave=nint(rms*dat)
-
- return
-end subroutine wspr5_wav
diff --git a/lib/fsk4hf/wspr5d.f90 b/lib/fsk4hf/wspr5d.f90 deleted file mode 100644 index 8a3c800b..00000000 --- a/lib/fsk4hf/wspr5d.f90 +++ /dev/null @@ -1,220 +0,0 @@ -program wspr5d - -! Decode WSPR-LF data read from *.c5 or *.wav files. - -! WSPR-LF is a potential WSPR-like mode intended for use at LF and MF. -! It uses an LDPC (300,60) code, OQPSK modulation, and 5 minute T/R sequences. - -! Reception and Demodulation algorithm: -! 1. Compute coarse spectrum; find fc1 = approx carrier freq -! 2. Mix from fc1 to 0; LPF at +/- 0.75*R -! 3. Square, FFT; find peaks near -R/2 and +R/2 to get fc2 -! 4. Mix from fc2 to 0 -! 5. Fit cb13 (central part of csync) to c -> lag, phase -! 6. Fit complex ploynomial for channel equalization -! 7. Get soft bits from equalized data - -! Still to do: find and decode more than one signal in the specified passband. - - include 'wsprlf_params.f90' - parameter (NMAX=300*12000) - character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11 - character*120 data_dir - complex csync(0:NZ-1) !Sync symbols only, from cbb - complex c(0:NZ-1) !Complex waveform - complex c1(0:NZ-1) !Complex waveform - complex zz(NS+ND) !Complex symbol values (intermediate) - complex z - real*8 fMHz - real rxdata(ND),llr(ND) !Soft symbols - real pp(2*NSPS) !Shaped pulse for OQPSK - real a(5) !For twkfreq1 - real aa(20),bb(20) !Fitted polyco's - real fpks(20) - integer id(NS+ND) !NRZ values (+/-1) for Sync and Data - integer ierror(NS+ND) - integer isync(48) !Long sync vector - integer ib13(13) !Barker 13 code - integer ihdr(11) - integer*8 n8 - integer*2 iwave(NMAX) !Generated full-length waveform - integer*1 idat(7) - integer*1 decoded(KK),apmask(ND),cw(ND) - data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/ - - nargs=iargc() - if(nargs.lt.2) then - print*,'Usage: wspr5d [-a <data_dir>] [-f fMHz] file1 [file2 ...]' - go to 999 - endif - iarg=1 - data_dir="." - call getarg(iarg,arg) - if(arg(1:2).eq.'-a') then - call getarg(iarg+1,data_dir) - iarg=iarg+2 - endif - call getarg(iarg,arg) - if(arg(1:2).eq.'-f') then - call getarg(iarg+1,arg) - read(arg,*) fMHz - iarg=iarg+2 - endif - - open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', & - position='append') -! maxn=4 !Default value - maxn=2 - twopi=8.0*atan(1.0) - fs=NSPS*12000.0/NSPS0 !Sample rate - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - ts=2*NSPS*dt !Duration of OQPSK symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - - do i=1,N2 !Half-sine pulse shape - pp(i)=sin(0.5*(i-1)*twopi/(2*NSPS)) - enddo - n8=z'cbf089223a51' - do i=1,48 - isync(i)=-1 - if(iand(n8,1).eq.1) isync(i)=1 - n8=n8/2 - enddo - -! Define array id() for sync symbols - id=0 - do j=1,48 !First group of 48 - id(2*j-1)=2*isync(j) - enddo - do j=1,13 !Barker 13 code - id(j+96)=2*ib13(j) - enddo - do j=1,48 !Second group of 48 - id(2*j+109)=2*isync(j) - enddo - - csync=0. - do j=1,205 - if(abs(id(j)).eq.2) then - ia=nint((j-0.5)*N2) - ib=ia+N2-1 - csync(ia:ib)=pp*id(j)/abs(id(j)) - endif - enddo - -write(*,*) 'iarg, nargs ',iarg,nargs - do ifile=iarg,nargs - call getarg(ifile,infile) - open(10,file=infile,status='old',access='stream') - j1=index(infile,'.c5') - j2=index(infile,'.wav') - if(j1.gt.0) then - read(10,end=999) fname,ntrmin,fMHz,c - read(fname(8:11),*) nutc - write(datetime,'(i11)') nutc - else if(j2.gt.0) then - read(10,end=999) ihdr,iwave - read(infile(j2-4:j2-1),*) nutc - datetime=infile(j2-11:j2-1) - call wspr5_downsample(iwave,c) - else - print*,'Wrong file format?' - go to 999 - endif - close(10) - fa=100.0 - fb=150.0 - call getfc1w(c,fs,fa,fb,fc1,xsnr) !First approx for freq - npeaks=20 - call getfc2w(c,csync,npeaks,fs,fc1,fpks) !Refined freq - - a(1)=-fc1 - a(2:5)=0. - call twkfreq1(c,NZ,fs,a,c) !Mix c down by fc1+fc2 -! Find time offset xdt - amax=0. - jpk=0 - iaa=0 - ibb=NZ-1 - jmax=1260 - do j=-jmax,jmax,NSPS/8 - ia=j - ib=NZ-1+j - if(ia.lt.0) then - ia=0 - iaa=-j - else - iaa=0 - endif - if(ib.gt.NZ-1) then - ib=NZ-1 - ibb=NZ-1-j - endif - z=sum(c(ia:ib)*conjg(csync(iaa:ibb))) - if(abs(z).gt.amax) then - amax=abs(z) - jpk=j - endif - enddo - xdt=jpk/fs -xdt=1.0 -jpk=fs*xdt - do i=0,NZ-1 - j=i+jpk - if(j.ge.0 .and. j.lt.NZ) c1(i)=c(j) - enddo - - nterms=maxn - do itry=1,npeaks - nhard0=0 - nhardsync0=0 - ifer=1 - a(1)=-fpks(itry) - a(2:5)=0. - call twkfreq1(c1,NZ,fs,a,c) !Mix c1 into c - call cpolyfitw(c,pp,id,maxn,aa,bb,zz,nhs) - call msksoftsymw(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0) - if(nhardsync0.gt.35) cycle - rxav=sum(rxdata)/ND - rx2av=sum(rxdata*rxdata)/ND - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - ss=0.84 - llr=2.0*rxdata/(ss*ss) - apmask=0 - max_iterations=40 - ifer=0 - call bpdecode300(llr,apmask,max_iterations,decoded,niterations,cw) - nhardmin=0 - if(niterations.lt.0) call osd300(llr,apmask,5,decoded,cw,nhardmin,dmin) - nbadcrc=0 - call chkcrc10(decoded,nbadcrc) - if(nbadcrc.ne.0) ifer=1 - if(ifer.eq.0) exit - enddo !Freq dither loop - message=' ' - if(ifer.eq.0) then - write(cbits,1100) decoded(1:50) -1100 format(50i1) - read(cbits,1102) idat -1102 format(6b8,b2) - idat(7)=ishft(idat(7),6) - call wqdecode(idat,message,itype) - nsnr=nint(xsnr) -! freq=fMHz + 1.d-6*(fc1+fc2) -! freq=fMHz + 1.d-6*(fc1+fpks(itry)) - freq=fc1+fpks(itry) - nfdot=0 - write(13,1110) datetime,0,nsnr,xdt,freq,message,nfdot -1110 format(a11,2i4,f6.2,f12.7,2x,a22,i3) - write(*,1112) datetime(8:11),nsnr,xdt,freq,nfdot,message,itry,nhardmin -!1112 format(a4,i4,f5.1,f11.6,i3,2x,a22,i4) -1112 format(a4,i4,f8.3,f8.3,i3,2x,a22,i4,i4) - endif - enddo ! ifile loop - write(*,1120) -1120 format("<DecodeFinished>") - -999 end program wspr5d diff --git a/lib/fsk4hf/wspr5d_exp.f90 b/lib/fsk4hf/wspr5d_exp.f90 deleted file mode 100644 index 6e6667b6..00000000 --- a/lib/fsk4hf/wspr5d_exp.f90 +++ /dev/null @@ -1,544 +0,0 @@ -program wspr5d - -! Decode WSPR-LF data read from *.c5 or *.wav files. - -! WSPR-LF is a potential WSPR-like mode intended for use at LF and MF. -! It uses an LDPC (300,60) code, OQPSK modulation, and 5 minute T/R sequences. -! -! Still to do: find and decode more than one signal in the specified passband. - -! include 'wsprlf_params.f90' - - parameter (NDOWN=30) - parameter (KK=60) - parameter (ND=300) - parameter (NS=109) - parameter (NR=3) - parameter (NN=NR+NS+ND) - parameter (NSPS0=8640) - parameter (NSPS=16) - parameter (N2=2*NSPS) - parameter (NZ=NSPS*NN) - parameter (NZ400=288*NN) - parameter (NMAX=300*12000) - - character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11 - character*120 data_dir - complex csync(0:NZ-1) !Sync symbols only, from cbb - complex c400(0:NZ400-1) !Complex waveform - complex c(0:NZ-1) !Complex waveform - complex cd(0:NZ-1) !Complex waveform - complex ca(0:NZ-1) !Complex waveform - complex zz,zzsum - real*8 fMHz - real rxdata(ND),llr(ND) !Soft symbols - real pp(32) !Shaped pulse for OQPSK - real sbits(412),softbits(9) - real fpks(20) - integer id(NS+ND) !NRZ values (+/-1) for Sync and Data - integer isync(48) !Long sync vector - integer ib13(13) !Barker 13 code - integer ihdr(11) - integer*8 n8 - integer*2 iwave(NMAX) !Generated full-length waveform - integer*1 idat(7) - integer*1 decoded(KK),apmask(ND),cw(ND) - integer*1 hbits(412),bits(13) - logical reset - data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/ - - nargs=iargc() - if(nargs.lt.2) then - print*,'Usage: wspr5d [-a <data_dir>] [-f fMHz] file1 [file2 ...]' - go to 999 - endif - iarg=1 - data_dir="." - call getarg(iarg,arg) - if(arg(1:2).eq.'-a') then - call getarg(iarg+1,data_dir) - iarg=iarg+2 - endif - call getarg(iarg,arg) - if(arg(1:2).eq.'-f') then - call getarg(iarg+1,arg) - read(arg,*) fMHz - iarg=iarg+2 - endif - - open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', & - position='append') - maxn=8 !Default value - twopi=8.0*atan(1.0) - fs=NSPS*12000.0/NSPS0 !Sample rate - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - ts=2*NSPS*dt !Duration of OQPSK symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - - do i=1,32 !Half-sine pulse shape - pp(i)=sin(0.5*(i-1)*twopi/(32)) - enddo - n8=z'cbf089223a51' - do i=1,48 - isync(i)=-1 - if(iand(n8,1).eq.1) isync(i)=1 - n8=n8/2 - enddo - -! Define array id() for sync symbols - id=0 - do j=1,48 !First group of 48 - id(2*j-1)=2*isync(j) - enddo - do j=1,13 !Barker 13 code - id(j+96)=2*ib13(j) - enddo - do j=1,48 !Second group of 48 - id(2*j+109)=2*isync(j) - enddo - - csync=0. - do j=1,205 - if(abs(id(j)).eq.2) then - ia=nint((j-0.5)*N2) - ib=ia+N2-1 - csync(ia:ib)=pp*id(j)/abs(id(j)) - endif - enddo - - do ifile=iarg,nargs - call getarg(ifile,infile) - open(10,file=infile,status='old',access='stream') - j1=index(infile,'.c5') - j2=index(infile,'.wav') - if(j1.gt.0) then - read(10,end=999) fname,ntrmin,fMHz,c400 - read(fname(8:11),*) nutc - write(datetime,'(i11)') nutc - else if(j2.gt.0) then - read(10,end=999) ihdr,iwave - read(infile(j2-4:j2-1),*) nutc - datetime=infile(j2-11:j2-1) - call wspr5_downsample(iwave,c400) - else - print*,'Wrong file format?' - go to 999 - endif - close(10) - - fa=100.0 - fb=150.0 - fs400=400.0 - call getfc1(c400,fs400,fa,fb,fc1,xsnr) !First approx for freq - npeaks=5 - call getfc2(c400,npeaks,fs400,fc1,fpks) !Refined freq - -! do idf=1,npeaks ! consider the top npeak peaks - do idf=1,1 ! for genie-aided sync - fc1=125.0 ! genie provided - fc2=0.0 ! from the genie -! fc2=fpks(idf) - call downsample(c400,fc1+fc2,cd) - s2=sum(cd*conjg(cd))/(16*412) - cd=cd/sqrt(s2) - do is=0,0 ! dt search range is zeroed for genie-aided sync - idt=is/2 - if( mod(is,2).eq. 1 ) idt=-(is+1)/2 - xdt=real(22+idt)/22.222 - 1.0 - ca=cshift(cd,22+idt) - zzsum=0.0 - do iseq=3,4 - if(iseq.eq.4) then - k=1-2*3 - nseq=9 - istep=3*4 - else - k=1-2*iseq - nseq=iseq*3 - istep=iseq*4 - endif - do i=1,408,istep - j=(i+1)*16 - if(iseq.eq.4) then -! phase=-1.18596900 -! For now, average complex corr. coeffs over the entire frame to -! estimate phase - phase=atan2(imag(zzsum),real(zzsum)) - k=k+3*2 - call mskcohdet(nseq,ca(j),pp,id(k),softbits,phase) - else - k=k+iseq*2 - call mskseqdet(nseq,ca(j),pp,id(k),softbits,1,zz) - zzsum=zzsum+zz - endif - sbits(i+1)=softbits(1) - sbits(i+2)=softbits(2) - if( id(k+1) .ne. 0 ) sbits(i+2)=id(k+1)*25 - sbits(i+3)=softbits(3) - if( iseq .ge. 2 ) then - sbits(i+5)=softbits(4) - sbits(i+6)=softbits(5) - if( id(k+3) .ne. 0 ) sbits(i+6)=id(k+3)*25 - sbits(i+7)=softbits(6) - if( iseq .ge. 3 ) then - sbits(i+9)=softbits(7) - sbits(i+10)=softbits(8) - if( id(k+5) .ne. 0 ) sbits(i+10)=id(k+5)*25 - sbits(i+11)=softbits(9) - endif - endif - enddo - j=1 - do i=1,205 - if( abs(id(i)) .ne. 2 ) then - rxdata(j)=sbits(2*i-1) - j=j+1 - endif - enddo - do i=1,204 - rxdata(j)=sbits(2*i) - j=j+1 - enddo - rxav=sum(rxdata)/ND - rx2av=sum(rxdata*rxdata)/ND - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - sigma=1.20 - llr=2*rxdata/(sigma*sigma) - apmask=0 - max_iterations=40 - - ifer=0 - call bpdecode300(llr,apmask,max_iterations,decoded,niterations,cw) -! niterations will be equal to the Hamming distance between hard received word and the codeword - nhardmin=0 - if(niterations.lt.0) call osd300(llr,apmask,5,decoded,cw,nhardmin,dmin) - if(nhardmin.gt.0) niterations=nhardmin - nbadcrc=0 - call chkcrc10(decoded,nbadcrc) - if(nbadcrc.ne.0) ifer=1 - - if( ifer.eq.0 ) then - write(cbits,1200) decoded(1:50) -1200 format(50i1) - read(cbits,1202) idat -1202 format(6b8,b2) - idat(7)=ishft(idat(7),6) - call wqdecode(idat,message,itype) - nsnr=nint(xsnr) -! freq=fMHz + 1.d-6*(fc1+fc2) - freq=fc1+fc2 - nfdot=0 - write(13,1210) datetime,0,nsnr,xdt,freq,message,nfdot -1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3) - write(*,1212) datetime(8:11),nsnr,xdt,freq,nfdot,message,'*',idf,nseq,is,iseq,niterations -!1212 format(a4,i4,f5.1,f11.6,i3,2x,a22,a1,i3,i3,i3,i4) -1212 format(a4,i4,f8.3,f8.3,i3,2x,a22,a1,i3,i3,i3,i3,i4) - goto 888 - endif - enddo !iseq - enddo - enddo -888 continue - enddo - - write(*,1120) -1120 format("<DecodeFinished>") - -999 end program wspr5d - -subroutine getmetric(ib,ps,xmet) - real ps(0:511) - xm1=0 - xm0=0 - do i=0,511 - if( iand(i/ib,1) .eq. 1 .and. ps(i) .gt. xm1 ) xm1=ps(i) - if( iand(i/ib,1) .eq. 0 .and. ps(i) .gt. xm0 ) xm0=ps(i) - enddo - xmet=xm1-xm0 - return -end subroutine getmetric - -subroutine mskseqdet(ns,cdat,pp,bsync,softbits,ncoh,zz) -! -! Detect sequences of 3, 6, or 9 bits (ns). -! Sync bits are assumed to be known. -! -complex cdat(16*12),cbest(16*12),cideal(16*12) -complex cdf(16*12),cfac,zz -real cm(0:511),cmbest(0:511) -real pp(32),softbits(9) -integer bit(13),bestbits(13),sgn(13) -integer bsync(7) - -twopi=8.0*atan(1.0) -dt=30.0*18.0/12000.0 -cmax=0; -fbest=0.0; -np=2**ns-1 -idfmax=40 -if( ncoh .eq. 1 ) idfmax=0 -do idf=0,idfmax - if( mod(idf,2).eq.0 ) deltaf=idf/2*0.02 - if( mod(idf,2).eq.1 ) deltaf=-(idf+1)/2*0.02 - dphi=twopi*deltaf*dt - cfac=cmplx(cos(dphi),sin(dphi)) - cdf=1.0 - do i=2,16*(ns-1) - cdf(i)=cdf(i-1)*cfac - enddo - - cm=0 - ibflag=0 - do i=0,np - bit(1)=(bsync(1)+2)/4 - bit(2)=iand(i/(2**(ns-1)),1) - bit(3)=iand(i/(2**(ns-2)),1) - if( bsync(2).ne.0 ) then ! force the barker bits - bit(3)=(bsync(2)+2)/4 - endif - bit(4)=iand(i/(2**(ns-3)),1) - bit(5)=(bsync(3)+2)/4 - - if( ns .ge. 6 ) then - bit(6)=iand(i/(2**(ns-4)),1) - bit(7)=iand(i/(2**(ns-5)),1) - if( bsync(4).ne.0 ) then ! force the barker bits - bit(7)=(bsync(4)+2)/4 - endif - bit(8)=iand(i/(2**(ns-6)),1) - bit(9)=(bsync(5)+2)/4 - if( ns .eq. 9 ) then - bit(10)=iand(i/4,1) - bit(11)=iand(i/2,1) - if( bsync(6).ne.0 ) then ! force the barker bits - bit(11)=(bsync(6)+2)/4 - endif - bit(12)=iand(i/1,1) - bit(13)=(bsync(7)+2)/4 - endif - endif - - sgn=2*bit-1 - cideal(1:16) =cmplx(sgn(1)*pp(17:32),sgn(2)*pp(1:16)) - cideal(17:32) =cmplx(sgn(3)*pp(1:16),sgn(2)*pp(17:32)) - cideal(33:48) =cmplx(sgn(3)*pp(17:32),sgn(4)*pp(1:16)) - cideal(49:64) =cmplx(sgn(5)*pp(1:16),sgn(4)*pp(17:32)) - if( ns .ge. 6 ) then - cideal(65:80) =cmplx(sgn(5)*pp(17:32),sgn(6)*pp(1:16)) - cideal(81:96) =cmplx(sgn(7)*pp(1:16),sgn(6)*pp(17:32)) - cideal(97:112) =cmplx(sgn(7)*pp(17:32),sgn(8)*pp(1:16)) - cideal(113:128)=cmplx(sgn(9)*pp(1:16),sgn(8)*pp(17:32)) - if( ns .eq. 9 ) then - cideal(129:144) =cmplx(sgn(9)*pp(17:32),sgn(10)*pp(1:16)) - cideal(145:160) =cmplx(sgn(11)*pp(1:16),sgn(10)*pp(17:32)) - cideal(161:176) =cmplx(sgn(11)*pp(17:32),sgn(12)*pp(1:16)) - cideal(177:192)=cmplx(sgn(13)*pp(1:16),sgn(12)*pp(17:32)) - endif - endif - cideal=cideal*cdf - cm(i)=abs(sum(cdat(1:64*ns/3)*conjg(cideal(1:64*ns/3))))/1.e3 - if( cm(i) .gt. cmax ) then - ibflag=1 - cmax=cm(i) - bestbits=bit - cbest=cideal - fbest=deltaf - zz=sum(cdat*conjg(cbest))/1.e3 - endif - enddo - if( ibflag .eq. 1 ) then ! new best found - cmbest=cm - endif -enddo -softbits=0.0 -call getmetric(1,cmbest,softbits(ns)) -call getmetric(2,cmbest,softbits(ns-1)) -call getmetric(4,cmbest,softbits(ns-2)) -if( ns .ge. 6 ) then - call getmetric(8,cmbest,softbits(ns-3)) - call getmetric(16,cmbest,softbits(ns-4)) - call getmetric(32,cmbest,softbits(ns-5)) - if( ns .eq. 9 ) then - call getmetric(64,cmbest,softbits(3)) - call getmetric(128,cmbest,softbits(2)) - call getmetric(256,cmbest,softbits(1)) - endif -endif -end subroutine mskseqdet - -subroutine mskcohdet(ns,cdat,pp,bsync,softbits,phase) -! -! Coherent demodulate blocks of 9 bits (ns). -! - complex cdat(16*12),crot(16*12) - real pp(32),softbits(9) - - np=2**ns-1 - - softbits=0.0 - crot=cdat*cmplx(cos(phase),-sin(phase)) - softbits(1)=sum(imag(crot(1:32)*pp)) - softbits(2)=sum(real(crot(17:48)*pp)) - softbits(3)=sum(imag(crot(33:64)*pp)) - softbits(4)=sum(imag(crot(65:96)*pp)) - softbits(5)=sum(real(crot(81:112)*pp)) - softbits(6)=sum(imag(crot(97:128)*pp)) - softbits(7)=sum(imag(crot(129:160)*pp)) - softbits(8)=sum(real(crot(145:176)*pp)) - softbits(9)=sum(imag(crot(161:192)*pp)) - softbits=softbits/64. -end subroutine mskcohdet - -subroutine downsample(ci,f0,co) - parameter(NI=412*288,NO=NI/18) - complex ci(0:NI-1),ct(0:NI-1) - complex co(0:NO-1) - - df=400.0/NI - ct=ci - call four2a(ct,NI,1,-1,1) !c2c FFT to freq domain - i0=nint(f0/df) - co=0.0 - co(0)=ct(i0) -! b=3.0 !optimized for sequence detection - b=6.0 - do i=1,NO/2 - arg=(i*df/b)**2 - filt=exp(-arg) - co(i)=ct(i0+i)*filt - co(NO-i)=ct(i0-i)*filt - enddo - co=co/NO - call four2a(co,NO,1,1,1) !c2c FFT back to time domain - return -end subroutine downsample - -subroutine getfc1(c,fs,fa,fb,fc1,xsnr) - -! include 'wsprlf_params.f90' - parameter (NZ=288*412) - parameter (NSPS=288) - parameter (N2=2*NSPS) - parameter (NFFT1=16*NSPS) - parameter (NH1=NFFT1/2) - - complex c(0:NZ-1) !Complex waveform - complex c2(0:NFFT1-1) !Short spectra - real s(-NH1+1:NH1) !Coarse spectrum - nspec=NZ/N2 - df1=fs/NFFT1 - s=0. - do k=1,nspec - ia=(k-1)*N2 - ib=ia+N2-1 - c2(0:N2-1)=c(ia:ib) - c2(N2:)=0. - call four2a(c2,NFFT1,1,-1,1) - do i=0,NFFT1-1 - j=i - if(j.gt.NH1) j=j-NFFT1 - s(j)=s(j) + real(c2(i))**2 + aimag(c2(i))**2 - enddo - enddo -! call smo121(s,NFFT1) - smax=0. - ipk=0 - fc1=0. - ia=nint(fa/df1) - ib=nint(fb/df1) - do i=ia,ib - f=i*df1 - if(s(i).gt.smax) then - smax=s(i) - ipk=i - fc1=f - endif -! write(51,3001) f,s(i),db(s(i)) -! 3001 format(f10.3,e12.3,f10.3) - enddo - -! The following is for testing SNR calibration: - sp3n=(s(ipk-1)+s(ipk)+s(ipk+1)) !Sig + 3*noise - base=(sum(s)-sp3n)/(NFFT1-3.0) !Noise per bin - psig=sp3n-3*base !Sig only - pnoise=(2500.0/df1)*base !Noise in 2500 Hz - xsnr=db(psig/pnoise) - xsnr=xsnr+5.0 - return -end subroutine getfc1 - -subroutine getfc2(c,npeaks,fs,fc1,fpks) - -! include 'wsprlf_params.f90' - parameter (NZ=288*412) - parameter (NSPS=288) - parameter (N2=2*NSPS) - parameter (NFFT1=16*NSPS) - parameter (NH1=NFFT1/2) - - complex c(0:NZ-1) !Complex waveform - complex cs(0:NZ-1) !For computing spectrum - real a(5) - real freqs(413),sp2(413),fpks(npeaks) - integer pkloc(1) - - df=fs/NZ - baud=fs/NSPS - a(1)=-fc1 - a(2:5)=0. - call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1 - -! Filter, square, then FFT to get refined carrier frequency fc2. - call four2a(cs,NZ,1,-1,1) !To freq domain - - ia=nint(0.75*baud/df) - cs(ia:NZ-1-ia)=0. !Save only freqs around fc1 -! do i=1,NZ/2 -! filt=1/(1+((i*df)**2/(0.50*baud)**2)**8) -! cs(i)=cs(i)*filt -! cs(NZ+1-i)=cs(NZ+1-i)*filt -! enddo - call four2a(cs,NZ,1,1,1) !Back to time domain - cs=cs/NZ - cs=cs*cs !Square the data - call four2a(cs,NZ,1,-1,1) !Compute squared spectrum -! Find two peaks separated by baud - pmax=0. - fc2=0. -! ja=nint(0.3*baud/df) - ja=nint(0.5*baud/df) - k=1 - sp2=0.0 - do j=-ja,ja - f2=j*df - ia=nint((f2-0.5*baud)/df) - if(ia.lt.0) ia=ia+NZ - ib=nint((f2+0.5*baud)/df) - p=real(cs(ia))**2 + aimag(cs(ia))**2 + & - real(cs(ib))**2 + aimag(cs(ib))**2 - if(p.gt.pmax) then - pmax=p - fc2=0.5*f2 - endif - freqs(k)=0.5*f2 - sp2(k)=p - k=k+1 -! write(52,1200) f2,p,db(p) -!1200 format(f10.3,2f15.3) - enddo - - do i=1,npeaks - pkloc=maxloc(sp2) - ipk=pkloc(1) - fpks(i)=freqs(ipk) - ipk0=max(1,ipk-2) - ipk1=min(413,ipk+2) -! ipk0=ipk -! ipk1=ipk - sp2(ipk0:ipk1)=0.0 - enddo - return -end subroutine getfc2 diff --git a/lib/fsk4hf/wspr5sim.f90 b/lib/fsk4hf/wspr5sim.f90 deleted file mode 100644 index 5c2147b9..00000000 --- a/lib/fsk4hf/wspr5sim.f90 +++ /dev/null @@ -1,111 +0,0 @@ -program wspr5sim - -! Generate simulated data for a 5-minute "WSPR-LF" mode. Output is saved -! to a *.c5 or *.wav file. - - use wavhdr - include 'wsprlf_params.f90' !Set various constants - parameter (NMAX=300*12000) - type(hdr) h !Header for .wav file - character arg*12,fname*16 - character msg*22,msgsent*22 - complex c0(0:NZ-1) - complex c(0:NZ-1) - real*8 fMHz - integer itone(NN) - integer*2 iwave(NMAX) !Generated full-length waveform - -! Get command-line argument(s) - nargs=iargc() - if(nargs.ne.8) then - print*,'Usage: wspr5sim "message" f0 DT fsp del nwav nfiles snr' - print*,'Example: wspr5sim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33' - go to 999 - endif - call getarg(1,msg) !Message to be transmitted - call getarg(2,arg) - read(arg,*) f0 !Freq relative to WSPR-band center (Hz) - call getarg(3,arg) - read(arg,*) xdt !Time offset from nominal (s) - call getarg(4,arg) - read(arg,*) fspread !Watterson frequency spread (Hz) - call getarg(5,arg) - read(arg,*) delay !Watterson delay (ms) - call getarg(6,arg) - read(arg,*) nwav !1 for *.wav file, 0 for *.c5 file - call getarg(7,arg) - read(arg,*) nfiles !Number of files - call getarg(8,arg) - read(arg,*) snrdb !SNR_2500 - - twopi=8.0*atan(1.0) - fs=12000.0/NDOWN !Sample rate - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - ts=2*NSPS*dt !Duration of OQPSK symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - bandwidth_ratio=2500.0/(fs/2.0) - sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - txt=NN*NSPS0/12000.0 - - call genwspr5(msg,msgsent,itone) !Encode the message, get itone - write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent -1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, & - ' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22) - - dphi0=twopi*(f0-0.25*baud)*dt - dphi1=twopi*(f0+0.25*baud)*dt - phi=0.0 - c0=0. - k=-1 + nint(xdt/dt) - do j=1,NN !Generate OQPSK waveform from itone - dphi=dphi0 - if(itone(j).eq.1) dphi=dphi1 - if(k.eq.0) phi=-dphi - do i=1,NSPS - k=k+1 - phi=phi+dphi - if(phi.gt.twopi) phi=phi-twopi - xphi=phi - if(k.ge.0 .and. k.lt.NZ) c0(k)=cmplx(cos(xphi),sin(xphi)) - enddo - enddo - - call sgran() - do ifile=1,nfiles - c=c0 - if(nwav.eq.0) then - if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then - call watterson(c,NZ,fs,delay,fspread) - endif - c=c*sig - if(snrdb.lt.90) then - do i=0,NZ-1 !Add gaussian noise at specified SNR - xnoise=gran() - ynoise=gran() - c(i)=c(i) + cmplx(xnoise,ynoise) - enddo - endif - write(fname,1100) ifile -1100 format('000000_',i4.4,'.c5') - open(10,file=fname,status='unknown',access='stream') - fMHz=10.1387d0 - nmin=5 - write(10) fname,nmin,fMHz,c !Save to *.c5 file - close(10) - else - call wspr5_wav(baud,xdt,f0,itone,snrdb,iwave) - h=default_header(12000,NMAX) - write(fname,1102) ifile -1102 format('000000_',i4.4,'.wav') - open(10,file=fname,status='unknown',access='stream') - write(10) h,iwave !Save to *.wav file - close(10) - endif - write(*,1110) ifile,xdt,f0,snrdb,fname -1110 format(i4,f7.2,f8.2,f7.1,2x,a16) - enddo - -999 end program wspr5sim diff --git a/lib/fsk4hf/wspr_fsk8_downsample.f90 b/lib/fsk4hf/wspr_fsk8_downsample.f90 deleted file mode 100644 index 9750e0cb..00000000 --- a/lib/fsk4hf/wspr_fsk8_downsample.f90 +++ /dev/null @@ -1,27 +0,0 @@ -subroutine wspr_fsk8_downsample(iwave,c)
-
-! Input: i*2 data in iwave() at sample rate 12000 Hz
-! Output: Complex data in c(), sampled at 12000/24=500 Hz
-
- include 'wspr_fsk8_params.f90'
- integer*2 iwave(NMAX)
- complex c(0:NMAXD-1)
- complex c1(0:NMAXD-1)
- complex cx(0:NMAX/2)
- real x(NMAX)
- equivalence (x,cx)
-
- df=12000.0/NMAX
- x=iwave
- call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
- i0=nint(1500.0/df)
- c1(0)=cx(i0)
- do i=1,NMAXD/2
- c1(i)=cx(i0+i)
- c1(NMAXD-i)=cx(i0-i)
- enddo
- c=c1/NMAXD
- call four2a(c,NMAXD,1,1,1) !c2c FFT back to time domain
-
- return
-end subroutine wspr_fsk8_downsample
diff --git a/lib/fsk4hf/wspr_fsk8_params.f90 b/lib/fsk4hf/wspr_fsk8_params.f90 deleted file mode 100644 index c080f029..00000000 --- a/lib/fsk4hf/wspr_fsk8_params.f90 +++ /dev/null @@ -1,14 +0,0 @@ -! LDPC (300,60) code
-parameter (NDOWN=24) !Downsample factor
-parameter (KK=60) !Information bits (50 + CRC10)
-parameter (ND=100) !Data symbols
-parameter (NS=14) !Sync symbols (2 @ Costas 7x7)
-parameter (NN=NS+ND) !Total symbols (114)
-parameter (NSPS0=24576) !Samples per symbol at 12000 S/s
-parameter (NSPS=NSPS0/NDOWN) !Sam/sym, downsampled (1024)
-parameter (N7=7*NSPS) !Samples in Costas 7x7 array (7168)
-parameter (NZ=NSPS*NN) !Samples in downsampled waveform (116,736)
-parameter (NMAX=240*12000) !Samples in iwave()
-parameter (NMAXD=NMAX/24) !Samples in c(), after downsampling
-parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-parameter (NH2=NSPS/2)
diff --git a/lib/fsk4hf/wspr_fsk8_sim.f90 b/lib/fsk4hf/wspr_fsk8_sim.f90 deleted file mode 100644 index 40d808a0..00000000 --- a/lib/fsk4hf/wspr_fsk8_sim.f90 +++ /dev/null @@ -1,107 +0,0 @@ -program wspr_fsk8_sim - -! Generate simulated data for a 4-minute "WSPR-LF" mode using 8-FSK. -! Output is saved to a *.wav file. - - use wavhdr - include 'wspr_fsk8_params.f90' !Set various constants - type(hdr) h !Header for .wav file - character arg*12,fname*16 - character msg*22,msgsent*22 - complex c0(0:NZ-1) - complex c(0:NZ-1) - real*8 fMHz - integer itone(NN) - integer*2 iwave(NMAX) !Generated full-length waveform - -! Get command-line argument(s) - nargs=iargc() - if(nargs.ne.8) then - print*,'Usage: wspr5sim "message" f0 DT fsp del nwav nfiles snr' - print*,'Example: wspr5sim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33' - go to 999 - endif - call getarg(1,msg) !Message to be transmitted - call getarg(2,arg) - read(arg,*) f0 !Freq relative to WSPR-band center (Hz) - call getarg(3,arg) - read(arg,*) xdt !Time offset from nominal (s) - call getarg(4,arg) - read(arg,*) fspread !Watterson frequency spread (Hz) - call getarg(5,arg) - read(arg,*) delay !Watterson delay (ms) - call getarg(6,arg) - read(arg,*) nwav !1 for *.wav file, 0 for *.c4 file - call getarg(7,arg) - read(arg,*) nfiles !Number of files - call getarg(8,arg) - read(arg,*) snrdb !SNR_2500 - - twopi=8.0*atan(1.0) - fs=12000.0/NDOWN !Sample rate after downsampling - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of symbols (s) - baud=1.0/tt !Keying rate - bw=8*baud - txt=NZ*dt !Transmission length (s) - bandwidth_ratio=2500.0/(fs/2.0) - sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - txt=NN*NSPS0/12000.0 - - call genwspr_fsk8(msg,msgsent,itone) !Encode the message, get itone - write(*,1000) f0,xdt,txt,snrdb,bw,msgsent -1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, & - ' BW:',f4.1,2x,a22) - - - phi=0.0 - c0=0. - k=-1 + nint(xdt/dt) - do j=1,NN !Generate OQPSK waveform from itone - dphi=twopi*(f0+itone(j)*baud)*dt - if(k.eq.0) phi=-dphi - do i=1,NSPS - k=k+1 - phi=phi+dphi - if(phi.gt.twopi) phi=phi-twopi - xphi=phi - if(k.ge.0 .and. k.lt.NZ) c0(k)=cmplx(cos(xphi),sin(xphi)) - enddo - enddo - - call sgran() - do ifile=1,nfiles - if(nwav.eq.0) then - c=c0 - if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then - call watterson(c,NZ,fs,delay,fspread) - endif - c=c*sig - if( snrdb.lt.90) then - do i=0,NZ-1 - xnoise=gran() - ynoise=gran() - c(i)=c(i)+cmplx(xnoise,ynoise) - enddo - endif - write(fname,1100) ifile -1100 format('000000_',i4.4,'.c4') - open(10,file=fname,status='unknown',access='stream') - fMHz=1.866d0 - nmin=4 - write(10) fname,nmin,fMHz,c - else - call wspr_fsk8_wav(baud,xdt,f0,itone,snrdb,iwave) - h=default_header(12000,NMAX) - write(fname,1102) ifile -1102 format('000000_',i4.4,'.wav') - open(10,file=fname,status='unknown',access='stream') - write(10) h,iwave !Save to *.wav file - close(10) - endif - write(*,1110) ifile,xdt,f0,snrdb,fname -1110 format(i4,f7.2,f8.2,f7.1,2x,a16) - enddo - -999 end program wspr_fsk8_sim diff --git a/lib/fsk4hf/wspr_fsk8_wav.f90 b/lib/fsk4hf/wspr_fsk8_wav.f90 deleted file mode 100644 index 3b0a0ff3..00000000 --- a/lib/fsk4hf/wspr_fsk8_wav.f90 +++ /dev/null @@ -1,44 +0,0 @@ -subroutine wspr_fsk8_wav(baud,xdt,f0,itone,snrdb,iwave)
-
-! Generate iwave() from itone().
-
- include 'wspr_fsk8_params.f90'
- integer itone(NN)
- integer*2 iwave(NMAX)
- real*8 twopi,dt,dphi,phi
- real dat(NMAX)
-
- twopi=8.d0*atan(1.d0)
- dt=1.d0/12000.d0
-
- dat=0.
- if(snrdb.lt.90) then
- do i=1,NMAX
- dat(i)=gran() !Generate gaussian noise, rms = 1.0
- enddo
- bandwidth_ratio=2500.0/6000.0
- sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
- else
- sig=1.0
- endif
-
- phi=0.d0
- k=nint((xdt+1.0)/dt)
- do j=1,NN
- dphi=twopi*(f0+ itone(j)*baud)*dt
- if(k.eq.0) phi=-dphi
- do i=1,NSPS0
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi)
- enddo
- enddo
- fac=32767.0
- rms=100.0
- if(snrdb.ge.90.0) iwave=nint(fac*dat)
- if(snrdb.lt.90.0) iwave=nint(rms*dat)
-
- return
-end subroutine wspr_fsk8_wav
diff --git a/lib/fsk4hf/wspr_fsk8d.f90 b/lib/fsk4hf/wspr_fsk8d.f90 deleted file mode 100644 index 1f69c440..00000000 --- a/lib/fsk4hf/wspr_fsk8d.f90 +++ /dev/null @@ -1,197 +0,0 @@ -program wspr_fsk8d - -! WSPR-LF is a potential WSPR-like mode intended for use at LF and MF. -! This version uses 4-minute T/R sequences, an LDPC (300,60) code, -! 8-FSK modulation, and noncoherent demodulation. This decoder reads -! data from *.wav files. - -! Reception and Demodulation algorithm: -! 1. Compute coarse spectrum; find fc1 = approx carrier freq -! 2. Mix from fc1 to 0; LPF at +/- 0.75*R -! 3. Find two 7x7 Costas arrays to get xdt and fc2 -! 4. Mix from fc2 to 0, compute aligned symbol spectra -! 5. Get soft bits from symbol spectra - -! Still to do: find and decode more than one signal in the specified passband. - - include 'wspr_fsk8_params.f90' - character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11 - character*120 data_dir - complex csync(0:N7-1) !Sync symbols for Costas 7x7 array - complex c1(0:2*N7-1) - complex c2(0:2*N7-1) - complex c(0:NMAXD-1) !Complex waveform - real*8 fMHz - real rxdata(3*ND),llr(3*ND) !Soft symbols - real a(5) !For twkfreq1 - real s(0:NH2,NN) - real savg(0:NH2) - real ss(0:N7) - real ss0(0:N7) - real ps(0:7) - integer ihdr(11) - integer*2 iwave(NMAX) !Generated full-length waveform - integer*1 idat(7) - integer*1 decoded(KK),apmask(3*ND),cw(3*ND) - integer icos7(0:6) - data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern - - nargs=iargc() - if(nargs.lt.7) then - print*,'Usage: wspr_fsk8d -d db -f fMHz -a data_dir file1 [file2 ...]' - go to 999 - endif - call getarg(1,arg) - if(arg(1:3).ne.'-d ') go to 999 - call getarg(2,arg) - read(arg,*) degrade - rxbw=3000. - - call getarg(3,arg) - if(arg(1:3).ne.'-f ') go to 999 - call getarg(4,arg) - read(arg,*) fMHz - - call getarg(5,arg) - if(arg(1:3).ne.'-a ') go to 999 - call getarg(6,data_dir) - - open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', & - position='append') - - twopi=8.0*atan(1.0) - fs=NSPS*12000.0/NSPS0 !Sample rate after downsampling (Hz) - dt=1.0/fs !Sample interval (s) - ts=NSPS*dt !Symbol duration (s) - baud=1.0/ts !Keying rate (Hz) - txt=NZ*dt !Transmission length (s) - - phi=0. - k=-1 - do j=0,6 - dphi=twopi*baud*icos7(j)*dt - do i=1,NSPS - phi=phi+dphi - if(phi.gt.twopi) phi=phi-twopi - k=k+1 - csync(k)=cmplx(cos(phi),sin(phi)) - enddo - enddo - - do ifile=7,nargs - call getarg(ifile,infile) - open(10,file=infile,status='old',access='stream') - j1=index(infile,'.c4') - j2=index(infile,'.wav') - if(j1.gt.0) then - read(10,end=999) fname,ntrmin,fMHz,c(0:NZ-1) - read(fname(8:11),*) nutc - write(datetime,'(i11)') nutc - else if(j2.gt.0) then - read(10,end=999) ihdr,iwave - read(infile(j2-4:j2-1),*) nutc - datetime=infile(j2-11:j2-1) - if(degrade.gt.0.0) call degrade_snr(iwave,NMAX,degrade,rxbw) - call wspr_fsk8_downsample(iwave,c) - else - print*,'Wrong file format?' - go to 999 - endif - close(10) - pmax=0. - df1=fs/(2*N7) - ia=nint(100.0/df1) - ib=nint(150.0/df1) - ipk=0 - jpk=0 -! Get xdt and f0 from the sync arrays - do j0=0,1000,50 - j0b=j0+107*NSPS - c1(0:N7-1)=c(j0:j0+N7-1)*conjg(csync) - c1(N7:)=0. - c2(0:N7-1)=c(j0b:j0b+N7-1)*conjg(csync) - c2(N7:)=0. - call four2a(c1,2*N7,1,-1,1) - call four2a(c2,2*N7,1,-1,1) - do i=0,N7 - p=1.e-9*(real(c1(i))**2 + aimag(c1(i))**2 + & - real(c2(i))**2 + aimag(c2(i))**2) - ss(i)=p - enddo - do i=ia,ib - p=ss(i) - if(p.gt.pmax) then - pmax=p - ipk=i - jpk=j0 - endif - enddo - if(jpk.eq.j0) ss0=ss - enddo - f0=ipk*df1 - xdt=jpk*dt - 1.0 - - sp3n=(ss0(ipk-1)+ss0(ipk)+ss0(ipk+1)) !Sig + 3*noise - call pctile(ss0,N7,45,base) - psig=sp3n-3*base !Sig only - pnoise=(2500.0/df1)*base !Noise in 2500 Hz - xsnr=db(psig/pnoise) !SNR from sync tones - - if(jpk.ge.0) c(0:NMAXD-1-jpk)=c(jpk:NMAXD-1) - - a(1)=-f0 - a(2:5)=0. - call twkfreq1(c,NZ,fs,a,c) !Mix from f0 down to 0 - call spec8(c,s,savg) !Get symbol spectra - - do j=1,ND - k=j+7 - ps=s(0:7,k) - ps=sqrt(ps) !### ??? ### -! ps=log(ps) - r1=max(ps(1),ps(3),ps(5),ps(7))-max(ps(0),ps(2),ps(4),ps(6)) - r2=max(ps(2),ps(3),ps(6),ps(7))-max(ps(0),ps(1),ps(4),ps(5)) - r4=max(ps(4),ps(5),ps(6),ps(7))-max(ps(0),ps(1),ps(2),ps(3)) - rxdata(3*j-2)=r4 - rxdata(3*j-1)=r2 - rxdata(3*j)=r1 - enddo - - rxav=sum(rxdata)/ND - rx2av=sum(rxdata*rxdata)/ND - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - s0=1.1 - llr=2.0*rxdata/(s0*s0) - apmask=0 - max_iterations=40 - ifer=0 - call bpdecode300(llr,apmask,max_iterations,decoded,niterations,cw) - if(niterations.lt.0) call osd300(llr,apmask,5,decoded,cw,nhardmin,dmin) - if(nhardmin.ge.0) niterations=nhardmin - nbadcrc=0 - if(niterations.ge.0) call chkcrc10(decoded,nbadcrc) - if(niterations.lt.0 .or. nbadcrc.ne.0) ifer=1 - nsnr=nint(xsnr) -! freq=fMHz + 1.d-6*f0 - freq=1.d-6*(f0+1500) - nfdot=0 - message=' ' - if(ifer.eq.0) then - write(cbits,1100) decoded(1:50) -1100 format(50i1) - read(cbits,1102) idat -1102 format(6b8,b2) - idat(7)=ishft(idat(7),6) - call wqdecode(idat,message,itype) - write(*,1112) datetime(8:11),nsnr,xdt,freq,nfdot,message -1112 format(a4,i4,f5.1,f11.6,i3,2x,a22) - endif - write(13,1110) datetime,0,nsnr,xdt,freq,message,nfdot -1110 format(a11,2i4,f6.2,f12.7,2x,a22,i3) - enddo ! ifile loop - write(*,1120) -1120 format("<DecodeFinished>") - -999 end program wspr_fsk8d - diff --git a/lib/fsk4hf/wspr_params.f90 b/lib/fsk4hf/wspr_params.f90 deleted file mode 100644 index 18feaea2..00000000 --- a/lib/fsk4hf/wspr_params.f90 +++ /dev/null @@ -1,23 +0,0 @@ - parameter (NN=162)
- parameter (NSPS0=8192) !Samples per symbol at 12000 S/s
- parameter (NDOWN=32)
- parameter (NSPS=NSPS0/NDOWN)
- parameter (NZ=NSPS*NN) !Samples in waveform at 12000 S/s
- parameter (NZ0=NSPS0*NN) !Samples in waveform at 375 S/s
- parameter (NMAX=120*12000) !Samples in waveform at 375 S/s
-
-! Define the sync vector:
- integer*1 sync(162)
- data sync/ &
- 1,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0, &
- 0,1,0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,0,1, &
- 0,0,0,0,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,1, &
- 1,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,0,0,1, &
- 0,0,1,0,1,1,0,0,0,1,1,0,1,0,1,0,0,0,1,0, &
- 0,0,0,0,1,0,0,1,0,0,1,1,1,0,1,1,0,0,1,1, &
- 0,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,1,1, &
- 0,0,0,0,0,0,0,1,1,0,1,0,1,1,0,0,0,1,1,0, &
- 0,0/
-
-
-
diff --git a/lib/fsk4hf/wspr_wav.f90 b/lib/fsk4hf/wspr_wav.f90 deleted file mode 100644 index 188242bb..00000000 --- a/lib/fsk4hf/wspr_wav.f90 +++ /dev/null @@ -1,49 +0,0 @@ -subroutine wspr_wav(baud,xdt,h,f0,itone,snrdb,iwave)
-
-! Generate iwave() from itone().
-
- include 'wspr_params.f90'
- integer itone(NN)
- integer*2 iwave(NMAX)
- real*8 twopi,dt,dphi0,dphi1,dphi,phi
- real dat(NMAX)
-
- twopi=8.d0*atan(1.d0)
- dt=1.d0/12000.d0
- baud=375.0/256.0
-
- dat=0.
- if(snrdb.lt.90) then
- do i=1,NMAX
- dat(i)=gran() !Generate gaussian noise
- enddo
- bandwidth_ratio=2500.0/6000.0
- sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
- else
- sig=1.0
- endif
-
- phi=0.d0
- k=nint(xdt/dt)
- do j=1,NN
- dphi=twopi*(f0+h*(itone(j)-1.5)*baud)*dt
- do i=1,NSPS0
- k=k+1
- phi=mod(phi+dphi,twopi)
- if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(phi)
- enddo
- enddo
-
- rms=100.0
- if(snrdb.lt.90.0) then
- dat=rms*dat;
- if(maxval(abs(dat)).gt.32767.0) print*,"Warning - data will be clipped."
- else
- datpk=maxval(abs(dat))
- fac=32767.9/datpk
- dat=fac*dat
- endif
- iwave=nint(dat)
-
- return
-end subroutine wspr_wav
diff --git a/lib/fsk4hf/wsprcpm_params.f90 b/lib/fsk4hf/wsprcpm_params.f90 deleted file mode 100644 index b09ed86e..00000000 --- a/lib/fsk4hf/wsprcpm_params.f90 +++ /dev/null @@ -1,14 +0,0 @@ -parameter (KK=64) !Information bits (50 + CRC14) ?
-parameter (ND=200) !Data symbols: LDPC (204,68), r=1/3, don't send last 4 bits
-parameter (NS=16) !Sync symbols (16)
-parameter (NN=NS+ND) !Total symbols (216)
-
-parameter (NSPS0=6400) !Samples per symbol at 12000 S/s
-
-parameter (NDOWN=32) !Downsample to 200 sa/symbol (375 Hz) for candidate selection
-parameter (NSPS=NSPS0/NDOWN) !Samples per symbol
-parameter (NZ=NSPS*NN) !Samples in baseband waveform
-
-parameter (NZ0=NSPS0*NN) !Samples in waveform at 12000 S/s
-parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
diff --git a/lib/fsk4hf/wsprcpm_wav.f90 b/lib/fsk4hf/wsprcpm_wav.f90 deleted file mode 100644 index baf49a94..00000000 --- a/lib/fsk4hf/wsprcpm_wav.f90 +++ /dev/null @@ -1,44 +0,0 @@ -subroutine wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave)
-
-! Generate iwave() from itone().
-
- include 'wsprcpm_params.f90'
- parameter (NMAX=120*12000)
- integer itone(NN)
- integer*2 iwave(NMAX)
- real*8 twopi,dt,dphi0,dphi1,dphi,phi
- real dat(NMAX)
-
- twopi=8.d0*atan(1.d0)
- dt=1.d0/12000.d0
-
- dat=0.
- if(snrdb.lt.90) then
- do i=1,NMAX
- dat(i)=gran() !Generate gaussian noise
- enddo
- bandwidth_ratio=2500.0/6000.0
- sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
- else
- sig=1.0
- endif
-
- phi=0.d0
- k=nint(xdt/dt)
- do j=1,NN
- dphi=twopi*(f0+itone(j)*(h/2.0d0)*baud)*dt
- do i=1,NSPS0
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi)
- enddo
- enddo
- fac=32767.0
- rms=100.0
- if(snrdb.ge.90.0) iwave=nint(fac*dat)
- if(snrdb.lt.90.0) iwave=nint(rms*dat)
-
- return
-end subroutine wsprcpm_wav
diff --git a/lib/fsk4hf/wsprcpmd.f90 b/lib/fsk4hf/wsprcpmd.f90 deleted file mode 100644 index 281a2415..00000000 --- a/lib/fsk4hf/wsprcpmd.f90 +++ /dev/null @@ -1,550 +0,0 @@ -program wsprcpmd - -! Decode WSPRCPM data read from *.c2 or *.wav files. - -! WSPRCPM is a WSPR-like mode based on full-response CPM. -! -! Currently configured to use (204,68) r=1/3 LDPC code, regular column weight 3. -! 50 data bits + 14 bit CRC + 4 "0" bits. The 4 "0" bits are unused bits that -! are not transmitted. At the decoder, these bits are treated as "AP" bits. -! This shortens the code to (200,64) r=0.32, slightly decreasing the code rate. -! -! Frame format is: -! d100 p32 d100 (232) channel symbols -! - use crc - include 'wsprcpm_params.f90' - parameter(NMAX=120*12000) - character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11 - character*22 decodes(100) - character*120 data_dir - character*32 uwbits - character*68 dmsg - complex c2(0:120*12000/32-1) !Complex waveform - complex cframe(0:216*200-1) !Complex waveform - complex cd(0:216*10-1) !Complex waveform - complex c1(0:9,0:1),c0(0:9,0:1) - complex ccor(0:1,216) - complex csum,cterm - real*8 fMHz - real rxdata(ND),llr(204) !Soft symbols - real sbits(216),sbits1(216),sbits3(216) - real ps(0:8191),psbest(0:8191) - real candidates(100,2) - integer iuniqueword0 - integer isync(200) !Unique word - integer isync2(216) - integer ipreamble(16) !Preamble vector - integer ihdr(11) - integer*2 iwave(NMAX) !Generated full-length waveform - integer*1,target :: idat(9) - integer*1 decoded(68),apmask(204),cw(204) - integer*1 hbits(216),hbits1(216),hbits3(216) - data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/ - data iuniqueword0/z'30C9E8AD'/ - - write(uwbits,'(b32.32)') iuniqueword0 - read(uwbits,'(32i1)') isync(1:32) - read(uwbits,'(32i1)') isync(33:64) - read(uwbits,'(32i1)') isync(65:96) - read(uwbits,'(32i1)') isync(97:128) - read(uwbits,'(32i1)') isync(129:160) - read(uwbits,'(32i1)') isync(161:192) - read(uwbits,'(8i1)') isync(193:200) - - fs=12000.0/NDOWN !Sample rate - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - h=1.00 !h=0.8 seems to be optimum for AWGN sensitivity (not for fading) - twopi=8.0*atan(1.0) - - isync2(1:100)=isync(1:100) - isync2(101:104)=0 ! This is *not* backwards. - isync2(105:112)=1 - isync2(113:116)=0 - isync2(117:216)=isync(101:200) - -! data sync tone -! 0 0 0 -! 0 1 1 -! 1 0 2 -! 1 1 3 - dphi=twopi*baud*(h/2.0)*dt*20 ! dt*10 is samp interval after downsample - do j=0,1 - if(j.eq.0) then - dphi0=-3*dphi - dphi1=+1*dphi - else - dphi0=-1*dphi - dphi1=+3*dphi - endif - phi0=0.0 - phi1=0.0 - do i=0,9 - c1(i,j)=cmplx(cos(phi1),sin(phi1)) - c0(i,j)=cmplx(cos(phi0),sin(phi0)) - phi1=mod(phi1+dphi1,twopi) - phi0=mod(phi0+dphi0,twopi) - enddo - enddo - - nargs=iargc() - if(nargs.lt.1) then - print*,'Usage: wsprcpmd [-a <data_dir>] [-f fMHz] [-c ncoh] file1 [file2 ...]' - go to 999 - endif - iarg=1 - data_dir="." - call getarg(iarg,arg) - if(arg(1:2).eq.'-a') then - call getarg(iarg+1,data_dir) - iarg=iarg+2 - endif - call getarg(iarg,arg) - if(arg(1:2).eq.'-f') then - call getarg(iarg+1,arg) - read(arg,*) fMHz - iarg=iarg+2 - endif - ncoh=1 - npdi=16 - if(arg(1:2).eq.'-c') then - call getarg(iarg+1,arg) - read(arg,*) ncoh - iarg=iarg+2 - npdi=16/ncoh - endif -! write(*,*) 'ncoh: ',ncoh,' npdi: ',npdi - - open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', & - position='append') - - xs1=0.0 - xs2=0.0 - fr1=0.0 - fr2=0.0 - nav=0 - ngood=0 - - do ifile=iarg,nargs - call getarg(ifile,infile) - open(10,file=infile,status='old',access='stream') - j1=index(infile,'.c2') - j2=index(infile,'.wav') - if(j1.gt.0) then - read(10,end=999) fname,ntrmin,fMHz,c2 - read(fname(8:11),*) nutc - write(datetime,'(i11)') nutc - else if(j2.gt.0) then - read(10,end=999) ihdr,iwave - read(infile(j2-4:j2-1),*) nutc - datetime=infile(j2-11:j2-1) - call wsprcpm_downsample(iwave,c2) - else - print*,'Wrong file format?' - go to 999 - endif - close(10) - - fa=-100.0 - fb=100.0 - fs=12000.0/32.0 - npts=120*12000.0/32.0 - nsync=16 - call getcandidate2(c2,npts,fs,fa,fb,ncand,candidates) !First approx for freq -ndecodes=0 -do icand=1,ncand - fc0=candidates(icand,1) - xsnr=candidates(icand,2) - xmax=-1e32 - do i=-5,5 - ft=fc0+i*0.2 - call noncoherent_frame_sync(c2,ft,isync2,is,xf1) - if(xf1.gt.xmax) then - xmax=xf1 - fc1=ft - is0=is - endif - enddo - call coherent_preamble_fsync(c2,ipreamble,nsync,NSPS,is0,fc1,fcest,xp1) - call noncoherent_frame_sync(c2,fcest,isync2,istart,xf2) - write(*,'(i5,i5,i5,4(f11.5,2x))') ifile,iii,istart,fc0,fc1,fcest - -do ijitter=0,4 - io=-10*(ijitter/2+1) - if(mod(ijitter,2).eq.0) io=10*(ijitter/2) - ib=max(0,istart+io) - cframe=c2(ib:ib+216*200-1) - call downsample2(cframe,fcest,cd) - - s2=sum(cd*conjg(cd))/(10*216) - cd=cd/sqrt(s2) - - do nseq=1,7 - if( nseq.eq.1 ) then ! noncoherent single-symbol detection - sbits1=0.0 - do ibit=1,216 - j=isync2(ibit) - ib=(ibit-1)*10 - ccor(1,ibit)=sum(cd(ib:ib+9)*conjg(c1(0:9,j))) - ccor(0,ibit)=sum(cd(ib:ib+9)*conjg(c0(0:9,j))) - sbits1(ibit)=abs(ccor(1,ibit))-abs(ccor(0,ibit)) - hbits1(ibit)=0 - if(sbits1(ibit).gt.0) hbits1(ibit)=1 - enddo - sbits=sbits1 - hbits=hbits1 - sbits3=sbits1 - hbits3=hbits1 - elseif( nseq.ge.2 ) then - ps=0 - if( nseq.eq. 2 ) nbit=3 - if( nseq.eq. 3 ) nbit=5 - if( nseq.eq. 4 ) nbit=7 - if( nseq.eq. 5 ) nbit=9 - if( nseq.eq. 6 ) nbit=11 - if( nseq.eq. 7 ) nbit=13 - numseq=2**(nbit) - do ibit=nbit/2+1,216-nbit/2 - ps=0.0 - pmax=0.0 - do iseq=0,numseq-1 - csum=0.0 - cterm=1.0 - k=1 - do i=nbit-1,0,-1 - ibb=iand(iseq/(2**i),1) - csum=csum+ccor(ibb,ibit-(nbit/2+1)+k)*cterm - cterm=-cterm - k=k+1 - enddo - ps(iseq)=abs(csum) - if( ps(iseq) .gt. pmax ) then - pmax=ps(iseq) - ibflag=1 - endif - enddo - if( ibflag .eq. 1 ) then - psbest=ps - ibflag=0 - endif - call getmetric2(2**(nbit/2),psbest,numseq,sbits3(ibit)) - hbits3(ibit)=0 - if(sbits3(ibit).gt.0) hbits3(ibit)=1 - enddo - sbits=sbits3 - hbits=hbits3 - endif - rxdata(1:100)=sbits(1:100) - rxdata(101:200)=sbits(117:216); - rxav=sum(rxdata(1:200))/200.0 - rx2av=sum(rxdata(1:200)*rxdata(1:200))/200.0 - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - sigma=0.90 - llr(201:204)=-5.0 - llr(1:200)=2*rxdata/(sigma*sigma) - apmask=0 - apmask(201:204)=1 - max_iterations=40 - ifer=0 - call bpdecode204(llr,apmask,max_iterations,decoded,cw,nharderror,niterations) - nhardmin=-1 - if(nharderror.lt.0) call osd204(llr,apmask,5,decoded,cw,nhardmin,dmin) - if(sum(decoded).eq.0) cycle - if(nhardmin.ge.0 .or. nharderror.ge.0) then - idat=0 - write(dmsg,'(68i1)') decoded - read(dmsg(1:50),'(6b8.8,b2.2)') idat(1:7) - idat(7)=idat(7)*64 - read(dmsg(51:64),'(b14.14)') ndec_crc - ncalc_crc=iand(crc14(c_loc(idat),9),z'FFFF') - nbadcrc=1 - if(ncalc_crc .eq. ndec_crc) nbadcrc=0 - else - cycle - endif - if( nbadcrc.eq.0 ) then - write(cbits,1200) decoded(1:50) -1200 format(50i1) - read(cbits,1202) idat -1202 format(8b8,b4) - idat(7)=ishft(idat(7),6) - call wqdecode(idat,message,itype) - idupe=0 - do i=1,ndecodes - if(decodes(i).eq.message) idupe=1 - enddo - if(idupe.eq.1) goto 888 - ndecodes=ndecodes+1 - decodes(ndecodes)=message - nsnr=nint(xsnr) - freq=fMHz + 1.d-6*(fc1+fbest) - nfdot=0 - write(13,1210) datetime,0,nsnr,xdt,freq,message,nfdot -1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3) - write(*,1212) datetime(8:11),nsnr,xdt,freq,nfdot,message,'*',idf,nseq,ijitter,nharderror,nhardmin -1212 format(a4,i4,f5.1,f11.6,i3,2x,a22,a1,i5,i5,i5,i5,i5) - goto 888 - endif - enddo ! nseq -enddo !jitter -888 continue -enddo !candidate list - enddo !files - - write(*,1120) -1120 format("<DecodeFinished>") - -999 end program wsprcpmd - - -subroutine coherent_preamble_fsync(c2,ipreamble,nsync,nsps,istart,fc0,fc1,xmax) - complex c2(0:120*12000/32-1) - complex cpreamble(0:16*200-1) - complex ctmp1(0:4*16*200-1) - complex ctwkp(0:16*200-1) - complex ccohp(0:15) - integer ipreamble(nsync) - logical first/.true./ - save dt,first,h,twopi,cpreamble - - if(first) then - baud=12000.0/6400.0 - dt=32.0/12000.0 - h=1.00 - twopi=8.0*atan(1.0) - k=0 - phi=0.0 - dphi=twopi*baud*0.5*h*dt - do i=1,16 - dp=dphi - if(ipreamble(i).eq.0) dp=-dphi - do j=1,200 - cpreamble(k)=cmplx(cos(phi),sin(phi)) - phi=mod(phi+dp,twopi) - k=k+1 - enddo - enddo - first=.false. - endif - - dphi=twopi*fc0*dt - ctwkp=cmplx(0.0,0.0) - phi=0 - do i=0,nsync*nsps-1 - ctwkp(i)=cpreamble(i)*cmplx(cos(phi),sin(phi)) - phi=mod(phi+dphi,twopi) - enddo - ipstart=istart+100*200 - ctmp1=0.0 - ctmp1(0:16*200-1)=c2(ipstart:ipstart+16*200-1)*conjg(ctwkp) - call four2a(ctmp1,4*16*200,1,-1,1) !c2c FFT to freq domain - xmax=0.0 - ctmp1=cshift(ctmp1,-200) - dfp=1/(4*6400.0/12000.0*16) - do i=150,250 - xa=abs(ctmp1(i)) - if(xa.gt.xmax) then - ishift=i - xmax=xa - endif - enddo - delta=(ishift-200)*dfp - xm1=abs(ctmp1(ishift-1)) - x0=abs(ctmp1(ishift)) - xp1=abs(ctmp1(ishift+1)) - xint=(log(xm1)-log(xp1))/(log(xm1)+log(xp1)-2*log(x0)) - delta2=delta+xint*dfp/2.0 - fc1=fc0+delta2 - return -end subroutine coherent_preamble_fsync - - -subroutine noncoherent_frame_sync(c2,fc,isync2,istart,ssmax) - complex c2(0:120*12000/32-1) - complex ct0(0:199),ct1(0:199),ct2(0:199),ct3(0:199) - integer isync2(216) - - twopi=8.0*atan(1.0) - h=1.0 - dt=32.0/12000.0 - baud=12000.0/6400.0 - imax=370 ! defines dt search range (375 samples/s) - ssmax=-1e32 - izero=375 - do it = -imax,imax,10 -! noncoherent wspr-type dt estimation - dp0=twopi*(fc-1.5*h*baud)*dt - dp1=twopi*(fc-0.5*h*baud)*dt - dp2=twopi*(fc+0.5*h*baud)*dt - dp3=twopi*(fc+1.5*h*baud)*dt - th0=0.0 - th1=0.0 - th2=0.0 - th3=0.0 - do i=0,199 - ct0(i)=cmplx(cos(th0),sin(th0)) - ct1(i)=cmplx(cos(th1),sin(th1)) - ct2(i)=cmplx(cos(th2),sin(th2)) - ct3(i)=cmplx(cos(th3),sin(th3)) - th0=mod(th0+dp0,twopi) - th1=mod(th1+dp1,twopi) - th2=mod(th2+dp2,twopi) - th3=mod(th3+dp3,twopi) - enddo - ss=0.0 - totp=0.0 - do is=1,216 - i0=izero+it+(is-1)*200 - p0=abs(sum(c2(i0:i0+199)*conjg(ct0))) - p1=abs(sum(c2(i0:i0+199)*conjg(ct1))) - p2=abs(sum(c2(i0:i0+199)*conjg(ct2))) - p3=abs(sum(c2(i0:i0+199)*conjg(ct3))) - p0=sqrt(p0) - p1=sqrt(p1) - p2=sqrt(p2) - p3=sqrt(p3) - - totp=totp+p0+p1+p2+p3 -! cmet=(p1+p3)-(p0+p2) - cmet=max(p1,p3)-max(p0,p2) ! This works better near threshold SNR - if(isync2(is).eq.0) ss=ss-cmet - if(isync2(is).eq.1) ss=ss+cmet - enddo - ss=ss/totp - if(ss.gt.ssmax) then - ioffset=it - ssmax=ss - endif - enddo - istart=izero+ioffset - return -end subroutine noncoherent_frame_sync - -subroutine getmetric2(ib,ps,ns,xmet) - real ps(0:ns-1) - xm1=0 - xm0=0 - do i=0,ns-1 - if( iand(i/ib,1) .eq. 1 .and. ps(i) .gt. xm1 ) xm1=ps(i) - if( iand(i/ib,1) .eq. 0 .and. ps(i) .gt. xm0 ) xm0=ps(i) - enddo - xmet=xm1-xm0 - return -end subroutine getmetric2 - -subroutine downsample2(ci,f0,co) - parameter(NI=216*200,NH=NI/2,NO=NI/20) ! downsample from 200 samples per symbol to 10 - complex ci(0:NI-1),ct(0:NI-1) - complex co(0:NO-1) - fs=12000.0/32.0 - df=fs/NI - ct=ci - call four2a(ct,NI,1,-1,1) !c2c FFT to freq domain - i0=nint(f0/df) - ct=cshift(ct,i0) - co=0.0 - co(0)=ct(0) - b=8.0 - do i=1,NO/2 - arg=(i*df/b)**2 - filt=exp(-arg) - co(i)=ct(i)*filt - co(NO-i)=ct(NI-i)*filt - enddo - co=co/NO - call four2a(co,NO,1,1,1) !c2c FFT back to time domain - return -end subroutine downsample2 - -subroutine getcandidate2(c,npts,fs,fa,fb,ncand,candidates) - parameter(NDAT=200,NFFT1=120*12000/32,NH1=NFFT1/2,NFFT2=120*12000/320,NH2=NFFT2/2) - complex c(0:npts-1) !Complex waveform - complex cc(0:NFFT1-1) - complex csfil(0:NFFT2-1) - complex cwork(0:NFFT2-1) - real bigspec(0:NFFT2-1) - complex c2(0:NFFT1-1) !Short spectra - real s(-NH1+1:NH1) !Coarse spectrum - real ss(-NH1+1:NH1) !Smoothed coarse spectrum - real candidates(100,2) - integer indx(NFFT2-1) - logical first - data first/.true./ - save first,w,df,csfil - - if(first) then - df=10*fs/NFFT1 - csfil=cmplx(0.0,0.0) - do i=0,NFFT2-1 - csfil(i)=exp(-((i-NH2)/20.0)**2) - enddo - csfil=cshift(csfil,NH2) - call four2a(csfil,NFFT2,1,-1,1) - first=.false. - endif - - cc=cmplx(0.0,0.0) - cc(0:npts-1)=c; - call four2a(cc,NFFT1,1,-1,1) - cc=abs(cc)**2 - call four2a(cc,NFFT1,1,-1,1) - cwork(0:NH2)=cc(0:NH2)*conjg(csfil(0:NH2)) - cwork(NH2+1:NFFT2-1)=cc(NFFT1-NH2+1:NFFT1-1)*conjg(csfil(NH2+1:NFFT2-1)) - - call four2a(cwork,NFFT2,1,+1,1) - bigspec=cshift(real(cwork),-NH2) - il=NH2+fa/df - ih=NH2+fb/df - nnl=ih-il+1 - call indexx(bigspec(il:il+nnl-1),nnl,indx) - xn=bigspec(il-1+indx(nint(0.3*nnl))) - bigspec=bigspec/xn - ncand=0 - do i=il,ih - if((bigspec(i).gt.bigspec(i-1)).and. & - (bigspec(i).gt.bigspec(i+1)).and. & - (bigspec(i).gt.1.15).and.ncand.lt.100) then - ncand=ncand+1 - candidates(ncand,1)=df*(i-NH2) - candidates(ncand,2)=10*log10(bigspec(i))-30.0 - endif - enddo -! do i=1,ncand -! write(*,*) i,candidates(i,1),candidates(i,2) -! enddo - return -end subroutine getcandidate2 - -subroutine wsprcpm_downsample(iwave,c) - -! Input: i*2 data in iwave() at sample rate 12000 Hz -! Output: Complex data in c(), sampled at 400 Hz - - include 'wsprcpm_params.f90' - parameter (NMAX=120*12000,NFFT2=NMAX/32) - integer*2 iwave(NMAX) - complex c(0:NMAX/32-1) - complex c1(0:NFFT2-1) - complex cx(0:NMAX/2) - real x(NMAX) - equivalence (x,cx) - - df=12000.0/NMAX - x=iwave - call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain - i0=nint(1500.0/df) - c1(0)=cx(i0) - do i=1,NFFT2/2 - c1(i)=cx(i0+i) - c1(NFFT2-i)=cx(i0-i) - enddo - c1=c1/NFFT2 - call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain - c=c1(0:NMAX/32-1) - return -end subroutine wsprcpm_downsample - diff --git a/lib/fsk4hf/wsprcpmsim.f90 b/lib/fsk4hf/wsprcpmsim.f90 deleted file mode 100644 index 6a1f87f3..00000000 --- a/lib/fsk4hf/wsprcpmsim.f90 +++ /dev/null @@ -1,109 +0,0 @@ -program wsprcpmsim - -! Generate simulated data for a 2-minute "WSPR-LF" mode. Output is saved -! to a *.c2 or *.wav file. - - use wavhdr - include 'wsprcpm_params.f90' !Set various constants - parameter (NMAX=120*12000) - type(hdr) hwav !Header for .wav file - character arg*12,fname*16 - character msg*22,msgsent*22 - complex c0(0:NMAX/NDOWN-1) - complex c(0:NMAX/NDOWN-1) - real*8 fMHz - integer itone(NN) - integer*2 iwave(NMAX) !Generated full-length waveform - -! Get command-line argument(s) - nargs=iargc() - if(nargs.ne.8) then - print*,'Usage: wsprmsksim "message" f0 DT fsp del nwav nfiles snr' - print*,'Example: wsprmsksim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33' - go to 999 - endif - call getarg(1,msg) !Message to be transmitted - call getarg(2,arg) - read(arg,*) f0 !Freq relative to WSPR-band center (Hz) - call getarg(3,arg) - read(arg,*) xdt !Time offset from nominal (s) - call getarg(4,arg) - read(arg,*) fspread !Watterson frequency spread (Hz) - call getarg(5,arg) - read(arg,*) delay !Watterson delay (ms) - call getarg(6,arg) - read(arg,*) nwav !1 for *.wav file, 0 for *.c2 file - call getarg(7,arg) - read(arg,*) nfiles !Number of files - call getarg(8,arg) - read(arg,*) snrdb !SNR_2500 - - twopi=8.0*atan(1.0) - fs=12000.0/NDOWN ! - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - bandwidth_ratio=2500.0/(fs/2.0) - sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - txt=NN*NSPS0/12000.0 - - call genwsprcpm(msg,msgsent,itone) !Encode the message, get itone - write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent -1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, & - ' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22) - - h=1.00 - c0=0. - k=-1 + nint(xdt/dt) - do j=1,NN - dp=twopi*(f0+itone(j)*(h/2.0)*baud)*dt - do i=1,NSPS - k=k+1 - phi=mod(phi+dp,twopi) - if(k.ge.0 .and. k.lt.NMAX/NDOWN) c0(k)=cmplx(cos(phi),sin(phi)) - enddo - enddo - call sgran() - do ifile=1,nfiles - c=c0 - if(nwav.eq.0) then - if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then - call watterson(c,NMAX/NDOWN,fs,delay,fspread) - endif -!do i=0,NMAX/NDOWN-1 -!write(23,*) i,real(c(i)),imag(c(i)) -!enddo - c=c*sig - if(snrdb.lt.90) then - do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR - xnoise=gran() - ynoise=gran() - c(i)=c(i) + cmplx(xnoise,ynoise) - enddo - endif - write(fname,1100) ifile -1100 format('000000_',i4.4,'.c2') - open(10,file=fname,status='unknown',access='stream') - fMHz=10.1387d0 - nmin=2 - write(10) fname,nmin,fMHz,c !Save to *.c2 file - close(10) -!do i=0,NMAX/NDOWN-1 -!write(57,*) i,real(c(i)),imag(c(i)) -!enddo - else - call wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave) - hwav=default_header(12000,NMAX) - write(fname,1102) ifile -1102 format('000000_',i4.4,'.wav') - open(10,file=fname,status='unknown',access='stream') - write(10) hwav,iwave !Save to *.wav file - close(10) - endif - write(*,1110) ifile,xdt,f0,snrdb,fname -1110 format(i4,f7.2,f8.2,f7.1,2x,a16) - enddo - -999 end program wsprcpmsim diff --git a/lib/fsk4hf/wsprdpskd.f90 b/lib/fsk4hf/wsprdpskd.f90 deleted file mode 100644 index 223e2e4f..00000000 --- a/lib/fsk4hf/wsprdpskd.f90 +++ /dev/null @@ -1,439 +0,0 @@ -program wsprdpskd - -! Decode WSPRDPSK data read from *.c2 or *.wav files. - -! Currently configured to use (204,68) r=1/3 LDPC code, regular column weight 3. -! 50 data bits + 14 bit CRC + 4 "0" bits. The 4 "0" bits are unused bits that -! are not transmitted. At the decoder, these bits are treated as "AP" bits. -! This shortens the code to (200,64) r=0.32, slightly decreasing the code rate. -! Frame format is: -! d100 p32 d100 (232) channel symbols -! - use crc - include 'wsprdpsk_params.f90' - parameter(NMAX=120*12000) - character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11 - character*22 decodes(100) - character*120 data_dir - character*32 uwbits - character*68 dmsg - complex c2(0:120*12000/30-1) !Complex waveform - complex cframe(0:232*200-1) !Complex waveform - complex cd(0:240*10-1) !Complex waveform - complex cs(0:240) - complex c1(0:9,0:1),c0(0:9,0:1) - complex ccor(0:1,232) - complex csum,cterm - real*8 fMHz - real rxdata(ND),llr(204) !Soft symbols - real sbits(232),sbits1(232),sbits3(232) - real ps(0:8191),psbest(0:8191) - real candidates(100,2) - integer iuniqueword0 - integer isync(200) !Unique word - integer isync2(232) - integer ipreamble(16) !Preamble vector - integer ihdr(11) - integer*2 iwave(NMAX) !Generated full-length waveform - integer*1,target :: idat(9) - integer*1 decoded(68),apmask(204),cw(204) - integer*1 hbits(232),hbits1(232),hbits3(232) - integer*1 b(14),bbest(14) - data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/ - data iuniqueword0/z'30C9E8AD'/ - - write(uwbits,'(b32.32)') iuniqueword0 - read(uwbits,'(32i1)') isync(1:32) - read(uwbits,'(32i1)') isync(33:64) - read(uwbits,'(32i1)') isync(65:96) - read(uwbits,'(32i1)') isync(97:128) - read(uwbits,'(32i1)') isync(129:160) - read(uwbits,'(32i1)') isync(161:192) - read(uwbits,'(8i1)') isync(193:200) - - fs=12000.0/NDOWN !Sample rate - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - h=1.00 !h=0.8 seems to be optimum for AWGN sensitivity (not for fading) - twopi=8.0*atan(1.0) - - isync2(1:100)=isync(1:100) - isync2(101:104)=0 ! This is *not* backwards. - isync2(105:112)=1 - isync2(113:116)=0 - isync2(117:216)=isync(101:200) - - dphi=twopi*baud*(h/2.0)*dt*20 ! dt*20 is samp interval after downsample - do j=0,1 - if(j.eq.0) then - dphi0=-3*dphi - dphi1=+1*dphi - else - dphi0=-1*dphi - dphi1=+3*dphi - endif - phi0=0.0 - phi1=0.0 - do i=0,9 - c1(i,j)=cmplx(cos(phi1),sin(phi1)) - c0(i,j)=cmplx(cos(phi0),sin(phi0)) - phi1=mod(phi1+dphi1,twopi) - phi0=mod(phi0+dphi0,twopi) - enddo - enddo - - nargs=iargc() - if(nargs.lt.1) then - print*,'Usage: wsprdpskd [-a <data_dir>] [-f fMHz] [-c ncoh] file1 [file2 ...]' - go to 999 - endif - iarg=1 - data_dir="." - call getarg(iarg,arg) - if(arg(1:2).eq.'-a') then - call getarg(iarg+1,data_dir) - iarg=iarg+2 - endif - call getarg(iarg,arg) - if(arg(1:2).eq.'-f') then - call getarg(iarg+1,arg) - read(arg,*) fMHz - iarg=iarg+2 - endif - ncoh=1 - npdi=16 - if(arg(1:2).eq.'-c') then - call getarg(iarg+1,arg) - read(arg,*) ncoh - iarg=iarg+2 - npdi=16/ncoh - endif -! write(*,*) 'ncoh: ',ncoh,' npdi: ',npdi - - open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', & - position='append') - - xs1=0.0 - xs2=0.0 - fr1=0.0 - fr2=0.0 - nav=0 - ngood=0 - - do ifile=iarg,nargs - call getarg(ifile,infile) - open(10,file=infile,status='old',access='stream') - j1=index(infile,'.c2') - j2=index(infile,'.wav') - if(j1.gt.0) then - read(10,end=999) fname,ntrmin,fMHz,c2 - read(fname(8:11),*) nutc - write(datetime,'(i11)') nutc - else if(j2.gt.0) then - read(10,end=999) ihdr,iwave - read(infile(j2-4:j2-1),*) nutc - datetime=infile(j2-11:j2-1) - call wsprdpsk_downsample(iwave,c2) - else - print*,'Wrong file format?' - go to 999 - endif - close(10) - - fa=-10.0 - fb=10.0 - fs=12000.0/30.0 - npts=120*12000.0/30.0 -! call getcandidate2(c2,npts,fs,fa,fb,ncand,candidates) !First approx for freq - ncand=1 - candidates(1,1)=0.0 - candidates(1,2)=-28 - ndecodes=0 - do icand=1,ncand - fc0=candidates(icand,1) - xsnr=candidates(icand,2) - call dsdpsk(c2,fc0,cd) - i0=40 - do i=0,231 - cs(i)=cd(i0+10*i)/5e4 - enddo -! 2-bit differential detection - do i=1,231 -! do i=1,232 - sbits(i)=-real(cs(i)*conjg(cs(i-1))) !2 symbol dpsk -! sbits(i)=real(cs(i-1)) !for coherent dpsk -! sbits(i)=real(cs(i)) !for coherent bpsk - enddo -! do i=1,231 -! sbits3(i)=-sbits(i+1)*sbits(i) ! for coherent dpsk -! enddo - -! detect a differentially encoded block of symbols using the -! Divsalar and Simon approach, except that we estimate only -! the central symbol of the block and then step the block forward -! by one symbol. -! - sbits3=sbits -!goto 100 - nbit=13 ! number of decoded bits to be derived from nbit+1 symbols - numseq=2**nbit - il=(nbit+1)/2 - ih=231-nbit/2 - do isym=il,ih - rmax=-1e32 - b=0 - do iseq=0,numseq-1 - do i=1,nbit - b(i)=merge(1,0,iand(iseq,2**(nbit-i))>0) - enddo - b(1:nbit)=2*b(1:nbit)-1 - i1=isym-(nbit+1)/2 - csum=cs(i1) - do i=1,nbit - bb=1 - do m=1,i - bb=bb*b(m) - enddo - csum=csum+bb*cs(i1+i) - enddo -! ps(iseq)=abs(csum)**2 - ps(iseq)=abs(csum) - if(ps(iseq).gt.rmax) then - bbest=b - rmax=ps(iseq) - endif - enddo - if(isym.eq.il) then - do i=1,isym-1 - call getmetric(2**(nbit-i),ps,numseq,xmet) - sbits3(i)=-xmet - enddo - endif - call getmetric(2**((nbit-1)/2),ps,numseq,xmet) - sbits3(isym)=-xmet - if(isym.eq.ih) then - do i=ih+1,231 - call getmetric(2**(231-i),ps,numseq,xmet) - sbits3(i)=-xmet - enddo - endif - enddo -100 continue - rxdata(1:100)=sbits3(1:100) - rxdata(101:200)=sbits3(132:231); - rxav=sum(rxdata(1:200))/200.0 - rx2av=sum(rxdata(1:200)*rxdata(1:200))/200.0 - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - sigma=0.90 - llr(201:204)=-5.0 - llr(1:200)=2*rxdata/(sigma*sigma) - apmask=0 - apmask(201:204)=1 - max_iterations=40 - ifer=0 - call bpdecode204(llr,apmask,max_iterations,decoded,cw,nharderror,niterations) - nhardmin=-1 - if(nharderror.lt.0) call osd204(llr,apmask,5,decoded,cw,nhardmin,dmin) - if(sum(decoded).eq.0) cycle - if(nhardmin.ge.0 .or. nharderror.ge.0) then - idat=0 - write(dmsg,'(68i1)') decoded - read(dmsg(1:50),'(6b8.8,b2.2)') idat(1:7) - idat(7)=idat(7)*64 - read(dmsg(51:64),'(b14.14)') ndec_crc - ncalc_crc=iand(crc14(c_loc(idat),9),z'FFFF') - nbadcrc=1 - if(ncalc_crc .eq. ndec_crc) nbadcrc=0 - else - cycle - endif - if( nbadcrc.eq.0 ) then - write(cbits,1200) decoded(1:50) -1200 format(50i1) - read(cbits,1202) idat -1202 format(8b8,b4) - idat(7)=ishft(idat(7),6) - call wqdecode(idat,message,itype) - idupe=0 - do i=1,ndecodes - if(decodes(i).eq.message) idupe=1 - enddo - if(idupe.eq.1) goto 888 - ndecodes=ndecodes+1 - decodes(ndecodes)=message - nsnr=nint(xsnr) - freq=fMHz + 1.d-6*(fc1+fbest) - nfdot=0 - write(13,1210) datetime,0,nsnr,xdt,freq,message,nfdot -1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3) - write(*,1212) datetime(8:11),nsnr,xdt,freq,nfdot,message,'*',idf,nseq,ijitter,nharderror,nhardmin -1212 format(a4,i4,f5.1,f11.6,i3,2x,a22,a1,i5,i5,i5,i5,i5) - goto 888 - endif -888 continue - enddo !candidate list - enddo !files - - write(*,1120) -1120 format("<DecodeFinished>") - -999 end program wsprdpskd - -subroutine getmetric(ib,ps,ns,xmet) - real ps(0:ns-1) - xm1=-1e32 - xm0=-1e32 - do i=0,ns-1 - if( iand(i/ib,1) .eq. 1 .and. ps(i) .gt. xm1 ) then - xm1=ps(i) - endif - if( iand(i/ib,1) .eq. 0 .and. ps(i) .gt. xm0 ) then - xm0=ps(i) - endif - enddo - xmet=xm1-xm0 - return -end subroutine getmetric - -subroutine getmetric3(ib,ps,ns,xmet) - real ps(0:ns-1) - xm1=0 - xm0=0 - do i=0,ns-1 - if( iand(i/ib,1) .eq. 1 ) then - xm1=xm1+ps(i) - endif - if( iand(i/ib,1) .eq. 0 ) then - xm0=xm0+ps(i) - endif - enddo - xmet=xm1-xm0 - return -end subroutine getmetric3 - -subroutine dsdpsk(ci,f0,co) - parameter(NI=240*200,NH=NI/2,NO=NI/20) ! downsample from 200 samples per symbol to 10 - complex ci(0:NI-1),ct(0:NI-1) - complex co(0:NO-1) - - pi=4.0*atan(1.0) - fs=12000.0/30.0 - df=fs/NI - ct=ci - call four2a(ct,NI,1,-1,1) !c2c FFT to freq domain - i0=nint(f0/df) - ct=cshift(ct,i0) - co=0.0 - co(0)=ct(0) - - dt=20/fs - beta=1.0 - tt=10*dt - baud=1/tt - bw=(1+beta)*baud/2.0 - bf=(1-beta)*baud/2.0 - iw=bw/df - if=bf/df - co=0.0 - co(0)=ct(0) - do i=1,iw - filt=((1.0+cos(pi*(i-if)/(iw-if)))/2.0)**0.5 - co(i)=ct(i)*filt - co(NO-i)=ct(NI-i)*filt - enddo - co=co/NO - call four2a(co,NO,1,1,1) !c2c FFT back to time domain - return -end subroutine dsdpsk - -subroutine getcandidate2(c,npts,fs,fa,fb,ncand,candidates) - parameter(NDAT=200,NFFT1=120*12000/30,NH1=NFFT1/2,NFFT2=120*12000/300,NH2=NFFT2/2) - complex c(0:npts-1) !Complex waveform - complex cc(0:NFFT1-1) - complex csfil(0:NFFT2-1) - complex cwork(0:NFFT2-1) - real bigspec(0:NFFT2-1) - complex c2(0:NFFT1-1) !Short spectra - real s(-NH1+1:NH1) !Coarse spectrum - real ss(-NH1+1:NH1) !Smoothed coarse spectrum - real candidates(100,2) - integer indx(NFFT2-1) - logical first - data first/.true./ - save first,w,df,csfil - - if(first) then - df=10*fs/NFFT1 - csfil=cmplx(0.0,0.0) - do i=0,NFFT2-1 - csfil(i)=exp(-((i-NH2)/20.0)**2) - enddo - csfil=cshift(csfil,NH2) - call four2a(csfil,NFFT2,1,-1,1) - first=.false. - endif - - cc=cmplx(0.0,0.0) - cc(0:npts-1)=c; - call four2a(cc,NFFT1,1,-1,1) - cc=abs(cc)**2 - call four2a(cc,NFFT1,1,-1,1) - cwork(0:NH2)=cc(0:NH2)*conjg(csfil(0:NH2)) - cwork(NH2+1:NFFT2-1)=cc(NFFT1-NH2+1:NFFT1-1)*conjg(csfil(NH2+1:NFFT2-1)) - - call four2a(cwork,NFFT2,1,+1,1) - bigspec=cshift(real(cwork),-NH2) - il=NH2+fa/df - ih=NH2+fb/df - nnl=ih-il+1 - call indexx(bigspec(il:il+nnl-1),nnl,indx) - xn=bigspec(il-1+indx(nint(0.3*nnl))) - bigspec=bigspec/xn - ncand=0 - do i=il,ih - if((bigspec(i).gt.bigspec(i-1)).and. & - (bigspec(i).gt.bigspec(i+1)).and. & - (bigspec(i).gt.1.15).and.ncand.lt.100) then - ncand=ncand+1 - candidates(ncand,1)=df*(i-NH2) - candidates(ncand,2)=10*log10(bigspec(i))-30.0 - endif - enddo -! do i=1,ncand -! write(*,*) i,candidates(i,1),candidates(i,2) -! enddo - return -end subroutine getcandidate2 - -subroutine wsprdpsk_downsample(iwave,c) - -! Input: i*2 data in iwave() at sample rate 12000 Hz -! Output: Complex data in c(), sampled at 400 Hz - - include 'wsprdpsk_params.f90' - parameter (NMAX=120*12000,NFFT2=NMAX/30) - integer*2 iwave(NMAX) - complex c(0:NMAX/30-1) - complex c1(0:NFFT2-1) - complex cx(0:NMAX/2) - real x(NMAX) - equivalence (x,cx) - - df=12000.0/NMAX - x=iwave - call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain - i0=nint(1500.0/df) - c1(0)=cx(i0) - do i=1,NFFT2/2 - c1(i)=cx(i0+i) - c1(NFFT2-i)=cx(i0-i) - enddo - c1=c1/NFFT2 - call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain - c=c1(0:NMAX/30-1) - return -end subroutine wsprdpsk_downsample - diff --git a/lib/fsk4hf/wsprdpsksim.f90 b/lib/fsk4hf/wsprdpsksim.f90 deleted file mode 100644 index fa5e34e4..00000000 --- a/lib/fsk4hf/wsprdpsksim.f90 +++ /dev/null @@ -1,175 +0,0 @@ -program wsprdpsksim - -! Generate simulated data for a 2-minute "WSPR-DPSK" mode. Output is saved -! to a *.c2 or *.wav file. - - use wavhdr - include 'wsprdpsk_params.f90' !Set various constants - parameter (NMAX=120*12000) - type(hdr) hwav !Header for .wav file - character arg*12,fname*16 - character msg*22,msgsent*22 - complex c0(0:NMAX/NDOWN-1) - complex c(0:NMAX/NDOWN-1) - complex c0wav(0:NMAX-1) - complex cwav(0:NMAX-1) - real*8 fMHz - integer imessage(NN) - integer*2 iwave(NMAX) !Generated full-length waveform - -! Get command-line argument(s) - nargs=iargc() - if(nargs.ne.8) then - print*,'Usage: wsprdpsksim "message" f0 DT fsp del nwav nfiles snr' - print*,'Example: wsprdpsksim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33' - go to 999 - endif - call getarg(1,msg) !Message to be transmitted - call getarg(2,arg) - read(arg,*) f0 !Freq relative to WSPR-band center (Hz) - call getarg(3,arg) - read(arg,*) xdt !Time offset from nominal (s) - call getarg(4,arg) - read(arg,*) fspread !Watterson frequency spread (Hz) - call getarg(5,arg) - read(arg,*) delay !Watterson delay (ms) - call getarg(6,arg) - read(arg,*) nwav !1 for *.wav file, 0 for *.c2 file - call getarg(7,arg) - read(arg,*) nfiles !Number of files - call getarg(8,arg) - read(arg,*) snrdb !SNR_2500 - - twopi=8.0*atan(1.0) - pi=twopi/2.0 - fs=12000.0/NDOWN - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - bandwidth_ratio=2500.0/(fs/2.0) - sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - txt=NN*NSPS0/12000.0 - - call genwsprdpsk(msg,msgsent,imessage) !Encode the message, get itone - imessage=2*imessage-1 - write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent -1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, & - ' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22) - - - beta=1.0 ! excess bandwidth - if(nwav.eq.0) then - df=fs/(NMAX/NDOWN) ! - c=0 - bw=(1+beta)*baud/2.0 - bf=(1-beta)*baud/2.0 - iw=bw/df - if=bf/df - c(0:if-1)=1.0 - if(iw.gt.if) then - do i=if,iw - c(i)=((1.0+cos(pi*(i-if)/(iw-if)))/2.0)**0.5 - enddo - endif - c(NMAX/NDOWN-1:NMAX/NDOWN-iw:-1)=c(1:iw) - - istart=xdt/dt - c0=0.0 - do i=1,NN - c0(istart+(i-1)*200)=imessage(i) - enddo - call four2a(c0,NMAX/NDOWN,1,1,1) - c0=c0*conjg(c) - ic=f0/df - c0=cshift(c0,ic) - call four2a(c0,NMAX/NDOWN,1,-1,1) - xx=sum(abs(c0(istart:istart+NN*200-1)**2))/(NN*200) - c0=c0/sqrt(xx) - - call sgran() - do ifile=1,nfiles - c=c0 - if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then - call watterson(c,NMAX/NDOWN,fs,delay,fspread) - endif - c=c*sig - if(snrdb.lt.90) then - do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR - xnoise=gran() - ynoise=gran() - c(i)=c(i) + cmplx(xnoise,ynoise) - enddo - endif -snrtest=sum(abs(c(istart:istart+NN*200-1)**2))/(NN*200)/2.0-1.0 -write(*,*) 'sample SNR: ',10*log10(snrtest)+10*log10(0.4/2.5) - write(fname,1100) ifile -1100 format('000000_',i4.4,'.c2') - open(10,file=fname,status='unknown',access='stream') - fMHz=10.1387d0 - nmin=2 - write(10) fname,nmin,fMHz,c !Save to *.c2 file - close(10) - enddo - else - fs=12000.0 - df=fs/NMAX - dt=1/fs - bandwidth_ratio=2500.0/(fs/2.0) - sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - cwav=0 - bw=(1+beta)*baud/2.0 - bf=(1-beta)*baud/2.0 - iw=bw/df - if=bf/df - cwav(0:if-1)=1.0 - if(iw.gt.if) then - do i=if,iw - cwav(i)=((1.0+cos(pi*(i-if)/(iw-if)))/2.0)**0.5 - enddo - endif - cwav(NMAX-1:NMAX-iw:-1)=cwav(1:iw) - - istart=xdt/dt - c0wav=0.0 - do i=1,NN - c0wav(istart+(i-1)*200*NDOWN)=imessage(i) - enddo - call four2a(c0wav,NMAX,1,1,1) - c0wav=c0wav*conjg(cwav) - ic=f0/df - c0wav=cshift(c0wav,-ic) - call four2a(c0wav,NMAX,1,-1,1) - xx=sum(abs(c0wav(istart:istart+NN*200*NDOWN-1))**2)/(NN*200*NDOWN) - c0wav=c0wav/sqrt(xx) -write(*,*) 'Peak power: ',maxval(abs(c0wav)**2) -write(*,*) 'Average power: ',sum(abs(c0wav(istart:istart+NN*200*NDOWN-1))**2)/(NN*200*NDOWN) - call sgran() - do ifile=1,nfiles - cwav=c0wav - if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then - call watterson(cwav,NMAX,fs,delay,fspread) - endif - cwav=cwav*sig - if(snrdb.lt.90) then - do i=1,NMAX !Add gaussian noise at specified SNR - xnoise=gran() - iwave(i)=100*(real(cwav(i-1)) + xnoise) - enddo - endif -snrtest=sum(real(iwave(istart:istart+NN*200*NDOWN-1)**2)/(NN*200*NDOWN))/100.0**2-1 -write(*,*) 'sample SNR: ',10*log10(snrtest)+10*log10(6.0/2.5) - hwav=default_header(12000,NMAX) - write(fname,1102) ifile -1102 format('000000_',i4.4,'.wav') - open(10,file=fname,status='unknown',access='stream') - write(10) hwav,iwave !Save to *.wav file - close(10) - enddo - endif - write(*,1110) ifile,xdt,f0,snrdb,fname -1110 format(i4,f7.2,f8.2,f7.1,2x,a16) - -999 end program wsprdpsksim diff --git a/lib/fsk4hf/wsprlf.f90 b/lib/fsk4hf/wsprlf.f90 deleted file mode 100644 index efc3e846..00000000 --- a/lib/fsk4hf/wsprlf.f90 +++ /dev/null @@ -1,110 +0,0 @@ -program wsprlf - - parameter (NN=121) !Total symbols - parameter (NSPS=28800) !Samples per symbol @ fs=12000 Hz - parameter (NZ=NSPS*NN) !Samples in waveform - - character*8 arg - complex c(0:NZ-1) - real*8 twopi,fs,f0,dt,phi,dphi - real x(0:NZ-1) - real p(0:NZ/2) - real h0(0:NSPS/2) !Pulse shape, rising edge - real h1(0:NSPS/2) !Pulse shape, trailing edge - real tmp(NN) - integer id(NN) !Generated data - integer ie(NN) !Differentially encoded data - data fs/12000.d0/ - - nargs=iargc() - if(nargs.ne.3) then - print*,'Usage: wsprlf f0 t1 snr' - goto 999 - endif - call getarg(1,arg) - read(arg,*) f0 - call getarg(2,arg) - read(arg,*) t1 - call getarg(3,arg) - read(arg,*) snrdb - - call random_number(tmp) !Generate random bipolar data - id=1 - where(tmp.lt.0.5) id=-1 - ie(1)=1 - do i=2,NN !Differentially encode - ie(i)=id(i)*ie(i-1) - enddo - - n1=nint(t1*NSPS) - twopi=8.d0*atan(1.d0) - - do i=0,2*n1-1 !Define the shape functions - if(i.le.n1-1) then - h0(i)=0.5*(1.0-cos(0.5*i*twopi/n1)) - else - h1(i-n1)=0.5*(1.0-cos(0.5*i*twopi/n1)) - endif - enddo - if(t1.eq.0.0) h0=1 - if(t1.eq.0.0) h1=1 - -! Shape the channel pulses - x=1. - x(0:n1-1)=h0(0:n1-1) !Leading edge of 1st pulse - do j=2,NN !Leading edges - if(ie(j).ne.ie(j-1)) then - ia=(j-1)*NSPS + 1 - ib=ia+n1-1 - x(ia:ib)=h0(0:n1-1) - endif - enddo - do j=1,NN-1 !Trailing edges - if(ie(j+1).ne.ie(j)) then - ib=j*NSPS - ia=ib-n1+1 - x(ia:ib)=h1(0:n1-1) - endif - enddo - ib=NN*NSPS-1 - ia=ib-n1+1 - x(ia:ib)=h1(0:n1-1) !Trailing edge of last pulse - - dt=1.d0/fs - ts=dt*NSPS - baud=fs/NSPS - write(*,1000) baud,ts -1000 format('Baud:',f6.3,' Tsym:',f6.3) - - dphi=twopi*f0*dt - phi=0.d0 - i=-1 - do j=1,NN !Generate the baseband waveform - a=ie(j) - do k=1,NSPS - i=i+1 - x(i)=a*x(i) - phi=phi+dphi - if(phi.gt.twopi) phi=phi-twopi - xphi=phi - c(i)=x(i)*cmplx(cos(xphi),sin(xphi)) - sym=i*dt/ts - if(j.le.20) write(13,1010) sym,x(i),c(i) -1010 format(4f12.6) - enddo - enddo - - call four2a(c,NZ,1,-1,1) !To freq domain - df=fs/NZ - nh=NZ/2 - do i=0,nh - f=i*df - p(i)=real(c(i))**2 + aimag(c(i))**2 - enddo - p=p/maxval(p) - do i=0,nh !Save spectrum for plotting - write(14,1020) i*df,p(i),10.0*log10(p(i)+1.e-8) -1020 format(f10.3,2e12.3) - enddo - -999 end program wsprlf diff --git a/lib/fsk4hf/wsprlf_params.f90 b/lib/fsk4hf/wsprlf_params.f90 deleted file mode 100644 index d0c3f5c7..00000000 --- a/lib/fsk4hf/wsprlf_params.f90 +++ /dev/null @@ -1,14 +0,0 @@ -!parameter (NDOWN=540) !Downsample factor (default 540)
-parameter (NDOWN=30) !Downsample factor (default 540)
-parameter (KK=60) !Information bits (50 + CRC10)
-parameter (ND=300) !Data symbols: LDPC (300,60), r=1/5
-parameter (NS=109) !Sync symbols (2 x 48 + Barker 13)
-parameter (NR=3) !Ramp up/down
-parameter (NN=NR+NS+ND) !Total symbols (412)
-parameter (NSPS0=8640) !Samples per symbol at 12000 S/s
-parameter (NSPS=NSPS0/NDOWN) !Samples per MSK symbol (16)
-parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
-parameter (N13=13*N2) !Samples in central sync vector (416)
-parameter (NZ=NSPS*NN) !Samples in baseband waveform (6592)
-parameter (NZMAX=NSPS0*NN)
-parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
diff --git a/lib/fsk4hf/wsprlfsim.f90 b/lib/fsk4hf/wsprlfsim.f90 deleted file mode 100644 index 6ee0710b..00000000 --- a/lib/fsk4hf/wsprlfsim.f90 +++ /dev/null @@ -1,286 +0,0 @@ -program wsprlfsim - -! Simulate characteristics of a potential "WSPR-LF" mode using LDPC (300,60) -! code, OQPSK modulation, and 5 minute T/R sequences. - -! Reception and Demodulation algorithm: -! 1. Compute coarse spectrum; find fc1 = approx carrier freq -! 2. Mix from fc1 to 0; LPF at +/- 0.75*R -! 3. Square, FFT; find peaks near -R/2 and +R/2 to get fc2 -! 4. Mix from fc2 to 0 -! 5. Fit cb13 (central part of csync) to c -> lag, phase -! 6. Fit complex ploynomial for channel equalization -! 7. Get soft bits from equalized data - - include 'wsprlf_params.f90' - -! Q: Would it be better for central Sync array to use both I and Q channels? - - character*8 arg - complex cbb(0:NZ-1) !Complex baseband waveform - complex csync(0:NZ-1) !Sync symbols only, from cbb - complex c(0:NZ-1) !Complex waveform - complex c0(0:NZ-1) !Complex waveform - complex c1(0:NZ-1) !Complex waveform - complex zz(NS+ND) !Complex symbol values (intermediate) - complex z - real xnoise(0:NZ-1) !Generated random noise - real ynoise(0:NZ-1) !Generated random noise - real rxdata(ND),llr(ND) !Soft symbols - real pp(2*NSPS) !Shaped pulse for OQPSK - real a(5) !For twkfreq1 - real aa(20),bb(20) !Fitted polyco's - real t(11) - character*12 label(11) - integer*8 count0,count1,count2,count3,clkfreq - integer nc(11) - integer id(NS+ND) !NRZ values (+/-1) for Sync and Data - integer ierror(NS+ND) - integer icw(NN) - integer itone(NN) - integer*1 msgbits(KK),decoded(KK),apmask(ND),cw(ND) -! integer*1 codeword(ND) - data msgbits/0,0,1,0,0,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,1, & - 1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,1,1,0,1,1,0,1,0,1,1,0,0,1,1/ - data label/'genwsprlf','twkfreq1 a','watterson','noise gen','getfc1w', & - 'getfc2w','twkfreq1 b','xdt loop','cpolyfitw','msksoftsym', & - 'bpdecode300'/ - - nargs=iargc() - if(nargs.ne.6) then - print*,'Usage: wsprlfsim f0(Hz) delay(ms) fspread(Hz) maxn iters snr(dB)' - print*,'Example: wsprlfsim 0 0 0 5 10 -20' - print*,'Set snr=0 to cycle through a range' - go to 999 - endif - call getarg(1,arg) - read(arg,*) f0 !Generated carrier frequency - call getarg(2,arg) - read(arg,*) delay !Delta_t (ms) for Watterson model - call getarg(3,arg) - read(arg,*) fspread !Fspread (Hz) for Watterson model - call getarg(4,arg) - read(arg,*) maxn !Max nterms for polyfit - call getarg(5,arg) - read(arg,*) iters !Iterations at each SNR - call getarg(6,arg) - read(arg,*) snrdb !Specified SNR_2500 - - nc=0 - twopi=8.0*atan(1.0) - fs=NSPS*12000.0/NSPS0 !Sample rate = 22.2222... Hz - dt=1.0/fs !Sample interval (s) - tt=NSPS*dt !Duration of "itone" symbols (s) - ts=2*NSPS*dt !Duration of OQPSK symbols (s) - baud=1.0/tt !Keying rate for "itone" symbols (baud) - txt=NZ*dt !Transmission length (s) - bandwidth_ratio=2500.0/(fs/2.0) - write(*,1000) fs,f0,delay,fspread,maxn,baud,3*baud,txt,iters -1000 format('fs:',f10.3,' f0:',f5.1,' Delay:',f4.1,' fSpread:',f5.2, & - ' maxn:',i3,/'Baud:',f8.3,' BW:',f5.1,' TxT:',f6.1,' iters:',i4/) - write(*,1004) -1004 format(/' SNR sync data ser ber fer fsigma tsigma', & - ' tsec'/68('-')) - - do i=1,N2 !Half-sine pulse shape - pp(i)=sin(0.5*(i-1)*twopi/(2*NSPS)) - enddo - - t=0. - call system_clock(count0,clkfreq) - call genwsprlf(msgbits,id,icw,cbb,csync,itone)!Generate baseband waveform - call system_clock(count1,clkfreq) - t(1)=float(count1-count0)/float(clkfreq) - nc(1)=nc(1)+1 - do i=0,NZ-1 - write(40,4001) i,cbb(i),csync(i) -4001 format(i8,4f12.6) - enddo - - call system_clock(count0,clkfreq) - a=0. - a(1)=f0 - call twkfreq1(cbb,NZ,fs,a,c0) !Mix baseband to specified frequency - call system_clock(count1,clkfreq) - t(2)=float(count1-count0)/float(clkfreq) - nc(2)=nc(2)+1 - - isna=-20 - isnb=-40 - if(snrdb.ne.0.0) then - isna=nint(snrdb) - isnb=isna - endif - do isnr=isna,isnb,-1 !Loop over SNR range - if(isna.ne.isnb) snrdb=isnr - sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - nhard=0 - nhardsync=0 - nfe=0 - sqf=0. - sqt=0. - - call system_clock(count2,clkfreq) - do iter=1,iters !Loop over requested iterations - c=c0 -write(*,*) 'iter ',iter - call system_clock(count0,clkfreq) - if(delay.ne.0.0 .or. fspread.ne.0.0) then - call watterson(c,NZ,fs,delay,fspread) - endif - call system_clock(count1,clkfreq) - t(3)=t(3)+float(count1-count0)/float(clkfreq) - nc(3)=nc(3)+1 - - call system_clock(count0,clkfreq) - c=sig*c !Scale to requested SNR - if(snrdb.lt.90) then - do i=0,NZ-1 !Generate gaussian noise - xnoise(i)=gran() - ynoise(i)=gran() - enddo - c=c + cmplx(xnoise,ynoise) !Add AWGN noise - endif - call system_clock(count1,clkfreq) - t(4)=t(4)+float(count1-count0)/float(clkfreq) - nc(4)=nc(4)+1 - - call system_clock(count0,clkfreq) - call getfc1w(c,fs,fc1) !First approx for freq - call system_clock(count1,clkfreq) - t(5)=t(5)+float(count1-count0)/float(clkfreq) - nc(5)=nc(5)+1 -write(*,*) 'fc1 ',fc1 - call system_clock(count0,clkfreq) - call getfc2w(c,csync,fs,fc1,fc2,fc3) !Refined freq -write(*,*) 'fc1,fc2,fc3 ',fc1,fc2,fc3 - call system_clock(count1,clkfreq) - t(6)=t(6)+float(count1-count0)/float(clkfreq) - nc(6)=nc(6)+1 - sqf=sqf + (fc1+fc2-f0)**2 - - call system_clock(count0,clkfreq) -!NB: Measured performance is about equally good using fc2 or fc3 here: - a(1)=-(fc1+fc2) - a(2:5)=0. - call twkfreq1(c,NZ,fs,a,c) !Mix c down by fc1+fc2 - call system_clock(count1,clkfreq) - t(7)=t(7)+float(count1-count0)/float(clkfreq) - nc(7)=nc(7)+1 - -! The following may not be necessary? -! z=sum(c(3088:3503)*cb13)/208.0 !Get phase from Barker 13 vector -! z0=z/abs(z) -! c=c*conjg(z0) - - call system_clock(count0,clkfreq) -!---------------------------------------------------------------- DT -! Not presently used: - amax=0. - jpk=0 - iaa=0 - ibb=NZ-1 - do j=-20*NSPS,20*NSPS,NSPS/8 - ia=j - ib=NZ-1+j - if(ia.lt.0) then - ia=0 - iaa=-j - else - iaa=0 - endif - if(ib.gt.NZ-1) then - ib=NZ-1 - ibb=NZ-1-j - endif - z=sum(c(ia:ib)*conjg(csync(iaa:ibb))) - if(abs(z).gt.amax) then - amax=abs(z) - jpk=j - endif - enddo - xdt=jpk/fs - sqt=sqt + xdt**2 - call system_clock(count1,clkfreq) - t(8)=t(8)+float(count1-count0)/float(clkfreq) - nc(8)=nc(8)+1 - -!----------------------------------------------------------------- - - nterms=maxn - c1=c - do itry=1,20 - idf=itry/2 - if(mod(itry,2).eq.0) idf=-idf - nhard0=0 - nhardsync0=0 - ifer=1 - a(1)=idf*0.00085 - a(2:5)=0. - call system_clock(count0,clkfreq) - call twkfreq1(c1,NZ,fs,a,c) !Mix c1 into c - call cpolyfitw(c,pp,id,maxn,aa,bb,zz,nhs) - call system_clock(count1,clkfreq) - t(9)=t(9)+float(count1-count0)/float(clkfreq) - nc(9)=nc(9)+1 - - call system_clock(count0,clkfreq) - call msksoftsymw(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0) - call system_clock(count1,clkfreq) - t(10)=t(10)+float(count1-count0)/float(clkfreq) - nc(10)=nc(10)+1 - - if(nhardsync0.gt.35) cycle - rxav=sum(rxdata)/ND - rx2av=sum(rxdata*rxdata)/ND - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - ss=0.84 - llr=2.0*rxdata/(ss*ss) - apmask=0 - max_iterations=40 - ifer=0 - call system_clock(count0,clkfreq) - call bpdecode300(llr,apmask,max_iterations,decoded,niterations,cw) - call system_clock(count1,clkfreq) - t(11)=t(11)+float(count1-count0)/float(clkfreq) - nc(11)=nc(11)+1 - nbadcrc=0 - if(niterations.ge.0) call chkcrc10(decoded,nbadcrc) - if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0 .or. & - nbadcrc.ne.0) ifer=1 - if(ifer.eq.0) exit - enddo !Freq dither loop - nhard=nhard+nhard0 - nhardsync=nhardsync+nhardsync0 - nfe=nfe+ifer - if(nhardsync0+nhard0+niterations+ifer.gt.0) write(42,1045) snrdb, & - nhardsync0,nhard0,niterations,ifer,xdt -1045 format(f6.1,4i6,f8.2) - enddo - call system_clock(count3,clkfreq) - tsec=float(count3-count2)/float(clkfreq) - - fsigma=sqrt(sqf/iters) - tsigma=sqrt(sqt/iters) - ser=float(nhardsync)/(NS*iters) - ber=float(nhard)/(ND*iters) - fer=float(nfe)/iters - write(*,1050) snrdb,nhardsync,nhard,ser,ber,fer,fsigma,tsigma,tsec -1050 format(f6.1,2i7,2f8.4,f7.3,2f8.2f8.3) - enddo - - write(*,1060) NS*iters,ND*iters -1060 format(68('-')/6x,2i7) - - write(*,1065) -1065 format(/'Timing sec frac calls'/39('-')) - do i=1,11 - write(*,1070) label(i),t(i),t(i)/sum(t),nc(i) -1070 format(a12,2f9.3,i8) - enddo - write(*,1072) sum(t),1.0 -1072 format(39('-')/12x,2f10.3) - -999 end program wsprlfsim diff --git a/lib/fsk4hf/wsprsimf.f90 b/lib/fsk4hf/wsprsimf.f90 deleted file mode 100644 index c6c71fe6..00000000 --- a/lib/fsk4hf/wsprsimf.f90 +++ /dev/null @@ -1,113 +0,0 @@ -!------------------------------------------------------------------------------- -! -! This file is part of the WSPR application, Weak Signal Propagation Reporter -! -!------------------------------------------------------------------------------- - -program wsprsim - - use wavhdr - include 'wspr_params.f90' - type(hdr) hwav - character arg*12,fname14*14,fname15*15 - character*22 msg,msgsent - complex c0(0:NMAX/NDOWN-1) - complex c(0:NMAX/NDOWN-1) - integer itone(NN) - integer*2 iwave(NMAX) - real*8 fMHz - -! Get command-line argument(s) - nargs=iargc() - if(nargs.ne.8) then - print*,'Usage: wsprsim "message" f0 DT fsp del nwav nfiles snr' - print*,'Example: wsprsim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33' - go to 999 - endif - call getarg(1,msg) !Message to be transmitted - call getarg(2,arg) - read(arg,*) f0 !Freq relative to WSPR-band center (Hz) - call getarg(3,arg) - read(arg,*) xdt !Time offset from nominal (s) - call getarg(4,arg) - read(arg,*) fspread !Watterson frequency spread (Hz) - call getarg(5,arg) - read(arg,*) delay !Watterson delay (ms) - call getarg(6,arg) - read(arg,*) nwav !1 for *.wav file, 0 for *.c2 file - call getarg(7,arg) - read(arg,*) nfiles !Number of files - call getarg(8,arg) - read(arg,*) snrdb !SNR_2500 - - twopi=8.0*atan(1.0) - fs=12000.0/NDOWN - dt=1.0/fs - tt=NSPS*dt - baud=12000.0/8192.0 - - txt=NZ*dt !Transmission length (s) - bandwidth_ratio=2500.0/(fs/2.0) - sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 - txt=NN*NSPS0/12000.0 - - call genwspr(msg,msgsent,itone) !Encode the message, get itone - - write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent -1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, & - ' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22) -! write(*,*) "Channel symbols: " -! write(*,'(162i2)') itone - - h=1.0 - phi=0.0 - c0=0. - k=-1 + nint(xdt/dt) - do j=1,NN - dphi=-twopi*(f0+h*(itone(j)-1.5)*baud)*dt - do i=1,NSPS - k=k+1 - phi=mod(phi+dphi,twopi) - if(k.ge.0 .and. k.lt.NMAX/NDOWN) c0(k)=cmplx(cos(phi),sin(phi)) - enddo - enddo - call sgran() - do ifile=1,nfiles - c=c0 - if(nwav.eq.0) then - if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then - call watterson(c,NMAX/NDOWN,fs,delay,fspread) - endif - c=c*sig - if(snrdb.lt.90) then - do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR - xnoise=gran() - ynoise=gran() - c(i)=c(i) + cmplx(xnoise,ynoise) - enddo - endif - write(fname14,1100) ifile -1100 format('000000_',i4.4,'.c2') - open(10,file=fname14,status='unknown',access='stream') - fMHz=10.1387d0 - nmin=2 - write(10) fname14,nmin,fMHz,c !Save to *.c2 file - close(10) - write(*,1108) ifile,xdt,f0,snrdb,fname14 -1108 format(i4,f7.2,f8.2,f7.1,2x,a14) - else - freq=1500.0+f0 - call wspr_wav(baud,xdt,h,freq,itone,snrdb,iwave) - hwav=default_header(12000,NMAX) - write(fname15,1102) ifile -1102 format('000000_',i4.4,'.wav') - open(10,file=fname15,status='unknown',access='stream') - write(10) hwav,iwave !Save to *.wav file - close(10) - write(*,1110) ifile,xdt,f0,snrdb,fname15 -1110 format(i4,f7.2,f8.2,f7.1,2x,a15) - endif - enddo - -999 end program wsprsim diff --git a/lib/ft8/bpdecode174.f90 b/lib/ft8/bpdecode174.f90 deleted file mode 100644 index 9442cc4a..00000000 --- a/lib/ft8/bpdecode174.f90 +++ /dev/null @@ -1,401 +0,0 @@ -subroutine bpdecode174(llr,apmask,maxiterations,decoded,cw,nharderror,iter) -! -! A log-domain belief propagation decoder for the (174,87) code. -! -integer, parameter:: N=174, K=87, M=N-K -integer*1 codeword(N),cw(N),apmask(N) -integer colorder(N) -integer*1 decoded(K) -integer Nm(7,M) ! 5, 6, or 7 bits per check -integer Mn(3,N) ! 3 checks per bit -integer synd(M) -real tov(3,N) -real toc(7,M) -real tanhtoc(7,M) -real zn(N) -real llr(N) -real Tmn -integer nrw(M) - -data colorder/ & - 0, 1, 2, 3, 30, 4, 5, 6, 7, 8, 9, 10, 11, 32, 12, 40, 13, 14, 15, 16,& - 17, 18, 37, 45, 29, 19, 20, 21, 41, 22, 42, 31, 33, 34, 44, 35, 47, 51, 50, 43,& - 36, 52, 63, 46, 25, 55, 27, 24, 23, 53, 39, 49, 59, 38, 48, 61, 60, 57, 28, 62,& - 56, 58, 65, 66, 26, 70, 64, 69, 68, 67, 74, 71, 54, 76, 72, 75, 78, 77, 80, 79,& - 73, 83, 84, 81, 82, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,& - 100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,& - 120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,& - 140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,& - 160,161,162,163,164,165,166,167,168,169,170,171,172,173/ - -data Mn/ & - 1, 25, 69, & - 2, 5, 73, & - 3, 32, 68, & - 4, 51, 61, & - 6, 63, 70, & - 7, 33, 79, & - 8, 50, 86, & - 9, 37, 43, & - 10, 41, 65, & - 11, 14, 64, & - 12, 75, 77, & - 13, 23, 81, & - 15, 16, 82, & - 17, 56, 66, & - 18, 53, 60, & - 19, 31, 52, & - 20, 67, 84, & - 21, 29, 72, & - 22, 24, 44, & - 26, 35, 76, & - 27, 36, 38, & - 28, 40, 42, & - 30, 54, 55, & - 34, 49, 87, & - 39, 57, 58, & - 45, 74, 83, & - 46, 62, 80, & - 47, 48, 85, & - 59, 71, 78, & - 1, 50, 53, & - 2, 47, 84, & - 3, 25, 79, & - 4, 6, 14, & - 5, 7, 80, & - 8, 34, 55, & - 9, 36, 69, & - 10, 43, 83, & - 11, 23, 74, & - 12, 17, 44, & - 13, 57, 76, & - 15, 27, 56, & - 16, 28, 29, & - 18, 19, 59, & - 20, 40, 63, & - 21, 35, 52, & - 22, 54, 64, & - 24, 62, 78, & - 26, 32, 77, & - 30, 72, 85, & - 31, 65, 87, & - 33, 39, 51, & - 37, 48, 75, & - 38, 70, 71, & - 41, 42, 68, & - 45, 67, 86, & - 46, 81, 82, & - 49, 66, 73, & - 58, 60, 66, & - 61, 65, 85, & - 1, 14, 21, & - 2, 13, 59, & - 3, 67, 82, & - 4, 32, 73, & - 5, 36, 54, & - 6, 43, 46, & - 7, 28, 75, & - 8, 33, 71, & - 9, 49, 76, & - 10, 58, 64, & - 11, 48, 68, & - 12, 19, 45, & - 15, 50, 61, & - 16, 22, 26, & - 17, 72, 80, & - 18, 40, 55, & - 20, 35, 51, & - 23, 25, 34, & - 24, 63, 87, & - 27, 39, 74, & - 29, 78, 83, & - 30, 70, 77, & - 31, 69, 84, & - 22, 37, 86, & - 38, 41, 81, & - 42, 44, 57, & - 47, 53, 62, & - 52, 56, 79, & - 60, 75, 81, & - 1, 39, 77, & - 2, 16, 41, & - 3, 31, 54, & - 4, 36, 78, & - 5, 45, 65, & - 6, 57, 85, & - 7, 14, 49, & - 8, 21, 46, & - 9, 15, 72, & - 10, 20, 62, & - 11, 17, 71, & - 12, 34, 47, & - 13, 68, 86, & - 18, 23, 43, & - 19, 64, 73, & - 24, 48, 79, & - 25, 70, 83, & - 26, 80, 87, & - 27, 32, 40, & - 28, 56, 69, & - 29, 63, 66, & - 30, 42, 50, & - 33, 37, 82, & - 35, 60, 74, & - 38, 55, 84, & - 44, 52, 61, & - 51, 53, 72, & - 58, 59, 67, & - 47, 56, 76, & - 1, 19, 37, & - 2, 61, 75, & - 3, 8, 66, & - 4, 60, 84, & - 5, 34, 39, & - 6, 26, 53, & - 7, 32, 57, & - 9, 52, 67, & - 10, 12, 15, & - 11, 51, 69, & - 13, 14, 65, & - 16, 31, 43, & - 17, 20, 36, & - 18, 80, 86, & - 21, 48, 59, & - 22, 40, 46, & - 23, 33, 62, & - 24, 30, 74, & - 25, 42, 64, & - 27, 49, 85, & - 28, 38, 73, & - 29, 44, 81, & - 35, 68, 70, & - 41, 63, 76, & - 45, 49, 71, & - 50, 58, 87, & - 48, 54, 83, & - 13, 55, 79, & - 77, 78, 82, & - 1, 2, 24, & - 3, 6, 75, & - 4, 56, 87, & - 5, 44, 53, & - 7, 50, 83, & - 8, 10, 28, & - 9, 55, 62, & - 11, 29, 67, & - 12, 33, 40, & - 14, 16, 20, & - 15, 35, 73, & - 17, 31, 39, & - 18, 36, 57, & - 19, 46, 76, & - 21, 42, 84, & - 22, 34, 59, & - 23, 26, 61, & - 25, 60, 65, & - 27, 64, 80, & - 30, 37, 66, & - 32, 45, 72, & - 38, 51, 86, & - 41, 77, 79, & - 43, 56, 68, & - 47, 74, 82, & - 40, 52, 78, & - 54, 61, 71, & - 46, 58, 69/ - -data Nm/ & - 1, 30, 60, 89, 118, 147, 0, & - 2, 31, 61, 90, 119, 147, 0, & - 3, 32, 62, 91, 120, 148, 0, & - 4, 33, 63, 92, 121, 149, 0, & - 2, 34, 64, 93, 122, 150, 0, & - 5, 33, 65, 94, 123, 148, 0, & - 6, 34, 66, 95, 124, 151, 0, & - 7, 35, 67, 96, 120, 152, 0, & - 8, 36, 68, 97, 125, 153, 0, & - 9, 37, 69, 98, 126, 152, 0, & - 10, 38, 70, 99, 127, 154, 0, & - 11, 39, 71, 100, 126, 155, 0, & - 12, 40, 61, 101, 128, 145, 0, & - 10, 33, 60, 95, 128, 156, 0, & - 13, 41, 72, 97, 126, 157, 0, & - 13, 42, 73, 90, 129, 156, 0, & - 14, 39, 74, 99, 130, 158, 0, & - 15, 43, 75, 102, 131, 159, 0, & - 16, 43, 71, 103, 118, 160, 0, & - 17, 44, 76, 98, 130, 156, 0, & - 18, 45, 60, 96, 132, 161, 0, & - 19, 46, 73, 83, 133, 162, 0, & - 12, 38, 77, 102, 134, 163, 0, & - 19, 47, 78, 104, 135, 147, 0, & - 1, 32, 77, 105, 136, 164, 0, & - 20, 48, 73, 106, 123, 163, 0, & - 21, 41, 79, 107, 137, 165, 0, & - 22, 42, 66, 108, 138, 152, 0, & - 18, 42, 80, 109, 139, 154, 0, & - 23, 49, 81, 110, 135, 166, 0, & - 16, 50, 82, 91, 129, 158, 0, & - 3, 48, 63, 107, 124, 167, 0, & - 6, 51, 67, 111, 134, 155, 0, & - 24, 35, 77, 100, 122, 162, 0, & - 20, 45, 76, 112, 140, 157, 0, & - 21, 36, 64, 92, 130, 159, 0, & - 8, 52, 83, 111, 118, 166, 0, & - 21, 53, 84, 113, 138, 168, 0, & - 25, 51, 79, 89, 122, 158, 0, & - 22, 44, 75, 107, 133, 155, 172, & - 9, 54, 84, 90, 141, 169, 0, & - 22, 54, 85, 110, 136, 161, 0, & - 8, 37, 65, 102, 129, 170, 0, & - 19, 39, 85, 114, 139, 150, 0, & - 26, 55, 71, 93, 142, 167, 0, & - 27, 56, 65, 96, 133, 160, 174, & - 28, 31, 86, 100, 117, 171, 0, & - 28, 52, 70, 104, 132, 144, 0, & - 24, 57, 68, 95, 137, 142, 0, & - 7, 30, 72, 110, 143, 151, 0, & - 4, 51, 76, 115, 127, 168, 0, & - 16, 45, 87, 114, 125, 172, 0, & - 15, 30, 86, 115, 123, 150, 0, & - 23, 46, 64, 91, 144, 173, 0, & - 23, 35, 75, 113, 145, 153, 0, & - 14, 41, 87, 108, 117, 149, 170, & - 25, 40, 85, 94, 124, 159, 0, & - 25, 58, 69, 116, 143, 174, 0, & - 29, 43, 61, 116, 132, 162, 0, & - 15, 58, 88, 112, 121, 164, 0, & - 4, 59, 72, 114, 119, 163, 173, & - 27, 47, 86, 98, 134, 153, 0, & - 5, 44, 78, 109, 141, 0, 0, & - 10, 46, 69, 103, 136, 165, 0, & - 9, 50, 59, 93, 128, 164, 0, & - 14, 57, 58, 109, 120, 166, 0, & - 17, 55, 62, 116, 125, 154, 0, & - 3, 54, 70, 101, 140, 170, 0, & - 1, 36, 82, 108, 127, 174, 0, & - 5, 53, 81, 105, 140, 0, 0, & - 29, 53, 67, 99, 142, 173, 0, & - 18, 49, 74, 97, 115, 167, 0, & - 2, 57, 63, 103, 138, 157, 0, & - 26, 38, 79, 112, 135, 171, 0, & - 11, 52, 66, 88, 119, 148, 0, & - 20, 40, 68, 117, 141, 160, 0, & - 11, 48, 81, 89, 146, 169, 0, & - 29, 47, 80, 92, 146, 172, 0, & - 6, 32, 87, 104, 145, 169, 0, & - 27, 34, 74, 106, 131, 165, 0, & - 12, 56, 84, 88, 139, 0, 0, & - 13, 56, 62, 111, 146, 171, 0, & - 26, 37, 80, 105, 144, 151, 0, & - 17, 31, 82, 113, 121, 161, 0, & - 28, 49, 59, 94, 137, 0, 0, & - 7, 55, 83, 101, 131, 168, 0, & - 24, 50, 78, 106, 143, 149, 0/ - -data nrw/ & - 6,6,6,6,6,6,6,6,6,6, & - 6,6,6,6,6,6,6,6,6,6, & - 6,6,6,6,6,6,6,6,6,6, & - 6,6,6,6,6,6,6,6,6,7, & - 6,6,6,6,6,7,6,6,6,6, & - 6,6,6,6,6,7,6,6,6,6, & - 7,6,5,6,6,6,6,6,6,5, & - 6,6,6,6,6,6,6,6,6,6, & - 5,6,6,6,5,6,6/ - -ncw=3 - -decoded=0 -toc=0 -tov=0 -tanhtoc=0 -! initialize messages to checks -do j=1,M - do i=1,nrw(j) - toc(i,j)=llr((Nm(i,j))) - enddo -enddo - -ncnt=0 - -do iter=0,maxiterations - -! Update bit log likelihood ratios (tov=0 in iteration 0). - do i=1,N - if( apmask(i) .ne. 1 ) then - zn(i)=llr(i)+sum(tov(1:ncw,i)) - else - zn(i)=llr(i) - endif - enddo - -! Check to see if we have a codeword (check before we do any iteration). - cw=0 - where( zn .gt. 0. ) cw=1 - ncheck=0 - do i=1,M - synd(i)=sum(cw(Nm(1:nrw(i),i))) - if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1 -! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied' - enddo -! write(*,*) 'number of unsatisfied parity checks ',ncheck - if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it - codeword=cw(colorder+1) - decoded=codeword(M+1:N) - nerr=0 - do i=1,N - if( (2*cw(i)-1)*llr(i) .lt. 0.0 ) nerr=nerr+1 - enddo - nharderror=nerr - return - endif - - if( iter.gt.0 ) then ! this code block implements an early stopping criterion -! if( iter.gt.10000 ) then ! this code block implements an early stopping criterion - nd=ncheck-nclast - if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased - ncnt=0 ! reset counter - else - ncnt=ncnt+1 - endif -! write(*,*) iter,ncheck,nd,ncnt - if( ncnt .ge. 5 .and. iter .ge. 10 .and. ncheck .gt. 15) then - nharderror=-1 - return - endif - endif - nclast=ncheck - -! Send messages from bits to check nodes - do j=1,M - do i=1,nrw(j) - ibj=Nm(i,j) - toc(i,j)=zn(ibj) - do kk=1,ncw ! subtract off what the bit had received from the check - if( Mn(kk,ibj) .eq. j ) then - toc(i,j)=toc(i,j)-tov(kk,ibj) - endif - enddo - enddo - enddo - -! send messages from check nodes to variable nodes - do i=1,M - tanhtoc(1:7,i)=tanh(-toc(1:7,i)/2) - enddo - - do j=1,N - do i=1,ncw - ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j - Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) - call platanh(-Tmn,y) -! y=atanh(-Tmn) - tov(i,j)=2*y - enddo - enddo - -enddo -nharderror=-1 -return -end subroutine bpdecode174 diff --git a/lib/ft8/bpdecode174_91.f90 b/lib/ft8/bpdecode174_91.f90 new file mode 100644 index 00000000..78809f19 --- /dev/null +++ b/lib/ft8/bpdecode174_91.f90 @@ -0,0 +1,115 @@ +subroutine bpdecode174_91(llr,apmask,maxiterations,message77,cw,nharderror,iter) +! +! A log-domain belief propagation decoder for the (174,91) code. +! +use iso_c_binding, only: c_loc,c_size_t +use crc +integer, parameter:: N=174, K=91, M=N-K +integer*1 cw(N),apmask(N) +integer*1 decoded(K) +integer*1 message77(77) +integer nrw(M),ncw +integer Nm(7,M) +integer Mn(3,N) ! 3 checks per bit +integer synd(M) +real tov(3,N) +real toc(7,M) +real tanhtoc(7,M) +real zn(N) +real llr(N) +real Tmn + +include "ldpc_174_91_c_reordered_parity.f90" + +decoded=0 +toc=0 +tov=0 +tanhtoc=0 +! initialize messages to checks +do j=1,M + do i=1,nrw(j) + toc(i,j)=llr((Nm(i,j))) + enddo +enddo + +ncnt=0 + +do iter=0,maxiterations + +! Update bit log likelihood ratios (tov=0 in iteration 0). + do i=1,N + if( apmask(i) .ne. 1 ) then + zn(i)=llr(i)+sum(tov(1:ncw,i)) + else + zn(i)=llr(i) + endif + enddo + +! Check to see if we have a codeword (check before we do any iteration). + cw=0 + where( zn .gt. 0. ) cw=1 + ncheck=0 + do i=1,M + synd(i)=sum(cw(Nm(1:nrw(i),i))) + if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1 +! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied' + enddo +! write(*,*) 'number of unsatisfied parity checks ',ncheck + if( ncheck .eq. 0 ) then ! we have a codeword - if crc is good, return it + decoded=cw(1:K) + call chkcrc14a(decoded,nbadcrc) + nharderror=count( (2*cw-1)*llr .lt. 0.0 ) + if(nbadcrc.eq.0) then + message77=decoded(1:77) + return + endif + endif + + if( iter.gt.0 ) then ! this code block implements an early stopping criterion +! if( iter.gt.10000 ) then ! this code block implements an early stopping criterion + nd=ncheck-nclast + if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased + ncnt=0 ! reset counter + else + ncnt=ncnt+1 + endif +! write(*,*) iter,ncheck,nd,ncnt + if( ncnt .ge. 5 .and. iter .ge. 10 .and. ncheck .gt. 15) then + nharderror=-1 + return + endif + endif + nclast=ncheck + +! Send messages from bits to check nodes + do j=1,M + do i=1,nrw(j) + ibj=Nm(i,j) + toc(i,j)=zn(ibj) + do kk=1,ncw ! subtract off what the bit had received from the check + if( Mn(kk,ibj) .eq. j ) then + toc(i,j)=toc(i,j)-tov(kk,ibj) + endif + enddo + enddo + enddo + +! send messages from check nodes to variable nodes + do i=1,M + tanhtoc(1:7,i)=tanh(-toc(1:7,i)/2) + enddo + + do j=1,N + do i=1,ncw + ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j + Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) + call platanh(-Tmn,y) +! y=atanh(-Tmn) + tov(i,j)=2*y + enddo + enddo + +enddo +nharderror=-1 +return +end subroutine bpdecode174_91 diff --git a/lib/ft8/chkcrc12a.f90 b/lib/ft8/chkcrc12a.f90 deleted file mode 100644 index fc429190..00000000 --- a/lib/ft8/chkcrc12a.f90 +++ /dev/null @@ -1,24 +0,0 @@ -subroutine chkcrc12a(decoded,nbadcrc)
-
- use crc
- integer*1 decoded(87)
- integer*1, target:: i1Dec8BitBytes(11)
- character*87 cbits
-
-! Write decoded bits into cbits: 75-bit message plus 12-bit CRC
- write(cbits,1000) decoded
-1000 format(87i1)
- read(cbits,1001) i1Dec8BitBytes
-1001 format(11b8)
- read(cbits,1002) ncrc12 !Received CRC12
-1002 format(75x,b12)
-
- i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32)
- i1Dec8BitBytes(11)=0
- icrc12=crc12(c_loc(i1Dec8BitBytes),11) !CRC12 computed from 75 msg bits
-
- nbadcrc=1
- if(ncrc12.eq.icrc12) nbadcrc=0
-
- return
-end subroutine chkcrc12a
diff --git a/lib/ft8/chkcrc13a.f90 b/lib/ft8/chkcrc13a.f90 new file mode 100644 index 00000000..74259cfc --- /dev/null +++ b/lib/ft8/chkcrc13a.f90 @@ -0,0 +1,24 @@ +subroutine chkcrc13a(decoded,nbadcrc)
+
+ use crc
+ integer*1 decoded(90)
+ integer*1, target:: i1Dec8BitBytes(12)
+ character*90 cbits
+
+! Write decoded bits into cbits: 77-bit message plus 13-bit CRC
+ write(cbits,1000) decoded
+1000 format(90i1)
+ read(cbits,1001) i1Dec8BitBytes
+1001 format(12b8)
+ read(cbits,1002) ncrc13 !Received CRC13
+1002 format(77x,b13)
+
+ i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32+16+8)
+ i1Dec8BitBytes(11:12)=0
+ icrc13=crc13(c_loc(i1Dec8BitBytes),12) !CRC13 computed from 77 msg bits
+
+ nbadcrc=1
+ if(ncrc13.eq.icrc13) nbadcrc=0
+
+ return
+end subroutine chkcrc13a
diff --git a/lib/ft8/chkcrc14a.f90 b/lib/ft8/chkcrc14a.f90 new file mode 100644 index 00000000..d9d3d7a4 --- /dev/null +++ b/lib/ft8/chkcrc14a.f90 @@ -0,0 +1,24 @@ +subroutine chkcrc14a(decoded,nbadcrc)
+
+ use crc
+ integer*1 decoded(91)
+ integer*1, target:: i1Dec8BitBytes(12)
+ character*91 cbits
+
+! Write decoded bits into cbits: 77-bit message plus 14-bit CRC
+ write(cbits,1000) decoded
+1000 format(91i1)
+ read(cbits,1001) i1Dec8BitBytes
+1001 format(12b8)
+ read(cbits,1002) ncrc14 !Received CRC14
+1002 format(77x,b14)
+
+ i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32+16+8)
+ i1Dec8BitBytes(11:12)=0
+ icrc14=crc14(c_loc(i1Dec8BitBytes),12) !CRC14 computed from 77 msg bits
+
+ nbadcrc=1
+ if(ncrc14.eq.icrc14) nbadcrc=0
+
+ return
+end subroutine chkcrc14a
diff --git a/lib/ft8/encode174_91.f90 b/lib/ft8/encode174_91.f90 new file mode 100644 index 00000000..0ffa4841 --- /dev/null +++ b/lib/ft8/encode174_91.f90 @@ -0,0 +1,58 @@ +subroutine encode174_91(message77,codeword) +! +! Add a 14-bit CRC to a 77-bit message and return a 174-bit codeword +! +use, intrinsic :: iso_c_binding +use iso_c_binding, only: c_loc,c_size_t +use crc + +integer, parameter:: N=174, K=91, M=N-K +character*91 tmpchar +integer*1 codeword(N) +integer*1 gen(M,K) +integer*1 message77(77),message(K) +integer*1 pchecks(M) +integer*1, target :: i1MsgBytes(12) +include "ldpc_174_91_c_generator.f90" +logical first +data first/.true./ +save first,gen + +if( first ) then ! fill the generator matrix + gen=0 + do i=1,M + do j=1,23 + read(g(i)(j:j),"(Z1)") istr + ibmax=4 + if(j.eq.23) ibmax=3 + do jj=1, ibmax + icol=(j-1)*4+jj + if( btest(istr,4-jj) ) gen(i,icol)=1 + enddo + enddo + enddo +first=.false. +endif + +! Add 14-bit CRC to form 91-bit message+CRC14 +write(tmpchar,'(77i1)') message77 +tmpchar(78:80)='000' +i1MsgBytes=0 +read(tmpchar,'(10b8)') i1MsgBytes(1:10) +ncrc14 = crc14 (c_loc (i1MsgBytes), 12) +write(tmpchar(78:91),'(b14)') ncrc14 +read(tmpchar,'(91i1)') message + +do i=1,M + nsum=0 + do j=1,K + nsum=nsum+message(j)*gen(i,j) + enddo + pchecks(i)=mod(nsum,2) +enddo + +codeword(1:K)=message +codeword(K+1:N)=pchecks + +return +end subroutine encode174_91 diff --git a/lib/ft8/extractmessage174.f90 b/lib/ft8/extractmessage174.f90 index e7c7c3a1..4bac6694 100644 --- a/lib/ft8/extractmessage174.f90 +++ b/lib/ft8/extractmessage174.f90 @@ -30,7 +30,7 @@ subroutine extractmessage174(decoded,msgreceived,ncrcflag) enddo i4Dec6BitWords(ibyte)=itmp enddo - call unpackmsg(i4Dec6BitWords,msgreceived,.false.,' ') + call unpackmsg(i4Dec6BitWords,msgreceived) ncrcflag=1 else msgreceived=' ' diff --git a/lib/ft8/extractmessage174_91.f90 b/lib/ft8/extractmessage174_91.f90 new file mode 100644 index 00000000..d2d3019e --- /dev/null +++ b/lib/ft8/extractmessage174_91.f90 @@ -0,0 +1,40 @@ +subroutine extractmessage174_91(decoded,msgreceived,ncrcflag) + use iso_c_binding, only: c_loc,c_size_t + use crc + use packjt + + character*22 msgreceived + character*91 cbits + integer*1 decoded(91) + integer*1, target:: i1Dec8BitBytes(12) + integer*4 i4Dec6BitWords(12) + +! Write decoded bits into cbits: 77-bit message plus 14-bit CRC + write(cbits,1000) decoded +1000 format(91i1) + read(cbits,1001) i1Dec8BitBytes +1001 format(12b8) + read(cbits,1002) ncrc14 !Received CRC12 +1002 format(77x,b14) + + i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32+16+8) + i1Dec8BitBytes(11:12)=0 + icrc14=crc14(c_loc(i1Dec8BitBytes),12) !CRC12 computed from 75 msg bits + + if(ncrc14.eq.icrc14 .or. sum(decoded(57:87)).eq.0) then !### Kludge ### +! CRC14 checks out --- unpack 72-bit message + do ibyte=1,12 + itmp=0 + do ibit=1,6 + itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*6+ibit)) + enddo + i4Dec6BitWords(ibyte)=itmp + enddo + call unpackmsg(i4Dec6BitWords,msgreceived) + ncrcflag=1 + else + msgreceived=' ' + ncrcflag=-1 + endif + return + end subroutine extractmessage174_91 diff --git a/lib/ft8/foxgen.f90 b/lib/ft8/foxgen.f90 index b1220966..7492a6f7 100644 --- a/lib/ft8/foxgen.f90 +++ b/lib/ft8/foxgen.f90 @@ -14,84 +14,31 @@ subroutine foxgen() ! common/foxcom/. The generated wave(NWAVE) is passed back in the same
! common block.
- use crc
- parameter (NN=79,ND=58,KK=87,NSPS=4*1920)
+ parameter (NN=79,ND=58,NSPS=4*1920)
parameter (NWAVE=NN*NSPS,NFFT=614400,NH=NFFT/2)
character*40 cmsg
- character*22 msg,msgsent
- character*6 mygrid
- character*87 cbits
- character*88 cb88
- logical bcontest
- integer itone(NN)
- integer icos7(0:6)
- integer*1 msgbits(KK),codeword(3*ND),msgbits2
- integer*1, target:: i1Msg8BitBytes(11)
+ character*37 msg,msgsent
+ integer itone(79)
+ integer*1 msgbits(77),msgbits2
integer*1, target:: mycall
real x(NFFT)
real*8 dt,twopi,f0,fstep,dfreq,phi,dphi
complex cx(0:NH)
common/foxcom/wave(NWAVE),nslots,nfreq,i3bit(5),cmsg(5),mycall(12)
- common/foxcom2/itone2(NN),msgbits2(KK)
+ common/foxcom2/itone2(NN),msgbits2(77)
equivalence (x,cx),(y,cy)
- data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
- bcontest=.false.
fstep=60.d0
dfreq=6.25d0
dt=1.d0/48000.d0
twopi=8.d0*atan(1.d0)
- mygrid=' '
irpt=0
nplot=0
wave=0.
do n=1,nslots
- i3b=i3bit(n)
- if(i3b.eq.0) then
- msg=cmsg(n)(1:22) !Standard FT8 message
- else
- i1=index(cmsg(n),' ') !Special Fox message
- i2=index(cmsg(n),';')
- i3=index(cmsg(n),'<')
- i4=index(cmsg(n),'>')
- msg=cmsg(n)(1:i1)//cmsg(n)(i2+1:i3-2)//' '
- read(cmsg(n)(i4+2:i4+4),*) irpt
- endif
- call genft8(msg,mygrid,bcontest,0,msgsent,msgbits,itone)
-! print*,'Foxgen:',n,cmsg(n),msgsent
-
- if(i3b.eq.1) then
- icrc10=crc10(c_loc(mycall),12)
- nrpt=irpt+30
- write(cbits,1001) msgbits(1:56),icrc10,nrpt,i3b,0
-1001 format(56b1.1,b10.10,b6.6,b3.3,b12.12)
- read(cbits,1002) msgbits
-1002 format(87i1)
-
- cb88=cbits//'0'
- read(cb88,1003) i1Msg8BitBytes(1:11)
-1003 format(11b8)
- icrc12=crc12(c_loc(i1Msg8BitBytes),11)
-
- write(cbits,1001) msgbits(1:56),icrc10,nrpt,i3b,icrc12
- read(cbits,1002) msgbits
-
- call encode174(msgbits,codeword) !Encode the test message
-
-! Message structure: S7 D29 S7 D29 S7
- itone(1:7)=icos7
- itone(36+1:36+7)=icos7
- itone(NN-6:NN)=icos7
- k=7
- do j=1,ND
- i=3*j -2
- k=k+1
- if(j.eq.30) k=k+7
- itone(k)=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2)
- enddo
- endif
-
+ msg=cmsg(n)(1:37)
+ call genft8(msg,i3,n3,msgsent,msgbits,itone)
! Make copies of itone() and msgbits() for ft8sim
itone2=itone
msgbits2=msgbits
diff --git a/lib/ft8/foxgen_wrap.f90 b/lib/ft8/foxgen_wrap.f90 index dbcb2582..bc8c430f 100644 --- a/lib/ft8/foxgen_wrap.f90 +++ b/lib/ft8/foxgen_wrap.f90 @@ -1,6 +1,6 @@ subroutine foxgen_wrap(msg40,msgbits,itone)
- parameter (NN=79,ND=58,KK=87,NSPS=4*1920)
+ parameter (NN=79,ND=58,KK=77,NSPS=4*1920)
parameter (NWAVE=NN*NSPS)
character*40 msg40,cmsg
diff --git a/lib/ft8/ft8_downsample.f90 b/lib/ft8/ft8_downsample.f90 index 79191416..f3552258 100644 --- a/lib/ft8/ft8_downsample.f90 +++ b/lib/ft8/ft8_downsample.f90 @@ -5,15 +5,23 @@ subroutine ft8_downsample(dd,newdat,f0,c1) parameter (NMAX=15*12000,NSPS=1920)
parameter (NFFT1=192000,NFFT2=3200) !192000/60 = 3200
- logical newdat
+ logical newdat,first
complex c1(0:NFFT2-1)
complex cx(0:NFFT1/2)
- real dd(NMAX),x(NFFT1)
+ real dd(NMAX),x(NFFT1),taper(0:100)
equivalence (x,cx)
- save cx
+ data first/.true./
+ save cx,first,taper
+ if(first) then
+ pi=4.0*atan(1.0)
+ do i=0,100
+ taper(i)=0.5*(1.0+cos(i*pi/100))
+ enddo
+ first=.false.
+ endif
if(newdat) then
-! Data in dd have changed, recompute the long FFT
+! Data in dd have changed, recompute the long FFT
x(1:NMAX)=dd
x(NMAX+1:NFFT1)=0. !Zero-pad the x array
call four2a(cx,NFFT1,1,-1,0) !r2c FFT to freq domain
@@ -23,9 +31,9 @@ subroutine ft8_downsample(dd,newdat,f0,c1) df=12000.0/NFFT1
baud=12000.0/NSPS
i0=nint(f0/df)
- ft=f0+8.0*baud
+ ft=f0+8.5*baud
it=min(nint(ft/df),NFFT1/2)
- fb=f0-1.0*baud
+ fb=f0-1.5*baud
ib=max(1,nint(fb/df))
k=0
c1=0.
@@ -33,6 +41,8 @@ subroutine ft8_downsample(dd,newdat,f0,c1) c1(k)=cx(i)
k=k+1
enddo
+ c1(0:100)=c1(0:100)*taper(100:0:-1)
+ c1(k-1-100:k-1)=c1(k-1-100:k-1)*taper
c1=cshift(c1,i0-ib)
call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain
fac=1.0/sqrt(float(NFFT1)*NFFT2)
diff --git a/lib/ft8/ft8_params.f90 b/lib/ft8/ft8_params.f90 index 858e61e9..bd228bde 100644 --- a/lib/ft8/ft8_params.f90 +++ b/lib/ft8/ft8_params.f90 @@ -1,5 +1,5 @@ -! LDPC (174,87) code
-parameter (KK=87) !Information bits (75 + CRC12)
+! LDPC (174,91) code
+parameter (KK=91) !Information bits (77 + CRC14)
parameter (ND=58) !Data symbols
parameter (NS=21) !Sync symbols (3 @ Costas 7x7)
parameter (NN=NS+ND) !Total channel symbols (79)
diff --git a/lib/ft8/ft8_testmsg.f90 b/lib/ft8/ft8_testmsg.f90 index aac3ad93..2a1bf8f9 100644 --- a/lib/ft8/ft8_testmsg.f90 +++ b/lib/ft8/ft8_testmsg.f90 @@ -1,145 +1,51 @@ - parameter (MAXTEST=75,NTEST=68) - character*40 testmsg(MAXTEST) - character*40 testmsgchk(MAXTEST) - ! Test msgs should include the extremes for the different types - ! See pfx.f90 - ! Type 1 P & A - ! Type 1 1A & E5 - data testmsg(1:NTEST)/ & - "CQ WB9XYZ EN34", & - "CQ DX WB9XYZ EN34", & - "QRZ WB9XYZ EN34", & - "KA1ABC WB9XYZ EN34", & - "KA1ABC WB9XYZ RO", & - "KA1ABC WB9XYZ -21", & - "KA1ABC WB9XYZ R-19", & - "KA1ABC WB9XYZ RRR", & - "KA1ABC WB9XYZ 73", & - "KA1ABC WB9XYZ", & - "CQ 000 WB9XYZ EN34", & - "CQ 999 WB9XYZ EN34", & - "CQ EU WB9XYZ EN34", & - "CQ WY WB9XYZ EN34", & - "1A/KA1ABC WB9XYZ", & - "E5/KA1ABC WB9XYZ", & - "KA1ABC 1A/WB9XYZ", & - "KA1ABC E5/WB9XYZ", & - "KA1ABC/P WB9XYZ", & - "KA1ABC/A WB9XYZ", & - "KA1ABC WB9XYZ/P", & - "KA1ABC WB9XYZ/A", & - "CQ KA1ABC/P", & - "CQ WB9XYZ/A", & - "QRZ KA1ABC/P", & - "QRZ WB9XYZ/A", & - "DE KA1ABC/P", & - "DE WB9XYZ/A", & - "CQ 1A/KA1ABC", & - "CQ E5/KA1ABC", & - "DE 1A/KA1ABC", & - "DE E5/KA1ABC", & - "QRZ 1A/KA1ABC", & - "QRZ E5/KA1ABC", & - "CQ WB9XYZ/1A", & - "CQ WB9XYZ/E5", & - "QRZ WB9XYZ/1A", & - "QRZ WB9XYZ/E5", & - "DE WB9XYZ/1A", & - "DE WB9XYZ/E5", & - "CQ A000/KA1ABC FM07", & - "CQ ZZZZ/KA1ABC FM07", & - "QRZ W4/KA1ABC FM07", & - "DE W4/KA1ABC FM07", & - "CQ W4/KA1ABC -22", & - "DE W4/KA1ABC -22", & - "QRZ W4/KA1ABC -22", & - "CQ W4/KA1ABC R-22", & - "DE W4/KA1ABC R-22", & - "QRZ W4/KA1ABC R-22", & - "DE W4/KA1ABC 73", & - "CQ KA1ABC FM07", & - "QRZ KA1ABC FM07", & - "DE KA1ABC/VE6 FM07", & - "CQ KA1ABC/VE6 -22", & - "DE KA1ABC/VE6 -22", & - "QRZ KA1ABC/VE6 -22", & - "CQ KA1ABC/VE6 R-22", & - "DE KA1ABC/VE6 R-22", & - "QRZ KA1ABC/VE6 R-22", & - "DE KA1ABC 73", & - "HELLO WORLD", & - "ZL4/KA1ABC 73", & - "KA1ABC XL/WB9XYZ", & - "KA1ABC WB9XYZ/W4", & - "DE KA1ABC/QRP 2W", & - "KA1ABC/1 WB9XYZ/1", & - "123456789ABCDEFGH"/ - data testmsgchk(1:NTEST)/ & - "CQ WB9XYZ EN34", & - "CQ DX WB9XYZ EN34", & - "QRZ WB9XYZ EN34", & - "KA1ABC WB9XYZ EN34", & - "KA1ABC WB9XYZ RO", & - "KA1ABC WB9XYZ -21", & - "KA1ABC WB9XYZ R-19", & - "KA1ABC WB9XYZ RRR", & - "KA1ABC WB9XYZ 73", & - "KA1ABC WB9XYZ", & - "CQ 000 WB9XYZ EN34", & - "CQ 999 WB9XYZ EN34", & - "CQ EU WB9XYZ EN34", & - "CQ WY WB9XYZ EN34", & - "1A/KA1ABC WB9XYZ", & - "E5/KA1ABC WB9XYZ", & - "KA1ABC 1A/WB9XYZ", & - "KA1ABC E5/WB9XYZ", & - "KA1ABC/P WB9XYZ", & - "KA1ABC/A WB9XYZ", & - "KA1ABC WB9XYZ/P", & - "KA1ABC WB9XYZ/A", & - "CQ KA1ABC/P", & - "CQ WB9XYZ/A", & - "QRZ KA1ABC/P", & - "QRZ WB9XYZ/A", & - "DE KA1ABC/P", & - "DE WB9XYZ/A", & - "CQ 1A/KA1ABC", & - "CQ E5/KA1ABC", & - "DE 1A/KA1ABC", & - "DE E5/KA1ABC", & - "QRZ 1A/KA1ABC", & - "QRZ E5/KA1ABC", & - "CQ WB9XYZ/1A", & - "CQ WB9XYZ/E5", & - "QRZ WB9XYZ/1A", & - "QRZ WB9XYZ/E5", & - "DE WB9XYZ/1A", & - "DE WB9XYZ/E5", & - "CQ A000/KA1ABC FM07", & - "CQ ZZZZ/KA1ABC FM07", & - "QRZ W4/KA1ABC FM07", & - "DE W4/KA1ABC FM07", & - "CQ W4/KA1ABC -22", & - "DE W4/KA1ABC -22", & - "QRZ W4/KA1ABC -22", & - "CQ W4/KA1ABC R-22", & - "DE W4/KA1ABC R-22", & - "QRZ W4/KA1ABC R-22", & - "DE W4/KA1ABC 73", & - "CQ KA1ABC FM07", & - "QRZ KA1ABC FM07", & - "DE KA1ABC/VE6 FM07", & - "CQ KA1ABC/VE6 -22", & - "DE KA1ABC/VE6 -22", & - "QRZ KA1ABC/VE6 -22", & - "CQ KA1ABC/VE6 R-22", & - "DE KA1ABC/VE6 R-22", & - "QRZ KA1ABC/VE6 R-22", & - "DE KA1ABC 73", & - "HELLO WORLD", & - "ZL4/KA1ABC 73", & - "KA1ABC XL/WB9", & - "KA1ABC WB9XYZ", & - "DE KA1ABC/QRP", & - "KA1ABC/1 WB9X", & - "123456789ABCD"/ + parameter (MAXTEST=75,NTEST=48) + character*37 testmsg(MAXTEST) + data testmsg(1:NTEST)/ & + "CQ K1ABC FN42", & + "K1ABC W9XYZ EN37", & + "W9XYZ K1ABC -11", & + "K1ABC W9XYZ R-09", & + "W9XYZ K1ABC RRR", & + "K1ABC W9XYZ 73", & + "K1ABC W9XYZ RR73", & + "CQ KH1/KH7Z", & + "K1ABC RR73; W9XYZ <KH1/KH7Z> -08", & + "CQ FD K1ABC FN42", & + "K1ABC W9XYZ 6A WI", & + "W9XYZ K1ABC R 2B EMA", & + "CQ TEST K1ABC/R FN42", & + "K1ABC/R W9XYZ EN37", & + "W9XYZ K1ABC/R R FN42", & + "K1ABC/R W9XYZ RR73", & + "CQ TEST K1ABC FN42", & + "K1ABC W9XYZ 579 WI", & + "W9XYZ K1ABC R 589 MA", & + "K1ABC KA0DEF 559 MO", & + "TU; KA0DEF K1ABC R 569 MA", & + "KA1ABC G3AAA 529 0013", & + "TU; G3AAA K1ABC R 559 MA", & + "CQ G4ABC/P IO91", & + "G4ABC/P PA9XYZ JO22", & + "PA9XYZ 590003 IO91NP", & + "G4ABC/P R 570007 JO22DB", & + "PA9XYZ G4ABC/P RR73", & + "CQ PJ4/K1ABC", & + "PJ4/K1ABC <W9XYZ>", & + "W9XYZ <PJ4/K1ABC> -11", & + "<PJ4/K1ABC> W9XYZ R-09", & + "<W9XYZ> PJ4/K1ABC RRR", & + "PJ4/K1ABC <W9XYZ> 73", & + "CQ W9XYZ EN37", & + "<W9XYZ> YW18FIFA", & + "<YW18FIFA> W9XYZ -11", & + "W9XYZ <YW18FIFA> R-09", & + "YW18FIFA <W9XYZ> RRR", & + "<W9XYZ> YW18FIFA 73", & + "TNX BOB 73 GL", & + "CQ YW18FIFA", & + "<YW18FIFA> KA1ABC", & + "KA1ABC <YW18FIFA> -11", & + "<YW18FIFA> KA1ABC R-17", & + "<KA1ABC> YW18FIFA RR73", & + "<YW18FIFA> KA1ABC 73", & + "123456789ABCDEF012"/ diff --git a/lib/ft8/ft8apset.f90 b/lib/ft8/ft8apset.f90 index ca5e5a6d..15eddd05 100644 --- a/lib/ft8/ft8apset.f90 +++ b/lib/ft8/ft8apset.f90 @@ -1,31 +1,43 @@ -subroutine ft8apset(mycall12,mygrid6,hiscall12,hisgrid6,bcontest,apsym,iaptype) - parameter(NAPM=4,KK=87) - character*12 mycall12,hiscall12 - character*22 msg,msgsent - character*6 mycall,hiscall - character*6 mygrid6,hisgrid6 - character*4 hisgrid - logical bcontest - integer apsym(KK) - integer*1 msgbits(KK) - integer itone(KK) - - mycall=mycall12(1:6) - hiscall=hiscall12(1:6) - hisgrid=hisgrid6(1:4) - if(len_trim(hiscall).eq.0) then - iaptype=1 - hiscall="K9AN" - else - iaptype=2 +subroutine ft8apset(mycall12,hiscall12,apsym) + use packjt77 + character*77 c77 + character*37 msg + character*12 mycall12,hiscall12,hiscall + integer apsym(58) + logical nohiscall + + if(len(trim(mycall12)).eq.0) then + apsym=0 + apsym(1)=99 + apsym(30)=99 + return endif - hisgrid=hisgrid6(1:4) -! if(len_trim(hisgrid).eq.0) hisgrid="EN50" - if(index(hisgrid," ").eq.0) hisgrid="EN50" - msg=mycall//' '//hiscall//' '//hisgrid - i3bit=0 ! ### TEMPORARY ??? ### - call genft8(msg,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - apsym=2*msgbits-1 - + + nohiscall=.false. + hiscall=hiscall12 + if(len(trim(hiscall)).eq.0) then + hiscall="K9ABC" + nohiscall=.true. + endif + +! Encode a dummy standard message: i3=1, 28 1 28 1 1 15 +! + msg=trim(mycall12)//' '//trim(hiscall)//' RRR' + call pack77(msg,i3,n3,c77) + if(i3.ne.1) then + apsym=0 + apsym(1)=99 + apsym(30)=99 + return + endif + + read(c77,'(58i1)',err=1) apsym(1:58) + apsym=2*apsym-1 + if(nohiscall) apsym(30)=99 + return + +1 apsym=0 + apsym(1)=99 + apsym(30)=99 return end subroutine ft8apset diff --git a/lib/ft8/ft8b.f90 b/lib/ft8/ft8b.f90 index 7d345316..5db48341 100644 --- a/lib/ft8/ft8b.f90 +++ b/lib/ft8/ft8b.f90 @@ -1,50 +1,56 @@ -subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & - napwid,lsubtract,nagain,iaptype,mycall12,mygrid6,hiscall12,bcontest, & +subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & + napwid,lsubtract,nagain,ncontest,iaptype,mycall12,hiscall12, & sync0,f1,xdt,xbase,apsym,nharderrors,dmin,nbadcrc,ipass,iera,msg37,xsnr) use crc use timer_module, only: timer + use packjt77 include 'ft8_params.f90' parameter(NP2=2812) character*37 msg37 - character message*22,msgsent*22 - character*12 mycall12,hiscall12 - character*6 mycall6,mygrid6,hiscall6,c1,c2 - character*87 cbits - logical bcontest + character*12 mycall12,hiscall12,hiscall12_0 + character*77 c77 + character*13 c13 real a(5) - real s1(0:7,ND),s2(0:7,NN),s1sort(8*ND) - real ps(0:7),psl(0:7) - real bmeta(3*ND),bmetb(3*ND),bmetap(3*ND) - real llr(3*ND),llra(3*ND),llr0(3*ND),llr1(3*ND),llrap(3*ND) !Soft symbols + real s8(0:7,NN) + real s2(0:511),s2l(0:511) + real bmeta(174),bmetb(174),bmetc(174) + real llra(174),llrb(174),llrc(174),llrd(174) !Soft symbols real dd0(15*12000) - integer*1 decoded(KK),decoded0(KK),apmask(3*ND),cw(3*ND) - integer*1 msgbits(KK) - integer apsym(KK) - integer mcq(28),mde(28),mrrr(16),m73(16),mrr73(16) + integer*1 message77(77),apmask(174),cw(174) + integer apsym(58) + integer mcq(29),mcqru(29),mcqfd(29),mcqtest(29) + integer mrrr(19),m73(19),mrr73(19) integer itone(NN) - integer indxs1(8*ND) integer icos7(0:6),ip(1) integer nappasses(0:5) !Number of decoding passes to use for each QSO state integer naptypes(0:5,4) ! (nQSOProgress, decoding pass) maximum of 4 passes for now - integer*1, target:: i1hiscall(12) - complex cd0(3200) + integer ncontest,ncontest0 + logical one(0:511,0:8) + integer graymap(0:7) + complex cd0(0:3199) complex ctwk(32) complex csymb(32) - logical first,newdat,lsubtract,lapon,lapcqonly,nagain - equivalence (s1,s1sort) - data icos7/2,5,6,0,4,1,3/ - data mcq/1,1,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,1,1,0,0,1/ - data mrrr/0,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1/ - data m73/0,1,1,1,1,1,1,0,1,1,0,1,0,0,0,0/ - data mde/1,1,1,1,1,1,1,1,0,1,1,0,0,1,0,0,0,0,0,1,1,1,0,1,0,0,0,1/ - data mrr73/0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1/ + complex cs(0:7,NN) + logical first,newdat,lsubtract,lapon,lapcqonly,nagain,unpk77_success + data icos7/3,1,4,0,6,5,2/ ! Flipped w.r.t. original FT8 sync array + data mcq/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0/ + data mcqru/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0/ + data mcqfd/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0/ + data mcqtest/0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,1,1,0,0,1,0/ + data mrrr/0,1,1,1,1,1,1,0,1,0,0,1,0,0,1,0,0,0,1/ + data m73/0,1,1,1,1,1,1,0,1,0,0,1,0,1,0,0,0,0,1/ + data mrr73/0,1,1,1,1,1,1,0,0,1,1,1,0,1,0,1,0,0,1/ data first/.true./ - save nappasses,naptypes + data graymap/0,1,3,2,5,6,4,7/ + save nappasses,naptypes,ncontest0,one,hiscall12_0 - if(first) then + + if(first.or.(ncontest.ne.ncontest0)) then mcq=2*mcq-1 - mde=2*mde-1 + mcqfd=2*mcqfd-1 + mcqru=2*mcqru-1 + mcqtest=2*mcqtest-1 mrrr=2*mrrr-1 m73=2*m73-1 mrr73=2*mrr73-1 @@ -57,25 +63,39 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & ! iaptype !------------------------ -! 1 CQ ??? ??? -! 2 MyCall ??? ??? -! 3 MyCall DxCall ??? -! 4 MyCall DxCall RRR -! 5 MyCall DxCall 73 -! 6 MyCall DxCall RR73 -! 7 ??? DxCall ??? - - naptypes(0,1:4)=(/1,2,0,0/) - naptypes(1,1:4)=(/2,3,0,0/) - naptypes(2,1:4)=(/2,3,0,0/) - naptypes(3,1:4)=(/3,4,5,6/) - naptypes(4,1:4)=(/3,4,5,6/) - naptypes(5,1:4)=(/3,1,2,0/) +! 1 CQ ??? ??? (29+3=32 ap bits) +! 2 MyCall ??? ??? (29+3=32 ap bits) +! 3 MyCall DxCall ??? (58+3=61 ap bits) +! 4 MyCall DxCall RRR (77 ap bits) +! 5 MyCall DxCall 73 (77 ap bits) +! 6 MyCall DxCall RR73 (77 ap bits) + + naptypes(0,1:4)=(/1,2,0,0/) ! Tx6 selected (CQ) + naptypes(1,1:4)=(/2,3,0,0/) ! Tx1 + naptypes(2,1:4)=(/2,3,0,0/) ! Tx2 + naptypes(3,1:4)=(/3,4,5,6/) ! Tx3 + naptypes(4,1:4)=(/3,4,5,6/) ! Tx4 + naptypes(5,1:4)=(/3,1,2,0/) ! Tx5 + + one=.false. + do i=0,511 + do j=0,8 + if(iand(i,2**j).ne.0) one(i,j)=.true. + enddo + enddo first=.false. + ncontest0=ncontest + endif + + if(hiscall12.ne.hiscall12_0) then + c13=hiscall12//' ' + call save_hash_call(c13,n10,n12,n22) + hiscall12_0=hiscall12 endif max_iterations=30 nharderrors=-1 + nbadcrc=1 ! this is used upstream to flag good decodes. fs2=12000.0/NDOWN dt2=1.0/fs2 twopi=8.0*atan(1.0) @@ -108,7 +128,7 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & ctwk(i)=cmplx(cos(phi),sin(phi)) phi=mod(phi+dphi,twopi) enddo - call sync8d(cd0,i0,ctwk,1,sync) + call sync8d(cd0,i0,ctwk,1,sync) if( sync .gt. smax ) then smax=sync delfbest=delf @@ -119,16 +139,15 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & call twkfreq1(cd0,NP2,fs2,a,cd0) xdt=xdt2 f1=f1+delfbest !Improved estimate of DF + call sync8d(cd0,i0,ctwk,0,sync) - call sync8d(cd0,i0,ctwk,2,sync) - - j=0 do k=1,NN i1=ibest+(k-1)*32 csymb=cmplx(0.0,0.0) - if( i1.ge.1 .and. i1+31 .le. NP2 ) csymb=cd0(i1:i1+31) + if( i1.ge.0 .and. i1+31 .le. NP2-1 ) csymb=cd0(i1:i1+31) call four2a(csymb,32,1,-1,1) - s2(0:7,k)=abs(csymb(1:8))/1e3 + cs(0:7,k)=csymb(1:8)/1e3 + s8(0:7,k)=abs(csymb(1:8)) enddo ! sync quality check @@ -136,11 +155,11 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & is2=0 is3=0 do k=1,7 - ip=maxloc(s2(:,k)) + ip=maxloc(s8(:,k)) if(icos7(k-1).eq.(ip(1)-1)) is1=is1+1 - ip=maxloc(s2(:,k+36)) + ip=maxloc(s8(:,k+36)) if(icos7(k-1).eq.(ip(1)-1)) is2=is2+1 - ip=maxloc(s2(:,k+72)) + ip=maxloc(s8(:,k+72)) if(icos7(k-1).eq.(ip(1)-1)) is3=is3+1 enddo ! hard sync sum - max is 21 @@ -150,292 +169,262 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & return endif - j=0 - do k=1,NN - if(k.le.7) cycle - if(k.ge.37 .and. k.le.43) cycle - if(k.gt.72) cycle - j=j+1 - s1(0:7,j)=s2(0:7,k) - enddo - - call indexx(s1sort,8*ND,indxs1) - xmeds1=s1sort(indxs1(nint(0.5*8*ND))) - s1=s1/xmeds1 - - do j=1,ND - i4=3*j-2 - i2=3*j-1 - i1=3*j -! Max amplitude - ps=s1(0:7,j) - r1=max(ps(1),ps(3),ps(5),ps(7))-max(ps(0),ps(2),ps(4),ps(6)) - r2=max(ps(2),ps(3),ps(6),ps(7))-max(ps(0),ps(1),ps(4),ps(5)) - r4=max(ps(4),ps(5),ps(6),ps(7))-max(ps(0),ps(1),ps(2),ps(3)) - bmeta(i4)=r4 - bmeta(i2)=r2 - bmeta(i1)=r1 - bmetap(i4)=r4 - bmetap(i2)=r2 - bmetap(i1)=r1 -! Max log metric - psl=log(ps) - r1=max(psl(1),psl(3),psl(5),psl(7))-max(psl(0),psl(2),psl(4),psl(6)) - r2=max(psl(2),psl(3),psl(6),psl(7))-max(psl(0),psl(1),psl(4),psl(5)) - r4=max(psl(4),psl(5),psl(6),psl(7))-max(psl(0),psl(1),psl(2),psl(3)) - bmetb(i4)=r4 - bmetb(i2)=r2 - bmetb(i1)=r1 - -! Metric for Cauchy noise -! r1=log(ps(1)**3+ps(3)**3+ps(5)**3+ps(7)**3)- & -! log(ps(0)**3+ps(2)**3+ps(4)**3+ps(6)**3) -! r2=log(ps(2)**3+ps(3)**3+ps(6)**3+ps(7)**3)- & -! log(ps(0)**3+ps(1)**3+ps(4)**3+ps(5)**3) -! r4=log(ps(4)**3+ps(5)**3+ps(6)**3+ps(7)**3)- & -! log(ps(0)**3+ps(1)**3+ps(2)**3+ps(3)**3) -! Metric for AWGN, no fading -! bscale=2.5 -! b0=bessi0(bscale*ps(0)) -! b1=bessi0(bscale*ps(1)) -! b2=bessi0(bscale*ps(2)) -! b3=bessi0(bscale*ps(3)) -! b4=bessi0(bscale*ps(4)) -! b5=bessi0(bscale*ps(5)) -! b6=bessi0(bscale*ps(6)) -! b7=bessi0(bscale*ps(7)) -! r1=log(b1+b3+b5+b7)-log(b0+b2+b4+b6) -! r2=log(b2+b3+b6+b7)-log(b0+b1+b4+b5) -! r4=log(b4+b5+b6+b7)-log(b0+b1+b2+b3) - - if(nQSOProgress .eq. 0 .or. nQSOProgress .eq. 5) then -! When bits 88:115 are set as ap bits, bit 115 lives in symbol 39 along -! with no-ap bits 116 and 117. Take care of metrics for bits 116 and 117. - if(j.eq.39) then ! take care of bits that live in symbol 39 - if(apsym(28).lt.0) then - bmetap(i2)=max(ps(2),ps(3))-max(ps(0),ps(1)) - bmetap(i1)=max(ps(1),ps(3))-max(ps(0),ps(2)) - else - bmetap(i2)=max(ps(6),ps(7))-max(ps(4),ps(5)) - bmetap(i1)=max(ps(5),ps(7))-max(ps(4),ps(6)) - endif - endif - endif - -! When bits 116:143 are set as ap bits, bit 115 lives in symbol 39 along -! with ap bits 116 and 117. Take care of metric for bit 115. -! if(j.eq.39) then ! take care of bit 115 -! iii=2*(apsym(29)+1)/2 + (apsym(30)+1)/2 ! known values of bits 116 & 117 -! if(iii.eq.0) bmetap(i4)=ps(4)-ps(0) -! if(iii.eq.1) bmetap(i4)=ps(5)-ps(1) -! if(iii.eq.2) bmetap(i4)=ps(6)-ps(2) -! if(iii.eq.3) bmetap(i4)=ps(7)-ps(3) -! endif - -! bit 144 lives in symbol 48 and will be 1 if it is set as an ap bit. -! take care of metrics for bits 142 and 143 - if(j.eq.48) then ! bit 144 is always 1 - bmetap(i4)=max(ps(5),ps(7))-max(ps(1),ps(3)) - bmetap(i2)=max(ps(3),ps(7))-max(ps(1),ps(5)) - endif - -! bit 154 lives in symbol 52 and will be 0 if it is set as an ap bit -! take care of metrics for bits 155 and 156 - if(j.eq.52) then ! bit 154 will be 0 if it is set as an ap bit. - bmetap(i2)=max(ps(2),ps(3))-max(ps(0),ps(1)) - bmetap(i1)=max(ps(1),ps(3))-max(ps(0),ps(2)) - endif - + do nsym=1,3 + nt=2**(3*nsym) + do ihalf=1,2 + do k=1,29,nsym + if(ihalf.eq.1) ks=k+7 + if(ihalf.eq.2) ks=k+43 + amax=-1.0 + do i=0,nt-1 + i1=i/64 + i2=iand(i,63)/8 + i3=iand(i,7) + if(nsym.eq.1) then + s2(i)=abs(cs(graymap(i3),ks)) + elseif(nsym.eq.2) then + s2(i)=abs(cs(graymap(i2),ks)+cs(graymap(i3),ks+1)) + elseif(nsym.eq.3) then + s2(i)=abs(cs(graymap(i1),ks)+cs(graymap(i2),ks+1)+cs(graymap(i3),ks+2)) + else + print*,"Error - nsym must be 1, 2, or 3." + endif + enddo + s2l(0:nt-1)=log(s2(0:nt-1)+1e-32) + i32=1+(k-1)*3+(ihalf-1)*87 + if(nsym.eq.1) ibmax=2 + if(nsym.eq.2) ibmax=5 + if(nsym.eq.3) ibmax=8 + do ib=0,ibmax + bm=maxval(s2(0:nt-1),one(0:nt-1,ibmax-ib)) - & + maxval(s2(0:nt-1),.not.one(0:nt-1,ibmax-ib)) + if(i32+ib .gt.174) cycle + if(nsym.eq.1) then + bmeta(i32+ib)=bm + elseif(nsym.eq.2) then + bmetb(i32+ib)=bm + elseif(nsym.eq.3) then + bmetc(i32+ib)=bm + endif + enddo + enddo + enddo enddo - - call normalizebmet(bmeta,3*ND) - call normalizebmet(bmetb,3*ND) - call normalizebmet(bmetap,3*ND) + call normalizebmet(bmeta,174) + call normalizebmet(bmetb,174) + call normalizebmet(bmetc,174) scalefac=2.83 - llr0=scalefac*bmeta - llr1=scalefac*bmetb - llra=scalefac*bmetap ! llr's for use with ap - apmag=scalefac*(maxval(abs(bmetap))*1.01) + llra=scalefac*bmeta + llrb=scalefac*bmetb + llrc=scalefac*bmetc + + apmag=maxval(abs(llra))*1.01 ! pass # !------------------------------ -! 1 regular decoding -! 2 erase 24 -! 3 erase 48 -! 4 ap pass 1 +! 1 regular decoding, nsym=1 +! 2 regular decoding, nsym=2 +! 3 regular decoding, nsym=3 +! 4 ap pass 1, nsym=1 (for now?) ! 5 ap pass 2 ! 6 ap pass 3 -! 7 ap pass 4, etc. +! 7 ap pass 4 - if(lapon) then + if(lapon.or.ncontest.eq.6) then !Hounds always use AP if(.not.lapcqonly) then - npasses=4+nappasses(nQSOProgress) + npasses=3+nappasses(nQSOProgress) else - npasses=5 + npasses=4 endif else - npasses=4 + npasses=3 endif do ipass=1,npasses - - llr=llr0 - if(ipass.eq.2) llr=llr1 - if(ipass.eq.3) llr(1:24)=0. - if(ipass.eq.4) llr(1:48)=0. - if(ipass.le.4) then + llrd=llra + if(ipass.eq.2) llrd=llrb + if(ipass.eq.3) llrd=llrc + if(ipass.le.3) then apmask=0 - llrap=llr iaptype=0 endif - - if(ipass .gt. 4) then + + if(ipass .gt. 3) then + llrd=llra if(.not.lapcqonly) then - iaptype=naptypes(nQSOProgress,ipass-4) + iaptype=naptypes(nQSOProgress,ipass-3) else iaptype=1 endif - if(iaptype.ge.3 .and. (abs(f1-nfqso).gt.napwid .and. abs(f1-nftx).gt.napwid) ) cycle - if(iaptype.eq.1 .or. iaptype.eq.2 ) then ! AP,???,??? + +! ncontest=0 : NONE +! 1 : NA_VHF +! 2 : EU_VHF +! 3 : FIELD DAY +! 4 : RTTY +! 5 : FOX +! 6 : HOUND +! +! Conditions that cause us to bail out of AP decoding + if(ncontest.le.4 .and. iaptype.ge.3 .and. (abs(f1-nfqso).gt.napwid .and. abs(f1-nftx).gt.napwid) ) cycle + if(ncontest.eq.5) cycle ! No AP for Foxes + if(ncontest.eq.6.and.f1.gt.950.0) cycle ! Hounds use AP only for signals below 950 Hz + if(iaptype.ge.2 .and. apsym(1).gt.1) cycle ! No, or nonstandard, mycall + if(iaptype.ge.3 .and. apsym(30).gt.1) cycle ! No, or nonstandard, dxcall + + if(iaptype.eq.1) then ! CQ or CQ RU or CQ TEST or CQ FD apmask=0 - apmask(88:115)=1 ! first 28 bits are AP - apmask(144)=1 ! not free text - llrap=llr - if(iaptype.eq.1) llrap(88:115)=apmag*mcq - if(iaptype.eq.2) llrap(88:115)=apmag*apsym(1:28) - llrap(116:117)=llra(116:117) - llrap(142:143)=llra(142:143) - llrap(144)=-apmag + apmask(1:29)=1 + if(ncontest.eq.0) llrd(1:29)=apmag*mcq(1:29) + if(ncontest.eq.1) llrd(1:29)=apmag*mcqtest(1:29) + if(ncontest.eq.2) llrd(1:29)=apmag*mcqtest(1:29) + if(ncontest.eq.3) llrd(1:29)=apmag*mcqfd(1:29) + if(ncontest.eq.4) llrd(1:29)=apmag*mcqru(1:29) + if(ncontest.eq.6) llrd(1:29)=apmag*mcq(1:29) + apmask(75:77)=1 + llrd(75:76)=apmag*(-1) + llrd(77)=apmag*(+1) endif - if(iaptype.eq.3) then ! mycall, dxcall, ??? + + if(iaptype.eq.2) then ! MyCall,???,??? apmask=0 - apmask(88:115)=1 ! mycall - apmask(116:143)=1 ! hiscall - apmask(144)=1 ! not free text - llrap=llr - llrap(88:143)=apmag*apsym(1:56) - llrap(144)=-apmag + if(ncontest.eq.0.or.ncontest.eq.1) then + apmask(1:29)=1 + llrd(1:29)=apmag*apsym(1:29) + apmask(75:77)=1 + llrd(75:76)=apmag*(-1) + llrd(77)=apmag*(+1) + else if(ncontest.eq.2) then + apmask(1:28)=1 + llrd(1:28)=apmag*apsym(1:28) + apmask(72:74)=1 + llrd(72)=apmag*(-1) + llrd(73)=apmag*(+1) + llrd(74)=apmag*(-1) + apmask(75:77)=1 + llrd(75:77)=apmag*(-1) + else if(ncontest.eq.3) then + apmask(1:28)=1 + llrd(1:28)=apmag*apsym(1:28) + apmask(75:77)=1 + llrd(75:77)=apmag*(-1) + else if(ncontest.eq.4) then + apmask(2:29)=1 + llrd(2:29)=apmag*apsym(1:28) + apmask(75:77)=1 + llrd(75)=apmag*(-1) + llrd(76:77)=apmag*(+1) + else if(ncontest.eq.6) then ! ??? RR73; MyCall <???> ??? + apmask(29:56)=1 + llrd(29:56)=apmag*apsym(1:28) + apmask(72:77)=1 + llrd(72:73)=apmag*(-1) + llrd(74)=apmag*(+1) + llrd(75:77)=apmag*(-1) + endif endif - if(iaptype.eq.4 .or. iaptype.eq.5 .or. iaptype.eq.6) then + + if(iaptype.eq.3) then ! MyCall,DxCall,??? apmask=0 - apmask(88:115)=1 ! mycall - apmask(116:143)=1 ! hiscall - apmask(144:159)=1 ! RRR or 73 or RR73 - llrap=llr - llrap(88:143)=apmag*apsym(1:56) - if(iaptype.eq.4) llrap(144:159)=apmag*mrrr - if(iaptype.eq.5) llrap(144:159)=apmag*m73 - if(iaptype.eq.6) llrap(144:159)=apmag*mrr73 + if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.2.or.ncontest.eq.6) then + apmask(1:58)=1 + llrd(1:58)=apmag*apsym + apmask(75:77)=1 + llrd(75:76)=apmag*(-1) + llrd(77)=apmag*(+1) + else if(ncontest.eq.3) then ! Field Day + apmask(1:56)=1 + llrd(1:28)=apmag*apsym(1:28) + llrd(29:56)=apmag*apsym(30:57) + apmask(72:74)=1 + apmask(75:77)=1 + llrd(75:77)=apmag*(-1) + else if(ncontest.eq.4) then ! RTTY RU + apmask(2:57)=1 + llrd(2:29)=apmag*apsym(1:28) + llrd(30:57)=apmag*apsym(30:57) + apmask(75:77)=1 + llrd(75)=apmag*(-1) + llrd(76:77)=apmag*(+1) + endif endif - if(iaptype.eq.7) then ! ???, dxcall, ??? + + if(iaptype.eq.5.and.ncontest.eq.6) cycle !Hound + if(iaptype.eq.4 .or. iaptype.eq.5 .or. iaptype.eq.6) then apmask=0 - apmask(116:143)=1 ! hiscall - apmask(144)=1 ! not free text - llrap=llr - llrap(115)=llra(115) - llrap(116:143)=apmag*apsym(29:56) - llrap(144)=-apmag + if(ncontest.le.4 .or. (ncontest.eq.6.and.iaptype.eq.6)) then + apmask(1:77)=1 ! mycall, hiscall, RRR|73|RR73 + llrd(1:58)=apmag*apsym + if(iaptype.eq.4) llrd(59:77)=apmag*mrrr + if(iaptype.eq.5) llrd(59:77)=apmag*m73 + if(iaptype.eq.6) llrd(59:77)=apmag*mrr73 + else if(ncontest.eq.6.and.iaptype.eq.4) then ! Hound listens for MyCall RR73;... + apmask(1:28)=1 + llrd(1:28)=apmag*apsym(1:28) + apmask(72:77)=1 + llrd(72:73)=apmag*(-1) + llrd(74)=apmag*(1) + llrd(75:77)=apmag*(-1) + endif endif endif cw=0 - call timer('bpd174 ',0) - call bpdecode174(llrap,apmask,max_iterations,decoded,cw,nharderrors, & + call timer('bpd174_91 ',0) + call bpdecode174_91(llrd,apmask,max_iterations,message77,cw,nharderrors, & niterations) - call timer('bpd174 ',1) + call timer('bpd174_91 ',1) dmin=0.0 if(ndepth.eq.3 .and. nharderrors.lt.0) then ndeep=3 if(abs(nfqso-f1).le.napwid .or. abs(nftx-f1).le.napwid) then - if((ipass.eq.3 .or. ipass.eq.4) .and. .not.nagain) then - ndeep=3 - else - ndeep=4 - endif + ndeep=4 endif if(nagain) ndeep=5 - call timer('osd174 ',0) - call osd174(llrap,apmask,ndeep,decoded,cw,nharderrors,dmin) - call timer('osd174 ',1) + call timer('osd174_91 ',0) + call osd174_91(llrd,apmask,ndeep,message77,cw,nharderrors,dmin) + call timer('osd174_91 ',1) endif - nbadcrc=1 - message=' ' - xsnr=-99.0 + + msg37=' ' + if(nharderrors.lt.0 .or. nharderrors.gt.36) cycle if(count(cw.eq.0).eq.174) cycle !Reject the all-zero codeword - if(nharderrors.ge.0 .and. nharderrors+dmin.lt.60.0 .and. & - .not.(sync.lt.2.0 .and. nharderrors.gt.35) .and. & - .not.(ipass.gt.2 .and. nharderrors.gt.39) .and. & - .not.(ipass.eq.4 .and. nharderrors.gt.30) & - ) then - call chkcrc12a(decoded,nbadcrc) - else - nharderrors=-1 - cycle + write(c77,'(77i1)') message77 + read(c77(72:74),'(b3)') n3 + read(c77(75:77),'(b3)') i3 + if(i3.gt.4 .or. (i3.eq.0.and.n3.gt.5)) then + cycle endif - i3bit=4*decoded(73) + 2*decoded(74) + decoded(75) - iFreeText=decoded(57) - if(nbadcrc.eq.0) then - decoded0=decoded - if(i3bit.eq.1) decoded(57:)=0 - call extractmessage174(decoded,message,ncrcflag) - decoded=decoded0 -! This needs fixing for messages with i3bit=1: - call genft8(message,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - if(lsubtract) call subtractft8(dd0,itone,f1,xdt2) - xsig=0.0 - xnoi=0.0 - do i=1,79 - xsig=xsig+s2(itone(i),i)**2 - ios=mod(itone(i)+4,7) - xnoi=xnoi+s2(ios,i)**2 - enddo - xsnr=0.001 - if(xnoi.gt.0 .and. xnoi.lt.xsig) xsnr=xsig/xnoi-1.0 - xsnr=10.0*log10(xsnr)-27.0 - xsnr2=db(xsig/xbase - 1.0) - 32.0 - if(.not.nagain) xsnr=xsnr2 - if(xsnr .lt. -24.0) xsnr=-24.0 - - if(i3bit.eq.1) then - do i=1,12 - i1hiscall(i)=ichar(hiscall12(i:i)) - enddo - icrc10=crc10(c_loc(i1hiscall),12) - write(cbits,1001) decoded -1001 format(87i1) - read(cbits,1002) ncrc10,nrpt -1002 format(56x,b10,b6) - irpt=nrpt-30 - i1=index(message,' ') - i2=index(message(i1+1:),' ') + i1 - c1=message(1:i1)//' ' - c2=message(i1+1:i2)//' ' - - if(ncrc10.eq.icrc10) msg37=c1//' RR73; '//c2//' <'// & - trim(hiscall12)//'> ' - if(ncrc10.ne.icrc10) msg37=c1//' RR73; '//c2//' <...> ' - -! msg37=c1//' RR73; '//c2//' <...> ' - write(msg37(35:37),1010) irpt -1010 format(i3.2) - if(msg37(35:35).ne.'-') msg37(35:35)='+' - - iz=len(trim(msg37)) - do iter=1,10 !Collapse multiple blanks - ib2=index(msg37(1:iz),' ') - if(ib2.lt.1) exit - msg37=msg37(1:ib2)//msg37(ib2+2:) - iz=iz-1 - enddo - else - msg37=message//' ' - endif - - return + call unpack77(c77,msg37,unpk77_success) + if(.not.unpk77_success) then + cycle + endif + nbadcrc=0 ! If we get this far: valid codeword, valid (i3,n3), nonquirky message. + call get_tones_from_77bits(message77,itone) + if(lsubtract) call subtractft8(dd0,itone,f1,xdt) + xsig=0.0 + xnoi=0.0 + do i=1,79 + xsig=xsig+s8(itone(i),i)**2 + ios=mod(itone(i)+4,7) + xnoi=xnoi+s8(ios,i)**2 + enddo + xsnr=0.001 + xsnr2=0.001 + arg=xsig/xnoi-1.0 + if(arg.gt.0.1) xsnr=arg + arg=xsig/xbase/2.6e6-1.0 + if(arg.gt.0.1) xsnr2=arg + xsnr=10.0*log10(xsnr)-27.0 + xsnr2=10.0*log10(xsnr2)-27.0 + if(.not.nagain) then + xsnr=xsnr2 endif + if(xsnr .lt. -24.0) xsnr=-24.0 + + return enddo - return end subroutine ft8b @@ -477,4 +466,3 @@ function bessi0(x) endif return end function bessi0 - diff --git a/lib/ft8/ft8code.f90 b/lib/ft8/ft8code.f90 index d273562e..cbafd34b 100644 --- a/lib/ft8/ft8code.f90 +++ b/lib/ft8/ft8code.f90 @@ -1,34 +1,25 @@ program ft8code -! Provides examples of message packing, LDPC(144,87) encoding, bit and +! Provides examples of message packing, LDPC(174,91) encoding, bit and ! symbol ordering, and other details of the FT8 protocol. - use packjt - use crc + use packjt77 include 'ft8_params.f90' !Set various constants include 'ft8_testmsg.f90' parameter (NWAVE=NN*NSPS) - - character*40 msg,msgchk - character*37 msg37 - character*6 c1,c2 + + character*37 msg,msgsent character*9 comment - character*22 msgsent,message - character*6 mygrid6 - character bad*1,msgtype*10 - character*87 cbits - logical bcontest + character bad*1,msgtype*18 integer itone(NN) - integer dgen(12) - integer*1 msgbits(KK),decoded(KK),decoded0(KK) - data mygrid6/'EM48 '/ + integer*1 msgbits(77) ! Get command-line argument(s) nargs=iargc() if(nargs.ne.1 .and. nargs.ne.3) then print* print*,'Program ft8code: Provides examples of message packing, ', & - 'LDPC(174,87) encoding,' + 'LDPC(174,91) encoding,' print*,'bit and symbol ordering, and other details of the FT8 protocol.' print* print*,'Usage: ft8code [-c grid] "message" # Results for specified message' @@ -36,99 +27,57 @@ program ft8code go to 999 endif - bcontest=.false. call getarg(1,msg) !Message to be transmitted if(len(trim(msg)).eq.2 .and. msg(1:2).eq.'-t') then - testmsg(NTEST+1)='KA1ABC RR73; WB9XYZ <KH1/KH7Z> -11' - nmsg=NTEST+1 - else if(len(trim(msg)).eq.2 .and. msg(1:2).eq.'-c') then - bcontest=.true. - call getarg(2,mygrid6) - call getarg(3,msg) - msgchk=msg - nmsg=1 + nmsg=NTEST else - msgchk=msg - call fmtmsg(msgchk,iz) !To upper case; collapse multiple blanks + call fmtmsg(msg,iz) !To upper case; collapse multiple blanks nmsg=1 endif write(*,1010) -1010 format(" Message Decoded Err? Type"/76("-")) +1010 format(4x,'Message',31x,'Decoded',29x,'Err i3.n3'/100('-')) do imsg=1,nmsg if(nmsg.gt.1) msg=testmsg(imsg) - call fmtmsg(msg,iz) !To upper case, collapse multiple blanks - msgchk=msg ! Generate msgsent, msgbits, and itone - if(index(msg,';').le.0) then - call packmsg(msg(1:22),dgen,itype,bcontest) - msgtype="" - if(itype.eq.1) msgtype="Std Msg" - if(itype.eq.2) msgtype="Type 1 pfx" - if(itype.eq.3) msgtype="Type 1 sfx" - if(itype.eq.4) msgtype="Type 2 pfx" - if(itype.eq.5) msgtype="Type 2 sfx" - if(itype.eq.6) msgtype="Free text" - i3bit=0 - call genft8(msg(1:22),mygrid6,bcontest,i3bit,msgsent,msgbits,itone) + i3=-1 + n3=-1 + call genft8(msg,i3,n3,msgsent,msgbits,itone) + msgtype="" + if(i3.eq.0) then + if(n3.eq.0) msgtype="Free text" + if(n3.eq.1) msgtype="DXpedition mode" + if(n3.eq.2) msgtype="EU VHF Contest" + if(n3.eq.3) msgtype="ARRL Field Day" + if(n3.eq.4) msgtype="ARRL Field Day" + if(n3.eq.5) msgtype="Telemetry" + if(n3.ge.6) msgtype="Undefined type" + endif + if(i3.eq.1) msgtype="Standard msg" + if(i3.eq.2) msgtype="EU VHF Contest" + if(i3.eq.3) msgtype="ARRL RTTY Roundup" + if(i3.eq.4) msgtype="Nonstandard calls" + if(i3.ge.5) msgtype="Undefined msg type" + if(i3.ge.1) n3=-1 + bad=" " + comment=' ' + if(msg.ne.msgsent) bad="*" + if(n3.ge.0) then + write(*,1020) imsg,msg,msgsent,bad,i3,n3,msgtype,comment +1020 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',i1,1x,a18,1x,a9) else - call foxgen_wrap(msg,msgbits,itone) - i3bit=1 + write(*,1022) imsg,msg,msgsent,bad,i3,msgtype,comment +1022 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',1x,1x,a18,1x,a9) endif - decoded=msgbits - i3bit=4*decoded(73) + 2*decoded(74) + decoded(75) - iFreeText=decoded(57) - decoded0=decoded - if(i3bit.eq.1) decoded(57:)=0 - call extractmessage174(decoded,message,ncrcflag) - decoded=decoded0 - - if(i3bit.eq.0) then - if(bcontest) call fix_contest_msg(mygrid6,message) - bad=" " - comment=' ' - if(itype.ne.6 .and. message.ne.msgchk) bad="*" - if(itype.eq.6 .and. message(1:13).ne.msgchk(1:13)) bad="*" - if(itype.eq.6 .and. len(trim(msgchk)).gt.13) comment='truncated' - write(*,1020) imsg,msgchk,message,bad,i3bit,itype,msgtype,comment -1020 format(i2,'.',1x,a22,1x,a22,1x,a1,2i2,1x,a10,1x,a9) - else - write(cbits,1001) decoded -1001 format(87i1) - read(cbits,1002) nrpt -1002 format(66x,b6) - irpt=nrpt-30 - i1=index(message,' ') - i2=index(message(i1+1:),' ') + i1 - c1=message(1:i1)//' ' - c2=message(i1+1:i2)//' ' - msg37=c1//' RR73; '//c2//' <...> ' - write(msg37(35:37),1003) irpt -1003 format(i3.2) - if(msg37(35:35).ne.'-') msg37(35:35)='+' - iz=len(trim(msg37)) - do iter=1,10 !Collapse multiple blanks into one - ib2=index(msg37(1:iz),' ') - if(ib2.lt.1) exit - msg37=msg37(1:ib2)//msg37(ib2+2:) - iz=iz-1 - enddo - - write(*,1021) imsg,msgchk,msg37 -1021 format(i2,'.',1x,a40,1x,a37) - endif - enddo if(nmsg.eq.1) then - write(*,1030) msgbits(1:56) -1030 format(/'Call1: ',28i1,' Call2: ',28i1) - write(*,1032) msgbits(57:72),msgbits(73:75),msgbits(76:87) -1032 format('Grid: ',16i1,' 3Bit: ',3i1,' CRC12: ',12i1) + write(*,1030) msgbits +1030 format(/'Message bits: ',/77i1) write(*,1034) itone -1034 format(/'Channel symbols:'/79i1) +1034 format(/'Channel symbols (tones):'/79i1) endif 999 end program ft8code diff --git a/lib/ft8/ft8sim.f90 b/lib/ft8/ft8sim.f90 index a8bd4965..bbec600d 100644 --- a/lib/ft8/ft8sim.f90 +++ b/lib/ft8/ft8sim.f90 @@ -1,36 +1,33 @@ program ft8sim -! Generate simulated data for a 15-second HF/6m mode using 8-FSK. +! Generate simulated "type 2" ft8 files ! Output is saved to a *.wav file. use wavhdr + use packjt77 include 'ft8_params.f90' !Set various constants parameter (NWAVE=NN*NSPS) type(hdr) h !Header for .wav file character arg*12,fname*17 - character msg40*40,msg*22,msgsent*22,msg0*22 - character*6 mygrid6 - logical bcontest + character msg37*37,msgsent37*37 + character c77*77 complex c0(0:NMAX-1) complex c(0:NMAX-1) real wave(NMAX) integer itone(NN) - integer*1 msgbits(KK) + integer*1 msgbits(77) integer*2 iwave(NMAX) !Generated full-length waveform - data mygrid6/'EM48 '/ ! Get command-line argument(s) nargs=iargc() if(nargs.ne.8) then - print*,'Usage: ft8sim "message" nsig|f0 DT fdop del width nfiles snr' - print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 0 10 -18' - print*,' ft8sim "K1ABC W9XYZ EN37" 10 0.0 0.1 1.0 25 10 -18' - print*,' ft8sim "K1ABC W9XYZ EN37" 25 0.0 0.1 1.0 25 10 -18' + print*,'Usage: ft8sim "message" f0 DT fdop del width nfiles snr' + print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 0 10 -18' + print*,' ft8sim "WA9XYZ/R KA1ABC/R FN42" 1500.0 0.0 0.1 1.0 0 10 -18' print*,' ft8sim "K1ABC RR73; W9XYZ <KH1/KH7Z> -11" 300 0 0 0 25 1 -10' - print*,'Make nfiles negative to invoke 72-bit contest mode.' go to 999 endif - call getarg(1,msg40) !Message to be transmitted + call getarg(1,msg37) !Message to be transmitted call getarg(2,arg) read(arg,*) f0 !Frequency (only used for single-signal) call getarg(3,arg) @@ -45,13 +42,13 @@ program ft8sim read(arg,*) nfiles !Number of files call getarg(8,arg) read(arg,*) snrdb !SNR_2500 + nsig=1 if(f0.lt.100.0) then nsig=f0 f0=1500 endif - bcontest=nfiles.lt.0 nfiles=abs(nfiles) twopi=8.0*atan(1.0) fs=12000.0 !Sample rate (Hz) @@ -65,97 +62,72 @@ program ft8sim if(snrdb.gt.90.0) sig=1.0 txt=NN*NSPS/12000.0 -! Source-encode, then get itone() - if(index(msg40,';').le.0) then - i3bit=0 - msg=msg40(1:22) - call genft8(msg,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - write(*,1000) f0,xdt,txt,snrdb,bw,msgsent + ! Source-encode, then get itone() + i3=-1 + n3=-1 + call pack77(msg37,i3,n3,c77) + call genft8(msg37,i3,n3,msgsent37,msgbits,itone) + + write(*,*) + write(*,'(a23,a37,3x,a7,i1,a1,i1)') 'New Style FT8 Message: ',msgsent37,'i3.n3: ',i3,'.',n3 + write(*,1000) f0,xdt,txt,snrdb,bw 1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, & - ' BW:',f4.1,2x,a22) + ' BW:',f4.1) + write(*,*) + if(i3.eq.1) then + write(*,*) ' mycall hiscall hisgrid' + write(*,'(28i1,1x,i1,1x,28i1,1x,i1,1x,i1,1x,15i1,1x,3i1)') msgbits(1:77) else - call foxgen_wrap(msg40,msgbits,itone) - write(*,1001) f0,xdt,txt,snrdb,bw,msg40 -1001 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, & - ' BW:',f4.1,2x,a40) + write(*,'(a14)') 'Message bits: ' + write(*,'(77i1)') msgbits endif + write(*,*) + write(*,'(a17)') 'Channel symbols: ' + write(*,'(79i1)') itone + write(*,*) - write(*,1030) msgbits(1:56) -1030 format(/'Call1: ',28i1,' Call2: ',28i1) - write(*,1032) msgbits(57:72),msgbits(73:75),msgbits(76:87) -1032 format('Grid: ',16i1,' 3Bit: ',3i1,' CRC12: ',12i1) - write(*,1034) itone -1034 format(/'Channel symbols:'/79i1/) + call sgran() msg0=msg do ifile=1,nfiles - c=0. - do isig=1,nsig - c0=0. - if(nsig.eq.2) then - if(index(msg,'R-').gt.0) f0=500 - i1=index(msg,' ') - msg(i1+4:i1+4)=char(ichar('A')+isig-1) - if(isig.eq.2) then - f0=f0+100 - endif - call genft8(msg,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - endif - if(nsig.eq.25) then - f0=(isig+2)*100.0 - else if(nsig.eq.50) then - msg=msg0 - f0=1000.0 + (isig-1)*60.0 - i1=index(msg,' ') - i2=index(msg(i1+1:),' ') + i1 - msg(i1+2:i1+2)=char(ichar('0')+mod(isig-1,10)) - msg(i1+3:i1+3)=char(ichar('A')+mod(isig-1,26)) - msg(i1+4:i1+4)=char(ichar('A')+mod(isig-1,26)) - msg(i1+5:i1+5)=char(ichar('A')+mod(isig-1,26)) - write(msg(i2+3:i2+4),'(i2.2)') isig-1 - if(ifile.ge.2 .and. isig.eq.ifile-1) then - write(msg(i2+1:i2+4),1002) -isig -1002 format('R',i3.2) - f0=600.0 + mod(isig-1,5)*60.0 - endif - call genft8(msg,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - endif - k=-1 + nint((xdt+0.5+0.01*gran())/dt) -! k=-1 + nint((xdt+0.5)/dt) - ia=k+1 - phi=0.0 - do j=1,NN !Generate complex waveform - dphi=twopi*(f0+itone(j)*baud)*dt - do i=1,NSPS - k=k+1 - phi=mod(phi+dphi,twopi) - if(k.ge.0 .and. k.lt.NMAX) c0(k)=cmplx(cos(phi),sin(phi)) - enddo + k=nint((xdt+0.5)/dt) + ia=k + phi=0.0 + c0=0.0 + do j=1,NN !Generate complex waveform + dphi=twopi*(f0*dt+itone(j)/real(NSPS)) + do i=1,NSPS + if(k.ge.0 .and. k.lt.NMAX) c0(k)=cmplx(cos(phi),sin(phi)) + k=k+1 + phi=mod(phi+dphi,twopi) enddo - if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c0,NMAX,fs,delay,fspread) - c=c+sig*c0 enddo + if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c0,NMAX,NWAVE,fs,delay,fspread) + c=sig*c0 + ib=k wave=real(c) peak=maxval(abs(wave(ia:ib))) - rms=sqrt(dot_product(wave(ia:ib),wave(ia:ib))/NWAVE) nslots=1 if(width.gt.0.0) call filt8(f0,nslots,width,wave) - + if(snrdb.lt.90) then do i=1,NMAX !Add gaussian noise at specified SNR xnoise=gran() -! wave(i)=wave(i) + xnoise -! if(i.ge.ia .and. i.le.ib) write(30,3001) i,wave(i)/peak -!3001 format(i8,f12.6) wave(i)=wave(i) + xnoise enddo endif - fac=32767.0 - rms=100.0 - if(snrdb.ge.90.0) iwave(1:NMAX)=nint(fac*wave) - if(snrdb.lt.90.0) iwave(1:NMAX)=nint(rms*wave) + gain=100.0 + if(snrdb.lt.90.0) then + wave=gain*wave + else + datpk=maxval(abs(wave)) + fac=32766.9/datpk + wave=fac*wave + endif + if(any(abs(wave).gt.32767.0)) print*,"Warning - data will be clipped." + iwave=nint(wave) h=default_header(12000,NMAX) write(fname,1102) ifile @@ -165,8 +137,5 @@ program ft8sim close(10) write(*,1110) ifile,xdt,f0,snrdb,fname 1110 format(i4,f7.2,f8.2,f7.1,2x,a17) - enddo - + enddo 999 end program ft8sim - - diff --git a/lib/ft8/genft8.f90 b/lib/ft8/genft8.f90 index dcb249d3..bf3116b8 100644 --- a/lib/ft8/genft8.f90 +++ b/lib/ft8/genft8.f90 @@ -1,44 +1,33 @@ -subroutine genft8(msg,mygrid,bcontest,i3bit,msgsent,msgbits,itone) +subroutine genft8(msg,i3,n3,msgsent,msgbits,itone) ! Encode an FT8 message, producing array itone(). - use crc - use packjt + use packjt77 include 'ft8_params.f90' - character*22 msg,msgsent - character*6 mygrid - character*87 cbits - logical bcontest,checksumok - integer*4 i4Msg6BitWords(12) !72-bit message as 6-bit words - integer*1 msgbits(KK),codeword(3*ND) - integer*1, target:: i1Msg8BitBytes(11) - integer itone(NN) + character msg*37,msgsent*37 + character*77 c77 + integer*1 msgbits(77),codeword(174) + integer itone(79) integer icos7(0:6) - data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern - - call packmsg(msg,i4Msg6BitWords,itype,bcontest) !Pack into 12 6-bit bytes - call unpackmsg(i4Msg6BitWords,msgsent,bcontest,mygrid) !Unpack to get msgsent - - write(cbits,1000) i4Msg6BitWords,32*i3bit -1000 format(12b6.6,b8.8) - read(cbits,1001) i1Msg8BitBytes(1:10) -1001 format(10b8) - i1Msg8BitBytes(10)=iand(i1Msg8BitBytes(10),128+64+32) - i1Msg8BitBytes(11)=0 - icrc12=crc12(c_loc(i1Msg8BitBytes),11) - -! For reference, here's how to check the CRC -! i1Msg8BitBytes(10)=icrc12/256 -! i1Msg8BitBytes(11)=iand (icrc12,255) -! checksumok = crc12_check(c_loc (i1Msg8BitBytes), 11) -! if( checksumok ) write(*,*) 'Good checksum' - - write(cbits,1003) i4Msg6BitWords,i3bit,icrc12 -1003 format(12b6.6,b3.3,b12.12) - read(cbits,1004) msgbits -1004 format(87i1) - - call encode174(msgbits,codeword) !Encode the test message + integer graymap(0:7) + logical unpk77_success + data icos7/3,1,4,0,6,5,2/ !Costas 7x7 tone pattern + data graymap/0,1,3,2,5,6,4,7/ + + i3=-1 + n3=-1 + call pack77(msg,i3,n3,c77) + call unpack77(c77,msgsent,unpk77_success) + read(c77,'(77i1)',err=1) msgbits + if(unpk77_success) go to 2 +1 msgbits=0 + itone=0 + msgsent='*** bad message *** ' + go to 900 + +entry get_tones_from_77bits(msgbits,itone) + +2 call encode174_91(msgbits,codeword) !Encode the test message ! Message structure: S7 D29 S7 D29 S7 itone(1:7)=icos7 @@ -49,8 +38,9 @@ subroutine genft8(msg,mygrid,bcontest,i3bit,msgsent,msgbits,itone) i=3*j -2 k=k+1 if(j.eq.30) k=k+7 - itone(k)=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2) + indx=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2) + itone(k)=graymap(indx) enddo - return +900 return end subroutine genft8 diff --git a/lib/ft8/genft8refsig.f90 b/lib/ft8/genft8refsig.f90 index 5bf4885c..cd1468c1 100644 --- a/lib/ft8/genft8refsig.f90 +++ b/lib/ft8/genft8refsig.f90 @@ -1,7 +1,8 @@ subroutine genft8refsig(itone,cref,f0) complex cref(79*1920) integer itone(79) - real*8 twopi,phi,dphi,dt,xnsps +! real*8 twopi,phi,dphi,dt,xnsps + real twopi,phi,dphi,dt,xnsps data twopi/0.d0/ save twopi if( twopi .lt. 0.1 ) twopi=8.d0*atan(1.d0) diff --git a/lib/ft8/ldpc_174_91_c_colorder.f90 b/lib/ft8/ldpc_174_91_c_colorder.f90 new file mode 100644 index 00000000..a83de09d --- /dev/null +++ b/lib/ft8/ldpc_174_91_c_colorder.f90 @@ -0,0 +1,11 @@ +data colorder/ & + 0, 1, 2, 3, 28, 4, 5, 6, 7, 8, 9, 10, 11, 34, 12, 32, 13, 14, 15, 16, & + 17, 18, 36, 29, 43, 19, 20, 42, 21, 40, 30, 37, 22, 47, 61, 45, 44, 23, 41, 39, & + 49, 24, 46, 50, 48, 26, 31, 33, 51, 38, 52, 59, 55, 66, 57, 27, 60, 35, 54, 58, & + 25, 56, 62, 64, 67, 69, 63, 68, 70, 72, 65, 73, 75, 74, 71, 77, 78, 76, 79, 80, & + 53, 81, 83, 82, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, & +100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119, & +120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139, & +140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, & +160,161,162,163,164,165,166,167,168,169,170,171,172,173/ + diff --git a/lib/ft8/ldpc_174_91_c_generator.f90 b/lib/ft8/ldpc_174_91_c_generator.f90 new file mode 100644 index 00000000..675bae57 --- /dev/null +++ b/lib/ft8/ldpc_174_91_c_generator.f90 @@ -0,0 +1,86 @@ +character*23 g(83) + +data g/ & + "8329ce11bf31eaf509f27fc", & + "761c264e25c259335493132", & + "dc265902fb277c6410a1bdc", & + "1b3f417858cd2dd33ec7f62", & + "09fda4fee04195fd034783a", & + "077cccc11b8873ed5c3d48a", & + "29b62afe3ca036f4fe1a9da", & + "6054faf5f35d96d3b0c8c3e", & + "e20798e4310eed27884ae90", & + "775c9c08e80e26ddae56318", & + "b0b811028c2bf997213487c", & + "18a0c9231fc60adf5c5ea32", & + "76471e8302a0721e01b12b8", & + "ffbccb80ca8341fafb47b2e", & + "66a72a158f9325a2bf67170", & + "c4243689fe85b1c51363a18", & + "0dff739414d1a1b34b1c270", & + "15b48830636c8b99894972e", & + "29a89c0d3de81d665489b0e", & + "4f126f37fa51cbe61bd6b94", & + "99c47239d0d97d3c84e0940", & + "1919b75119765621bb4f1e8", & + "09db12d731faee0b86df6b8", & + "488fc33df43fbdeea4eafb4", & + "827423ee40b675f756eb5fe", & + "abe197c484cb74757144a9a", & + "2b500e4bc0ec5a6d2bdbdd0", & + "c474aa53d70218761669360", & + "8eba1a13db3390bd6718cec", & + "753844673a27782cc42012e", & + "06ff83a145c37035a5c1268", & + "3b37417858cc2dd33ec3f62", & + "9a4a5a28ee17ca9c324842c", & + "bc29f465309c977e89610a4", & + "2663ae6ddf8b5ce2bb29488", & + "46f231efe457034c1814418", & + "3fb2ce85abe9b0c72e06fbe", & + "de87481f282c153971a0a2e", & + "fcd7ccf23c69fa99bba1412", & + "f0261447e9490ca8e474cec", & + "4410115818196f95cdd7012", & + "088fc31df4bfbde2a4eafb4", & + "b8fef1b6307729fb0a078c0", & + "5afea7acccb77bbc9d99a90", & + "49a7016ac653f65ecdc9076", & + "1944d085be4e7da8d6cc7d0", & + "251f62adc4032f0ee714002", & + "56471f8702a0721e00b12b8", & + "2b8e4923f2dd51e2d537fa0", & + "6b550a40a66f4755de95c26", & + "a18ad28d4e27fe92a4f6c84", & + "10c2e586388cb82a3d80758", & + "ef34a41817ee02133db2eb0", & + "7e9c0c54325a9c15836e000", & + "3693e572d1fde4cdf079e86", & + "bfb2cec5abe1b0c72e07fbe", & + "7ee18230c583cccc57d4b08", & + "a066cb2fedafc9f52664126", & + "bb23725abc47cc5f4cc4cd2", & + "ded9dba3bee40c59b5609b4", & + "d9a7016ac653e6decdc9036", & + "9ad46aed5f707f280ab5fc4", & + "e5921c77822587316d7d3c2", & + "4f14da8242a8b86dca73352", & + "8b8b507ad467d4441df770e", & + "22831c9cf1169467ad04b68", & + "213b838fe2ae54c38ee7180", & + "5d926b6dd71f085181a4e12", & + "66ab79d4b29ee6e69509e56", & + "958148682d748a38dd68baa", & + "b8ce020cf069c32a723ab14", & + "f4331d6d461607e95752746", & + "6da23ba424b9596133cf9c8", & + "a636bcbc7b30c5fbeae67fe", & + "5cb0d86a07df654a9089a20", & + "f11f106848780fc9ecdd80a", & + "1fbb5364fb8d2c9d730d5ba", & + "fcb86bc70a50c9d02a5d034", & + "a534433029eac15f322e34c", & + "c989d9c7c3d3b8c55d75130", & + "7bb38b2f0186d46643ae962", & + "2644ebadeb44b9467d1f42c", & + "608cc857594bfbb55d69600"/ diff --git a/lib/ft8/ldpc_174_91_c_parity.f90 b/lib/ft8/ldpc_174_91_c_parity.f90 new file mode 100644 index 00000000..6210ee26 --- /dev/null +++ b/lib/ft8/ldpc_174_91_c_parity.f90 @@ -0,0 +1,269 @@ +data Mn/ & + 1, 24, 66, & + 2, 5, 70, & + 3, 31, 65, & + 4, 49, 58, & + 6, 60, 67, & + 7, 32, 75, & + 8, 48, 82, & + 9, 35, 41, & + 10, 39, 62, & + 11, 14, 61, & + 12, 71, 74, & + 13, 23, 78, & + 15, 16, 79, & + 17, 54, 63, & + 18, 50, 57, & + 19, 30, 47, & + 20, 64, 80, & + 21, 28, 69, & + 22, 25, 43, & + 26, 34, 72, & + 27, 36, 37, & + 29, 40, 44, & + 33, 52, 53, & + 38, 55, 83, & + 42, 51, 59, & + 45, 76, 81, & + 46, 68, 77, & + 56, 67, 73, & + 1, 4, 5, & + 2, 47, 51, & + 3, 46, 82, & + 6, 24, 76, & + 7, 9, 16, & + 8, 10, 78, & + 11, 35, 55, & + 12, 38, 64, & + 13, 22, 37, & + 14, 15, 58, & + 17, 50, 53, & + 18, 29, 56, & + 19, 26, 57, & + 20, 39, 77, & + 21, 36, 63, & + 23, 54, 74, & + 25, 69, 73, & + 27, 33, 65, & + 28, 44, 79, & + 30, 43, 52, & + 31, 45, 61, & + 32, 48, 71, & + 34, 60, 62, & + 40, 41, 70, & + 42, 66, 68, & + 49, 75, 83, & + 59, 72, 80, & + 36, 64, 81, & + 1, 65, 74, & + 2, 8, 81, & + 3, 26, 79, & + 4, 22, 72, & + 5, 38, 50, & + 6, 9, 52, & + 7, 18, 77, & + 10, 28, 55, & + 11, 56, 59, & + 12, 67, 68, & + 13, 29, 47, & + 14, 39, 54, & + 15, 60, 70, & + 16, 37, 66, & + 17, 25, 82, & + 19, 21, 71, & + 20, 30, 31, & + 23, 75, 80, & + 24, 69, 75, & + 27, 32, 62, & + 33, 59, 76, & + 34, 53, 61, & + 35, 46, 47, & + 40, 43, 83, & + 41, 42, 63, & + 20, 44, 48, & + 16, 45, 73, & + 42, 49, 57, & + 25, 51, 62, & + 33, 58, 78, & + 1, 44, 45, & + 2, 7, 61, & + 3, 6, 54, & + 4, 35, 48, & + 5, 13, 21, & + 8, 56, 79, & + 9, 64, 69, & + 10, 19, 66, & + 11, 36, 60, & + 12, 37, 58, & + 14, 32, 43, & + 15, 63, 80, & + 17, 28, 77, & + 18, 74, 83, & + 22, 53, 81, & + 23, 30, 34, & + 24, 31, 40, & + 26, 41, 76, & + 27, 57, 70, & + 29, 49, 65, & + 3, 38, 78, & + 5, 39, 82, & + 46, 50, 73, & + 51, 52, 74, & + 55, 71, 72, & + 44, 67, 72, & + 43, 68, 78, & + 1, 32, 59, & + 2, 6, 71, & + 4, 16, 54, & + 7, 65, 67, & + 8, 30, 42, & + 9, 22, 31, & + 10, 18, 76, & + 11, 23, 82, & + 12, 28, 61, & + 13, 52, 79, & + 14, 50, 51, & + 15, 81, 83, & + 17, 29, 60, & + 19, 33, 64, & + 20, 26, 73, & + 21, 34, 40, & + 24, 27, 77, & + 25, 55, 58, & + 35, 53, 66, & + 36, 48, 68, & + 37, 46, 75, & + 38, 45, 47, & + 39, 57, 69, & + 41, 56, 62, & + 20, 49, 53, & + 46, 52, 63, & + 45, 70, 75, & + 27, 35, 80, & + 1, 15, 30, & + 2, 68, 80, & + 3, 36, 51, & + 4, 28, 51, & + 5, 31, 56, & + 6, 20, 37, & + 7, 40, 82, & + 8, 60, 69, & + 9, 10, 49, & + 11, 44, 57, & + 12, 39, 59, & + 13, 24, 55, & + 14, 21, 65, & + 16, 71, 78, & + 17, 30, 76, & + 18, 25, 80, & + 19, 61, 83, & + 22, 38, 77, & + 23, 41, 50, & + 7, 26, 58, & + 29, 32, 81, & + 33, 40, 73, & + 18, 34, 48, & + 13, 42, 64, & + 5, 26, 43, & + 47, 69, 72, & + 54, 55, 70, & + 45, 62, 68, & + 10, 63, 67, & + 14, 66, 72, & + 22, 60, 74, & + 35, 39, 79, & + 1, 46, 64/ + +data Nm/ & + 1, 29, 57, 87, 114, 142, 174, & + 2, 30, 58, 88, 115, 143, 0, & + 3, 31, 59, 89, 107, 144, 0, & + 4, 29, 60, 90, 116, 145, 0, & + 2, 29, 61, 91, 108, 146, 166, & + 5, 32, 62, 89, 115, 147, 0, & + 6, 33, 63, 88, 117, 148, 161, & + 7, 34, 58, 92, 118, 149, 0, & + 8, 33, 62, 93, 119, 150, 0, & + 9, 34, 64, 94, 120, 150, 170, & + 10, 35, 65, 95, 121, 151, 0, & + 11, 36, 66, 96, 122, 152, 0, & + 12, 37, 67, 91, 123, 153, 165, & + 10, 38, 68, 97, 124, 154, 171, & + 13, 38, 69, 98, 125, 142, 0, & + 13, 33, 70, 83, 116, 155, 0, & + 14, 39, 71, 99, 126, 156, 0, & + 15, 40, 63, 100, 120, 157, 164, & + 16, 41, 72, 94, 127, 158, 0, & + 17, 42, 73, 82, 128, 138, 147, & + 18, 43, 72, 91, 129, 154, 0, & + 19, 37, 60, 101, 119, 159, 172, & + 12, 44, 74, 102, 121, 160, 0, & + 1, 32, 75, 103, 130, 153, 0, & + 19, 45, 71, 85, 131, 157, 0, & + 20, 41, 59, 104, 128, 161, 166, & + 21, 46, 76, 105, 130, 141, 0, & + 18, 47, 64, 99, 122, 145, 0, & + 22, 40, 67, 106, 126, 162, 0, & + 16, 48, 73, 102, 118, 142, 156, & + 3, 49, 73, 103, 119, 146, 0, & + 6, 50, 76, 97, 114, 162, 0, & + 23, 46, 77, 86, 127, 163, 0, & + 20, 51, 78, 102, 129, 164, 0, & + 8, 35, 79, 90, 132, 141, 173, & + 21, 43, 56, 95, 133, 144, 0, & + 21, 37, 70, 96, 134, 147, 0, & + 24, 36, 61, 107, 135, 159, 0, & + 9, 42, 68, 108, 136, 152, 173, & + 22, 52, 80, 103, 129, 148, 163, & + 8, 52, 81, 104, 137, 160, 0, & + 25, 53, 81, 84, 118, 165, 0, & + 19, 48, 80, 97, 113, 166, 0, & + 22, 47, 82, 87, 112, 151, 0, & + 26, 49, 83, 87, 135, 140, 169, & + 27, 31, 79, 109, 134, 139, 174, & + 16, 30, 67, 79, 135, 167, 0, & + 7, 50, 82, 90, 133, 164, 0, & + 4, 54, 84, 106, 138, 150, 0, & + 15, 39, 61, 109, 124, 160, 0, & + 25, 30, 85, 110, 124, 144, 145, & + 23, 48, 62, 110, 123, 139, 0, & + 23, 39, 78, 101, 132, 138, 0, & + 14, 44, 68, 89, 116, 168, 0, & + 24, 35, 64, 111, 131, 153, 168, & + 28, 40, 65, 92, 137, 146, 0, & + 15, 41, 84, 105, 136, 151, 0, & + 4, 38, 86, 96, 131, 161, 0, & + 25, 55, 65, 77, 114, 152, 0, & + 5, 51, 69, 95, 126, 149, 172, & + 10, 49, 78, 88, 122, 158, 0, & + 9, 51, 76, 85, 137, 169, 0, & + 14, 43, 81, 98, 139, 170, 0, & + 17, 36, 56, 93, 127, 165, 174, & + 3, 46, 57, 106, 117, 154, 0, & + 1, 53, 70, 94, 132, 171, 0, & + 5, 28, 66, 112, 117, 170, 0, & + 27, 53, 66, 113, 133, 143, 169, & + 18, 45, 75, 93, 136, 149, 167, & + 2, 52, 69, 105, 140, 168, 0, & + 11, 50, 72, 111, 115, 155, 0, & + 20, 55, 60, 111, 112, 167, 171, & + 28, 45, 83, 109, 128, 163, 0, & + 11, 44, 57, 100, 110, 172, 0, & + 6, 54, 74, 75, 134, 140, 0, & + 26, 32, 77, 104, 120, 156, 0, & + 27, 42, 63, 99, 130, 159, 0, & + 12, 34, 86, 107, 113, 155, 0, & + 13, 47, 59, 92, 123, 173, 0, & + 17, 55, 74, 98, 141, 143, 157, & + 26, 56, 58, 101, 125, 162, 0, & + 7, 31, 71, 108, 121, 148, 0, & + 24, 54, 80, 100, 125, 158, 0/ + +data nrw/ & +7,6,6,6,7,6,7,6,6,7,6,6,7,7,6,6,6, & +7,6,7,6,7,6,6,6,7,6,6,6,7,6,6,6,6, & +7,6,6,6,7,7,6,6,6,6,7,7,6,6,6,6,7, & +6,6,6,7,6,6,6,6,7,6,6,6,7,6,6,6,7, & +7,6,6,7,6,6,6,6,6,6,6,7,6,6,6/ + +ncw=3 diff --git a/lib/ft8/ldpc_174_91_c_reordered_parity.f90 b/lib/ft8/ldpc_174_91_c_reordered_parity.f90 new file mode 100644 index 00000000..2309ad8e --- /dev/null +++ b/lib/ft8/ldpc_174_91_c_reordered_parity.f90 @@ -0,0 +1,270 @@ +data Mn/ & + 16, 45, 73, & + 25, 51, 62, & + 33, 58, 78, & + 1, 44, 45, & + 2, 7, 61, & + 3, 6, 54, & + 4, 35, 48, & + 5, 13, 21, & + 8, 56, 79, & + 9, 64, 69, & + 10, 19, 66, & + 11, 36, 60, & + 12, 37, 58, & + 14, 32, 43, & + 15, 63, 80, & + 17, 28, 77, & + 18, 74, 83, & + 22, 53, 81, & + 23, 30, 34, & + 24, 31, 40, & + 26, 41, 76, & + 27, 57, 70, & + 29, 49, 65, & + 3, 38, 78, & + 5, 39, 82, & + 46, 50, 73, & + 51, 52, 74, & + 55, 71, 72, & + 44, 67, 72, & + 43, 68, 78, & + 1, 32, 59, & + 2, 6, 71, & + 4, 16, 54, & + 7, 65, 67, & + 8, 30, 42, & + 9, 22, 31, & + 10, 18, 76, & + 11, 23, 82, & + 12, 28, 61, & + 13, 52, 79, & + 14, 50, 51, & + 15, 81, 83, & + 17, 29, 60, & + 19, 33, 64, & + 20, 26, 73, & + 21, 34, 40, & + 24, 27, 77, & + 25, 55, 58, & + 35, 53, 66, & + 36, 48, 68, & + 37, 46, 75, & + 38, 45, 47, & + 39, 57, 69, & + 41, 56, 62, & + 20, 49, 53, & + 46, 52, 63, & + 45, 70, 75, & + 27, 35, 80, & + 1, 15, 30, & + 2, 68, 80, & + 3, 36, 51, & + 4, 28, 51, & + 5, 31, 56, & + 6, 20, 37, & + 7, 40, 82, & + 8, 60, 69, & + 9, 10, 49, & + 11, 44, 57, & + 12, 39, 59, & + 13, 24, 55, & + 14, 21, 65, & + 16, 71, 78, & + 17, 30, 76, & + 18, 25, 80, & + 19, 61, 83, & + 22, 38, 77, & + 23, 41, 50, & + 7, 26, 58, & + 29, 32, 81, & + 33, 40, 73, & + 18, 34, 48, & + 13, 42, 64, & + 5, 26, 43, & + 47, 69, 72, & + 54, 55, 70, & + 45, 62, 68, & + 10, 63, 67, & + 14, 66, 72, & + 22, 60, 74, & + 35, 39, 79, & + 1, 46, 64, & + 1, 24, 66, & + 2, 5, 70, & + 3, 31, 65, & + 4, 49, 58, & + 1, 4, 5, & + 6, 60, 67, & + 7, 32, 75, & + 8, 48, 82, & + 9, 35, 41, & + 10, 39, 62, & + 11, 14, 61, & + 12, 71, 74, & + 13, 23, 78, & + 11, 35, 55, & + 15, 16, 79, & + 7, 9, 16, & + 17, 54, 63, & + 18, 50, 57, & + 19, 30, 47, & + 20, 64, 80, & + 21, 28, 69, & + 22, 25, 43, & + 13, 22, 37, & + 2, 47, 51, & + 23, 54, 74, & + 26, 34, 72, & + 27, 36, 37, & + 21, 36, 63, & + 29, 40, 44, & + 19, 26, 57, & + 3, 46, 82, & + 14, 15, 58, & + 33, 52, 53, & + 30, 43, 52, & + 6, 9, 52, & + 27, 33, 65, & + 25, 69, 73, & + 38, 55, 83, & + 20, 39, 77, & + 18, 29, 56, & + 32, 48, 71, & + 42, 51, 59, & + 28, 44, 79, & + 34, 60, 62, & + 31, 45, 61, & + 46, 68, 77, & + 6, 24, 76, & + 8, 10, 78, & + 40, 41, 70, & + 17, 50, 53, & + 42, 66, 68, & + 4, 22, 72, & + 36, 64, 81, & + 13, 29, 47, & + 2, 8, 81, & + 56, 67, 73, & + 5, 38, 50, & + 12, 38, 64, & + 59, 72, 80, & + 3, 26, 79, & + 45, 76, 81, & + 1, 65, 74, & + 7, 18, 77, & + 11, 56, 59, & + 14, 39, 54, & + 16, 37, 66, & + 10, 28, 55, & + 15, 60, 70, & + 17, 25, 82, & + 20, 30, 31, & + 12, 67, 68, & + 23, 75, 80, & + 27, 32, 62, & + 24, 69, 75, & + 19, 21, 71, & + 34, 53, 61, & + 35, 46, 47, & + 33, 59, 76, & + 40, 43, 83, & + 41, 42, 63, & + 49, 75, 83, & + 20, 44, 48, & + 42, 49, 57/ + +data Nm/ & + 4, 31, 59, 91, 92, 96, 153, & + 5, 32, 60, 93, 115, 146, 0, & + 6, 24, 61, 94, 122, 151, 0, & + 7, 33, 62, 95, 96, 143, 0, & + 8, 25, 63, 83, 93, 96, 148, & + 6, 32, 64, 97, 126, 138, 0, & + 5, 34, 65, 78, 98, 107, 154, & + 9, 35, 66, 99, 139, 146, 0, & + 10, 36, 67, 100, 107, 126, 0, & + 11, 37, 67, 87, 101, 139, 158, & + 12, 38, 68, 102, 105, 155, 0, & + 13, 39, 69, 103, 149, 162, 0, & + 8, 40, 70, 82, 104, 114, 145, & + 14, 41, 71, 88, 102, 123, 156, & + 15, 42, 59, 106, 123, 159, 0, & + 1, 33, 72, 106, 107, 157, 0, & + 16, 43, 73, 108, 141, 160, 0, & + 17, 37, 74, 81, 109, 131, 154, & + 11, 44, 75, 110, 121, 166, 0, & + 45, 55, 64, 111, 130, 161, 173, & + 8, 46, 71, 112, 119, 166, 0, & + 18, 36, 76, 89, 113, 114, 143, & + 19, 38, 77, 104, 116, 163, 0, & + 20, 47, 70, 92, 138, 165, 0, & + 2, 48, 74, 113, 128, 160, 0, & + 21, 45, 78, 83, 117, 121, 151, & + 22, 47, 58, 118, 127, 164, 0, & + 16, 39, 62, 112, 134, 158, 0, & + 23, 43, 79, 120, 131, 145, 0, & + 19, 35, 59, 73, 110, 125, 161, & + 20, 36, 63, 94, 136, 161, 0, & + 14, 31, 79, 98, 132, 164, 0, & + 3, 44, 80, 124, 127, 169, 0, & + 19, 46, 81, 117, 135, 167, 0, & + 7, 49, 58, 90, 100, 105, 168, & + 12, 50, 61, 118, 119, 144, 0, & + 13, 51, 64, 114, 118, 157, 0, & + 24, 52, 76, 129, 148, 149, 0, & + 25, 53, 69, 90, 101, 130, 156, & + 20, 46, 65, 80, 120, 140, 170, & + 21, 54, 77, 100, 140, 171, 0, & + 35, 82, 133, 142, 171, 174, 0, & + 14, 30, 83, 113, 125, 170, 0, & + 4, 29, 68, 120, 134, 173, 0, & + 1, 4, 52, 57, 86, 136, 152, & + 26, 51, 56, 91, 122, 137, 168, & + 52, 84, 110, 115, 145, 168, 0, & + 7, 50, 81, 99, 132, 173, 0, & + 23, 55, 67, 95, 172, 174, 0, & + 26, 41, 77, 109, 141, 148, 0, & + 2, 27, 41, 61, 62, 115, 133, & + 27, 40, 56, 124, 125, 126, 0, & + 18, 49, 55, 124, 141, 167, 0, & + 6, 33, 85, 108, 116, 156, 0, & + 28, 48, 70, 85, 105, 129, 158, & + 9, 54, 63, 131, 147, 155, 0, & + 22, 53, 68, 109, 121, 174, 0, & + 3, 13, 48, 78, 95, 123, 0, & + 31, 69, 133, 150, 155, 169, 0, & + 12, 43, 66, 89, 97, 135, 159, & + 5, 39, 75, 102, 136, 167, 0, & + 2, 54, 86, 101, 135, 164, 0, & + 15, 56, 87, 108, 119, 171, 0, & + 10, 44, 82, 91, 111, 144, 149, & + 23, 34, 71, 94, 127, 153, 0, & + 11, 49, 88, 92, 142, 157, 0, & + 29, 34, 87, 97, 147, 162, 0, & + 30, 50, 60, 86, 137, 142, 162, & + 10, 53, 66, 84, 112, 128, 165, & + 22, 57, 85, 93, 140, 159, 0, & + 28, 32, 72, 103, 132, 166, 0, & + 28, 29, 84, 88, 117, 143, 150, & + 1, 26, 45, 80, 128, 147, 0, & + 17, 27, 89, 103, 116, 153, 0, & + 51, 57, 98, 163, 165, 172, 0, & + 21, 37, 73, 138, 152, 169, 0, & + 16, 47, 76, 130, 137, 154, 0, & + 3, 24, 30, 72, 104, 139, 0, & + 9, 40, 90, 106, 134, 151, 0, & + 15, 58, 60, 74, 111, 150, 163, & + 18, 42, 79, 144, 146, 152, 0, & + 25, 38, 65, 99, 122, 160, 0, & + 17, 42, 75, 129, 170, 172, 0/ + +data nrw/ & +7,6,6,6,7,6,7,6,6,7,6,6,7,7,6,6, & +6,7,6,7,6,7,6,6,6,7,6,6,6,7,6,6, & +6,6,7,6,6,6,7,7,6,6,6,6,7,7,6,6, & +6,6,7,6,6,6,7,6,6,6,6,7,6,6,6,7, & +6,6,6,7,7,6,6,7,6,6,6,6,6,6,6,7, & +6,6,6/ + +ncw=3 diff --git a/lib/ft8/ldpcsim174.f90 b/lib/ft8/ldpcsim174.f90 deleted file mode 100644 index 08b181eb..00000000 --- a/lib/ft8/ldpcsim174.f90 +++ /dev/null @@ -1,234 +0,0 @@ -program ldpcsim174 -! End to end test of the (174,75)/crc12 encoder and decoder. -use crc -use packjt - -character*22 msg,msgsent,msgreceived -character*8 arg -character*6 grid -integer*1, allocatable :: codeword(:), decoded(:), message(:) -integer*1, target:: i1Msg8BitBytes(11) -integer*1 msgbits(87) -integer*1 apmask(174), cw(174) -integer*2 checksum -integer*4 i4Msg6BitWords(13) -integer colorder(174) -integer nerrtot(174),nerrdec(174),nmpcbad(87) -logical checksumok,fsk,bpsk -real*8, allocatable :: rxdata(:) -real, allocatable :: llr(:) - -data colorder/ & - 0, 1, 2, 3, 30, 4, 5, 6, 7, 8, 9, 10, 11, 32, 12, 40, 13, 14, 15, 16,& - 17, 18, 37, 45, 29, 19, 20, 21, 41, 22, 42, 31, 33, 34, 44, 35, 47, 51, 50, 43,& - 36, 52, 63, 46, 25, 55, 27, 24, 23, 53, 39, 49, 59, 38, 48, 61, 60, 57, 28, 62,& - 56, 58, 65, 66, 26, 70, 64, 69, 68, 67, 74, 71, 54, 76, 72, 75, 78, 77, 80, 79,& - 73, 83, 84, 81, 82, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,& - 100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,& - 120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,& - 140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,& - 160,161,162,163,164,165,166,167,168,169,170,171,172,173/ - -nerrtot=0 -nerrdec=0 -nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword - -nargs=iargc() -if(nargs.ne.4) then - print*,'Usage: ldpcsim niter ndepth #trials s ' - print*,'eg: ldpcsim 10 2 1000 0.84' - print*,'belief propagation iterations: niter, ordered-statistics depth: ndepth' - print*,'If s is negative, then value is ignored and sigma is calculated from SNR.' - return -endif -call getarg(1,arg) -read(arg,*) max_iterations -call getarg(2,arg) -read(arg,*) ndepth -call getarg(3,arg) -read(arg,*) ntrials -call getarg(4,arg) -read(arg,*) s - -fsk=.false. -bpsk=.true. - -! don't count crc bits as data bits -N=174 -K=87 -! scale Eb/No for a (174,87) code -rate=real(K)/real(N) - -write(*,*) "rate: ",rate -write(*,*) "niter= ",max_iterations," s= ",s - -allocate ( codeword(N), decoded(K), message(K) ) -allocate ( rxdata(N), llr(N) ) - - msg="K1JT K9AN EN50" -! msg="G4WJS K9AN EN50" - call packmsg(msg,i4Msg6BitWords,itype,.false.) !Pack into 12 6-bit bytes - call unpackmsg(i4Msg6BitWords,msgsent,.false.,grid) !Unpack to get msgsent - write(*,*) "message sent ",msgsent - - i4=0 - ik=0 - im=0 - do i=1,12 - nn=i4Msg6BitWords(i) - do j=1, 6 - ik=ik+1 - i4=i4+i4+iand(1,ishft(nn,j-6)) - i4=iand(i4,255) - if(ik.eq.8) then - im=im+1 -! if(i4.gt.127) i4=i4-256 - i1Msg8BitBytes(im)=i4 - ik=0 - endif - enddo - enddo - - i1Msg8BitBytes(10:11)=0 - checksum = crc12 (c_loc (i1Msg8BitBytes), 11) -! For reference, the next 3 lines show how to check the CRC - i1Msg8BitBytes(10)=checksum/256 - i1Msg8BitBytes(11)=iand (checksum,255) - checksumok = crc12_check(c_loc (i1Msg8BitBytes), 11) - if( checksumok ) write(*,*) 'Good checksum' - -! K=87, For now: -! msgbits(1:72) JT message bits -! msgbits(73:75) 3 free message bits (set to 0) -! msgbits(76:87) CRC12 - mbit=0 - do i=1, 9 - i1=i1Msg8BitBytes(i) - do ibit=1,8 - mbit=mbit+1 - msgbits(mbit)=iand(1,ishft(i1,ibit-8)) - enddo - enddo - msgbits(73:75)=0 ! the three extra message bits go here - i1=i1Msg8BitBytes(10) ! First 4 bits of crc12 are LSB of this byte - do ibit=1,4 - msgbits(75+ibit)=iand(1,ishft(i1,ibit-4)) - enddo - i1=i1Msg8BitBytes(11) ! Now shift in last 8 bits of the CRC - do ibit=1,8 - msgbits(79+ibit)=iand(1,ishft(i1,ibit-8)) - enddo - - write(*,*) 'message' - write(*,'(11(8i1,1x))') msgbits - - call encode174(msgbits,codeword) - call init_random_seed() -! call sgran() - - write(*,*) 'codeword' - write(*,'(22(8i1,1x))') codeword - -write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma" -do idb = 20,-10,-1 -!do idb = -3,-3,-1 - db=idb/2.0-1.0 - sigma=1/sqrt( 2*(10**(db/10.0)) ) - ngood=0 - nue=0 - nbadcrc=0 - nberr=0 - do itrial=1, ntrials -! Create a realization of a noisy received word - do i=1,N - if( bpsk ) then - rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran() - elseif( fsk ) then - if( codeword(i) .eq. 1 ) then - r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r2=(sigma*gran())**2 + (sigma*gran())**2 - elseif( codeword(i) .eq. 0 ) then - r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2 - r1=(sigma*gran())**2 + (sigma*gran())**2 - endif -! rxdata(i)=0.35*(sqrt(r1)-sqrt(r2)) -! rxdata(i)=0.35*(exp(r1)-exp(r2)) - rxdata(i)=0.12*(log(r1)-log(r2)) - endif - enddo - nerr=0 - do i=1,N - if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1 - enddo - if(nerr.ge.1) nerrtot(nerr)=nerrtot(nerr)+1 - nberr=nberr+nerr - -! Correct signal normalization is important for this decoder. - rxav=sum(rxdata)/N - rx2av=sum(rxdata*rxdata)/N - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig -! To match the metric to the channel, s should be set to the noise standard deviation. -! For now, set s to the value that optimizes decode probability near threshold. -! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of -! magnitude in UER - if( s .lt. 0 ) then - ss=sigma - else - ss=s - endif - - llr=2.0*rxdata/(ss*ss) - nap=0 ! number of AP bits - llr(colorder(174-87+1:174-87+nap)+1)=5*(2.0*msgbits(1:nap)-1.0) - apmask=0 - apmask(colorder(174-87+1:174-87+nap)+1)=1 - -! max_iterations is max number of belief propagation iterations - call bpdecode174(llr, apmask, max_iterations, decoded, cw, nharderrors,niterations) - if( ndepth .ge. 0 .and. nharderrors .lt. 0 ) call osd174(llr, apmask, ndepth, decoded, cw, nharderrors, dmin) -! If the decoder finds a valid codeword, nharderrors will be .ge. 0. - if( nharderrors .ge. 0 ) then - call extractmessage174(decoded,msgreceived,ncrcflag) - if( ncrcflag .ne. 1 ) then - nbadcrc=nbadcrc+1 - endif - - nueflag=0 - nerrmpc=0 - do i=1,K ! find number of errors in message+crc part of codeword - if( msgbits(i) .ne. decoded(i) ) then - nueflag=1 - nerrmpc=nerrmpc+1 - endif - enddo - if(nerrmpc.ge.1) nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1 - if( ncrcflag .eq. 1 ) then - if( nueflag .eq. 0 ) then - ngood=ngood+1 - if(nerr.ge.1) nerrdec(nerr)=nerrdec(nerr)+1 - else if( nueflag .eq. 1 ) then - nue=nue+1; - endif - endif - endif - enddo - baud=12000/1920 - snr2500=db+10.0*log10((baud/2500.0)) - pberr=real(nberr)/(real(ntrials*N)) - write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr - -enddo - -open(unit=23,file='nerrhisto.dat',status='unknown') -do i=1,174 - write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10) -enddo -close(23) -open(unit=25,file='nmpcbad.dat',status='unknown') -do i=1,87 - write(25,'(i4,2x,i10)') i,nmpcbad(i) -enddo -close(25) - -end program ldpcsim174 diff --git a/lib/ft8/osd174.f90 b/lib/ft8/osd174.f90 deleted file mode 100644 index 45d7faa4..00000000 --- a/lib/ft8/osd174.f90 +++ /dev/null @@ -1,365 +0,0 @@ -subroutine osd174(llr,apmask,ndeep,decoded,cw,nhardmin,dmin) -! -! An ordered-statistics decoder for the (174,87) code. -! -include "ldpc_174_87_params.f90" - -integer*1 apmask(N),apmaskr(N) -integer*1 gen(K,N) -integer*1 genmrb(K,N),g2(N,K) -integer*1 temp(K),m0(K),me(K),mi(K),misub(K),e2sub(N-K),e2(N-K),ui(N-K) -integer*1 r2pat(N-K) -integer indices(N),nxor(N) -integer*1 cw(N),ce(N),c0(N),hdec(N) -integer*1 decoded(K) -integer indx(N) -real llr(N),rx(N),absrx(N) -logical first,reset -data first/.true./ -save first,gen - -if( first ) then ! fill the generator matrix - gen=0 - do i=1,M - do j=1,22 - read(g(i)(j:j),"(Z1)") istr - do jj=1, 4 - irow=(j-1)*4+jj - if( btest(istr,4-jj) ) gen(irow,i)=1 - enddo - enddo - enddo - do irow=1,K - gen(irow,M+irow)=1 - enddo -first=.false. -endif - -! Re-order received vector to place systematic msg bits at the end. -rx=llr(colorder+1) -apmaskr=apmask(colorder+1) - -! Hard decisions on the received word. -hdec=0 -where(rx .ge. 0) hdec=1 - -! Use magnitude of received symbols as a measure of reliability. -absrx=abs(rx) -call indexx(absrx,N,indx) - -! Re-order the columns of the generator matrix in order of decreasing reliability. -do i=1,N - genmrb(1:K,i)=gen(1:K,indx(N+1-i)) - indices(i)=indx(N+1-i) -enddo - -! Do gaussian elimination to create a generator matrix with the most reliable -! received bits in positions 1:K in order of decreasing reliability (more or less). -do id=1,K ! diagonal element indices - do icol=id,K+20 ! The 20 is ad hoc - beware - iflag=0 - if( genmrb(id,icol) .eq. 1 ) then - iflag=1 - if( icol .ne. id ) then ! reorder column - temp(1:K)=genmrb(1:K,id) - genmrb(1:K,id)=genmrb(1:K,icol) - genmrb(1:K,icol)=temp(1:K) - itmp=indices(id) - indices(id)=indices(icol) - indices(icol)=itmp - endif - do ii=1,K - if( ii .ne. id .and. genmrb(ii,id) .eq. 1 ) then - genmrb(ii,1:N)=ieor(genmrb(ii,1:N),genmrb(id,1:N)) - endif - enddo - exit - endif - enddo -enddo - -g2=transpose(genmrb) - -! The hard decisions for the K MRB bits define the order 0 message, m0. -! Encode m0 using the modified generator matrix to find the "order 0" codeword. -! Flip various combinations of bits in m0 and re-encode to generate a list of -! codewords. Return the member of the list that has the smallest Euclidean -! distance to the received word. - -hdec=hdec(indices) ! hard decisions from received symbols -m0=hdec(1:K) ! zero'th order message -absrx=absrx(indices) -rx=rx(indices) -apmaskr=apmaskr(indices) - -call mrbencode(m0,c0,g2,N,K) -nxor=ieor(c0,hdec) -nhardmin=sum(nxor) -dmin=sum(nxor*absrx) - -cw=c0 -ntotal=0 -nrejected=0 - -if(ndeep.eq.0) goto 998 ! norder=0 -if(ndeep.gt.5) ndeep=5 -if( ndeep.eq. 1) then - nord=1 - npre1=0 - npre2=0 - nt=40 - ntheta=12 -elseif(ndeep.eq.2) then - nord=1 - npre1=1 - npre2=0 - nt=40 - ntheta=12 -elseif(ndeep.eq.3) then - nord=1 - npre1=1 - npre2=1 - nt=40 - ntheta=12 - ntau=14 -elseif(ndeep.eq.4) then - nord=2 - npre1=1 - npre2=0 - nt=40 - ntheta=12 - ntau=19 -elseif(ndeep.eq.5) then - nord=2 - npre1=1 - npre2=1 - nt=40 - ntheta=12 - ntau=19 -endif - -do iorder=1,nord - misub(1:K-iorder)=0 - misub(K-iorder+1:K)=1 - iflag=K-iorder+1 - do while(iflag .ge.0) - if(iorder.eq.nord .and. npre1.eq.0) then - iend=iflag - else - iend=1 - endif - do n1=iflag,iend,-1 - mi=misub - mi(n1)=1 - if(any(iand(apmaskr(1:K),mi).eq.1)) cycle - ntotal=ntotal+1 - me=ieor(m0,mi) - if(n1.eq.iflag) then - call mrbencode(me,ce,g2,N,K) - e2sub=ieor(ce(K+1:N),hdec(K+1:N)) - e2=e2sub - nd1Kpt=sum(e2sub(1:nt))+1 - d1=sum(ieor(me(1:K),hdec(1:K))*absrx(1:K)) - else - e2=ieor(e2sub,g2(K+1:N,n1)) - nd1Kpt=sum(e2(1:nt))+2 - endif - if(nd1Kpt .le. ntheta) then - call mrbencode(me,ce,g2,N,K) - nxor=ieor(ce,hdec) - if(n1.eq.iflag) then - dd=d1+sum(e2sub*absrx(K+1:N)) - else - dd=d1+ieor(ce(n1),hdec(n1))*absrx(n1)+sum(e2*absrx(K+1:N)) - endif - if( dd .lt. dmin ) then - dmin=dd - cw=ce - nhardmin=sum(nxor) - nd1Kptbest=nd1Kpt - endif - else - nrejected=nrejected+1 - endif - enddo -! Get the next test error pattern, iflag will go negative -! when the last pattern with weight iorder has been generated. - call nextpat(misub,k,iorder,iflag) - enddo -enddo - -if(npre2.eq.1) then - reset=.true. - ntotal=0 - do i1=K,1,-1 - do i2=i1-1,1,-1 - ntotal=ntotal+1 - mi(1:ntau)=ieor(g2(K+1:K+ntau,i1),g2(K+1:K+ntau,i2)) - call boxit(reset,mi(1:ntau),ntau,ntotal,i1,i2) - enddo - enddo - - ncount2=0 - ntotal2=0 - reset=.true. -! Now run through again and do the second pre-processing rule - misub(1:K-nord)=0 - misub(K-nord+1:K)=1 - iflag=K-nord+1 - do while(iflag .ge.0) - me=ieor(m0,misub) - call mrbencode(me,ce,g2,N,K) - e2sub=ieor(ce(K+1:N),hdec(K+1:N)) - do i2=0,ntau - ntotal2=ntotal2+1 - ui=0 - if(i2.gt.0) ui(i2)=1 - r2pat=ieor(e2sub,ui) -778 continue - call fetchit(reset,r2pat(1:ntau),ntau,in1,in2) - if(in1.gt.0.and.in2.gt.0) then - ncount2=ncount2+1 - mi=misub - mi(in1)=1 - mi(in2)=1 - if(sum(mi).lt.nord+npre1+npre2.or.any(iand(apmaskr(1:K),mi).eq.1)) cycle - me=ieor(m0,mi) - call mrbencode(me,ce,g2,N,K) - nxor=ieor(ce,hdec) - dd=sum(nxor*absrx) - if( dd .lt. dmin ) then - dmin=dd - cw=ce - nhardmin=sum(nxor) - endif - goto 778 - endif - enddo - call nextpat(misub,K,nord,iflag) - enddo -endif - -998 continue -! Re-order the codeword to place message bits at the end. -cw(indices)=cw -hdec(indices)=hdec -decoded=cw(M+1:N) -cw(colorder+1)=cw ! put the codeword back into received-word order -return -end subroutine osd174 - -subroutine mrbencode(me,codeword,g2,N,K) -integer*1 me(K),codeword(N),g2(N,K) -! fast encoding for low-weight test patterns - codeword=0 - do i=1,K - if( me(i) .eq. 1 ) then - codeword=ieor(codeword,g2(1:N,i)) - endif - enddo -return -end subroutine mrbencode - -subroutine nextpat(mi,k,iorder,iflag) - integer*1 mi(k),ms(k) -! generate the next test error pattern - ind=-1 - do i=1,k-1 - if( mi(i).eq.0 .and. mi(i+1).eq.1) ind=i - enddo - if( ind .lt. 0 ) then ! no more patterns of this order - iflag=ind - return - endif - ms=0 - ms(1:ind-1)=mi(1:ind-1) - ms(ind)=1 - ms(ind+1)=0 - if( ind+1 .lt. k ) then - nz=iorder-sum(ms) - ms(k-nz+1:k)=1 - endif - mi=ms - do i=1,k ! iflag will point to the lowest-index 1 in mi - if(mi(i).eq.1) then - iflag=i - exit - endif - enddo - return -end subroutine nextpat - -subroutine boxit(reset,e2,ntau,npindex,i1,i2) - integer*1 e2(1:ntau) - integer indexes(4000,2),fp(0:525000),np(4000) - logical reset - common/boxes/indexes,fp,np - - if(reset) then - patterns=-1 - fp=-1 - np=-1 - sc=-1 - indexes=-1 - reset=.false. - endif - - indexes(npindex,1)=i1 - indexes(npindex,2)=i2 - ipat=0 - do i=1,ntau - if(e2(i).eq.1) then - ipat=ipat+ishft(1,ntau-i) - endif - enddo - - ip=fp(ipat) ! see what's currently stored in fp(ipat) - if(ip.eq.-1) then - fp(ipat)=npindex - else - do while (np(ip).ne.-1) - ip=np(ip) - enddo - np(ip)=npindex - endif - return -end subroutine boxit - -subroutine fetchit(reset,e2,ntau,i1,i2) - integer indexes(4000,2),fp(0:525000),np(4000) - integer lastpat - integer*1 e2(ntau) - logical reset - common/boxes/indexes,fp,np - save lastpat,inext - - if(reset) then - lastpat=-1 - reset=.false. - endif - - ipat=0 - do i=1,ntau - if(e2(i).eq.1) then - ipat=ipat+ishft(1,ntau-i) - endif - enddo - index=fp(ipat) - - if(lastpat.ne.ipat .and. index.gt.0) then ! return first set of indices - i1=indexes(index,1) - i2=indexes(index,2) - inext=np(index) - elseif(lastpat.eq.ipat .and. inext.gt.0) then - i1=indexes(inext,1) - i2=indexes(inext,2) - inext=np(inext) - else - i1=-1 - i2=-1 - inext=-1 - endif - lastpat=ipat - return -end subroutine fetchit - diff --git a/lib/fsk4hf/osd204.f90 b/lib/ft8/osd174_91.f90 index acebbf64..958b0c9f 100644 --- a/lib/fsk4hf/osd204.f90 +++ b/lib/ft8/osd174_91.f90 @@ -1,9 +1,8 @@ -subroutine osd204(llr,apmask,ndeep,decoded,cw,nhardmin,dmin) +subroutine osd174_91(llr,apmask,ndeep,message77,cw,nhardmin,dmin) ! -! An ordered-statistics decoder for the (204,68) code. +! An ordered-statistics decoder for the (174,91) code. ! -include "ldpc_204_68_params.f90" - +integer, parameter:: N=174, K=91, M=N-K integer*1 apmask(N),apmaskr(N) integer*1 gen(K,N) integer*1 genmrb(K,N),g2(N,K) @@ -12,8 +11,12 @@ integer*1 r2pat(N-K) integer indices(N),nxor(N) integer*1 cw(N),ce(N),c0(N),hdec(N) integer*1 decoded(K) +integer*1 message77(77) integer indx(N) real llr(N),rx(N),absrx(N) + +include "ldpc_174_91_c_generator.f90" + logical first,reset data first/.true./ save first,gen @@ -21,23 +24,24 @@ save first,gen if( first ) then ! fill the generator matrix gen=0 do i=1,M - do j=1,17 + do j=1,23 read(g(i)(j:j),"(Z1)") istr - do jj=1, 4 - irow=(j-1)*4+jj - if( btest(istr,4-jj) ) gen(irow,i)=1 - enddo + ibmax=4 + if(j.eq.23) ibmax=3 + do jj=1, ibmax + irow=(j-1)*4+jj + if( btest(istr,4-jj) ) gen(irow,K+i)=1 + enddo enddo enddo do irow=1,K - gen(irow,M+irow)=1 + gen(irow,irow)=1 enddo first=.false. endif -! Re-order received vector to place systematic msg bits at the end. -rx=llr(colorder+1) -apmaskr=apmask(colorder+1) +rx=llr +apmaskr=apmask ! Hard decisions on the received word. hdec=0 @@ -92,7 +96,7 @@ absrx=absrx(indices) rx=rx(indices) apmaskr=apmaskr(indices) -call mrbencode(m0,c0,g2,N,K) +call mrbencode91(m0,c0,g2,N,K) nxor=ieor(c0,hdec) nhardmin=sum(nxor) dmin=sum(nxor*absrx) @@ -155,7 +159,7 @@ do iorder=1,nord ntotal=ntotal+1 me=ieor(m0,mi) if(n1.eq.iflag) then - call mrbencode(me,ce,g2,N,K) + call mrbencode91(me,ce,g2,N,K) e2sub=ieor(ce(K+1:N),hdec(K+1:N)) e2=e2sub nd1Kpt=sum(e2sub(1:nt))+1 @@ -165,7 +169,7 @@ do iorder=1,nord nd1Kpt=sum(e2(1:nt))+2 endif if(nd1Kpt .le. ntheta) then - call mrbencode(me,ce,g2,N,K) + call mrbencode91(me,ce,g2,N,K) nxor=ieor(ce,hdec) if(n1.eq.iflag) then dd=d1+sum(e2sub*absrx(K+1:N)) @@ -184,7 +188,7 @@ do iorder=1,nord enddo ! Get the next test error pattern, iflag will go negative ! when the last pattern with weight iorder has been generated. - call nextpat(misub,k,iorder,iflag) + call nextpat91(misub,k,iorder,iflag) enddo enddo @@ -195,7 +199,7 @@ if(npre2.eq.1) then do i2=i1-1,1,-1 ntotal=ntotal+1 mi(1:ntau)=ieor(g2(K+1:K+ntau,i1),g2(K+1:K+ntau,i2)) - call boxit(reset,mi(1:ntau),ntau,ntotal,i1,i2) + call boxit91(reset,mi(1:ntau),ntau,ntotal,i1,i2) enddo enddo @@ -208,7 +212,7 @@ if(npre2.eq.1) then iflag=K-nord+1 do while(iflag .ge.0) me=ieor(m0,misub) - call mrbencode(me,ce,g2,N,K) + call mrbencode91(me,ce,g2,N,K) e2sub=ieor(ce(K+1:N),hdec(K+1:N)) do i2=0,ntau ntotal2=ntotal2+1 @@ -216,7 +220,7 @@ if(npre2.eq.1) then if(i2.gt.0) ui(i2)=1 r2pat=ieor(e2sub,ui) 778 continue - call fetchit(reset,r2pat(1:ntau),ntau,in1,in2) + call fetchit91(reset,r2pat(1:ntau),ntau,in1,in2) if(in1.gt.0.and.in2.gt.0) then ncount2=ncount2+1 mi=misub @@ -224,7 +228,7 @@ if(npre2.eq.1) then mi(in2)=1 if(sum(mi).lt.nord+npre1+npre2.or.any(iand(apmaskr(1:K),mi).eq.1)) cycle me=ieor(m0,mi) - call mrbencode(me,ce,g2,N,K) + call mrbencode91(me,ce,g2,N,K) nxor=ieor(ce,hdec) dd=sum(nxor*absrx) if( dd .lt. dmin ) then @@ -235,20 +239,23 @@ if(npre2.eq.1) then goto 778 endif enddo - call nextpat(misub,K,nord,iflag) + call nextpat91(misub,K,nord,iflag) enddo endif 998 continue -! Re-order the codeword to place message bits at the end. +! Re-order the codeword to [message bits][parity bits] format. cw(indices)=cw hdec(indices)=hdec -decoded=cw(M+1:N) -cw(colorder+1)=cw ! put the codeword back into received-word order +decoded=cw(1:K) +call chkcrc14a(decoded,nbadcrc) +message77=decoded(1:77) +if(nbadcrc.eq.1) nhardmin=-nhardmin + return -end subroutine osd204 +end subroutine osd174_91 -subroutine mrbencode(me,codeword,g2,N,K) +subroutine mrbencode91(me,codeword,g2,N,K) integer*1 me(K),codeword(N),g2(N,K) ! fast encoding for low-weight test patterns codeword=0 @@ -258,9 +265,9 @@ integer*1 me(K),codeword(N),g2(N,K) endif enddo return -end subroutine mrbencode +end subroutine mrbencode91 -subroutine nextpat(mi,k,iorder,iflag) +subroutine nextpat91(mi,k,iorder,iflag) integer*1 mi(k),ms(k) ! generate the next test error pattern ind=-1 @@ -287,11 +294,11 @@ subroutine nextpat(mi,k,iorder,iflag) endif enddo return -end subroutine nextpat +end subroutine nextpat91 -subroutine boxit(reset,e2,ntau,npindex,i1,i2) +subroutine boxit91(reset,e2,ntau,npindex,i1,i2) integer*1 e2(1:ntau) - integer indexes(4000,2),fp(0:525000),np(4000) + integer indexes(5000,2),fp(0:525000),np(5000) logical reset common/boxes/indexes,fp,np @@ -323,10 +330,10 @@ subroutine boxit(reset,e2,ntau,npindex,i1,i2) np(ip)=npindex endif return -end subroutine boxit +end subroutine boxit91 -subroutine fetchit(reset,e2,ntau,i1,i2) - integer indexes(4000,2),fp(0:525000),np(4000) +subroutine fetchit91(reset,e2,ntau,i1,i2) + integer indexes(5000,2),fp(0:525000),np(5000) integer lastpat integer*1 e2(ntau) logical reset @@ -361,5 +368,5 @@ subroutine fetchit(reset,e2,ntau,i1,i2) endif lastpat=ipat return -end subroutine fetchit +end subroutine fetchit91 diff --git a/lib/ft8/sync8.f90 b/lib/ft8/sync8.f90 index 30f6de17..3924f1ba 100644 --- a/lib/ft8/sync8.f90 +++ b/lib/ft8/sync8.f90 @@ -1,4 +1,5 @@ -subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase)
+subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, &
+ ncand,sbase)
include 'ft8_params.f90'
! Search over +/- 2.5s relative to 0.5s TX start time.
@@ -10,14 +11,14 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) real x(NFFT1)
real sync2d(NH1,-JZ:JZ)
real red(NH1)
- real candidate0(3,200)
- real candidate(3,200)
+ real candidate0(3,maxcand)
+ real candidate(3,maxcand)
real dd(NMAX)
integer jpeak(NH1)
integer indx(NH1)
integer ii(1)
integer icos7(0:6)
- data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
+ data icos7/3,1,4,0,6,5,2/ !Costas 7x7 tone pattern
equivalence (x,cx)
! Compute symbol spectra, stepping by NSTEP steps.
@@ -37,17 +38,14 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) savg=savg + s(1:NH1,j) !Average spectrum
enddo
call baseline(savg,nfa,nfb,sbase)
-! savg=savg/NHSYM
-! do i=1,NH1
-! write(51,3051) i*df,savg(i),db(savg(i))
-!3051 format(f10.3,e12.3,f12.3)
-! enddo
ia=max(1,nint(nfa/df))
ib=nint(nfb/df)
nssy=NSPS/NSTEP ! # steps per symbol
nfos=NFFT1/NSPS ! # frequency bin oversampling factor
jstrt=0.5/tstep
+ candidate0=0.
+ k=0
do i=ia,ib
do j=-JZ,+JZ
@@ -58,23 +56,22 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) t0b=0.
t0c=0.
do n=0,6
- k=j+jstrt+nssy*n
- if(k.ge.1.and.k.le.NHSYM) then
- ta=ta + s(i+nfos*icos7(n),k)
- t0a=t0a + sum(s(i:i+nfos*6:nfos,k))
+ m=j+jstrt+nssy*n
+ if(m.ge.1.and.m.le.NHSYM) then
+ ta=ta + s(i+nfos*icos7(n),m)
+ t0a=t0a + sum(s(i:i+nfos*6:nfos,m))
endif
- tb=tb + s(i+nfos*icos7(n),k+nssy*36)
- t0b=t0b + sum(s(i:i+nfos*6:nfos,k+nssy*36))
- if(k+nssy*72.le.NHSYM) then
- tc=tc + s(i+nfos*icos7(n),k+nssy*72)
- t0c=t0c + sum(s(i:i+nfos*6:nfos,k+nssy*72))
+ tb=tb + s(i+nfos*icos7(n),m+nssy*36)
+ t0b=t0b + sum(s(i:i+nfos*6:nfos,m+nssy*36))
+ if(m+nssy*72.le.NHSYM) then
+ tc=tc + s(i+nfos*icos7(n),m+nssy*72)
+ t0c=t0c + sum(s(i:i+nfos*6:nfos,m+nssy*72))
endif
enddo
t=ta+tb+tc
t0=t0a+t0b+t0c
t0=(t0-t)/6.0
sync_abc=t/t0
-
t=tb+tc
t0=t0b+t0c
t0=(t0-t)/6.0
@@ -89,21 +86,19 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) j0=ii(1)
jpeak(i)=j0
red(i)=sync2d(i,j0)
-! write(52,3052) i*df,red(i),db(red(i))
-!3052 format(3f12.3)
enddo
iz=ib-ia+1
call indexx(red(ia:ib),iz,indx)
ibase=indx(nint(0.40*iz)) - 1 + ia
+ if(ibase.lt.1) ibase=1
+ if(ibase.gt.nh1) ibase=nh1
base=red(ibase)
red=red/base
- candidate0=0.
- k=0
- do i=1,200
+ do i=1,min(maxcand,iz)
n=ia + indx(iz+1-i) - 1
- if(red(n).lt.syncmin) exit
- if(k.lt.200) k=k+1
+ if(red(n).lt.syncmin.or.isnan(red(n)).or.k.eq.maxcand) exit
+ k=k+1
candidate0(1,k)=n*df
candidate0(2,k)=(jpeak(n)-1)*tstep
candidate0(3,k)=red(n)
@@ -121,9 +116,6 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) if(candidate0(3,i).lt.candidate0(3,j)) candidate0(3,i)=0.
endif
enddo
-! write(*,3001) i,candidate0(1,i-1),candidate0(1,i),candidate0(3,i-1), &
-! candidate0(3,i)
-!3001 format(i2,4f8.1)
endif
enddo
@@ -140,9 +132,8 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) j=indx(i)
! if( candidate0(3,j) .ge. syncmin .and. candidate0(2,j).ge.-1.5 ) then
if( candidate0(3,j) .ge. syncmin ) then
+ candidate(2:3,k)=candidate0(2:3,j)
candidate(1,k)=abs(candidate0(1,j))
- candidate(2,k)=candidate0(2,j)
- candidate(3,k)=candidate0(3,j)
k=k+1
endif
enddo
diff --git a/lib/ft8/sync8d.f90 b/lib/ft8/sync8d.f90 index d0d1c63b..798f2831 100644 --- a/lib/ft8/sync8d.f90 +++ b/lib/ft8/sync8d.f90 @@ -3,14 +3,14 @@ subroutine sync8d(cd0,i0,ctwk,itwk,sync) ! Compute sync power for a complex, downsampled FT8 signal.
parameter(NP2=2812,NDOWN=60)
- complex cd0(3125)
+ complex cd0(0:3199)
complex csync(0:6,32)
complex csync2(32)
complex ctwk(32)
complex z1,z2,z3
logical first
integer icos7(0:6)
- data icos7/2,5,6,0,4,1,3/
+ data icos7/3,1,4,0,6,5,2/
data first/.true./
save first,twopi,fs2,dt2,taus,baud,csync
@@ -44,9 +44,9 @@ subroutine sync8d(cd0,i0,ctwk,itwk,sync) z1=0.
z2=0.
z3=0.
- if(i1.ge.1 .and. i1+31.le.NP2) z1=sum(cd0(i1:i1+31)*conjg(csync2))
- if(i2.ge.1 .and. i2+31.le.NP2) z2=sum(cd0(i2:i2+31)*conjg(csync2))
- if(i3.ge.1 .and. i3+31.le.NP2) z3=sum(cd0(i3:i3+31)*conjg(csync2))
+ if(i1.ge.0 .and. i1+31.le.NP2-1) z1=sum(cd0(i1:i1+31)*conjg(csync2))
+ if(i2.ge.0 .and. i2+31.le.NP2-1) z2=sum(cd0(i2:i2+31)*conjg(csync2))
+ if(i3.ge.0 .and. i3+31.le.NP2-1) z3=sum(cd0(i3:i3+31)*conjg(csync2))
sync = sync + p(z1) + p(z2) + p(z3)
enddo
diff --git a/lib/ft8/watterson.f90 b/lib/ft8/watterson.f90 index d047a26e..a1131d7b 100644 --- a/lib/ft8/watterson.f90 +++ b/lib/ft8/watterson.f90 @@ -1,5 +1,8 @@ -subroutine watterson(c,npts,fs,delay,fspread)
-
+subroutine watterson(c,npts,nsig,fs,delay,fspread)
+!
+! npts is the total length of the simulated data vector
+! nsig is the number of points that are occupied by signal
+!
complex c(0:npts-1)
complex c2(0:npts-1)
complex cs1(0:npts-1)
@@ -55,7 +58,7 @@ subroutine watterson(c,npts,fs,delay,fspread) ! write(61,3001) i/12000.0,c(i)
!3001 format(3f12.6)
enddo
- rms=sqrt(sq/npts)
+ rms=sqrt(sq/nsig)
c=c/rms
return
diff --git a/lib/ft8_decode.f90 b/lib/ft8_decode.f90 index 3f6291fd..e29fa921 100644 --- a/lib/ft8_decode.f90 +++ b/lib/ft8_decode.f90 @@ -33,8 +33,8 @@ module ft8_decode contains subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, & - nutc,nfa,nfb,nexp_decode,ndepth,nagain,lft8apon,lapcqonly,napwid, & - mycall12,mygrid6,hiscall12,hisgrid6) + nutc,nfa,nfb,ndepth,ncontest,nagain,lft8apon,lapcqonly, & + napwid,mycall12,hiscall12,hisgrid6) ! use wavhdr use timer_module, only: timer include 'ft8/ft8_params.f90' @@ -42,30 +42,37 @@ contains class(ft8_decoder), intent(inout) :: this procedure(ft8_decode_callback) :: callback + parameter (MAXCAND=300) real s(NH1,NHSYM) real sbase(NH1) - real candidate(3,200) + real candidate(3,MAXCAND) real dd(15*12000) logical, intent(in) :: lft8apon,lapcqonly,nagain - logical newdat,lsubtract,ldupe,bcontest - character*12 mycall12, hiscall12 - character*6 mygrid6,hisgrid6 + logical newdat,lsubtract,ldupe + character*12 mycall12,hiscall12,mycall12_0 + character*6 hisgrid6 integer*2 iwave(15*12000) - integer apsym(KK) - character datetime*13,message*22,msg37*37 - character*22 allmessages(100) + integer apsym2(58) + character datetime*13,msg37*37 +! character message*22 + character*37 allmessages(100) integer allsnrs(100) - save s,dd + data mycall12_0/'dummy'/ + save s,dd,mycall12_0 + + if(mycall12.ne.mycall12_0) then + call my_hash(mycall12) + mycall12_0=mycall12 + endif - bcontest=iand(nexp_decode,128).ne.0 this%callback => callback write(datetime,1001) nutc !### TEMPORARY ### 1001 format("000000_",i6.6) - call ft8apset(mycall12,mygrid6,hiscall12,hisgrid6,bcontest,apsym,iaptype) + call ft8apset(mycall12,hiscall12,apsym2) dd=iwave ndecodes=0 - allmessages=' ' + allmessages=' ' allsnrs=0 ifa=nfa ifb=nfb @@ -94,9 +101,10 @@ contains if((ndecodes-n2).eq.0) cycle lsubtract=.false. endif - call timer('sync8 ',0) - call sync8(dd,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase) + maxc=MAXCAND + call sync8(dd,ifa,ifb,syncmin,nfqso,maxc,s,candidate, & + ncand,sbase) call timer('sync8 ',1) do icand=1,ncand sync=candidate(3,icand) @@ -105,35 +113,28 @@ contains xbase=10.0**(0.1*(sbase(nint(f1/3.125))-40.0)) nsnr0=min(99,nint(10.0*log10(sync) - 25.5)) !### empirical ### call timer('ft8b ',0) - call ft8b(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, & - lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12,mygrid6, & - hiscall12,bcontest,sync,f1,xdt,xbase,apsym,nharderrors,dmin, & + call ft8b(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, & + lapcqonly,napwid,lsubtract,nagain,ncontest,iaptype,mycall12, & + hiscall12,sync,f1,xdt,xbase,apsym2,nharderrors,dmin, & nbadcrc,iappass,iera,msg37,xsnr) - message=msg37(1:22) !### + call timer('ft8b ',1) nsnr=nint(xsnr) xdt=xdt-0.5 hd=nharderrors+dmin - call timer('ft8b ',1) if(nbadcrc.eq.0) then -! call jtmsg(message,iflag) - if(bcontest) then - call fix_contest_msg(mygrid6,message) - msg37(1:22)=message - endif -! if(iand(iflag,31).ne.0) message(22:22)='?' ldupe=.false. do id=1,ndecodes - if(message.eq.allmessages(id).and.nsnr.le.allsnrs(id)) ldupe=.true. + if(msg37.eq.allmessages(id).and.nsnr.le.allsnrs(id)) ldupe=.true. enddo if(.not.ldupe) then ndecodes=ndecodes+1 - allmessages(ndecodes)=message + allmessages(ndecodes)=msg37 allsnrs(ndecodes)=nsnr endif ! write(81,1004) nutc,ncand,icand,ipass,iaptype,iappass, & ! nharderrors,dmin,hd,min(sync,999.0),nint(xsnr), & -! xdt,nint(f1),message -!1004 format(i6.6,2i4,3i2,i3,3f6.1,i4,f6.2,i5,2x,a22) +! xdt,nint(f1),msg37 +!1004 format(i6.6,2i4,3i2,i3,3f6.1,i4,f6.2,i5,2x,a37) ! flush(81) if(.not.ldupe .and. associated(this%callback)) then qual=1.0-(nharderrors+dmin)/60.0 ! scale qual to [0.0,1.0] diff --git a/lib/gen4.f90 b/lib/gen4.f90 index 7b06be8c..b94789d2 100644 --- a/lib/gen4.f90 +++ b/lib/gen4.f90 @@ -26,8 +26,8 @@ subroutine gen4(msg0,ichk,msgsent,itone,itype) message=msg0 call fmtmsg(message,iz) - call packmsg(message,i4Msg6BitWords,itype,.false.) !Pack into 12 6-bit bytes - call unpackmsg(i4Msg6BitWords,msgsent,.false.,' ') !Unpack to get msgsent + call packmsg(message,i4Msg6BitWords,itype) !Pack into 12 6-bit bytes + call unpackmsg(i4Msg6BitWords,msgsent) !Unpack to get msgsent if(ichk.ne.0) go to 999 call encode4(message,itone) !Encode the information bits i1=index(message,'-') diff --git a/lib/gen65.f90 b/lib/gen65.f90 index ab61fd33..af036c2a 100644 --- a/lib/gen65.f90 +++ b/lib/gen65.f90 @@ -44,8 +44,8 @@ subroutine gen65(msg0,ichk,msgsent,itone,itype) ntest=0
if(flip.lt.0.0) ntest=1
if(nspecial.eq.0) then
- call packmsg(message,dgen,itype,.false.) !Pack message into 72 bits
- call unpackmsg(dgen,msgsent,.false.,' ') !Unpack to get message sent
+ call packmsg(message,dgen,itype) !Pack message into 72 bits
+ call unpackmsg(dgen,msgsent) !Unpack to get message sent
msgsent(20:22)=cok
call fmtmsg(msgsent,iz)
if(ichk.ne.0) go to 999 !Return if checking only
diff --git a/lib/gen9.f90 b/lib/gen9.f90 index 503ef6d3..80d5c12e 100644 --- a/lib/gen9.f90 +++ b/lib/gen9.f90 @@ -37,8 +37,8 @@ subroutine gen9(msg0,ichk,msgsent,i4tone,itype) message=message(i+1:)
enddo
- call packmsg(message,i4Msg6BitWords,itype,.false.) !Pack into 12 6-bit bytes
- call unpackmsg(i4Msg6BitWords,msgsent,.false.,' ') !Unpack to get msgsent
+ call packmsg(message,i4Msg6BitWords,itype) !Pack into 12 6-bit bytes
+ call unpackmsg(i4Msg6BitWords,msgsent) !Unpack to get msgsent
if(ichk.ne.0) go to 999
call entail(i4Msg6BitWords,i1Msg8BitBytes) !Add tail, make 8-bit bytes
nsym2=206
diff --git a/lib/genmsk40.f90 b/lib/genmsk40.f90 index 3310b106..4177cbc2 100644 --- a/lib/genmsk40.f90 +++ b/lib/genmsk40.f90 @@ -1,7 +1,7 @@ subroutine genmsk40(msg,msgsent,ichk,itone,itype)
use hashing
- character*22 msg,msgsent,hashmsg
+ character*37 msg,msgsent,hashmsg
character*4 crpt,rpt(0:15)
logical first
integer*4 itone(144)
@@ -29,7 +29,7 @@ subroutine genmsk40(msg,msgsent,ichk,itone,itype) 10 irpt=i !Report index, 0-15
if(ichk.lt.10000) then
hashmsg=msg(2:i1-1)
- call hash(hashmsg,22,ihash)
+ call hash(hashmsg,37,ihash)
ihash=iand(ihash,4095) !12-bit hash
ig=16*ihash + irpt !4-bit report
else
diff --git a/lib/genmsk144.f90 b/lib/genmsk_128_90.f90 index 5f9ce935..bfd175db 100644 --- a/lib/genmsk144.f90 +++ b/lib/genmsk_128_90.f90 @@ -1,4 +1,4 @@ -subroutine genmsk144(msg0,mygrid,ichk,bcontest,msgsent,i4tone,itype) +subroutine genmsk_128_90(msg0,ichk,msgsent,i4tone,itype) ! s8 + 48bits + s8 + 80 bits = 144 bits (72ms message duration) ! ! Encode an MSK144 message @@ -18,26 +18,21 @@ subroutine genmsk144(msg0,mygrid,ichk,bcontest,msgsent,i4tone,itype) ! 7 = short message "<Call_1 Call2> Rpt" use iso_c_binding, only: c_loc,c_size_t - use packjt - use hashing - character*22 msg0 - character*22 message !Message to be generated - character*22 msgsent !Message as it will be received - character*6 mygrid - integer*4 i4Msg6BitWords(13) !72-bit message as 6-bit words - integer*4 i4tone(144) ! - integer*1, target:: i1Msg8BitBytes(10) !80 bits represented in 10 bytes - integer*1 codeword(128) !Encoded bits before re-ordering - integer*1 msgbits(80) !72-bit message + 8-bit hash + use packjt77 + character*37 msg0 + character*37 message !Message to be generated + character*37 msgsent !Message as it will be received + character*77 c77 + integer*4 i4tone(144) + integer*1 codeword(128) + integer*1 msgbits(77) integer*1 bitseq(144) !Tone #s, data and sync (values 0-1) - integer*1 i1hash(4) integer*1 s8(8) - logical bcontest real*8 pp(12) real*8 xi(864),xq(864),pi,twopi data s8/0,1,1,1,0,0,1,0/ equivalence (ihash,i1hash) - logical first + logical first,unpk77_success data first/.true./ save @@ -51,6 +46,8 @@ subroutine genmsk144(msg0,mygrid,ichk,bcontest,msgsent,i4tone,itype) enddo endif + message(1:37)=' ' + itype=1 if(msg0(1:1).eq.'@') then !Generate a fixed tone read(msg0(2:5),*,end=1,err=1) nfreq !at specified frequency go to 2 @@ -58,60 +55,37 @@ subroutine genmsk144(msg0,mygrid,ichk,bcontest,msgsent,i4tone,itype) 2 i4tone(1)=nfreq else message=msg0 - do i=1,22 + + do i=1, 37 if(ichar(message(i:i)).eq.0) then - message(i:)=' ' + message(i:37)=' ' exit endif enddo - - do i=1,22 !Strip leading blanks + do i=1,37 !Strip leading blanks if(message(1:1).ne.' ') exit message=message(i+1:) enddo if(message(1:1).eq.'<') then - call genmsk40(message,msgsent,ichk,i4tone,itype) - if(itype.lt.0) go to 999 - i4tone(41)=-40 - go to 999 + i2=index(message,'>') + i1=0 + if(i2.gt.0) i1=index(message(1:i2),' ') + if(i1.gt.0) then + call genmsk40(message,msgsent,ichk,i4tone,itype) + if(itype.lt.0) go to 999 + i4tone(41)=-40 + go to 999 + endif endif - call packmsg(message,i4Msg6BitWords,itype,bcontest) !Pack into 12 6-bit bytes - call unpackmsg(i4Msg6BitWords,msgsent,bcontest,mygrid) !Unpack to get msgsent - + i3=-1 + n3=-1 + call pack77(message,i3,n3,c77) + call unpack77(c77,msgsent,unpk77_success) !Unpack to get msgsent if(ichk.eq.1) go to 999 - i4=0 - ik=0 - im=0 - do i=1,12 - nn=i4Msg6BitWords(i) - do j=1, 6 - ik=ik+1 - i4=i4+i4+iand(1,ishft(nn,j-6)) - i4=iand(i4,255) - if(ik.eq.8) then - im=im+1 - i1Msg8BitBytes(im)=i4 - ik=0 - endif - enddo - enddo - - ihash=nhash(c_loc(i1Msg8BitBytes),int(9,c_size_t),146) - ihash=2*iand(ihash,32767) !Generate the 8-bit hash - i1Msg8BitBytes(10)=i1hash(1) !Hash code to byte 10 - - mbit=0 - do i=1, 10 - i1=i1Msg8BitBytes(i) - do ibit=1,8 - mbit=mbit+1 - msgbits(mbit)=iand(1,ishft(i1,ibit-8)) - enddo - enddo - - call encode_msk144(msgbits,codeword) + read(c77,"(77i1)") msgbits + call encode_128_90(msgbits,codeword) !Create 144-bit channel vector: !8-bit sync word + 48 bits + 8-bit sync word + 80 bits @@ -142,6 +116,5 @@ subroutine genmsk144(msg0,mygrid,ichk,bcontest,msgsent,i4tone,itype) ! Flip polarity i4tone=-i4tone+1 - 999 return -end subroutine genmsk144 +end subroutine genmsk_128_90 diff --git a/lib/genmsk_short.f90 b/lib/genmsk_short.f90 deleted file mode 100644 index f1b555f3..00000000 --- a/lib/genmsk_short.f90 +++ /dev/null @@ -1,66 +0,0 @@ -subroutine genmsk_short(msg,msgsent,ichk,itone,itype)
-
- use hashing
- character*22 msg,msgsent
- character*3 crpt,rpt(0:7)
- logical first
- integer itone(35)
- integer ig24(0:4096-1) !Codewords for Golay (24,12) code
- integer b11(11)
- data b11/1,1,1,0,0,0,1,0,0,1,0/ !Barker 11 code
- data rpt /'26 ','27 ','28 ','R26','R27','R28','RRR','73 '/
- data first/.true./
- save first,ig24
-
- if(first) then
- call golay24_table(ig24) !Define the Golay(24,12) codewords
- first=.false.
- endif
-
- itype=-1
- msgsent='*** bad message ***'
- itone=0
- i1=index(msg,'>')
- if(i1.lt.9) go to 900
- call fmtmsg(msg,iz)
- crpt=msg(i1+2:i1+5)
- do i=0,7
- if(crpt.eq.rpt(i)) go to 10
- enddo
- go to 900
-
-10 irpt=i !Report index, 0-7
- if(ichk.lt.10000) then
- call hash(msg(2:i1-1),i1-2,ihash)
- ihash=iand(ihash,511) !9-bit hash for the two callsigns
- ig=8*ihash + irpt !12-bit message information
- else
- ig=ichk-10000
- endif
- ncodeword=ig24(ig)
- itone(1:11)=b11 !Insert the Barker-11 code
- n=2**24
- do i=12,35 !Insert codeword into itone array
- n=n/2
- itone(i)=0
- if(iand(ncodeword,n).ne.0) itone(i)=1
- enddo
- msgsent=msg
- itype=7
-
- n=count(itone(1:35).eq.0)
- if(mod(n,2).ne.0) stop 'Parity error in genmsk_short.'
-
-900 return
-end subroutine genmsk_short
-
-subroutine hash_calls(calls,ih9)
-
- use hashing
- character*(*) calls
- i1=index(calls,'>')
- call hash(calls(2:i1-1),i1-2,ih9)
- ih9=iand(ih9,511) !9-bit hash for the two callsigns
-
- return
-end subroutine hash_calls
diff --git a/lib/genqra64.f90 b/lib/genqra64.f90 index 819f13cc..4931342e 100644 --- a/lib/genqra64.f90 +++ b/lib/genqra64.f90 @@ -37,8 +37,8 @@ subroutine genqra64(msg0,ichk,msgsent,itone,itype) enddo call chkmsg(message,cok,nspecial,flip) - call packmsg(message,dgen,itype,.false.) !Pack message into 72 bits - call unpackmsg(dgen,msgsent,.false.,' ') !Unpack to get message sent + call packmsg(message,dgen,itype) !Pack message into 72 bits + call unpackmsg(dgen,msgsent) !Unpack to get message sent if(ichk.ne.0) go to 999 !Return if checking only call qra64_enc(dgen,sent) !Encode using QRA64 diff --git a/lib/hint65.f90 b/lib/hint65.f90 index 3d185330..ec414a23 100644 --- a/lib/hint65.f90 +++ b/lib/hint65.f90 @@ -88,7 +88,7 @@ subroutine hint65(s3,mrs,mrs2,nadd,nflip,mycall,hiscall,hisgrid,qual,decoded) if(m.eq.2) msg='CQ '//call2(i)//' '//grid2(i) endif call fmtmsg(msg,iz) - call packmsg(msg,dgen,itype,.false.) !Pack message into 72 bits + call packmsg(msg,dgen,itype) !Pack message into 72 bits call rs_encode(dgen,sym_rev) !RS encode sym(0:62)=sym_rev(62:0:-1) sym1(0:62,j)=sym diff --git a/lib/hspec.f90 b/lib/hspec.f90 index 4ede5060..da30e021 100644 --- a/lib/hspec.f90 +++ b/lib/hspec.f90 @@ -1,4 +1,4 @@ -subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144,bcontest, & +subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,ncontest,bmsk144, & btrain,pcoeffs,ingain,mycall,hiscall,bshmsg,bswl,datadir,green,s, & jh,pxmax,dbNoGain,line1,mygrid) @@ -8,6 +8,7 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144,bcontest, & ! ntrpdepth TR period and 1000*ndepth ! nrxfreq Rx audio center frequency ! ntol Decoding range is +/- ntol +! ncontest Contest type (0=NONE 1=NA_VHF 2=EU_VHF 3=FIELD_DAY 4=RTTY) ! bmsk144 Boolean, true if in MSK144 mode ! btrain Boolean, turns on training in MSK144 mode ! ingain Relative gain for spectra @@ -23,7 +24,7 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144,bcontest, & character*12 mycall,hiscall character*6 mygrid integer*2 id2(0:120*12000-1) - logical*1 bmsk144,bcontest,bshmsg,btrain,bswl + logical*1 bmsk144,bshmsg,btrain,bswl real green(0:JZ-1) real s(0:63,0:JZ-1) real x(512) @@ -96,7 +97,7 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144,bcontest, & tt2=sum(float(abs(id2(k0:k0+3583)))) if(tt1.ne.0.0 .and. tt2.ne.0) then call mskrtd(id2(k-7168+1:k),nutc0,tsec,ntol,nrxfreq,ndepth, & - mycall,mygrid,hiscall,bshmsg,bcontest,btrain,pcoeffs,bswl,& + mycall,mygrid,hiscall,bshmsg,btrain,pcoeffs,bswl, & datadir,line1) endif endif diff --git a/lib/jt49sim.f90 b/lib/jt49sim.f90 index e421f1d4..6d3ea51a 100644 --- a/lib/jt49sim.f90 +++ b/lib/jt49sim.f90 @@ -9,7 +9,7 @@ program jt49sim parameter (NFFT=10*65536,NH=NFFT/2)
type(hdr) h !Header for .wav file
integer*2 iwave(NMAX) !Generated waveform
- integer*4 itone(206) !Channel symbols (values 0-8)
+ integer*4 itone(206) !Channel symbols (values 0-8)
real*4 xnoise(NMAX) !Generated random noise
real*4 dat(NMAX) !Generated real data
complex cdat(NMAX) !Generated complex waveform
@@ -22,10 +22,12 @@ program jt49sim nargs=iargc()
if(nargs.ne. 7) then
print *, 'Usage: jt49sim "msg" nA-nE Nsigs fDop DT Nfiles SNR'
- print *, 'Example jt49sim "K1ABC W9XYZ EN37" 4G 10 0.2 0.0 1 0'
- print *, 'Example jt49sim "K1ABC W9XYZ EN37" 9A 1 0.0 0.0 1 -20'
+ print *, 'Example: jt49sim "K1ABC W9XYZ EN37" 4G 10 0.2 0.0 1 0'
+ print *, 'Example: jt49sim "K1ABC W9XYZ EN37" 9A 1 0.0 0.0 1 -20'
print *, 'Use msg=@nnnn to generate a tone at nnnn Hz:'
- print *, 'Example jt49sim "@1500" 9A 1 10.0 0.0 1 -20'
+ print *, 'Example: jt49sim "@1500" 9A 1 10.0 0.0 1 -20'
+ print *, 'If Nsigs > 100, generate one signal with f0=Nsigs'
+ print *, 'Example: jt49sim "K1ABC W9XYZ EN37" 4F 1800 0.2 0.0 1 -20'
go to 999
endif
call getarg(1,message)
@@ -84,6 +86,7 @@ program jt49sim if(mod(nsigs,2).eq.0) f0=1500.0 + dfsig*(isig-0.5-nsigs/2)
if(mod(nsigs,2).eq.1) f0=1500.0 + dfsig*(isig-(nsigs+1)/2)
if(nsigs.eq.1) f0=1000.0
+ if(nsigs.gt.100) f0=nsigs
xsnr=snrdb
if(snrdb.eq.0.0) xsnr=-20 - isig
@@ -121,6 +124,7 @@ program jt49sim k=k+1
if(k.ge.1) cdat(k)=cdat(k) + sig*z
enddo
+ if(nsigs.gt.100) exit
enddo
if(fspread.ne.0) then !Apply specified Doppler spread
diff --git a/lib/jt4_decode.f90 b/lib/jt4_decode.f90 index 3540b0c1..da0fbda6 100644 --- a/lib/jt4_decode.f90 +++ b/lib/jt4_decode.f90 @@ -111,12 +111,6 @@ contains character(len=12), intent(in) :: mycall,hiscall character(len=6), intent(in) :: hisgrid real, intent(in) :: dat(npts) !Raw data - - real ccfblue(-5:540) !CCF in time - real ccfred(-224:224) !CCF in frequency - real ps0(450) - -! real z(458,65) logical first,prtavg character decoded*22,special*5 character*22 avemsg,deepmsg,deepave,blank,deepmsg0,deepave1 @@ -128,8 +122,6 @@ contains nsave=0 first=.false. blank=' ' - ccfblue=0. - ccfred=0. ! Silence compiler warnings if(dttol.eq.-99.0 .and. emedelay.eq.-99.0 .and. nagain) stop endif @@ -157,15 +149,13 @@ contains ! Attempt to synchronize: look for sync pattern, get DF and DT. call timer('sync4 ',0) - mousedf=nint(nfqso + 1.5*4.375*mode4 - 1270.46) - call sync4(dat,npts,ntol,1,MouseDF,4,mode4,minw+1,dtx,dfx, & - snrx,snrsync,ccfblue,ccfred,flip,width,ps0) + call sync4(dat,npts,ntol,nfqso,4,mode4,minw+1,dtx,dfx, & + snrx,snrsync,flip,width) sync=snrsync dtxz=dtx-0.8 - nfreqz=dfx + 1270.46 - 1.5*4.375*mode4 + nfreqz=nint(dfx) call timer('sync4 ',1) - snrx=db(sync) - 26. nsnr=nint(snrx) if(sync.lt.syncmin) then if (associated (this%decode_callback)) then diff --git a/lib/jt65code.f90 b/lib/jt65code.f90 index 4f2a4e03..d3dac07d 100644 --- a/lib/jt65code.f90 +++ b/lib/jt65code.f90 @@ -61,7 +61,7 @@ program JT65code go to 10 endif - call packmsg(msg1,dgen,itype,.false.) !Pack message into 12 six-bit bytes + call packmsg(msg1,dgen,itype) !Pack message into 12 six-bit bytes msgtype="" if(itype.eq.1) msgtype="Std Msg" if(itype.eq.2) msgtype="Type 1 pfx" @@ -77,15 +77,17 @@ program JT65code call graycode(sent,63,-1,tmp) !Remove Gray code call interleave63(tmp,-1) !Remove interleaving call rs_decode(tmp,era,0,recd,nerr) !Decode the message - call unpackmsg(recd,decoded,.false.,' ') !Unpack the user message + call unpackmsg(recd,decoded) !Unpack the user message if(cok.eq."OOO") decoded(20:22)=cok call fmtmsg(decoded,iz) 10 bad=" " - if(decoded.ne.msgchk) bad="*" expected = 'EXACT' - if (msg0.ne.msgchk) expected = 'TRUNCATED' - if (nmsg.eq.1) expected = 'UNKNOWN' + if(decoded.ne.msg0) then + bad="*" + if(decoded(1:13).eq.msg0(1:13) .and. & + decoded(14:22).eq. ' ') expected = 'TRUNCATED' + endif write(*,1020) imsg,msg0,decoded,bad,itype,msgtype,expected 1020 format(i2,'.',1x,a22,1x,a22,1x,a1,i3,":",a10,2x,a22) enddo diff --git a/lib/jt65sim.f90 b/lib/jt65sim.f90 index ba4285d4..6f7030cf 100644 --- a/lib/jt65sim.f90 +++ b/lib/jt65sim.f90 @@ -21,12 +21,13 @@ program jt65sim character msg*22,fname*11,csubmode*1,c,optarg*500,numbuf*32 ! character call1*5,call2*5 logical :: display_help=.false.,seed_prngs=.true. - type (option) :: long_options(12) = [ & + type (option) :: long_options(13) = [ & option ('help',.false.,'h','Display this help message',''), & option ('sub-mode',.true.,'m','sub mode, default MODE=A','MODE'), & option ('num-sigs',.true.,'n','number of signals per file, default SIGNALS=10','SIGNALS'), & option ('f0',.true.,'F','base frequency offset, default F0=1500.0','F0'), & option ('doppler-spread',.true.,'d','Doppler spread, default SPREAD=0.0','SPREAD'), & + option ('drift per min',.true.,'D','Frequency drift (Hz/min), default DRIFT=0.0','DRIFT'), & option ('time-offset',.true.,'t','Time delta, default SECONDS=0.0','SECONDS'), & option ('num-files',.true.,'f','Number of files to generate, default FILES=1','FILES'), & option ('no-prng-seed',.false.,'p','Do not seed PRNGs (use for reproducible tests)',''), & @@ -50,6 +51,7 @@ program jt65sim nsigs=10 bf0=1500. fspread=0. + drift=0. xdt=0. snrdb=0. nfiles=1 @@ -58,7 +60,7 @@ program jt65sim msg="K1ABC W9XYZ EN37" do - call getopt('hm:n:F:d:t:f:ps:SG:M:',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.) + call getopt('hm:n:F:d:D:t:f:ps:SG:M:',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.) if( nstat .ne. 0 ) then exit end if @@ -76,6 +78,8 @@ program jt65sim read (optarg(:narglen), *,err=10) bf0 case ('d') read (optarg(:narglen), *,err=10) fspread + case ('D') + read (optarg(:narglen), *,err=10) drift case ('t') read (optarg(:narglen), *) numbuf if (numbuf(1:1) == '\') then !'\' @@ -105,7 +109,6 @@ program jt65sim end if case ('M') read (optarg(:narglen), '(A)',err=10) msg - write(*,*) msg end select cycle 10 display_help=.true. @@ -175,7 +178,7 @@ program jt65sim ! write(msg,1010) call1,call2,nint(xsnr) !1010 format(a5,1x,a5,1x,i3.2) !### - call packmsg(msg,dgen,itype,.false.) !Pack message into 12 six-bit bytes + call packmsg(msg,dgen,itype) !Pack message into 12 six-bit bytes call rs_encode(dgen,sent) !Encode using RS(63,12) call interleave63(sent,1) !Interleave channel symbols call graycode65(sent,63,1) !Apply Gray code @@ -190,6 +193,21 @@ program jt65sim endif enddo + if(len(trim(msg)).eq.2.or.len(trim(msg)).eq.3) then + nshorthand=0 + if(msg(1:2).eq.'RO') nshorthand=2 + if(msg(1:3).eq.'RRR') nshorthand=3 + if(msg(1:2).eq.'73') nshorthand=4 + if(nshorthand.gt.0) then + ntoggle=0 + do i=1,nsym,2 + itone(i)=ntoggle*10*nshorthand + if(i+1.le.126) itone(i+1)=ntoggle*10*nshorthand + ntoggle=mod(ntoggle+1,2) + enddo + endif + endif + bandwidth_ratio=2500.0/(fsample/2.0) sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*xsnr) if(xsnr.gt.90.0) sig=1.0 @@ -203,11 +221,8 @@ program jt65sim do i=1,npts !Add this signal into cdat() isym=floor(i/sps)+1 if(isym.gt.nsym) exit - if(isym.ne.isym0) then - freq=f0 + itone(isym)*baud*mode65 - dphi=twopi*freq*dt - isym0=isym - endif + freq=f0 + (drift/60.0)*(i-npts/2)*dt + itone(isym)*baud*mode65 + dphi=twopi*freq*dt phi=phi + dphi if(phi.gt.twopi) phi=phi-twopi xphi=phi @@ -282,9 +297,9 @@ program jt65sim endif - dat=aimag(cdat) + xnoise !Add the generated noise + dat(1:npts)=aimag(cdat(1:npts)) + xnoise(1:npts) !Add the generated noise if(snrdb.lt.90.0) then - dat=rms*dat(1:npts) + dat(1:npts)=rms*dat(1:npts) else datpk=maxval(abs(dat(1:npts))) fac=32766.9/datpk diff --git a/lib/jt9code.f90 b/lib/jt9code.f90 index 5a4b4fc8..0ab96d85 100644 --- a/lib/jt9code.f90 +++ b/lib/jt9code.f90 @@ -71,9 +71,11 @@ program jt9code 10 bad=" " expected = 'EXACT' - if (msg0.ne.msgchk) expected = 'TRUNCATED' - if (nmsg.eq.1) expected = 'UNKNOWN' - if(decoded.ne.msgchk) bad="*" + if(decoded.ne.msg0) then + bad="*" + if(decoded(1:13).eq.msg0(1:13) .and. & + decoded(14:22).eq. ' ') expected = 'TRUNCATED' + endif write(*,1020) imsg,msg0,decoded,bad,itype,msgtype,expected 1020 format(i2,'.',1x,a22,1x,a22,1x,a1,i3,":",a10,2x,a22) enddo diff --git a/lib/jt9fano.f90 b/lib/jt9fano.f90 index 275e0e07..1277117a 100644 --- a/lib/jt9fano.f90 +++ b/lib/jt9fano.f90 @@ -84,7 +84,7 @@ subroutine jt9fano(i1SoftSymbols,limit,nlim,msg) enddo
call unpackbits(i4DecodedBytes,nbytes,8,i1DecodedBits)
call packbits(i1DecodedBits,12,6,i4Decoded6BitWords)
- call unpackmsg(i4Decoded6BitWords,msg,.false.,' ') !Unpack decoded msg
+ call unpackmsg(i4Decoded6BitWords,msg) !Unpack decoded msg
if(index(msg,'000AAA ').gt.0) msg=' '
endif
diff --git a/lib/ldpc/COPYRIGHT b/lib/ldpc/COPYRIGHT deleted file mode 100755 index 9cd0d7f6..00000000 --- a/lib/ldpc/COPYRIGHT +++ /dev/null @@ -1,15 +0,0 @@ -Except as otherwise specified, all program code and documentation in this -directory is copyright (c) 1995-2012 by Radford M. Neal. - -Permission is granted for anyone to copy, use, modify, and distribute -these programs and accompanying documents for any purpose, provided -this copyright notice is retained and prominently displayed, and note -is made of any changes made to these programs. These programs and -documents are distributed without any warranty, express or implied. -As the programs were written for research purposes only, they have not -been tested to the degree that would be advisable in any important -application. All use of these programs is entirely at the user's own -risk. - -Some routines in the module rand.c are taken from the GNU C Library, -and are copyrighted as described there and in the file LGPL. diff --git a/lib/ldpc/LDPC-install b/lib/ldpc/LDPC-install deleted file mode 100755 index 0ca12ace..00000000 --- a/lib/ldpc/LDPC-install +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -# Copy the LPDC programs to the directory specified. The program file -# might be the name of the program, or (eg, on Cygwin) the name of the -# program with .exe appended. - -if [ x$1 == x -o x$2 != x ]; then - echo Usage: LDPC-install bin-directory - exit 1 -fi - -echo Installing LPDC programs in $1 - -mkdir -p $1 - -for prog in make-pchk alist-to-pchk pchk-to-alist \ - make-ldpc print-pchk make-gen print-gen \ - rand-src encode transmit decode extract verify; do - if [ -f $prog ]; then - cp $prog $1 - elif [ -f $prog.exe ]; then - cp $prog.exe $1 - else - echo No program $prog to install - fi -done - -echo Done diff --git a/lib/ldpc/LGPL b/lib/ldpc/LGPL deleted file mode 100755 index 7106bb0a..00000000 --- a/lib/ldpc/LGPL +++ /dev/null @@ -1,463 +0,0 @@ -The following is the license under which the portions of the GNU C -library used in the rand.c module is distributed. Note that this -license does not apply to the rest of this software. - - -GNU LESSER GENERAL PUBLIC LICENSE -Version 2.1, February 1999 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts -as the successor of the GNU Library Public License, version 2, hence -the version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - -To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - -Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - -Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - -When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - -We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - -For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - -In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - -Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - -The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - -GNU LESSER GENERAL PUBLIC LICENSE -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of e Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - -You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - -2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -a) The modified work must itself be a software library. - -b) You must cause the files modified to carry prominent notices -stating that you changed the files and the date of any change. - -c) You must cause the whole of the work to be licensed at no -charge to all third parties under the terms of this License. - -d) If a facility in the modified Library refers to a function or a -table of data to be supplied by an application program that uses -the facility, other than as an argument passed when the facility -is invoked, then you must make a good faith effort to ensure that, -in the event an application does not supply such function or -table, the facility still operates, and performs whatever part of -its purpose remains meaningful. - -(For example, a function in a library to compute square roots has -a purpose that is entirely well-defined independent of the -application. Therefore, Subsection 2d requires that any -application-supplied function or table used by this function must -be optional: if the application does not supply it, the square -root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - -Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - -a) Accompany the work with the complete corresponding -machine-readable source code for the Library including whatever -changes were used in the work (which must be distributed under -Sections 1 and 2 above); and, if the work is an executable linked -with the Library, with the complete machine-readable "work that -uses the Library", as object code and/or source code, so that the -user can modify the Library and then relink to produce a modified -executable containing the modified Library. (It is understood -that the user who changes the contents of definitions files in the -Library will not necessarily be able to recompile the application -to use the modified definitions.) - -b) Use a suitable shared library mechanism for linking with the -Library. A suitable mechanism is one that (1) uses at run time a -copy of the library already present on the user's computer system, -rather than copying library functions into the executable, and (2) -will operate properly with a modified version of the library, if -the user installs one, as long as the modified version is -interface-compatible with the version that the work was made with. - -c) Accompany the work with a written offer, valid for at -least three years, to give the same user the materials -specified in Subsection 6a, above, for a charge no more -than the cost of performing this distribution. - -d) If distribution of the work is made by offering access to copy -from a designated place, offer equivalent access to copy the above -specified materials from the same place. - -e) Verify that the user has already received a copy of these -materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - -It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - -7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - -a) Accompany the combined library with a copy of the same work -based on the Library, uncombined with any other library -facilities. This must be distributed under the terms of the -Sections above. - -b) Give prominent notice with the combined library of the fact -that part of it is a work based on the Library, and explaining -where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - -11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - -END OF TERMS AND CONDITIONS diff --git a/lib/ldpc/Makefile b/lib/ldpc/Makefile deleted file mode 100755 index 5f539ee8..00000000 --- a/lib/ldpc/Makefile +++ /dev/null @@ -1,115 +0,0 @@ -# MAKEFILE FOR LDPC PROGRAMS & ASSOCIATED UTILITIES. - -# Copyright (c) 1995-2012 by Radford M. Neal. -# -# Permission is granted for anyone to copy, use, modify, and distribute -# these programs and accompanying documents for any purpose, provided -# this copyright notice is retained and prominently displayed, and note -# is made of any changes made to these programs. These programs and -# documents are distributed without any warranty, express or implied. -# As the programs were written for research purposes only, they have not -# been tested to the degree that would be advisable in any important -# application. All use of these programs is entirely at the user's own -# risk. - - -# NOTE: The natural random numbers in "randfile" are accessed by the -# 'rand' module via a path to this directory. Change the definition of -# RAND_FILE in the compilation command for rand.c below if this is not -# appropriate. - -# NOTE: This makefile is trivial, simply recompiling everything from -# scratch every time. Since this takes only about 5 seconds on a modern -# PC, there's no point in putting in dependency-based rules, which just -# make things more complex and error-prone. - - -COMPILE = cc -c -O # Command to compile a module from .c to .o -LINK = cc # Command to link a program - - -# MAKE ALL THE MAIN PROGRAMS. First makes the modules used. - -progs: modules - $(COMPILE) make-pchk.c - $(LINK) make-pchk.o mod2sparse.o mod2dense.o mod2convert.o \ - rcode.o alloc.o intio.o open.o -lm -o make-pchk - $(COMPILE) alist-to-pchk.c - $(LINK) alist-to-pchk.o mod2sparse.o mod2dense.o mod2convert.o \ - rcode.o alloc.o intio.o open.o -lm -o alist-to-pchk - $(COMPILE) pchk-to-alist.c - $(LINK) pchk-to-alist.o mod2sparse.o mod2dense.o mod2convert.o \ - rcode.o alloc.o intio.o open.o -lm -o pchk-to-alist - $(COMPILE) make-ldpc.c - $(LINK) make-ldpc.o mod2sparse.o mod2dense.o mod2convert.o \ - rcode.o rand.o alloc.o intio.o open.o distrib.o -lm -o make-ldpc - $(COMPILE) print-pchk.c - $(LINK) print-pchk.o mod2sparse.o mod2dense.o mod2convert.o \ - rcode.o rand.o alloc.o intio.o open.o -lm -o print-pchk - $(COMPILE) make-gen.c - $(LINK) make-gen.o mod2sparse.o mod2dense.o mod2convert.o \ - rcode.o alloc.o intio.o open.o -lm -o make-gen - $(COMPILE) print-gen.c - $(LINK) print-gen.o mod2sparse.o mod2dense.o mod2convert.o \ - rcode.o rand.o alloc.o intio.o open.o -lm -o print-gen - $(COMPILE) rand-src.c - $(LINK) rand-src.o rand.o open.o -lm -o rand-src - $(COMPILE) encode.c - $(LINK) encode.o mod2sparse.o mod2dense.o mod2convert.o \ - enc.o rcode.o rand.o alloc.o intio.o blockio.o open.o -lm -o encode - $(COMPILE) transmit.c - $(LINK) transmit.o channel.o rand.o open.o -lm -o transmit - $(COMPILE) decode.c - $(LINK) decode.o channel.o mod2sparse.o mod2dense.o mod2convert.o \ - enc.o check.o \ - rcode.o rand.o alloc.o intio.o blockio.o dec.o open.o -lm -o decode - $(COMPILE) extract.c - $(LINK) extract.o mod2sparse.o mod2dense.o mod2convert.o \ - rcode.o alloc.o intio.o blockio.o open.o -lm -o extract - $(COMPILE) verify.c - $(LINK) verify.o mod2sparse.o mod2dense.o mod2convert.o check.o \ - rcode.o alloc.o intio.o blockio.o open.o -lm -o verify - -# MAKE THE TEST PROGRAMS. First makes the modules used. - -tests: modules - $(COMPILE) mod2dense-test.c - $(LINK) mod2dense-test.o mod2dense.o alloc.o intio.o \ - -lm -o mod2dense-test - $(COMPILE) mod2sparse-test.c - $(LINK) mod2sparse-test.o mod2sparse.o alloc.o intio.o \ - -lm -o mod2sparse-test - $(COMPILE) mod2convert-test.c - $(LINK) mod2convert-test.o mod2convert.o mod2dense.o mod2sparse.o \ - alloc.o intio.o rand.o open.o -lm -o mod2convert-test - $(COMPILE) rand-test.c - $(LINK) rand-test.o rand.o -lm -o rand-test - - -# MAKE THE MODULES USED BY THE PROGRAMS. - -modules: - $(COMPILE) rcode.c - $(COMPILE) channel.c - $(COMPILE) dec.c - $(COMPILE) enc.c - $(COMPILE) alloc.c - $(COMPILE) intio.c - $(COMPILE) blockio.c - $(COMPILE) check.c - $(COMPILE) open.c - $(COMPILE) mod2dense.c - $(COMPILE) mod2sparse.c - $(COMPILE) mod2convert.c - $(COMPILE) distrib.c - $(COMPILE) -DRAND_FILE=\"`pwd`/randfile\" rand.c - - -# CLEAN UP ALL PROGRAMS AND REMOVE ALL FILES PRODUCED BY TESTS AND EXAMPLES. - -clean: - rm -f core *.o *.exe ex-*.* test-file \ - make-pchk alist-to-pchk pchk-to-alist \ - make-ldpc print-pchk make-gen print-gen \ - rand-src encode transmit decode extract verify \ - mod2dense-test mod2sparse-test mod2convert-test rand-test diff --git a/lib/ldpc/Makefile.msk_osx b/lib/ldpc/Makefile.msk_osx deleted file mode 100644 index 45aa36a4..00000000 --- a/lib/ldpc/Makefile.msk_osx +++ /dev/null @@ -1,39 +0,0 @@ -# Compilers -CC = gcc -CXX = g++ -FC = gfortran -AR = ar cr -RANLIB = ranlib -MKDIR = mkdir -p -CP = cp -RM = rm -f - -FFLAGS = -O2 -fbounds-check -Wall -Wno-conversion -CFLAGS = -O2 -I. - -# Default rules -%.o: %.c - ${CC} ${CFLAGS} -c $< -%.o: %.f - ${FC} ${FFLAGS} -c $< -%.o: %.F - ${FC} ${FFLAGS} -c $< -%.o: %.f90 - ${FC} ${FFLAGS} -c $< -%.o: %.F90 - ${FC} ${FFLAGS} -c $< - -all: ldpcsim - -OBJS = ldpcsim.o alloc.o rcode.o dec.o enc.o \ - intio.o blockio.o check.o open.o mod2dense.o \ - mod2sparse.o mod2convert.o distrib.o rand.o gran.o - -ldpcsim:$(OBJS) - $(FC) -o ldpcsim $(OBJS) - -rand.o: - $(CC) $(CFLAGS) -DRAND_FILE=\"./randfile\" -c rand.c - -clean: - $(RM) *.o msksim diff --git a/lib/ldpc/README b/lib/ldpc/README deleted file mode 100755 index dd34af58..00000000 --- a/lib/ldpc/README +++ /dev/null @@ -1,6 +0,0 @@ -This is a collection of programs and modules, written in C, that -support research and education concerning Low Density Parity Check -(LDPC) codes. - -See index.html in this directory for an index to the documentation. -Copyright information can be found there, and in the file COPYRIGHT. diff --git a/lib/ldpc/alist-to-pchk.c b/lib/ldpc/alist-to-pchk.c deleted file mode 100755 index 21831ded..00000000 --- a/lib/ldpc/alist-to-pchk.c +++ /dev/null @@ -1,168 +0,0 @@ -/* ALIST-TO-PCHK.C - Convert a parity check matrix from alist format. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "alloc.h" -#include "intio.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" - - -void bad_alist_file(void); -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char *alist_file, *pchk_file; - FILE *af, *pf; - int mxrw, mxcw; - int *rw, *cw; - int i, j, k; - int tot, trans; - int nxt; - - trans = 0; - - for (;;) - { - if (argc>1 && strcmp(argv[1],"-t")==0) - { trans = 1; - argc -= 1; - argv += 1; - } - else - { break; - } - } - - if (argc!=3) - { usage(); - } - - pchk_file = argv[2]; - alist_file = argv[1]; - - af = open_file_std(alist_file,"r"); - - if (af==NULL) - { fprintf(stderr,"Can't open alist file: %s\n",alist_file); - exit(1); - } - - if (fscanf(af,"%d",&M)!=1 || M<1 - || fscanf(af,"%d",&N)!=1 || N<1 - || fscanf(af,"%d",&mxrw)!=1 || mxrw<0 || mxrw>N - || fscanf(af,"%d",&mxcw)!=1 || mxcw<0 || mxcw>M) - { bad_alist_file(); - } - - rw = (int *) chk_alloc (M, sizeof *rw); - - for (i = 0; i<M; i++) - { if (fscanf(af,"%d",&rw[i])!=1 || rw[i]<0 || rw[i]>N) - { bad_alist_file(); - } - } - - cw = (int *) chk_alloc (N, sizeof *cw); - - for (j = 0; j<N; j++) - { if (fscanf(af,"%d",&cw[j])!=1 || cw[j]<0 || cw[j]>M) - { bad_alist_file(); - } - } - - H = mod2sparse_allocate(M,N); - - do { if (fscanf(af,"%d",&nxt)!=1) nxt = -1; } while (nxt==0); - - tot = 0; - - for (i = 0; i<M; i++) - { for (k = 0; k<rw[i]; k++) - { if (nxt<=0 || nxt>N || mod2sparse_find(H,i,nxt-1)) - { bad_alist_file(); - } - mod2sparse_insert(H,i,nxt-1); - tot += 1; - do { if (fscanf(af,"%d",&nxt)!=1) nxt = -1; } while (nxt==0); - } - } - - for (j = 0; j<N; j++) - { for (k = 0; k<cw[j]; k++) - { if (nxt<=0 || nxt>M || !mod2sparse_find(H,nxt-1,j)) - { bad_alist_file(); - } - tot -= 1; - do { if (fscanf(af,"%d",&nxt)!=1) nxt = -1; } while (nxt==0); - } - } - - if (tot!=0 || nxt!=-1 || !feof(af)) - { bad_alist_file(); - } - - if (trans) - { mod2sparse *HT; - HT = H; - H = mod2sparse_allocate(N,M); - mod2sparse_transpose(HT,H); - } - - pf = open_file_std(pchk_file,"wb"); - if (pf==NULL) - { fprintf(stderr,"Can't create parity check file: %s\n",pchk_file); - exit(1); - } - - intio_write(pf,('P'<<8)+0x80); - - if (ferror(pf) || !mod2sparse_write(pf,H) || fclose(pf)!=0) - { fprintf(stderr,"Error writing to parity check file %s\n",pchk_file); - exit(1); - } - - return 0; -} - - -/* COMPLAIN THAT ALIST FILE IS BAD. */ - -void bad_alist_file() -{ fprintf(stderr,"Alist file doesn't have the right format\n"); - exit(1); -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr,"Usage: alist-to-pchk [ -t ] alist-file pchk-file\n"); - exit(1); -} diff --git a/lib/ldpc/alloc.c b/lib/ldpc/alloc.c deleted file mode 100755 index f289ceb8..00000000 --- a/lib/ldpc/alloc.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ALLOC.C - Routine to allocate memory and complain if it doesn't work. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdlib.h> -#include <stdio.h> - -#include "alloc.h" - - -/* ALLOCATE SPACE AND CHECK FOR ERROR. Calls 'calloc' to allocate space, - and then displays an error message and exits if the space couldn't be - found. */ - -void *chk_alloc -( unsigned n, /* Number of elements */ - unsigned size /* Size of each element */ -) -{ - void *p; - - p = calloc(n,size); - - if (p==0) - { fprintf(stderr,"Ran out of memory (while trying to allocate %d bytes)\n", - n*size); - exit(1); - } - - return p; -} diff --git a/lib/ldpc/alloc.h b/lib/ldpc/alloc.h deleted file mode 100755 index aa1fb173..00000000 --- a/lib/ldpc/alloc.h +++ /dev/null @@ -1,18 +0,0 @@ -/* ALLOC.H - Interface to memory allocation procedure. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -void *chk_alloc (unsigned, unsigned); /* Calls 'calloc' and exits with error - if it fails */ diff --git a/lib/ldpc/blockio.c b/lib/ldpc/blockio.c deleted file mode 100755 index c9d08632..00000000 --- a/lib/ldpc/blockio.c +++ /dev/null @@ -1,85 +0,0 @@ -/* BLOCKIO.C - Routines to read/write blocks of bits from/to a text file. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdlib.h> -#include <stdio.h> - -#include "blockio.h" - - -int blockio_flush = 0; /* Should blocks written be immediately flushed? */ - - -/* READ A BLOCK OF BITS. The bits must be given as '0' or '1' characters, - with whitespace allowed (but not required) between bits. Returns 0 if - a block is read successfully, and EOF if eof or an error occurs. If - EOF is returned, a warning will be printed if a partial block had already - been read. */ - -int blockio_read -( FILE *f, /* File to read from */ - char *b, /* Place to store bits read */ - int l /* Length of block */ -) -{ - int i, c; - - for (i = 0; i<l; i++) - { - do - { c = getc(f); - if (c==EOF) - { if (i>0) - { fprintf(stderr, - "Warning: Short block (%d long) at end of input file ignored\n",i); - } - return EOF; - } - } while (c==' ' || c=='\t' || c=='\n' || c=='\r'); - - if (c!='0' && c!='1') - { fprintf(stderr,"Bad character in binary file (not '0' or '1')\n"); - exit(1); - } - - b[i] = c=='1'; - } - - return 0; -} - - -/* WRITE A BLOCK OF BITS. Bits are written as '0' and '1' characters, with - no spaces between them, followed by a newline. */ - -void blockio_write -( FILE *f, /* File to write to */ - char *b, /* Block of bits to write */ - int l /* Length of block */ -) -{ - int i; - - for (i = 0; i<l; i++) - { if (b[i]!=0 && b[i]!=1) abort(); - putc("01"[b[i]],f); - } - - putc('\n',f); - - if (blockio_flush) - { fflush(f); - } -} diff --git a/lib/ldpc/blockio.h b/lib/ldpc/blockio.h deleted file mode 100755 index 3610acfb..00000000 --- a/lib/ldpc/blockio.h +++ /dev/null @@ -1,19 +0,0 @@ -/* BLOCKIO.H - Interface to block input/output routines. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -extern int blockio_flush; /* Should blocks written be immediately flushed? */ - -int blockio_read (FILE *, char *, int); -void blockio_write (FILE *, char *, int); diff --git a/lib/ldpc/channel.c b/lib/ldpc/channel.c deleted file mode 100755 index 9f6e3711..00000000 --- a/lib/ldpc/channel.c +++ /dev/null @@ -1,99 +0,0 @@ -/* CHANNEL.C - Procedures and variables regarding channels. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "channel.h" - - -/* GLOBAL VARIABLES. Declared in channel.h. */ - -channel_type channel; /* Type of channel */ - -double error_prob; /* Error probability for BSC */ -double std_dev; /* Noise standard deviation for AWGN */ -double lwidth; /* Width of noise distribution for AWLN */ - - -/* PARSE A COMMAND-LINE SPECIFICATION OF A CHANNEL. Takes a pointer to an - argument list and an argument count; returns the number of arguments that - make up a channel specification at this point in the command line. Returns - zero if the argument list does not start with a channel specification. - Returns -1 if there seems to be a channel specification here, but it's - invalid. - - Sets the variables declared in channel.h to the type and parameters of - the channel. - */ - -int channel_parse -( char **argv, /* Pointer to argument list */ - int argc /* Number of arguments in list */ -) -{ - char junk; - - if (argc==0) return 0; - - if (strcmp(argv[0],"bsc")==0 || strcmp(argv[0],"BSC")==0) - { - channel = BSC; - if (argc<2 || sscanf(argv[1],"%lf%c",&error_prob,&junk)!=1 - || error_prob<=0 || error_prob>=1) - { return -1; - } - else - { return 2; - } - } - else if (strcmp(argv[0],"awgn")==0 || strcmp(argv[0],"AWGN")==0) - { - channel = AWGN; - if (argc<2 || sscanf(argv[1],"%lf%c",&std_dev,&junk)!=1 - || std_dev<=0) - { return -1; - } - else - { return 2; - } - } - else if (strcmp(argv[0],"awln")==0 || strcmp(argv[0],"AWLN")==0) - { - channel = AWLN; - if (argc<2 || sscanf(argv[1],"%lf%c",&lwidth,&junk)!=1 - || lwidth<=0) - { return -1; - } - else - { return 2; - } - } - else - { - return 0; - } -} - - -/* PRINT USAGE MESSAGE REGARDING CHANNEL SPECIFICATIONS. */ - -void channel_usage(void) -{ - fprintf(stderr, - "Channel: bsc error-probability | awgn standard-deviation | awln width\n"); -} diff --git a/lib/ldpc/channel.h b/lib/ldpc/channel.h deleted file mode 100755 index 0522e856..00000000 --- a/lib/ldpc/channel.h +++ /dev/null @@ -1,32 +0,0 @@ -/* CHANNEL.H - Declarations regarding channels. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* TYPES OF CHANNEL, AND CHANNEL PARAMETERS. The global variables declared - here are located in channel.c. */ - -typedef enum { BSC, AWGN, AWLN } channel_type; - -extern channel_type channel; /* Type of channel */ - -extern double error_prob; /* Error probability for BSC */ -extern double std_dev; /* Noise standard deviation for AWGN */ -extern double lwidth; /* Width of noise distributoin for AWLN */ - - -/* PROCEDURES TO DO WITH CHANNELS. */ - -int channel_parse (char **, int); -void channel_usage (void); diff --git a/lib/ldpc/channel.html b/lib/ldpc/channel.html deleted file mode 100755 index ad512919..00000000 --- a/lib/ldpc/channel.html +++ /dev/null @@ -1,182 +0,0 @@ -<HTML><HEAD> - -<TITLE> Transmission Through a Simulated Channel </TITLE> - -</HEAD><BODY> - - -<H1> Transmission Through a Simulated Channel </H1> - -<P>Once a codeword has been found to represent a source message, it -can be sent through a <I>channel</I>, with the result that certain -data is received as the output of the channel, which will be related -to the codeword sent, but with random noise. This software currently -handles only memoryless binary channels, for which each bit sent -through the channel results in a separate piece of data being -received, and the noise affecting one bit is independent of the noise -affecting other bits. - -<P>For a <I>Binary Symmetric Channel</I> (BSC), each bit sent -results in a bit being received. The bit received differs from the -bit sent with some error probability, <I>p</I>, which is the same for -0 bits and for 1 bits. In other words, the probability distribution -for the bit received given the bit sent is as follows: -<BLOCKQUOTE> -P(receive 1 | send 1) = P(receive 0 | send 0) = 1-<I>p</I><BR> -P(receive 1 | send 0) = P(receive 0 | send 1) = <I>p</I> -</BLOCKQUOTE> - -<P>For an <I>Additive White Gaussian Noise</I> (AWGN) channel, the -data received at each time is equal to the data sent plus Gaussian -noise with mean zero and some standard deviation, <I>s</I>, -independently for each bit. For this software, the data sent is -1 -for a 0 bit and +1 for a 1 bit. In other words, the distribution -of the received data given the bit sent is as follows: -<BLOCKQUOTE> -data received | send 1 ~ N(+1,<I>s</I><SUP><SMALL>2</SMALL></SUP>)<BR> -data received | send 0 ~ N(-1,<I>s</I><SUP><SMALL>2</SMALL></SUP>) -</BLOCKQUOTE> - -<P>It is typically assumed that the standard deviation of the noise -varies with the rate at which bits are sent, increasing in proportion -to the square root of the rate. The error rate obtained from sending -unencoded bits at rate <I>R</I> will then be the same as is obtained -using a code that repeats each bit <I>n</I> times, and sends these -bits at rate <I>nR</I> (assuming optimal decoding of each bit by -thresholding the sum of the <I>n</I> channel outputs corresponding to -that bit). Another way of looking at this scaling for <I>s</I> is -that when bits are send at a lower rate, the receiver will be -accumulating the channel output for a longer time, with the result -that the amount of noise will decrease (relative to the signal) as a -result of averaging. - -<P>To account for this, it is common to compare codes for AWGN -channels in terms of their bit error rate and the value of -<BLOCKQUOTE> -<I>E<SUB><SMALL>b</SMALL></SUB></I> / <I>N<SUB><SMALL>0</SMALL></SUB></I> -= 1 / 2<I>R</I><I>s</I><SUP><SMALL>2</SMALL></SUP> -</BLOCKQUOTE> -at which they operate, where <I>R</I>=<I>K</I>/<I>N</I> is the rate -of the code, and <I>s</I> is the noise level at which the code -achieves the quoted bit error rate. Hence, a code operating at a lower -rate is allowed to assume a lower noise level to make the comparison fair. -It is common to quote -<I>E<SUB><SMALL>b</SMALL></SUB></I> / -<I>N<SUB><SMALL>0</SMALL></SUB></I> in decibels (db), equal to -10 log<SUB><SMALL>10</SMALL></SUB>(<I>E<SUB><SMALL>b</SMALL></SUB></I> -/ <I>N<SUB><SMALL>0</SMALL></SUB></I>). - -<P>The <I>Additive White Logistic Noise</I> (AWLN) channel is similar -to the AWGN channel, except that the noise comes from a logistic rather -than a Gaussian distribution. The probability density function for the -noise is -<BLOCKQUOTE> -(1/<I>w</I>) exp(-<I>n</I>/<I>w</I>) / [1 + exp(-<I>n</I>/<I>w</I>)]<SUP>2</SUP> -</BLOCKQUOTE> -where <I>n</I> is the amount of noise, and <I>w</I> is a width parameter -for the distribution, analogous to the <I>s</I> parameter for -Gaussian noise. (However, <I>w</I> is not equal to the standard deviation -for the logistic distribution, which is -sqrt(pi<SUP><SMALL>2</SMALL></SUP>/3)<I>w</I>.) <B>Note:</B> Although I've -named this channel in analogy with the AWGN channel, it does not share -the properties discussed above regarding how noise levels would be expected -to change when the data rate changes. - - -<P><A NAME="transmit"><HR><B>transmit</B>: Transmit bits through a -simulated channel. - -<BLOCKQUOTE><PRE> -transmit <I>encoded-file</I>|<I>n-zeros received-file seed channel</I> -</PRE> -<BLOCKQUOTE> -where <TT><I>channel</I></TT> is one of the following: -<BLOCKQUOTE><PRE> -bsc <I>error-probability</I> - -awgn <I>standard-deviation</I> - -awln <I>width</I> -</PRE></BLOCKQUOTE> -</BLOCKQUOTE> -</BLOCKQUOTE> - -<P>Simulates the transmission of the bits in -<TT><I>encoded-file</I></TT> through a channel, with the received data -being stored in <TT><I>received-file</I></TT>. Typically, -<TT><I>encoded-file</I></TT> will have been produced by the <A -HREF="encoding.html#encode"><TT>encode</TT></A> program, but it could -also come from <A HREF="support.html#rand-src"><TT>rand-src</TT></A> -or another program. If newlines separate blocks in -<TT><I>encoded-file</I></TT>, these block boundaries will be preserved -in <TT><I>received-file</I></TT>. - -<P>Alternatively, a count of zeros to transmit can be given, rather -than a <I>encoded-file</I>. This count can be the product of the -block size and the number of blocks, written with <TT>x</TT> -separating these numbers, with no spaces. The -<TT><I>received-file</I></TT> will mark the block boundaries with -newlines, assuming a block size of one if a simple bit count is given. -Note that zero messages are sufficient for assessing the performance -of a linear code with a symmetrical channel and a symmetrical decoding -algorithm. <B>Warning:</B> Ties, messages that lead to floating-point -overflow, and program bugs can easily make a decoding algorithm -non-symmetrical, so it's best not to test exclusively on zero -messages. Indeed, it is best not to do this at all unless you -really need to avoid the time needed to generate and encode random -messages. - -<P>The transmission will be corrupted by random noise, which will be -generated pseudo-randomly based on <TT><I>seed</I></TT>. The actual -random seed used will be <TT><I>seed</I></TT> times 10 plus 3, so that -the stream of pseudo-random numbers will not be the same as any that -might have been used by another program. - -<P>The fourth argument specifies the type of channel, currently either -<TT>bsc</TT> (or <TT>BSC</TT>) for the Binary Symmetric Channel, or -<TT>awgn</TT> (or <TT>AWGN</TT>) for the Additive White Gaussian -Noise channel, or <TT>awln</TT> (or <TT>AWLN</TT>) for the Additive White -Logistic Noise channel. The channel type is followed by an argument -specifying the characteristics of the channel, as follows: -<BLOCKQUOTE> -<P>BSC: The probability that a bit will be flipped by noise - ie, the - probability that the bit received is an error. - -<P>AWGN: The standard deviation of the Gaussian noise that is added to the - encodings of the bits. - -<P>AWLN: The width parameter of the logistic distribution for the noise - that is added to the encodings of the bits. -</BLOCKQUOTE> - -See the description of <A HREF="channel.html">channel transmission</A> -for more details. - -<P><B>Examples</B>: The command: -<UL><PRE> -<LI>transmit 10x3 rec 1 bsc 0.1 -</PRE></UL> -will simulate the transmission of 30 zero bits (3 blocks of size 10) through -a Binary Symmetric Channel with error probability of 0.1. The result will -be to store something like the following in the file <TT>rec</TT>: -<BLOCKQUOTE><PRE> -0000000000 -1000000000 -0100000000 -</PRE></BLOCKQUOTE> -If an AWGN channel is used instead, as follows: -<UL><PRE> -<LI>transmit 10x3 rec 1 awgn 0.5 -</PRE></UL> -then the file <TT>rec</TT> will contain data such as: -<BLOCKQUOTE><PRE> - -1.36 -0.86 -0.80 -1.19 -1.18 -0.64 -0.31 -1.16 -1.56 -0.79 - -2.20 -1.62 -0.53 -1.29 -1.08 -2.05 -0.75 -1.22 -0.81 -0.52 - -0.86 -0.34 -1.10 -1.30 -1.10 -1.20 -0.37 -1.07 -0.22 -1.46 -</PRE></BLOCKQUOTE> - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/check.c b/lib/ldpc/check.c deleted file mode 100755 index e22b1dd9..00000000 --- a/lib/ldpc/check.c +++ /dev/null @@ -1,177 +0,0 @@ -/* CHECK.C - Compute parity checks and other stats on decodings. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> - -#include "mod2sparse.h" -#include "check.h" - - - -/* COMPUTE PARITY CHECKS. Returns the number of parity checks violated by - dblk. The results of all the parity checks are stored in pchk. */ - -int check -( mod2sparse *H, /* Parity check matrix */ - char *dblk, /* Guess for codeword */ - char *pchk /* Place to store parity checks */ -) -{ - int M, i, c; - - M = mod2sparse_rows(H); - - mod2sparse_mulvec (H, dblk, pchk); - - c = 0; - for (i = 0; i<M; i++) - { c += pchk[i]; - } - - return c; -} - - -/* COUNT HOW MANY BITS HAVED CHANGED FROM BIT INDICATED BY LIKELIHOOD. The - simple decoding based on likelihood ratio is compared to the given decoding. - A bit for which the likelihood ratio is exactly one counts as half a - change, which explains why the result is a double rather than an int. - */ - -double changed -( double *lratio, /* Likelihood ratios for bits */ - char *dblk, /* Candidate decoding */ - int N /* Number of bits */ -) -{ - double changed; - int j; - - changed = 0; - for (j = 0; j<N; j++) - { changed += lratio[j]==1 ? 0.5 : dblk[j] != (lratio[j]>1); - } - - return changed; -} - - -/* COMPUTE THE EXPECTED NUMBER OF PARITY CHECK ERRORS. Computes the - expected number of parity check errors with respect to the distribution - given by the bit probabilities passed, with bits assumed to be independent. - */ - -double expected_parity_errors -( mod2sparse *H, /* Parity check matrix */ - double *bpr /* Bit probabilities */ -) -{ - mod2entry *f; - double ee, p; - int M, i, j; - - M = mod2sparse_rows(H); - - ee = 0; - - for (i = 0; i<M; i++) - { p = 0; - for (f = mod2sparse_first_in_row(H,i); - !mod2sparse_at_end(f); - f = mod2sparse_next_in_row(f)) - { j = mod2sparse_col(f); - p = p * (1-bpr[j]) + (1-p) * bpr[j]; - } - ee += p; - } - - return ee; -} - - -/* COMPUTE LOG LIKELIHOOD OF A DECODING. */ - -double loglikelihood -( double *lratio, /* Likelihood ratios for bits */ - char *bits, /* Bits in decoding */ - int N /* Length of codeword */ -) -{ - double ll; - int j; - - ll = 0; - - for (j = 0; j<N; j++) - { ll -= bits[j] ? log(1+1/lratio[j]) : log(1+lratio[j]); - } - - return ll; -} - - -/* COMPUTE THE EXPECTED LOG LIKELIHOOD BASED ON BIT PROBABILITIES. Computes - the expected value of the log likelihood with respect to the distribution - given by the bit probabilities passed, with bits assumed to be independent. - */ - -double expected_loglikelihood -( double *lratio, /* Likelihood ratios for bits */ - double *bpr, /* Bit probabilities */ - int N /* Length of codeword */ -) -{ - double ll; - int j; - - ll = 0; - - for (j = 0; j<N; j++) - { if (bpr[j]>0) - { ll -= bpr[j]*log(1+1/lratio[j]); - } - if (bpr[j]<1) - { ll -= (1-bpr[j])*log(1+lratio[j]); - } - } - - return ll; -} - - -/* COMPUTE ENTROPY FROM BIT PROBABILITIES. Computes the entropy of the - distribution given by the bit probabilities, on the assumption that - bits are independent. - */ - -double entropy -( double *bpr, /* Bit probabilities */ - int N /* Length of codeword */ -) -{ - double e; - int j; - - e = 0; - for (j = 0; j<N; j++) - { if (bpr[j]>0 && bpr[j]<1) - { e -= bpr[j]*log(bpr[j]) + (1-bpr[j])*log(1-bpr[j]); - } - } - - return e/log(2.0); -} diff --git a/lib/ldpc/check.h b/lib/ldpc/check.h deleted file mode 100755 index 7ac00544..00000000 --- a/lib/ldpc/check.h +++ /dev/null @@ -1,25 +0,0 @@ -/* CHECK.H - Interface to procedure for computing parity checks, etc. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -int check (mod2sparse *, char *, char *); - -double changed (double *, char *, int); - -double expected_parity_errors (mod2sparse *, double *); - -double loglikelihood (double *, char *, int); -double expected_loglikelihood (double *, double *, int); - -double entropy (double *, int); diff --git a/lib/ldpc/dec.c b/lib/ldpc/dec.c deleted file mode 100755 index 68029115..00000000 --- a/lib/ldpc/dec.c +++ /dev/null @@ -1,420 +0,0 @@ -/* DEC.C - Decoding procedures. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* NOTE: See decoding.html for general documentation on the decoding methods */ - - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -#include "alloc.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -/*#include "rand.h"*/ -#include "rcode.h" -#include "check.h" -#include "dec.h" -#include "enc.h" - - -/* GLOBAL VARIABLES. Declared in dec.h. */ - -decoding_method dec_method; /* Decoding method to use */ - -int ldpc_table; /* Trace option, 2 for a table of decoding details */ -int block_no; /* Number of current block, from zero */ - -int max_iter; /* Maximum number of iteratons of decoding to do */ -char *gen_file; /* Generator file for Enum_block and Enum_bit */ - - -/* DECODE BY EXHAUSTIVE ENUMERATION. Decodes by trying all possible source - messages (and hence all possible codewords, unless the parity check matrix - was redundant). If the last argument is 1, it sets dblk to the most likely - entire block; if this argument is 0, each bit of dblk is set to the most - likely value for that bit. The marginal probabilities of each bit being 1 - are returned in bitpr. - - The function value returned is the total number of codewords tried (which - will be the same for all blocks). The return valued is "unsigned" because - it might conceivably be as big as 2^31. - - The parity check matrix and other data are taken from the global variables - declared in rcode.h. - - The number of message bits should not be greater than 31 for this procedure. - The setup procedure immediately below checks this, reads the generator file, - and outputs headers for the detailed trace file, if required. - */ - -void enum_decode_setup(void) -{ - read_gen(gen_file,0,0); - - if (N-M>31) - { fprintf(stderr, -"Trying to decode messages with %d bits by exhaustive enumeration is absurd!\n", - N-M); - exit(1); - } - - if (ldpc_table==2) - { printf(" block decoding likelihood\n"); - } -} - -unsigned enum_decode -( double *lratio, /* Likelihood ratios for bits */ - char *dblk, /* Place to stored decoded message */ - double *bitpr, /* Place to store marginal bit probabilities */ - int max_block /* Maximize probability of whole block being correct? */ -) -{ - mod2dense *u, *v; - double lk, maxlk, tpr; - double *bpr, *lk0, *lk1; - char sblk[31]; - char *cblk; - unsigned d; - int i, j; - - if (N-M>31) abort(); - - /* Allocate needed space. */ - - bpr = bitpr; - if (bpr==0 && max_block==0) - { bpr = chk_alloc (N, sizeof *bpr); - } - - cblk = chk_alloc (N, sizeof *cblk); - - if (type=='d') - { u = mod2dense_allocate(N-M,1); - v = mod2dense_allocate(M,1); - } - - if (type=='m') - { u = mod2dense_allocate(M,1); - v = mod2dense_allocate(M,1); - } - - lk0 = chk_alloc (N, sizeof *lk0); - lk1 = chk_alloc (N, sizeof *lk1); - - /* Pre-compute likelihoods for bits. */ - - for (j = 0; j<N; j++) - { lk0[j] = 1/(1+lratio[j]); - lk1[j] = 1 - lk0[j]; - } - - /* Initialize marginal bit probabilities. */ - - if (bpr) - { for (j = 0; j<N; j++) bpr[j] = 0.0; - } - - /* Exhaustively try all possible decoded messages. */ - - tpr = 0.0; - - for (d = 0; d<=(1<<(N-M))-1; d++) - { - /* Unpack message into source block. */ - - for (i = N-M-1; i>=0; i--) - { sblk[i] = (d>>i)&1; - } - - /* Find full codeword for this message. */ - - switch (type) - { case 's': - { sparse_encode (sblk, cblk); - break; - } - case 'd': - { dense_encode (sblk, cblk, u, v); - break; - } - case 'm': - { mixed_encode (sblk, cblk, u, v); - break; - } - } - - /* Compute likelihood for this decoding. */ - - lk = 1; - for (j = 0; j<N; j++) - { lk *= cblk[j]==0 ? lk0[j] : lk1[j]; - } - - /* Update maximum likelihood decoding. */ - - if (max_block) - { if (d==0 || lk>maxlk) - { for (j = 0; j<N; j++) - { dblk[j] = cblk[j]; - } - maxlk = lk; - } - } - - /* Update bit probabilities. */ - - if (bpr) - { for (j = 0; j<N; j++) - { if (cblk[j]==1) - { bpr[j] += lk; - } - } - tpr += lk; - } - - /* Output data to trace file. */ - - if (ldpc_table==2) - { printf("%7d %10x %10.4e\n",block_no,d,lk); - } - } - - /* Normalize bit probabilities. */ - - if (bpr) - { for (j = 0; j<N; j++) bpr[j] /= tpr; - } - - /* Decoding to maximize bit-by-bit success, if that's what's wanted. - In case of a tie, decode to a 1. */ - - if (!max_block) - { for (j = 0; j<N; j++) - { dblk[j] = bpr[j]>=0.5; - } - } - - /* Free space. */ - - if (bpr!=0 && bpr!=bitpr) free(bpr); - free(cblk); - free(lk0); - free(lk1); - - return 1<<(N-M); -} - - -/* DECODE USING PROBABILITY PROPAGATION. Tries to find the most probable - values for the bits of the codeword, given a parity check matrix (H), and - likelihood ratios (lratio) for each bit. If max_iter is positive, up to - that many iterations of probability propagation are done, stopping before - then if the tentative decoding is a valid codeword. If max_iter is - negative, abs(max_iter) iterations are done, regardless of whether a - codeword was found earlier. - - Returns the number of iterations done (as an "unsigned" for consistency - with enum_decode). Regardless of whether or not a valid codeword was - reached, the bit vector from thresholding the bit-by-bit probabilities is - stored in dblk, and the resulting parity checks are stored in pchk (all - will be zero if the codeword is valid). The final probabilities for each - bit being a 1 are stored in bprb. - - The setup procedure immediately below outputs headers for the detailed trace - file, if required. -*/ - -void prprp_decode_setup (void) -{ - if (ldpc_table==2) - { printf( - " block iter changed perrs loglik Eperrs Eloglik entropy\n"); - } -} - -unsigned prprp_decode -( mod2sparse *H, /* Parity check matrix */ - double *lratio, /* Likelihood ratios for bits */ - char *dblk, /* Place to store decoding */ - char *pchk, /* Place to store parity checks */ - double *bprb /* Place to store bit probabilities */ -) -{ - int N, n, c; - - N = mod2sparse_cols(H); - - /* Initialize probability and likelihood ratios, and find initial guess. */ - - initprp(H,lratio,dblk,bprb); - - /* Do up to abs(max_iter) iterations of probability propagation, stopping - early if a codeword is found, unless max_iter is negative. */ - - for (n = 0; ; n++) - { - c = check(H,dblk,pchk); - - if (ldpc_table==2) - { printf("%7d %5d %8.1f %6d %+9.2f %8.1f %+9.2f %7.1f\n", - block_no, n, changed(lratio,dblk,N), c, loglikelihood(lratio,dblk,N), - expected_parity_errors(H,bprb), expected_loglikelihood(lratio,bprb,N), - entropy(bprb,N)); - } - - if (n==max_iter || n==-max_iter || (max_iter>0 && c==0)) - { break; - } - - iterprp(H,lratio,dblk,bprb); - } - - return n; -} - - -/* INITIALIZE PROBABILITY PROPAGATION. Stores initial ratios, probabilities, - and guess at decoding. */ - -void initprp -( mod2sparse *H, /* Parity check matrix */ - double *lratio, /* Likelihood ratios for bits */ - char *dblk, /* Place to store decoding */ - double *bprb /* Place to store bit probabilities, 0 if not wanted */ -) -{ - mod2entry *e; - int N; - int j; - - N = mod2sparse_cols(H); - - for (j = 0; j<N; j++) - { for (e = mod2sparse_first_in_col(H,j); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_col(e)) - { e->pr = lratio[j]; - e->lr = 1; - } - if (bprb) bprb[j] = 1 - 1/(1+lratio[j]); - dblk[j] = lratio[j]>=1; - } -} - - -/* DO ONE ITERATION OF PROBABILITY PROPAGATION. */ - -void iterprp -( mod2sparse *H, /* Parity check matrix */ - double *lratio, /* Likelihood ratios for bits */ - char *dblk, /* Place to store decoding */ - double *bprb /* Place to store bit probabilities, 0 if not wanted */ -) -{ - double pr, dl, t; - mod2entry *e; - int N, M; - int i, j; - - M = mod2sparse_rows(H); - N = mod2sparse_cols(H); - - /* Recompute likelihood ratios. */ - - for (i = 0; i<M; i++) - { dl = 1; - for (e = mod2sparse_first_in_row(H,i); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_row(e)) - { e->lr = dl; - dl *= 2/(1+e->pr) - 1; - } - dl = 1; - for (e = mod2sparse_last_in_row(H,i); - !mod2sparse_at_end(e); - e = mod2sparse_prev_in_row(e)) - { t = e->lr * dl; - e->lr = (1-t)/(1+t); - dl *= 2/(1+e->pr) - 1; - } - } - - /* Recompute probability ratios. Also find the next guess based on the - individually most likely values. */ - - for (j = 0; j<N; j++) - { pr = lratio[j]; - for (e = mod2sparse_first_in_col(H,j); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_col(e)) - { e->pr = pr; - pr *= e->lr; - } - if (isnan(pr)) - { pr = 1; - } - if (bprb) bprb[j] = 1 - 1/(1+pr); - dblk[j] = pr>=1; - pr = 1; - for (e = mod2sparse_last_in_col(H,j); - !mod2sparse_at_end(e); - e = mod2sparse_prev_in_col(e)) - { e->pr *= pr; - if (isnan(e->pr)) - { e->pr = 1; - } - pr *= e->lr; - } - } -} - -void ldpc_decode_ ( double lratio[], char decoded[], int *max_iterations, int *niterations, int *max_dither, int *ndither) -{ - int i, j, itry, valid; - char dblk[N],pchk[M]; - double bprb[N],lr[N]; - float fac; - - max_iter=*max_iterations; - srand(-1); - for (itry=0; itry< *max_dither; itry++) { - for (i=0; i<N; i++) { - if( itry == 0 ) { - fac=0.0; - } else { - fac=(rand()%1024-512)/512.0; - } - lr[i]=lratio[i]*exp(fac); - } - *niterations = prprp_decode ( H, lr, dblk, pchk, bprb ); - valid = check( H, dblk, pchk )==0; - if( !valid ) { - *niterations=-1; - } else { - j=0; - for( i=M; i<N; i++ ) { - decoded[j]=dblk[cols[i]]; - j=j+1; - } - *ndither=itry; -// printf("ldpc_decode %d %d \n",*niterations, *ndither); - return; - } - } -} diff --git a/lib/ldpc/dec.h b/lib/ldpc/dec.h deleted file mode 100755 index d2dc32a3..00000000 --- a/lib/ldpc/dec.h +++ /dev/null @@ -1,43 +0,0 @@ -/* DEC.H - Interface to decoding procedures. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* DECODING METHOD, ITS PARAMETERS, AND OTHER VARIABLES. The global variables - declared here are located in dec.c. */ - -typedef enum -{ Enum_block, Enum_bit, Prprp -} decoding_method; - -extern decoding_method dec_method; /* Decoding method to use */ - -extern int ldpc_table; /* Trace option, 2 for a table of decoding details */ -extern int block_no; /* Number of current block, from zero */ - -extern int max_iter; /* Maximum number of iteratons of decoding to do */ -extern char *gen_file; /* Generator file for Enum_block and Enum_bit */ - - -/* PROCEDURES RELATING TO DECODING METHODS. */ - -void enum_decode_setup (void); -unsigned enum_decode (double *, char *, double *, int); - -void prprp_decode_setup (void); -unsigned prprp_decode -(mod2sparse *, double *, char *, char *, double *); - -void initprp (mod2sparse *, double *, char *, double *); -void iterprp (mod2sparse *, double *, char *, double *); diff --git a/lib/ldpc/decode-detail.html b/lib/ldpc/decode-detail.html deleted file mode 100755 index f829feba..00000000 --- a/lib/ldpc/decode-detail.html +++ /dev/null @@ -1,99 +0,0 @@ -<HTML><HEAD> - -<TITLE> Detailed Decoding Trace Information </TITLE> - - -</HEAD><BODY> - -<H1> Detailed Decoding Trace Information </H1> - -The <B>-T</B> option to <A HREF="decoding.html#decode"><TT>decode</TT></A> -causes a detailed trace of information on the process of decoding to -be written to standard output, in a multi-column format, with the first -line containing the headers for each column. This format is suitable -for reading into S-Plus or R. - -The first column is always the number of the block being decoded; -several lines may be output for each block. The other columns vary -with the decoding method used, as described below. - - -<H2>Enum-bit and Enum-block decoding methods</H2> - -For source messages with <I>K</I> bits, 2<SUP><I>K</I></SUP> lines are output -for each block, containing the following information: -<BLOCKQUOTE> -<TABLE> -<tr align="left" valign="top"> - <td> <B>block</B> </td> - <td>The number of the block, from zero</td></tr> -<tr align="left" valign="top"> - <td> <B>decoding</B> </td> - <td>A possible decoding for the message bits, expressed as a hexadecimal - number. The other bits are determined by the message bits.</td></tr> -<tr align="left" valign="top"> - <td> <B>likelihood</B> </td> - <td>The likelihood for this decoding (ie, the probability of obtaining - the data received if this was the message sent).</td></tr> -</TABLE> -</BLOCKQUOTE> - -For these methods, the number of "iterations" (output with the -<B>-t</B> option) is always 2<SUP><I>K</I></SUP>. - - -<H2>Prprp decoding method</H2> - -Each block results in one line of output for the initial state (based -on individual likelihood ratios), and one line for each subsequent -iteration, containing the following information: -<BLOCKQUOTE> -<TABLE> -<tr align="left" valign="top"> - <td> <B>block</B> </td> - <td>The number of the block, from zero</td></tr> -<tr align="left" valign="top"> - <td> <B>iter</B> </td> - <td>The number of an iteration, zero for the initial state.</td></tr> -<tr align="left" valign="top"> - <td> <B>changed</B> </td> - <td>The number of bits in the decoding that differ from the bit that would - be chosen based just on the likelihood ratio for that bit. Bits whose - likelihood ratios are exactly one contribute 0.5 to this - count. (Likelihood ratios of exactly one can arise when the output - of an AWGN channel rounds to exactly 0.00.)</td></tr> -<tr align="left" valign="top"> - <td> <B>perrs</B> </td> - <td>The number of parity check errors in the current tentative - decoding.</td></tr> -<tr align="left" valign="top"> - <td> <B>loglik</B> </td> - <td>The log likelihood of the current tentative decoding.</td></tr> -<tr align="left" valign="top"> - <td> <B>Eperrs</B> </td> - <td>The expected number of parity check errors in a decoding found - by randomly picking a value for each bit, independently, according - to the current bit probabilities.</td></tr> -<tr align="left" valign="top"> - <td> <B>Eloglik</B> </td> - <td>The expected log likelihood of a decoding found by randomly picking - a value for each bit, independently, according to the current bit - probabilities. - </td></tr> -<tr align="left" valign="top"> - <td> <B>entropy</B> </td> - <td>The entropy (in bits) of the distribution defined by the current bit - probablities, assumed to apply to bits independently.</td></tr> -</TABLE> -</BLOCKQUOTE> - -The number of "iterations" (output with the <B>-t</B> option) is -the obvious count of probability propagation iterations. The -initial state does not count as an iteration. - -<HR> - -<A HREF="decoding.html">Back to decoding documentation</A><BR> -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/decode.c b/lib/ldpc/decode.c deleted file mode 100755 index ec04f2e4..00000000 --- a/lib/ldpc/decode.c +++ /dev/null @@ -1,384 +0,0 @@ -/* DECODE.C - Decode blocks of received data. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "rand.h" -#include "alloc.h" -#include "blockio.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "channel.h" -#include "rcode.h" -#include "check.h" -#include "dec.h" - - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char *pchk_file, *rfile, *dfile, *pfile; - char **meth; - FILE *rf, *df, *pf; - - char *dblk, *pchk; - double *lratio; - double *bitpr; - - double *awn_data; /* Places to store channel data */ - int *bsc_data; - - unsigned iters; /* Unsigned because can be huge for enum */ - double tot_iter; /* Double because can be huge for enum */ - double chngd, tot_changed; /* Double because can be fraction if lratio==1*/ - - int tot_valid; - char junk; - int valid; - - int i, j, k; - - /* Look at initial flag arguments. */ - - ldpc_table = 0; - blockio_flush = 0; - - while (argc>1) - { - if (strcmp(argv[1],"-t")==0) - { if (ldpc_table!=0) usage(); - ldpc_table = 1; - } - else if (strcmp(argv[1],"-T")==0) - { if (ldpc_table!=0) usage(); - ldpc_table = 2; - } - else if (strcmp(argv[1],"-f")==0) - { if (blockio_flush!=0) usage(); - blockio_flush = 1; - } - else - { break; - } - - argc -= 1; - argv += 1; - } - - /* Look at arguments up to the decoding method specification. */ - - if (!(pchk_file = argv[1]) - || !(rfile = argv[2]) - || !(dfile = argv[3])) - { usage(); - } - - if (argv[4]==0 || argv[5]==0) usage(); - - k = channel_parse(argv+4,argc-4); - if (k<=0) - { pfile = argv[4]; - k = channel_parse(argv+5,argc-5); - if (k<=0) usage(); - meth = argv+5+k; - } - else - { pfile = 0; - meth = argv+4+k; - } - - /* Look at the specification of the decoding method, which starts at meth and - continues to the end of the command line (marked by a zero pointer). */ - - if (!meth[0]) usage(); - - if (strcmp(meth[0],"prprp")==0) - { dec_method = Prprp; - if (!meth[1] || sscanf(meth[1],"%d%c",&max_iter,&junk)!=1 || meth[2]) - { usage(); - } - } - else if (strcmp(meth[0],"enum-block")==0) - { dec_method = Enum_block; - if (!(gen_file = meth[1]) || meth[2]) usage(); - } - else if (strcmp(meth[0],"enum-bit")==0) - { dec_method = Enum_bit; - if (!(gen_file = meth[1]) || meth[2]) usage(); - } - else - { usage(); - } - - /* Check that we aren't overusing standard input or output. */ - - if ((strcmp(pchk_file,"-")==0) - + (strcmp(rfile,"-")==0) > 1) - { fprintf(stderr,"Can't read more than one stream from standard input\n"); - exit(1); - } - if ((ldpc_table>0) - + (strcmp(dfile,"-")==0) - + (pfile!=0 && strcmp(pfile,"-")==0) > 1) - { fprintf(stderr,"Can't send more than one stream to standard output\n"); - exit(1); - } - - /* Read parity check file. */ - - read_pchk(pchk_file); - - if (N<=M) - { fprintf(stderr, - "Number of bits (%d) should be greater than number of checks (%d)\n",N,M); - exit(1); - } - - /* Open file of received data. */ - - rf = open_file_std(rfile,"r"); - if (rf==NULL) - { fprintf(stderr,"Can't open file of received data: %s\n",rfile); - exit(1); - } - - /* Create file for decoded data. */ - - df = open_file_std(dfile,"w"); - if (df==NULL) - { fprintf(stderr,"Can't create file for decoded data: %s\n",dfile); - exit(1); - } - - /* Create file for bit probabilities, if specified. */ - - if (pfile) - { pf = open_file_std(pfile,"w"); - if (pf==NULL) - { fprintf(stderr,"Can't create file for bit probabilities: %s\n",pfile); - exit(1); - } - } - - /* Allocate space for data from channel. */ - - switch (channel) - { case BSC: - { bsc_data = chk_alloc (N, sizeof *bsc_data); - break; - } - case AWGN: case AWLN: - { awn_data = chk_alloc (N, sizeof *awn_data); - break; - } - default: - { abort(); - } - } - - /* Allocate other space. */ - - dblk = chk_alloc (N, sizeof *dblk); - lratio = chk_alloc (N, sizeof *lratio); - pchk = chk_alloc (M, sizeof *pchk); - bitpr = chk_alloc (N, sizeof *bitpr); - - /* Print header for summary table. */ - - if (ldpc_table==1) - { printf(" block iterations valid changed\n"); - } - - /* Do the setup for the decoding method. */ - - switch (dec_method) - { case Prprp: - { prprp_decode_setup(); - break; - } - case Enum_block: case Enum_bit: - { enum_decode_setup(); - break; - } - default: abort(); - } - - /* Read received blocks, decode, and write decoded blocks. */ - - tot_iter = 0; - tot_valid = 0; - tot_changed = 0; - - for (block_no = 0; ; block_no++) - { - /* Read block from received file, exit if end-of-file encountered. */ - - for (i = 0; i<N; i++) - { int c; - switch (channel) - { case BSC: - { c = fscanf(rf,"%1d",&bsc_data[i]); - break; - } - case AWGN: case AWLN: - { c = fscanf(rf,"%lf",&awn_data[i]); - break; - } - default: abort(); - } - if (c==EOF) - { if (i>0) - { fprintf(stderr, - "Warning: Short block (%d long) at end of received file ignored\n",i); - } - goto done; - } - if (c<1 || channel==BSC && bsc_data[i]!=0 && bsc_data[i]!=1) - { fprintf(stderr,"File of received data is garbled\n"); - exit(1); - } - } - - /* Find likelihood ratio for each bit. */ - - switch (channel) - { case BSC: - { for (i = 0; i<N; i++) - { lratio[i] = bsc_data[i]==1 ? (1-error_prob) / error_prob - : error_prob / (1-error_prob); - } - break; - } - case AWGN: - { for (i = 0; i<N; i++) - { lratio[i] = exp(2*awn_data[i]/(std_dev*std_dev)); - } - break; - } - case AWLN: - { for (i = 0; i<N; i++) - { double e, d1, d0; - e = exp(-(awn_data[i]-1)/lwidth); - d1 = 1 / ((1+e)*(1+1/e)); - e = exp(-(awn_data[i]+1)/lwidth); - d0 = 1 / ((1+e)*(1+1/e)); - lratio[i] = d1/d0; - } - break; - } - default: abort(); - } - - /* Try to decode using the specified method. */ - - switch (dec_method) - { case Prprp: - { iters = prprp_decode (H, lratio, dblk, pchk, bitpr); - break; - } - case Enum_block: case Enum_bit: - { iters = enum_decode (lratio, dblk, bitpr, dec_method==Enum_block); - break; - } - default: abort(); - } - - /* See if it worked, and how many bits were changed. */ - - valid = check(H,dblk,pchk)==0; - - chngd = changed(lratio,dblk,N); - - tot_iter += iters; - tot_valid += valid; - tot_changed += chngd; - - /* Print summary table entry. */ - - if (ldpc_table==1) - { printf ("%7d %10f %d %8.1f\n", - block_no, (double)iters, valid, (double)chngd); - /* iters is printed as a double to avoid problems if it's >= 2^31 */ - fflush(stdout); - } - - /* Write decoded block. */ - - blockio_write(df,dblk,N); - - /* Write bit probabilities, if asked to. */ - - if (pfile) - { for (j = 0; j<N; j++) - { fprintf(pf," %.5f",bitpr[j]); - } - fprintf(pf,"\n"); - } - - /* Check for errors when writing. */ - - if (ferror(df) || pfile && ferror(pf)) - { break; - } - } - - /* Finish up. */ - -done: - fprintf(stderr, - "Decoded %d blocks, %d valid. Average %.1f iterations, %.0f%% bit changes\n", - block_no, tot_valid, (double)tot_iter/block_no, - 100.0*(double)tot_changed/(N*block_no)); - - if (ferror(df) || fclose(df)!=0) - { fprintf(stderr,"Error writing decoded blocks to %s\n",dfile); - exit(1); - } - - if (pfile) - { if (ferror(pf) || fclose(pf)!=0) - { fprintf(stderr,"Error writing bit probabilities to %s\n",dfile); - exit(1); - } - } - - exit(0); -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - - -void usage(void) -{ fprintf(stderr,"Usage:\n"); - fprintf(stderr, -" decode [ -f ] [ -t | -T ] pchk-file received-file decoded-file [ bp-file ] channel method\n"); - channel_usage(); - fprintf(stderr, -"Method: enum-block gen-file | enum-bit gen-file | prprp [-]max-iterations\n"); - exit(1); -} diff --git a/lib/ldpc/decoding.html b/lib/ldpc/decoding.html deleted file mode 100755 index 0e9538ac..00000000 --- a/lib/ldpc/decoding.html +++ /dev/null @@ -1,342 +0,0 @@ -<HTML><HEAD> - -<TITLE> Decoding Received Blocks </TITLE> - - -</HEAD><BODY> - -<H1> Decoding Received Blocks </H1> - -Transmitted codewords are decoded from the received data on the basis -of the <I>likelihood</I> of the possible codewords, which is the -probability of receiving the data that was actually received if the -codeword is question were the one that was sent. This software -presently deals only with memoryless channels, in which the noise is -independent from bit to bit. For such a channel, the likelihood -factorizes into a product of likelihoods for each bit. - -For decoding purposes, all that matters is the relative likelihood -for a bit to be 1 versus 0. This is captured by the <I>likelihood -ratio</I> in favour of a 1, which is P(data | bit is 1) / P(data | -bit is 0). - -<P>For a Binary Symmetric Channel with error probability <I>p</I>, -the likelihood ratio in favour of a 1 bit is as follows: -<BLOCKQUOTE> - If the received data was +1: (1-<I>p</I>) / <I>p</I><BR> - If the received data was -1: <I>p</I> / (1-<I>p</I>) -</BLOCKQUOTE> -For an Additive White Gaussian Noise channel, with signals of +1 for a 1 bit -and or -1 for a 0 bit, and with noise standard deviation <I>s</I>, the -likelihood ratio in favour of a 1 bit when data <I>y</I> was received is -<BLOCKQUOTE> - exp ( 2y / s<SUP><SMALL>2</SMALL></SUP> ) -</BLOCKQUOTE> -For an Additive White Logistic Noise channel, the corresponding -likelihood ratio is -<I>d</I><SUB><SMALL>1</SMALL></SUB>/<I>d</I><SUB><SMALL>0</SMALL></SUB>, -where -<I>d</I><SUB><SMALL>1</SMALL></SUB>=<I>e</I><SUB><SMALL>1</SMALL></SUB> -/ (1+<I>e</I><SUB><SMALL>1</SMALL></SUB>)<SUP><SMALL>2</SMALL></SUP> and -<I>d</I><SUB><SMALL>0</SMALL></SUB>=<I>e</I><SUB><SMALL>0</SMALL></SUB> -/ (1+<I>e</I><SUB><SMALL>0</SMALL></SUB>)<SUP><SMALL>2</SMALL></SUP>, -with <I>e</I><SUB><SMALL>1</SMALL></SUB>=exp(-(<I>y</I>-1)/<I>w</I>) and -<I>e</I><SUB><SMALL>0</SMALL></SUB>=exp(-(<I>y</I>+1)/<I>w</I>). -<BLOCKQUOTE> </BLOCKQUOTE> - -<P>It is usual to consider codewords to be equally likely <I>a -priori</I>. This is reasonable if the source messages are all equally -likely (any source redundancy being ignored, or remove by a -preliminary data compression stage), provided that the mapping from -source messages to codewords is onto. Decoding can then be done using -only the parity check matrix defining the codewords, without reference -to the generator matrix defining the mapping from source messages to -codewords. Note that the condition that this mapping be onto isn't -true with this software in the atypical case where the code is defined -by a parity check matrix with redundant rows; see the discussion of <A -HREF="dep-H.html">linear dependence in parity check matrices</A>. -This minor complication is mostly ignored here, except by the exhaustive -enumeration decoding methods. - -<P>Assuming equal <I>a priori</I> probabilities for codewords, the -probability of correctly decoding an entire codeword is minimized by -picking the codeword with the highest likelihood. One might instead -wish to decode each bit to the value that is most probable. This -minimizes the bit error rate, but is not in general guaranteed to lead -a decoding for each block to the most probable complete codeword; -indeed, the decoding may not be a codeword at all. Minimizing the bit -error rate seems nevertheless to be the most sensible objective, -unless block boundaries have some significance in a wider context. - -<P>Optimal decoding by either criterion is infeasible for general -linear codes when messages are more than about 20 or 30 bits in -length. The fundamental advantage of Low Density Parity Check codes -is that good (though not optimal) decodings can be obtained by methods -such as probability propagation, described next. - -<A NAME="prprp"><H2>Decoding by probability propagation</H2></A> - -<P>The probability propagation algorithm was originally devised by -Robert Gallager in the early 1960's and later reinvented by David -MacKay and myself. It can be seen as an instance of the sum-product -algorithm for inference on factor graphs, and as an instance of belief -propagation in probabilistic networks. See the <A -HREF="refs.html">references</A> for details. Below, I give a fairly -intuitive description of the algorithm. - -<P>The algorithm uses only the parity check matrix for the code, whose -columns correspond to codeword bits, and whose rows correspond to -parity checks, and the likelihood ratios for the bits derived from the -data. It aims to find the probability of each bit of the transmitted -codeword being 1, though the results of the algorithm are in general -only approximate. - -<P>The begin, information about each bit of the codeword derived from -the received data for that bit alone is expressed as a <I>probability -ratio</I>, the probability of the bit being 1 divided by the -probability of the bit being 0. This probability ratio is equal to -the likelihood ratio (see above) for that bit, since 0 and 1 are -assumed to be equally likely <I>a priori</I>. As the algorithm -progresses, these probability ratios will be modified to take account -of information obtained from other bits, in conjunction with the -requirement that the parity checks be satisfied. To avoid double -counting of information, for every bit, the algorithm maintains a -separate probability ratio for each parity check that that bit -participates in, giving the probability for that bit to be 1 versus 0 -based only on information derived from <I>other</I> parity checks, -along with the data received for the bit. - -<P>For each parity check, the algorithm maintains separate -<I>likelihood ratios</I> (analogous to, but distinct from, the -likelihood ratios based on received data), for every bit that -participates in that parity check. These ratios give the probability -of that parity check being satisfied if the bit in question is 1 -divided by the probability of the check being satisfied if the bit is -0, taking account of the probabilities of each of the <I>other</I> -bits participating in this check being 1, as derived from the -probability ratios for these bits with respect to this check. - -<P>The algorithm alternates between recalculating the likelihood -ratios for each check, which are stored in the <B>lr</B> fields of the -parity check matrix entries, and recalculating the probability ratios -for each bit, which are stored in the <B>pr</B> fields of the entries -in the sparse matrix representation of the parity check matrix. (See -the documentation on <A HREF="mod2sparse.html#rep">representation of -sparse matrices</A> for details on these entries.) - -<P>Recalculating the likelihood ratio for a check with respect to some -bit may appear time consuming, requiring that all possible -combinations of values for the other bits participating in the check -be considered. Fortunately, there is a short cut. One can calculate -<BLOCKQUOTE> - <I>t</I> - = product of [ 1 / (1+<I>p<SUB><SMALL>i</SMALL></SUB></I>) - - <I>p<SUB><SMALL>i</SMALL></SUB></I> / - (1+<I>p<SUB><SMALL>i</SMALL></SUB></I>) ] - = product of [ 2 / (1+<I>p<SUB><SMALL>i</SMALL></SUB></I>) - 1 ] -</BLOCKQUOTE> -where the product is over the probability ratios -<I>p<SUB><SMALL>i</SMALL></SUB></I> for the other bits participating -in this check. Factor <I>i</I> in this product is equal to probability -of bit <I>i</I> being 0 minus the probability that it is 1. The terms -in the expansion of this product (in the first form above) correspond to -possible combinations of values for the other bits, with the result that -<I>t</I> will be the probability of the check being satisfied if the bit -in question is 0 minus the probability if the bit in question is 1. The -likelihood ratio for this check with respect to the bit in question can then -be calculated as (1-<I>t</I>)/(1+<I>t</I>). - -<P>For a particular check, the product above differs for different -bits, with respect to which we wish to calculate a likelihood ratio, -only in that for each bit the factor corresponding to that bit is left -out. We can calculate all these products easily by ordering the bits -arbitrarily, computing running products of the factor for the first -bit, the factors for the first two bits, etc., and also running -products of the factor for the last bit, the factors for the last two -bits, etc. Multiplying the running product of the factors up to -<I>i</I>-1 by the running product of the factors from <I>i</I>+1 on -gives the product needed for bit <I>i</I>. The second form of the -factors above is used, as it requires less computation, and is still -well defined even if some ratios are infinite. - -<P>To recalculate the probability ratio for a bit with respect to a -check, all that is need is to multiply together the likelihood ratio -for this bit derived from the received data (see above), and the -current values of the likelihood ratios for all the <I>other</I> -checks that this bit participates in, with respect to this bit. To -save time, these products are computed by combining forward and -backward products, similarly to the method used for likelihood ratios. - -<P>By including likelihood ratios from all checks, a similar -calculation produces the current probability ratio for the bit to be 1 -versus 0 based on all information that has propagated to the bit so -far. This ratio can be thresholded at one to produce the current best -guess as to whether this bit is a 1 or a 0. - -<P>The hope is that this algorithm will eventually converge to a state -where these bit probabilities give a near-optimal decoding. This is -does not always occur, but the algorithm behaves well enough to -produce very good results at rates approaching (though not yet -reaching) the theoretical Shannon limit. - - -<P><A NAME="decode"><HR><B>decode</B>: Decode blocks of received data -into codewords. - -<BLOCKQUOTE><PRE> -decode [ -f ] [ -t | -T ] <I>pchk-file received-file decoded-file</I> [ <I>bp-file</I> ] <I>channel method</I> -</PRE> -<BLOCKQUOTE> -where <TT><I>channel</I></TT> is one of: -<BLOCKQUOTE><PRE> -bsc <I>error-probability</I> - -awgn <I>standard-deviation</I> - -awln <I>width</I> -</PRE></BLOCKQUOTE> -and <TT><I>method</I></TT> is one of: -<BLOCKQUOTE><PRE> -enum-block <TT><I>gen-file</I></TT> - -enum-bit <TT><I>gen-file</I></TT> - -prprp <TT>[-]<I>max-iterations</I></TT> -</PRE></BLOCKQUOTE> -</BLOCKQUOTE> -</BLOCKQUOTE> - -<P>Decodes the blocks in <TT><I>received-file</I></TT>, which are -assumed to be have been received through the specified channel. The -results written to <TT><I>decoded-file</I></TT> are the specified -decoding method's guesses as to what bits were sent through the -channel, given what was received. The probability of each bit being a -1, as judged by the decoding method being used, is written to -<TT><I>bp-file</I></TT>, if given. - -<P>A newline is output at the end of each block written to -<TT><I>decoded-file</I></TT> and <TT><I>bp-file</I></TT>. Newlines in -<TT><I>received-file</I></TT> are ignored. A warning is displayed on -standard error if the number of bits in <TT><I>received-file</I></TT> -is not a multiple of the block length. - -<P>A summary is displayed on standard error, giving the total number -of blocks decoded, the number of blocks that decoded to valid -codewords, the average number of iterations of the decoding algorithm -used, and the percent of bits that were changed from the values one -would guess for them based just on their individual likelihood ratios. - -<P>If the <B>-t</B> option is given, a line of information regarding each block -decoded is written to standard output, preceded by a line of headers. -The information for each block is as follows: -<BLOCKQUOTE> -<TABLE> -<tr align="left" valign="top"> - <td> <B>block</B> </td> - <td>The number of the block, from zero</td></tr> -<tr align="left" valign="top"> - <td> <B>iterations</B> </td> - <td>The number of "iterations" used in decoding. What exactly an iteration - is depends on the decoding method used (see - <A HREF="decode-detail.html">here</A>).</td></tr> -<tr align="left" valign="top"> - <td> <B>valid</B> </td> - <td>Has the value 1 if the decoding is a valid codeword, 0 if not.</td></tr> -<tr align="left" valign="top"> - <td> <B>changed</B> </td> - <td>The number of bits in the decoding that differ from the bit that would - be chosen based just on the likelihood ratio for that bit. Bits whose - likelihood ratios are exactly one contribute 0.5 to this count.</td></tr> -</TABLE> -</BLOCKQUOTE> -The file produced is is suitable for -reading into the S-Plus or R statistics packages, with a command such as -<BLOCKQUOTE><PRE> -data <- read.table(<I>file</I>,header=T) -</PRE></BLOCKQUOTE> - -<P>If instead the <B>-T</B> option is given, detailed information on -the process of decoding each block will be written to standard output. -For a description, see the <A HREF="decode-detail.html">documentation -on detailed decoding trace information</A>. - -<P>The type of channel that is assumed is specified after the file -name arguments. This may currently be either <TT>bsc</TT> (or -<TT>BSC</TT>) for the Binary Symmetric Channel, or <TT>awgn</TT> (or -<TT>AWGN</TT>) for the Additive White Gaussian Noise channel, or -<TT>awln</TT> (or <TT>AWLN</TT>) for the Additive White Logistic Noise -channel. The channel type is followed by an argument specifying the -assumed characteristics of the channel, as follows: -<BLOCKQUOTE> -<P>BSC: The probability that a bit will be flipped by noise - ie, the - probability that the bit received is an error. - -<P>AWGN: The standard deviation of the Gaussian noise added to the - encodings of the bits. - -<P>AWLN: The width parameter of the logistic distribution for the noise - that is added to the encodings of the bits. -</BLOCKQUOTE> -See the description of <A HREF="channel.html">channel transmission</A> -for more about these channels. - -<P>Following the channel specification is a specification of the -decoding method to use. The <TT>enum-block</TT> and <TT>enum-bit</TT> -methods find the optimal decoding by exhaustive enumeration of -codewords derived from all possible source messages. They differ in -that <TT>enum-block</TT> decodes to the most likely codeword, whereas -<TT>enum-bit</TT> decodes to the bits that are individually most -probable. These methods require that a file containing a -representation of a generator matrix be given, to allow enumeration of -codewords. If the parity check matrix has no redundant rows, any -valid generator matrix will give the same decoding (except perhaps if -there is a tie). If redundant rows exist, the generator matrix should -specify the same set of message bits as the generator matrix that was -used for the actual encoding, since the redundancy will lead to some -codeword bits being fixed at zero (see <A HREF="dep-H.html">linear -dependence in parity check matrices</A>). - -<P>The <TT>prprp</TT> decoding method decodes using <A -HREF="#prprp">probability propagation</A>. The maximum number of -iterations of probability propagation to do is given following -<TT>prprp</TT>. If a minus sign precedes this number, the maximum -number of iterations is always done. If no minus sign is present, the -algorithm stops once the tentative decoding, based on bit-by-bit -probabilities, is a valid codeword. Note that continuing to the -maximum number of iterations will usually result in -at least slightly different bit probabilities (written to -<TT><I>bp-file</I></TT> if specified), and could conceivably change -the decoding compared to stopping at the first valid codeword, or -result in a failure to decode to a valid codeword even though one was -found earlier. - -<P>If the <B>-f</B> option is given, output to <TT><I>decoded-file</I></TT> -is flushed after each block. This allows one to use decode as a server, -reading blocks to decode from a named pipe, and writing the decoded block -to another named pipe. - - -<P><A NAME="extract"><HR><B>extract</B>: Extract the message bits from a block. - -<BLOCKQUOTE><PRE> -extract <I>gen-file decoded-file extracted-file</I> -</PRE></BLOCKQUOTE> - -<P>Given a file of codewords in <TT><I>decoded-file</I></TT> (usually, -decoded blocks output by <A HREF="#decode"><TT>decode</TT></A>), and a -generator matrix from <TT><I>gen-file</I></TT> (needed only to -determine where the message bits are located in a codeword), this -program writes the message bits extracted from these codewords to the -file <TT><I>extracted-file</I></TT>. - -<P>A newline is output at the end of each block written to -<TT><I>extracted-file</I></TT>. Newlines in -<TT><I>decoded-file</I></TT> are ignored. A warning is displayed on -standard error if the number of bits in <TT><I>decoded-file</I></TT> -is not a multiple of the block length. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/dep-H.html b/lib/ldpc/dep-H.html deleted file mode 100755 index b80b2a5c..00000000 --- a/lib/ldpc/dep-H.html +++ /dev/null @@ -1,85 +0,0 @@ -<HTML><HEAD> - -<TITLE> Linear Dependence in Parity Check Matrices </TITLE> - -</HEAD><BODY> - - -<H1> Linear Dependence in Parity Check Matrices </H1> - -<P>If a code is specified by means of a <I>M</I> by <I>N</I> parity -check matrix, <B>H</B>, in which some rows are linearly dependent - a -situation that is usually avoided - it would be possible to map more -than the usual <I>K=N-M</I> message bits into a codeword, since one or -more rows of <B>H</B> could have been deleted without affecting which -bit vectors are codewords. - -<P>However, this software does not increase the number of message bits -in this case, but instead produces a generator matrix in which some -rows are all zero, which will cause some bits of the codeword to -always be zero, regardless of the source message. Referring to the <A -HREF="encoding.html#gen-rep">description of generator matrix -representations</A>, this is accomplished by partially computing -what would normally be <B>A</B><SUP><SMALL>-1</SMALL></SUP> (for a -dense or mixed representations) or the <B>L</B> and <B>U</B> matrices -(for a sparse representation), even though singularity prevents this -computation from being carried out fully. - -<P><B>Example:</B> The parity check matrix created below is redundant, -since the 10100 row is equal to the sum of the 11000 and 01100 rows. -<UL><PRE> -<LI>make-pchk dep.pchk 4 5 0:0 0:1 1:1 1:2 2:0 2:2 3:3 3:4 -<LI>print-pchk -d dep.pchk - -Parity check matrix in dep.pchk (dense format): - - 1 1 0 0 0 - 0 1 1 0 0 - 1 0 1 0 0 - 0 0 0 1 1 - -<LI>make-gen dep.pchk dep.gen dense -Note: Parity check matrix has 1 redundant checks -Number of 1s per check in Inv(A) X B is 0.2 -<LI>print-gen dep.gen - -Generator matrix (dense representation): - -Column order (message bits at end): - - 0 1 3 2 4 - -Inv(A) X B: - - 0 - 0 - 1 - 0 -</PRE></UL> -The generator matrix above can be used to encode message blocks containing -one bit. This message bit is copied unchanged to the last bit (numbered 4) -of the codeword, and the first four bits of the codeword are set by multiplying -this message bit (seen as a vector of length one) by -<B>A</B><SUP><SMALL>-1</SMALL></SUP><B>B</B>, shown above, and then -storing the results in positions given by the column ordering. -The result is that bit 3 of the codeword produced is -also set to the message bit, and bits 0, 1, and 2 are set to zero. - -<P>Which bits are used for message bits, and which bits are fixed at -zero, depends on arbitrary choices in the algorithm, which may differ -from one encoding method to another. No attempt is made to make the -best choice. - -<P>Note that codeword bits that are always zero can arise even when <B>H</B> -does not have linearly dependent rows. For example, if a row of <B>H</B> -has just one 1 in it, the codeword bit at that position must be zero in any -codeword. The way the software handles parity check matrices with less -than <I>M</I> independent rows is equivalent to adding additional rows -to <B>H</B> in which only one bit is 1, in order to produce <I>M</I> -independent checks. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/distrib.c b/lib/ldpc/distrib.c deleted file mode 100755 index 879c54ad..00000000 --- a/lib/ldpc/distrib.c +++ /dev/null @@ -1,188 +0,0 @@ -/* DISTRIB.C - Procedures for handling distributions over numbers. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal and Peter Junteng Liu. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> -#include <string.h> - -#include "alloc.h" -#include "distrib.h" - - -/* CREATE A DISTRIBUTION AS SPECIFIED IN A STRING. Space for the distribution - is allocated; the string is not freed. - - The string must consist either of a single positive integer, representing - the distribution over just that number, or have a form such as the - following: - - 5x2/3.5x1/1.5x4 - - This specifies a distribution over 3 numbers, 2, 1, and 4, specified by - the second number in each pair, with proportions of 0.5, 0.35, and 0.15, - respectively, specified by the first number in each pair. The actual - proportions are found by dividing the first number in each pair by the sum - of these numbers. - - The distrib type represents the distribution list. It stores a pointer to - an array of distrib_entry elements along with the length of this array. - Each distrib_entry contains a (number,proportion) pair. -*/ - -distrib *distrib_create -( char *c /* String describing distribution over numbers */ -) -{ - distrib *d; - char *str, *tstr; - int i, n, scan_num, size; - double prop, sum; - char junk; - - /* Check for special case of a single number. */ - - if (sscanf(c,"%d%c",&n,&junk)==1 && n>0) - { tstr = chk_alloc ( (int)(4.1+log10(n)), sizeof(*tstr)); - sprintf(tstr,"1x%d",n); - d = distrib_create(tstr); - free(tstr); - return d; - } - - /* Initial scan of string for size and proper usage. */ - - str = c; - size = 0; - sum = 0; - - d = chk_alloc(1, sizeof *d); - - for (;;) - { - scan_num = sscanf(str, "%lgx%d%c", &prop, &n, &junk); - - if ((scan_num!=2 && scan_num!=3) || prop<=0 || n<=0) - { return 0; - } - if (scan_num==3 && junk!='/') - { return 0; - } - - size += 1; - sum += prop; - - if (scan_num==2) - { break; - } - else - { str = (char*)strchr(str, '/') + 1; - } - } - - /* Allocate memory for the list and fill it in */ - - d->size = size; - d->list = chk_alloc (size, sizeof(distrib_entry)); - - i = 0; - str = c; - - for (;;) - { - scan_num = sscanf(str, "%lgx%d%c", &prop, &n, &junk); - - d->list[i].prop = prop/sum; - d->list[i].num = n; - i += 1; - - if (scan_num==2) - { break; - } - else if (scan_num==3) - { str = (char*)strchr(str, '/') + 1; - } - else - { abort(); - } - } - - return d; -} - - -/* FREE SPACE OCCUPIED A DISTRIBUTION LIST. */ - -void distrib_free -( distrib *d /* List to free */ -) -{ free(d->list); - free(d); -} - - -/* RETURN THE MAXIMUM NUMBER IN A DISTRIBUTION LIST. Returns 0 if the list - pointer is 0. */ - -int distrib_max -( distrib *d /* List to examine */ -) -{ - int i; - int cur; - - if (d==0) return 0; - - cur = 0; - - for (i = 1; i<d->size; i++) - { if (d->list[i].num > d->list[cur].num) - { cur = i; - } - } - - return d->list[cur].num; -} - - -/* TEST PROGRAM. */ - -#ifdef TEST_DISTRIB - -main -( int argc, - char **argv -) -{ - distrib *d; - int i, j; - - for (i = 1; i<argc; i++) - { d = distrib_create(argv[i]); - if (d==0) - { printf("Error\n\n"); - } - else - { for (j = 0; j<distrib_size(d); j++) - { printf("%.3f %d\n",distrib_prop(d,j),distrib_num(d,j)); - } - printf("\n"); - } - } - - exit(0); -} - -#endif diff --git a/lib/ldpc/distrib.h b/lib/ldpc/distrib.h deleted file mode 100755 index f3355b23..00000000 --- a/lib/ldpc/distrib.h +++ /dev/null @@ -1,49 +0,0 @@ -/* DISTRIB.H - Interface to module for handling distributions over numbers. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal and Peter Junteng Liu. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* DATA STRUCTURES USED TO STORE A DISTRIBUTION LIST. Entries in the list - * (distrib_entry) are stored in an array (distrib->list[]). */ - -typedef struct distrib_entry -{ int num; /* A positive number */ - double prop; /* Proportion for this number */ -} distrib_entry; - -typedef struct distrib -{ struct distrib_entry *list; /* The list of numbers and proportions */ - int size; /* Number of entries in the list */ -} distrib; - - -/* MACROS TO ACCESS ELEMENTS OF A DISTRIBUTION LIST. Note that indexes for - entries start at 0. */ - -#define distrib_num(d,i) \ - ((d)->list[i].num) /* The number for the i'th entry */ - -#define distrib_prop(d,i) \ - ((d)->list[i].prop) /* The i'th entry's proportion [probability] */ - -#define distrib_size(d) \ - ((d)->size) /* The length of the list (integer) */ - - -/* PROCEDURES FOR DISTRIBUTION LISTS. */ - -distrib *distrib_create (char *); -void distrib_free (distrib *); - -int distrib_max(distrib *); diff --git a/lib/ldpc/enc.c b/lib/ldpc/enc.c deleted file mode 100755 index 8b4cdbde..00000000 --- a/lib/ldpc/enc.c +++ /dev/null @@ -1,173 +0,0 @@ -/* ENC.C - Encoding procedures. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -/*#include "rand.h"*/ -#include "alloc.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" -#include "enc.h" - - -/* The procedures in this module obtain the generator matrix to use for - encoding from the global variables declared in rcode.h */ - - -/* ENCODE A BLOCK USING A SPARSE REPRESENTATION OF THE GENERATOR MATRIX. */ - -void sparse_encode -( char *sblk, - char *cblk -) -{ - int i, j; - - mod2entry *e; - char *x, *y; - - x = chk_alloc (M, sizeof *x); - y = chk_alloc (M, sizeof *y); - - /* Multiply the vector of source bits by the systematic columns of the - parity check matrix, giving x. Also copy these bits to the coded block. */ - - for (i = 0; i<M; i++) x[i] = 0; - - for (j = M; j<N; j++) - { - cblk[cols[j]] = sblk[j-M]; - - if (sblk[j-M]==1) - { for (e = mod2sparse_first_in_col(H,cols[j]); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_col(e)) - { x[mod2sparse_row(e)] ^= 1; - } - } - } - - /* Solve Ly=x for y by forward substitution, then U(cblk)=y by backward - substitution. */ - - if (!mod2sparse_forward_sub(L,rows,x,y) - || !mod2sparse_backward_sub(U,cols,y,cblk)) - { - abort(); /* Shouldn't occur, even if the parity check matrix has - redundant rows */ - } - - free(x); - free(y); -} - - -/* ENCODE A BLOCK USING DENSE REPRESENTATION OF GENERATOR MATRIX. */ - -void dense_encode -( char *sblk, - char *cblk, - mod2dense *u, - mod2dense *v -) -{ - int j; - - /* Copy source bits to the systematic part of the coded block. */ - - for (j = M; j<N; j++) - { cblk[cols[j]] = sblk[j-M]; - } - - /* Multiply by Inv(A) X B to produce check bits. */ - - for (j = M; j<N; j++) - { mod2dense_set(u,j-M,0,sblk[j-M]); - } - - mod2dense_multiply(G,u,v); - - /* Copy check bits to the right places in the coded block. */ - - for (j = 0; j<M; j++) - { cblk[cols[j]] = mod2dense_get(v,j,0); - } -} - - -/* ENCODE A BLOCK USING MIXED REPRESENTATION OF GENERATOR MATRIX. */ - -void mixed_encode -( char *sblk, - char *cblk, - mod2dense *u, - mod2dense *v -) -{ - mod2entry *e; - int j; - - /* Multiply the vector of source bits by the message bit columns of the - parity check matrix. Also copy these bits to the coded block. Take - account of how columns have been reordered. */ - - mod2dense_clear(u); - - for (j = M; j<N; j++) - { - cblk[cols[j]] = sblk[j-M]; - - if (sblk[j-M]==1) - { for (e = mod2sparse_first_in_col(H,cols[j]); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_col(e)) - { (void) mod2dense_flip(u,mod2sparse_row(e),0); - } - } - } - - /* Multiply by Inv(A) to produce check bits. */ - - mod2dense_multiply(G,u,v); - - /* Copy check bits to the right places in the coded block. */ - - for (j = 0; j<M; j++) - { cblk[cols[j]] = mod2dense_get(v,j,0); - } -} - -// Wrapper for calling sparse_encode from fortran -void ldpc_encode_( -char msg[N-M], -char cdw[N] -){ - int i; - char checks[M]; - - sparse_encode(msg,cdw); - mod2sparse_mulvec (H, cdw, checks); - for (i = 0; i<M; i++) { - if( checks[i] == 1 ) { - printf("Failed to encode.\n"); - abort(); - } - } -} - diff --git a/lib/ldpc/enc.h b/lib/ldpc/enc.h deleted file mode 100755 index 083b5f52..00000000 --- a/lib/ldpc/enc.h +++ /dev/null @@ -1,19 +0,0 @@ -/* ENC.H - Interface to encoding procedures. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -void sparse_encode (char *, char *); -void dense_encode (char *, char *, mod2dense *, mod2dense *); -void mixed_encode (char *, char *, mod2dense *, mod2dense *); -void ldpc_encode_ (char *, char *); diff --git a/lib/ldpc/encode.c b/lib/ldpc/encode.c deleted file mode 100755 index f5ef7d5d..00000000 --- a/lib/ldpc/encode.c +++ /dev/null @@ -1,195 +0,0 @@ -/* ENCODE.C - Encode message blocks. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "rand.h" -#include "alloc.h" -#include "blockio.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" -#include "enc.h" - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char *source_file, *encoded_file; - char *pchk_file, *gen_file; - mod2dense *u, *v; - - FILE *srcf, *encf; - char *sblk, *cblk, *chks; - int i, n; - - /* Look at initial flag arguments. */ - - blockio_flush = 0; - - while (argc>1) - { - if (strcmp(argv[1],"-f")==0) - { if (blockio_flush!=0) usage(); - blockio_flush = 1; - } - else - { break; - } - - argc -= 1; - argv += 1; - } - - /* Look at remaining arguments. */ - - if (!(pchk_file = argv[1]) - || !(gen_file = argv[2]) - || !(source_file = argv[3]) - || !(encoded_file = argv[4]) - || argv[5]) - { usage(); - } - - if ((strcmp(pchk_file,"-")==0) - + (strcmp(gen_file,"-")==0) - + (strcmp(source_file,"-")==0) > 1) - { fprintf(stderr,"Can't read more than one stream from standard input\n"); - exit(1); - } - - /* Read parity check file */ - - read_pchk(pchk_file); - - if (N<=M) - { fprintf(stderr, - "Can't encode if number of bits (%d) not greater than number of checks (%d)\n", - N,M); - exit(1); - } - - /* Read generator matrix file. */ - - read_gen(gen_file,0,0); - - /* Allocate needed space. */ - - if (type=='d') - { u = mod2dense_allocate(N-M,1); - v = mod2dense_allocate(M,1); - } - - if (type=='m') - { u = mod2dense_allocate(M,1); - v = mod2dense_allocate(M,1); - } - - /* Open source file. */ - - srcf = open_file_std(source_file,"r"); - if (srcf==NULL) - { fprintf(stderr,"Can't open source file: %s\n",source_file); - exit(1); - } - - /* Create encoded output file. */ - - encf = open_file_std(encoded_file,"w"); - if (encf==NULL) - { fprintf(stderr,"Can't create file for encoded data: %s\n",encoded_file); - exit(1); - } - - sblk = chk_alloc (N-M, sizeof *sblk); - cblk = chk_alloc (N, sizeof *cblk); - chks = chk_alloc (M, sizeof *chks); - - /* Encode successive blocks. */ - - for (n = 0; ; n++) - { - /* Read block from source file. */ - - if (blockio_read(srcf,sblk,N-M)==EOF) - { break; - } - - /* Compute encoded block. */ - - switch (type) - { case 's': - { sparse_encode (sblk, cblk); - break; - } - case 'd': - { dense_encode (sblk, cblk, u, v); - break; - } - case 'm': - { mixed_encode (sblk, cblk, u, v); - break; - } - } - - /* Check that encoded block is a code word. */ - - mod2sparse_mulvec (H, cblk, chks); - - for (i = 0; i<M; i++) - { if (chks[i]==1) - { fprintf(stderr,"Output block %d is not a code word! (Fails check %d)\n",n,i); - abort(); - } - } - - /* Write encoded block to encoded output file. */ - - blockio_write(encf,cblk,N); - if (ferror(encf)) - { break; - } - } - -// fprintf(stderr, -// "Encoded %d blocks, source block size %d, encoded block size %d\n",n,N-M,N); - - if (ferror(encf) || fclose(encf)!=0) - { fprintf(stderr,"Error writing encoded blocks to %s\n",encoded_file); - exit(1); - } - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr, - "Usage: encode [ -f ] pchk-file gen-file source-file encoded-file\n"); - exit(1); -} diff --git a/lib/ldpc/encoding.html b/lib/ldpc/encoding.html deleted file mode 100755 index f9cb077c..00000000 --- a/lib/ldpc/encoding.html +++ /dev/null @@ -1,283 +0,0 @@ -<HTML><HEAD> - -<TITLE> Encoding Message Blocks </TITLE> - -</HEAD><BODY> - - -<H1> Encoding Message Blocks </H1> - -To use a code to send messages, we must define a mapping from a bit -vector, <B>s</B>, of length <I>K</I>, representing a source message, -to a codeword, <B>x</B>, of length <I>N</I>><I>K</I>. We will -consider only linear mappings, which can be written in the form -<B>x</B>=<B>G</B><SUP><SMALL>T</SMALL></SUP><B>s</B>, where <B>G</B> -is a <I>generator matrix</I>. For a code with parity check matrix -<B>H</B>, whose codewords satisfy <B>Hx</B>=<B>0</B>, the generator -matrix must satisfy <B>HG</B><SUP><SMALL>T</SMALL></SUP>=<B>0</B>. -This software assumes that the number of rows in the parity check -matrix, <I>M</I>, is equal to <I>N-K</I>, as would normally be the -case. - -<P>This software deals only with <I>systematic</I> encodings, in which -the <I>K</I> bits of <B>s</B> are copied unchanged to some subset of -the <I>N</i> bits of <B>x</B> (the <I>message bits</I>), and the -remaining <I>M=N-K</I> <I>check bits</I> of <B>x</B> are then set so -as to make the result a codeword. For a linear code, a systematic -encoding scheme always exists, for some choice of which bits of a -codeword are message bits. It is conventional to rearrange the order -of the bits in a codeword so that the message bits come first. The -first <I>K</I> columns of the <I>K</I> by <I>N</I> generator matrix -will then be the identity matrix. - -<P>However, this software does <I>not</I> assume that the message bits -come first, since different encoding methods prefer different -locations for the message bits. Instead, a vector of indexes of where -each message bit is located within a codeword is recorded in a file -along with a representation of the part of the generator matrix that -produces the check bits. More than one such generator matrix file can -be created for a single parity check file, in which the locations of -the message bits may be different. Decoding of a received message -into a codeword (with <A -HREF="decoding.html#decode"><TT>decode</TT></A>) does not depend on -knowing which are the message bits, though this does need to be known -in order to reconstruct the original message (with <A -HREF="decoding.html#extract"><TT>extract</TT></A>). - -<P>This software stores representations of generator matrices in files -in a format that is not human-readable (except by using the <A -HREF="#print-gen"><TT>print-gen</TT></A> program). However, these -files <I>are</I> readable on a machine with a different architecture -than they were written on. - - -<A NAME="gen-rep"><H2>Generator matrix representations</H2></A> - -<P>For simplicity of exposition, it will be assumed for the next few -paragraphs that the message bits are located at the <I>end</I> of the -codeword, so a codeword can be divided into <I>M</I> check bits, -<B>c</B>, followed by <I>K</I> message bits, <B>s</B>. - -<P>On the above assumption, the parity check matrix, <B>H</B>, can be divided -into an <I>M</I> by <I>M</I> matrix <B>A</B> occupying -the first <I>M</I> columns of <B>H</B> and an <I>M</I> by <I>K</I> matrix -<B>B</B> occupying the remaining columns of <B>H</B>. The requirement that -a codeword, <B>x</B>, satisfy all parity checks (ie, that <B>Hx</B>=<B>0</B>) -can then be written as -<BLOCKQUOTE> - <B>Ac</B> + <B>Bs</B> = <B>0</B> -</BLOCKQUOTE> -Provided that <B>A</B> is non-singular, it follows that -<BLOCKQUOTE> - <B>c</B> = <B>A</B><SUP><SMALL>-1</SMALL></SUP><B>Bs</B> -</BLOCKQUOTE> -<B>A</B> may be singular for some choices of which codeword bits are message -bits, but a choice for which <B>A</B> is non-singular always exists if the -rows of <B>H</B> are linearly independent. It is possible, however, that the -rows of <B>H</B> are not linearly independent (ie, some rows are redundant). -This is an exceptional -and not particularly interesting case, which is mostly ignored in the -descriptions below; see the discussion of <A HREF="dep-H.html">linear -dependence in parity check matrices</A> for the details. - -<P>The equation <B>c</B> = <B>A</B><SUP><SMALL>-1</SMALL></SUP><B>Bs</B> -defines what the check bits should be, but actual computation of these -check bits can be done in several ways, three of which are implemented -in this software. Each method involves a different representation of -the generator matrix. (Note that none of these methods involves the -explicit representation of the matrix <B>G</B> mentioned above.) - -<P>In the <I>dense representation</I>, the <I>M</I> by <I>K</I> matrix -<B>A</B><SUP><SMALL>-1</SMALL></SUP><B>B</B> is computed, and stored -in a dense format (see the <A HREF="mod2dense.html">dense modulo-2 -matrix package</A>). A message is encoded by multiplying the -source bits, <B>s</B>, by this matrix to obtain the required check bits. - -<P>In the <I>mixed representation</I>, the <I>M</I> by <I>M</I> matrix -<B>A</B><SUP><SMALL>-1</SMALL></SUP> is computed and stored in a dense -format, and the <I>M</I> by <I>K</I> matrix <B>B</B>, the right -portion of the parity check matrix, is also stored, in a sparse format -(see the <A HREF="mod2sparse.html">sparse modulo-2 matrix package</A>). -To encode a message, the source vector <B>s</B> is first multiplied on -the left by <B>B</B>, an operation which can be done very quickly if -<B>B</B> is sparse (as it will be for LDPC codes). The result is then -multiplied on the left by <B>A</B><SUP><SMALL>-1</SMALL></SUP>. If -<I>M</I><<I>K</I>, the total time may be less than when using the -dense representation above. - -<P>The <I>sparse representation</I> goes further, and avoids -explicitly computing <B>A</B><SUP><SMALL>-1</SMALL></SUP>, which tends -to be dense even if <B>H</B> is sparse. Instead, a <I>LU -decomposition</I> of <B>A</B> is found, consisting of a lower -triangular matrix <B>L</B> and an upper triangular matrix <B>U</B> for -which <B>LU</B>=<B>A</B>. The effect of multiplying <B>Bs</B>=<B>z</B> by -<B>A</B><SUP><SMALL>-1</SMALL></SUP> can then be obtained by -<BLOCKQUOTE> - Solving <B>Ly</B>=<B>z</B> for <B>y</B> using forward substitution.<BR> - Solving <B>Uc</B>=<B>y</B> for <B>c</B> using backward substitution. -</BLOCKQUOTE> -Both of these operations will be fast if <B>L</B> and <B>U</B> are -sparse. Heuristics are used to try to achieve this, by rearranging the -rows and columns of <B>H</B> in the process of selecting <B>A</B> and -finding its LU decomposition. - - -<P><A NAME="make-gen"><HR><B>make-gen</B>: Make a generator matrix from -a parity check matrix. - -<BLOCKQUOTE><PRE> -make-gen <I>pchk-file gen-file method</I> -</PRE> -<BLOCKQUOTE> -where <TT><I>method</I></TT> is one of the following: -<BLOCKQUOTE><PRE> -sparse [ first | mincol | minprod ] [ <I>abandon-num abandon-when</I> ] - -dense [ <I>other-gen-file </I> ] - -mixed [ <I>other-gen-file </I> ] -</PRE></BLOCKQUOTE> -</BLOCKQUOTE> -</BLOCKQUOTE> - -<P>Finds a generator matrix for the code whose parity check matrix is -in <TT><I>pchk-file</I></TT>, and writes a representation of this -generator matrix to <TT><I>gen-file</I></TT>. The remaining arguments -specify what representation of the generator matrix is to be used (see -the <A HREF="#gen-rep">description above</A>), and the method to be -used in finding it. A message regarding the density of 1s in the -resulting representation is displayed on standard error. For a sparse -representation, a smaller number of 1s will produce faster encoding. - -<P>All representations include a specification for how the columns of -the parity check matrix should be re-ordered so that the message bits -come last. References to columns of the parity check matrix below -refer to their order after this reordering. For the <I>dense</I> and -<I>mixed</I> representations, an <TT><I>other-gen-file</I></TT> may be -specified, in which case the ordering of columns will be the same as -the ordering stored in that file (which must produce a non-singular -<B>A</B> matrix; redundant rows of <B>H</B> are not allowed with this -option). Otherwise, <TT>make-gen</TT> decides on an appropriate -ordering of columns itself. Note that the column rearrangement is -recorded as part of the representation of the generator matrix; the -parity check matrix as stored in its file is not altered. - -<P>The <I>dense</I> representation consists of a dense representation -of the matrix <B>A</B><SUP><SMALL>-1</SMALL></SUP><B>B</B>, where -<B>A</B> is the matrix consisting of the first <I>M</I> columns (after -reordering) of the parity check matrix, and <B>B</B> is the remaining -columns. If <B>H</B> contains redundant rows, there is an additional -reordering of columns of <B>A</B> in order create the same effect as -if the redundant rows came last. - -<P>The <I>mixed</I> representation consists of a dense representation -of the matrix <B>A</B><SUP><SMALL>-1</SMALL></SUP>, where <B>A</B> is -the matrix consisting of the first <I>M</I> columns (after reordering) -of the parity check matrix. The remaining columns of the parity check -matrix, making up the matrix <B>B</B>, are also part of the -representation, but are not written to <TT><I>gen-file</I></TT>, since -they can be obtained from <TT><I>pchk-file</I></TT>. As for mixed -representations, an additional reordering of columns of <B>A</B> may -be needed if <B>H</B> has redundant rows. - -<P>A <I>sparse</I> representation consists of sparse representations -of the <B>L</B> and <B>U</B> matrices, whose product is <B>A</B>, the -first <I>M</I> columns of the parity check matrix (whose columns and -rows may both have been reordered). The matrix <B>B</B>, consisting -of the remaining columns of the parity check matrix, is also part of -the representation, but it is not written to <TT><I>gen-file</I></TT>, -since it can be obtained from <TT><I>pchk-file</I></TT>. - -<P>If a sparse representation is chosen, arguments after -<TT>sparse</TT> specify what heuristic is used when reordering columns -and rows in order to try to make <B>L</B> and <B>U</B> as sparse as -possible. The default if no heuristic is specified is -<TT>minprod</TT>. If the <TT><I>abandon-num</I></TT> and -<TT><I>abandon-when</I></TT> options are given, some information is -discarded in order to speed up the process of finding <B>L</B> and -<B>U</B>, at a possible cost in terms of how good a result is -obtained. For details on these heuristics, see the descriptions of <A -HREF="sparse-LU.html">sparse LU decomposition methods</A>. - -<P><B>Example:</B> A dense representation of a generator matrix for the -Hamming code created by the example for <A -HREF="pchk.html#make-pchk"><TT>make-pchk</TT></A> can be created as follows: -<UL><PRE> -<LI>make-gen ham7.pchk ham7.gen dense -Number of 1s per check in Inv(A) X B is 3.0 -</PRE></UL> - - -<P><A NAME="print-gen"><HR><B>print-gen</B>: Print a representation of a -generator matrix. - -<BLOCKQUOTE><PRE> -print-gen [ -d ] <I>gen-file</I> -</PRE></BLOCKQUOTE> - -<P>Prints in human-readable form the representation of the generator -matrix that is stored in <TT><I>gen-file</I></TT>. The <B>-d</B> -option causes the matrices involved to be printed in a dense format, -even if they are stored in the file in a sparse format. See the <A -HREF="#gen-rep">description above</A> for details of generator matrix -representations. Note that the <B>L</B> matrix for a sparse representation -will be lower triangular only after the rows are rearranged, and the <B>U</B> -matrix will be upper triangular only after the columns are rearranged. -The matrix <B>B</B> that is part of the sparse -and mixed representations is not printed, since it is not stored -in the <TT><I>gen-file</I></TT>, but is rather a subset of columns -of the parity check matrix. - -<P><B>Example:</B> The generator matrix for the -Hamming code created by the example for <A -HREF="#make-gen"><TT>make-gen</TT></A> can be printed as follows: -<UL><PRE> -<LI>print-gen ham7.gen - -Generator matrix (dense representation): - -Column order: - - 0 1 2 3 4 5 6 - -Inv(A) X B: - - 1 1 1 0 - 1 1 0 1 - 0 1 1 1 -</PRE></UL> -For this example, the columns did not need to be rearranged, and hence the -message bits will be in positions 3, 4, 5, and 6 of a codeword. - -<P><A NAME="encode"><HR><B>encode</B>: Encode message blocks as codewords - -<BLOCKQUOTE><PRE> -encode [ -f ] <I>pchk-file gen-file source-file encoded-file</I> -</PRE></BLOCKQUOTE> - -Encodes message blocks of length <I>K</I>, read from -<TT><I>source-file</I></TT>, as codewords of length <I>N</I>, which -are written to <TT><I>encoded-file</I></TT>, replacing any previous -data in this file. Here, <I>N</I> is the number of columns in the -parity check matrix in <TT><I>pchk-file</I></TT>, and -<I>K</I>=<I>N-M</I>, where <I>M</I> is the number of rows in the -parity check matrix. The generator matrix used, from -<TT><I>gen-file</I></TT>, determines which bits of the codeword are -set to the message bits, and how the remaining check bits are -computed. The generator matrix is created from -<TT><I>pchk-file</I></TT> using <A HREF="#make-gen"><TT>make-gen</TT></A>. - -<P>A newline is output at the end of each block written to -<TT><I>encoded-file</I></TT>. Newlines in <TT><I>source-file</I></TT> -are ignored. - -<P>If the <B>-f</B> option is given, output to <TT><I>encoded-file</I></TT> -is flushed after each block. This allows one to use encode as a server, -reading blocks to encode from a named pipe, and writing the encoded block -to another named pipe. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/ex-dep b/lib/ldpc/ex-dep deleted file mode 100755 index 3acebedc..00000000 --- a/lib/ldpc/ex-dep +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh - -# Examples of a how a parity check matrix with dependent rows is handled. - -set -e # Stop if an error occurs -set -v # Echo commands as they are read - -# CODE 1 - -make-pchk ex-dep.pchk 4 6 0:0 0:5 3:1 3:2 -print-pchk -d ex-dep.pchk -echo 00011011 >ex-dep.src - -# SPARSE REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen sparse -print-gen -d ex-dep.gen -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src - -# DENSE REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen dense -print-gen -d ex-dep.gen -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src - -# MIXED REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen mixed -print-gen -d ex-dep.gen -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src - -# CODE 2 - -make-pchk ex-dep.pchk 4 5 0:0 0:1 1:1 1:2 2:0 2:2 3:3 3:4 -print-pchk -d ex-dep.pchk -echo 01 >ex-dep.src - -# SPARSE REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen sparse -print-gen -d ex-dep.gen -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src - -# DENSE REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen dense -print-gen -d ex-dep.gen -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src - -# MIXED REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen mixed -print-gen -d ex-dep.gen -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src diff --git a/lib/ldpc/ex-dep-out b/lib/ldpc/ex-dep-out deleted file mode 100755 index c4df520a..00000000 --- a/lib/ldpc/ex-dep-out +++ /dev/null @@ -1,224 +0,0 @@ - -# CODE 1 - -make-pchk ex-dep.pchk 4 6 0:0 0:5 3:1 3:2 -print-pchk -d ex-dep.pchk - -Parity check matrix in ex-dep.pchk (dense format): - - 1 0 0 0 0 1 - 0 0 0 0 0 0 - 0 0 0 0 0 0 - 0 1 1 0 0 0 - -echo 00011011 >ex-dep.src - -# SPARSE REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen sparse -Note: Parity check matrix has 2 redundant checks -Number of 1s per check in L is 0.8, U is 0.5, B is 0.2, total is 1.5 -print-gen -d ex-dep.gen - -Generator matrix in ex-dep.gen (sparse representation): - -Column order (message bits at end): - - 5 2 1 3 4 0 - -Row order: - - 0 3 2 1 - -L: - - 1 0 0 0 - 0 0 0 0 - 0 0 0 0 - 0 1 0 0 - -U: - - 0 0 0 0 0 1 - 0 1 1 0 0 0 - 0 0 0 0 0 0 - 0 0 0 0 0 0 - -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -Encoded 4 blocks, source block size 2, encoded block size 6 -000000 -100001 -000010 -100011 -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src -Block counts: tot 4, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 - -# DENSE REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen dense -Note: Parity check matrix has 2 redundant checks -Number of 1s per check in Inv(A) X B is 0.2 -print-gen -d ex-dep.gen - -Generator matrix in ex-dep.gen (dense representation): - -Column order (message bits at end): - - 0 1 2 3 4 5 - -Inv(A) X B: - - 0 1 - 0 0 - 0 0 - 0 0 - -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -Encoded 4 blocks, source block size 2, encoded block size 6 -000000 -100001 -000010 -100011 -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src -Block counts: tot 4, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 - -# MIXED REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen mixed -Note: Parity check matrix has 2 redundant checks -Number of 1s per check in Inv(A) is 0.5, in B is 0.2, total is 0.8 -print-gen -d ex-dep.gen - -Generator matrix in ex-dep.gen (mixed representation): - -Column order (message bits at end): - - 0 1 2 3 4 5 - -Inv(A): - - 1 0 0 0 - 0 0 0 1 - 0 0 0 0 - 0 0 0 0 - -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -Encoded 4 blocks, source block size 2, encoded block size 6 -000000 -100001 -000010 -100011 -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src -Block counts: tot 4, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 - -# CODE 2 - -make-pchk ex-dep.pchk 4 5 0:0 0:1 1:1 1:2 2:0 2:2 3:3 3:4 -print-pchk -d ex-dep.pchk - -Parity check matrix in ex-dep.pchk (dense format): - - 1 1 0 0 0 - 0 1 1 0 0 - 1 0 1 0 0 - 0 0 0 1 1 - -echo 01 >ex-dep.src - -# SPARSE REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen sparse -Note: Parity check matrix has 1 redundant checks -Number of 1s per check in L is 1.0, U is 1.2, B is 0.5, total is 2.8 -print-gen -d ex-dep.gen - -Generator matrix in ex-dep.gen (sparse representation): - -Column order (message bits at end): - - 4 1 2 3 0 - -Row order: - - 3 0 1 2 - -L: - - 0 1 0 0 - 0 1 1 0 - 0 0 1 0 - 1 0 0 0 - -U: - - 0 0 0 1 1 - 0 1 0 0 0 - 0 0 1 0 0 - 0 0 0 0 0 - -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -Encoded 2 blocks, source block size 1, encoded block size 5 -00000 -11100 -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src -Block counts: tot 2, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 - -# DENSE REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen dense -Note: Parity check matrix has 1 redundant checks -Number of 1s per check in Inv(A) X B is 0.2 -print-gen -d ex-dep.gen - -Generator matrix in ex-dep.gen (dense representation): - -Column order (message bits at end): - - 0 1 3 2 4 - -Inv(A) X B: - - 0 - 0 - 1 - 0 - -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -Encoded 2 blocks, source block size 1, encoded block size 5 -00000 -00011 -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src -Block counts: tot 2, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 - -# MIXED REPRESENTATION - -make-gen ex-dep.pchk ex-dep.gen mixed -Note: Parity check matrix has 1 redundant checks -Number of 1s per check in Inv(A) is 1.0, in B is 0.2, total is 1.2 -print-gen -d ex-dep.gen - -Generator matrix in ex-dep.gen (mixed representation): - -Column order (message bits at end): - - 0 1 3 2 4 - -Inv(A): - - 1 1 0 0 - 0 1 0 0 - 0 0 0 1 - 0 0 0 0 - -encode ex-dep.pchk ex-dep.gen ex-dep.src ex-dep.enc; cat ex-dep.enc -Encoded 2 blocks, source block size 1, encoded block size 5 -00000 -00011 -verify ex-dep.pchk ex-dep.enc ex-dep.gen ex-dep.src -Block counts: tot 2, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 diff --git a/lib/ldpc/ex-ham7a b/lib/ldpc/ex-ham7a deleted file mode 100755 index 7ccc0809..00000000 --- a/lib/ldpc/ex-ham7a +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# Example of decoding a (7,4) Hamming code using exhaustive enumeration and -# probability propagation, with an Additive White Gaussian Noise channel with -# noise standard deviation of 0.5, for which Eb/N0 = 5.44 dB. -# -# Testing is done by transmitting zero blocks, which is sufficient because -# both the channel and the decoding procedure are symmetrical. WARNING: But -# things can easily become non-symmetrical with bugs, so this technique should -# be used with caution, and only when necessary for performance reasons. -# Decoding is done three times, once minimizing block error probability, once -# minimizing bit error probability, and once by up to 200 iterations of -# probability propagation. - -set -e # Stop if an error occurs -set -v # Echo commands as they are read - -make-pchk ex-ham7a.pchk 3 7 0:0 0:3 0:4 0:5 1:1 1:3 1:4 1:6 2:2 2:4 2:5 2:6 -make-gen ex-ham7a.pchk ex-ham7a.gen dense -transmit 7x100000 ex-ham7a.rec 1 awgn 0.5 - -# DECODE BY ENUMERATION TO MINIMIZE BLOCK ERROR PROBABILITY - -decode ex-ham7a.pchk ex-ham7a.rec ex-ham7a.dec-blk awgn 0.5 \ - enum-block ex-ham7a.gen -verify ex-ham7a.pchk ex-ham7a.dec-blk ex-ham7a.gen - -# DECODE BY ENUMERATION TO MINIMIZE BIT ERROR PROBABILITY - -decode ex-ham7a.pchk ex-ham7a.rec ex-ham7a.dec-bit awgn 0.5 \ - enum-bit ex-ham7a.gen -verify ex-ham7a.pchk ex-ham7a.dec-bit ex-ham7a.gen - -# DECODE BY PROBABILITY PROPAGATION - -decode ex-ham7a.pchk ex-ham7a.rec ex-ham7a.dec-prp awgn 0.5 \ - prprp 200 -verify ex-ham7a.pchk ex-ham7a.dec-prp ex-ham7a.gen diff --git a/lib/ldpc/ex-ham7a-out b/lib/ldpc/ex-ham7a-out deleted file mode 100755 index eaa4ea52..00000000 --- a/lib/ldpc/ex-ham7a-out +++ /dev/null @@ -1,33 +0,0 @@ - -make-pchk ex-ham7a.pchk 3 7 0:0 0:3 0:4 0:5 1:1 1:3 1:4 1:6 2:2 2:4 2:5 2:6 -make-gen ex-ham7a.pchk ex-ham7a.gen dense -Number of 1s per check in Inv(A) X B is 3.0 -transmit 7x100000 ex-ham7a.rec 1 awgn 0.5 -Transmitted 700000 bits - -# DECODE BY ENUMERATION TO MINIMIZE BLOCK ERROR PROBABILITY - -decode ex-ham7a.pchk ex-ham7a.rec ex-ham7a.dec-blk awgn 0.5 \ - enum-block ex-ham7a.gen -Decoded 100000 blocks, 100000 valid. Average 16.0 iterations, 2% bit changes -verify ex-ham7a.pchk ex-ham7a.dec-blk ex-ham7a.gen -Block counts: tot 100000, with chk errs 0, with src errs 186, both 0 -Bit error rate (on message bits only): 7.950e-04 - -# DECODE BY ENUMERATION TO MINIMIZE BIT ERROR PROBABILITY - -decode ex-ham7a.pchk ex-ham7a.rec ex-ham7a.dec-bit awgn 0.5 \ - enum-bit ex-ham7a.gen -Decoded 100000 blocks, 99988 valid. Average 16.0 iterations, 2% bit changes -verify ex-ham7a.pchk ex-ham7a.dec-bit ex-ham7a.gen -Block counts: tot 100000, with chk errs 12, with src errs 186, both 7 -Bit error rate (on message bits only): 7.775e-04 - -# DECODE BY PROBABILITY PROPAGATION - -decode ex-ham7a.pchk ex-ham7a.rec ex-ham7a.dec-prp awgn 0.5 \ - prprp 200 -Decoded 100000 blocks, 99927 valid. Average 0.3 iterations, 2% bit changes -verify ex-ham7a.pchk ex-ham7a.dec-prp ex-ham7a.gen -Block counts: tot 100000, with chk errs 73, with src errs 276, both 52 -Bit error rate (on message bits only): 1.290e-03 diff --git a/lib/ldpc/ex-ham7b b/lib/ldpc/ex-ham7b deleted file mode 100755 index 3bdd4a60..00000000 --- a/lib/ldpc/ex-ham7b +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# Example of coding using a (7,4) Hamming code, with transmission through -# a Binary Symmetric Channel with error probability of 0.05. -# -# This example shows how random source messages can be encoded as codewords, -# transmitted through the simulated channel, decoded, and the message bits -# extracted from the codewords. The final result is in ex-ham7b.ext, which can -# be compared to ex-ham7b.src. - -set -e # Stop if an error occurs -set -v # Echo commands as they are read - -make-pchk ex-ham7b.pchk 3 7 0:0 0:3 0:4 0:5 1:1 1:3 1:4 1:6 2:2 2:4 2:5 2:6 -make-gen ex-ham7b.pchk ex-ham7b.gen dense -rand-src ex-ham7b.src 1 4x1000 -encode ex-ham7b.pchk ex-ham7b.gen ex-ham7b.src ex-ham7b.enc -transmit ex-ham7b.enc ex-ham7b.rec 1 bsc 0.05 -decode ex-ham7b.pchk ex-ham7b.rec ex-ham7b.dec bsc 0.05 enum-bit ex-ham7b.gen -verify ex-ham7b.pchk ex-ham7b.dec ex-ham7b.gen ex-ham7b.src -extract ex-ham7b.gen ex-ham7b.dec ex-ham7b.ext diff --git a/lib/ldpc/ex-ham7b-out b/lib/ldpc/ex-ham7b-out deleted file mode 100755 index 37ecfc49..00000000 --- a/lib/ldpc/ex-ham7b-out +++ /dev/null @@ -1,15 +0,0 @@ - -make-pchk ex-ham7b.pchk 3 7 0:0 0:3 0:4 0:5 1:1 1:3 1:4 1:6 2:2 2:4 2:5 2:6 -make-gen ex-ham7b.pchk ex-ham7b.gen dense -Number of 1s per check in Inv(A) X B is 3.0 -rand-src ex-ham7b.src 1 4x1000 -encode ex-ham7b.pchk ex-ham7b.gen ex-ham7b.src ex-ham7b.enc -Encoded 1000 blocks, source block size 4, encoded block size 7 -transmit ex-ham7b.enc ex-ham7b.rec 1 bsc 0.05 -Transmitted 7000 bits -decode ex-ham7b.pchk ex-ham7b.rec ex-ham7b.dec bsc 0.05 enum-bit ex-ham7b.gen -Decoded 1000 blocks, 1000 valid. Average 16.0 iterations, 4% bit changes -verify ex-ham7b.pchk ex-ham7b.dec ex-ham7b.gen ex-ham7b.src -Block counts: tot 1000, with chk errs 0, with src errs 47, both 0 -Bit error rate (on message bits only): 2.000e-02 -extract ex-ham7b.gen ex-ham7b.dec ex-ham7b.ext diff --git a/lib/ldpc/ex-ldpc-encode b/lib/ldpc/ex-ldpc-encode deleted file mode 100755 index 7165e482..00000000 --- a/lib/ldpc/ex-ldpc-encode +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -# Example of how an LDPC code can be encoded using using sparse, -# dense, and mixed representations of the generator matrix. The dense -# and mixed representations are based on the same set of message bits -# as the sparse method with minprod heuristic. This allows the correctness -# of these methods to be checked by verifying that they all produce the same -# result when encoding random messages. The results are also checked by -# 'verify'. -# -# A (400,200) LDPC code with 3 checks per bit is used for the test. - -set -e # Stop if an error occurs -set -v # Echo commands as they are read - -make-ldpc ex-ldpc-encode.pchk 200 400 1 evenboth 3 - -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.genf sparse first -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.genc sparse mincol -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.genp sparse minprod -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.gend dense ex-ldpc-encode.genp -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.genm mixed ex-ldpc-encode.genp - -rand-src ex-ldpc-encode.src 1 200x10 - -encode ex-ldpc-encode.pchk ex-ldpc-encode.genf ex-ldpc-encode.src \ - ex-ldpc-encode.encf -encode ex-ldpc-encode.pchk ex-ldpc-encode.genc ex-ldpc-encode.src \ - ex-ldpc-encode.encc -encode ex-ldpc-encode.pchk ex-ldpc-encode.genp ex-ldpc-encode.src \ - ex-ldpc-encode.encp -encode ex-ldpc-encode.pchk ex-ldpc-encode.gend ex-ldpc-encode.src \ - ex-ldpc-encode.encd -encode ex-ldpc-encode.pchk ex-ldpc-encode.genm ex-ldpc-encode.src \ - ex-ldpc-encode.encm - -cmp ex-ldpc-encode.encp ex-ldpc-encode.encd -cmp ex-ldpc-encode.encp ex-ldpc-encode.encm - -verify ex-ldpc-encode.pchk ex-ldpc-encode.encf ex-ldpc-encode.genf \ - ex-ldpc-encode.src -verify ex-ldpc-encode.pchk ex-ldpc-encode.encc ex-ldpc-encode.genc \ - ex-ldpc-encode.src -verify ex-ldpc-encode.pchk ex-ldpc-encode.encp ex-ldpc-encode.genp \ - ex-ldpc-encode.src diff --git a/lib/ldpc/ex-ldpc-encode-out b/lib/ldpc/ex-ldpc-encode-out deleted file mode 100755 index 0dc1a1cf..00000000 --- a/lib/ldpc/ex-ldpc-encode-out +++ /dev/null @@ -1,47 +0,0 @@ - -make-ldpc ex-ldpc-encode.pchk 200 400 1 evenboth 3 - -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.genf sparse first -Number of 1s per check in L is 6.4, U is 6.4, B is 3.0, total is 15.8 -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.genc sparse mincol -Number of 1s per check in L is 3.0, U is 3.3, B is 3.0, total is 9.3 -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.genp sparse minprod -Number of 1s per check in L is 2.4, U is 3.2, B is 3.0, total is 8.6 -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.gend dense ex-ldpc-encode.genp -Number of 1s per check in Inv(A) X B is 69.2 -make-gen ex-ldpc-encode.pchk ex-ldpc-encode.genm mixed ex-ldpc-encode.genp -Number of 1s per check in Inv(A) is 64.7, in B is 3.0, total is 67.7 - -rand-src ex-ldpc-encode.src 1 200x10 - -encode ex-ldpc-encode.pchk ex-ldpc-encode.genf ex-ldpc-encode.src \ - ex-ldpc-encode.encf -Encoded 10 blocks, source block size 200, encoded block size 400 -encode ex-ldpc-encode.pchk ex-ldpc-encode.genc ex-ldpc-encode.src \ - ex-ldpc-encode.encc -Encoded 10 blocks, source block size 200, encoded block size 400 -encode ex-ldpc-encode.pchk ex-ldpc-encode.genp ex-ldpc-encode.src \ - ex-ldpc-encode.encp -Encoded 10 blocks, source block size 200, encoded block size 400 -encode ex-ldpc-encode.pchk ex-ldpc-encode.gend ex-ldpc-encode.src \ - ex-ldpc-encode.encd -Encoded 10 blocks, source block size 200, encoded block size 400 -encode ex-ldpc-encode.pchk ex-ldpc-encode.genm ex-ldpc-encode.src \ - ex-ldpc-encode.encm -Encoded 10 blocks, source block size 200, encoded block size 400 - -cmp ex-ldpc-encode.encp ex-ldpc-encode.encd -cmp ex-ldpc-encode.encp ex-ldpc-encode.encm - -verify ex-ldpc-encode.pchk ex-ldpc-encode.encf ex-ldpc-encode.genf \ - ex-ldpc-encode.src -Block counts: tot 10, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 -verify ex-ldpc-encode.pchk ex-ldpc-encode.encc ex-ldpc-encode.genc \ - ex-ldpc-encode.src -Block counts: tot 10, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 -verify ex-ldpc-encode.pchk ex-ldpc-encode.encp ex-ldpc-encode.genp \ - ex-ldpc-encode.src -Block counts: tot 10, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 diff --git a/lib/ldpc/ex-ldpc36-1000a b/lib/ldpc/ex-ldpc36-1000a deleted file mode 100755 index 19c4ba08..00000000 --- a/lib/ldpc/ex-ldpc36-1000a +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -# Example of a (2000,1000) LDPC code with 3 checks per bit and 6 bits per -# check, tested on Additive White Gaussian Noise channels with noise standard -# deviations varying from 0.80 to 0.95. -# -# Testing is done by transmitting random messages, which is safer (though -# slower) than using only zero messages. Decoding is done using a maximum -# of 250 iterations of probability propagation. - -set -e # Stop if an error occurs -set -v # Echo commands as they are read - -make-ldpc ex-ldpc36-1000a.pchk 1000 2000 1 evenboth 3 no4cycle -make-gen ex-ldpc36-1000a.pchk ex-ldpc36-1000a.gen dense -rand-src ex-ldpc36-1000a.src 1 1000x100 -encode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.gen ex-ldpc36-1000a.src \ - ex-ldpc36-1000a.enc - -# NOISE STANDARD DEVIATION 0.80, Eb/N0 = 1.94 dB - -transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.80 -decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.80\ - prprp 250 -verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \ - ex-ldpc36-1000a.src - -# NOISE STANDARD DEVIATION 0.85, Eb/N0 = 1.41 dB - -transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.85 -decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.85\ - prprp 250 -verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \ - ex-ldpc36-1000a.src - -# NOISE STANDARD DEVIATION 0.90, Eb/N0 = 0.92 dB - -transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.90 -decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.90\ - prprp 250 -verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \ - ex-ldpc36-1000a.src - -# NOISE STANDARD DEVIATION 0.95, Eb/N0 = 0.45 dB - -transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.95 -decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.95\ - prprp 250 -verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \ - ex-ldpc36-1000a.src diff --git a/lib/ldpc/ex-ldpc36-1000a-out b/lib/ldpc/ex-ldpc36-1000a-out deleted file mode 100755 index 418ed5c9..00000000 --- a/lib/ldpc/ex-ldpc36-1000a-out +++ /dev/null @@ -1,57 +0,0 @@ - -make-ldpc ex-ldpc36-1000a.pchk 1000 2000 1 evenboth 3 no4cycle -Eliminated 24 cycles of length four by moving checks within column -make-gen ex-ldpc36-1000a.pchk ex-ldpc36-1000a.gen dense -Number of 1s per check in Inv(A) X B is 400.3 -rand-src ex-ldpc36-1000a.src 1 1000x100 -encode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.gen ex-ldpc36-1000a.src \ - ex-ldpc36-1000a.enc -Encoded 100 blocks, source block size 1000, encoded block size 2000 - -# NOISE STANDARD DEVIATION 0.80, Eb/N0 = 1.94 dB - -transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.80 -Transmitted 200000 bits -decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.80\ - prprp 250 -Decoded 100 blocks, 100 valid. Average 10.8 iterations, 11% bit changes -verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \ - ex-ldpc36-1000a.src -Block counts: tot 100, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 - -# NOISE STANDARD DEVIATION 0.85, Eb/N0 = 1.41 dB - -transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.85 -Transmitted 200000 bits -decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.85\ - prprp 250 -Decoded 100 blocks, 88 valid. Average 52.2 iterations, 12% bit changes -verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \ - ex-ldpc36-1000a.src -Block counts: tot 100, with chk errs 12, with src errs 12, both 12 -Bit error rate (on message bits only): 7.490e-03 - -# NOISE STANDARD DEVIATION 0.90, Eb/N0 = 0.92 dB - -transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.90 -Transmitted 200000 bits -decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.90\ - prprp 250 -Decoded 100 blocks, 19 valid. Average 209.4 iterations, 11% bit changes -verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \ - ex-ldpc36-1000a.src -Block counts: tot 100, with chk errs 81, with src errs 81, both 81 -Bit error rate (on message bits only): 6.529e-02 - -# NOISE STANDARD DEVIATION 0.95, Eb/N0 = 0.45 dB - -transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.95 -Transmitted 200000 bits -decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.95\ - prprp 250 -Decoded 100 blocks, 1 valid. Average 248.0 iterations, 9% bit changes -verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \ - ex-ldpc36-1000a.src -Block counts: tot 100, with chk errs 99, with src errs 99, both 99 -Bit error rate (on message bits only): 1.055e-01 diff --git a/lib/ldpc/ex-ldpc36-5000a b/lib/ldpc/ex-ldpc36-5000a deleted file mode 100755 index f791e056..00000000 --- a/lib/ldpc/ex-ldpc36-5000a +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -# Example of a (10000,5000) LDPC code with 3 checks per bit and 6 bits per -# check, tested on Additive White Gaussian Noise channels with noise standard -# deviations varying from 0.80 to 0.95. -# -# Testing is done by transmitting random messages, with pipes used so that -# intermediate files are avoided. Decoding is done using a maximum of 250 -# iterations of probability propagation. - -set -e # Stop if an error occurs -set -v # Echo commands as they are read - -make-ldpc ex-ldpc36-5000a.pchk 5000 10000 2 evenboth 3 no4cycle -make-gen ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen dense -rand-src ex-ldpc36-5000a.src 1 5000x100 - -# NOISE STANDARD DEVIATION 0.80, Eb/N0 = 1.94 dB - -encode ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - \ - | transmit - - 1 awgn 0.80 \ - | decode ex-ldpc36-5000a.pchk - - awgn 0.80 prprp 250 \ - | verify ex-ldpc36-5000a.pchk - ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - -# NOISE STANDARD DEVIATION 0.85, Eb/N0 = 1.41 dB - -encode ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - \ - | transmit - - 1 awgn 0.85 \ - | decode ex-ldpc36-5000a.pchk - - awgn 0.85 prprp 250 \ - | verify ex-ldpc36-5000a.pchk - ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - -# NOISE STANDARD DEVIATION 0.90, Eb/N0 = 0.92 dB - -encode ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - \ - | transmit - - 1 awgn 0.90 \ - | decode ex-ldpc36-5000a.pchk - - awgn 0.90 prprp 250 \ - | verify ex-ldpc36-5000a.pchk - ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - -# NOISE STANDARD DEVIATION 0.95, Eb/N0 = 0.45 dB - -encode ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - \ - | transmit - - 1 awgn 0.95 \ - | decode ex-ldpc36-5000a.pchk - - awgn 0.95 prprp 250 \ - | verify ex-ldpc36-5000a.pchk - ex-ldpc36-5000a.gen ex-ldpc36-5000a.src diff --git a/lib/ldpc/ex-ldpc36-5000a-out b/lib/ldpc/ex-ldpc36-5000a-out deleted file mode 100755 index f7bae5b9..00000000 --- a/lib/ldpc/ex-ldpc36-5000a-out +++ /dev/null @@ -1,54 +0,0 @@ - -make-ldpc ex-ldpc36-5000a.pchk 5000 10000 2 evenboth 3 no4cycle -Eliminated 25 cycles of length four by moving checks within column -make-gen ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen dense -Number of 1s per check in Inv(A) X B is 2068.3 -rand-src ex-ldpc36-5000a.src 1 5000x100 - -# NOISE STANDARD DEVIATION 0.80, Eb/N0 = 1.94 dB - -encode ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - \ - | transmit - - 1 awgn 0.80 \ - | decode ex-ldpc36-5000a.pchk - - awgn 0.80 prprp 250 \ - | verify ex-ldpc36-5000a.pchk - ex-ldpc36-5000a.gen ex-ldpc36-5000a.src -Encoded 100 blocks, source block size 5000, encoded block size 10000 -Transmitted 1000000 bits -Decoded 100 blocks, 100 valid. Average 11.1 iterations, 11% bit changes -Block counts: tot 100, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 - -# NOISE STANDARD DEVIATION 0.85, Eb/N0 = 1.41 dB - -encode ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - \ - | transmit - - 1 awgn 0.85 \ - | decode ex-ldpc36-5000a.pchk - - awgn 0.85 prprp 250 \ - | verify ex-ldpc36-5000a.pchk - ex-ldpc36-5000a.gen ex-ldpc36-5000a.src -Encoded 100 blocks, source block size 5000, encoded block size 10000 -Transmitted 1000000 bits -Decoded 100 blocks, 95 valid. Average 33.7 iterations, 12% bit changes -Block counts: tot 100, with chk errs 5, with src errs 5, both 5 -Bit error rate (on message bits only): 2.706e-03 - -# NOISE STANDARD DEVIATION 0.90, Eb/N0 = 0.92 dB - -encode ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - \ - | transmit - - 1 awgn 0.90 \ - | decode ex-ldpc36-5000a.pchk - - awgn 0.90 prprp 250 \ - | verify ex-ldpc36-5000a.pchk - ex-ldpc36-5000a.gen ex-ldpc36-5000a.src -Encoded 100 blocks, source block size 5000, encoded block size 10000 -Transmitted 1000000 bits -Decoded 100 blocks, 2 valid. Average 246.2 iterations, 10% bit changes -Block counts: tot 100, with chk errs 98, with src errs 98, both 98 -Bit error rate (on message bits only): 7.650e-02 - -# NOISE STANDARD DEVIATION 0.95, Eb/N0 = 0.45 dB - -encode ex-ldpc36-5000a.pchk ex-ldpc36-5000a.gen ex-ldpc36-5000a.src - \ - | transmit - - 1 awgn 0.95 \ - | decode ex-ldpc36-5000a.pchk - - awgn 0.95 prprp 250 \ - | verify ex-ldpc36-5000a.pchk - ex-ldpc36-5000a.gen ex-ldpc36-5000a.src -Encoded 100 blocks, source block size 5000, encoded block size 10000 -Transmitted 1000000 bits -Decoded 100 blocks, 0 valid. Average 250.0 iterations, 9% bit changes -Block counts: tot 100, with chk errs 100, with src errs 100, both 100 -Bit error rate (on message bits only): 1.092e-01 diff --git a/lib/ldpc/ex-ldpcvar-5000a b/lib/ldpc/ex-ldpcvar-5000a deleted file mode 100755 index e8995e54..00000000 --- a/lib/ldpc/ex-ldpcvar-5000a +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -# Example of a (10000,5000) LDPC code with varying numbers of check per bit, -# tested on Additive White Gaussian Noise channels with noise standard -# deviations varying from 0.80 to 0.95. The code has 20% columns with two -# check bits, 70% columns with three check bits, and 10% columns with seven -# check bits. -# -# Testing is done by transmitting random messages, with pipes used so that -# intermediate files are avoided. Decoding is done using a maximum of 250 -# iterations of probability propagation. - -set -e # Stop if an error occurs -set -v # Echo commands as they are read - -make-ldpc ex-ldpcvar-5000a.pchk 5000 10000 2 evenboth 2x2/7x3/1x7 no4cycle -make-gen ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen dense -rand-src ex-ldpcvar-5000a.src 1 5000x100 - -# NOISE STANDARD DEVIATION 0.80, Eb/N0 = 1.94 dB - -encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \ - | transmit - - 1 awgn 0.80 \ - | decode ex-ldpcvar-5000a.pchk - - awgn 0.80 prprp 250 \ - | verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - -# NOISE STANDARD DEVIATION 0.85, Eb/N0 = 1.41 dB - -encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \ - | transmit - - 1 awgn 0.85 \ - | decode ex-ldpcvar-5000a.pchk - - awgn 0.85 prprp 250 \ - | verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - -# NOISE STANDARD DEVIATION 0.90, Eb/N0 = 0.92 dB - -encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \ - | transmit - - 1 awgn 0.90 \ - | decode ex-ldpcvar-5000a.pchk - - awgn 0.90 prprp 250 \ - | verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - -# NOISE STANDARD DEVIATION 0.95, Eb/N0 = 0.45 dB - -encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \ - | transmit - - 1 awgn 0.95 \ - | decode ex-ldpcvar-5000a.pchk - - awgn 0.95 prprp 250 \ - | verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src diff --git a/lib/ldpc/ex-ldpcvar-5000a-out b/lib/ldpc/ex-ldpcvar-5000a-out deleted file mode 100755 index 3cdb2081..00000000 --- a/lib/ldpc/ex-ldpcvar-5000a-out +++ /dev/null @@ -1,54 +0,0 @@ - -make-ldpc ex-ldpcvar-5000a.pchk 5000 10000 2 evenboth 2x2/7x3/1x7 no4cycle -Eliminated 46 cycles of length four by moving checks within column -make-gen ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen dense -Number of 1s per check in Inv(A) X B is 1437.1 -rand-src ex-ldpcvar-5000a.src 1 5000x100 - -# NOISE STANDARD DEVIATION 0.80, Eb/N0 = 1.94 dB - -encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \ - | transmit - - 1 awgn 0.80 \ - | decode ex-ldpcvar-5000a.pchk - - awgn 0.80 prprp 250 \ - | verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src -Encoded 100 blocks, source block size 5000, encoded block size 10000 -Transmitted 1000000 bits -Decoded 100 blocks, 100 valid. Average 11.3 iterations, 11% bit changes -Block counts: tot 100, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 - -# NOISE STANDARD DEVIATION 0.85, Eb/N0 = 1.41 dB - -encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \ - | transmit - - 1 awgn 0.85 \ - | decode ex-ldpcvar-5000a.pchk - - awgn 0.85 prprp 250 \ - | verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src -Encoded 100 blocks, source block size 5000, encoded block size 10000 -Transmitted 1000000 bits -Decoded 100 blocks, 100 valid. Average 18.0 iterations, 12% bit changes -Block counts: tot 100, with chk errs 0, with src errs 0, both 0 -Bit error rate (on message bits only): 0.000e+00 - -# NOISE STANDARD DEVIATION 0.90, Eb/N0 = 0.92 dB - -encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \ - | transmit - - 1 awgn 0.90 \ - | decode ex-ldpcvar-5000a.pchk - - awgn 0.90 prprp 250 \ - | verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src -Encoded 100 blocks, source block size 5000, encoded block size 10000 -Transmitted 1000000 bits -Decoded 100 blocks, 65 valid. Average 119.8 iterations, 12% bit changes -Block counts: tot 100, with chk errs 35, with src errs 35, both 35 -Bit error rate (on message bits only): 2.438e-02 - -# NOISE STANDARD DEVIATION 0.95, Eb/N0 = 0.45 dB - -encode ex-ldpcvar-5000a.pchk ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src - \ - | transmit - - 1 awgn 0.95 \ - | decode ex-ldpcvar-5000a.pchk - - awgn 0.95 prprp 250 \ - | verify ex-ldpcvar-5000a.pchk - ex-ldpcvar-5000a.gen ex-ldpcvar-5000a.src -Encoded 100 blocks, source block size 5000, encoded block size 10000 -Transmitted 1000000 bits -Decoded 100 blocks, 0 valid. Average 250.0 iterations, 9% bit changes -Block counts: tot 100, with chk errs 100, with src errs 100, both 100 -Bit error rate (on message bits only): 1.017e-01 diff --git a/lib/ldpc/ex-wrong-model b/lib/ldpc/ex-wrong-model deleted file mode 100755 index a8304c6c..00000000 --- a/lib/ldpc/ex-wrong-model +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh - -# These tests investigate what happens when the wrong model is used for -# decoding. A (1800,1000) LDPC code with 3 check per bit is used. -# Testing is done by transmitting random messages. Decoding is done using -# a maximum of 100 iterations of probability propagation. -# -# The first set of tests compares decoding of messages sent through an -# AWGN channel using the correct AWGN model with sigma=0.90 to decoding -# using AWGN models with incorrect values for sigma and to decoding -# using AWLN models with varying width parameters for the logistic noise -# distribution. -# -# A second set of tests compares decoding of messages sent through an -# AWLN channel using the correct AWLN model with width=0.50 to decoding -# using AWLN models with incorrect values for width and to decoding -# using AWGN models with varying sigma parameters. - -set -e # Stop if an error occurs -set -v # Echo commands as they are read - -make-ldpc ex-wrong-model.pchk 1000 1800 1 evenboth 3 no4cycle -make-gen ex-wrong-model.pchk ex-wrong-model.gen dense -rand-src ex-wrong-model.src 1 800x1000 -encode ex-wrong-model.pchk ex-wrong-model.gen ex-wrong-model.src \ - ex-wrong-model.enc - -# FIRST SET OF TESTS, TRANSMITTING THROUGH AWGN CHANNEL WITH SIGMA=0.90 - -transmit ex-wrong-model.enc ex-wrong-model.rec 1 awgn 0.90 - -# DECODING WITH CORRECT AWGN NOISE MODEL, SIGMA=0.90 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.90 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.95 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.95 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.85 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.85 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.40 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.40 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.45 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.45 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.50 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.50 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.55 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.55 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.60 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.60 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.65 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.65 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# SECOND SET OF TESTS, TRANSMITTING THROUGH AWLN CHANNEL WITH WIDTH=0.50 - -transmit ex-wrong-model.enc ex-wrong-model.rec 1 awln 0.50 - -# DECODING WITH CORRECT AWLN NOISE MODEL, WIDTH=0.50 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.50 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.55 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.55 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.45 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.45 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.80 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.80 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.85 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.85 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.90 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.90 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.95 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.95 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWGN NOISE MODEL, SIGMA=1.00 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 1.00 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src - -# DECODING WITH AWGN NOISE MODEL, SIGMA=1.05 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 1.05 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src diff --git a/lib/ldpc/ex-wrong-model-out b/lib/ldpc/ex-wrong-model-out deleted file mode 100755 index cde814c9..00000000 --- a/lib/ldpc/ex-wrong-model-out +++ /dev/null @@ -1,163 +0,0 @@ - -make-ldpc ex-wrong-model.pchk 1000 1800 1 evenboth 3 no4cycle -Eliminated 19 cycles of length four by moving checks within column -make-gen ex-wrong-model.pchk ex-wrong-model.gen dense -Number of 1s per check in Inv(A) X B is 318.6 -rand-src ex-wrong-model.src 1 800x1000 -encode ex-wrong-model.pchk ex-wrong-model.gen ex-wrong-model.src \ - ex-wrong-model.enc -Encoded 1000 blocks, source block size 800, encoded block size 1800 - -# FIRST SET OF TESTS, TRANSMITTING THROUGH AWGN CHANNEL WITH SIGMA=0.90 - -transmit ex-wrong-model.enc ex-wrong-model.rec 1 awgn 0.90 -Transmitted 1800000 bits - -# DECODING WITH CORRECT AWGN NOISE MODEL, SIGMA=0.90 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.90 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 910 valid. Average 25.8 iterations, 13% bit changes -Block counts: tot 1000, with chk errs 90, with src errs 89, both 89 -Bit error rate (on message bits only): 6.484e-03 - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.95 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.95 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 909 valid. Average 25.7 iterations, 13% bit changes -Block counts: tot 1000, with chk errs 91, with src errs 91, both 91 -Bit error rate (on message bits only): 6.540e-03 - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.85 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.85 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 900 valid. Average 27.7 iterations, 13% bit changes -Block counts: tot 1000, with chk errs 100, with src errs 100, both 100 -Bit error rate (on message bits only): 7.604e-03 - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.40 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.40 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 755 valid. Average 42.3 iterations, 13% bit changes -Block counts: tot 1000, with chk errs 245, with src errs 245, both 245 -Bit error rate (on message bits only): 1.884e-02 - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.45 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.45 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 827 valid. Average 34.7 iterations, 13% bit changes -Block counts: tot 1000, with chk errs 173, with src errs 172, both 172 -Bit error rate (on message bits only): 1.306e-02 - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.50 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.50 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 849 valid. Average 31.7 iterations, 13% bit changes -Block counts: tot 1000, with chk errs 151, with src errs 151, both 151 -Bit error rate (on message bits only): 1.069e-02 - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.55 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.55 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 855 valid. Average 32.3 iterations, 13% bit changes -Block counts: tot 1000, with chk errs 145, with src errs 145, both 145 -Bit error rate (on message bits only): 1.022e-02 - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.60 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.60 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 790 valid. Average 40.0 iterations, 13% bit changes -Block counts: tot 1000, with chk errs 210, with src errs 210, both 210 -Bit error rate (on message bits only): 1.452e-02 - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.65 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.65 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 540 valid. Average 63.3 iterations, 11% bit changes -Block counts: tot 1000, with chk errs 460, with src errs 460, both 460 -Bit error rate (on message bits only): 3.247e-02 - -# SECOND SET OF TESTS, TRANSMITTING THROUGH AWLN CHANNEL WITH WIDTH=0.50 - -transmit ex-wrong-model.enc ex-wrong-model.rec 1 awln 0.50 -Transmitted 1800000 bits - -# DECODING WITH CORRECT AWLN NOISE MODEL, WIDTH=0.50 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.50 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 914 valid. Average 25.1 iterations, 12% bit changes -Block counts: tot 1000, with chk errs 86, with src errs 86, both 86 -Bit error rate (on message bits only): 6.130e-03 - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.55 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.55 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 907 valid. Average 25.6 iterations, 12% bit changes -Block counts: tot 1000, with chk errs 93, with src errs 93, both 93 -Bit error rate (on message bits only): 6.474e-03 - -# DECODING WITH AWLN NOISE MODEL, WIDTH=0.45 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awln 0.45 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 893 valid. Average 27.5 iterations, 12% bit changes -Block counts: tot 1000, with chk errs 107, with src errs 107, both 107 -Bit error rate (on message bits only): 7.744e-03 - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.80 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.80 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 702 valid. Average 44.9 iterations, 12% bit changes -Block counts: tot 1000, with chk errs 298, with src errs 298, both 298 -Bit error rate (on message bits only): 2.245e-02 - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.85 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.85 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 765 valid. Average 39.4 iterations, 12% bit changes -Block counts: tot 1000, with chk errs 235, with src errs 235, both 235 -Bit error rate (on message bits only): 1.693e-02 - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.90 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.90 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 808 valid. Average 35.7 iterations, 12% bit changes -Block counts: tot 1000, with chk errs 192, with src errs 192, both 192 -Bit error rate (on message bits only): 1.374e-02 - -# DECODING WITH AWGN NOISE MODEL, SIGMA=0.95 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 0.95 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 814 valid. Average 34.6 iterations, 12% bit changes -Block counts: tot 1000, with chk errs 186, with src errs 186, both 186 -Bit error rate (on message bits only): 1.291e-02 - -# DECODING WITH AWGN NOISE MODEL, SIGMA=1.00 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 1.00 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 808 valid. Average 35.6 iterations, 12% bit changes -Block counts: tot 1000, with chk errs 192, with src errs 192, both 192 -Bit error rate (on message bits only): 1.320e-02 - -# DECODING WITH AWGN NOISE MODEL, SIGMA=1.05 - -decode ex-wrong-model.pchk ex-wrong-model.rec - awgn 1.05 prprp 100 \ - | verify ex-wrong-model.pchk - ex-wrong-model.gen ex-wrong-model.src -Decoded 1000 blocks, 771 valid. Average 40.7 iterations, 11% bit changes -Block counts: tot 1000, with chk errs 229, with src errs 228, both 228 -Bit error rate (on message bits only): 1.524e-02 diff --git a/lib/ldpc/examples.html b/lib/ldpc/examples.html deleted file mode 100755 index bc94faed..00000000 --- a/lib/ldpc/examples.html +++ /dev/null @@ -1,87 +0,0 @@ -<HTML><HEAD> - -<TITLE> Examples of LDPC Program Usage </TITLE> - -</HEAD><BODY> - - -<H1> Examples of LDPC Program Usage </H1> - -<P>Below, are some command files containing examples of the use of -the <A HREF="progs.html">LDPC programs</A>, together with the output I -obtained for these examples. Output on other machines might -conceivably be slightly different, due to different round-off errors. -The <A HREF="run-examples"><TT>run-examples</TT></A> script runs all the example -scripts and compares their output with the outputs that I obtained (on -a Pentium machine). - -<P><A HREF="ex-ham7b">ex-ham7b</A>, -output in <A HREF="ex-ham7b-out">ex-ham7b-out</A> -<BLOCKQUOTE> -A (7,4) Hamming code used with a BSC. -Demonstrates encoding of random messages and decoding to minimize -bit error rate by exhaustive enumeration. -</BLOCKQUOTE> - -<P><A HREF="ex-ham7a">ex-ham7a</A>, -output in <A HREF="ex-ham7a-out">ex-ham7a-out</A> -<BLOCKQUOTE> -A (7,4) Hamming code used with an AWGN channel. Tested using zero messages. -Decoded by exhaustive enumeration to minimize either block or bit error rate, -and by probability propagation. -</BLOCKQUOTE> - -<P><A HREF="ex-dep">ex-dep</A>, -output in <A HREF="ex-dep-out">ex-dep-out</A> -<BLOCKQUOTE> -Examples of how parity check matrices with linearly dependent rows (ie, -redundant parity checks) are handled. This is probably not of -great interest to most users. -</BLOCKQUOTE> - -<P><A HREF="ex-ldpc-encode">ex-ldpc-encode</A>, -output in <A HREF="ex-ldpc-encode-out">ex-ldpc-encode-out</A> -<BLOCKQUOTE> -Encodes messages with an LDPC code using sparse, dense, and mixed -representations of the generator matrix. -</BLOCKQUOTE> - -<P><A HREF="ex-ldpc36-1000a">ex-ldpc36-1000a</A>, -output in <A HREF="ex-ldpc36-1000a-out">ex-ldpc36-1000a-out</A> -<BLOCKQUOTE> -A (2000,1000) LDPC code with 3 checks per bit and 6 bits per check. -Three encoding methods are tried out, and the code is -tested on an AWGN channel at various noise levels, using random messages. -</BLOCKQUOTE> - -<P><A HREF="ex-ldpc36-5000a">ex-ldpc36-5000a</A>, -output in <A HREF="ex-ldpc36-5000a-out">ex-ldpc36-5000a-out</A> -<BLOCKQUOTE> -A (10000,5000) LDPC code with 3 checks per bit and 6 bits per check. -Tested on an AWGN channel at various noise levels, using random messages. -Pipes are used to avoid creating lots of files. -</BLOCKQUOTE> - -<P><A HREF="ex-ldpcvar-5000a">ex-ldpcvar-5000a</A>, -output in <A HREF="ex-ldpcvar-5000a-out">ex-ldpcvar-5000a-out</A> -<BLOCKQUOTE> -A (10000,5000) LDPC code with the number of checks per bit varying from 2 to 7. -Tested on an AWGN channel at various noise levels, using random messages. -Pipes are used to avoid creating lots of files. Performance is better than -for the code above in which the number of checks is the same for all bits. -</BLOCKQUOTE> - -<P><A HREF="ex-wrong-model">ex-wrong-model</A>, -output in <A HREF="ex-wrong-model-out">ex-wrong-model-out</A> -<BLOCKQUOTE> -Tests what happens when messages are decoded using the wrong noise -model, including using the right type of model but with the wrong -noise level, and using the wrong type of model (ie, using an AWLN model -for messages transmitted through an AWGN channel, or vice versa). -</BLOCKQUOTE> - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/extract.c b/lib/ldpc/extract.c deleted file mode 100755 index f969f897..00000000 --- a/lib/ldpc/extract.c +++ /dev/null @@ -1,112 +0,0 @@ -/* EXTRACT.C - Extract message bits from coded blocks. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "alloc.h" -#include "blockio.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char *gen_file, *coded_file, *ext_file; - FILE *codef, *extf; - char *cblk; - int i; - - /* Look at arguments. */ - - if (!(gen_file = argv[1]) - || !(coded_file = argv[2]) - || !(ext_file = argv[3]) - || argv[4]) - { usage(); - } - - if ((strcmp(gen_file,"-")==0) + (strcmp(coded_file,"-")==0) > 1) - { fprintf(stderr,"Can't read more than one stream from standard input\n"); - exit(1); - } - - /* Read generator matrix file, up to the point of finding out which - are the message bits. */ - - read_gen(gen_file,1,1); - - /* Open decoded file. */ - - codef = open_file_std(coded_file,"r"); - if (codef==NULL) - { fprintf(stderr,"Can't open coded file: %s\n",coded_file); - exit(1); - } - - /* Open file to write extracted message bits to. */ - - extf = open_file_std(ext_file,"w"); - if (extf==NULL) - { fprintf(stderr,"Can't create file for extracted bits: %s\n",ext_file); - exit(1); - } - - cblk = chk_alloc (N, sizeof *cblk); - - for (;;) - { - /* Read block from coded file. */ - - if (blockio_read(codef,cblk,N)==EOF) break; - - /* Extract message bits and write to file, followed by newline to mark - block boundary. */ - - for (i = M; i<N; i++) - { putc("01"[cblk[cols[i]]],extf); - } - - putc('\n',extf); - } - - if (ferror(extf) || fclose(extf)!=0) - { fprintf(stderr,"Error writing extracted data to %s\n",ext_file); - exit(1); - } - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr, - "Usage: extract gen-file decoded-file extracted-file\n"); - exit(1); -} diff --git a/lib/ldpc/github.html b/lib/ldpc/github.html deleted file mode 100755 index 8f28cc5c..00000000 --- a/lib/ldpc/github.html +++ /dev/null @@ -1,67 +0,0 @@ -<HTML><HEAD> - -<TITLE> Github Facilities </TITLE> - -</HEAD><BODY> - -<H1> Github Facilities </H1> - -<P>Starting with the Version of 2012-02-11, the source code repository -for this software is hosted by <A HREF="http://github.com">Github</A>, -and is located at <A -HREF="http://github.com/radfordneal/LDPC-codes">http://github.com/radfordneal/LDPC-codes</A>. -This repository includes the annotated log of changes made since the -Version of 2006-02-08. - -<P>You can use the facilities at Github to obtain the source-code -repository, report bugs, and contribute to the wiki. - -<H2>Obtaining the source repository, and modifying it</H2> - -<P>To obtain a copy of the source-code repository, issue the following -command (in a Unix/Linux/Cygwin environment that has git installed): -<BLOCKQUOTE><PRE> -git clone git://github.com/radfordneal/LDPC-codes -</PRE></BLOCKQUOTE> -This will retrieve the current state of the software, storing it -in the directory <TT>LDPC-codes</TT>, which you should ensure does not -exist before issuing this command above. - -<P>Note that if all you want to do is compile and use the current -version, you can instead download the source without development -history as described in the <A HREF="install.html">installation -instructions</A>. - -<P>The <TT>LDPC-codes</TT> directory created by the <TT>git clone</TT> -command is a git repository, which can be manipulated with the various -forms of the <TT>git</TT> command, which are documented, for example, -<A HREF="http://git-scm.com/documentation">here</A>. - -<P>Each stable version of the software is a separate branch of the -repository. The documentation on the most recent stable version is in -the "gh-pages" branch. The current development version is on the -"master" branch. The are other branches for each stable version that -was released. - -<P>You can make local changes to your copy of the repository, and use -the modified software. If you wish, you can ask me -(radfordneal@gmail.com) to include your changes in a new release, or, -if you register as a <A HREF="http://github.com">Github</A> user, you can set -up your own fork of the software for you and other people to use. - - -<H2>Reporting Bugs</H2> - -You can use the Github "Issues" facility to report bugs in the -software. You have to register as a <A HREF="github.com">Github</A> -user to do this (which is free). You can then go <A -HREF="https://github.com/radfordneal/LDPC-codes/issues">here</A> and -click on "New issue" to report a bug. You can also use this facility -to suggest new features or other revisions. I may not have time to -implement them, but perhaps someone else will. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/index.html b/lib/ldpc/index.html deleted file mode 100755 index 11aa1248..00000000 --- a/lib/ldpc/index.html +++ /dev/null @@ -1,89 +0,0 @@ -<HTML><HEAD> - -<TITLE> Software for Low Density Parity Check Codes </TITLE> - -</HEAD><BODY> - - -<H1> Software for Low Density Parity Check Codes </H1> - -<P>Version in development. - -<P>This collection of programs and modules, written in C, is intended -to support research and education concerning Low Density Parity Check -(LDPC) codes. (Note, however, that the copyright notice no longer -restricts use to these purposes). These error-correcting codes were -invented by Robert Gallager in the early 1960's, and re-invented and -shown to have very good performance by David MacKay and myself in the -mid-1990's. The decoding algorithm for LDPC codes is related to that -used for Turbo codes, and to probabilistic inference methods used in -other fields. Variations on LDPC and Turbo codes are currently the -best practical codes known, in terms of their ability to transmit data -at rates approaching channel capacity with very low error probability. - -<p>This and past versions of the software are available <A -HREF="http://www.cs.utoronto.ca/~radford/ldpc.software.html">here</A>, -from <A HREF="http://www.cs.utoronto.ca/~radford/">Radford Neal<A>'s -web page. The source code for this software is also <A -HREF="http://github.com/radfordneal/LDPC-codes">hosted at Github</A>, -where there is a <A HREF="http://radfordneal.github.com/LDPC-codes/">copy -of these documentation pages</A> for the latest release. Github also -provides facilities for bug reporting and discussion. - -<H2>Index to Documentation</H2> - -<A HREF="install.html">Download and installation instructions</A> -<BLOCKQUOTE> - How to get and compile the programs and modules. -</BLOCKQUOTE> -<A HREF="github.html">Github facilities</A> -<BLOCKQUOTE> - How to get the source repository, report bugs, etc. -</BLOCKQUOTE> -<A HREF="release.html">Release notes</A> -<BLOCKQUOTE> - A log of changes made in each release of this software. -</BLOCKQUOTE> -<A HREF="progs.html">Software and program usage documentation</A> -<BLOCKQUOTE> - General documentation on the methods implemented, and details of - program usage. -</BLOCKQUOTE> -<A HREF="examples.html">Examples of program usage</A> -<BLOCKQUOTE> - Examples using simple Hamming codes, and using more interesting LDPC codes. -</BLOCKQUOTE> -<A HREF="modify.html">How to modify the programs</A> -<BLOCKQUOTE> - Notes on how to add new channel types, new decoding methods, etc. -</BLOCKQUOTE> -<A HREF="modules.html">Module documentation</A> -<BLOCKQUOTE> - Modules used by the programs for modulo-2 matrix - operations and random number generation. -</BLOCKQUOTE> -<A HREF="refs.html">References</A> -<BLOCKQUOTE> - Classic and more recent papers on LDPC codes and related topics. -</BLOCKQUOTE> - -<H2> <A NAME="copyright">Copyright and Lack of Warranty</A> </H2> - -<P> Except as otherwise specified, all of this software and -documentation is copyright © 1995-2012 by Radford M. Neal. - -<P>Permission is granted for anyone to copy, use, modify, and distribute -these programs and accompanying documents for any purpose, provided -this copyright notice is retained and prominently displayed, and note -is made of any changes made to these programs. These programs and -documents are distributed without any warranty, express or implied. -As the programs were written for research purposes only, they have not -been tested to the degree that would be advisable in any important -application. All use of these programs is entirely at the user's own -risk. - -<P>Some routines in the module rand.c are taken from the GNU C Library, -and are copyrighted as described there and in the file LGPL. - -</BODY></HTML> - diff --git a/lib/ldpc/install.html b/lib/ldpc/install.html deleted file mode 100755 index f6966ab5..00000000 --- a/lib/ldpc/install.html +++ /dev/null @@ -1,82 +0,0 @@ -<HTML><HEAD> - -<TITLE> Installing the LDPC Software </TITLE> - -</HEAD><BODY> - -<H1> Installing the LDPC Software </H1> - -The LDPC software is written in C, and may well work with any C -compiler, though it has been tested only with gcc, in Unix and Linux -environments, and in the <A HREF="http://www.cygwin.com">Cygwin</A> -Unix-like environment that runs under Microsoft Windows. The -installation instructions below assume that you are using a Unix-like -system. - -<P>All the software, including the documentation you are viewing here, -is contained in a tar file, which you can download by clicking one -of the options below: -<BLOCKQUOTE> - <A HREF="http://www.cs.utoronto.ca/~radford/ftp/LDPC-yyyy-mm-dd/LDPC-yyyy-mm-dd.tar">Tar - file of LDPC software</A> (0.9 Megabytes)<BR> - <A HREF="http://www.cs.utoronto.ca/~radford/ftp/LDPC-yyyy-mm-dd/LDPC-yyyy-mm-dd.tar.gz">Gzipped - tar file of LDPC software</A> (0.4 Megabytes) -</BLOCKQUOTE> - -<P>Once you obtain the tar file (and uncompress it with gunzip if -necessary), you should extract the files with the following Unix command: -<BLOCKQUOTE><PRE> -tar xf LDPC-yyyy-mm-dd.tar -</PRE></BLOCKQUOTE> -This will create a source directory called <TT>LDPC-yyyy-mm-dd</TT>, and place -all the source, documentation, and other files in this directory. - -<P>If you prefer for this directory to be called something else, -rename it <B>now</B>, before compiling the programs, since the file -<TT>randfile</TT> in this directory, containing natural random numbers, -is accessed according to its path when the programs were compiled. - -<P>Once the tar command above has finished, you should change into the -newly-created directory, and type -<BLOCKQUOTE><PRE> -make -</PRE></BLOCKQUOTE> -If all goes well, this should compile all the programs (except for some -test programs, which can be compiled with <TT>make test</TT>). You -may want to edit the file <TT>Makefile</TT> before running <TT>make</TT> -in order to change compilation options, such as the optimization level. - -<P>You can run the programs from this source directory, or you can copy -them to some other directory by running the <TT>LDPC-install</TT> -shell file. For instance, to install them in a bin directory in your -home directory, do the following: -<BLOCKQUOTE><PRE> -./LDPC-install $HOME/bin -</PRE></BLOCKQUOTE> - -<P>The source directory contains a copy of all the HTML files -documenting the software, such as the one you are reading now, with -the file <TT>index.html</TT> being the starting point. It is best to -use this local copy when referring to the documentation, rather than -get it off the web, since that is faster and also insures that the -documentation is for the version that you are using. Just tell your -browser to open the URL -<BLOCKQUOTE><PRE> -file:<I>path-to-software</I>/index.html -</PRE></BLOCKQUOTE> -where <TT><I>path-to-software</I></TT> is the full path (starting with "/") -to the directory where you've put the software. - -<P>The command -<BLOCKQUOTE><PRE> -make clean -</PRE></BLOCKQUOTE> -will remove all the compiled programs, as well as the files created when -the <A HREF="examples.html">examples</A> are run, and <TT>core</TT>, if it -exists. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/intio.c b/lib/ldpc/intio.c deleted file mode 100755 index bfa8db9f..00000000 --- a/lib/ldpc/intio.c +++ /dev/null @@ -1,110 +0,0 @@ -/* INTIO.C - Routines to read and write integers one byte at a time. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdlib.h> -#include <stdio.h> - -#include "intio.h" - - -/* READ AN INTEGER ONE BYTE AT A TIME. Four bytes are read, ordered from - low to high order. These are considered to represent a signed integer, - in two's complement form. The value returned is this integer, converted - to whatever a C "int" is. The conversion should work as long as an "int" - is at least four bytes, even if it's not in two's complement representation - (except for the largest two's complement negative integer). - - If an error or eof is encountered, zero is returned. The caller can - check for these events using feof and ferror. - - The file read from should have been opened as "binary". -*/ - -int intio_read -( FILE *f /* File to read from */ -) -{ - unsigned char b[4]; - int top; - int i; - - for (i = 0; i<4; i++) - { if (fread(&b[i],1,1,f) != 1) return 0; - } - - top = b[3]>127 ? (int)b[3] - 256 : b[3]; - - return (top<<24) + (b[2]<<16) + (b[1]<<8) + b[0]; -} - - -/* WRITE AN INTEGER ONE BYTE AT A TIME. Four bytes are written, ordered from - low to high order. These are considered to represent a signed integer, - in two's complement form. This should work as long as the integer passed - can be represented in four bytes, even if a C "int" is longer than this. - - The file written to should have been opened as "binary". -*/ - -void intio_write -( FILE *f, /* File to write to */ - int v /* Value to write to file */ -) -{ - unsigned char b; - int i; - - for (i = 0; i<3; i++) - { b = v&0xff; - fwrite(&b,1,1,f); - v >>= 8; - } - - b = v>0 ? v : v+256; - fwrite(&b,1,1,f); -} - - -/* TEST PROGRAM. */ - -#ifdef TEST_INTIO - -main(void) -{ - FILE *f; - f = fopen("test","wb"); - intio_write(f,334); - intio_write(f,-40000); - intio_write(f,0x8fffffff); - intio_write(f,-0x8fffffff); - fclose(f); - f = fopen("test","rb"); - if (intio_read(f)!=334 - || intio_read(f)!=-40000 - || intio_read(f)!=0x8fffffff - || intio_read(f)!=-0x8fffffff) - { fprintf(stderr,"got back bad data\n"); - exit(1); - } - if (intio_read(f)!=0 || !feof(f) || ferror(f)) - { fprintf(stderr,"eof not handled correctly\n"); - exit(1); - } - fclose(f); - fprintf(stderr,"OK\n"); - exit(0); -} - -#endif diff --git a/lib/ldpc/intio.h b/lib/ldpc/intio.h deleted file mode 100755 index 03979d0c..00000000 --- a/lib/ldpc/intio.h +++ /dev/null @@ -1,17 +0,0 @@ -/* INTIO.H - Interface for reading and writing integers one byte at a time. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -int intio_read (FILE *); /* Read an integer */ -void intio_write (FILE *, int); /* Write an integer */ diff --git a/lib/ldpc/jtmode_codes/jtmskcode.results b/lib/ldpc/jtmode_codes/jtmskcode.results deleted file mode 100644 index e925b4a5..00000000 --- a/lib/ldpc/jtmode_codes/jtmskcode.results +++ /dev/null @@ -1,12 +0,0 @@ -rate 1/2 constraint len 13, bpsk, ngood, nbad 10^6 trials - 0.00 43968 30 - 0.50 111824 33 - 1.00 238157 21 - 1.50 425263 20 - 2.00 634824 14 - 2.50 812206 2 - 3.00 924507 2 - 3.50 975836 0 - 4.00 993832 0 - 4.50 998695 0 - 5.00 999771 0 diff --git a/lib/ldpc/jtmode_codes/peg-128-80-denev20.gen b/lib/ldpc/jtmode_codes/peg-128-80-denev20.gen Binary files differdeleted file mode 100644 index ae887a46..00000000 --- a/lib/ldpc/jtmode_codes/peg-128-80-denev20.gen +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-128-80-denev20.pchk b/lib/ldpc/jtmode_codes/peg-128-80-denev20.pchk Binary files differdeleted file mode 100644 index dac8ee61..00000000 --- a/lib/ldpc/jtmode_codes/peg-128-80-denev20.pchk +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-128-80-denev7.gen b/lib/ldpc/jtmode_codes/peg-128-80-denev7.gen Binary files differdeleted file mode 100644 index 9c73857d..00000000 --- a/lib/ldpc/jtmode_codes/peg-128-80-denev7.gen +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-128-80-denev7.pchk b/lib/ldpc/jtmode_codes/peg-128-80-denev7.pchk Binary files differdeleted file mode 100644 index 0985c5a8..00000000 --- a/lib/ldpc/jtmode_codes/peg-128-80-denev7.pchk +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-128-80-reg3.gen b/lib/ldpc/jtmode_codes/peg-128-80-reg3.gen Binary files differdeleted file mode 100644 index 30414fdb..00000000 --- a/lib/ldpc/jtmode_codes/peg-128-80-reg3.gen +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-128-80-reg3.pchk b/lib/ldpc/jtmode_codes/peg-128-80-reg3.pchk Binary files differdeleted file mode 100644 index e257b2cf..00000000 --- a/lib/ldpc/jtmode_codes/peg-128-80-reg3.pchk +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-128-80-reg4.gen b/lib/ldpc/jtmode_codes/peg-128-80-reg4.gen Binary files differdeleted file mode 100644 index 092a667e..00000000 --- a/lib/ldpc/jtmode_codes/peg-128-80-reg4.gen +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-128-80-reg4.pchk b/lib/ldpc/jtmode_codes/peg-128-80-reg4.pchk Binary files differdeleted file mode 100644 index 9d8649c8..00000000 --- a/lib/ldpc/jtmode_codes/peg-128-80-reg4.pchk +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-198-72-irreg-8x3-2x4.gen b/lib/ldpc/jtmode_codes/peg-198-72-irreg-8x3-2x4.gen Binary files differdeleted file mode 100644 index 977aa911..00000000 --- a/lib/ldpc/jtmode_codes/peg-198-72-irreg-8x3-2x4.gen +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-198-72-irreg-8x3-2x4.pchk b/lib/ldpc/jtmode_codes/peg-198-72-irreg-8x3-2x4.pchk Binary files differdeleted file mode 100644 index 5fa60e7a..00000000 --- a/lib/ldpc/jtmode_codes/peg-198-72-irreg-8x3-2x4.pchk +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-198-72-reg3.gen b/lib/ldpc/jtmode_codes/peg-198-72-reg3.gen Binary files differdeleted file mode 100644 index 15241c91..00000000 --- a/lib/ldpc/jtmode_codes/peg-198-72-reg3.gen +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-198-72-reg3.pchk b/lib/ldpc/jtmode_codes/peg-198-72-reg3.pchk Binary files differdeleted file mode 100644 index dd8e4561..00000000 --- a/lib/ldpc/jtmode_codes/peg-198-72-reg3.pchk +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-198-72-reg4.gen b/lib/ldpc/jtmode_codes/peg-198-72-reg4.gen Binary files differdeleted file mode 100644 index 66c4bae9..00000000 --- a/lib/ldpc/jtmode_codes/peg-198-72-reg4.gen +++ /dev/null diff --git a/lib/ldpc/jtmode_codes/peg-198-72-reg4.pchk b/lib/ldpc/jtmode_codes/peg-198-72-reg4.pchk Binary files differdeleted file mode 100644 index 4de31430..00000000 --- a/lib/ldpc/jtmode_codes/peg-198-72-reg4.pchk +++ /dev/null diff --git a/lib/ldpc/make-gen.c b/lib/ldpc/make-gen.c deleted file mode 100755 index 4c948047..00000000 --- a/lib/ldpc/make-gen.c +++ /dev/null @@ -1,350 +0,0 @@ -/* MAKE-GEN.C - Make generator matrix from parity-check matrix. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -#include "alloc.h" -#include "intio.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" - -typedef enum { Sparse, Dense, Mixed } make_method; /* Ways of making it */ - -void make_dense_mixed (FILE *, make_method, char *); /* Procs to make it */ -void make_sparse (FILE *, mod2sparse_strategy, int, int); -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char *pchk_file, *gen_file, *other_gen_file; - mod2sparse_strategy strategy; - int abandon_when, abandon_number; - make_method method; - char *meth; - char junk; - FILE *f; - - /* Look at arguments. */ - - if (!(pchk_file = argv[1]) - || !(gen_file = argv[2]) - || !(meth = argv[3])) - { usage(); - } - - if (strcmp(meth,"sparse")==0) - { method = Sparse; - strategy = Mod2sparse_minprod; - abandon_number = 0; - if (argv[4]) - { if (strcmp(argv[4],"first")==0) strategy = Mod2sparse_first; - else if (strcmp(argv[4],"mincol")==0) strategy = Mod2sparse_mincol; - else if (strcmp(argv[4],"minprod")==0) strategy = Mod2sparse_minprod; - else - { usage(); - } - if (argv[5]) - { if (sscanf(argv[5],"%d%c",&abandon_number,&junk)!=1 || abandon_number<=0 - || !argv[6] - || sscanf(argv[6],"%d%c",&abandon_when,&junk)!=1 || abandon_when<=0 - || argv[7]) - { usage(); - } - } - } - } - else if (strcmp(meth,"dense")==0) - { method = Dense; - other_gen_file = argv[4]; - if (other_gen_file && argv[5]) - { usage(); - } - } - else if (strcmp(meth,"mixed")==0) - { method = Mixed; - other_gen_file = argv[4]; - if (other_gen_file && argv[5]) - { usage(); - } - } - else - { usage(); - } - - /* Read parity check matrix. */ - - read_pchk(pchk_file); - - if (N<=M) - { fprintf(stderr, - "Can't encode if number of bits (%d) isn't greater than number of checks (%d)\n",N,M); - exit(1); - } - - /* Create generator matrix file. */ - - f = open_file_std(gen_file,"wb"); - if (f==NULL) - { fprintf(stderr,"Can't create generator matrix file: %s\n",gen_file); - exit(1); - } - - /* Allocate space for row and column permutations. */ - - cols = chk_alloc (N, sizeof *cols); - rows = chk_alloc (M, sizeof *rows); - - /* Create generator matrix with specified method. */ - - switch (method) - { case Sparse: - { make_sparse(f,strategy,abandon_number,abandon_when); - break; - } - case Dense: case Mixed: - { make_dense_mixed(f,method,other_gen_file); - break; - } - default: abort(); - } - - /* Check for error writing file. */ - - if (ferror(f) || fclose(f)!=0) - { fprintf(stderr,"Error writing to generator matrix file\n"); - exit(1); - } - - return 0; -} - - -/* MAKE DENSE OR MIXED REPRESENTATION OF GENERATOR MATRIX. */ - -void make_dense_mixed -( FILE *f, - make_method method, - char *other_gen_file -) -{ - mod2dense *DH, *A, *A2, *AI, *B; - int i, j, c, c2, n; - int *rows_inv; - - DH = mod2dense_allocate(M,N); - AI = mod2dense_allocate(M,M); - B = mod2dense_allocate(M,N-M); - G = mod2dense_allocate(M,N-M); - - mod2sparse_to_dense(H,DH); - - /* If another generator matrix was specified, invert using the set of - columns it specifies. */ - - if (other_gen_file) - { - read_gen(other_gen_file,1,0); - - A = mod2dense_allocate(M,M); - mod2dense_copycols(DH,A,cols); - - if (!mod2dense_invert(A,AI)) - { fprintf(stderr, - "Couldn't invert sub-matrix with column order given in other file\n"); - exit(1); - } - - mod2dense_copycols(DH,B,cols+M); - } - - /* If no other generator matrix was specified, invert using whatever - selection of rows/columns is needed to get a non-singular sub-matrix. */ - - if (!other_gen_file) - { - A = mod2dense_allocate(M,N); - A2 = mod2dense_allocate(M,N); - - n = mod2dense_invert_selected(DH,A2,rows,cols); - mod2sparse_to_dense(H,DH); /* DH was destroyed by invert_selected */ - - if (n>0) - { fprintf(stderr,"Note: Parity check matrix has %d redundant checks\n",n); - } - - rows_inv = chk_alloc (M, sizeof *rows_inv); - - for (i = 0; i<M; i++) - { rows_inv[rows[i]] = i; - } - - mod2dense_copyrows(A2,A,rows); - mod2dense_copycols(A,A2,cols); - mod2dense_copycols(A2,AI,rows_inv); - - mod2dense_copycols(DH,B,cols+M); - } - - /* Form final generator matrix. */ - - if (method==Dense) - { mod2dense_multiply(AI,B,G); - } - else if (method==Mixed) - { G = AI; - } - else - { abort(); - } - - /* Compute and print number of 1s. */ - - if (method==Dense) - { c = 0; - for (i = 0; i<M; i++) - { for (j = 0; j<N-M; j++) - { c += mod2dense_get(G,i,j); - } - } - fprintf(stderr, - "Number of 1s per check in Inv(A) X B is %.1f\n", (double)c/M); - } - - if (method==Mixed) - { c = 0; - for (i = 0; i<M; i++) - { for (j = 0; j<M; j++) - { c += mod2dense_get(G,i,j); - } - } - c2 = 0; - for (i = M; i<N; i++) - { c2 += mod2sparse_count_col(H,cols[i]); - } - fprintf(stderr, - "Number of 1s per check in Inv(A) is %.1f, in B is %.1f, total is %.1f\n", - (double)c/M, (double)c2/M, (double)(c+c2)/M); - } - - /* Write the represention of the generator matrix to the file. */ - - intio_write(f,('G'<<8)+0x80); - - if (method==Dense) - { fwrite ("d", 1, 1, f); - } - if (method==Mixed) - { fwrite ("m", 1, 1, f); - } - - intio_write(f,M); - intio_write(f,N); - - for (i = 0; i<N; i++) - { intio_write(f,cols[i]); - } - - mod2dense_write (f, G); -} - - -/* MAKE SPARSE REPRESENTATION OF GENERATOR MATRIX. */ - -void make_sparse -( FILE *f, - mod2sparse_strategy strategy, - int abandon_number, - int abandon_when -) -{ - int n, cL, cU, cB; - int i; - - /* Find LU decomposition. */ - - L = mod2sparse_allocate(M,M); - U = mod2sparse_allocate(M,N); - - n = mod2sparse_decomp(H,M,L,U,rows,cols,strategy,abandon_number,abandon_when); - - if (n!=0 && abandon_number==0) - { fprintf(stderr,"Note: Parity check matrix has %d redundant checks\n",n); - } - if (n!=0 && abandon_number>0) - { fprintf(stderr, - "Note: Have %d dependent columns, but this could be due to abandonment.\n",n); - fprintf(stderr, - " Try again with lower abandonment number.\n"); - exit(1); - } - - /* Compute and print number of 1s. */ - - cL = cU = cB = 0; - - for (i = 0; i<M; i++) cL += mod2sparse_count_row(L,i); - for (i = 0; i<M; i++) cU += mod2sparse_count_row(U,i); - for (i = M; i<N; i++) cB += mod2sparse_count_col(H,cols[i]); - - fprintf(stderr, - "Number of 1s per check in L is %.1f, U is %.1f, B is %.1f, total is %.1f\n", - (double)cU/M, (double)cL/M, (double)cB/M, (double)(cL+cU+cB)/M); - - /* Write it all to the generator matrix file. */ - - intio_write(f,('G'<<8)+0x80); - - fwrite ("s", 1, 1, f); - - intio_write(f,M); - intio_write(f,N); - - for (i = 0; i<N; i++) - { intio_write(f,cols[i]); - } - - for (i = 0; i<M; i++) - { intio_write(f,rows[i]); - } - - mod2sparse_write (f, L); - mod2sparse_write (f, U); -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf (stderr, - "Usage: make-gen pchk-file gen-file method\n"); - fprintf (stderr, - "Method: sparse [ \"first\" | \"mincol\" | \"minprod\" ] [ abandon_num abandon_when ]\n"); - fprintf (stderr, - " or: dense [ other-gen-file ]\n"); - fprintf (stderr, - " or: mixed [ other-gen-file ]\n"); - exit(1); -} diff --git a/lib/ldpc/make-ldpc.c b/lib/ldpc/make-ldpc.c deleted file mode 100755 index 300b21ae..00000000 --- a/lib/ldpc/make-ldpc.c +++ /dev/null @@ -1,415 +0,0 @@ -/* MAKE-LDPC.C - Make a Low Density Parity Check code's parity check matrix. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal and Peter Junteng Liu. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "rand.h" -#include "alloc.h" -#include "intio.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" -#include "distrib.h" - - -/* METHODS FOR CONSTRUCTING CODES. */ - -typedef enum -{ Evencol, /* Uniform number of bits per column, with number specified */ - Evenboth /* Uniform (as possible) over both columns and rows */ -} make_method; - - -void make_ldpc (int, make_method, distrib *, int); -int *column_partition (distrib *, int); -void usage (void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - make_method method; - char *file, **meth; - int seed, no4cycle; - distrib *d; - char junk; - FILE *f; - - /* Look at initial arguments. */ - - if (!(file = argv[1]) - || !argv[2] || sscanf(argv[2],"%d%c",&M,&junk)!=1 || M<=0 - || !argv[3] || sscanf(argv[3],"%d%c",&N,&junk)!=1 || N<=0 - || !argv[4] || sscanf(argv[4],"%d%c",&seed,&junk)!=1) - { usage(); - } - - /* Look at the arguments specifying the method for producing the code. */ - - meth = argv+5; - - if (!meth[0]) usage(); - - no4cycle = 0; - - if (strcmp(meth[0],"evencol")==0 || strcmp(meth[0],"evenboth")==0) - { method = strcmp(meth[0],"evencol")==0 ? Evencol : Evenboth; - if (!meth[1]) - { usage(); - } - d = distrib_create(meth[1]); - if (d==0) - { usage(); - } - if (meth[2]) - { if (strcmp(meth[2],"no4cycle")==0) - { no4cycle = 1; - if (meth[3]) - { usage(); - } - } - else - { usage(); - } - } - } - else - { usage(); - } - - /* Check for some problems. */ - - if (distrib_max(d)>M) - { fprintf(stderr, - "At least one checks per bit (%d) is greater than total checks (%d)\n", - distrib_max(d), M); - exit(1); - } - - if (distrib_max(d)==M && N>1 && no4cycle) - { fprintf(stderr, - "Can't eliminate cycles of length four with this many checks per bit\n"); - exit(1); - } - - /* Make the parity check matrix. */ - - make_ldpc(seed,method,d,no4cycle); - - /* Write out the parity check matrix. */ - - f = open_file_std(file,"wb"); - if (f==NULL) - { fprintf(stderr,"Can't create parity check file: %s\n",file); - exit(1); - } - - intio_write(f,('P'<<8)+0x80); - - if (ferror(f) || !mod2sparse_write(f,H) || fclose(f)!=0) - { fprintf(stderr,"Error writing to parity check file %s\n",file); - exit(1); - } - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr,"Usage: make-ldpc pchk-file n-checks n-bits seed method\n"); - fprintf(stderr,"Method: evencol checks-per-col [ \"no4cycle\" ]\n"); - fprintf(stderr," or: evencol checks-distribution [ \"no4cycle\" ]\n"); - fprintf(stderr," or: evenboth checks-per-col [ \"no4cycle\" ]\n"); - fprintf(stderr," or: evenboth checks-distribution [ \"no4cycle\" ]\n"); - exit(1); -} - - -/* CREATE A SPARSE PARITY-CHECK MATRIX. Of size M by N, stored in H. */ - -void make_ldpc -( int seed, /* Random number seed */ - make_method method, /* How to make it */ - distrib *d, /* Distribution list specified */ - int no4cycle /* Eliminate cycles of length four? */ -) -{ - mod2entry *e, *f, *g, *h; - int added, uneven, elim4, all_even, n_full, left; - int i, j, k, t, z, cb_N; - int *part, *u; - - rand_seed(10*seed+1); - - H = mod2sparse_allocate(M,N); - part = column_partition(d,N); - - /* Create the initial version of the parity check matrix. */ - - switch (method) - { - case Evencol: - { - z = 0; - left = part[z]; - - for (j = 0; j<N; j++) - { while (left==0) - { z += 1; - if (z>distrib_size(d)) - { abort(); - } - left = part[z]; - } - for (k = 0; k<distrib_num(d,z); k++) - { do - { i = rand_int(M); - } while (mod2sparse_find(H,i,j)); - mod2sparse_insert(H,i,j); - } - left -= 1; - } - - break; - } - - case Evenboth: - { - cb_N = 0; - for (z = 0; z<distrib_size(d); z++) - { cb_N += distrib_num(d,z) * part[z]; - } - - u = chk_alloc (cb_N, sizeof *u); - - for (k = cb_N-1; k>=0; k--) - { u[k] = k%M; - } - - uneven = 0; - t = 0; - z = 0; - left = part[z]; - - for (j = 0; j<N; j++) - { - while (left==0) - { z += 1; - if (z>distrib_size(d)) - { abort(); - } - left = part[z]; - } - - for (k = 0; k<distrib_num(d,z); k++) - { - for (i = t; i<cb_N && mod2sparse_find(H,u[i],j); i++) ; - - if (i==cb_N) - { uneven += 1; - do - { i = rand_int(M); - } while (mod2sparse_find(H,i,j)); - mod2sparse_insert(H,i,j); - } - else - { do - { i = t + rand_int(cb_N-t); - } while (mod2sparse_find(H,u[i],j)); - mod2sparse_insert(H,u[i],j); - u[i] = u[t]; - t += 1; - } - } - - left -= 1; - } - - if (uneven>0) - { fprintf(stderr,"Had to place %d checks in rows unevenly\n",uneven); - } - - break; - } - - default: abort(); - } - - /* Add extra bits to avoid rows with less than two checks. */ - - added = 0; - - for (i = 0; i<M; i++) - { e = mod2sparse_first_in_row(H,i); - if (mod2sparse_at_end(e)) - { j = rand_int(N); - e = mod2sparse_insert(H,i,j); - added += 1; - } - e = mod2sparse_first_in_row(H,i); - if (mod2sparse_at_end(mod2sparse_next_in_row(e)) && N>1) - { do - { j = rand_int(N); - } while (j==mod2sparse_col(e)); - mod2sparse_insert(H,i,j); - added += 1; - } - } - - if (added>0) - { fprintf(stderr, - "Added %d extra bit-checks to make row counts at least two\n", - added); - } - - /* Add extra bits to try to avoid problems with even column counts. */ - - n_full = 0; - all_even = 1; - for (z = 0; z<distrib_size(d); z++) - { if (distrib_num(d,z)==M) - { n_full += part[z]; - } - if (distrib_num(d,z)%2==1) - { all_even = 0; - } - } - - if (all_even && N-n_full>1 && added<2) - { int a; - for (a = 0; added+a<2; a++) - { do - { i = rand_int(M); - j = rand_int(N); - } while (mod2sparse_find(H,i,j)); - mod2sparse_insert(H,i,j); - } - fprintf(stderr, - "Added %d extra bit-checks to try to avoid problems from even column counts\n", - a); - } - - /* Eliminate cycles of length four, if asked, and if possible. */ - - if (no4cycle) - { - elim4 = 0; - - for (t = 0; t<10; t++) - { k = 0; - for (j = 0; j<N; j++) - { for (e = mod2sparse_first_in_col(H,j); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_col(e)) - { for (f = mod2sparse_first_in_row(H,mod2sparse_row(e)); - !mod2sparse_at_end(f); - f = mod2sparse_next_in_row(f)) - { if (f==e) continue; - for (g = mod2sparse_first_in_col(H,mod2sparse_col(f)); - !mod2sparse_at_end(g); - g = mod2sparse_next_in_col(g)) - { if (g==f) continue; - for (h = mod2sparse_first_in_row(H,mod2sparse_row(g)); - !mod2sparse_at_end(h); - h = mod2sparse_next_in_row(h)) - { if (mod2sparse_col(h)==j) - { do - { i = rand_int(M); - } while (mod2sparse_find(H,i,j)); - mod2sparse_delete(H,e); - mod2sparse_insert(H,i,j); - elim4 += 1; - k += 1; - goto nextj; - } - } - } - } - } - nextj: ; - } - if (k==0) break; - } - - if (elim4>0) - { fprintf(stderr, - "Eliminated %d cycles of length four by moving checks within column\n", - elim4); - } - - if (t==10) - { fprintf(stderr, - "Couldn't eliminate all cycles of length four in 10 passes\n"); - } - } -} - - -/* PARTITION THE COLUMNS ACCORDING TO THE SPECIFIED PROPORTIONS. It - may not be possible to do this exactly. Returns a pointer to an - array of integers containing the numbers of columns corresponding - to the entries in the distribution passed. */ - -int *column_partition -( distrib *d, /* List of proportions and number of check-bits */ - int n /* Total number of columns to partition */ -) -{ - double *trunc; - int *part; - int cur, used; - int i, j; - - trunc = chk_alloc (distrib_size(d), sizeof(double)); - part = chk_alloc (distrib_size(d), sizeof(int)); - - used = 0; - for (i = 0; i<distrib_size(d); i++) - { cur = floor(distrib_prop(d,i)*n); - part[i] = cur; - trunc[i] = distrib_prop(d,i)*n - cur; - used += cur; - } - - if (used>n) - { abort(); - } - - while (used<n) - { cur = 0; - for (j = 1; j<distrib_size(d); j++) - { if (trunc[j]>trunc[cur]) - { cur = j; - } - } - part[cur] += 1; - used += 1; - trunc[cur] = -1; - } - - free(trunc); - return part; -} diff --git a/lib/ldpc/make-pchk.c b/lib/ldpc/make-pchk.c deleted file mode 100755 index 7459ca9b..00000000 --- a/lib/ldpc/make-pchk.c +++ /dev/null @@ -1,93 +0,0 @@ -/* MAKE-PCHK.C - Make a parity check matrix explicitly. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "alloc.h" -#include "intio.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" - - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char **bit_specs; - char *file; - FILE *f; - int i, j, k; - char junk; - - if (!(file = argv[1]) - || !argv[2] || sscanf(argv[2],"%d%c",&M,&junk)!=1 || M<=0 - || !argv[3] || sscanf(argv[3],"%d%c",&N,&junk)!=1 || N<=0) - { usage(); - } - - bit_specs = argv+4; - - if (bit_specs[0]==0) - { usage(); - } - - H = mod2sparse_allocate(M,N); - - for (k = 0; bit_specs[k]!=0; k++) - { if (sscanf(bit_specs[k],"%d:%d%c",&i,&j,&junk)!=2 || i<0 || j<0) - { usage(); - } - if (i>=M || j>=N) - { fprintf(stderr,"Bit %d:%d is out of range\n",i,j); - exit(1); - } - mod2sparse_insert(H,i,j); - } - - f = open_file_std(file,"wb"); - if (f==NULL) - { fprintf(stderr,"Can't create parity check file: %s\n",file); - exit(1); - } - - intio_write(f,('P'<<8)+0x80); - - if (ferror(f) || !mod2sparse_write(f,H) || fclose(f)!=0) - { fprintf(stderr,"Error writing to parity check file %s\n",file); - exit(1); - } - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr,"Usage: make-pchk pchk-file n-checks n-bits row:col ...\n"); - exit(1); -} diff --git a/lib/ldpc/mod2convert-test-out b/lib/ldpc/mod2convert-test-out deleted file mode 100755 index 430eec0b..00000000 --- a/lib/ldpc/mod2convert-test-out +++ /dev/null @@ -1,9 +0,0 @@ - -Creating sparse matrix. -Converting from sparse to dense. -Converting back to dense again. -Testing for equality of two sparse matrices: OK. -Converting to dense once again. -Testing for equality of two dense matrices: OK. - -DONE WITH TESTS. diff --git a/lib/ldpc/mod2convert-test.c b/lib/ldpc/mod2convert-test.c deleted file mode 100755 index eac257ff..00000000 --- a/lib/ldpc/mod2convert-test.c +++ /dev/null @@ -1,80 +0,0 @@ -/* MOD2CONVERT-TEST. C - Program to test mod2convert module. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* Correct output for this program is saved in the file mod2convert-test-out */ - - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> - -#include "mod2dense.h" -#include "mod2sparse.h" -#include "mod2convert.h" -#include "rand.h" - -#define Rows 40 /* Dimensions of matrix to use in test */ -#define Cols 13 - -#define N 100 /* Number of bits to set in test matrix (some may be - duplicates, leading to fewer 1's in matrix */ - -main(void) -{ - mod2sparse *sm1, *sm2; - mod2dense *dm1, *dm2; - int i; - - sm1 = mod2sparse_allocate(Rows,Cols); - sm2 = mod2sparse_allocate(Rows,Cols); - - dm1 = mod2dense_allocate(Rows,Cols); - dm2 = mod2dense_allocate(Rows,Cols); - - printf("\nCreating sparse matrix.\n"); - fflush(stdout); - - for (i = 0; i<N; i++) - { mod2sparse_insert(sm1,rand_int(Rows),rand_int(Cols)); - } - - printf("Converting from sparse to dense.\n"); - fflush(stdout); - - mod2sparse_to_dense(sm1,dm1); - - printf("Converting back to dense again.\n"); - fflush(stdout); - - mod2dense_to_sparse(dm1,sm2); - - printf("Testing for equality of two sparse matrices: %s.\n", - mod2sparse_equal(sm1,sm2) ? "OK" : "NOT OK"); - fflush(stdout); - - printf("Converting to dense once again.\n"); - fflush(stdout); - - mod2sparse_to_dense(sm2,dm2); - - printf("Testing for equality of two dense matrices: %s.\n", - mod2dense_equal(dm1,dm2) ? "OK" : "NOT OK"); - fflush(stdout); - - printf("\nDONE WITH TESTS.\n"); - - exit(0); -} diff --git a/lib/ldpc/mod2convert.c b/lib/ldpc/mod2convert.c deleted file mode 100755 index 20858582..00000000 --- a/lib/ldpc/mod2convert.c +++ /dev/null @@ -1,83 +0,0 @@ -/* MOD2CONVERT.C - Routines converting between sparse and dense mod2 matrices.*/ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* NOTE: See mod2convert.html for documentation on these procedures. */ - - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> - -#include "mod2dense.h" -#include "mod2sparse.h" -#include "mod2convert.h" - - -/* CONVERT A MOD2 MATRIX FROM SPARSE TO DENSE FORM. */ - -void mod2sparse_to_dense -( mod2sparse *m, /* Sparse matrix to convert */ - mod2dense *r /* Place to store result */ -) -{ - mod2entry *e; - int i; - - if (mod2sparse_rows(m)>mod2dense_rows(r) - || mod2sparse_cols(m)>mod2dense_cols(r)) - { fprintf(stderr, - "mod2sparse_to_dense: Dimension of result matrix is less than source\n"); - exit(1); - } - - mod2dense_clear(r); - - for (i = 0; i<mod2sparse_rows(m); i++) - { e = mod2sparse_first_in_row(m,i); - while (!mod2sparse_at_end(e)) - { mod2dense_set(r,i,mod2sparse_col(e),1); - e = mod2sparse_next_in_row(e); - } - } -} - - -/* CONVERT A MOD2 MATRIX FROM DENSE TO SPARSE FORM. */ - -void mod2dense_to_sparse -( mod2dense *m, /* Dense matrix to convert */ - mod2sparse *r /* Place to store result */ -) -{ - int i, j; - - if (mod2dense_rows(m)>mod2sparse_rows(r) - || mod2dense_cols(m)>mod2sparse_cols(r)) - { fprintf(stderr, - "mod2dense_to_sparse: Dimension of result matrix is less than source\n"); - exit(1); - } - - mod2sparse_clear(r); - - for (i = 0; i<mod2dense_rows(m); i++) - { for (j = 0; j<mod2dense_cols(m); j++) - { if (mod2dense_get(m,i,j)) - { mod2sparse_insert(r,i,j); - } - } - } -} diff --git a/lib/ldpc/mod2convert.h b/lib/ldpc/mod2convert.h deleted file mode 100755 index bd1a2d84..00000000 --- a/lib/ldpc/mod2convert.h +++ /dev/null @@ -1,18 +0,0 @@ -/* MOD2CONVERT.H - Routines converting between sparse and dense mod2 matrices.*/ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -void mod2sparse_to_dense (mod2sparse *, mod2dense *); -void mod2dense_to_sparse (mod2dense *, mod2sparse *); diff --git a/lib/ldpc/mod2convert.html b/lib/ldpc/mod2convert.html deleted file mode 100755 index 7f77358f..00000000 --- a/lib/ldpc/mod2convert.html +++ /dev/null @@ -1,51 +0,0 @@ -<HTML><HEAD> - -<TITLE> Modulo-2 Matrix Sparse/Dense Conversion </TITLE> - -</HEAD><BODY> - - -<H1> Modulo-2 Matrix Sparse/Dense Conversion </H1> - -<P>The routines below convert modulo-2 matrices between the form used by -the <A HREF="mod2dense.html">routines for dense modulo-2 matrices</A> -and the form used by the <A HREF="mod2dense.html">routines for sparse -modulo-2 matrices</A>. - -<P><B>Header files required</B>: -<TT>mod2sparse.h mod2dense.h mod2convert.h</TT> - - -<P><A NAME="sparse_to_dense"><HR><B>mod2sparse_to_dense</B>: -Convert a modulo-2 matrix from sparse to dense form.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_to_dense -( mod2sparse *m, /* Sparse matrix to convert */ - mod2dense *r /* Place to store result */ -) -</PRE></BLOCKQUOTE> - -The dense matrix, r, must already have been allocated, and must have at -least as many rows and columns as m, the sparse matrix to be converted. - - -<P><A NAME="dense_to_sparse"><HR><B>mod2dense_to_sparse</B>: -Convert a modulo-2 matrix from dense to sparse form.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_to_sparse -( mod2dense *m, /* Dense matrix to convert */ - mod2sparse *r /* Place to store result */ -) -</PRE></BLOCKQUOTE> - -The sparse matrix, r, must already have been allocated, and must have at -least as many rows and columns as m, the dense matrix to be converted. - - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/mod2dense-test-out b/lib/ldpc/mod2dense-test-out deleted file mode 100755 index e38525b6..00000000 --- a/lib/ldpc/mod2dense-test-out +++ /dev/null @@ -1,699 +0,0 @@ - -PART 1: - -Matrix m1: - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - -Matrix m2, as read from file. Should be same as m1 above. - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - -Test of equality of m1 & m2 (should be 1): 1 - -Matrix m3, copied from m1 above. - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - -Test of equality of m1 & m3 (should be 1): 1 - -Matrix m3 again, should now be all zeros. - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - -Test of equality of m1 & m3 (should be 0): 0 - - -PART 2: - -Transpose of m1. - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 - 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - -PART 3: - -Matrix s0. - - 0 0 0 0 0 0 0 - 0 0 0 1 1 0 0 - 1 0 0 0 0 0 0 - 0 1 0 0 0 0 0 - 0 0 0 0 0 0 0 - -Matrix s1. - - 0 0 0 0 0 0 0 - 0 0 0 1 0 1 0 - 0 0 0 0 0 0 0 - 1 1 0 0 0 0 1 - 0 0 0 0 0 0 0 - -Matrix s2. - - 1 0 0 0 - 0 1 0 0 - 0 0 0 0 - 0 0 0 0 - 0 0 0 0 - 0 1 1 1 - 0 0 0 0 - -Sum of s0 and s1. - - 0 0 0 0 0 0 0 - 0 0 0 0 1 1 0 - 1 0 0 0 0 0 0 - 1 0 0 0 0 0 1 - 0 0 0 0 0 0 0 - -Product of s1 and s2. - - 0 0 0 0 - 0 1 1 1 - 0 0 0 0 - 1 1 0 0 - 0 0 0 0 - -Above matrix with (1,2) cleared. - - 0 0 0 0 - 0 1 0 1 - 0 0 0 0 - 1 1 0 0 - 0 0 0 0 - - -PART 4: - -Matrix s1. - - 0 0 0 1 0 - 0 1 0 0 1 - 1 0 0 0 0 - 0 1 1 0 0 - 1 0 1 0 0 - -Matrix s3, the inverse of s1 (return code 1). - - 0 0 1 0 0 - 0 0 1 1 1 - 0 0 1 0 1 - 1 0 0 0 0 - 0 1 1 1 1 - -Original matrix times inverse (should be identity). - - 1 0 0 0 0 - 0 1 0 0 0 - 0 0 1 0 0 - 0 0 0 1 0 - 0 0 0 0 1 - -Inverse times original matrix (should be identity). - - 1 0 0 0 0 - 0 1 0 0 0 - 0 0 1 0 0 - 0 0 0 1 0 - 0 0 0 0 1 - -Inverse of inverse (should be same as original s1). - 0 0 0 1 0 - 0 1 0 0 1 - 1 0 0 0 0 - 0 1 1 0 0 - 1 0 1 0 0 - -Test of equality with original (should be 1): 1 - -Matrix s1. - - 0 0 0 0 1 0 0 - 0 1 0 0 0 0 1 - 1 0 0 0 0 0 0 - 0 1 1 0 0 0 0 - 1 0 1 0 0 0 0 - -Matrix s3, from invert_selected applied to s1 (return code 0). - - 0 0 0 0 1 0 0 - 1 0 1 0 0 0 1 - 1 0 0 0 0 0 0 - 1 0 0 0 0 0 1 - 1 1 1 0 0 0 1 - - row ordering returned: 0 1 2 3 4 - - column ordering returned: 4 1 0 2 6 5 3 - -Columns extracted in order from original matrix. - - 1 0 0 0 0 - 0 1 0 0 1 - 0 0 1 0 0 - 0 1 0 1 0 - 0 0 1 1 0 - -Inverse of above calculated using mod2dense_inverse (return code 1) - - 1 0 0 0 0 - 0 0 1 1 1 - 0 0 1 0 0 - 0 0 1 0 1 - 0 1 1 1 1 - -Columns extracted in order from s3 (should also be inverse of above). - - 1 0 0 0 0 - 0 0 1 1 1 - 0 0 1 0 0 - 0 0 1 0 1 - 0 1 1 1 1 - -Matrix s1. - - 1 1 0 0 0 0 0 - 0 1 1 0 0 0 0 - 1 0 1 0 0 0 0 - 0 0 0 1 1 0 0 - 0 0 0 0 0 0 0 - -Matrix s3, from invert_selected applied to s1 (return code 2). - - 1 1 0 0 0 0 0 - 0 1 0 0 0 0 0 - 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 - - row ordering returned: 0 1 3 4 2 - - column ordering returned: 0 1 3 2 4 5 6 - -Matrix s4, from copying rows in order from s3. - - 1 1 0 0 0 0 0 - 0 1 0 0 0 0 0 - 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 - -PART 5: - -Matrix s1. - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 - -Matrix s3, the inverse of s1 (return code 1). - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 1 1 0 1 1 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 1 - 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 - 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 1 0 1 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 - 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 1 - 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 1 0 1 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - -Original matrix times inverse (should be identity). - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 - -Inverse times original matrix (should be identity). - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 - -Inverse of inverse (should be same as original s1). - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 - -Test of equality with original (should be 1): 1 - - -PART 6: - -Matrix s1. - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - -Result of forcibly inverting s1 (needed to alter 7 elements). - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - -Altered elements at these indexes: - - 3 3 - 7 7 - 15 15 - 21 21 - 23 23 - 29 29 - 32 12 - -Inverse of inverse of altered matrix. - - 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - -DONE WITH TESTS. diff --git a/lib/ldpc/mod2dense-test.c b/lib/ldpc/mod2dense-test.c deleted file mode 100755 index f38ad54f..00000000 --- a/lib/ldpc/mod2dense-test.c +++ /dev/null @@ -1,560 +0,0 @@ -/* MOD2DENSE-TEST. C - Program to test mod2dense module. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* Correct output for this program is saved in the file mod2dense-test-out */ - - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> - -#include "mod2dense.h" - - -main(void) -{ - mod2dense *m1, *m2, *m3, *m4; - mod2dense *s0, *s1, *s2, *s3, *s4, *s5; - int a_row[35], a_col[35]; - int code; - int i, j; - FILE *f; - - - printf("\nPART 1:\n\n"); - - /* Set up m1 with bits on a diagonal plus a few more set to 1. */ - - m1 = mod2dense_allocate(35,40); - - mod2dense_clear(m1); - - for (i = 0; i<35; i++) mod2dense_set(m1,i,i,1); - - mod2dense_set(m1,2,3,1); - mod2dense_set(m1,34,4,1); - mod2dense_set(m1,10,38,1); - - /* Print m1. */ - - printf("Matrix m1:\n\n"); - mod2dense_print(stdout,m1); - printf("\n"); fflush(stdout); - - /* Store m1 in a file. */ - - f = fopen("test-file","wb"); - if (f==0) - { fprintf(stderr,"Can't create test-file\n"); - exit(1); - } - - if (!mod2dense_write(f,m1)) - { printf("Error from mod2dense_write\n"); - } - - fclose(f); - - /* Read matrix written above back into m2. */ - - f = fopen("test-file","rb"); - if (f==0) - { fprintf(stderr,"Can't open test-file\n"); - exit(1); - } - - m2 = mod2dense_read(f); - - if (m2==0) - { printf("Error from mod2dense_read\n"); - exit(1); - } - - /* Print m2, along with result of equality test. */ - - printf("Matrix m2, as read from file. Should be same as m1 above.\n\n"); - mod2dense_print(stdout,m2); - printf("\n"); fflush(stdout); - - printf("Test of equality of m1 & m2 (should be 1): %d\n\n", - mod2dense_equal(m1,m2)); - - /* Copy m1 to m3. */ - - m3 = mod2dense_allocate(mod2dense_rows(m1),mod2dense_cols(m1)); - - mod2dense_copy(m1,m3); - - /* Print m3, along with result of equality test. */ - - printf("Matrix m3, copied from m1 above.\n\n"); - mod2dense_print(stdout,m3); - printf("\n"); fflush(stdout); - - printf("Test of equality of m1 & m3 (should be 1): %d\n\n", - mod2dense_equal(m1,m3)); - - /* Clear m3. */ - - mod2dense_clear(m3); - - /* Print m3 again. */ - - printf("Matrix m3 again, should now be all zeros.\n\n"); - mod2dense_print(stdout,m3); - printf("\n"); fflush(stdout); - - printf("Test of equality of m1 & m3 (should be 0): %d\n\n", - mod2dense_equal(m1,m3)); - - - printf("\nPART 2:\n\n"); - - /* Compute transpose of m1. */ - - m4 = mod2dense_allocate(mod2dense_cols(m1),mod2dense_rows(m1)); - - mod2dense_transpose(m1,m4); - - /* Print transpose. */ - - printf("Transpose of m1.\n\n"); - mod2dense_print(stdout,m4); - printf("\n"); fflush(stdout); - - /* Free space for m1, m2, and m3. */ - - mod2dense_free(m1); - mod2dense_free(m2); - mod2dense_free(m3); - - - printf("\nPART 3:\n\n"); - - /* Allocate some small matrices. */ - - s0 = mod2dense_allocate(5,7); - s1 = mod2dense_allocate(5,7); - s2 = mod2dense_allocate(7,4); - s3 = mod2dense_allocate(5,4); - s4 = mod2dense_allocate(5,7); - - /* Set up the contents of s0, s1, and s2. */ - - mod2dense_clear(s0); - mod2dense_clear(s1); - mod2dense_clear(s2); - - mod2dense_set(s0,1,3,1); - mod2dense_set(s0,1,4,1); - mod2dense_set(s0,2,0,1); - mod2dense_set(s0,3,1,1); - - mod2dense_set(s1,1,3,1); - mod2dense_set(s1,1,5,1); - mod2dense_set(s1,3,0,1); - mod2dense_set(s1,3,1,1); - mod2dense_set(s1,3,6,1); - - mod2dense_set(s2,5,1,1); - mod2dense_set(s2,5,2,1); - mod2dense_set(s2,5,3,1); - mod2dense_set(s2,0,0,1); - mod2dense_set(s2,1,1,1); - - /* Print s0, s1, and s2. */ - - printf("Matrix s0.\n\n"); - mod2dense_print(stdout,s0); - printf("\nMatrix s1.\n\n"); - mod2dense_print(stdout,s1); - printf("\nMatrix s2.\n\n"); - mod2dense_print(stdout,s2); - printf("\n"); fflush(stdout); - - /* Add s0 and s1, storing the result in s4, then print s4. */ - - mod2dense_add(s0,s1,s4); - - printf("Sum of s0 and s1.\n\n"); - mod2dense_print(stdout,s4); - printf("\n"); fflush(stdout); - - /* Multiply s1 and s2, storing the product in s3, and then print s3. */ - - mod2dense_multiply(s1,s2,s3); - - printf("Product of s1 and s2.\n\n"); - mod2dense_print(stdout,s3); - printf("\n"); fflush(stdout); - - /* Try clearing a bit in s3, then printing the result. */ - - mod2dense_set(s3,1,2,0); - - printf("Above matrix with (1,2) cleared.\n\n"); - mod2dense_print(stdout,s3); - printf("\n"); fflush(stdout); - - /* Free space for s0, s1, s2, s3, and s4. */ - - mod2dense_free(s0); - mod2dense_free(s1); - mod2dense_free(s2); - mod2dense_free(s3); - mod2dense_free(s4); - - - printf("\nPART 4:\n\n"); - - /* Set up a small square matrix, s1. Also copy it to s2. */ - - s1 = mod2dense_allocate(5,5); - s2 = mod2dense_allocate(5,5); - - mod2dense_clear(s1); - - mod2dense_set(s1,0,3,1); - mod2dense_set(s1,1,4,1); - mod2dense_set(s1,1,1,1); - mod2dense_set(s1,2,0,1); - mod2dense_set(s1,3,1,1); - mod2dense_set(s1,3,2,1); - mod2dense_set(s1,4,2,1); - mod2dense_set(s1,4,0,1); - - mod2dense_copy(s1,s2); - - /* Print s1. */ - - printf("Matrix s1.\n\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - /* Compute inverse of s1, storing it in s3. */ - - s3 = mod2dense_allocate(5,5); - - code = mod2dense_invert(s1,s3); - - /* Print inverse (s3). */ - - printf("Matrix s3, the inverse of s1 (return code %d).\n\n",code); - mod2dense_print(stdout,s3); - printf("\n"); fflush(stdout); - - /* Compute and print product of inverse and original matrix, both ways. */ - - mod2dense_multiply(s2,s3,s1); - printf("Original matrix times inverse (should be identity).\n\n"); - mod2dense_print(stdout,s1); - - mod2dense_multiply(s3,s2,s1); - printf("\nInverse times original matrix (should be identity).\n\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - /* Compute and print inverse of inverse, and do equality check. */ - - mod2dense_invert(s3,s1); - - printf("Inverse of inverse (should be same as original s1).\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - printf("Test of equality with original (should be 1): %d\n\n", - mod2dense_equal(s1,s2)); - - /* Free s1, s2, and s3. */ - - mod2dense_free(s1); - mod2dense_free(s2); - mod2dense_free(s3); - - /* Set up a rectangular matrix like s1 above, but with two zero columns. - Copy to s4 as well. */ - - s1 = mod2dense_allocate(5,7); - - mod2dense_clear(s1); - - mod2dense_set(s1,0,4,1); - mod2dense_set(s1,1,6,1); - mod2dense_set(s1,1,1,1); - mod2dense_set(s1,2,0,1); - mod2dense_set(s1,3,1,1); - mod2dense_set(s1,3,2,1); - mod2dense_set(s1,4,2,1); - mod2dense_set(s1,4,0,1); - - s4 = mod2dense_allocate(5,7); - mod2dense_copy(s1,s4); - - /* Print s1. */ - - printf("Matrix s1.\n\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - /* Compute inverse of sub-matrix of s1, storing it in s3. Print results. */ - - s3 = mod2dense_allocate(5,7); - - code = mod2dense_invert_selected(s1,s3,a_row,a_col); - - printf("Matrix s3, from invert_selected applied to s1 (return code %d).\n\n", - code); - - mod2dense_print(stdout,s3); - - printf("\n row ordering returned:"); - for (i = 0; i<5; i++) printf(" %d",a_row[i]); - printf("\n"); - - printf("\n column ordering returned:"); - for (j = 0; j<7; j++) printf(" %d",a_col[j]); - printf("\n"); - - printf("\n"); fflush(stdout); - - printf("Columns extracted in order from original matrix.\n\n"); - - s2 = mod2dense_allocate(5,5); - mod2dense_copycols(s4,s2,a_col); - mod2dense_print(stdout,s2); - printf("\n"); fflush(stdout); - - s5 = mod2dense_allocate(5,5); - code = mod2dense_invert(s2,s5); - - printf( - "Inverse of above calculated using mod2dense_inverse (return code %d)\n\n", - code); - - mod2dense_print(stdout,s5); - printf("\n"); fflush(stdout); - - printf( - "Columns extracted in order from s3 (should also be inverse of above).\n\n"); - mod2dense_copycols(s3,s2,a_col); - mod2dense_print(stdout,s2); - printf("\n"); fflush(stdout); - - /* Try out mod2dense_invert_selected again. */ - - mod2dense_clear(s1); - - mod2dense_set(s1,0,0,1); - mod2dense_set(s1,0,1,1); - mod2dense_set(s1,1,1,1); - mod2dense_set(s1,1,2,1); - mod2dense_set(s1,2,0,1); - mod2dense_set(s1,2,2,1); - mod2dense_set(s1,3,3,1); - mod2dense_set(s1,3,4,1); - - printf("Matrix s1.\n\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - code = mod2dense_invert_selected(s1,s3,a_row,a_col); - - printf("Matrix s3, from invert_selected applied to s1 (return code %d).\n\n", - code); - - mod2dense_print(stdout,s3); - - printf("\n row ordering returned:"); - for (i = 0; i<5; i++) printf(" %d",a_row[i]); - printf("\n"); - printf("\n column ordering returned:"); - for (j = 0; j<7; j++) printf(" %d",a_col[j]); - printf("\n"); - - printf("\n"); fflush(stdout); - - printf("Matrix s4, from copying rows in order from s3.\n\n"); - - mod2dense_copyrows(s3,s4,a_row); - - mod2dense_print(stdout,s4); - - free(s1); - free(s2); - free(s3); - free(s4); - free(s5); - - - printf("\nPART 5:\n\n"); - - /* Set up a larger square matrix, s1. Also copy it to s2. */ - - s1 = mod2dense_allocate(35,35); - s2 = mod2dense_allocate(35,35); - - mod2dense_clear(s1); - - for (i = 0; i<35; i++) mod2dense_set(s1,i,i,1); - - mod2dense_set(s1,10,3,1); - mod2dense_set(s1,11,4,1); - mod2dense_set(s1,11,11,1); - mod2dense_set(s1,12,20,1); - mod2dense_set(s1,13,31,1); - mod2dense_set(s1,23,12,1); - mod2dense_set(s1,24,12,1); - mod2dense_set(s1,14,10,1); - mod2dense_set(s1,2,20,1); - mod2dense_set(s1,3,31,1); - mod2dense_set(s1,3,12,1); - mod2dense_set(s1,24,2,1); - mod2dense_set(s1,24,0,1); - mod2dense_set(s1,5,3,1); - mod2dense_set(s1,18,3,1); - mod2dense_set(s1,17,11,1); - mod2dense_set(s1,32,23,1); - mod2dense_set(s1,9,24,1); - mod2dense_set(s1,19,11,1); - mod2dense_set(s1,11,30,1); - mod2dense_set(s1,21,27,1); - mod2dense_set(s1,21,22,1); - mod2dense_set(s1,23,33,1); - mod2dense_set(s1,24,23,1); - mod2dense_set(s1,24,25,1); - mod2dense_set(s1,30,34,1); - mod2dense_set(s1,31,10,1); - mod2dense_set(s1,33,17,1); - mod2dense_set(s1,33,18,1); - mod2dense_set(s1,34,8,1); - mod2dense_set(s1,34,11,1); - mod2dense_set(s1,34,3,1); - mod2dense_set(s1,34,24,1); - mod2dense_set(s1,25,34,1); - mod2dense_set(s1,13,34,1); - - mod2dense_set(s1,3,3,0); - mod2dense_set(s1,11,11,0); - mod2dense_set(s1,23,23,0); - mod2dense_set(s1,24,24,0); - - mod2dense_copy(s1,s2); - - /* Print s1. */ - - printf("Matrix s1.\n\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - /* Compute inverse of s1, storing it in s3. */ - - s3 = mod2dense_allocate(35,35); - - code = mod2dense_invert(s1,s3); - - /* Print inverse (s3). */ - - printf("Matrix s3, the inverse of s1 (return code %d).\n\n",code); - mod2dense_print(stdout,s3); - printf("\n"); fflush(stdout); - - /* Compute and print product of inverse and original matrix, both ways. */ - - mod2dense_multiply(s2,s3,s1); - printf("Original matrix times inverse (should be identity).\n\n"); - mod2dense_print(stdout,s1); - - mod2dense_multiply(s3,s2,s1); - printf("\nInverse times original matrix (should be identity).\n\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - /* Compute and print inverse of inverse, and do equality check. */ - - mod2dense_invert(s3,s1); - - printf("Inverse of inverse (should be same as original s1).\n\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - printf("Test of equality with original (should be 1): %d\n\n", - mod2dense_equal(s1,s2)); - - /* Free s1, s2, and s3. */ - - mod2dense_free(s1); - mod2dense_free(s2); - mod2dense_free(s3); - - - printf("\nPART 6:\n\n"); - - /* Set up a largish square matrix, s1. Also copy it to s2. */ - - s1 = mod2dense_allocate(35,35); - s2 = mod2dense_allocate(35,35); - - mod2dense_clear(s1); - - for (i = 0; i<10; i++) - { if (i!=3 && i!=7) - { mod2dense_set(s1,i,i,1); - } - } - for (i = 10; i<35; i++) - { if (i!=15 && i!=21 && i!=32) - { mod2dense_set(s1,i,34-(i-10),1); - } - } - - /* Print s1. */ - - printf("Matrix s1.\n\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - /* Forcibly invert s1, storing inverse in s3. */ - - s3 = mod2dense_allocate(35,35); - - code = mod2dense_forcibly_invert(s1,s3,a_row,a_col); - - /* Print inverse, and list of altered elements. */ - - printf("Result of forcibly inverting s1 (needed to alter %d elements).\n\n", - code); - mod2dense_print(stdout,s3); - printf("\n"); fflush(stdout); - - printf("Altered elements at these indexes:\n\n"); - - for (i = 0; i<code; i++) - { printf("%3d %3d\n",a_row[i],a_col[i]); - } - printf("\n"); fflush(stdout); - - /* Compute and print inverse of inverse. */ - - mod2dense_invert(s3,s1); - - printf("Inverse of inverse of altered matrix.\n\n"); - mod2dense_print(stdout,s1); - printf("\n"); fflush(stdout); - - printf("\nDONE WITH TESTS.\n"); - - exit(0); -} diff --git a/lib/ldpc/mod2dense.c b/lib/ldpc/mod2dense.c deleted file mode 100755 index 35a20712..00000000 --- a/lib/ldpc/mod2dense.c +++ /dev/null @@ -1,754 +0,0 @@ -/* MOD2DENSE.C - Procedures for handling dense mod2 matrices. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* NOTE: See mod2dense.html for documentation on these procedures. */ - - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> - -#include "alloc.h" -#include "intio.h" -#include "mod2dense.h" - - -/* ALLOCATE SPACE FOR A DENSE MOD2 MATRIX. */ - -mod2dense *mod2dense_allocate -( int n_rows, /* Number of rows in matrix */ - int n_cols /* Number of columns in matrix */ -) -{ - mod2dense *m; - int j; - - if (n_rows<=0 || n_cols<=0) - { fprintf(stderr,"mod2dense_allocate: Invalid number of rows or columns\n"); - exit(1); - } - - m = chk_alloc (1, sizeof *m); - - m->n_rows = n_rows; - m->n_cols = n_cols; - - m->n_words = (n_rows+mod2_wordsize-1) >> mod2_wordsize_shift; - - m->col = chk_alloc (m->n_cols, sizeof *m->col); - - m->bits = chk_alloc(m->n_words*m->n_cols, sizeof *m->bits); - - for (j = 0; j<m->n_cols; j++) - { m->col[j] = m->bits + j*m->n_words; - } - - return m; -} - - -/* FREE SPACE OCCUPIED BY A DENSE MOD2 MATRIX. */ - -void mod2dense_free -( mod2dense *m /* Matrix to free */ -) -{ if (m) - { free(m->bits); - free(m->col); - free(m); - } -} - - -/* CLEAR A DENSE MOD2 MATRIX. */ - -void mod2dense_clear -( mod2dense *r -) -{ - int k, j; - - for (j = 0; j<mod2dense_cols(r); j++) - { for (k = 0; k<r->n_words; k++) - { r->col[j][k] = 0; - } - } - -} - - -/* COPY A DENSE MOD2 MATRIX. */ - -void mod2dense_copy -( mod2dense *m, /* Matrix to copy */ - mod2dense *r /* Place to store copy of matrix */ -) -{ - int k, j; - - if (mod2dense_rows(m)>mod2dense_rows(r) - || mod2dense_cols(m)>mod2dense_cols(r)) - { fprintf(stderr,"mod2dense_copy: Destination matrix is too small\n"); - exit(1); - } - - for (j = 0; j<mod2dense_cols(m); j++) - { for (k = 0; k<m->n_words; k++) - { r->col[j][k] = m->col[j][k]; - } - for ( ; k<r->n_words; k++) - { r->col[j][k] = 0; - } - } - - for ( ; j<mod2dense_cols(r); j++) - { for (k = 0; k<r->n_words; k++) - { r->col[j][k] = 0; - } - } -} - - -/* COPY ROWS OF A DENSE MOD2 MATRIX. */ - -void mod2dense_copyrows -( mod2dense *m, /* Matrix to copy */ - mod2dense *r, /* Place to store copy of matrix */ - int *rows /* Indexes of rows to copy, from 0 */ -) -{ - int i, j; - - if (mod2dense_cols(m)>mod2dense_cols(r)) - { fprintf(stderr, - "mod2dense_copyrows: Destination matrix has fewer columns than source\n"); - exit(1); - } - - mod2dense_clear(r); - - for (i = 0; i<mod2dense_rows(r); i++) - { if (rows[i]<0 || rows[i]>=mod2dense_rows(m)) - { fprintf(stderr,"mod2dense_copyrows: Row index out of range\n"); - exit(1); - } - for (j = 0; j<mod2dense_cols(m); j++) - { mod2dense_set(r,i,j,mod2dense_get(m,rows[i],j)); - } - } -} - - -/* COPY COLUMNS OF A DENSE MOD2 MATRIX. */ - -void mod2dense_copycols -( mod2dense *m, /* Matrix to copy */ - mod2dense *r, /* Place to store copy of matrix */ - int *cols /* Indexes of columns to copy, from 0 */ -) -{ - int k, j; - - if (mod2dense_rows(m)>mod2dense_rows(r)) - { fprintf(stderr, - "mod2dense_copycols: Destination matrix has fewer rows than source\n"); - exit(1); - } - - for (j = 0; j<mod2dense_cols(r); j++) - { if (cols[j]<0 || cols[j]>=mod2dense_cols(m)) - { fprintf(stderr,"mod2dense_copycols: Column index out of range\n"); - exit(1); - } - for (k = 0; k<m->n_words; k++) - { r->col[j][k] = m->col[cols[j]][k]; - } - for ( ; k<r->n_words; k++) - { r->col[j][k] = 0; - } - } -} - - -/* PRINT A DENSE MOD2 MATRIX IN HUMAN-READABLE FORM. */ - -void mod2dense_print -( FILE *f, - mod2dense *m -) -{ - int i, j; - - for (i = 0; i<mod2dense_rows(m); i++) - { for (j = 0; j<mod2dense_cols(m); j++) - { fprintf(f," %d",mod2dense_get(m,i,j)); - } - fprintf(f,"\n"); - } -} - - -/* WRITE A DENSE MOD2 MATRIX TO A FILE IN MACHINE-READABLE FORM. - - Data is written using intio_write, so that it will be readable on a machine - with a different byte-ordering. At present, this assumes that the words - used to pack bits into are no longer than 32 bits. */ - -int mod2dense_write -( FILE *f, - mod2dense *m -) -{ - int j, k; - - intio_write(f,m->n_rows); - if (ferror(f)) return 0; - - intio_write(f,m->n_cols); - if (ferror(f)) return 0; - - for (j = 0; j<mod2dense_cols(m); j++) - { - for (k = 0; k<m->n_words; k++) - { intio_write(f,m->col[j][k]); - if (ferror(f)) return 0; - } - } - - return 1; -} - - -/* READ A DENSE MOD2 MATRIX STORED IN MACHINE-READABLE FORM FROM A FILE. */ - -mod2dense *mod2dense_read -( FILE *f -) -{ - int n_rows, n_cols; - mod2dense *m; - int j, k; - - n_rows = intio_read(f); - if (feof(f) || ferror(f) || n_rows<=0) return 0; - - n_cols = intio_read(f); - if (feof(f) || ferror(f) || n_cols<=0) return 0; - - m = mod2dense_allocate(n_rows,n_cols); - - for (j = 0; j<mod2dense_cols(m); j++) - { - for (k = 0; k<m->n_words; k++) - { m->col[j][k] = intio_read(f); - if (feof(f) || ferror(f)) - { mod2dense_free(m); - return 0; - } - } - } - - return m; -} - - -/* GET AN ELEMENT FROM A DENSE MOD2 MATRIX. */ - -int mod2dense_get -( mod2dense *m, /* Matrix to get element from */ - int row, /* Row of element (starting with zero) */ - int col /* Column of element (starting with zero) */ -) -{ - if (row<0 || row>=mod2dense_rows(m) || col<0 || col>=mod2dense_cols(m)) - { fprintf(stderr,"mod2dense_get: row or column index out of bounds\n"); - exit(1); - } - - return mod2_getbit (m->col[col][row>>mod2_wordsize_shift], - row&mod2_wordsize_mask); -} - - -/* SET AN ELEMENT IN A DENSE MOD2 MATRIX. */ - -void mod2dense_set -( mod2dense *m, /* Matrix to modify element of */ - int row, /* Row of element (starting with zero) */ - int col, /* Column of element (starting with zero) */ - int value /* New value of element (0 or 1) */ -) -{ - mod2word *w; - - if (row<0 || row>=mod2dense_rows(m) || col<0 || col>=mod2dense_cols(m)) - { fprintf(stderr,"mod2dense_set: row or column index out of bounds\n"); - exit(1); - } - - w = &m->col[col][row>>mod2_wordsize_shift]; - - *w = value ? mod2_setbit1(*w,row&mod2_wordsize_mask) - : mod2_setbit0(*w,row&mod2_wordsize_mask); -} - - -/* FLIP AN ELEMENT OF A DENSE MOD2 MATRIX. */ - -int mod2dense_flip -( mod2dense *m, /* Matrix to flip element in */ - int row, /* Row of element (starting with zero) */ - int col /* Column of element (starting with zero) */ -) -{ - mod2word *w; - int b; - - if (row<0 || row>=mod2dense_rows(m) || col<0 || col>=mod2dense_cols(m)) - { fprintf(stderr,"mod2dense_flip: row or column index out of bounds\n"); - exit(1); - } - - b = 1 ^ mod2_getbit (m->col[col][row>>mod2_wordsize_shift], - row&mod2_wordsize_mask); - - w = &m->col[col][row>>mod2_wordsize_shift]; - - *w = b ? mod2_setbit1(*w,row&mod2_wordsize_mask) - : mod2_setbit0(*w,row&mod2_wordsize_mask); - - return b; -} - - -/* COMPUTE THE TRANSPOSE OF A DENSE MOD2 MATRIX. */ - -void mod2dense_transpose -( mod2dense *m, /* Matrix to compute transpose of (left unchanged) */ - mod2dense *r /* Result of transpose operation */ -) -{ - mod2word w, v, *p; - int k1, j1, i2, j2; - - if (mod2dense_rows(m)!=mod2dense_cols(r) - || mod2dense_cols(m)!=mod2dense_rows(r)) - { fprintf(stderr, - "mod2dense_transpose: Matrices have incompatible dimensions\n"); - exit(1); - } - - if (r==m) - { fprintf(stderr, - "mod2dense_transpose: Result matrix is the same as the operand\n"); - exit(1); - } - - mod2dense_clear(r); - - for (j1 = 0; j1<mod2dense_cols(m); j1++) - { - i2 = j1 >> mod2_wordsize_shift; - v = 1 << (j1 & mod2_wordsize_mask); - - p = m->col[j1]; - k1 = 0; - - for (j2 = 0; j2<mod2dense_cols(r); j2++) - { if (k1==0) - { w = *p++; - k1 = mod2_wordsize; - } - if (w&1) - { r->col[j2][i2] |= v; - } - w >>= 1; - k1 -= 1; - } - } -} - - -/* ADD TWO DENSE MOD2 MATRICES. */ - -void mod2dense_add -( mod2dense *m1, /* Left operand of add */ - mod2dense *m2, /* Right operand of add */ - mod2dense *r /* Place to store result of add */ -) -{ - int j, k; - - if (mod2dense_rows(m1)!=mod2dense_rows(r) - || mod2dense_cols(m1)!=mod2dense_cols(r) - || mod2dense_rows(m2)!=mod2dense_rows(r) - || mod2dense_cols(m2)!=mod2dense_cols(r)) - { fprintf(stderr,"mod2dense_add: Matrices have different dimensions\n"); - exit(1); - } - - for (j = 0; j<mod2dense_cols(r); j++) - { for (k = 0; k<r->n_words; k++) - { r->col[j][k] = m1->col[j][k] ^ m2->col[j][k]; - } - } -} - - -/* MULTIPLY TWO DENSE MOD2 MATRICES. - - The algorithm used runs faster if the second matrix (right operand of the - multiply) is sparse, but it is also appropriate for dense matrices. This - procedure could be speeded up a bit by replacing the call of mod2dense_get - with in-line code that avoids division, but this doesn't seem worthwhile - at the moment. -*/ - -void mod2dense_multiply -( mod2dense *m1, /* Left operand of multiply */ - mod2dense *m2, /* Right operand of multiply */ - mod2dense *r /* Place to store result of multiply */ -) -{ - int i, j, k; - - if (mod2dense_cols(m1)!=mod2dense_rows(m2) - || mod2dense_rows(m1)!=mod2dense_rows(r) - || mod2dense_cols(m2)!=mod2dense_cols(r)) - { fprintf(stderr, - "mod2dense_multiply: Matrices have incompatible dimensions\n"); - exit(1); - } - - if (r==m1 || r==m2) - { fprintf(stderr, - "mod2dense_multiply: Result matrix is the same as one of the operands\n"); - exit(1); - } - - mod2dense_clear(r); - - for (j = 0; j<mod2dense_cols(r); j++) - { for (i = 0; i<mod2dense_rows(m2); i++) - { if (mod2dense_get(m2,i,j)) - { for (k = 0; k<r->n_words; k++) - { r->col[j][k] ^= m1->col[i][k]; - } - } - } - } -} - - -/* SEE WHETHER TWO DENSE MOD2 MATRICES ARE EQUAL. */ - -int mod2dense_equal -( mod2dense *m1, - mod2dense *m2 -) -{ - int k, j, w; - mod2word m; - - if (mod2dense_rows(m1)!=mod2dense_rows(m2) - || mod2dense_cols(m1)!=mod2dense_cols(m2)) - { fprintf(stderr,"mod2dense_equal: Matrices have different dimensions\n"); - exit(1); - } - - w = m1->n_words; - - /* Form a mask that has 1s in the lower bit positions corresponding to - bits that contain information in the last word of a matrix column. */ - - m = (1 << (mod2_wordsize - (w*mod2_wordsize-m1->n_rows))) - 1; - - for (j = 0; j<mod2dense_cols(m1); j++) - { - for (k = 0; k<w-1; k++) - { if (m1->col[j][k] != m2->col[j][k]) return 0; - } - - if ((m1->col[j][k]&m) != (m2->col[j][k]&m)) return 0; - } - - return 1; -} - - -/* INVERT A DENSE MOD2 MATRIX. */ - -int mod2dense_invert -( mod2dense *m, /* The matrix to find the inverse of (destroyed) */ - mod2dense *r /* Place to store the inverse */ -) -{ - mod2word *s, *t; - int i, j, k, n, w, k0, b0; - - if (mod2dense_rows(m)!=mod2dense_cols(m)) - { fprintf(stderr,"mod2dense_invert: Matrix to invert is not square\n"); - exit(1); - } - - if (r==m) - { fprintf(stderr, - "mod2dense_invert: Result matrix is the same as the operand\n"); - exit(1); - } - - n = mod2dense_rows(m); - w = m->n_words; - - if (mod2dense_rows(r)!=n || mod2dense_cols(r)!=n) - { fprintf(stderr, - "mod2dense_invert: Matrix to receive inverse has wrong dimensions\n"); - exit(1); - } - - mod2dense_clear(r); - for (i = 0; i<n; i++) - { mod2dense_set(r,i,i,1); - } - - for (i = 0; i<n; i++) - { - k0 = i >> mod2_wordsize_shift; - b0 = i & mod2_wordsize_mask; - - for (j = i; j<n; j++) - { if (mod2_getbit(m->col[j][k0],b0)) break; - } - - if (j==n) return 0; - - if (j!=i) - { - t = m->col[i]; - m->col[i] = m->col[j]; - m->col[j] = t; - - t = r->col[i]; - r->col[i] = r->col[j]; - r->col[j] = t; - } - - for (j = 0; j<n; j++) - { if (j!=i && mod2_getbit(m->col[j][k0],b0)) - { s = m->col[j]; - t = m->col[i]; - for (k = k0; k<w; k++) s[k] ^= t[k]; - s = r->col[j]; - t = r->col[i]; - for (k = 0; k<w; k++) s[k] ^= t[k]; - } - } - } - - return 1; -} - - -/* INVERT A DENSE MOD2 MATRIX WITH ROWS & COLUMNS SELECTED FROM BIGGER MATRIX.*/ - -int mod2dense_invert_selected -( mod2dense *m, /* Matrix from which to pick a submatrix to invert */ - mod2dense *r, /* Place to store the inverse */ - int *rows, /* Set to indexes of rows used and not used */ - int *cols /* Set to indexes of columns used and not used */ -) -{ - mod2word *s, *t; - int i, j, k, n, n2, w, k0, b0, c, R; - - if (r==m) - { fprintf(stderr, - "mod2dense_invert_selected2: Result matrix is the same as the operand\n"); - exit(1); - } - - n = mod2dense_rows(m); - w = m->n_words; - - n2 = mod2dense_cols(m); - - if (mod2dense_rows(r)!=n || mod2dense_cols(r)!=n2) - { fprintf(stderr, -"mod2dense_invert_selected2: Matrix to receive inverse has wrong dimensions\n"); - exit(1); - } - - mod2dense_clear(r); - - for (i = 0; i<n; i++) - { rows[i] = i; - } - - for (j = 0; j<n2; j++) - { cols[j] = j; - } - - R = 0; - i = 0; - - for (;;) - { - while (i<n-R) - { - k0 = rows[i] >> mod2_wordsize_shift; - b0 = rows[i] & mod2_wordsize_mask; - - for (j = i; j<n2; j++) - { if (mod2_getbit(m->col[cols[j]][k0],b0)) break; - } - - if (j<n2) break; - - R += 1; - c = rows[i]; - rows[i] = rows[n-R]; - rows[n-R] = c; - - } - - if (i==n-R) break; - - c = cols[j]; - cols[j] = cols[i]; - cols[i] = c; - - mod2dense_set(r,rows[i],c,1); - - for (j = 0; j<n2; j++) - { if (j!=c && mod2_getbit(m->col[j][k0],b0)) - { s = m->col[j]; - t = m->col[c]; - for (k = 0; k<w; k++) s[k] ^= t[k]; - s = r->col[j]; - t = r->col[c]; - for (k = 0; k<w; k++) s[k] ^= t[k]; - } - } - - i += 1; - } - - for (j = n-R; j<n; j++) - { s = r->col[cols[j]]; - for (k = 0; k<w; k++) s[k] = 0; - } - - return R; -} - - -/* FORCIBLY INVERT A DENSE MOD2 MATRIX. */ - -int mod2dense_forcibly_invert -( mod2dense *m, /* The matrix to find the inverse of (destroyed) */ - mod2dense *r, /* Place to store the inverse */ - int *a_row, /* Place to store row indexes of altered elements */ - int *a_col /* Place to store column indexes of altered elements */ -) -{ - mod2word *s, *t; - int i, j, k, n, w, k0, b0; - int u, c; - - if (mod2dense_rows(m)!=mod2dense_cols(m)) - { fprintf(stderr, - "mod2dense_forcibly_invert: Matrix to invert is not square\n"); - exit(1); - } - - if (r==m) - { fprintf(stderr, - "mod2dense_forcibly_invert: Result matrix is the same as the operand\n"); - exit(1); - } - - n = mod2dense_rows(m); - w = m->n_words; - - if (mod2dense_rows(r)!=n || mod2dense_cols(r)!=n) - { fprintf(stderr, - "mod2dense_forcibly_invert: Matrix to receive inverse has wrong dimensions\n"); - exit(1); - } - - mod2dense_clear(r); - for (i = 0; i<n; i++) - { mod2dense_set(r,i,i,1); - } - - for (i = 0; i<n; i++) - { a_row[i] = -1; - a_col[i] = i; - } - - for (i = 0; i<n; i++) - { - k0 = i >> mod2_wordsize_shift; - b0 = i & mod2_wordsize_mask; - - for (j = i; j<n; j++) - { if (mod2_getbit(m->col[j][k0],b0)) break; - } - - if (j==n) - { j = i; - mod2dense_set(m,i,j,1); - a_row[i] = i; - } - - if (j!=i) - { - t = m->col[i]; - m->col[i] = m->col[j]; - m->col[j] = t; - - t = r->col[i]; - r->col[i] = r->col[j]; - r->col[j] = t; - - u = a_col[i]; - a_col[i] = a_col[j]; - a_col[j] = u; - } - - for (j = 0; j<n; j++) - { if (j!=i && mod2_getbit(m->col[j][k0],b0)) - { s = m->col[j]; - t = m->col[i]; - for (k = k0; k<w; k++) s[k] ^= t[k]; - s = r->col[j]; - t = r->col[i]; - for (k = 0; k<w; k++) s[k] ^= t[k]; - } - } - } - - c = 0; - for (i = 0; i<n; i++) - { if (a_row[i]!=-1) - { a_row[c] = a_row[i]; - a_col[c] = a_col[i]; - c += 1; - } - } - - return c; -} diff --git a/lib/ldpc/mod2dense.h b/lib/ldpc/mod2dense.h deleted file mode 100755 index 3d0c603f..00000000 --- a/lib/ldpc/mod2dense.h +++ /dev/null @@ -1,113 +0,0 @@ -/* MOD2DENSE.H - Interface to module for handling dense mod2 matrices. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* This module implements operations on matrices of mod2 elements (bits, - with addition and multiplication being done modulo 2). The matrices - are stored with consecutive bits of a column packed into words, and - the procedures are implemented where possible using bit operations - on these words. This is an appropriate representation when the matrices - are dense (ie, 0s and 1s are about equally frequent). - - All procedures in this module display an error message on standard - error and terminate the program if passed an invalid argument (indicative - of a programming error), or if memory cannot be allocated. Errors from - invalid contents of a file result in an error code being returned to the - caller, with no message being printed by this module. -*/ - - -#include <stdint.h> /* Has the definition of uint32_t used below */ - -/* PACKING OF BITS INTO WORDS. Bits are packed into 32-bit words, with - the low-order bit coming first. */ - -typedef uint32_t mod2word; /* Data type that holds packed bits. If uint32_t - doesn't exist, change it to unsigned long */ - -#define mod2_wordsize 32 /* Number of bits that fit in a mod2word. Can't - be increased without changing intio module */ - -#define mod2_wordsize_shift 5 /* Amount to shift by to divide by wordsize */ -#define mod2_wordsize_mask 0x1f /* What to AND with to produce mod wordsize */ - -/* Extract the i'th bit of a mod2word. */ - -#define mod2_getbit(w,i) (((w)>>(i))&1) - -/* Make a word like w, but with the i'th bit set to 1 (if it wasn't already). */ - -#define mod2_setbit1(w,i) ((w)|(1<<(i))) - -/* Make a word like w, but with the i'th bit set to 0 (if it wasn't already). */ - -#define mod2_setbit0(w,i) ((w)&(~(1<<(i)))) - - -/* STRUCTURE REPRESENTING A DENSE MATRIX. These structures are dynamically - allocated using mod2dense_allocate (or by other procedures that call - mod2dense_allocate). They should be freed with mod2dense_free when no - longer required. - - Direct access to this structure should be avoided except in low-level - routines. Use the macros and procedures defined below instead. */ - -typedef struct -{ - int n_rows; /* Number of rows in the matrix */ - int n_cols; /* Number of columns in the matrix */ - - int n_words; /* Number of words used to store a column of bits */ - - mod2word **col; /* Pointer to array of pointers to columns */ - - mod2word *bits; /* Pointer to storage block for bits in this matrix - (pieces of this block are pointed to from col) */ -} mod2dense; - - -/* MACROS. */ - -#define mod2dense_rows(m) ((m)->n_rows) /* Get the number of rows or columns */ -#define mod2dense_cols(m) ((m)->n_cols) /* in a matrix */ - - -/* PROCEDURES. */ - -mod2dense *mod2dense_allocate (int, int); -void mod2dense_free (mod2dense *); - -void mod2dense_clear (mod2dense *); -void mod2dense_copy (mod2dense *, mod2dense *); -void mod2dense_copyrows (mod2dense*, mod2dense *, int *); -void mod2dense_copycols (mod2dense*, mod2dense *, int *); - -void mod2dense_print (FILE *, mod2dense *); -int mod2dense_write (FILE *, mod2dense *); -mod2dense *mod2dense_read (FILE *); - -int mod2dense_get (mod2dense *, int, int); -void mod2dense_set (mod2dense *, int, int, int); -int mod2dense_flip(mod2dense *, int, int); - -void mod2dense_transpose (mod2dense *, mod2dense *); -void mod2dense_add (mod2dense *, mod2dense *, mod2dense *); -void mod2dense_multiply (mod2dense *, mod2dense *, mod2dense *); - -int mod2dense_equal (mod2dense *, mod2dense *); - -int mod2dense_invert (mod2dense *, mod2dense *); -int mod2dense_forcibly_invert (mod2dense *, mod2dense *, int *, int *); -int mod2dense_invert_selected (mod2dense *, mod2dense *, int *, int *); diff --git a/lib/ldpc/mod2dense.html b/lib/ldpc/mod2dense.html deleted file mode 100755 index 2b831387..00000000 --- a/lib/ldpc/mod2dense.html +++ /dev/null @@ -1,487 +0,0 @@ -<HTML><HEAD> - -<TITLE> Dense Modulo-2 Matrix Routines </TITLE> - -</HEAD><BODY> - - -<H1> Dense Modulo-2 Matrix Routines </H1> - -<P>This module implements operations on matrices in which the elements -are all 0 or 1, with addition and multiplication being done modulo 2. -The matrices are stored with consecutive bits of a column packed into -32-bit words, and the procedures are implemented where possible using -bit operations on these words. - -<P>This is an appropriate representation when the matrices are dense -(ie, 0s and 1s are about equally frequent). Matrices in which most -elements are 0s may be better handled with the <A -HREF="mod2sparse.html">sparse modulo-2 matrix routines</A>. Matrices -can be converted between these two formats using the <A -HREF="mod2convert.html">module-2 matrix conversion routines</A>. - -<P>All procedures in this module display an error message on standard -error and terminate the program if passed an invalid argument -(indicative of a programming error), or if memory cannot be allocated. -Errors from invalid contents of a file result in an error code being -returned to the caller, with no message being printed by this module. - - -<H2>Representation of dense matrices</H2> - -<P>This module represents a matrix by a pointer to a structure of type -<TT>mod2dense</TT>. This structure records the number of rows and -columns in the matrix, and contains an array of pointers to where the -bits making up each column are stored. These bits are packed 32 per -word. When possible, bits in a column are manipulated 32 bits at a -time, which operations such as adding one column to another much -faster than the corresponding operations on rows. The pointer -structure also allows the columns of a matrix to easily be rearranged, -which may be necessary when doing matrix inversion. - - -<P><B>Header files required</B>: -<TT>mod2dense.h</TT> - - -<A NAME="dimension-sec"> -<P><HR> -<CENTER><BIG>Dimension Macros</BIG></CENTER> -</A> - -<HR>The following macros take a pointer to a mod2dense structure as their -argument, and return the number of rows or the number of columns in -the matrix pointed to, which will have been fixed when the matrix was -created with <A HREF="#allocate">mod2dense_allocate</A>: -<BLOCKQUOTE><PRE> -mod2dense_rows(m) /* Returns the number of rows in m */ - -mod2dense_cols(m) /* Returns the number of columns in m */ -</PRE></BLOCKQUOTE> - - -<A NAME="alloc-sec"> -<P><HR> -<CENTER><BIG>Allocating and Freeing Dense Modulo-2 Matrices</BIG></CENTER> -</A> - - -<A NAME="allocate"><HR><B>mod2dense_allocate</B>: -Allocate space for a dense module-2 matrix.</A> - -<BLOCKQUOTE><PRE> -mod2dense *mod2dense_allocate -( int n_rows, /* Number of rows in matrix */ - int n_cols /* Number of columns in matrix */ -) -</PRE></BLOCKQUOTE> - -Allocates space for a matrix with the given number of rows and -columns, and returns a pointer to it. If there is not enough memory -available, a message is displayed on standard error and the program is -terminated. The matrix should be freed with <A -HREF="#free"><TT>mod2dense_free</TT></A> once it is no longer in use. - -<P><A NAME="free"><HR><B>mod2dense_free</B>: -Free the space occupied by a dense module-2 matrix.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_free -( mod2dense *m /* Pointer to matrix to free */ -) -</PRE></BLOCKQUOTE> - -Frees the space occupied by the matrix for re-use. The pointer passed -should no longer be used. - - -<A NAME="copy-clear-sec"> -<P><HR> -<CENTER><BIG>Copying and Clearing Dense Modulo-2 Matrices</BIG></CENTER> -</A> - -<A NAME="clear"><HR><B>mod2dense_clear</B>: -Set all elements of a matrix to zero.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_clear -( mod2dense *m /* Pointer to matrix to clear */ -) -</PRE></BLOCKQUOTE> - -Sets all of the elements of the matrix passed to 0. - -<P><A NAME="copy"><HR><B>mod2dense_copy</B>: -Copy the contents of one matrix to another.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_copy -( mod2dense *m /* Pointer to matrix to copy from */ - mod2dense *r /* Pointer to matrix to receive data */ -) -</PRE></BLOCKQUOTE> - -Copies the contents of the first matrix passed, <B>m</B>, to the -second matrix passed, <B>r</B>, which must already have been -allocated, and must have at least as many rows and columns as the -first. If <B>r</B> is larger than <B>m</B>, its elements that have -row or column indexes greater than the dimension of <B>m</B> are set -to zeros. - - -<P><A NAME="copyrows"><HR><B>mod2dense_copyrows</B>: -Copy selected rows from one matrix to another.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_copyrows -( mod2dense *m, /* Pointer to matrix to copy columns from */ - mod2dense *r, /* Pointer to matrix in which to store data */ - int *rows /* Indexes of rows, numbered from 0 */ -) -</PRE></BLOCKQUOTE> - -Copies selected rows of the first matrix, <B>m</B>, to the second -matrix, <B>r</B>, which must already have been allocated, and which -must have at least as many columns as <B>m</B>. The indexes of the -rows to copy are given in order as an array of length the same as -the number of rows in <B>r</B>; duplicates are allowed. Row -indexes start at 0. These rows are copied to <B>r</B>, with the -row indexed by the first entry in <B>rows</B> going to the first -row of <B>r</B>, and so forth. If <B>r</B> has more columns than -<B>m</B>, the extra entries in each row are set to zeros. - - -<P><A NAME="copycols"><HR><B>mod2dense_copycols</B>: -Copy selected columns from one matrix to another.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_copycols -( mod2dense *m, /* Pointer to matrix to copy columns from */ - mod2dense *r, /* Pointer to matrix in which to store data */ - int *cols /* Indexes of columns, numbered from 0 */ -) -</PRE></BLOCKQUOTE> - -Copies selected columns of the first matrix, <B>m</B>, to the second -matrix, <B>r</B>, which must already have been allocated, and which -must have at least as many rows as <B>m</B>. The indexes of the -columns to copy are given in order as an array of length the same as -the number of columns in <B>r</B>; duplicates are allowed. Column -indexes start at 0. These columns are copied to <B>r</B>, with the -column indexed by the first entry in <B>cols</B> going to the first -column of <B>r</B>, and so forth. If <B>r</B> has more rows than -<B>m</B>, the extra entries in each column are set to zeros. - - -<A NAME="input-output-sec"> -<P><HR> -<CENTER><BIG>Input and Output of Dense Modulo-2 Matrices</BIG></CENTER> -</A> - -<A NAME="print"><HR><B>mod2dense_print</B>: -Print a dense modulo-2 matrix in human-readable form.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_print -( FILE *f, /* File to print to */ - mod2dense *m /* Pointer to matrix to print */ -) -</PRE></BLOCKQUOTE> - -The matrix is printed on standard output as "0" and "1" characters, -each preceded by a space, with one line of "0"s and "1"s for each row -of the matrix. - -<P><A NAME="write"><HR><B>mod2dense_write</B>: -Write a dense modulo-2 matrix to a file in machine-readable format.</A> - -<BLOCKQUOTE><PRE> -int mod2dense_write -( FILE *f, /* File to write data to */ - mod2dense *m /* Pointer to matrix write out */ -) -</PRE></BLOCKQUOTE> - -Writes a machine-readable representation the dense matrix <B>m</B> to -the file <B>f</B>. The file should have been opened in binary mode -(with a "b" in the mode passed to fopen). The contents written will -not be text, and will not be human-readable. Other binary data may -precede or follow the data for the matrix written. - -<P>The data written to the file consists of the number of rows and the -number of columns, followed by the bits in each column, packed into -32-bit words. The data should be readable by <A -HREF="#read"><TT>mod2dense_read</TT></A> even on a machine with a -different byte-ordering. - -<P>The value returned by <TT>mod2dense_write</TT> is one if the -operation was successful, zero if an error of some sort occurred. - -<P><A NAME="read"><HR><B>mod2dense_read</B>: -Read a dense modulo-2 matrix from a file.</A> - -<BLOCKQUOTE><PRE> -mod2dense *mod2dense_read -( FILE *f, /* File to read data from */ -) -</PRE></BLOCKQUOTE> - -Reads a dense modulo-2 matrix from the file <B>f</B>. This file -should have been opened in binary mode (with a "b" in the mode passed -to fopen). The contents of the file at the point when -<TT>mod2dense_read</TT> is called should have been written by <A -HREF="#write"><TT>mod2dense_write</TT></A>. Other binary data may -precede or follow this data. - -<P>The value returned is a pointer to the matrix read, for which space -will have been allocated by <TT>mod2dense_read</TT>, or zero if an -error occurred (either an error reading the file, or data not in the -right format). - - -<A NAME="elementary-sec"> -<P><HR> -<CENTER><BIG>Elementary Operations on Dense Modulo-2 Matrices</BIG></CENTER> -</A> - -<A NAME="get"><HR><B>mod2dense_get</B>: -Get an element of a dense modulo-2 matrix.</A> - -<BLOCKQUOTE><PRE> -int mod2dense_get -( mod2dense *m, /* Pointer to matrix to get element from */ - int row, /* Row of element (indexed from zero) */ - int col /* Column of element (indexed from zero) */ -) -</PRE></BLOCKQUOTE> - -Returns the value (0 or 1) of the element in the given row and column -of the matrix <B>m</B>. - -<P><A NAME="set"><HR><B>mod2dense_set</B>: -Set an element of a dense modulo-2 matrix.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_set -( mod2dense *m, /* Pointer to matrix to get element from */ - int row, /* Row of element (indexed from zero) */ - int col, /* Column of element (indexed from zero) */ - int value /* New value of element (0 or 1) */ -) -</PRE></BLOCKQUOTE> - -Set the element in the given row and column of the matrix <B>m</B> to -the specified value. - -<P><A NAME="flip"><HR><B>mod2dense_flip</B>: -Flip an element of a dense modulo-2 matrix.</A> - -<BLOCKQUOTE><PRE> -int mod2dense_flip -( mod2dense *m, /* Pointer to matrix to get element from */ - int row, /* Row of element (indexed from zero) */ - int col /* Column of element (indexed from zero) */ -) -</PRE></BLOCKQUOTE> - -Flips the value of the element in the given row and column of the -matrix <B>m</B>, changing it to 0 if it was 1, and to 1 if it was 0. -Returns the new value of this element. - - -<A NAME="arith-sec"> -<P><HR> -<CENTER><BIG>Dense Modulo-2 Matrix Arithmetic and Comparison</BIG></CENTER> -</A> - -<A NAME="transpose"><HR><B>mod2dense_transpose</B>: -Compute the transpose of a dense modulo-2 matrix.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_transpose -( mod2dense *m, /* Matrix to compute transpose of */ - mod2dense *r /* Result of transpose operation */ -) -</PRE></BLOCKQUOTE> - -Stores the transpose of its first argument, <B>m</B>, in the matrix -pointed to by its second argument, <B>r</B>, which must already have -been allocated, and which must have as many rows as <B>m</B> has -columns, and as many columns as <B>m</B> has rows. The two matrices -<B>m</B> and <B>r</B> must not be the same (ie, the two pointers -passed must be different). - -<P><A NAME="add"><HR><B>mod2dense_add</B>: -Add two dense modulo-2 matrices.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_add -( mod2dense *m1, /* Left operand of add */ - mod2dense *m2, /* Right operand of add */ - mod2dense *r /* Place to store result of add */ -) -</PRE></BLOCKQUOTE> - -Adds matrices <B>m1</B> and <B>m2</B>, storing the result in the -matrix pointed to by <B>r</B>. All three matrices must have the same -numbers of rows and columns. It is permissible for <B>r</B> to be the -same as <B>m1</B> and/or <B>m2</B>. Neither of the first two matrices is -changed by this procedure (unless they are the same as <B>r</B>). - - -<P><A NAME="multiply"><HR><B>mod2dense_multiply</B>: -Multiply two dense modulo-2 matrices.</A> - -<BLOCKQUOTE><PRE> -void mod2dense_multiply -( mod2dense *m1, /* Left operand of multiply */ - mod2dense *m2, /* Right operand of multiply */ - mod2dense *r /* Place to store result of multiply */ -) -</PRE></BLOCKQUOTE> - -Does a matrix multiplication of <B>m1</B> by <B>m2</B>, and stores the -result in the matrix pointed to by <B>r</B>. The matrices must have -compatible numbers of rows and columns. Neither of the first two -matrices is changed by this procedure. The result matrix, <B>r</B>, -must not be the same as either <B>m1</B> or <B>m2</B>. - -<P>The algorithm used runs faster if <B>m2</B> contains mostly 0s, but -it is also appropriate for matrices with many 1s. - -<P><A NAME="equal"><HR><B>mod2dense_equal</B>: -Check whether two dense modulo-2 matrices are equal.</A> - -<BLOCKQUOTE><PRE> -int mod2dense_equal -( mod2dense *m1, /* Pointers to the two matrices */ - mod2dense *m2 /* to compare */ -) -</PRE></BLOCKQUOTE> - -Returns one if every element of <B>m1</B> is equal to the -corresponding element of <B>m2</B>, and otherwise returns zero. The -two matrices must have the same number of rows and the same number of -columns. - -<A NAME="invert-sec"> -<P><HR> -<CENTER><BIG>Dense Modulo-2 Matrix Inversion</BIG></CENTER> -</A> - -<A NAME="invert"><HR><B>mod2dense_invert</B>: -Invert a dense modulo-2 matrix.</A> - -<BLOCKQUOTE><PRE> -int mod2dense_invert -( mod2dense *m, /* Matrix to find inverse of (destroyed) */ - mod2dense *r /* Place to store the inverse */ -) -</PRE></BLOCKQUOTE> - -<P>Inverts the first matrix passed, <B>m</B>, and stores its inverse in -the second matrix, <B>r</B>. The contents of <B>m</B> are destroyed -by this operation, though it remains a valid matrix for storing into -later. The matrix <B>m</B> must have the same number of rows as -columns. The matrix <B>r</B> must already have been allocated, and -must have the same number of rows and columns as <B>m</B>. The -two matrices passed must not be the same. - -<P>The value returned is one if the inversion was successful and zero -if the matrix turned out to be singular (in which case the contents of -both the original matrix and the result matrix will be garbage). - -<P>The algorithm used is based on inverting M by transforming the equation -MI = M to the equation MR = I using column operations, at which point R -is the inverse of M. The representation of matrices used allows easy -swapping of columns as needed by fiddling pointers. - -<P><A NAME="forcibly_invert"><HR><B>mod2dense_forcibly_invert</B>: -Forcibly invert a matrix by changing bits if necessary.</A> - -<BLOCKQUOTE><PRE> -int mod2dense_forcibly_invert -( mod2dense *m, /* Matrix to find inverse of (destroyed) */ - mod2dense *r, /* Place to store the inverse */ - int *a_row, /* Place to store row indexes of altered elements */ - int *a_col /* Place to store column indexes of altered elements */ -) -</PRE></BLOCKQUOTE> - -<P>Inverts the first matrix passed, <B>m</B>, and stores its inverse -in the second matrix, <B>r</B>, proceeding with the inversion even if -<B>m</B> is singular, by changing some elements as necessary. The -contents of <B>m</B> are destroyed by this operation, though it -remains a valid matrix for storing into later. The matrix <B>m</B> -must have the same number of rows as columns. The matrix <B>r</B> -must already have been allocated, and must have the same number of -rows and columns as <B>m</B>. The two matrices passed must not be the -same. - -<P>The value returned is the number of elements of <B>m</B> that had -to be changed to make inversion possible (zero, if the original matrix -was non-singular). The row and column indexes of the elements of the -original matrix that were changed are stored in the arrays passed as -the last two elements. These arrays must have as many elements as the -dimension of the matrix. (This is so even if it is known that fewer -elements than this will be changed, as these arrays are also used as -temporary storage by this routine.) - -<P>See <A HREF="#invert"><TT>mod2dense_invert</TT></A> for the algorithm used. - -<P><A NAME="invert_selected"><HR><B>mod2dense_invert_selected</B>: -Invert a matrix with columns selected from a bigger matrix.</A> - -<BLOCKQUOTE><PRE> -int mod2dense_invert_selected -( mod2dense *m, /* Matrix from which a submatrix is inverted (destroyed) */ - mod2dense *r, /* Place to store the inverse */ - int *rows, /* Place to store indexes of rows used and not used */ - int *cols /* Place to store indexes of columns used and not used */ -) -</PRE></BLOCKQUOTE> - -<P>Inverts a matrix obtained by selecting certain columns from the -first matrix passed, <B>m</B>, which must have at least as many -columns as rows. The second matrix passed, <B>r</B>, must already -exist, and must have the same number of rows and columns as <B>m</B>. -The result of inverting the sub-matrix of <B>m</B> is stored in the -corresponding columns of <B>r</B>, with the other columns being set to -garbage (or zero, see below). Normally, one would extract just the -relevant columns afterwards using <A -HREF="#copycols"><TT>mod2dense_copycols</TT></A>.) The contents of -<B>m</B> are destroyed (though it remains a valid matrix for storing -into later. The two matrices passed must not be the same. - -<P>The indexes of the columns selected are stored, in order, in the last -argument, <B>cols</B>, followed by the columns not selected (in -arbitrary order). The argument <B>rows</B> is set to the indexes of -the rows used, which will be simply the indexes from zero up if the -matrix is invertible, and will otherwise give an ordering that allows -the inversion to proceed as far as possible. - -<P>The value returned is zero if an invertible matrix was found, and -is otherwise the number of columns/rows that are redundant (ie, the -amount by which matrix falls short of being of full rank). If -inversion fails, partial results are stored in the columns and rows of -<B>r</B> identified by the initial portions of <B>cols</B> and -<B>rows</B>, such that if these rows and columns were extracted in -their new order, they would constitute the inverse of the -corresponding re-ordered submatrix of <B>m</B>. The remaining portion -of <B>cols</B> up to the number of rows in <B>m</B> will contain -indexes of columns of <B>r</B> that are selected arbitrarily; these -columns will, however, be set to contain all zeros. - -<P>Note that when the first matrix is square, and non-singular, the -result is NOT in general the same as that obtained by calling <A -HREF="#invert"></TT>mod2dense_invert</TT></A>, since that procedure -orders the columns of the inverse so that it applies to the original -ordering of the columns of the first matrix. - -<P>See <A HREF="#invert"><TT>mod2dense_invert</TT></A> for the algorithm used. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/mod2sparse-test-out b/lib/ldpc/mod2sparse-test-out deleted file mode 100755 index 5d17ddec..00000000 --- a/lib/ldpc/mod2sparse-test-out +++ /dev/null @@ -1,431 +0,0 @@ - -PART 1: - -Matrix m1: - - 0: 0 - 1: 1 - 2: 2 3 - 3: 3 - 4: 4 - 5: 5 - 6: 6 - 7: 7 - 8: 8 - 9: 9 -10: 10 38 -11: 11 -12: 12 -13: 13 -14: 14 -15: 15 -16: 16 -17: 17 -18: 18 -19: 19 -20: 20 -21: 21 -22: 22 -23: 23 -24: 24 -25: 25 -26: 26 -27: 27 -28: 28 -29: 29 -30: 30 -31: 31 -32: 32 -33: 33 -34: 4 34 - -Matrix m2, as read from file. Should be same as m1 above. - - 0: 0 - 1: 1 - 2: 2 3 - 3: 3 - 4: 4 - 5: 5 - 6: 6 - 7: 7 - 8: 8 - 9: 9 -10: 10 38 -11: 11 -12: 12 -13: 13 -14: 14 -15: 15 -16: 16 -17: 17 -18: 18 -19: 19 -20: 20 -21: 21 -22: 22 -23: 23 -24: 24 -25: 25 -26: 26 -27: 27 -28: 28 -29: 29 -30: 30 -31: 31 -32: 32 -33: 33 -34: 4 34 - -Test of equality of m1 & m2 (should be 1): 1 - -Matrix m3, copied from m1 above. - - 0: 0 - 1: 1 - 2: 2 3 - 3: 3 - 4: 4 - 5: 5 - 6: 6 - 7: 7 - 8: 8 - 9: 9 -10: 10 38 -11: 11 -12: 12 -13: 13 -14: 14 -15: 15 -16: 16 -17: 17 -18: 18 -19: 19 -20: 20 -21: 21 -22: 22 -23: 23 -24: 24 -25: 25 -26: 26 -27: 27 -28: 28 -29: 29 -30: 30 -31: 31 -32: 32 -33: 33 -34: 4 34 - -Test of equality of m1 & m3 (should be 1): 1 - -Matrix m3 again, should now be all zeros. - - 0: - 1: - 2: - 3: - 4: - 5: - 6: - 7: - 8: - 9: -10: -11: -12: -13: -14: -15: -16: -17: -18: -19: -20: -21: -22: -23: -24: -25: -26: -27: -28: -29: -30: -31: -32: -33: -34: - -Test of equality of m1 & m3 (should be 0): 0 - - -PART 2: - -Transpose of m1. - - 0: 0 - 1: 1 - 2: 2 - 3: 2 3 - 4: 4 34 - 5: 5 - 6: 6 - 7: 7 - 8: 8 - 9: 9 -10: 10 -11: 11 -12: 12 -13: 13 -14: 14 -15: 15 -16: 16 -17: 17 -18: 18 -19: 19 -20: 20 -21: 21 -22: 22 -23: 23 -24: 24 -25: 25 -26: 26 -27: 27 -28: 28 -29: 29 -30: 30 -31: 31 -32: 32 -33: 33 -34: 34 -35: -36: -37: -38: 10 -39: - -Matrix m1 after adding rows 2 and 12 and 3 to 10. - - 0: 0 - 1: 1 - 2: 2 3 - 3: 3 - 4: 4 - 5: 5 - 6: 6 - 7: 7 - 8: 8 - 9: 9 -10: 2 10 12 38 -11: 11 -12: 12 -13: 13 -14: 14 -15: 15 -16: 16 -17: 17 -18: 18 -19: 19 -20: 20 -21: 21 -22: 22 -23: 23 -24: 24 -25: 25 -26: 26 -27: 27 -28: 28 -29: 29 -30: 30 -31: 31 -32: 32 -33: 33 -34: 4 34 - -Matrix m1 after further adding column 34 to 0. - - 0: 0 - 1: 1 - 2: 2 3 - 3: 3 - 4: 4 - 5: 5 - 6: 6 - 7: 7 - 8: 8 - 9: 9 -10: 2 10 12 38 -11: 11 -12: 12 -13: 13 -14: 14 -15: 15 -16: 16 -17: 17 -18: 18 -19: 19 -20: 20 -21: 21 -22: 22 -23: 23 -24: 24 -25: 25 -26: 26 -27: 27 -28: 28 -29: 29 -30: 30 -31: 31 -32: 32 -33: 33 -34: 0 4 34 - - -PART 3: - -Matrix s0. - -0: -1: 3 4 -2: 0 -3: 1 -4: - -Matrix s1. - -0: -1: 3 5 -2: -3: 0 1 6 -4: - -Matrix s2. - -0: 0 -1: 1 -2: -3: -4: -5: 1 2 3 -6: - -Maxtrix s1 times unpacked vector ( 1 0 0 1 0 1 0 ). - -( 0 0 0 1 0 ) - -Sum of s0 and s1. - -0: -1: 4 5 -2: 0 -3: 0 6 -4: - -Product of s1 and s2. - -0: -1: 1 2 3 -2: -3: 0 1 -4: - -Tried to find (1,2), actually found: (1,2) - -Above matrix with (1,2) cleared. - -0: -1: 1 3 -2: -3: 0 1 -4: - -Tried to find (1,1), actually found: (1,1) - -Matrix with (1,1) cleared as well. - -0: -1: 3 -2: -3: 0 1 -4: - - -PART 4: - -Matrix s1. - -0: 3 5 -1: 1 6 -2: 0 -3: 1 2 -4: 0 2 -5: 6 - -LU decomposition (returned value was 0). - -L= -0: 3 -1: 1 -2: 0 -3: 1 2 -4: 0 2 4 -5: - -U= -0: 0 -1: 1 6 -2: 2 6 -3: 3 -4: 6 - -cols: 0 1 2 3 6 5 4 -rows: 2 1 3 0 4 5 - -Product of L and U. - -0: 3 -1: 1 6 -2: 0 -3: 1 2 -4: 0 2 -5: - -Solution of Ly=x with x from ( 0 1 1 0 1 0 ) according to rows selected. - - 1 1 1 0 1 - -Returned value from forward_sub was 1 - -Solution of Uz=y. - - 1 0 0 0 0 0 1 - -Returned value from backward_sub was 1 - - -PART 5: - -Matrix m1: - -0: 3 -1: 1 -2: 2 -3: 0 - -Matrix m2, copyrows of m1 in order 3,1,2,0 (should be identity) - -0: 0 -1: 1 -2: 2 -3: 3 - -Matrix m3, copycols of m1 in order 3,1,2,0 (should be identity) - -0: 0 -1: 1 -2: 2 -3: 3 - - -DONE WITH TESTS. diff --git a/lib/ldpc/mod2sparse-test.c b/lib/ldpc/mod2sparse-test.c deleted file mode 100755 index 04c26250..00000000 --- a/lib/ldpc/mod2sparse-test.c +++ /dev/null @@ -1,378 +0,0 @@ -/* MOD2SPARSE-TEST. C - Program to test mod2sparse module. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* Correct output for this program is saved in the file mod2sparse-test-out */ - - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> - -#include "mod2sparse.h" - - -main(void) -{ - mod2sparse *m1, *m2, *m3, *m4; - mod2sparse *s0, *s1, *s2, *s3, *s4; - mod2sparse *L, *U; - mod2entry *e; - int rows[5], cols[7]; - int i, j; - FILE *f; - - - printf("\nPART 1:\n\n"); - - /* Set up m1 with bits on a diagonal plus a few more set to 1. */ - - m1 = mod2sparse_allocate(35,40); - - mod2sparse_clear(m1); - - for (i = 0; i<35; i++) mod2sparse_insert(m1,i,i); - - mod2sparse_insert(m1,2,3); - mod2sparse_insert(m1,34,4); - mod2sparse_insert(m1,10,38); - - /* Print m1. */ - - printf("Matrix m1:\n\n"); - mod2sparse_print(stdout,m1); - printf("\n"); fflush(stdout); - - /* Store m1 in a file. */ - - f = fopen("test-file","wb"); - if (f==0) - { fprintf(stderr,"Can't create test-file\n"); - exit(1); - } - - if (!mod2sparse_write(f,m1)) - { printf("Error from mod2sparse_write\n"); - } - - fclose(f); - - /* Read matrix written above back into m2. */ - - f = fopen("test-file","rb"); - if (f==0) - { fprintf(stderr,"Can't open test-file\n"); - exit(1); - } - - m2 = mod2sparse_read(f); - - if (m2==0) - { printf("Error from mod2sparse_read\n"); - exit(1); - } - - /* Print m2, along with result of equality test. */ - - printf("Matrix m2, as read from file. Should be same as m1 above.\n\n"); - mod2sparse_print(stdout,m2); - printf("\n"); fflush(stdout); - - printf("Test of equality of m1 & m2 (should be 1): %d\n\n", - mod2sparse_equal(m1,m2)); - - /* Copy m1 to m3. */ - - m3 = mod2sparse_allocate(mod2sparse_rows(m1),mod2sparse_cols(m1)); - - mod2sparse_copy(m1,m3); - - /* Print m3, along with result of equality test. */ - - printf("Matrix m3, copied from m1 above.\n\n"); - mod2sparse_print(stdout,m3); - printf("\n"); fflush(stdout); - - printf("Test of equality of m1 & m3 (should be 1): %d\n\n", - mod2sparse_equal(m1,m3)); - - /* Clear m3. */ - - mod2sparse_clear(m3); - - /* Print m3 again. */ - - printf("Matrix m3 again, should now be all zeros.\n\n"); - mod2sparse_print(stdout,m3); - printf("\n"); fflush(stdout); - - printf("Test of equality of m1 & m3 (should be 0): %d\n\n", - mod2sparse_equal(m1,m3)); - - - printf("\nPART 2:\n\n"); - - /* Compute transpose of m1. */ - - m4 = mod2sparse_allocate(mod2sparse_cols(m1),mod2sparse_rows(m1)); - - mod2sparse_transpose(m1,m4); - - /* Print transpose. */ - - printf("Transpose of m1.\n\n"); - mod2sparse_print(stdout,m4); - printf("\n"); fflush(stdout); - - /* Add rows and columns in m1. */ - - mod2sparse_add_row(m1,10,m1,2); - mod2sparse_add_row(m1,10,m1,12); - mod2sparse_add_row(m1,10,m1,3); - printf("Matrix m1 after adding rows 2 and 12 and 3 to 10.\n\n"); - mod2sparse_print(stdout,m1); - printf("\n"); fflush(stdout); - printf("Matrix m1 after further adding column 34 to 0.\n\n"); - mod2sparse_add_col(m1,0,m1,34); - mod2sparse_print(stdout,m1); - printf("\n"); fflush(stdout); - - /* Free space for m1, m2, and m3. */ - - mod2sparse_free(m1); - mod2sparse_free(m2); - mod2sparse_free(m3); - - - printf("\nPART 3:\n\n"); - - /* Allocate some small matrices. */ - - s0 = mod2sparse_allocate(5,7); - s1 = mod2sparse_allocate(5,7); - s2 = mod2sparse_allocate(7,4); - s3 = mod2sparse_allocate(5,4); - s4 = mod2sparse_allocate(5,7); - - /* Set up the contents of s0, s1, and s2. */ - - mod2sparse_clear(s0); - mod2sparse_clear(s1); - mod2sparse_clear(s2); - - mod2sparse_insert(s0,1,3); - mod2sparse_insert(s0,1,4); - mod2sparse_insert(s0,2,0); - mod2sparse_insert(s0,3,1); - - mod2sparse_insert(s1,1,3); - mod2sparse_insert(s1,1,5); - mod2sparse_insert(s1,3,0); - mod2sparse_insert(s1,3,1); - mod2sparse_insert(s1,3,6); - - mod2sparse_insert(s2,5,1); - mod2sparse_insert(s2,5,2); - mod2sparse_insert(s2,5,3); - mod2sparse_insert(s2,0,0); - mod2sparse_insert(s2,1,1); - - /* Print s0, s1, and s2. */ - - printf("Matrix s0.\n\n"); - mod2sparse_print(stdout,s0); - printf("\nMatrix s1.\n\n"); - mod2sparse_print(stdout,s1); - printf("\nMatrix s2.\n\n"); - mod2sparse_print(stdout,s2); - printf("\n"); fflush(stdout); - - /* Multiply s1 by vector (1 1 0 1 0 1 0). */ - - { char u[7] = { 1, 0, 0, 1, 0, 1, 0 }; - char v[5]; - int i; - printf("Maxtrix s1 times unpacked vector ( 1 0 0 1 0 1 0 ).\n\n("); - mod2sparse_mulvec(s1,u,v); - for (i = 0; i<5; i++) printf(" %d",v[i]); - printf(" )\n\n"); - } - - /* Add s0 and s1, storing the result in s4, then print s4. */ - - mod2sparse_add(s0,s1,s4); - - printf("Sum of s0 and s1.\n\n"); - mod2sparse_print(stdout,s4); - printf("\n"); fflush(stdout); - - /* Multiply s1 and s2, storing the product in s3, and then print s3. */ - - mod2sparse_multiply(s1,s2,s3); - - printf("Product of s1 and s2.\n\n"); - mod2sparse_print(stdout,s3); - printf("\n"); fflush(stdout); - - /* Try clearing a bit in s3, then printing the result. */ - - e = mod2sparse_find(s3,1,2); - printf("Tried to find (1,2), actually found: (%d,%d)\n\n", - mod2sparse_row(e), mod2sparse_col(e)); - - mod2sparse_delete(s3,e); - - printf("Above matrix with (1,2) cleared.\n\n"); - mod2sparse_print(stdout,s3); - printf("\n"); fflush(stdout); - - /* Try clearing another bit in s3, then printing the result. */ - - e = mod2sparse_find(s3,1,1); - printf("Tried to find (1,1), actually found: (%d,%d)\n\n", - mod2sparse_row(e), mod2sparse_col(e)); - - mod2sparse_delete(s3,e); - - printf("Matrix with (1,1) cleared as well.\n\n"); - mod2sparse_print(stdout,s3); - printf("\n"); fflush(stdout); - - /* Free space for s0, s1, s2, s3, and s4. */ - - mod2sparse_free(s0); - mod2sparse_free(s1); - mod2sparse_free(s2); - mod2sparse_free(s3); - mod2sparse_free(s4); - - - printf("\nPART 4:\n\n"); - - /* Set up a small rectangular matrix, s1. */ - - s1 = mod2sparse_allocate(6,7); - - mod2sparse_clear(s1); - - mod2sparse_insert(s1,0,3); - mod2sparse_insert(s1,0,5); - mod2sparse_insert(s1,1,6); - mod2sparse_insert(s1,1,1); - mod2sparse_insert(s1,2,0); - mod2sparse_insert(s1,3,1); - mod2sparse_insert(s1,3,2); - mod2sparse_insert(s1,4,2); - mod2sparse_insert(s1,4,0); - mod2sparse_insert(s1,5,6); - - /* Print s1. */ - - printf("Matrix s1.\n\n"); - mod2sparse_print(stdout,s1); - printf("\n"); fflush(stdout); - - /* Compute and print LU decomposition. */ - - L = mod2sparse_allocate(6,5); - U = mod2sparse_allocate(5,7); - - i = mod2sparse_decomp(s1,5,L,U,rows,cols,Mod2sparse_first,0,0); - - printf("LU decomposition (returned value was %d).\n\n",i); - printf("L=\n"); - mod2sparse_print(stdout,L); - printf("\nU=\n"); - mod2sparse_print(stdout,U); - printf("\n"); - - printf("cols:"); - for (j = 0; j<7; j++) printf(" %d",cols[j]); - printf("\n"); - printf("rows:"); - for (i = 0; i<6; i++) printf(" %d",rows[i]); - printf("\n\n"); - fflush(stdout); - - /* Compute and print product of L and U. Should match s1 for the - sub-matrix found. */ - - s2 = mod2sparse_allocate(6,7); - mod2sparse_multiply(L,U,s2); - - printf("Product of L and U.\n\n"); - mod2sparse_print(stdout,s2); - printf("\n"); - fflush(stdout); - - /* Solve system by forward and backward substitution. */ - - { char x[6] = { 0, 1, 1, 0, 1, 0 }; - static char y[5], z[7]; - int i, r; - - r = mod2sparse_forward_sub (L, rows, x, y); - printf( -"Solution of Ly=x with x from ( 0 1 1 0 1 0 ) according to rows selected.\n\n"); - for (i = 0; i<5; i++) printf(" %d",y[i]); - printf("\n\nReturned value from forward_sub was %d\n\n",r); - fflush(stdout); - - r = mod2sparse_backward_sub (U, cols, y, z); - printf("Solution of Uz=y.\n\n"); - for (i = 0; i<7; i++) printf(" %d",z[i]); - printf("\n\nReturned value from backward_sub was %d\n\n",r); - fflush(stdout); - } - - printf("\nPART 5:\n\n"); - - m1 = mod2sparse_allocate(4,4); - m2 = mod2sparse_allocate(4,4); - m3 = mod2sparse_allocate(4,4); - - mod2sparse_insert(m1,0,3); - mod2sparse_insert(m1,1,1); - mod2sparse_insert(m1,2,2); - mod2sparse_insert(m1,3,0); - - printf("Matrix m1:\n\n"); - - mod2sparse_print(stdout,m1); - printf("\n"); fflush(stdout); - - printf("Matrix m2, copyrows of m1 in order 3,1,2,0 (should be identity)\n\n"); - - { int rows[] = { 3, 1, 2, 0 }; - mod2sparse_copyrows(m1,m2,rows); - } - - mod2sparse_print(stdout,m2); - printf("\n"); fflush(stdout); - - printf("Matrix m3, copycols of m1 in order 3,1,2,0 (should be identity)\n\n"); - - { int cols[] = { 3, 1, 2, 0 }; - mod2sparse_copycols(m1,m3,cols); - } - - mod2sparse_print(stdout,m3); - printf("\n"); fflush(stdout); - - - printf("\nDONE WITH TESTS.\n"); - - exit(0); -} diff --git a/lib/ldpc/mod2sparse.c b/lib/ldpc/mod2sparse.c deleted file mode 100755 index f3f9ba9f..00000000 --- a/lib/ldpc/mod2sparse.c +++ /dev/null @@ -1,1365 +0,0 @@ -/* MOD2SPARSE.C - Procedures for handling sparse mod2 matrices. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* NOTE: See mod2sparse.html for documentation on these procedures. */ - - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> - -#include "alloc.h" -#include "intio.h" -#include "mod2sparse.h" - - -/* ALLOCATE AN ENTRY WITHIN A MATRIX. This local procedure is used to - allocate a new entry, representing a non-zero element, within a given - matrix. Entries in this matrix that were previously allocated and - then freed are re-used. If there are no such entries, a new block - of entries is allocated. */ - -static mod2entry *alloc_entry -( mod2sparse *m -) -{ - mod2block *b; - mod2entry *e; - int k; - - if (m->next_free==0) - { - b = chk_alloc (1, sizeof *b); - - b->next = m->blocks; - m->blocks = b; - - for (k = 0; k<Mod2sparse_block; k++) - { b->entry[k].left = m->next_free; - m->next_free = &b->entry[k]; - } - } - - e = m->next_free; - m->next_free = e->left; - - e->pr = 0; - e->lr = 0; - - return e; -} - - -/* ALLOCATE SPACE FOR A SPARSE MOD2 MATRIX. */ - -mod2sparse *mod2sparse_allocate -( int n_rows, /* Number of rows in matrix */ - int n_cols /* Number of columns in matrix */ -) -{ - mod2sparse *m; - mod2entry *e; - int i, j; - - if (n_rows<=0 || n_cols<=0) - { fprintf(stderr,"mod2sparse_allocate: Invalid number of rows or columns\n"); - exit(1); - } - - m = chk_alloc (1, sizeof *m); - - m->n_rows = n_rows; - m->n_cols = n_cols; - - m->rows = chk_alloc (n_rows, sizeof *m->rows); - m->cols = chk_alloc (n_cols, sizeof *m->cols); - - m->blocks = 0; - m->next_free = 0; - - for (i = 0; i<n_rows; i++) - { e = &m->rows[i]; - e->left = e->right = e->up = e->down = e; - e->row = e->col = -1; - } - - for (j = 0; j<n_cols; j++) - { e = &m->cols[j]; - e->left = e->right = e->up = e->down = e; - e->row = e->col = -1; - } - - return m; -} - - -/* FREE SPACE OCCUPIED BY A SPARSE MOD2 MATRIX. */ - -void mod2sparse_free -( mod2sparse *m /* Matrix to free */ -) -{ - mod2block *b; - - if (m) - { free(m->rows); - free(m->cols); - - while (m->blocks!=0) - { b = m->blocks; - m->blocks = b->next; - free(b); - } - - free (m); - } -} - - -/* CLEAR A SPARSE MATRIX TO ALL ZEROS. */ - -void mod2sparse_clear -( mod2sparse *r -) -{ - mod2block *b; - mod2entry *e; - int i, j; - - for (i = 0; i<mod2sparse_rows(r); i++) - { e = &r->rows[i]; - e->left = e->right = e->up = e->down = e; - } - - for (j = 0; j<mod2sparse_cols(r); j++) - { e = &r->cols[j]; - e->left = e->right = e->up = e->down = e; - } - - while (r->blocks!=0) - { b = r->blocks; - r->blocks = b->next; - free(b); - } -} - - -/* COPY A SPARSE MATRIX. */ - -void mod2sparse_copy -( mod2sparse *m, /* Matrix to copy */ - mod2sparse *r /* Place to store copy of matrix */ -) -{ - mod2entry *e, *f; - int i; - - if (mod2sparse_rows(m)>mod2sparse_rows(r) - || mod2sparse_cols(m)>mod2sparse_cols(r)) - { fprintf(stderr,"mod2sparse_copy: Destination matrix is too small\n"); - exit(1); - } - - mod2sparse_clear(r); - - for (i = 0; i<mod2sparse_rows(m); i++) - { - e = mod2sparse_first_in_row(m,i); - - while (!mod2sparse_at_end(e)) - { f = mod2sparse_insert(r,e->row,e->col); - f->lr = e->lr; - f->pr = e->pr; - e = mod2sparse_next_in_row(e); - } - } -} - - -/* COPY ROWS OF A SPARSE MOD2 MATRIX. */ - -void mod2sparse_copyrows -( mod2sparse *m, /* Matrix to copy */ - mod2sparse *r, /* Place to store copy of matrix */ - int *rows /* Indexes of rows to copy, from 0 */ -) -{ - mod2entry *e; - int i; - - if (mod2sparse_cols(m)>mod2sparse_cols(r)) - { fprintf(stderr, - "mod2sparse_copyrows: Destination matrix has fewer columns than source\n"); - exit(1); - } - - mod2sparse_clear(r); - - for (i = 0; i<mod2sparse_rows(r); i++) - { if (rows[i]<0 || rows[i]>=mod2sparse_rows(m)) - { fprintf(stderr,"mod2sparse_copyrows: Row index out of range\n"); - exit(1); - } - e = mod2sparse_first_in_row(m,rows[i]); - while (!mod2sparse_at_end(e)) - { mod2sparse_insert(r,i,e->col); - e = mod2sparse_next_in_row(e); - } - } -} - - -/* COPY COLUMNS OF A SPARSE MOD2 MATRIX. */ - -void mod2sparse_copycols -( mod2sparse *m, /* Matrix to copy */ - mod2sparse *r, /* Place to store copy of matrix */ - int *cols /* Indexes of columns to copy, from 0 */ -) -{ - mod2entry *e; - int j; - - if (mod2sparse_rows(m)>mod2sparse_rows(r)) - { fprintf(stderr, - "mod2sparse_copycols: Destination matrix has fewer rows than source\n"); - exit(1); - } - - mod2sparse_clear(r); - - for (j = 0; j<mod2sparse_cols(r); j++) - { if (cols[j]<0 || cols[j]>=mod2sparse_cols(m)) - { fprintf(stderr,"mod2sparse_copycols: Column index out of range\n"); - exit(1); - } - e = mod2sparse_first_in_col(m,cols[j]); - while (!mod2sparse_at_end(e)) - { mod2sparse_insert(r,e->row,j); - e = mod2sparse_next_in_col(e); - } - } -} - - -/* PRINT A SPARSE MOD2 MATRIX IN HUMAN-READABLE FORM. */ - -void mod2sparse_print -( FILE *f, - mod2sparse *m -) -{ - int rdigits, cdigits; - mod2entry *e; - int i; - - rdigits = mod2sparse_rows(m)<=10 ? 1 - : mod2sparse_rows(m)<=100 ? 2 - : mod2sparse_rows(m)<=1000 ? 3 - : mod2sparse_rows(m)<=10000 ? 4 - : mod2sparse_rows(m)<=100000 ? 5 - : 6; - - cdigits = mod2sparse_cols(m)<=10 ? 1 - : mod2sparse_cols(m)<=100 ? 2 - : mod2sparse_cols(m)<=1000 ? 3 - : mod2sparse_cols(m)<=10000 ? 4 - : mod2sparse_cols(m)<=100000 ? 5 - : 6; - - for (i = 0; i<mod2sparse_rows(m); i++) - { - fprintf(f,"%*d:",rdigits,i); - - e = mod2sparse_first_in_row(m,i); - while (!mod2sparse_at_end(e)) - { fprintf(f," %*d",cdigits,mod2sparse_col(e)); - e = mod2sparse_next_in_row(e); - } - - fprintf(f,"\n"); - } -} - - -/* WRITE A SPARSE MOD2 MATRIX TO A FILE IN MACHINE-READABLE FORM. */ - -int mod2sparse_write -( FILE *f, - mod2sparse *m -) -{ - mod2entry *e; - int i; - - intio_write(f,m->n_rows); - if (ferror(f)) return 0; - - intio_write(f,m->n_cols); - if (ferror(f)) return 0; - - for (i = 0; i<mod2sparse_rows(m); i++) - { - e = mod2sparse_first_in_row(m,i); - - if (!mod2sparse_at_end(e)) - { - intio_write (f, -(i+1)); - if (ferror(f)) return 0; - - while (!mod2sparse_at_end(e)) - { - intio_write (f, mod2sparse_col(e)+1); - if (ferror(f)) return 0; - - e = mod2sparse_next_in_row(e); - } - } - } - - intio_write(f,0); - if (ferror(f)) return 0; - - return 1; -} - - -/* READ A SPARSE MOD2 MATRIX STORED IN MACHINE-READABLE FORM FROM A FILE. */ - -mod2sparse *mod2sparse_read -( FILE *f -) -{ - int n_rows, n_cols; - mod2sparse *m; - int v, row, col; - - n_rows = intio_read(f); - if (feof(f) || ferror(f) || n_rows<=0) return 0; - - n_cols = intio_read(f); - if (feof(f) || ferror(f) || n_cols<=0) return 0; - - m = mod2sparse_allocate(n_rows,n_cols); - - row = -1; - - for (;;) - { - v = intio_read(f); - if (feof(f) || ferror(f)) break; - - if (v==0) - { return m; - } - else if (v<0) - { row = -v-1; - if (row>=n_rows) break; - } - else - { col = v-1; - if (col>=n_cols) break; - if (row==-1) break; - mod2sparse_insert(m,row,col); - } - } - - /* Error if we get here. */ - - mod2sparse_free(m); - return 0; -} - - -/* LOOK FOR AN ENTRY WITH GIVEN ROW AND COLUMN. */ - -mod2entry *mod2sparse_find -( mod2sparse *m, - int row, - int col -) -{ - mod2entry *re, *ce; - - if (row<0 || row>=mod2sparse_rows(m) || col<0 || col>=mod2sparse_cols(m)) - { fprintf(stderr,"mod2sparse_find: row or column index out of bounds\n"); - exit(1); - } - - /* Check last entries in row and column. */ - - re = mod2sparse_last_in_row(m,row); - if (mod2sparse_at_end(re) || mod2sparse_col(re)<col) - { return 0; - } - if (mod2sparse_col(re)==col) - { return re; - } - - ce = mod2sparse_last_in_col(m,col); - if (mod2sparse_at_end(ce) || mod2sparse_row(ce)<row) - { return 0; - } - if (mod2sparse_row(ce)==row) - { return ce; - } - - /* Search row and column in parallel, from the front. */ - - re = mod2sparse_first_in_row(m,row); - ce = mod2sparse_first_in_col(m,col); - - for (;;) - { - if (mod2sparse_at_end(re) || mod2sparse_col(re)>col) - { return 0; - } - if (mod2sparse_col(re)==col) - { return re; - } - - if (mod2sparse_at_end(ce) || mod2sparse_row(ce)>row) - { return 0; - } - if (mod2sparse_row(ce)==row) - { return ce; - } - - re = mod2sparse_next_in_row(re); - ce = mod2sparse_next_in_col(ce); - } -} - - -/* INSERT AN ENTRY WITH GIVEN ROW AND COLUMN. */ - -mod2entry *mod2sparse_insert -( mod2sparse *m, - int row, - int col -) -{ - mod2entry *re, *ce, *ne; - - if (row<0 || row>=mod2sparse_rows(m) || col<0 || col>=mod2sparse_cols(m)) - { fprintf(stderr,"mod2sparse_insert: row or column index out of bounds\n"); - exit(1); - } - - /* Find old entry and return it, or allocate new entry and insert into row. */ - - re = mod2sparse_last_in_row(m,row); - - if (!mod2sparse_at_end(re) && mod2sparse_col(re)==col) - { return re; - } - - if (mod2sparse_at_end(re) || mod2sparse_col(re)<col) - { re = re->right; - } - else - { - re = mod2sparse_first_in_row(m,row); - - for (;;) - { - if (!mod2sparse_at_end(re) && mod2sparse_col(re)==col) - { return re; - } - - if (mod2sparse_at_end(re) || mod2sparse_col(re)>col) - { break; - } - - re = mod2sparse_next_in_row(re); - } - } - - ne = alloc_entry(m); - - ne->row = row; - ne->col = col; - - ne->left = re->left; - ne->right = re; - ne->left->right = ne; - ne->right->left = ne; - - /* Insert new entry into column. If we find an existing entry here, - the matrix must be garbled, since we didn't find it in the row. */ - - ce = mod2sparse_last_in_col(m,col); - - if (!mod2sparse_at_end(ce) && mod2sparse_row(ce)==row) - { fprintf(stderr,"mod2sparse_insert: Garbled matrix\n"); - exit(1); - } - - if (mod2sparse_at_end(ce) || mod2sparse_row(ce)<row) - { ce = ce->down; - } - else - { - ce = mod2sparse_first_in_col(m,col); - - for (;;) - { - if (!mod2sparse_at_end(ce) && mod2sparse_row(ce)==row) - { fprintf(stderr,"mod2sparse_insert: Garbled matrix\n"); - exit(1); - } - - if (mod2sparse_at_end(ce) || mod2sparse_row(ce)>row) - { break; - } - - ce = mod2sparse_next_in_col(ce); - } - } - - ne->up = ce->up; - ne->down = ce; - ne->up->down = ne; - ne->down->up = ne; - - /* Return the new entry. */ - - return ne; -} - - -/* DELETE AN ENTRY FROM A SPARSE MATRIX. */ - -void mod2sparse_delete -( mod2sparse *m, - mod2entry *e -) -{ - if (e==0) - { fprintf(stderr,"mod2sparse_delete: Trying to delete a null entry\n"); - exit(1); - } - - if (e->row<0 || e->col<0) - { fprintf(stderr,"mod2sparse_delete: Trying to delete a header entry\n"); - exit(1); - } - - e->left->right = e->right; - e->right->left = e->left; - - e->up->down = e->down; - e->down->up = e->up; - - e->left = m->next_free; - m->next_free = e; -} - - -/* TEST WHETHER TWO SPARSE MATRICES ARE EQUAL. */ - -int mod2sparse_equal -( mod2sparse *m1, - mod2sparse *m2 -) -{ - mod2entry *e1, *e2; - int i; - - if (mod2sparse_rows(m1)!=mod2sparse_rows(m2) - || mod2sparse_cols(m1)!=mod2sparse_cols(m2)) - { fprintf(stderr,"mod2sparse_equal: Matrices have different dimensions\n"); - exit(1); - } - - for (i = 0; i<mod2sparse_rows(m1); i++) - { - e1 = mod2sparse_first_in_row(m1,i); - e2 = mod2sparse_first_in_row(m2,i); - - while (!mod2sparse_at_end(e1) && !mod2sparse_at_end(e2)) - { - if (mod2sparse_col(e1)!=mod2sparse_col(e2)) - { return 0; - } - - e1 = mod2sparse_next_in_row(e1); - e2 = mod2sparse_next_in_row(e2); - } - - if (!mod2sparse_at_end(e1) || !mod2sparse_at_end(e2)) - { return 0; - } - } - - return 1; -} - - -/* COMPUTE THE TRANSPOSE OF A SPARSE MOD2 MATRIX. */ - -void mod2sparse_transpose -( mod2sparse *m, /* Matrix to compute transpose of (left unchanged) */ - mod2sparse *r /* Result of transpose operation */ -) -{ - mod2entry *e; - int i; - - if (mod2sparse_rows(m)!=mod2sparse_cols(r) - || mod2sparse_cols(m)!=mod2sparse_rows(r)) - { fprintf(stderr, - "mod2sparse_transpose: Matrices have incompatible dimensions\n"); - exit(1); - } - - if (r==m) - { fprintf(stderr, - "mod2sparse_transpose: Result matrix is the same as the operand\n"); - exit(1); - } - - mod2sparse_clear(r); - - for (i = 0; i<mod2sparse_rows(m); i++) - { - e = mod2sparse_first_in_row(m,i); - - while (!mod2sparse_at_end(e)) - { mod2sparse_insert(r,mod2sparse_col(e),i); - e = mod2sparse_next_in_row(e); - } - } -} - - -/* ADD TWO SPARSE MOD2 MATRICES. */ - -void mod2sparse_add -( mod2sparse *m1, /* Left operand of add */ - mod2sparse *m2, /* Right operand of add */ - mod2sparse *r /* Place to store result of add */ -) -{ - mod2entry *e1, *e2; - int i; - - if (mod2sparse_rows(m1)!=mod2sparse_rows(r) - || mod2sparse_cols(m1)!=mod2sparse_cols(r) - || mod2sparse_rows(m2)!=mod2sparse_rows(r) - || mod2sparse_cols(m2)!=mod2sparse_cols(r)) - { fprintf(stderr,"mod2sparse_add: Matrices have different dimensions\n"); - exit(1); - } - - if (r==m1 || r==m2) - { fprintf(stderr, - "mod2sparse_add: Result matrix is the same as one of the operands\n"); - exit(1); - } - - mod2sparse_clear(r); - - for (i = 0; i<mod2sparse_rows(r); i++) - { - e1 = mod2sparse_first_in_row(m1,i); - e2 = mod2sparse_first_in_row(m2,i); - - while (!mod2sparse_at_end(e1) && !mod2sparse_at_end(e2)) - { - if (mod2sparse_col(e1)==mod2sparse_col(e2)) - { e1 = mod2sparse_next_in_row(e1); - e2 = mod2sparse_next_in_row(e2); - } - - else if (mod2sparse_col(e1)<mod2sparse_col(e2)) - { mod2sparse_insert(r,i,mod2sparse_col(e1)); - e1 = mod2sparse_next_in_row(e1); - } - - else - { mod2sparse_insert(r,i,mod2sparse_col(e2)); - e2 = mod2sparse_next_in_row(e2); - } - } - - while (!mod2sparse_at_end(e1)) - { mod2sparse_insert(r,i,mod2sparse_col(e1)); - e1 = mod2sparse_next_in_row(e1); - } - - while (!mod2sparse_at_end(e2)) - { mod2sparse_insert(r,i,mod2sparse_col(e2)); - e2 = mod2sparse_next_in_row(e2); - } - } -} - - -/* MULTIPLY TWO SPARSE MOD2 MATRICES. */ - -void mod2sparse_multiply -( mod2sparse *m1, /* Left operand of multiply */ - mod2sparse *m2, /* Right operand of multiply */ - mod2sparse *r /* Place to store result of multiply */ -) -{ - mod2entry *e1, *e2; - int i, j, b; - - if (mod2sparse_cols(m1)!=mod2sparse_rows(m2) - || mod2sparse_rows(m1)!=mod2sparse_rows(r) - || mod2sparse_cols(m2)!=mod2sparse_cols(r)) - { fprintf (stderr, - "mod2sparse_multiply: Matrices have incompatible dimensions\n"); - exit(1); - } - - if (r==m1 || r==m2) - { fprintf(stderr, - "mod2sparse_multiply: Result matrix is the same as one of the operands\n"); - exit(1); - } - - mod2sparse_clear(r); - - for (i = 0; i<mod2sparse_rows(m1); i++) - { - if (mod2sparse_at_end(mod2sparse_first_in_row(m1,i))) - { continue; - } - - for (j = 0; j<mod2sparse_cols(m2); j++) - { - b = 0; - - e1 = mod2sparse_first_in_row(m1,i); - e2 = mod2sparse_first_in_col(m2,j); - - while (!mod2sparse_at_end(e1) && !mod2sparse_at_end(e2)) - { - if (mod2sparse_col(e1)==mod2sparse_row(e2)) - { b ^= 1; - e1 = mod2sparse_next_in_row(e1); - e2 = mod2sparse_next_in_col(e2); - } - - else if (mod2sparse_col(e1)<mod2sparse_row(e2)) - { e1 = mod2sparse_next_in_row(e1); - } - - else - { e2 = mod2sparse_next_in_col(e2); - } - } - - if (b) - { mod2sparse_insert(r,i,j); - } - } - } -} - - -/* MULTIPLY VECTOR BY SPARSE MATRIX. */ - -void mod2sparse_mulvec -( mod2sparse *m, /* The sparse matrix, with M rows and N columns */ - char *u, /* The input vector, N long */ - char *v /* Place to store the result, M long */ -) -{ - mod2entry *e; - int M, N; - int i, j; - - M = mod2sparse_rows(m); - N = mod2sparse_cols(m); - - for (i = 0; i<M; i++) v[i] = 0; - - for (j = 0; j<N; j++) - { if (u[j]) - { for (e = mod2sparse_first_in_col(m,j); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_col(e)) - { v[mod2sparse_row(e)] ^= 1; - } - } - } -} - - -/* COUNT ENTRIES IN A ROW. */ - -int mod2sparse_count_row -( mod2sparse *m, - int row -) -{ - mod2entry *e; - int count; - - if (row<0 || row>=mod2sparse_rows(m)) - { fprintf(stderr,"mod2sparse_count_row: row index out of bounds\n"); - exit(1); - } - - count = 0; - - for (e = mod2sparse_first_in_row(m,row); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_row(e)) - { count += 1; - } - - return count; -} - - -/* COUNT ENTRIES IN A COLUMN. */ - -int mod2sparse_count_col -( mod2sparse *m, - int col -) -{ - mod2entry *e; - int count; - - if (col<0 || col>=mod2sparse_cols(m)) - { fprintf(stderr,"mod2sparse_count_col: column index out of bounds\n"); - exit(1); - } - - count = 0; - - for (e = mod2sparse_first_in_col(m,col); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_col(e)) - { count += 1; - } - - return count; -} - - -/* ADD TO A ROW. */ - -void mod2sparse_add_row -( mod2sparse *m1, /* Matrix containing row to add to */ - int row1, /* Index in this matrix of row to add to */ - mod2sparse *m2, /* Matrix containing row to add from */ - int row2 /* Index in this matrix of row to add from */ -) -{ - mod2entry *f1, *f2, *ft; - - if (mod2sparse_cols(m1)<mod2sparse_cols(m2)) - { fprintf (stderr, - "mod2sparse_add_row: row added to is shorter than row added from\n"); - exit(1); - } - - if (row1<0 || row1>=mod2sparse_rows(m1) - || row2<0 || row2>=mod2sparse_rows(m2)) - { fprintf (stderr,"mod2sparse_add_row: row index out of range\n"); - exit(1); - } - - f1 = mod2sparse_first_in_row(m1,row1); - f2 = mod2sparse_first_in_row(m2,row2); - - while (!mod2sparse_at_end(f1) && !mod2sparse_at_end(f2)) - { if (mod2sparse_col(f1)>mod2sparse_col(f2)) - { mod2sparse_insert(m1,row1,mod2sparse_col(f2)); - f2 = mod2sparse_next_in_row(f2); - } - else - { ft = mod2sparse_next_in_row(f1); - if (mod2sparse_col(f1)==mod2sparse_col(f2)) - { mod2sparse_delete(m1,f1); - f2 = mod2sparse_next_in_row(f2); - } - f1 = ft; - } - } - - while (!mod2sparse_at_end(f2)) - { mod2sparse_insert(m1,row1,mod2sparse_col(f2)); - f2 = mod2sparse_next_in_row(f2); - } -} - - -/* ADD TO A COLUMN. */ - -void mod2sparse_add_col -( mod2sparse *m1, /* Matrix containing column to add to */ - int col1, /* Index in this matrix of column to add to */ - mod2sparse *m2, /* Matrix containing column to add from */ - int col2 /* Index in this matrix of column to add from */ -) -{ - mod2entry *f1, *f2, *ft; - - if (mod2sparse_rows(m1)<mod2sparse_rows(m2)) - { fprintf (stderr, - "mod2sparse_add_col: Column added to is shorter than column added from\n"); - exit(1); - } - - if (col1<0 || col1>=mod2sparse_cols(m1) - || col2<0 || col2>=mod2sparse_cols(m2)) - { fprintf (stderr,"mod2sparse_add_col: Column index out of range\n"); - exit(1); - } - - f1 = mod2sparse_first_in_col(m1,col1); - f2 = mod2sparse_first_in_col(m2,col2); - - while (!mod2sparse_at_end(f1) && !mod2sparse_at_end(f2)) - { if (mod2sparse_row(f1)>mod2sparse_row(f2)) - { mod2sparse_insert(m1,mod2sparse_row(f2),col1); - f2 = mod2sparse_next_in_col(f2); - } - else - { ft = mod2sparse_next_in_col(f1); - if (mod2sparse_row(f1)==mod2sparse_row(f2)) - { mod2sparse_delete(m1,f1); - f2 = mod2sparse_next_in_col(f2); - } - f1 = ft; - } - } - - while (!mod2sparse_at_end(f2)) - { mod2sparse_insert(m1,mod2sparse_row(f2),col1); - f2 = mod2sparse_next_in_col(f2); - } -} - - -/* FIND AN LU DECOMPOSITION OF A SPARSE MATRIX. */ - -int mod2sparse_decomp -( mod2sparse *A, /* Input matrix, M by N */ - int K, /* Size of sub-matrix to find LU decomposition of */ - mod2sparse *L, /* Matrix in which L is stored, M by K */ - mod2sparse *U, /* Matrix in which U is stored, K by N */ - int *rows, /* Array where row indexes are stored, M long */ - int *cols, /* Array where column indexes are stored, N long */ - mod2sparse_strategy strategy, /* Strategy to follow in picking rows/columns */ - int abandon_number, /* Number of columns to abandon at some point */ - int abandon_when /* When to abandon these columns */ -) -{ - int *rinv, *cinv, *acnt, *rcnt; - mod2sparse *B; - int M, N; - - mod2entry *e, *f, *fn, *e2; - int i, j, k, cc, cc2, cc3, cr2, pr; - int found, nnf; - - M = mod2sparse_rows(A); - N = mod2sparse_cols(A); - - if (mod2sparse_cols(L)!=K || mod2sparse_rows(L)!=M - || mod2sparse_cols(U)!=N || mod2sparse_rows(U)!=K) - { fprintf (stderr, - "mod2sparse_decomp: Matrices have incompatible dimensions\n"); - exit(1); - } - - if (abandon_number>N-K) - { fprintf(stderr,"Trying to abandon more columns than allowed\n"); - exit(1); - } - - rinv = chk_alloc (M, sizeof *rinv); - cinv = chk_alloc (N, sizeof *cinv); - - if (abandon_number>0) - { acnt = chk_alloc (M+1, sizeof *acnt); - } - - if (strategy==Mod2sparse_minprod) - { rcnt = chk_alloc (M, sizeof *rcnt); - } - - mod2sparse_clear(L); - mod2sparse_clear(U); - - /* Copy A to B. B will be modified, then discarded. */ - - B = mod2sparse_allocate(M,N); - mod2sparse_copy(A,B); - - /* Count 1s in rows of B, if using minprod strategy. */ - - if (strategy==Mod2sparse_minprod) - { for (i = 0; i<M; i++) - { rcnt[i] = mod2sparse_count_row(B,i); - } - } - - /* Set up initial row and column choices. */ - - for (i = 0; i<M; i++) rows[i] = rinv[i] = i; - for (j = 0; j<N; j++) cols[j] = cinv[j] = j; - - /* Find L and U one column at a time. */ - - nnf = 0; - - for (i = 0; i<K; i++) - { - /* Choose the next row and column of B. */ - - switch (strategy) - { - case Mod2sparse_first: - { - found = 0; - - for (k = i; k<N; k++) - { e = mod2sparse_first_in_col(B,cols[k]); - while (!mod2sparse_at_end(e)) - { if (rinv[mod2sparse_row(e)]>=i) - { found = 1; - goto out_first; - } - e = mod2sparse_next_in_col(e); - } - } - - out_first: - break; - } - - case Mod2sparse_mincol: - { - found = 0; - - for (j = i; j<N; j++) - { cc2 = mod2sparse_count_col(B,cols[j]); - if (!found || cc2<cc) - { e2 = mod2sparse_first_in_col(B,cols[j]); - while (!mod2sparse_at_end(e2)) - { if (rinv[mod2sparse_row(e2)]>=i) - { found = 1; - cc = cc2; - e = e2; - k = j; - break; - } - e2 = mod2sparse_next_in_col(e2); - } - } - } - - break; - } - - case Mod2sparse_minprod: - { - found = 0; - - for (j = i; j<N; j++) - { cc2 = mod2sparse_count_col(B,cols[j]); - e2 = mod2sparse_first_in_col(B,cols[j]); - while (!mod2sparse_at_end(e2)) - { if (rinv[mod2sparse_row(e2)]>=i) - { cr2 = rcnt[mod2sparse_row(e2)]; - if (!found || cc2==1 || (cc2-1)*(cr2-1)<pr) - { found = 1; - pr = cc2==1 ? 0 : (cc2-1)*(cr2-1); - e = e2; - k = j; - } - } - e2 = mod2sparse_next_in_col(e2); - } - } - - break; - } - - default: - { fprintf(stderr,"mod2sparse_decomp: Unknown stategy\n"); - exit(1); - } - } - - if (!found) - { nnf += 1; - } - - /* Update 'rows' and 'cols'. Looks at 'k' and 'e' found above. */ - - if (found) - { - if (cinv[mod2sparse_col(e)]!=k) abort(); - - cols[k] = cols[i]; - cols[i] = mod2sparse_col(e); - - cinv[cols[k]] = k; - cinv[cols[i]] = i; - - k = rinv[mod2sparse_row(e)]; - - if (k<i) abort(); - - rows[k] = rows[i]; - rows[i] = mod2sparse_row(e); - - rinv[rows[k]] = k; - rinv[rows[i]] = i; - } - - /* Update L, U, and B. */ - - f = mod2sparse_first_in_col(B,cols[i]); - - while (!mod2sparse_at_end(f)) - { - fn = mod2sparse_next_in_col(f); - k = mod2sparse_row(f); - - if (rinv[k]>i) - { mod2sparse_add_row(B,k,B,mod2sparse_row(e)); - if (strategy==Mod2sparse_minprod) - { rcnt[k] = mod2sparse_count_row(B,k); - } - mod2sparse_insert(L,k,i); - } - else if (rinv[k]<i) - { mod2sparse_insert(U,rinv[k],cols[i]); - } - else - { mod2sparse_insert(L,k,i); - mod2sparse_insert(U,i,cols[i]); - } - - f = fn; - } - - /* Get rid of all entries in the current column of B, just to save space. */ - - for (;;) - { f = mod2sparse_first_in_col(B,cols[i]); - if (mod2sparse_at_end(f)) break; - mod2sparse_delete(B,f); - } - - /* Abandon columns of B with lots of entries if it's time for that. */ - - if (abandon_number>0 && i==abandon_when) - { - for (k = 0; k<M+1; k++) - { acnt[k] = 0; - } - for (j = 0; j<N; j++) - { k = mod2sparse_count_col(B,j); - acnt[k] += 1; - } - - cc = abandon_number; - k = M; - while (acnt[k]<cc) - { cc -= acnt[k]; - k -= 1; - if (k<0) abort(); - } - - cc2 = 0; - for (j = 0; j<N; j++) - { cc3 = mod2sparse_count_col(B,j); - if (cc3>k || (cc3==k && cc>0)) - { if (cc3==k) cc -= 1; - for (;;) - { f = mod2sparse_first_in_col(B,j); - if (mod2sparse_at_end(f)) break; - mod2sparse_delete(B,f); - } - cc2 += 1; - } - } - - if (cc2!=abandon_number) abort(); - - if (strategy==Mod2sparse_minprod) - { for (j = 0; j<M; j++) - { rcnt[j] = mod2sparse_count_row(B,j); - } - } - } - } - - /* Get rid of all entries in the rows of L past row K, after reordering. */ - - for (i = K; i<M; i++) - { for (;;) - { f = mod2sparse_first_in_row(L,rows[i]); - if (mod2sparse_at_end(f)) break; - mod2sparse_delete(L,f); - } - } - - mod2sparse_free(B); - free(rinv); - free(cinv); - if (strategy==Mod2sparse_minprod) free(rcnt); - if (abandon_number>0) free(acnt); - - return nnf; -} - - -/* SOLVE A LOWER-TRIANGULAR SYSTEM BY FORWARD SUBSTITUTION. */ - -int mod2sparse_forward_sub -( mod2sparse *L, /* Matrix that is lower triangular after reordering */ - int *rows, /* Array of indexes (from 0) of rows for new order */ - char *x, /* Vector on right of equation, also reordered */ - char *y /* Place to store solution */ -) -{ - int K, i, j, ii, b, d; - mod2entry *e; - - K = mod2sparse_cols(L); - - /* Make sure that L is lower-triangular, after row re-ordering. */ - - for (i = 0; i<K; i++) - { ii = rows ? rows[i] : i; - e = mod2sparse_last_in_row(L,ii); - if (!mod2sparse_at_end(e) && mod2sparse_col(e)>i) - { fprintf(stderr, - "mod2sparse_forward_sub: Matrix is not lower-triangular\n"); - exit(1); - } - } - - /* Solve system by forward substitution. */ - - for (i = 0; i<K; i++) - { - ii = rows ? rows[i] : i; - - /* Look at bits in this row, forming inner product with partial - solution, and seeing if the diagonal is 1. */ - - d = 0; - b = 0; - - for (e = mod2sparse_first_in_row(L,ii); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_row(e)) - { - j = mod2sparse_col(e); - - if (j==i) - { d = 1; - } - else - { b ^= y[j]; - } - } - - /* Check for no solution if the diagonal isn't 1. */ - - if (!d && b!=x[ii]) - { return 0; - } - - /* Set bit of solution, zero if arbitrary. */ - - y[i] = b^x[ii]; - } - - return 1; -} - - -/* SOLVE AN UPPER-TRIANGULAR SYSTEM BY BACKWARD SUBSTITUTION. */ - -int mod2sparse_backward_sub -( mod2sparse *U, /* Matrix that is upper triangular after reordering */ - int *cols, /* Array of indexes (from 0) of columns for new order */ - char *y, /* Vector on right of equation */ - char *z /* Place to store solution, also reordered */ -) -{ - int K, i, j, ii, b, d; - mod2entry *e; - - K = mod2sparse_rows(U); - - /* Make sure that U is upper-triangular, after column re-ordering. */ - - for (i = 0; i<K; i++) - { ii = cols ? cols[i] : i; - e = mod2sparse_last_in_col(U,ii); - if (!mod2sparse_at_end(e) && mod2sparse_row(e)>i) - { fprintf(stderr, - "mod2sparse_backward_sub: Matrix is not upper-triangular\n"); - exit(1); - } - } - - /* Solve system by backward substitution. */ - - for (i = K-1; i>=0; i--) - { - ii = cols ? cols[i] : i; - - /* Look at bits in this row, forming inner product with partial - solution, and seeing if the diagonal is 1. */ - - d = 0; - b = 0; - - for (e = mod2sparse_first_in_row(U,i); - !mod2sparse_at_end(e); - e = mod2sparse_next_in_row(e)) - { - j = mod2sparse_col(e); - - if (j==ii) - { d = 1; - } - else - { b ^= z[j]; - } - } - - /* Check for no solution if the diagonal isn't 1. */ - - if (!d && b!=y[i]) - { return 0; - } - - /* Set bit of solution, zero if arbitrary. */ - - z[ii] = b^y[i]; - } - - return 1; -} diff --git a/lib/ldpc/mod2sparse.h b/lib/ldpc/mod2sparse.h deleted file mode 100755 index 23d8d79f..00000000 --- a/lib/ldpc/mod2sparse.h +++ /dev/null @@ -1,147 +0,0 @@ -/* MOD2SPARSE.H - Interface to module for handling sparse mod2 matrices. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* This module implements operations on sparse matrices of mod2 elements - (bits, with addition and multiplication being done modulo 2). - - All procedures in this module display an error message on standard - error and terminate the program if passed an invalid argument (indicative - of a programming error), or if memory cannot be allocated. Errors from - invalid contents of a file result in an error code being returned to the - caller, with no message being printed by this module. -*/ - - -/* DATA STRUCTURES USED TO STORE A SPARSE MATRIX. Non-zero entries (ie, 1s) - are represented by nodes that are doubly-linked both by row and by column, - with the headers for these lists being kept in arrays. Nodes are allocated - in blocks to reduce time and space overhead. Freed nodes are kept for - reuse in the same matrix, rather than being freed for other uses, except - that they are all freed when the matrix is cleared to all zeros by the - mod2sparse_clear procedure, or copied into by mod2sparse_copy. - - Direct access to these structures should be avoided except in low-level - routines. Use the macros and procedures defined below instead. */ - -typedef struct mod2entry /* Structure representing a non-zero entry, or - the header for a row or column */ -{ - int row, col; /* Row and column indexes of this entry, starting - at 0, and with -1 for a row or column header */ - - struct mod2entry *left, *right, /* Pointers to entries adjacent in row */ - *up, *down; /* and column, or to headers. Free */ - /* entries are linked by 'left'. */ - - double pr, lr; /* Probability and likelihood ratios - not used */ - /* by the mod2sparse module itself */ -} mod2entry; - -#define Mod2sparse_block 10 /* Number of entries to block together for - memory allocation */ - -typedef struct mod2block /* Block of entries allocated all at once */ -{ - struct mod2block *next; /* Next block that has been allocated */ - - mod2entry entry[Mod2sparse_block]; /* Entries in this block */ - -} mod2block; - -typedef struct /* Representation of a sparse matrix */ -{ - int n_rows; /* Number of rows in the matrix */ - int n_cols; /* Number of columns in the matrix */ - - mod2entry *rows; /* Pointer to array of row headers */ - mod2entry *cols; /* Pointer to array of column headers */ - - mod2block *blocks; /* Blocks that have been allocated */ - mod2entry *next_free; /* Next free entry */ - -} mod2sparse; - - -/* MACROS TO GET AT ELEMENTS OF A SPARSE MATRIX. The 'first', 'last', 'next', - and 'prev' macros traverse the elements in a row or column. Moving past - the first/last element gets one to a header element, which can be identified - using the 'at_end' macro. Macros also exist for finding out the row - and column of an entry, and for finding out the dimensions of a matrix. */ - -#define mod2sparse_first_in_row(m,i) ((m)->rows[i].right) /* Find the first */ -#define mod2sparse_first_in_col(m,j) ((m)->cols[j].down) /* or last entry in */ -#define mod2sparse_last_in_row(m,i) ((m)->rows[i].left) /* a row or column */ -#define mod2sparse_last_in_col(m,j) ((m)->cols[j].up) - -#define mod2sparse_next_in_row(e) ((e)->right) /* Move from one entry to */ -#define mod2sparse_next_in_col(e) ((e)->down) /* another in any of the four */ -#define mod2sparse_prev_in_row(e) ((e)->left) /* possible directions */ -#define mod2sparse_prev_in_col(e) ((e)->up) - -#define mod2sparse_at_end(e) ((e)->row<0) /* See if we've reached the end */ - -#define mod2sparse_row(e) ((e)->row) /* Find out the row or column index */ -#define mod2sparse_col(e) ((e)->col) /* of an entry (indexes start at 0) */ - -#define mod2sparse_rows(m) ((m)->n_rows) /* Get the number of rows or columns*/ -#define mod2sparse_cols(m) ((m)->n_cols) /* in a matrix */ - - -/* POSSIBLE LU DECOMPOSITION STRATEGIES. For use with mod2sparse_decomp. */ - -typedef enum -{ Mod2sparse_first, - Mod2sparse_mincol, - Mod2sparse_minprod -} mod2sparse_strategy; - - -/* PROCEDURES TO MANIPULATE SPARSE MATRICES. */ - -mod2sparse *mod2sparse_allocate (int, int); -void mod2sparse_free (mod2sparse *); - -void mod2sparse_clear (mod2sparse *); -void mod2sparse_copy (mod2sparse *, mod2sparse *); -void mod2sparse_copyrows (mod2sparse *, mod2sparse *, int *); -void mod2sparse_copycols (mod2sparse *, mod2sparse *, int *); - -void mod2sparse_print (FILE *, mod2sparse *); -int mod2sparse_write (FILE *, mod2sparse *); -mod2sparse *mod2sparse_read (FILE *); - -mod2entry *mod2sparse_find (mod2sparse *, int, int); -mod2entry *mod2sparse_insert (mod2sparse *, int, int); -void mod2sparse_delete (mod2sparse *, mod2entry *); - -void mod2sparse_transpose (mod2sparse *, mod2sparse *); -void mod2sparse_add (mod2sparse *, mod2sparse *, mod2sparse *); -void mod2sparse_multiply (mod2sparse *, mod2sparse *, mod2sparse *); -void mod2sparse_mulvec (mod2sparse *, char *, char *); - -int mod2sparse_equal (mod2sparse *, mod2sparse *); - -int mod2sparse_count_row (mod2sparse *, int); -int mod2sparse_count_col (mod2sparse *, int); - -void mod2sparse_add_row (mod2sparse *, int, mod2sparse *, int); -void mod2sparse_add_col (mod2sparse *, int, mod2sparse *, int); - -int mod2sparse_decomp (mod2sparse *, int, mod2sparse *, mod2sparse *, - int *, int *, mod2sparse_strategy, int, int); - -int mod2sparse_forward_sub (mod2sparse *, int *, char *, char *); -int mod2sparse_backward_sub (mod2sparse *, int *, char *, char *); diff --git a/lib/ldpc/mod2sparse.html b/lib/ldpc/mod2sparse.html deleted file mode 100755 index 1681d4a7..00000000 --- a/lib/ldpc/mod2sparse.html +++ /dev/null @@ -1,719 +0,0 @@ -<HTML><HEAD> - -<TITLE> Sparse Modulo-2 Matrix Routines </TITLE> - -</HEAD><BODY> - - -<H1> Sparse Modulo-2 Matrix Routines </H1> - -<P>This module implements operations on matrices in which the elements -are all 0 or 1, with addition and multiplication being done modulo 2. -The matrices are represented by doubly-linked lists of entries -representing the elements in each row and column that are 1s, with -other elements being assumed to be zero. - -<P>This is an appropriate representation when the matrices are sparse -(ie, 0s are much more frequent that 1s). Matrices in which 0s and 1s -are about equally likely may be better handled with the <A -HREF="mod2dense.html">dense modulo-2 matrix routines</A>. Matrices -can be converted between these two formats using the <A -HREF="mod2convert.html">module-2 matrix conversion routines</A>. - -<P>All procedures in this module display an error message on standard -error and terminate the program if passed an invalid argument (indicative -of a programming error), or if memory cannot be allocated. Errors from -invalid contents of a file result in an error code being returned to the -caller, with no message being printed by this module. - - -<A NAME="rep"><H2>Representation of sparse matrices</H2></A> - -<P>This module represents a non-zero element of a matrix (which must have -the value 1, since these are modulo-2 matrices) by a node of type -<TT>mod2entry</TT>, which contains the row and column of the element, -pointers to the next non-zero elements above and below in its column -and to the left and the right in its row, and two double-precision -floating-point numbers called <B>pr</B> and <B>lr</B>, which are -of no significance to this module, but which are used by the routines -for <A HREF="decoding.html#prprp">decoding LDPC codes by probability -propagation</A>. - -<P>The <TT>mod2sparse</TT> type represents a matrix. It records the -number of rows and columns in the matrix, and contains arrays of -pointers to the <TT>mod2entry</TT> structures for the first non-zero -element in each row and the first non-zero element in each column. - -<P>Matrices must be created by the <A -HREF="#allocate"><TT>mod2sparse_allocate</TT></A> procedure, which -returns a pointer to a <TT>mod2sparse</TT> structure. When a matrix -is no longer needed, the space it occupies can be freed with <A -HREF="#free"><TT>mod2sparse_free</TT></A>. Elements within a matrix, -represented by <TT>mod2entry</TT> nodes, are allocated as needed, and -if deleted, they will be reused for new elements within the same -matrix. The space they occupy is not reusable for other matrices or -other purposes until the entire matrix is either freed, with <A -HREF="#free"><TT>mod2sparse_free</TT></A>, or cleared to all zeros, -with <A HREF="#clear"><TT>mod2sparse_clear</TT></A>, or used as -the result matrix for copying or arithmetic operations. - - -<P><B>Header files required</B>: -<TT>mod2sparse.h</TT> - - -<A NAME="dimension-sec"> -<P><HR> -<CENTER><BIG>Dimension Macros</BIG></CENTER> -</A> - -<HR>The following macros take a pointer to a mod2sparse structure as their -argument, and return the number of rows or the number of columns in -the matrix pointed to, which will have been fixed when the matrix was -created with <A HREF="#allocate">mod2sparse_allocate</A>: -<BLOCKQUOTE><PRE> -mod2sparse_rows(m) /* Returns the number of rows in m */ - -mod2sparse_cols(m) /* Returns the number of columns in m */ -</PRE></BLOCKQUOTE> - - -<A NAME="traversal-sec"> -<P><HR> -<CENTER><BIG>Traversal Macros</BIG></CENTER> -</A> - -<HR>The following macros are used to move around a sparse matrix by -following the pointers from one non-zero element to the next or -previous non-zero element in the same row or column. If such a -movement takes one beyond the last or before first entry in a row or -column, or if one tries to find the first or last non-zero entry in a -row or column that has no non-zero entries, the entry returned will be -a special one that can be identified using the -<TT>mod2sparse_at_end</TT> macro. If one is already at this special -entry, moving further wraps one around to the first or last entry. - -<P>The macros for finding the first or last entry in a row or column -take as their arguments a pointer to the matrix (<TT>mod2sparse -*</TT>) and a row or column index, starting at zero. The other macros -take as their arguments a pointer to an entry (<TT>mod2entry *</TT>) -within some matrix. - -<BLOCKQUOTE><PRE> -mod2sparse_first_in_row(m,i) /* Returns the first entry in row i of m */ -mod2sparse_first_in_col(m,j) /* Returns the first entry in column j of m */ - -mod2sparse_last_in_row(m,i) /* Returns the last entry in row i of m */ -mod2sparse_last_in_col(m,j) /* Returns the last entry in column j of m */ - -mod2sparse_next_in_row(e) /* Returns the entry after e in its row */ -mod2sparse_next_in_col(e) /* Returns the entry after e in its column */ - -mod2sparse_prev_in_row(e) /* Returns the entry before e in its row */ -mod2sparse_prev_in_col(e) /* Returns the entry before e in its col */ - -mod2sparse_row(e) /* Returns the row index of entry e */ -mod2sparse_col(e) /* Returns the column index of entry e */ - -mod2sparse_at_end(e) /* Returns 1 if e is a special entry obtained - by moving past the end, returns 0 otherwise */ -</PRE></BLOCKQUOTE> - - -<A NAME="alloc-sec"> -<P><HR> -<CENTER><BIG>Allocating and Freeing Sparse Modulo-2 Matrices</BIG></CENTER> -</A> - - -<A NAME="allocate"><HR><B>mod2sparse_allocate</B>: -Allocate space for a sparse module-2 matrix.</A> - -<BLOCKQUOTE><PRE> -mod2sparse *mod2sparse_allocate -( int n_rows, /* Number of rows in matrix */ - int n_cols /* Number of columns in matrix */ -) -</PRE></BLOCKQUOTE> - -Allocates space for a matrix with the given number of rows and -columns, and returns a pointer to it. The matrix will initially -be all zero. - -<P>If there is not enough memory available, a message is displayed on -standard error and the program is terminated. The matrix should be -freed with <A HREF="#free"><TT>mod2sparse_free</TT></A> once it is no -longer in use. - -<P><A NAME="free"><HR><B>mod2sparse_free</B>: -Free the space occupied by a sparse module-2 matrix.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_free -( mod2sparse *m /* Pointer to matrix to free */ -) -</PRE></BLOCKQUOTE> - -Frees the space occupied by the matrix for re-use. The pointer passed -should not be used afterward. Note that space for the individual matrix -elements (but not the matrix as a whole) is also freed when <A -HREF="#clear"><TT>mod2sparse_clear</TT></A> is called, or the matrix -is used as the destination for other operations. - - -<A NAME="copy-clear-sec"> -<P><HR> -<CENTER><BIG>Copying and Clearing Sparse Modulo-2 Matrices</BIG></CENTER> -</A> - -<A NAME="clear"><HR><B>mod2sparse_clear</B>: -Set all elements of a matrix to zero.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_clear -( mod2sparse *m /* Pointer to matrix to clear */ -) -</PRE></BLOCKQUOTE> - -Sets all of the elements of the matrix passed to 0. The space occupied -by the previous non-zero elements is freed for use in other matrices, or -other purposes. The matrix itself is not freed, however. To do that, -use <A HREF="#free"><TT>mod2sparse_free</TT></A>. - - -<P><A NAME="copy"><HR><B>mod2sparse_copy</B>: -Copy the contents of one matrix to another.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_copy -( mod2sparse *m /* Pointer to matrix to copy from */ - mod2sparse *r /* Pointer to matrix to receive data */ -) -</PRE></BLOCKQUOTE> - -Copies the contents of the first matrix passed, <B>m</B>, to the -second matrix passed, <B>r</B>, which must already have been -allocated, and must have at least as many rows and columns as the -first. If <B>r</B> is larger than <B>m</B>, its elements that have -row or column indexes greater than the dimension of <B>m</B> are set -to zeros. - -<P>The space occupied by the previous non-zero entries of <B>r</B> is -freed for general use (which may include being reused immediately for -the copies of the entries in <B>m</B>). - - -<P><A NAME="copyrows"><HR><B>mod2sparse_copyrows</B>: -Copy selected rows from one matrix to another.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_copyrows -( mod2sparse *m, /* Pointer to matrix to copy rows from */ - mod2sparse *r, /* Pointer to matrix in which to store data */ - int *rows /* Indexes of rows, numbered from 0 */ -) -</PRE></BLOCKQUOTE> - -Copies selected rows of the first matrix, <B>m</B>, to the second -matrix, <B>r</B>, which must already have been allocated, and which -must have at least as many columns as <B>m</B>. The indexes of the -rows to copy are given in order as an array of length the same as -the number of rows in <B>r</B>; duplicates are allowed. Row -indexes start at 0. These rows are copied to <B>r</B>, with the -row indexed by the first entry in <B>rows</B> going to the -first row of <B>r</B>, and so forth. If <B>r</B> has more columns than -<B>m</B>, the extra entries in each row are set to zeros. - -<P>The space occupied by the previous non-zero entries of <B>r</B> is -freed for general use (which may include being reused immediately for -the copies of the entries in <B>m</B>). - - -<P><A NAME="copycols"><HR><B>mod2sparse_copycols</B>: -Copy selected columns from one matrix to another.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_copycols -( mod2sparse *m, /* Pointer to matrix to copy columns from */ - mod2sparse *r, /* Pointer to matrix in which to store data */ - int *cols /* Indexes of columns, numbered from 0 */ -) -</PRE></BLOCKQUOTE> - -Copies selected columns of the first matrix, <B>m</B>, to the second -matrix, <B>r</B>, which must already have been allocated, and which -must have at least as many rows as <B>m</B>. The indexes of the -columns to copy are given in order as an array of length the same as -the number of columns in <B>r</B>; duplicates are allowed. Column -indexes start at 0. These columns are copied to <B>r</B>, with the -column indexed by the first entry in <B>cols</B> going to the -first column of <B>r</B>, and so forth. If <B>r</B> has more rows than -<B>m</B>, the extra entries in each column are set to zeros. - -<P>The space occupied by the previous non-zero entries of <B>r</B> is -freed for general use (which may include being reused immediately for -the copies of the entries in <B>m</B>). - - -<A NAME="input-output-sec"> -<P><HR> -<CENTER><BIG>Input and Output of Sparse Modulo-2 Matrices</BIG></CENTER> -</A> - -<A NAME="print"><HR><B>mod2sparse_print</B>: -Print a sparse modulo-2 matrix in human-readable form.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_print -( FILE *f, /* File to print to */ - mod2sparse *m /* Pointer to matrix to print */ -) -</PRE></BLOCKQUOTE> - -The matrix is printed on standard output with one line of output per row, -of the form -<BLOCKQUOTE><PRE> -<I>row</I>: <I>col col col ...</I> -</PRE></BLOCKQUOTE> -where <I>row</I> is the index of the row, and the <I>col</I> entries are -the indexes of columns that are non-zero in that row. Row and column -indexes start at zero. Rows with no entries are printed with no column -indexes after the colon. The number of columns is not indicated in the output. - -<P><A NAME="write"><HR><B>mod2sparse_write</B>: -Write a sparse modulo-2 matrix to a file in machine-readable format.</A> - -<BLOCKQUOTE><PRE> -int mod2sparse_write -( FILE *f, /* File to write data to */ - mod2sparse *m /* Pointer to matrix write out */ -) -</PRE></BLOCKQUOTE> - -Writes a machine-readable representation the sparse matrix <B>m</B> to -the file <B>f</B>. The file should have been opened in binary mode -(with a "b" in the mode passed to fopen). The contents written will -not be text, and will not be human-readable. Other binary data may -precede or follow the data for the matrix written. - -<P>The data written to the file starts with the number of rows and the -number of columns. Following this are negative integers giving row -indexes (starting at 1), which apply until the next row index, and -positive integers giving column indexes (starting at 1) for a non-zero -entry in the matrix. The data should be readable by <A -HREF="#read"><TT>mod2sparse_read</TT></A> even on a machine with a -different byte-ordering. - -<P>The value returned by <TT>mod2sparse_write</TT> is one if the -operation was successful, zero if an error of some sort occurred. - -<P><A NAME="read"><HR><B>mod2sparse_read</B>: -Read a sparse modulo-2 matrix from a file.</A> - -<BLOCKQUOTE><PRE> -mod2sparse *mod2sparse_read -( FILE *f, /* File to read data from */ -) -</PRE></BLOCKQUOTE> - -Reads a sparse modulo-2 matrix from the file <B>f</B>. This file -should have been opened in binary mode (with a "b" in the mode passed -to fopen). The contents of the file at the point when -<TT>mod2sparse_read</TT> is called should have been written by <A -HREF="#write"><TT>mod2sparse_write</TT></A>. Other binary data may -precede or follow this data. - -<P>The value returned is a pointer to the matrix read, for which space -will have been allocated by <TT>mod2sparse_read</TT>, or zero if an -error occurred (either an error reading the file, or data not in the -right format). - - -<A NAME="elementary-sec"> -<P><HR> -<CENTER><BIG>Elementary Operations on Sparse Modulo-2 Matrices</BIG></CENTER> -</A> - -<A NAME="find"><HR><B>mod2sparse_find</B>: -Look for an entry at a given row and column.</A> - -<BLOCKQUOTE><PRE> -mod2entry *mod2sparse_find -( mod2sparse *m, /* Matrix in which to look for entry */ - int row, /* Row index (from 0) */ - int col /* Column index (from 0) */ -) -</PRE></BLOCKQUOTE> - -Looks for an entry at the given row and column in the matrix <B>m</B>, -representing a non-zero element (ie, one with value 1). Returns a -pointer to this entry if it exists, or zero (a null pointer) if it -does not exist (ie, if that element of the matrix has value 0). - -<P>The search strategy is to first look at the end of the row and the -end of the column. The entry might be found at one of these two -places, or it might be determinable from these end entries that no -entry exists at the given row and column. Otherwise, searches are -done from the start of the row and the start of the column, in -parallel, until an entry with the given row and column are found, or -until it can be determined that such an entry does not exist. -Searching in parallel ensures that the operation will be fast if -either the row is sparse or the column is sparse. - -<P><A NAME="insert"><HR><B>mod2sparse_insert</B>: -Insert an entry at a given row and column.</A> - -<BLOCKQUOTE><PRE> -mod2entry *mod2sparse_insert -( mod2sparse *m, /* Matrix in which to insert an entry */ - int row, /* Row index (from 0) */ - int col /* Column index (from 0) */ -) -</PRE></BLOCKQUOTE> - -Adds a new entry (representing an element with value 1) at the given -row and column position in the matrix <B>m</B>. If such an entry -already exists, nothing is done (this is not considered to be an -error). The new (or existing) entry is returned as the value of -this procedure. - -<P>The search strategy is to first look at the end of the row for an -existing entry or for the place where the new entry belongs. If this -fails, the row is searched from the beginning. If an existing entry -is found, it is returned. Otherwise, a new entry is created, it is -inserted in its correct place in the row, and it is inserted in its -correct place in its column, once again by first looking at the end, -and then if required searching from the beginning. - -<P>The effect of this strategy is that a sparse matrix can be efficiently -created by either adding entries in increasing order by row and column or in -decreasing order by row and column. - -<P><A NAME="delete"><HR><B>mod2sparse_delete</B>: -Delete an entry from a sparse modulo-2 matrix.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_delete -( mod2sparse *m, /* Matrix in which to delete an entry */ - mod2entry *e /* Entry to delete - MUST be in m */ -) -</PRE></BLOCKQUOTE> - -Deletes the entry <B>e</B> from the sparse matrix <B>m</B>, which -effectively sets to zero the element of the matrix that this entry -corresponded to. The entry is freed for future use in the same -matrix, but not (immediately, at least) for use in other matrices, or -generally. The pointer to this entry should not be used again once -it is deleted. - -<P>The time required for this operation does not depend on how many -entries are currently in the matrix. - -<P><B>Warning:</B> It is an error if <B>e</B> is not an entry of -<B>m</B>. This error is not currently diagnosed, but doing this may -cause serious problems, as it may lead later to entries for <B>m</B> -being erroneously freed when the matrix to which <B>e</B> properly -belongs is freed. - -<A NAME="arith-sec"> -<P><HR> -<CENTER><BIG>Sparse Modulo-2 Matrix Arithmetic and Comparison</BIG></CENTER> -</A> - -<A NAME="transpose"><HR><B>mod2sparse_transpose</B>: -Compute the transpose of a sparse modulo-2 matrix.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_transpose -( mod2sparse *m, /* Matrix to compute transpose of */ - mod2sparse *r /* Result of transpose operation */ -) -</PRE></BLOCKQUOTE> - -Stores the transpose of its first argument, <B>m</B>, in the matrix -pointed to by its second argument, <B>r</B>, which must already have -been allocated, and which must have as many rows as <B>m</B> has -columns, and as many columns as <B>m</B> has rows. The two matrices -<B>m</B> and <B>r</B> must not be the same (ie, the two pointers -passed must be different). - -<P>The space occupied by the previous non-zero entries of <B>r</B> is -freed for general use. - -<P><A NAME="add"><HR><B>mod2sparse_add</B>: -Add two sparse modulo-2 matrices.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_add -( mod2sparse *m1, /* Left operand of add */ - mod2sparse *m2, /* Right operand of add */ - mod2sparse *r /* Place to store result of add */ -) -</PRE></BLOCKQUOTE> - -Adds matrices <B>m1</B> and <B>m2</B>, storing the result in the -matrix pointed to by <B>r</B>. All three matrices must have the same -numbers of rows and columns. It is permissible for <B>r</B> to be the -same as <B>m1</B> and/or <B>m2</B>. Neither of the first two matrices is -changed by this procedure (unless they are the same as <B>r</B>). - -<P>The space occupied by the previous non-zero entries of <B>r</B> is -freed for general use. - - -<P><A NAME="multiply"><HR><B>mod2sparse_multiply</B>: -Multiply two sparse modulo-2 matrices.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_multiply -( mod2sparse *m1, /* Left operand of multiply */ - mod2sparse *m2, /* Right operand of multiply */ - mod2sparse *r /* Place to store result of multiply */ -) -</PRE></BLOCKQUOTE> - -Does a matrix multiplication of <B>m1</B> by <B>m2</B>, and stores the -result in the matrix pointed to by <B>r</B>. The matrices must have -compatible numbers of rows and columns. Neither of the first two -matrices is changed by this procedure. The result matrix, <B>r</B>, -must not be the same as either <B>m1</B> or <B>m2</B>. - -<P>The space occupied by the previous non-zero entries of <B>r</B> is -freed for general use. - -<P><A NAME="mulvec"><HR><B>mod2sparse_mulvec</B>: -Multiply a vector by a sparse modulo-2 matrix.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_mulvec -( mod2sparse *m, /* Pointer to matrix to multiply by, M rows, N columns */ - char *u, /* Pointer to unpacked vector to multiply, N long */ - char *v /* Pointer to unpacked result vector, M long */ -) -</PRE></BLOCKQUOTE> - -Multiplies the vector <B>u</B> on the left by the sparse modulo-2 -matrix <B>m</B>, storing the result in <B>v</B>. Both <B>u</B> and -<B>v</B> are modulo-2 vectors, but are stored unpacked, with one bit -per char. Any non-zero value in <B>u</B> is equivalent to '1'. -The vectors <B>u</B> and <B>v</B> must not overlap. - -<P><A NAME="equal"><HR><B>mod2sparse_equal</B>: -Check whether two sparse modulo-2 matrices are equal.</A> - -<BLOCKQUOTE><PRE> -int mod2sparse_equal -( mod2sparse *m1, /* Pointers to the two matrices */ - mod2sparse *m2 /* to compare */ -) -</PRE></BLOCKQUOTE> - -Returns one if every element of <B>m1</B> is equal to the -corresponding element of <B>m2</B>, and otherwise returns zero. The -two matrices must have the same number of rows and the same number of -columns. - - -<A NAME="row-col-ops-sec"> -<P><HR> -<CENTER><BIG>Row/Column Operations on Sparse Modulo-2 Matrices</BIG> -</CENTER></A> - -<A NAME="count_row"><HR><B>mod2sparse_count_row</B>: -Count the number of 1s in a row of a sparse matrix.</A> - -<BLOCKQUOTE><PRE> -int mod2sparse_count_row -( mod2sparse *m, /* Pointer to matrix */ - int row /* Index of row to count (from 0) */ -) -</PRE></BLOCKQUOTE> - -Returns the number of 1s in the given row of the matrix, by counting -the number of entries in that row. - -<P><A NAME="count_col"><HR><B>mod2sparse_count_col</B>: -Count the number of 1s in a column of a sparse matrix.</A> - -<BLOCKQUOTE><PRE> -int mod2sparse_count_col -( mod2sparse *m, /* Pointer to matrix */ - int col /* Index of column to count (from 0) */ -) -</PRE></BLOCKQUOTE> - -Returns the number of 1s in the given column of the matrix, by counting -the number of entries in that column. - -<P><A NAME="add_row"><HR><B>mod2sparse_add_row</B>: -Add a row to a row of a sparse matrix.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_add_row -( mod2sparse *m1, /* Matrix containing row to add to */ - int row1, /* Index in this matrix of row to add to */ - mod2sparse *m2, /* Matrix containing row to add from */ - int row2 /* Index in this matrix of row to add from */ -) -</PRE></BLOCKQUOTE> - -Modifies the row with index <B>row1</B> in the matrix <B>m1</B> by -adding to that row the row with index <B>row2</B> in the matrix -<B>m2</B>. The matrix <B>m1</B> must have at least as many columns as -<B>m2</B>. This operation is performed by inserting entries into the -row of <B>m1</B> at positions where they exist in the row of <B>m2</B> -but not in the row of <B>m1</B>, and deleting entries in the row of -<B>m1</B> that exist in the same position in the row of <B>m2</B>. -The matrix <B>m2</B> is not modified. - -<P><A NAME="add_col"><HR><B>mod2sparse_add_col</B>: -Add a column to a column of a sparse matrix.</A> - -<BLOCKQUOTE><PRE> -void mod2sparse_add_col -( mod2sparse *m1, /* Matrix containing column to add to */ - int col1, /* Index in this matrix of col to add to */ - mod2sparse *m2, /* Matrix containing column to add from */ - int col2 /* Index in this matrix of column to add from */ -) -</PRE></BLOCKQUOTE> - -Modifies the column with index <B>col1</B> in the matrix <B>m1</B> by -adding to that column the column with index <B>col2</B> in the matrix -<B>m2</B>. The matrix <B>m1</B> must have at least as many rows as -<B>m2</B>. This operation is performed by inserting entries into the -column of <B>m1</B> at positions where they exist in the column of -<B>m2</B> but not in the column of <B>m1</B>, and deleting entries in -the column of <B>m1</B> that exist in the same position in the column -of <B>m2</B>. The matrix <B>m2</B> is not modified. - - -<A NAME="lu-decomp-sec"> -<P><HR> -<CENTER><BIG>LU Decomposition of Sparse Modulo-2 Matrices</BIG></CENTER> -</A> - -<A NAME="decomp"><HR><B>mod2sparse_decomp</B>: -Find an LU decomposition of a sparse modulo-2 (sub-)matrix.</A> - -<BLOCKQUOTE><PRE> -int mod2sparse_decomp -( mod2sparse *A, /* Matrix to find LU decomposition within, M by N */ - int K, /* Size of sub-matrix to find LU decomposition of */ - mod2sparse *L, /* Matrix in which L is stored, M by K */ - mod2sparse *U, /* Matrix in which U is stored, K by N */ - int *rows, /* Array where row indexes are stored, M long */ - int *cols, /* Array where column indexes are stored, N long */ - mod2sparse_strategy strategy, /* Strategy to follow in picking rows/columns */ - int abandon_number, /* Number of columns to abandon at some point */ - int abandon_when /* When to abandon these columns */ -) -</PRE></BLOCKQUOTE> - -<P>Takes as input a matrix, <B>A</B>, having <I>M</I> rows and -<I>N</I> columns, and an integer <I>K</I>. Finds an LU decomposition -of a <I>K</I> by <I>K</I> sub-matrix of <B>A</B>. The decomposition -is stored in the matrix <B>L</B>, with <I>M</I> rows and <I>K</I> -columns, and the matrix <B>U</B>, with <I>K</I> rows and <I>N</I> -columns. The product of <B>L</B> and <B>U</B> will be equal to the -<I>K</I> by <I>K</I> submatrix of <B>A</B> obtained by taking only -rows and columns that are given in the first <I>K</I> elements of the -<B>rows</B> and <B>cols</B> arrays, which are set by this procedure, -with this sub-matrix distributed over the original <I>M</I> rows and -<I>N</I> columns. Furthermore, the ordering of the row and column -indexes in these arrays will be set so that if the rows of <B>L</B> -and the columns of <B>U</B> were rearranged in this order, <B>L</B> -would be lower triangular, with zeros in rows past row <I>K</I>, and -<B>U</B> would be upper triangular, with zeros in columns past column -<I>K</I>. The <B>rows</B> array is <I>M</I> long, and the <B>cols</B> -array is <I>N</I> long. The elements in both arrays after the first -<I>K</I> contain the indexes of the rows and columns not selected to -be part of the sub-matrix of <B>A</B>, in arbitrary order. - -<P>The rows and columns of <B>A</B> are selected in order to try to -make the LU decomposition as sparse as possible, using the strategy -identified by the <B>strategy</B>, <B>abandon_number</B>, and -<B>abandon_when</B> parameters. The possible strategies are -<TT>Mod2sparse_first</TT>, <TT>Mod2sparse_mincol</TT>, and -<TT>Mod2sparse_minprod</TT>. If <B>abandon_number</B> is greater than -zero, it is possible that the matrix will appear to have linearly -dependent rows when it actually does not. See the <A -HREF="sparse-LU.html">discussion of sparse LU decomposition -methods</A> for details about these strategies. - -<P>If <B>A</B> is not of rank <I>K</I> or more, <B>L</B> will contain -some number less than <I>K</I> of non-zero columns, and <B>U</B> will -contain an equal number of non-zero rows. The entries in the -<B>rows</B> and <B>cols</B> arrays for the extra zero rows or columns -will be arbitrary (but valid). The number of extra zero columns is -returned as the value of this procedure (hence a return value of zero -indicates that a <I>K</I> by <I>K</I> sub-matrix of full rank was -found). - -<P>The matrix <B>A</B> is not altered. The previous contents of -<B>L</B> and <B>U</B> are cleared. - -<P><A NAME="forward_sub"><HR><B>mod2sparse_forward_sub</B>: -Solve a lower-triangular system by forward substitution.</A> - -<BLOCKQUOTE><PRE> -int mod2sparse_forward_sub -( mod2sparse *L, /* Matrix that is lower triangular after reordering */ - int *rows, /* Array of indexes (from 0) of rows for new order */ - char *x, /* Vector on right of equation, also reordered */ - char *y /* Place to store solution */ -) -</PRE></BLOCKQUOTE> - -<P>Solves the system of equations <B>Ly</B>=<B>x</B> for <B>y</B> by -forward substitution, based on <B>L</B> being lower triangular after -its rows are reordered according to the given index array. The -vectors <B>x</B> and <B>y</B> are stored unpacked, one bit per -character. If <B>L</B> is <I>M</I> by <I>K</I>, then <B>x</B> should -be <I>M</I> long, but only the <I>K</I> bits indexed by <B>rows</B> -are looked at. The solution vector, <B>y</B>, must be <I>K</I> long. -Only <I>K</I> rows of <B>L</B> are used, as also determined by the -<I>K</I> indexes in the <B>rows</B> argument. If <B>rows</B> is null, -the first <I>K</I> rows of <B>L</B> and the first <I>K</I> elements of -<B>x</B> are used. - -<P>If the matrix <B>L</B> does not have 1s on its diagonal (after row -rearrangement), there may be no solution, depending on what <B>x</B> -is. If no solution exists, this procedure returns zero, otherwise it -returns one. Any arbitrary bits in the solution are set to zero. - -<P><A NAME="backward_sub"><HR><B>mod2sparse_backward_sub</B>: -Solve an upper-triangular system by backward substitution.</A> - -<BLOCKQUOTE><PRE> -int mod2sparse_backward_sub -( mod2sparse *U, /* Matrix that is upper triangular after reordering */ - int *cols, /* Array of indexes (from 0) of columns for new order */ - char *y, /* Vector on right of equation */ - char *z /* Place to store solution, also reordered */ -) -</PRE></BLOCKQUOTE> - -<P>Solves <B>Uz</B>=<B>y</B> for <B>z</B> by backward substitution, -based on <B>U</B> being upper triangular after its columns are -reordered according to the given index array. The vectors <B>y</B> -and <B>z</B> are stored unpacked, one bit per character. If <B>U</B> -is <I>K</I> by <I>N</I>, then the solution vector, <I>z</I>, should be -<I>N</I> long, but only the <I>K</I> bits indexed by <B>cols</B> are -set. The vector <B>y</B> must be <I>K</I> long. Only <I>K</I> columns -of <B>U</B> are used, as also determined by the <I>K</I> indexes in -the <B>cols</B> argument. The other columns of <B>U</B> must be zero -(this is not checked, but is necessary for the method used to work). -If <B>cols</B> is null, the first <I>K</I> columns of <B>U</B> and the -first <I>K</I> elements of <B>z</B> are used. - -<P>If the matrix <B>U</B> does not have 1s on its diagonal (after -column rearrangement) there may be no solution, depending on what y -is. If no solution exists, this procedure returns zero, otherwise it -returns one. Any arbitrary bits in the solution are set to zero. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/modify.html b/lib/ldpc/modify.html deleted file mode 100755 index 209b3ea7..00000000 --- a/lib/ldpc/modify.html +++ /dev/null @@ -1,125 +0,0 @@ -<HTML><HEAD> - -<TITLE> Notes on Modifying the LDPC Programs </TITLE> - -</HEAD><BODY> - - -<H1> Notes on Modifying the LDPC Programs </H1> - -<P>Here are a few notes on how to modify the programs to add new types of -channel, new decoding procedures, etc. You should also look at the <A -HREF="modules.html">module documentation</A>. - -<H2> Adding a new type of channel </H2> - -<P>Channels are involved in two programs: -<A HREF="channel.html#transmit"><B>transmit</B></A> and -<A HREF="decoding.html#decode"><B>decode</B></A>. -Adding another type of memoryless channel should be straightforward. -Adding a channel with memory may involve more work. Here are the -steps needed if no major reorganizations are required: -<OL> -<LI> Decide on a syntax for specifying the new channel type and its - parameters, and on an internal name for the channel type. Add - the internal name as a possibility in the enumerated <TT>channel_type</TT> - declared in <A HREF="channel.h"><TT>channel.h</TT></A>. You - may also need to declare new global variables to store parameters of - the channel in <A HREF="channel.h"><TT>channel.h</TT></A> and - <A HREF="channel.c"><TT>channel.c</TT></A>. -<LI> Modify the <TT>channel_parse</TT> and - <TT>channel_usage</TT> procedures in - <A HREF="channel.c"><TT>channel.c</TT></A> to - parse the specification of the new channel and display an appropriate - usage message. -<LI> Decide on how the new channel's output is represented in a file - (eg, for an erasure channel, what the symbol for an erasure is), and - update <A HREF="transmit.c"><TT>transmit.c</TT></A> to write the - new channel's output for each transmitted bit, after randomly generating - any noise (see - the <A HREF="rand.html">documentation on random number generation</A>). -<LI> Modify <A HREF="decode.c"><TT>decode.c</TT></A> in three places to - accommodate the new channel. The three sections of code to modify - allocate space for data from the channel, read data from the channel, - and set likelihood ratios based on the data read. The setting of - likelihood ratios is based on the assumption that the channel is - memoryless (ie, data received for different bits is independent). - Adding a channel with memory would require changing this assumption, - which would involve modifications to the decoding procedures too. -<LI> Document the new channel type in <A HREF="channel.html">channel.html</A> - and <A HREF="decoding.html">decoding.html</A>. -</OL> - -<H2> Adding a new decoding procedure </H2> - -A new decoding method can be implemented as follows: -<OL> -<LI> Decide on a syntax for specifying the method and its parameters, - using the trailing arguments to the - <A HREF="decoding.html#decode"><TT>decode</TT></A> program. Pick an - internal name for the method, and add it as a possibility in the - enumerated <TT>decoding_method</TT> type in - <A HREF="dec.h"><TT>dec.h</TT></A>. You may also need to declare - new variables for the method's parameters in - <A HREF="dec.h"><TT>dec.h</TT></A> and <A HREF="dec.c"><TT>dec.c</TT></A>. -<LI> Modify the argument parsing code in - <A HREF="decode.c"><TT>decode.c</TT></A> - to handle specifications of the new method, and change the <TT>usage</TT> - procedure to display the syntax for specifying the new method. -<LI> Write a setup procedure for your decoding method, putting it in - <A HREF="dec.c"><TT>dec.c</TT></A>, with a declaration in - <A HREF="dec.h"><TT>dec.h</TT></A>. At a minimum, this procedure - should print headers for the table of detailed decoding information - when the <B>-T</B> option was specified. -<LI> Write a decode procedure implementing your method, putting it in - <A HREF="dec.c"><TT>dec.c</TT></A>, with a declaration in - <A HREF="dec.h"><TT>dec.h</TT></A>. This procedure should output - detailed trace information when the <B>-T</B> option was specified. -<LI> Modify <A HREF="decode.c"><TT>decode.c</TT></A> in the appropriate - places to call the setup procedure and the decode procedure you wrote. -<LI> Document the new decoding method in - <A HREF="decoding.html">decoding.html</A> and - <A HREF="decode-detail.html">decode-detail.html</A>. -</OL> - -<H2> Adding a new method of making a low-density parity-check matrix </H2> - -<P>The <A HREF="pchk.html#make-ldpc"><B>make-ldpc</B></A> program can be -changed to add a new method for generating a LDPC code by modifying -<A HREF="make-ldpc.c"><TT>make-ldpc.c</TT></A>. A radically different -method might better be implemented by writing a new program of similar -structure. - - -<H2> Adding a new encoding method </H2> - -<P>A new heuristic for finding a sparse LU decomposition can be -implemented by changing <A HREF="make-gen.c">make-gen.c</A> to allow -the new heuristic to be specified on the command line, changing the <A -HREF="mod2sparse.html#decomp"><B>mod2sparse_decomp</B></A> procedure -in <A HREF="mod2sparse.c"><TT>mod2sparse.c</TT></A> to implement the -heuristic, and documenting the new heuristic in <A -HREF="encoding.html">encoding.html</A>, <A -HREF="sparse-LU.html">sparse-LU.html</A>, and <A -HREF="mod2sparse.html">mod2sparse.html</A>. - -<P>To implement a completely new encoding method, you will first need -to define a new file format for a generator matrix, modify <A -HREF="make-gen.c">make-gen.c</A> appropriately to write out this new -format, and modify the <TT>read_gen</TT> procedure in <A -HREF="rcode.c"><TT>rcode.c</TT></A> to read this format. You will -need to implement the new method in a procedure in <A -HREF="enc.c">enc.c</A>, and modify <A HREF="encode.c">encode.c</A> so -that it will call this new procedure when the new method is used. The -<TT>enum_decode</TT> procedure in <A HREF="dec.c">dec.c</A> will also -need to be modified so it can call the new encoding method. Finally, -you should document the new method in <A -HREF="encoding.html">encoding.html</A> - -<P> - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/modules.html b/lib/ldpc/modules.html deleted file mode 100755 index 93228ffe..00000000 --- a/lib/ldpc/modules.html +++ /dev/null @@ -1,89 +0,0 @@ -<HTML><HEAD> - -<TITLE> Modules Used in LDPC Programs </TITLE> - -</HEAD><BODY> - - -<H1> Modules Used in LDPC Programs </H1> - -You may need to familiarize yourself with the modules documented here -in order to <A HREF="modify.html">modify the LDPC programs</A>. -These modules may also be useful for other purposes. - -<P>Click on the title of a module below for general information, or on -specific routines for detailed documentation. - -<P><A HREF="mod2dense.html">Dense modulo-2 matrix routines</A>: -<BLOCKQUOTE><PRE> -<A HREF="mod2dense.html#dimension-sec"><I>Dimension macros:</I> mod2dense_rows mod2dense_cols</A> - -<I><A HREF="mod2dense.html#alloc-sec">Allocation:</A> <A HREF="mod2dense.html#copy-clear-sec">Copy/Clear:</A> <A HREF="mod2dense.html#input-output-sec">Input/Output:</A> <A HREF="mod2dense.html#elementary-sec">Elementary ops:</A></I> - -<A HREF="mod2dense.html#allocate">mod2dense_allocate</A> <A HREF="mod2dense.html#clear">mod2dense_clear</A> <A HREF="mod2dense.html#print">mod2dense_print</A> <A HREF="mod2dense.html#get">mod2dense_get</A> -<A HREF="mod2dense.html#free">mod2dense_free</A> <A HREF="mod2dense.html#copy">mod2dense_copy</A> <A HREF="mod2dense.html#write">mod2dense_write</A> <A HREF="mod2dense.html#set">mod2dense_set</A> - <A HREF="mod2dense.html#copyrows">mod2dense_copyrows</A> <A HREF="mod2dense.html#read">mod2dense_read</A> <A HREF="mod2dense.html#flip">mod2dense_flip</A> - <A HREF="mod2dense.html#copycols">mod2dense_copycols</A> - -<I><A HREF="mod2dense.html#arith-sec">Matrix arithmetic:</A> <A HREF="mod2dense.html#invert-sec">Matrix inversion:</A></I> - -<A HREF="mod2dense.html#transpose">mod2dense_transpose</A> <A HREF="mod2dense.html#invert">mod2dense_invert</A> -<A HREF="mod2dense.html#add">mod2dense_add</A> <A HREF="mod2dense.html#forcibly_invert">mod2dense_forcibly_invert</A> -<A HREF="mod2dense.html#multiply">mod2dense_multiply</A> <A HREF="mod2dense.html#invert_selected">mod2dense_invert_selected</A> -<A HREF="mod2dense.html#equal">mod2dense_equal</A> -</PRE></BLOCKQUOTE> - -<P><A HREF="mod2sparse.html">Sparse modulo-2 matrix routines</A>: -<BLOCKQUOTE><PRE> -<A HREF="mod2sparse.html#dimension-sec"><I>Dimension macros:</I> mod2sparse_rows mod2sparse_cols</A> - -<A HREF="mod2sparse.html#traversal-sec"><I>Traversal macros:</I> mod2sparse_first_in_row mod2sparse_next_in_row ...</A> - -<I><A HREF="mod2sparse.html#alloc-sec">Allocation:</A> <A HREF="mod2sparse.html#copy-clear-sec">Copy/Clear:</A> <A HREF="mod2sparse.html#input-output-sec">Input/Output:</A> <A HREF="mod2sparse.html#elementary-sec">Elementary ops:</A></I> - -<A HREF="mod2sparse.html#allocate">mod2sparse_allocate</A> <A HREF="mod2sparse.html#clear">mod2sparse_clear</A> <A HREF="mod2sparse.html#print">mod2sparse_print</A> <A HREF="mod2sparse.html#find">mod2sparse_find</A> -<A HREF="mod2sparse.html#free">mod2sparse_free</A> <A HREF="mod2sparse.html#copy">mod2sparse_copy</A> <A HREF="mod2sparse.html#write">mod2sparse_write</A> <A HREF="mod2sparse.html#insert">mod2sparse_insert</A> - <A HREF="mod2sparse.html#copyrows">mod2sparse_copyrows</A> <A HREF="mod2sparse.html#read">mod2sparse_read</A> <A HREF="mod2sparse.html#delete">mod2sparse_delete</A> - <A HREF="mod2sparse.html#copycols">mod2sparse_copycols</A> - -<I><A HREF="mod2sparse.html#arith-sec">Matrix arithmetic:</A> <A HREF="mod2sparse.html#row-col-ops-sec">Row/Column ops:</A> <A HREF="mod2sparse.html#lu-decomp-sec">LU decomposition:</A></I> - -<A HREF="mod2sparse.html#transpose">mod2sparse_transpose</A> <A HREF="mod2sparse.html#count_row">mod2sparse_count_row</A> <A HREF="mod2sparse.html#decomp">mod2sparse_decomp</A> -<A HREF="mod2sparse.html#add">mod2sparse_add</A> <A HREF="mod2sparse.html#count_col">mod2sparse_count_col</A> <A HREF="mod2sparse.html#forward_sub">mod2sparse_forward_sub</A> -<A HREF="mod2sparse.html#multiply">mod2sparse_multiply</A> <A HREF="mod2sparse.html#add_row">mod2sparse_add_row</A> <A HREF="mod2sparse.html#backward_sub">mod2sparse_backward_sub</A> -<A HREF="mod2sparse.html#mulvec">mod2sparse_mulvec</A> <A HREF="mod2sparse.html#add_col">mod2sparse_add_col</A> -<A HREF="mod2sparse.html#equal">mod2sparse_equal</A> -</PRE> -<A HREF="sparse-LU.html">Discussion of sparse LU decomposition methods.</A> -</BLOCKQUOTE> - -<P><A HREF="mod2convert.html">Modulo-2 matrix sparse/dense conversion</A>: -<BLOCKQUOTE><PRE> -<A HREF="mod2convert.html#sparse_to_dense">mod2sparse_to_dense</A> -<A HREF="mod2convert.html#dense_to_sparse">mod2dense_to_sparse</A> -</PRE></BLOCKQUOTE> - -<P><A HREF="rand.html">Random variate generation routines</A>: -<BLOCKQUOTE><PRE> -<I><A HREF="rand.html#get-set-sec">Set/Get state:<A> <A HREF="rand.html#uniform-sec">Uniform:</A> <A HREF="rand.html#discrete-sec">Discrete:</A> <A HREF="rand.html#continuous-sec">Continuous:</A></I> - -<A HREF="rand.html#seed">rand_seed</A> <A HREF="rand.html#uniform">rand_uniform</A> <A HREF="rand.html#int">rand_int</A> <A HREF="rand.html#gaussian">rand_gaussian</A> -<A HREF="rand.html#get_state">rand_get_state</A> <A HREF="rand.html#uniopen">rand_uniopen</A> <A HREF="rand.html#pickd">rand_pickd</A> <A HREF="rand.html#logistic">rand_logistic</A> -<A HREF="rand.html#use_state">rand_use_state</A> <A HREF="rand.html#pickf">rand_pickf</A> <A HREF="rand.html#cauchy">rand_cauchy</A> - <A HREF="rand.html#poisson">rand_poisson</A> <A HREF="rand.html#gamma">rand_gamma</A> - <A HREF="rand.html#permutation">rand_permutation</A> <A HREF="rand.html#exp">rand_exp</A> - <A HREF="rand.html#beta">rand_beta</A> -</PRE></BLOCKQUOTE> - -<P>Each of the modules above has a test program, called -<TT><I>module</I>-test</TT>. These programs are compiled by the command -<BLOCKQUOTE><PRE> -make tests -</PRE></BLOCKQUOTE> -See the source files for these test programs for further information. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/msksim.f90 b/lib/ldpc/msksim.f90 deleted file mode 100644 index 6ef50de5..00000000 --- a/lib/ldpc/msksim.f90 +++ /dev/null @@ -1,76 +0,0 @@ -program msksim - -use, intrinsic :: iso_c_binding - -! To change to a new code, edit the following line and the filenames -! that contain the parity check and generator matrices. -parameter (N=198, M=126, K=72) ! M and N are global variables on the C side. - -character(50) pchk_file,gen_file -integer(1) codeword(1:N), decoded(1:K), message(1:K) -real*8 lratio(N), rxdata(N) - -pchk_file="./jtmode_codes/peg-198-72-irreg-8x3-2x4.pchk" -gen_file="./jtmode_codes/peg-198-72-irreg-8x3-2x4.gen" - -rate=real(K)/real(N) - -call init_ldpc(trim(pchk_file)//char(0),trim(gen_file)//char(0)) - -message(1:K/2)=1 -message((K/2+1):K)=0 -call ldpc_encode(message,codeword) - -max_iterations=50 -ntrials=1000000 - -write(*,*) "Eb/N0 ngood nundetected" -do idb = 0, 11 - db=idb/2.0-0.5 - sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) - - ngood=0 - nue=0 - - do itrial=1, ntrials - - do i=1,N - rxdata(i) = 2.0*(codeword(i)-0.5) + sigma*gran() - enddo - -! correct signal normalization is important for this decoder. - rxav=sum(rxdata)/N - rx2av=sum(rxdata*rxdata)/N - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig - -! s can be tuned to trade a few tenth's dB of threshold -! for an order of magnitude in UER - do i=1,N - s=0.75 - lratio(i)=exp(2.0*rxdata(i)/(s*s)) - enddo - - call ldpc_decode(lratio, decoded, max_iterations, niterations) - - if( niterations .ge. 0 ) then - nueflag=0 - do i=1,K - if( message(i) .ne. decoded(i) ) then - nueflag=1 - endif - enddo - if( nueflag .eq. 1 ) then - nue=nue+1 - else - ngood=ngood+1; - endif - endif - - enddo - - write(*,"(f4.1,1x,i8,1x,i8)") db,ngood,nue - -enddo - -end program msksim diff --git a/lib/ldpc/open.c b/lib/ldpc/open.c deleted file mode 100755 index 8e850681..00000000 --- a/lib/ldpc/open.c +++ /dev/null @@ -1,50 +0,0 @@ -/* OPEN.C - Routine for opening file that might be stdin/stdout. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "open.h" - - -/* OPEN A FILE THAT MIGHT BE STANDARD INPUT OR OUTPUT. If the file name - given is "-", this procedure just returns stdin or stdout, depending on - whether the mode is for reading or writing. Otherwise, fopen is called. -*/ - -FILE *open_file_std -( char *fname, /* Name of file to open, or "-" for stdin/stdout */ - char *mode /* Mode for opening: eg, "r" or "w" */ -) -{ - if (strcmp(fname,"-")==0) - { switch (mode[0]) - { case 'r': - { return stdin; - } - case 'w': - { return stdout; - } - default: - { fprintf(stderr,"Bad mode passed to open_file_std: %s\n",mode); - exit(1); - } - } - } - else - { return fopen(fname,mode); - } -} diff --git a/lib/ldpc/open.h b/lib/ldpc/open.h deleted file mode 100755 index 2cb88b26..00000000 --- a/lib/ldpc/open.h +++ /dev/null @@ -1,16 +0,0 @@ -/* OPEN.H - Interface to routine for opening file that might be stdin/stdout. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -FILE *open_file_std (char *, char *); diff --git a/lib/ldpc/pchk-to-alist.c b/lib/ldpc/pchk-to-alist.c deleted file mode 100755 index 9670105a..00000000 --- a/lib/ldpc/pchk-to-alist.c +++ /dev/null @@ -1,166 +0,0 @@ -/* ALIST-TO-PCHK.C - Convert a parity check matrix to alist format. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "alloc.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" - - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char *alist_file, *pchk_file; - FILE *af, *pf; - int mxrw, mxcw; - int *rw, *cw; - int i, j, k; - mod2entry *e; - int trans; - int nozeros; - int last; - - trans = 0; - nozeros = 0; - - for (;;) - { - if (argc>1 && strcmp(argv[1],"-t")==0) - { trans = 1; - argc -= 1; - argv += 1; - } - else if (argc>1 && strcmp(argv[1],"-z")==0) - { nozeros = 1; - argc -= 1; - argv += 1; - } - else - { break; - } - } - - if (argc!=3) - { usage(); - } - - pchk_file = argv[1]; - alist_file = argv[2]; - - read_pchk(pchk_file); - - if (trans) - { mod2sparse *HT; - HT = H; - H = mod2sparse_allocate(N,M); - mod2sparse_transpose(HT,H); - M = mod2sparse_rows(H); - N = mod2sparse_cols(H); - } - - af = open_file_std(alist_file,"wb"); - - if (af==NULL) - { fprintf(stderr,"Can't create alist file: %s\n",alist_file); - exit(1); - } - - fprintf(af,"%d %d\n",M,N); - - rw = (int *) chk_alloc (M, sizeof *rw); - mxrw = 0; - - for (i = 0; i<M; i++) - { rw[i] = mod2sparse_count_row(H,i); - if (rw[i]>mxrw) - { mxrw = rw[i]; - } - } - - cw = (int *) chk_alloc (N, sizeof *cw); - mxcw = 0; - - for (j = 0; j<N; j++) - { cw[j] = mod2sparse_count_col(H,j); - if (cw[j]>mxcw) - { mxcw = cw[j]; - } - } - - fprintf(af,"%d %d\n",mxrw,mxcw); - - for (i = 0; i<M; i++) - { fprintf(af,"%d%c",rw[i],i==M-1?'\n':' '); - } - - for (j = 0; j<N; j++) - { fprintf(af,"%d%c",cw[j],j==N-1?'\n':' '); - } - - for (i = 0; i<M; i++) - { e = mod2sparse_first_in_row(H,i); - last = 0; - for (k = 0; !last; k++) - { last = nozeros ? k==rw[i]-1 : k==mxrw-1; - fprintf (af, "%d%c", mod2sparse_at_end(e)?0:mod2sparse_col(e)+1, - last?'\n':' '); - if (!mod2sparse_at_end(e)) - { e = mod2sparse_next_in_row(e); - } - } - } - - for (j = 0; j<N; j++) - { e = mod2sparse_first_in_col(H,j); - last = 0; - for (k = 0; !last; k++) - { last = nozeros ? k==cw[j]-1 : k==mxcw-1; - fprintf (af, "%d%c", mod2sparse_at_end(e)?0:mod2sparse_row(e)+1, - last?'\n':' '); - if (!mod2sparse_at_end(e)) - { e = mod2sparse_next_in_col(e); - } - } - } - - if (ferror(af) || fclose(af)!=0) - { fprintf(stderr,"Error writing to alist file %s\n",alist_file); - exit(1); - } - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr,"Usage: pchk-to-alist [ -t ] [ -z ] pchk-file alist-file\n"); - exit(1); -} diff --git a/lib/ldpc/pchk.html b/lib/ldpc/pchk.html deleted file mode 100755 index 5a117726..00000000 --- a/lib/ldpc/pchk.html +++ /dev/null @@ -1,371 +0,0 @@ -<HTML><HEAD> - -<TITLE> Creating a Parity Check Matrix </TITLE> - -</HEAD><BODY> - - -<H1> Creating a Parity Check Matrix </H1> - -<P>This software deals only with linear block codes for binary (ie, -modulo-2, GF(2)) vectors. The set of valid codewords for a linear -code can be specified by giving a <I>parity check matrix</I>, -<B>H</B>, with <I>M</I> rows and <I>N</I> columns. The valid -codewords are the vectors, <B>x</B>, of length <I>N</I>, for which -<B>Hx</B>=<B>0</B>, where all arithmetic is done modulo-2. Each row -of <B>H</B> represents a parity check on a subset of the bits in -<B>x</B>; all these parity checks must be satisfied for <B>x</B> to be -a codeword. Note that the parity check matrix for a given code (ie, -for a given set of valid codewords) is not unique, even after -eliminating rows of <B>H</B> that are redundant because they are -linear combinations of other rows. - -<P>This software stores parity check matrices in files in a sparse -format. These parity-check files are <I>not</I> human-readable -(except by using the <A HREF="#print-pchk"><TT>print-pchk</TT></A> -program). However, they <I>are</I> readable on a machine with a -different architecture than they were written on. - -<P>Some LDPC software by David MacKay and others uses the -<A HREF="http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html">alist -format</A> for parity check matrices. Two programs for converting -between this format and the format for sparse parity check matrices -used by this software are provided. - - -<A NAME="ldpc"><H2>Methods for constructing LDPC codes</H2></A> - -<P>This software is primarily intended for experimentation with Low -Density Parity Check (LDPC) codes. These codes can be constructed by -various methods, which generally involve some random selection of -where to put 1s in a parity check matrix. Any such method for -constructing LDPC codes will have the property that it produces parity -check matrices in which the number of 1s in a column is approximately -the same (perhaps on average) for any size parity check matrix. For a -given code rate, these matrices therefore become increasingly sparse -as the length of a codeword, and hence the number of parity checks, -increases. - -<P>Many methods for constructing LDPC matrices are described in the -<A HREF="refs.html">references</A>. Two simple methods are currently -implemented by this software, both of which operate according to the -following scheme: -<OL> -<LI> Create a preliminary parity check matrix by one of the methods. -<LI> Add 1s to the parity check matrix in order to avoid rows that have no - 1s in them, and hence are redundant, or which have only one 1 in them, - in which case the corresponding codeword bits will always be zero. - The places within such a row to add these 1s are selected randomly. -<LI> If the preliminary parity check matrix constructed in step (1) had - an even number of 1s in each column, add further 1s to avoid the problem - that this will cause the rows to add to zero, and hence at least - one check will be redundant. Up to two 1s are added (since it is also - undesirable for the sum of the rows to have only one 1 in it), at - positions selected randomly from the entire matrix. However, the - number of 1s to add in this step is reduced by the number already added - in step (2). (Note that although redundant checks are not disastrous, - they are better avoided; see the discussion of <A HREF="dep-H.html">linear - dependence in parity check matrices</A>.) -<LI> If requested, try to eliminate - situations where a pair of columns both have 1s in a particular pair of - rows, which correspond to cycles of length four in the factor graph of - the parity check matrix. When such a situation is detected, one of the - 1s involved is moved randomly within its column. This continues until - no such situations remain, or until 10 passes over all columns have - failed to eliminate all such situations. -</OL> - -<P>The <I>evencol</I> method is the simplest way of performing step -(1) of the above procedure. For each column of the parity check -matrix, independently, it places a specified number of 1s in positions -selected uniformly at random, with the only constraint being that -these 1s be in distinct rows. Note that despite the name, the columns -do not have to have the same number of 1s - a distribution over -several values for the number of 1s in a column can be specified -instead. Such codes with different-weight columns are sometimes -better than codes in which every column has the same weight. - -<P>The <I>evenboth</I> method also puts a specified number of 1s in -each column, but it tries as well to keep the numbers of 1s in the -rows approximately the same. Initially, it creates indicators for all -the 1s that will be required, and assigns these 1s to rows as evenly -as it can, favouring earlier rows if an exactly even split is not -possible. It then assigns 1s to successive columns by selecting -randomly, without replacement, from this initial supply of 1s, subject -only to the constraint that the 1s assigned to a column must be in -distinct rows. If at some point it is impossible to put the required -number of 1s in a column by picking from the 1s remaining, a 1 is set -in that column without reference to other columns, creating a possible -unevenness. - -<P>Note that regardless of how evenly 1s are distributed in the -preliminary parity check matrix created in step (1), steps (2) and (3) -can make the numbers of 1s in the both rows and columns be uneven, and -step (4), if done, can make the numbers of 1s in rows be uneven. - - -<P><A NAME="make-pchk"><HR><B>make-pchk</B>: Make a parity check -matrix by explicit specification. - -<BLOCKQUOTE><PRE> -make-pchk <I>pchk-file n-checks n-bits row</I>:<I>col ...</I> -</PRE></BLOCKQUOTE> - -<P>Creates a file named <TT><I>pchk-file</I></TT> in -which it stores a parity check matrix with <TT><I>n-checks</I></TT> -rows and <TT><I>n-bits</I></TT> columns. This parity check matrix -consists of all 0s except for 1s at the <I>row</I>:<I>col</I> -positions listed. Rows and columns are numbered starting at zero. -This program is intended primarily for testing and demonstration -purposes. - -<P><B>Example:</B> The well-known Hamming code with codewords of -length <I>N</I>=7 and with <I>M</I>=3 parity checks can be can be -created as follows: -<UL><PRE> -<LI>make-pchk ham7.pchk 3 7 0:0 0:3 0:4 0:5 1:1 1:3 1:4 1:6 2:2 2:4 2:5 2:6 -</PRE></UL> - - -<P><A NAME="alist-to-pchk"><HR><B>alist-to-pchk</B>: Convert a parity -check matrix from alist format to the sparse matrix format used by -this software. - -<BLOCKQUOTE><PRE> -alist-to-pchk [ -t ] <I>alist-file pchk-file</I> -</PRE></BLOCKQUOTE> - -<P>Converts a parity check matrix in -<A HREF="http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html">alist -format</A> stored in the file named <TT><I>alist-file</I></TT> to -the sparse matrix format used by this software, storing it in the -file named <TT><I>pchk-file</I></TT>. - -<P>If the <B>-t</B> option is given, the transpose of the parity check -matrix in <TT><I>alist-file</I></TT> is stored in the -<TT><I>pchk-file</I></TT>. - -<P>Any zeros indexes in the alist file are ignored, so that alist files -with zero padding (as required in the specification) are accepted, -but files without this zero padding are also accepted. Newlines -are ignored by <TT>alist-to-pchk</TT>, so no error is reported if -the set of indexes in a row or column description are not those -on a single line. - - -<P><A NAME="pchk-to-alist"><HR><B>pchk-to-alist</B>: Convert a parity -check matrix to alist format. - -<BLOCKQUOTE><PRE> -pchk-to-alist [ -t ] [ -z ] <I>pchk-file alist-file</I> -</PRE></BLOCKQUOTE> - -<P>Converts a parity check matrix stored in the sparse matrix format -used by this software, in the file named <TT><I>pchk-file</I></TT>, to -the <A -HREF="http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html">alist -format</A>, storing it in the file named <TT><I>alist-file</I></TT>. - -<P>If the <B>-t</B> option is given, the transpose of the parity check -matrix is converted to alist format. - -<P>If the number of 1s is not -the same for each row or each column, the alist format specification -says that the list of indexes of 1s for each row or column should -be padded with zeros to the maximum number of indexes. By default, -<TT>pchk-to-alist</TT> does this, but output of these 0s can be -suppressed by specifying the <B>-z</B> option. (The <TT>alist-to-pchk</TT> -program will accept alist files produced with or without the <B>-z</B> -option.) - - -<P><A NAME="print-pchk"><HR><B>print-pchk</B>: Print a parity check matrix. - -<BLOCKQUOTE><PRE> -print-pchk [ -d ] [ -t ] <I>pchk-file</I> -</PRE></BLOCKQUOTE> - -<P>Prints a human-readable representation of the parity check matrix stored -in <TT><I>pchk-file</I></TT>. -The <B>-d</B> option causes the matrix to be printed in a dense -format, even though parity check matrices are always stored in the -file in a sparse format. If the <B>-t</B> option is present, what is -printed is the transpose of the parity check matrix. - -<P>The sparse display format consists of one line for every row of the -matrix, consisting of the row number, a colon, and the column numbers -at which 1s are located (possibly none). Row and columns numbers -start at zero. No attempt is made to wrap long lines. - -<P>The dense display is the obvious array of 0s and 1s. Long lines -are not wrapped. - -<P><B>Example</B>: The parity check matrix for the Hamming code created -by the example for <A HREF="#make-pchk"><TT>make-pchk</TT></A> would print -as follows: -<UL><PRE> -<LI>print-pchk ham7.pchk - -Parity check matrix in ham7.pchk (sparse format): - -0: 0 3 4 5 -1: 1 3 4 6 -2: 2 4 5 6 - -<LI>print-pchk -d ham7.pchk - -Parity check matrix in ham7.pchk (dense format): - - 1 0 0 1 1 1 0 - 0 1 0 1 1 0 1 - 0 0 1 0 1 1 1 -</PRE></UL> - - -<P><A NAME="make-ldpc"><HR><B>make-ldpc</B>: Make a low density parity -check matrix, by random generation. - -<BLOCKQUOTE><PRE> -make-ldpc <I>pchk-file n-checks n-bits seed method</I> -</PRE> -<BLOCKQUOTE> -where <TT><I>method</I></TT> is one of the following: -<BLOCKQUOTE><PRE> -evencol <I>checks-per-col</I> [ no4cycle ] - -evencol <I>checks-distribution</I> [ no4cycle ] - -evenboth <I>checks-per-col</I> [ no4cycle ] - -evenboth <I>checks-distribution</I> [ no4cycle ] -</PRE></BLOCKQUOTE> -</BLOCKQUOTE> -</BLOCKQUOTE> - -<P>Creates a Low Density Parity Check matrix with -<TT><I>n-checks</I></TT> rows and <TT><I>n-bits</I></TT> columns. The -parity check matrix will be generated pseudo-randomly by the indicated -method, using a pseudo-random number stream determined by <TT><I>seed</I></TT>. -The actual random number seed used is 10 times <TT><I>seed</I></TT> plus 1, -so as to avoid using the same stream as any of the other programs. - -<P>Two methods are currently available for creating the LDPC matrix, -specified by <TT>evencol</TT> or <TT>evenboth</TT>. Both methods -produce a matrix in which the number of 1s in each column is -approximately <TT><I>checks-per-col</I></TT>, or varies from column -to column according the the <TT><I>checks-distribution</I></TT>. -The <TT>evenboth</TT> method also tries to make the number of checks per row be -approximately uniform; if this is not achieved, a message saying that -how many bits were placed unevenly is displayed on standard error. - -<P>For both methods, the <TT>no4cycle</TT> option will cause cycles of -length four in the factor graph representation of the code to be -eliminated (if possible). A message is displayed on standard error if -this is not achieved. - -<P>A <TT><I>checks-distribution</I></TT> has the form -<BLOCKQUOTE><PRE> -<I>prop</I>x<I>count</I>/<I>prop</I>x<I>count</I>/... -</PRE></BLOCKQUOTE> -Here, <TT><I>prop</I></TT> is a proportion of columns that have the -associated <TT><I>count</I></TT>. The proportions need not sum to one, -since they will be automatically normalized. For example, <TT>0.3x4/0.2x5</TT> -specifies that 60% of the columns will contain four 1s and 40% will -contain five 1s. - -<P>See the <A HREF="#ldpc">discussion above</A> for more details -on how these methods construct LDPC matrices. - -<P><B>Example 1:</B> The <TT>make-ldpc</TT> command below creates -a 20 by 40 low density parity check matrix with three 1s per -column and six 1s per row, using random seed 1. The matrix -is then printed in sparse format -using <A HREF="#print-pchk">print-pchk</A>. -<UL><PRE> -<LI>make-ldpc ldpc.pchk 20 40 1 evenboth 3 -<LI>print-pchk ldpc.pchk - -Parity check matrix in ldpc.pchk (sparse format): - - 0: 10 14 18 27 38 39 - 1: 2 3 5 11 27 30 - 2: 15 19 20 21 24 26 - 3: 2 4 25 28 32 38 - 4: 7 9 12 22 33 34 - 5: 5 6 21 22 26 32 - 6: 1 4 13 24 25 28 - 7: 1 14 28 29 30 36 - 8: 11 13 22 23 32 37 - 9: 6 8 13 20 31 33 -10: 0 3 24 29 31 38 -11: 7 12 15 16 17 23 -12: 3 16 29 34 35 39 -13: 0 8 10 18 36 37 -14: 6 11 18 20 35 39 -15: 0 7 14 16 25 37 -16: 2 4 9 19 30 31 -17: 5 9 10 17 19 23 -18: 8 15 17 21 26 27 -19: 1 12 33 34 35 36 -</PRE></UL> - -<P><B>Example 2:</B> The two <TT>make-ldpc</TT> commands -below both create a 20 by 40 low density parity check matrix with 30% -of columns with two 1s, 60% of columns with three 1s, and 10% of -columns with seven 1s. The transpose of the parity check matrix -is then printed in sparse format. -<UL><PRE> -<LI>make-ldpc ldpc.pchk 20 40 1 evenboth 0.3x2/0.6x3/0.1x7 -<LI>make-ldpc ldpc.pchk 20 40 1 evenboth 3x2/6x3/1x7 -<LI>print-pchk -t ldpc.pchk - -Transpose of parity check matrix in ldpc.pchk (sparse format): - - 0: 13 16 - 1: 9 18 - 2: 1 10 - 3: 3 15 - 4: 4 14 - 5: 14 17 - 6: 4 5 - 7: 1 8 - 8: 0 4 - 9: 9 14 -10: 5 8 -11: 6 16 -12: 2 12 19 -13: 3 17 18 -14: 2 16 17 -15: 2 11 18 -16: 12 13 19 -17: 7 13 18 -18: 2 5 11 -19: 10 12 14 -20: 1 8 16 -21: 10 18 19 -22: 3 6 17 -23: 7 11 12 -24: 1 2 19 -25: 0 6 7 -26: 5 8 15 -27: 1 4 7 -28: 6 13 19 -29: 3 4 11 -30: 3 8 17 -31: 4 5 9 -32: 0 10 15 -33: 7 11 13 -34: 8 12 19 -35: 0 2 10 -36: 0 5 9 11 15 17 18 -37: 0 1 2 6 7 14 16 -38: 0 1 3 9 12 13 15 -39: 3 6 9 10 14 15 16 -</PRE></UL> - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> - diff --git a/lib/ldpc/peg/128-64-reg4.deg b/lib/ldpc/peg/128-64-reg4.deg deleted file mode 100644 index 7b72d067..00000000 --- a/lib/ldpc/peg/128-64-reg4.deg +++ /dev/null @@ -1,4 +0,0 @@ -1 -4 -1.0 - diff --git a/lib/ldpc/peg/BigGirth.C b/lib/ldpc/peg/BigGirth.C deleted file mode 100644 index ad8b54a1..00000000 --- a/lib/ldpc/peg/BigGirth.C +++ /dev/null @@ -1,573 +0,0 @@ -#include <cstdio> -#include <cstdlib> -#include <iostream> -#include <fstream> -#include "BigGirth.h" -#include "Random.h" - -using namespace std; - -NodesInGraph::NodesInGraph(void) { - connectionParityBit=NULL; - connectionSymbolBit=NULL; -} - -void NodesInGraph::setNumOfConnectionSymbolBit(int deg) { - if(deg<=0) {cout<<"Wrong NodesInGraph::setNumOfConnectionSymbolBit()"<<endl;exit(-1);} - numOfConnectionSymbolBit=deg; - connectionSymbolBit=new int[deg]; -} -void NodesInGraph::initConnectionParityBit(void) { - maxDegParity=10000; - numOfConnectionParityBit=0; - connectionParityBit=new int[1];//dummy memory, actually not used -} -void NodesInGraph::initConnectionParityBit(int deg) { - maxDegParity=deg; - numOfConnectionParityBit=0; - connectionParityBit=new int[1];//dummy memory, actually not used -} -NodesInGraph::~NodesInGraph(void) { - delete [] connectionParityBit; - delete [] connectionSymbolBit; -} - -BigGirth::BigGirth(void) : H(NULL), verbose(true) { } - -BigGirth::BigGirth(int M, int N, int *symbolDegSequence, const char *filename, int sglConcent, int tgtGirth, bool verbose_) : H(NULL), verbose(verbose_) { - int i, j, k, m, index, localDepth=100; - int *mid; - - EXPAND_DEPTH=(tgtGirth-4)/2; - if(EXPAND_DEPTH<0) EXPAND_DEPTH=0; - - // corresponds to depth l in the PEG paper; - // the target girth = 2*EXPAND_DEPTH+4 - // if set large, then GREEDY algorithm - - myrandom=new Random(); //(12345678l, 987654321lu); - - this->M=M; - this->N=N; - this->filename=filename; - - mid=new int[M]; - - localGirth=new int[N]; - - nodesInGraph=new NodesInGraph [N]; - for(i=0;i<N;i++) - nodesInGraph[i].setNumOfConnectionSymbolBit(symbolDegSequence[i]); - - j=0; - for(k=0;k<N;k++) j+=symbolDegSequence[k]; - k=j/M; - for(i=0;i<M;i++) mid[i]=k; - for(i=0;i<j-k*M;i++) mid[i]++; - k=0; for(i=0;i<M;i++) k+=mid[i]; - if(k!=j) {cout<<"Wrong in computing maxDegParity!"<<endl;exit(-1);} - - for(i=0;i<M;i++) { - if(sglConcent==0) nodesInGraph[i].initConnectionParityBit(mid[i]); - else nodesInGraph[i].initConnectionParityBit(); - } - - for(k=0;k<N;k++){ - m=1000000;index=-1; - for(i=0;i<M;i++){ - if(nodesInGraph[i].numOfConnectionParityBit<m && nodesInGraph[i].numOfConnectionParityBit<nodesInGraph[i].maxDegParity) { - m=nodesInGraph[i].numOfConnectionParityBit; - index=i; - } - } - nodesInGraph[k].connectionSymbolBit[0]=index;//least connections of parity bit - - int iter=0; - ITER: - localGirth[k]=100; - for(m=1;m<nodesInGraph[k].numOfConnectionSymbolBit;m++){ - nodesInGraph[k].connectionSymbolBit[m]=selectParityConnect(k, m, localDepth); - localGirth[k]=(localGirth[k]>localDepth)?localDepth:localGirth[k]; - if(k>0 && localGirth[k]<localGirth[k-1] && iter<20) {iter++; goto ITER;} - if(localGirth[k]==0 && iter<30) {iter++; goto ITER;} - } - //if((k+1)%100==0) { - if(verbose) { - cout<<"k="<<k<<" "; - for(m=0;m<nodesInGraph[k].numOfConnectionSymbolBit;m++) - cout<<nodesInGraph[k].connectionSymbolBit[m]<<" "; - cout<<"LocalGirth="<<2*localGirth[k]+4; - cout<<endl; - } - updateConnection(k); - } - - if(verbose) { - cout<<"Showing the row weight distribution..."<<endl; - for(i=0;i<M;i++) - cout<<nodesInGraph[i].numOfConnectionParityBit<<" "; - cout<<endl; - } - delete [] mid; - - ofstream cycleFile; - cycleFile.open("leftHandGirth.log", ios::out); - localDepth=100; - for(k=0;k<N;k++) { - if(localGirth[k]<localDepth) localDepth=localGirth[k]; - if(localDepth==100) cycleFile<<"inf "; - else cycleFile<<2*localDepth+4<<" "; - } - cycleFile<<endl; - cycleFile.close(); - - if(verbose) { - cout<<"*************************************************************"<<endl; - cout<<" The global girth of the PEG Tanner graph :="<< 2*localDepth+4<<endl; - cout<<"*************************************************************"<<endl; - } - - loadH(); - -} - -BigGirth::~BigGirth(void) { - if(H!=NULL) { - for(int i=0;i<M;i++) - delete [] H[i]; - delete [] H; - H=NULL; - } - delete [] localGirth; - delete [] nodesInGraph; - nodesInGraph=NULL; - delete myrandom; -} - -int BigGirth::selectParityConnect(int kthSymbol, int mthConnection, int & cycle) { - int i, j, k, index, mincycles, numCur, cpNumCur; - int *tmp, *med; - int *current;//take note of the covering parity bits - - mincycles=0; - tmp=new int[M]; med=new int[M]; - - numCur=mthConnection; - current=new int[mthConnection]; - for(i=0;i<mthConnection;i++) current[i]=nodesInGraph[kthSymbol].connectionSymbolBit[i]; - -LOOP: - mincycles++; - for(i=0;i<M;i++) tmp[i]=0; - //maintain - for(i=0;i<mthConnection;i++) tmp[nodesInGraph[kthSymbol].connectionSymbolBit[i]]=1; - for(i=0;i<numCur;i++){ - for(j=0;j<nodesInGraph[current[i]].numOfConnectionParityBit;j++){ - for(k=0;k<nodesInGraph[nodesInGraph[current[i]].connectionParityBit[j]].numOfConnectionSymbolBit;k++){ - tmp[nodesInGraph[nodesInGraph[current[i]].connectionParityBit[j]].connectionSymbolBit[k]]=1; - } - } - } - - index=0; cpNumCur=0; - for(i=0;i<M;i++) { - if(tmp[i]==1) cpNumCur++; - if(tmp[i]==1 || nodesInGraph[i].numOfConnectionParityBit>=nodesInGraph[i].maxDegParity) - index++; - } - if(cpNumCur==numCur) {//can not expand any more - //additional handlement to select one having least connections - j=10000000; //dummy number - for(i=0;i<M;i++){ - if(tmp[i]==0 && nodesInGraph[i].numOfConnectionParityBit<j && nodesInGraph[i].numOfConnectionParityBit<nodesInGraph[i].maxDegParity) - j=nodesInGraph[i].numOfConnectionParityBit; - } - for(i=0;i<M;i++){ - if(tmp[i]==0){ - if(nodesInGraph[i].numOfConnectionParityBit!=j || nodesInGraph[i].numOfConnectionParityBit>=nodesInGraph[i].maxDegParity){ - tmp[i]=1; - } - } - } - index=0; - for(i=0;i<M;i++) if(tmp[i]==1) index++; - //---------------------------------------------------------------- - j=(*myrandom).uniform(0, M-index)+1; //randomly selected - index=0; - for(i=0;i<M;i++){ - if(tmp[i]==0) index++; - if(index==j) break; - } - delete [] tmp; tmp=NULL; - delete [] current; current=NULL; - return(i); - } - else if(index==M || mincycles>EXPAND_DEPTH){//covering all parity nodes or meet the upper bound on cycles - - cycle=mincycles-1; - for(i=0;i<M;i++) tmp[i]=0; - for(i=0;i<numCur;i++) tmp[current[i]]=1; - index=0; - for(i=0;i<M;i++) if(tmp[i]==1) index++; - if(index!=numCur) {cout<<"Error in the case of (index==M)"<<endl;exit(-1);} - //additional handlement to select one having least connections - j=10000000; - for(i=0;i<M;i++){ - if(tmp[i]==0 && nodesInGraph[i].numOfConnectionParityBit<j && nodesInGraph[i].numOfConnectionParityBit<nodesInGraph[i].maxDegParity) - j=nodesInGraph[i].numOfConnectionParityBit; - } - for(i=0;i<M;i++){ - if(tmp[i]==0){ - if(nodesInGraph[i].numOfConnectionParityBit!=j || nodesInGraph[i].numOfConnectionParityBit>=nodesInGraph[i].maxDegParity){ - tmp[i]=1; - } - } - } - - index=0; - for(i=0;i<M;i++) if(tmp[i]==1) index++; - - j=(*myrandom).uniform(0, M-index)+1; - index=0; - for(i=0;i<M;i++){ - if(tmp[i]==0) index++; - if(index==j) break; - } - delete [] tmp; tmp=NULL; - delete [] current; current=NULL; - return(i); - } - else if(cpNumCur>numCur && index!=M){ - delete [] current; - current=NULL; - numCur=cpNumCur; - current=new int[numCur]; - index=0; - for(i=0;i<M;i++) { - if(tmp[i]==1) {current[index]=i; index++;} - } - goto LOOP; - } - else { - cout<<"Should not come to this point..."<<endl; - cout<<"Error in BigGirth::selectParityConnect()"<<endl; - return(-1); - } -} - - -void BigGirth::updateConnection(int kthSymbol){ - int i, j, m; - int *tmp; - - for(i=0;i<nodesInGraph[kthSymbol].numOfConnectionSymbolBit;i++){ - m=nodesInGraph[kthSymbol].connectionSymbolBit[i];//m [0, M) parity node - tmp=new int[nodesInGraph[m].numOfConnectionParityBit+1]; - for(j=0;j<nodesInGraph[m].numOfConnectionParityBit;j++) - tmp[j]=nodesInGraph[m].connectionParityBit[j]; - tmp[nodesInGraph[m].numOfConnectionParityBit]=kthSymbol; - - delete [] nodesInGraph[m].connectionParityBit; - nodesInGraph[m].connectionParityBit=NULL; - nodesInGraph[m].numOfConnectionParityBit++; //increase by 1 - nodesInGraph[m].connectionParityBit=new int[nodesInGraph[m].numOfConnectionParityBit]; - for(j=0;j<nodesInGraph[m].numOfConnectionParityBit;j++) - nodesInGraph[m].connectionParityBit[j]=tmp[j]; - delete [] tmp; - tmp=NULL; - } -} - -void BigGirth::loadH(void){ - int i, j; - if(H==NULL) { - H=new int*[M]; - for(i=0;i<M;i++) H[i]=new int[N]; - } - - for(i=0;i<M;i++){ - for(j=0;j<N;j++){ - H[i][j]=0; - } - } - for(i=0;i<M;i++){ - for(j=0;j<nodesInGraph[i].numOfConnectionParityBit;j++){ - H[i][nodesInGraph[i].connectionParityBit[j]]=1; - } - } -} - -void BigGirth::writeToFile_Hmatrix(void){ - int i, j; - - loadH(); - - //cout<<"---------------code format--------------------------"<<endl; - //cout<<"- Block length N -"<<endl; - //cout<<"- Num of Check Nodex M -"<<endl; - //cout<<"- H matrix -"<<endl; - //cout<<"----------------------------------------------------"<<endl; - - ofstream codefile; - codefile.open(filename,ios::out); - codefile<<N<<" "<<M<<endl; - - for(i=0;i<M;i++){ - for(j=0;j<N;j++){ - codefile<<H[i][j]<<" "; - } - codefile<<endl; - } - codefile.close(); -} - -void BigGirth::writeToFile_Hcompressed(void){ - int i, j, max_col; - int *(*parityCheck_compressed); - - //cout<<"---------------code format--------------------------"<<endl; - //cout<<"- Block length N -"<<endl; - //cout<<"- Num of Check Nodex M -"<<endl; - //cout<<"- Num of column in the compressed H -"<<endl; - //cout<<"- H matrix (compressed) -"<<endl; - //cout<<"----------------------------------------------------"<<endl; - - //finding the num of columns, l, of the compressed parity-check matrix - - max_col=0; - for(i=0;i<M;i++) - if(nodesInGraph[i].numOfConnectionParityBit>max_col) - max_col=nodesInGraph[i].numOfConnectionParityBit; - - parityCheck_compressed=new int * [M]; - for(i=0;i<M;i++) - parityCheck_compressed[i]=new int[max_col]; - for(i=0;i<M;i++){ - for(j=0;j<max_col;j++) parityCheck_compressed[i][j]=0; - for(j=0;j<nodesInGraph[i].numOfConnectionParityBit;j++){ - parityCheck_compressed[i][j]=nodesInGraph[i].connectionParityBit[j]+1; - } - } - - ofstream codefile; - codefile.open(filename,ios::out); - codefile<<N<<endl; - codefile<<M<<endl; - codefile<<max_col<<endl; - for(i=0;i<M;i++){ - for(j=0;j<max_col;j++) - codefile<<parityCheck_compressed[i][j]<<" "; - codefile<<endl; - } - codefile.close(); - - for(i=0;i<M;i++){ - delete [] parityCheck_compressed[i]; - parityCheck_compressed[i]=NULL; - } - delete [] parityCheck_compressed; - parityCheck_compressed=NULL; -} - -void BigGirth::writeToFile(void){ - int i, j, k, d, redun; - int imed, max_row, index, max_col; - int *Index, *J, *itmp, *(*generator), *(*generator_compressed), *(*parityCheck_compressed); - //Gaussian Ellimination - Index=new int[M]; - J=new int[N]; - itmp=new int[N]; - for(i=0;i<M;i++) Index[i]=0; //indicator of redudant rows - for(j=0;j<N;j++) J[j]=j; //column permutation - redun=0;//the number of redundant rows - - loadH(); - - for(k=0;k<M;k++){ - if(H[k][J[k-redun]]==0) { - d=k; - for(i=k+1-redun;i<N;i++) - if(H[k][J[i]]!=0) {d=i;break;} - if(d==k) {//full-zero row:delete this row - redun++; - Index[k]=1; - continue; - } - else {//SWAP d column and k column in H matrix - imed=J[k-redun]; - J[k-redun]=J[d]; - J[d]=imed; - } - } - if(H[k][J[k-redun]]==0) { - cout<<"ERROR: should not come to this point"<<endl; - exit(-1); - } - else { - for(i=k+1;i<M;i++){ - if(H[i][J[k-redun]]!=0){ - for(j=k-redun;j<N;j++) - H[i][J[j]]=(H[i][J[j]]+H[k][J[j]])%2; - } - } - } - } - - if(verbose) - cout<<"Row rank of parity check matrix="<<M-redun<<endl; - - K=N-M+redun;//num of the information bits - - index=0; - for(i=0;i<M;i++){ - if(Index[i]==0){ // all-zero row - for(j=0;j<N;j++) - itmp[j]=H[i][J[j]]; - for(j=0;j<N;j++) - H[index][j]=itmp[j]; //Note: itmp can not be omitted here!!! - index++; - } - } - if(index!=M-redun) {cout<<"ERROR...if(index!=M-redun)"<<endl;exit(-1);} - - for(k=index-1;k>0;k--){ - for(i=k-1;i>=0;i--){ - if(H[i][k]==1) - for(j=k;j<N;j++) - H[i][j]=(H[i][j]+H[k][j])%2; - } - } - - if(verbose) { - cout<<"****************************************************"<<endl; - cout<<" Computing the compressed generator"<<endl; - cout<<"****************************************************"<<endl; - } - generator=new int * [K]; - for(i=0;i<K;i++) - generator[i]=new int[N-K]; - for(i=0;i<K;i++){ - for(j=0;j<N-K;j++) - generator[i][j]=H[j][i+N-K]; - //for(j=N-K;j<N;j++) - //generator[i][j]=0; - //generator[i][i+N-K]=1; - } - max_row=0; - for(j=0;j<N-K;j++){ - imed=0; - for(i=0;i<K;i++) - imed+=generator[i][j]; - if(imed>max_row) max_row=imed; - } - generator_compressed=new int * [max_row]; - for(i=0;i<max_row;i++) - generator_compressed[i]=new int[N]; - for(j=0;j<N-K;j++){ - index=0; - for(i=0;i<max_row;i++) generator_compressed[i][j]=0; - for(i=0;i<K;i++){ - if(generator[i][j]==1) { - generator_compressed[index][j]=i+1; - if(index>=max_row-1) break; - index++; - } - } - } - for(j=0;j<K;j++){ - for(i=0;i<max_row;i++) generator_compressed[i][j+N-K]=0; - generator_compressed[0][j+N-K]=j+1; - } - if(verbose) { - cout<<"*****************************************************"<<endl; - cout<<" Computing the compressed parity-check matrix"<<endl; - cout<<"*****************************************************"<<endl; - } - //finding the num of columns, l, of the compressed parity-check matrix - loadH(); //loading parity check matrix again - max_col=0; - for(i=0;i<M;i++){ - imed=0; - for(j=0;j<N;j++) - imed+=H[i][j]; - if(imed>max_col) max_col=imed; - } - parityCheck_compressed=new int * [M]; - for(i=0;i<M;i++) - parityCheck_compressed[i]=new int[max_col]; - for(i=0;i<M;i++){ - for(j=0;j<max_col;j++) parityCheck_compressed[i][j]=0; - index=0; - for(j=0;j<N;j++){ - if(H[i][J[j]]==1) { - parityCheck_compressed[i][index]=j+1; - if(index>=max_col-1) break; - index++; - } - } - } - if(verbose) { - cout<<"****************************************************"<<endl; - cout<<" Write to file (TEXT!) "<<endl; - cout<<"****************************************************"<<endl; - } - ofstream codefile; - codefile.open(filename,ios::out); - codefile<<N<<endl; - codefile<<K<<endl; - codefile<<M<<endl; - codefile<<max_row<<endl; - codefile<<max_col<<endl; - for(i=0;i<max_row;i++){ - for(j=0;j<N;j++) - codefile<<generator_compressed[i][j]<<" "; - codefile<<endl; - } - for(i=0;i<M;i++){ - for(j=0;j<max_col;j++) - codefile<<parityCheck_compressed[i][j]<<" "; - codefile<<endl; - } - for(i=N-K;i<N;i++) - codefile<<i+1<<" "; - codefile<<endl; - - codefile.close(); - if(verbose) { - cout<<"****************************************************"<<endl; - cout<<" Free memory"<<endl; - cout<<"****************************************************"<<endl; - } - delete [] Index; - Index=NULL; - delete [] J; - J=NULL; - delete [] itmp; - itmp=NULL; - for(i=0;i<M;i++){ - delete [] parityCheck_compressed[i]; - parityCheck_compressed[i]=NULL; - } - delete [] parityCheck_compressed; - parityCheck_compressed=NULL; - for(i=0;i<max_row;i++){ - delete [] generator_compressed[i]; - generator_compressed[i]=NULL; - } - delete [] generator_compressed; - generator_compressed=NULL; - for(i=0;i<K;i++){ - delete [] generator[i]; - generator[i]=NULL; - } - delete [] generator; - generator=NULL; - - if(verbose) { - cout<<"****************************************************"<<endl; - cout<<" OK!"<<endl; - cout<<"****************************************************"<<endl; - } - -} - diff --git a/lib/ldpc/peg/BigGirth.h b/lib/ldpc/peg/BigGirth.h deleted file mode 100644 index d30a05a1..00000000 --- a/lib/ldpc/peg/BigGirth.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef BIGGIRTH -#define BIGGIRTH 1 - -#include <cstdlib> -#include <iostream> // C++ I/O library header -#include "Random.h" - -class NodesInGraph{ - public: - int numOfConnectionParityBit; - int *connectionParityBit; - int numOfConnectionSymbolBit; - int *connectionSymbolBit; - int maxDegParity; - - NodesInGraph(void); - ~NodesInGraph(void); - void setNumOfConnectionSymbolBit(int deg); - void initConnectionParityBit(void); - void initConnectionParityBit(int deg); -}; - -class BigGirth { - public: - int M, N; - int K; - int EXPAND_DEPTH; - const char *filename; - int *(*H); - - int *localGirth; - - NodesInGraph *nodesInGraph; - Random *myrandom; - - BigGirth(int m, int n, int *symbolDegSequence, const char *filename, int sglConcent, int tgtGirth, bool verbose_ = true); - BigGirth(void); - - void writeToFile_Hcompressed(void); - void writeToFile_Hmatrix(void); - void writeToFile(void); - - void loadH(void); - - ~BigGirth(void); - - private: - int selectParityConnect(int kthSymbol, int mthConnection, int & cycle); - void updateConnection(int kthSymbol); - bool verbose; - -}; - -#endif diff --git a/lib/ldpc/peg/CodeName b/lib/ldpc/peg/CodeName deleted file mode 100644 index 118a6382..00000000 --- a/lib/ldpc/peg/CodeName +++ /dev/null @@ -1,68 +0,0 @@ -64 -16 -48 -14 -5 -3 1 3 6 1 4 1 1 1 1 2 1 1 1 1 6 6 2 2 1 1 2 2 1 2 6 2 6 1 1 2 1 1 6 3 2 6 2 1 1 6 1 1 2 1 1 1 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 -4 2 4 9 3 6 2 2 3 2 4 2 3 3 3 7 9 6 4 3 2 6 6 2 4 9 6 7 2 2 4 3 3 7 4 4 7 4 3 3 7 2 2 6 3 2 2 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -6 3 6 10 4 9 4 4 4 4 5 4 4 4 4 8 10 8 5 4 3 7 7 4 6 13 9 9 4 4 5 4 4 8 6 5 8 5 4 4 9 4 4 8 4 3 4 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -7 4 12 12 6 12 5 5 6 5 6 5 5 6 6 9 11 9 6 5 4 11 9 5 7 0 10 10 5 5 6 6 5 9 8 6 11 6 5 5 11 5 5 9 6 4 5 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -9 5 16 15 9 15 6 6 7 6 7 6 6 9 7 10 12 11 8 6 5 13 13 6 8 0 11 11 6 6 9 8 6 11 11 8 12 7 6 6 13 6 6 12 10 5 6 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -10 6 0 16 11 16 8 7 9 8 8 7 7 12 8 11 13 13 9 11 6 14 14 8 9 0 13 12 8 9 11 9 7 12 12 10 13 8 8 7 0 8 7 15 12 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -13 8 0 0 13 0 10 8 13 9 10 10 9 13 9 12 14 15 11 13 7 16 16 9 13 0 15 13 10 11 16 11 11 13 16 12 14 9 11 10 0 9 11 0 13 12 9 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -15 12 0 0 14 0 11 10 15 11 12 11 10 15 11 13 15 0 13 14 12 0 0 12 14 0 0 14 14 13 0 14 13 0 0 15 0 11 12 13 0 10 12 0 15 13 10 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 13 0 0 15 0 12 12 16 12 14 14 14 16 14 14 0 0 15 15 14 0 0 13 0 0 0 15 15 15 0 15 14 0 0 16 0 13 13 14 0 12 14 0 16 14 11 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 15 0 0 16 0 14 14 0 13 15 0 16 0 16 16 0 0 16 16 15 0 0 14 0 0 0 16 0 16 0 16 16 0 0 0 0 14 15 16 0 14 15 0 0 15 12 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 16 0 0 0 0 15 15 0 15 16 0 0 0 0 0 0 0 0 0 16 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 15 16 0 0 15 0 0 0 16 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 16 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 9 49 58 64 -2 39 50 59 0 -3 6 51 57 63 -4 6 52 58 0 -5 20 53 57 0 -4 37 48 60 0 -7 36 49 59 62 -8 29 55 60 0 -9 14 55 60 0 -10 30 56 60 0 -11 31 48 61 64 -12 24 48 62 0 -13 40 57 61 0 -1 35 48 62 0 -15 32 55 63 0 -16 28 56 63 0 -17 28 55 64 0 -18 27 56 58 0 -19 31 56 61 63 -5 32 56 61 0 -21 43 51 59 64 -22 23 57 59 0 -22 44 48 58 0 -12 43 58 60 63 -25 38 53 59 63 -26 41 55 59 0 -18 44 59 60 61 -17 27 50 60 62 -29 42 57 60 64 -8 30 48 63 0 -19 38 55 62 64 -15 45 48 64 0 -20 33 55 63 0 -34 41 56 60 0 -14 45 57 58 0 -11 36 55 62 0 -34 37 57 62 0 -7 47 57 61 0 -2 46 56 62 0 -33 40 58 59 0 -3 35 56 59 0 -10 47 58 62 0 -21 46 55 61 0 -23 25 52 56 64 -13 39 48 64 0 -26 54 57 61 0 -24 42 58 61 0 -16 48 54 63 0 -49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 diff --git a/lib/ldpc/peg/CyclesOfGraph.C b/lib/ldpc/peg/CyclesOfGraph.C deleted file mode 100644 index 77c98b59..00000000 --- a/lib/ldpc/peg/CyclesOfGraph.C +++ /dev/null @@ -1,237 +0,0 @@ -#include "CyclesOfGraph.h" - -NodesOfGraph::NodesOfGraph(void) { parityConnections=NULL;symbolConnections=NULL; -} -NodesOfGraph::~NodesOfGraph(void) { - delete [] parityConnections; - delete [] symbolConnections; - delete [] symbolMapping; - -} - -void NodesOfGraph::setParityConnections(int num, int *value) { - numOfParityConnections=num; - parityConnections=new int[num]; - for(int i=0;i<numOfParityConnections;i++){ - parityConnections[i]=value[i]; - //cout<<parityConnections[i]<<" "; - } - //cout<<endl; -} -void NodesOfGraph::setSymbolConnections(int num, int *value) { - numOfSymbolConnections=num; - symbolConnections=new int[num]; - for(int i=0;i<numOfSymbolConnections;i++){ - symbolConnections[i]=value[i]; - //cout<<symbolConnections[i]<<" "; - } - //cout<<endl; -} -void NodesOfGraph::setSymbolMapping(int num, int *value) { - numOfSymbolMapping=num; - //cout<<num<<endl; - symbolMapping=new int[num]; - for(int i=0;i<numOfSymbolMapping;i++){ - symbolMapping[i]=value[i]; - //cout<<symbolMapping[i]<<" "; - } - //cout<<endl; -} - -CyclesOfGraph::CyclesOfGraph(int mm, int n, int *(*h)){ - int i, j, k, m, index; - M=mm; - N=n; - H=h; - - tmp=new int [N]; - med=new int [N]; - tmpCycles=new int [N]; - cyclesTable=new int [N]; - nodesOfGraph=new NodesOfGraph [N]; - - //cout<<M<<" "<<N<<endl; - /* - for(i=0;i<M;i++){ - for(j=0;j<N;j++) - cout<<H[i][j]<<" "; - cout<<endl; - } - */ - for(i=0;i<N;i++){ - index=0; - for(j=0;j<M;j++){ - if(H[j][i]==1){ - tmp[index]=j; - index++; - } - } - nodesOfGraph[i].setSymbolConnections(index, tmp); - } - for(i=0;i<M;i++){ - index=0; - for(j=0;j<N;j++){ - if(H[i][j]==1){ - tmp[index]=j; - index++; - } - } - nodesOfGraph[i].setParityConnections(index, tmp); - } - for(i=0;i<N;i++){ - index=0; - for(j=0;j<nodesOfGraph[i].numOfSymbolConnections;j++){ - for(k=0;k<nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].numOfParityConnections;k++){ - int t=0; - for(m=0;m<index;m++){ - if(nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].parityConnections[k]==tmp[m]){ - t=1; break; - } - } - if(nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].parityConnections[k]==i) t=1; - if(t==0) { - tmp[index]=nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].parityConnections[k]; - index++; - } - } - } - nodesOfGraph[i].setSymbolMapping(index, tmp); - } -} - -CyclesOfGraph::~CyclesOfGraph(void){ - delete [] tmp; - tmp=NULL; - delete [] med; - med=NULL; - delete [] tmpCycles; - tmpCycles=NULL; - delete [] cyclesTable; - cyclesTable=NULL; - delete [] nodesOfGraph; - nodesOfGraph=NULL; -} - -void CyclesOfGraph::getCyclesTable(void) { - int i, j, k, m, n, t, imed; - for(i=0;i<N;i++){ - //special handlement for nodes having only one or zero connections - if(nodesOfGraph[i].numOfSymbolConnections<=1) { - cyclesTable[i]=2*N; - continue; - } - for(j=0;j<nodesOfGraph[i].numOfSymbolConnections-1;j++){ //-1 because the graph is undirected - for(k=0;k<nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].numOfParityConnections;k++){ - tmp[k]=nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].parityConnections[k]; - //cout<<tmp[k]<<" "; - } - //cout<<endl; - int cycles=2; - int index=nodesOfGraph[nodesOfGraph[i].symbolConnections[j]].numOfParityConnections; - LOOP: - imed=0; - for(k=0;k<index;k++){ - if(tmp[k]==i) continue; - //cout<<"k="<<k<<" "<<tmp[k]<<endl; - for(m=0;m<nodesOfGraph[tmp[k]].numOfSymbolConnections;m++){ - for(n=0;n<nodesOfGraph[i].numOfSymbolConnections;n++){ - if((n!=j)&&(nodesOfGraph[tmp[k]].symbolConnections[m]==nodesOfGraph[i].symbolConnections[n])){ - cycles+=2; - goto OUTLOOP; - } - } - } - for(m=0;m<nodesOfGraph[tmp[k]].numOfSymbolMapping;m++){ - t=0; - for(int l=0;l<imed;l++) { - if(nodesOfGraph[tmp[k]].symbolMapping[m]==med[l]){ - t=1; break; - } - } - if(t==0){ - med[imed]=nodesOfGraph[tmp[k]].symbolMapping[m]; - //cout<<med[imed]<<endl; - imed++; - } - } - } - index=imed;//cout<<index<<" "<<endl; - for(k=0;k<index;k++) { - tmp[k]=med[k];//cout<<tmp[k]<<" "; - } - //cout<<"j="<<j<<endl; - cycles+=2; - if(cycles>=2*N) //dead lock - goto OUTLOOP; - else - goto LOOP; - OUTLOOP: - tmpCycles[j]=cycles; - } - //for(j=0;j<nodesOfGraph[i].numOfSymbolConnections-1;j++) cout<<tmpCycles[j]<<" "; - //cout<<endl; - cyclesTable[i]=tmpCycles[0]; - for(j=1;j<nodesOfGraph[i].numOfSymbolConnections-1;j++){ - if(cyclesTable[i]>tmpCycles[j]) - cyclesTable[i]=tmpCycles[j]; - } - //OUTPUT cycles per symbol node - //cout<<"i="<<i<<" "<<cyclesTable[i]<<endl; - } -} - -int CyclesOfGraph::girth(void) { - int girth=2*N; - for(int i=0;i<N;i++) - if(girth>cyclesTable[i]) girth=cyclesTable[i]; - return(girth); -} - -void CyclesOfGraph::printCyclesTable(void){ - using namespace std; - int i, temp[20]; - /* - for(i=0;i<N;i++) - cout<<cyclesTable[i]<<" "; - cout<<endl; - */ - for(i=0;i<20;i++) temp[i]=0; - for(i=0;i<N;i++){ - if(cyclesTable[i]==4) temp[0]++; - else if(cyclesTable[i]==6) temp[1]++; - else if(cyclesTable[i]==8) temp[2]++; - else if(cyclesTable[i]==10) temp[3]++; - else if(cyclesTable[i]==12) temp[4]++; - else if(cyclesTable[i]==14) temp[5]++; - else if(cyclesTable[i]==16) temp[6]++; - else if(cyclesTable[i]==18) temp[7]++; - else if(cyclesTable[i]==20) temp[8]++; - else if(cyclesTable[i]==22) temp[9]++; - else if(cyclesTable[i]==24) temp[10]++; - else if(cyclesTable[i]==26) temp[11]++; - else if(cyclesTable[i]==28) temp[12]++; - else if(cyclesTable[i]==30) temp[13]++; - else { - cout<<"Wrong cycles calculation "<<cyclesTable[i]<<endl; - exit(-1); - } - } - cout<<endl; - cout<<"Num of Nodes with local girth 4: "<< temp[0]<<endl; - cout<<"Num of Nodes with local girth 6: "<< temp[1]<<endl; - cout<<"Num of Nodes with local girth 8: "<< temp[2]<<endl; - cout<<"Num of Nodes with local girth 10: "<< temp[3]<<endl; - cout<<"Num of Nodes with local girth 12: "<< temp[4]<<endl; - cout<<"Num of Nodes with local girth 14: "<< temp[5]<<endl; - cout<<"Num of Nodes with local girth 16: "<< temp[6]<<endl; - cout<<"Num of Nodes with local girth 18: "<< temp[7]<<endl; - cout<<"Num of Nodes with local girth 20: "<< temp[8]<<endl; - cout<<"Num of Nodes with local girth 22: "<< temp[9]<<endl; - cout<<"Num of Nodes with local girth 24: "<< temp[10]<<endl; - cout<<"Num of Nodes with local girth 26: "<< temp[11]<<endl; - cout<<"Num of Nodes with local girth 28: "<< temp[12]<<endl; - cout<<"Num of Nodes with local girth 30: "<< temp[13]<<endl; -} - - - diff --git a/lib/ldpc/peg/CyclesOfGraph.h b/lib/ldpc/peg/CyclesOfGraph.h deleted file mode 100644 index 9105537b..00000000 --- a/lib/ldpc/peg/CyclesOfGraph.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef CYCLESOFGRAPH -#define CYCLESOFGRAPH 1 - -#include <cstdlib> -#include <iostream> // C++ I/O library header -//#include <iomanip.h> - -class NodesOfGraph{ - public: - int numOfParityConnections; - int *parityConnections; - int numOfSymbolConnections; - int *symbolConnections; - int numOfSymbolMapping; - int *symbolMapping; - NodesOfGraph(void); - ~NodesOfGraph(void); - void setParityConnections(int num, int *value); - void setSymbolConnections(int num, int *value); - void setSymbolMapping(int num, int *values); -}; //Why this is necessary? - -class CyclesOfGraph { - public: - int M, N; - int *(*H); - int *cyclesTable; - NodesOfGraph *nodesOfGraph; - CyclesOfGraph(int mm, int n, int *(*h)); - ~CyclesOfGraph(void); - void getCyclesTable(void); - void printCyclesTable(void); - int girth(void); - private: - int *tmp, *med, *tmpCycles; -}; - -#endif - - diff --git a/lib/ldpc/peg/DenEvl_11.deg b/lib/ldpc/peg/DenEvl_11.deg deleted file mode 100644 index 18a77197..00000000 --- a/lib/ldpc/peg/DenEvl_11.deg +++ /dev/null @@ -1,3 +0,0 @@ -4 - 2 3 4 11 -0.450013 0.370771 0.0307238 0.1484922 diff --git a/lib/ldpc/peg/DenEvl_15.deg b/lib/ldpc/peg/DenEvl_15.deg deleted file mode 100644 index 3af8369d..00000000 --- a/lib/ldpc/peg/DenEvl_15.deg +++ /dev/null @@ -1,3 +0,0 @@ -7 -2 3 4 5 7 14 15 -0.477081 0.280572 0.0349963 0.0963301 0.0090884 0.00137443 0.10055777 diff --git a/lib/ldpc/peg/DenEvl_20.deg b/lib/ldpc/peg/DenEvl_20.deg deleted file mode 100644 index 174d6465..00000000 --- a/lib/ldpc/peg/DenEvl_20.deg +++ /dev/null @@ -1,4 +0,0 @@ -9 -2 3 4 6 7 8 9 19 20 -0.457827 0.323775 0.0214226 0.0592851 0.0389015 0.0248109 0.00884569 -0.0176697 0.04746251 diff --git a/lib/ldpc/peg/DenEvl_7.deg b/lib/ldpc/peg/DenEvl_7.deg deleted file mode 100644 index feb53aee..00000000 --- a/lib/ldpc/peg/DenEvl_7.deg +++ /dev/null @@ -1,3 +0,0 @@ -3 - 2 3 7 -0.521814 0.271293 0.206893 diff --git a/lib/ldpc/peg/DenEvl_9.deg b/lib/ldpc/peg/DenEvl_9.deg deleted file mode 100644 index 3072b205..00000000 --- a/lib/ldpc/peg/DenEvl_9.deg +++ /dev/null @@ -1,3 +0,0 @@ -3 - 2 3 9 -0.491281 0.335305 0.173414 diff --git a/lib/ldpc/peg/MainPEG.C b/lib/ldpc/peg/MainPEG.C deleted file mode 100644 index 18600139..00000000 --- a/lib/ldpc/peg/MainPEG.C +++ /dev/null @@ -1,200 +0,0 @@ -/************************************************************************/ -/* */ -/* Free software: Progressive edge-growth (PEG) algorithm */ -/* Created by Xiaoyu Hu */ -/* Evangelos Eletheriou */ -/* Dieter Arnold */ -/* IBM Research, Zurich Research Lab., Switzerland */ -/* */ -/* The C++ sources files have been compiled using xlC compiler */ -/* at IBM RS/6000 running AIX. For other compilers and platforms,*/ -/* minor changes might be needed. */ -/* */ -/* Bug reporting to: xhu@zurich.ibm.com */ -/**********************************************************************/ - -//// -// Modified by F. P. Beekhof; 2008 / 08 / 19 -//// - -#include <cstdlib> -#include <cstring> -#include <string> -#include <iostream> -#include <iomanip> -#include <fstream> -#include <cmath> -#include <vector> -#include "BigGirth.h" -#include "Random.h" -#include "CyclesOfGraph.h" - -const double EPS = 1e-6; - -using namespace std; - -void usage() -{ - cout<<"*******************************************************************************************"<<endl; - cout<<" Usage Reminder: MainPEG -numM M -numN N -codeName CodeName -degFileName DegFileName " <<endl; - cout<<" option: -sglConcent SglConcent " <<endl; - cout<<" sglConcent==0 ----- strictly concentrated parity-check " <<endl; - cout<<" degree distribution (including regular graphs)" <<endl; - cout<<" sglConcent==1 ----- Best-effort concentrated (DEFAULT) " <<endl; - cout<<" option: -tgtGirth TgtGirth " <<endl; - cout<<" TgtGirth==4, 6 ...; if very large, then greedy PEG (DEFAULT) " <<endl; - cout<<" IF sglConcent==0, TgtGirth is recommended to be set relatively small" <<endl; - cout<<" option: -q " <<endl; - cout<<" Quiet mode. Produces less output to the screen. " <<endl; - cout<<" option: -outputMode <0,1,2> " <<endl; - cout<<" Specifies output format. " <<endl; - cout<<" '0': H in compressed format (default) " <<endl; - cout<<" '1': H in un-compressed format " <<endl; - cout<<" '2': G and H in compressed format " <<endl; - cout<<" " <<endl; - cout<<" Remarks: File CodeName stores the generated PEG Tanner graph. The first line contains"<<endl; - cout<<" the block length, N. The second line defines the number of parity-checks, M."<<endl; - cout<<" The third line defines the number of columns of the compressed parity-check "<<endl; - cout<<" matrix. The following M lines are then the compressed parity-check matrix. "<<endl; - cout<<" Each of the M rows contains the indices (1 ... N) of 1's in the compressed "<<endl; - cout<<" row of parity-check matrix. If not all column entries are used, the column "<<endl; - cout<<" is filled up with 0's. "<<endl; - cout<<" "<<endl; - cout<<" If both G and H are in the output, (outMode 2), the first line contains"<<endl; - cout<<" N, the 2nd line K, the number of message bits, the 3rd line M, the 4th line"<<endl; - cout<<" contains the number of rows of the compressed generator matrix; the 5th"<<endl; - cout<<" defines the number of columns of the compressed parity-check matrix. The"<<endl; - cout<<" format of G is almost like that of H, but vertical -- i.e. the padding"<<endl; - cout<<" zeroes are on the bottom. "<<endl; - - cout<<" "<<endl; - cout<<" File DegFileName is the input file to specify the degree distribution (node "<<endl; - cout<<" perspective). The first line contains the number of various degrees. The second"<<endl; - cout<<" defines the row vector of degree sequence in the increasing order. The vector"<<endl; - cout<<" of fractions of the corresponding degree is defined in the last line. "<<endl; - cout<<" "<<endl; - cout<<" A log file called 'leftHandGirth.dat' will also be generated and stored in the"<<endl; - cout<<" current directory, which gives the girth of the left-hand subgraph of j, where"<<endl; - cout<<" 1<=j<=N. The left-hand subgraph of j is defined as all the edges emanating from"<<endl; - cout<<" bit nodes {1 ... j} and their associated nodes. "<<endl; - cout<<" "<<endl; - cout<<" The last point is, when strictly concentrated parity-check degree distribution"<<endl; - cout<<" is invoked, i.e. sglConcent==0, the girth might be weaken to some extent as "<<endl; - cout<<" compared to the generic PEG algorithm. "<<endl; - cout<<"**********************************************************************************************"<<endl; - exit(-1); -} - -int main(int argc, char * argv[]){ - int sglConcent=1; // default to non-strictly concentrated parity-check distribution - int targetGirth=100000; // default to greedy PEG version - std::string codeName, degFileName; - int M = -1, N = -1; - bool verbose = true; - - const int OUTPUT_MODE_H_COMPRESSED = 0; - const int OUTPUT_MODE_H = 1; - const int OUTPUT_MODE_G_H_COMPRESSED = 2; - int output_mode = OUTPUT_MODE_H_COMPRESSED; // default - - if (argc<9) { - usage(); - }else { - for(int i=1;i<argc;++i){ - if (strcmp(argv[i], "-numM")==0) { - if (++i >= argc) usage(); - M=atoi(argv[i]); - } else if(strcmp(argv[i], "-numN")==0) { - if (++i >= argc) usage(); - N=atoi(argv[i]); - } else if(strcmp(argv[i], "-codeName")==0) { - if (++i >= argc) usage(); - codeName = argv[i]; - } else if(strcmp(argv[i], "-degFileName")==0) { - if (++i >= argc) usage(); - degFileName = argv[i]; - } else if(strcmp(argv[i], "-sglConcent")==0) { - if (++i >= argc) usage(); - sglConcent=atoi(argv[i]); - } else if(strcmp(argv[i], "-tgtGirth")==0) { - if (++i >= argc) usage(); - targetGirth=atoi(argv[i]); - } else if(strcmp(argv[i], "-outputMode")==0) { - if (++i >= argc) usage(); - output_mode=atoi(argv[i]); - } else if(strcmp(argv[i], "-q")==0) { - verbose=false; - } else{ - usage(); - } - } - if (M == -1 || N == -1) { - cout<<"Error: M or N not specified!"<<endl; - exit(-1); - } - if (M>N) { - cout<<"Error: M must be smaller than N!"<<endl; - exit(-1); - } - } - - std::vector<int> degSeq(N); - - ifstream infn(degFileName.c_str()); - if (!infn) {cout << "\nCannot open file " << degFileName << endl; exit(-1); } - int m; - infn >>m; - std::vector<int> deg(m); - std::vector<double> degFrac(m); - for(int i=0;i<m;i++) infn>>deg[i]; - for(int i=0;i<m;i++) infn>>degFrac[i]; - infn.close(); - double dtmp=0.0; - for(int i=0;i<m;i++) dtmp+=degFrac[i]; - cout.setf(ios::fixed, ios::floatfield); - if(abs(dtmp-1.0)>EPS) { - cout.setf(ios::fixed, ios::floatfield); - cout <<"\n Invalid degree distribution (node perspective): sum != 1.0 but "<<setprecision(10)<<dtmp<<endl; exit(-1); - } - for(int i=1;i<m;++i) degFrac[i]+=degFrac[i-1]; - for(int i=0;i<N;++i) { - dtmp=double(i)/double(N); - int j; - for(j=m-1;j>=0;--j) { - if(dtmp>degFrac[j]) break; - } - if(dtmp<degFrac[0]) degSeq[i]=deg[0]; - else degSeq[i]=deg[j+1]; - } - - BigGirth bigGirth(M, N, °Seq[0], codeName.c_str(), - sglConcent, targetGirth, verbose); - - switch(output_mode) - { - case OUTPUT_MODE_H_COMPRESSED: bigGirth.writeToFile_Hcompressed(); break; - case OUTPUT_MODE_H: // different output format - bigGirth.writeToFile_Hmatrix(); break; - case OUTPUT_MODE_G_H_COMPRESSED: - // different output format: including generator matrix (compressed) - bigGirth.writeToFile(); break; - default: - cout << "Error: invalid output mode specified." << endl << endl; - usage(); - } - - //computing local girth distribution - - if (verbose && N<10000) { - cout<<" Now computing the local girth on the global Tanner graph setting. "<<endl; - cout<<" might take a bit long time. Please wait ... "<<endl; - bigGirth.loadH(); - CyclesOfGraph cog(M, N, bigGirth.H); - cog.getCyclesTable(); - cog.printCyclesTable(); - } -} - - - - diff --git a/lib/ldpc/peg/Makefile b/lib/ldpc/peg/Makefile deleted file mode 100644 index 7d6aa5ae..00000000 --- a/lib/ldpc/peg/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# GCC Makefile for: PEG-ECC by Xiao-Yu Hu. -# http://www.inference.phy.cam.ac.uk/mackay/PEG_ECC.html -# -# Tested with on Linux 2.4 and 2.6 (i686) with -# GCC versions 3.2.2, 3.3.5 and GNU Make version 3.80. -# -# Simeon Miteff <simeon@up.ac.za> -# Thu May 12 12:38:41 SAST 2005 - -PROGRAM = MainPEG -OBJECTS = MainPEG.o Random.o CyclesOfGraph.o BigGirth.o - -CXX = g++ -CXXFLAGS = -g -ansi -pedantic -Wno-deprecated -Wall -O2 -#CXXFLAGS = -g -ansi -pedantic -Wall -march=native -ftree-vectorize -O3 - -.SUFFIXES: .o .C - -all: ${OBJECTS} - $(CXX) -o ${PROGRAM} ${OBJECTS} - -.C.o: $< - $(CXX) ${CXXFLAGS} -c $< -o $@ - -.PHONY : clean - -clean: - rm -f ${OBJECTS} ${PROGRAM} *~ *.log - diff --git a/lib/ldpc/peg/Random.C b/lib/ldpc/peg/Random.C deleted file mode 100644 index 3c5d5438..00000000 --- a/lib/ldpc/peg/Random.C +++ /dev/null @@ -1,101 +0,0 @@ - -#include <cmath> -#include <algorithm> -#include "Random.h" - -void Random::bubbleSort(int a[], int size) -{ - for(int pass=1; pass<size; pass++) { - for(int i=0;i<size-pass;i++) - if(a[i]>a[i+1]){ - std::swap(a[i], a[i+1]); - } - } -} - -double Random::gauss(double sdev, double mean) -{ - double sum=0.0; - for (int i=1;i<=12;++i) - { - seed_u = 1664525lu * seed_u + 123456789lu; - sum+=double(seed_u); - } - return (sum/4.29497e9-6.0)*sdev+mean; -} - -double Random::uniform(double a, double b) -{ - double t; - for(int i=0; i<10;i++){ - seed=2045*seed+1; - //seed=seed -(seed/1048576)*1048576; - seed%=1048576; - } - t=seed/1048576.0; - t=a+(b-a)*t; - return(t); -} - -int Random::uniform(int a, int b) // [a, b-1] -{ - double t; - int i, tt; - if(b==a+1) return(a); - for(i=0; i<10;i++){ - seed=2045*seed+1; - //seed=seed -(seed/1048576)*1048576; - seed%=1048576; - } - t=seed/1048576.0; - t=a+(b-a)*t; - tt=(int)t; - if(tt<a) tt=a; - else if(tt>=b) tt=b-1; - return(tt); -} - -int Random::nonUniform(int a, int b) // [a, b-1] -{ - double t; - int i, tt; - if(b==a+1) return(a); - for(i=0; i<10;i++){ - seed=2045*seed+1; - //seed=seed -(seed/1048576)*1048576; - seed%=1048576; - } - t=seed/1048576.0; - t=a+(b-a)*pow(t, 0.6667); //t^1.5 - tt=(int)t; - if(tt<a) tt=a; - else if(tt>=b) tt=b-1; - return(tt); -} - -/* -void m_uniform(int a , int b, long int *seed, int *itmp, int num) -{ - int index, imed, i, k; - - index=0; - itmp[0]=uniform(a, b, seed); - Loop1: - imed=uniform(a, b, seed); - k=0; - for(i=0;i<=index;i++) - if(imed==itmp[i]) {k=1; break;} - if(k==0) {index++; itmp[index]=imed;} - if(index<num-1) goto Loop1; - bubble(itmp, num); //bubble sorting -} -*/ - - - - - - - - - diff --git a/lib/ldpc/peg/Random.h b/lib/ldpc/peg/Random.h deleted file mode 100644 index ef22bfd3..00000000 --- a/lib/ldpc/peg/Random.h +++ /dev/null @@ -1,29 +0,0 @@ - -#ifndef RANDOM -#define RANDOM 1 - -#include <cstdlib> -// #include <iostream> - -class Random{ - private: - - unsigned long int seed; //previously LONG INT - unsigned long int seed_u; - - public: - - Random(void) { - this->seed=987654321u; - this->seed_u=123456789lu; - } - ~Random(void){;} - void bubbleSort(int a[], int size); - double gauss(double sdev, double mean); - double uniform(double a, double b); - int uniform(int a, int b); // [a, b) - int nonUniform(int a, int b); - -}; - -#endif diff --git a/lib/ldpc/peg/Reg_2.deg b/lib/ldpc/peg/Reg_2.deg deleted file mode 100644 index 28d2c8f1..00000000 --- a/lib/ldpc/peg/Reg_2.deg +++ /dev/null @@ -1,3 +0,0 @@ -1 -2 -1.0 diff --git a/lib/ldpc/peg/Reg_3.deg b/lib/ldpc/peg/Reg_3.deg deleted file mode 100644 index 0fb5a574..00000000 --- a/lib/ldpc/peg/Reg_3.deg +++ /dev/null @@ -1,3 +0,0 @@ -1 -3 -1.0 diff --git a/lib/ldpc/peg/Reg_4.deg b/lib/ldpc/peg/Reg_4.deg deleted file mode 100644 index b42df500..00000000 --- a/lib/ldpc/peg/Reg_4.deg +++ /dev/null @@ -1,3 +0,0 @@ -1 -4 -1.0 diff --git a/lib/ldpc/peg/ldpc-peg-128-80.alist b/lib/ldpc/peg/ldpc-peg-128-80.alist deleted file mode 100644 index a25da9a3..00000000 --- a/lib/ldpc/peg/ldpc-peg-128-80.alist +++ /dev/null @@ -1,180 +0,0 @@ -48 128 -9 4 -9 9 9 9 9 8 8 8 8 8 9 9 8 8 9 9 8 8 8 8 9 9 9 8 9 9 9 9 9 9 8 8 8 9 8 9 9 9 8 9 8 8 8 9 8 8 8 9 -3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 -1 17 34 51 66 81 99 111 124 -2 18 35 50 67 82 100 112 125 -3 19 36 52 68 82 101 111 126 -2 20 36 51 69 83 102 113 127 -4 19 37 53 66 84 103 114 128 -5 21 38 54 70 85 92 114 0 -6 22 39 55 66 85 96 110 0 -7 23 32 56 71 86 103 115 0 -8 20 40 55 72 86 104 116 0 -9 19 41 57 73 87 105 116 0 -10 24 36 56 74 88 105 117 125 -10 17 33 47 75 89 106 118 128 -11 21 42 51 76 87 107 119 0 -1 25 40 58 74 84 107 113 0 -12 22 42 49 77 90 108 118 125 -13 26 43 59 68 89 104 120 124 -13 22 44 57 75 91 109 113 0 -12 23 37 46 78 88 107 112 0 -3 27 34 60 65 87 109 118 0 -6 27 45 61 79 89 98 112 0 -14 28 34 62 72 92 106 112 127 -8 27 42 59 71 92 110 121 126 -15 20 46 57 79 93 101 115 124 -9 29 45 62 74 94 108 121 0 -8 30 38 63 73 95 109 111 128 -16 29 47 64 69 96 109 117 126 -16 23 48 63 76 94 110 116 125 -7 25 39 52 70 97 106 117 124 -4 26 45 63 67 83 90 119 123 -15 28 39 50 76 88 103 121 123 -15 26 33 58 65 97 102 122 0 -14 31 47 52 77 81 93 116 0 -14 24 37 61 71 82 99 122 0 -4 31 40 54 80 91 106 115 122 -5 32 41 58 77 98 104 117 0 -9 18 49 65 79 85 104 119 128 -10 30 43 60 69 84 108 115 123 -1 18 43 48 73 91 98 114 127 -3 21 46 64 67 86 108 113 0 -5 24 48 55 75 93 107 120 126 -2 32 44 62 80 95 99 114 0 -16 28 41 59 80 83 100 118 0 -11 33 35 53 72 96 105 111 0 -11 25 44 60 78 90 100 120 122 -6 31 35 56 70 95 102 121 0 -12 17 50 54 68 94 105 119 0 -13 29 38 53 78 97 110 123 0 -7 30 49 61 64 81 101 120 127 -1 14 38 0 -2 4 41 0 -3 19 39 0 -5 29 34 0 -6 35 40 0 -7 20 45 0 -8 28 48 0 -9 22 25 0 -10 24 36 0 -11 12 37 0 -13 43 44 0 -15 18 46 0 -16 17 47 0 -21 32 33 0 -23 30 31 0 -26 27 42 0 -1 12 46 0 -2 36 38 0 -3 5 10 0 -4 9 23 0 -6 13 39 0 -7 15 17 0 -8 18 27 0 -11 33 40 0 -14 28 44 0 -16 29 31 0 -19 20 22 0 -21 30 42 0 -24 26 47 0 -25 37 48 0 -32 34 45 0 -8 35 41 0 -12 31 43 0 -1 19 21 0 -2 43 45 0 -3 4 11 0 -5 18 33 0 -6 25 47 0 -7 28 30 0 -9 14 34 0 -10 35 42 0 -13 15 22 0 -16 37 38 0 -17 41 44 0 -20 24 29 0 -18 23 39 0 -12 26 32 0 -27 38 40 0 -15 36 48 0 -2 30 46 0 -1 4 13 0 -3 28 32 0 -5 43 47 0 -6 34 46 0 -7 9 40 0 -8 11 45 0 -10 17 23 0 -14 31 35 0 -16 22 42 0 -19 37 44 0 -20 33 48 0 -21 24 41 0 -25 27 29 0 -26 39 48 0 -19 31 36 0 -1 5 7 0 -2 29 39 0 -3 16 46 0 -4 26 37 0 -6 28 45 0 -8 22 33 0 -9 21 43 0 -10 25 38 0 -11 14 24 0 -12 17 40 0 -13 27 30 0 -15 32 35 0 -18 44 47 0 -20 23 36 0 -34 41 42 0 -1 32 48 0 -2 3 33 0 -4 29 42 0 -5 14 37 0 -6 7 36 0 -8 9 39 0 -10 13 19 0 -11 18 30 0 -12 16 20 0 -15 29 44 0 -17 34 38 0 -6 21 22 0 -23 32 40 0 -24 27 46 0 -25 41 45 0 -7 26 43 0 -28 31 47 0 -20 35 38 0 -1 33 41 0 -2 42 44 0 -3 23 48 0 -4 31 45 0 -5 8 30 0 -9 16 35 36 -10 11 43 46 -12 21 28 34 -13 14 18 40 -15 24 37 39 -17 19 25 26 -7 22 27 47 -1 3 25 43 -2 18 20 21 -4 14 17 39 -5 6 38 41 -8 23 34 37 -9 10 27 32 -11 26 28 35 -12 15 19 42 -13 29 36 46 -16 40 44 48 -22 24 30 45 -31 33 34 44 -29 30 37 47 -1 16 23 28 -2 11 15 27 -3 22 26 40 -4 21 38 48 -5 12 25 36 diff --git a/lib/ldpc/peg/peg-128-64-reg4.alist b/lib/ldpc/peg/peg-128-64-reg4.alist deleted file mode 100644 index 30c8edf9..00000000 --- a/lib/ldpc/peg/peg-128-64-reg4.alist +++ /dev/null @@ -1,196 +0,0 @@ -64 128 -9 4 -8 8 8 8 9 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 8 8 8 8 8 8 8 -4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 -1 17 33 50 67 83 98 114 0 -2 18 34 50 68 84 99 115 0 -3 19 35 51 69 85 100 115 0 -4 20 36 52 70 86 101 115 0 -2 20 35 53 71 87 102 113 128 -5 21 33 54 64 88 103 116 0 -6 19 37 55 72 89 98 117 0 -7 22 38 56 73 90 96 116 0 -8 23 34 57 72 91 104 118 0 -7 24 39 58 74 84 100 119 0 -9 22 40 59 74 92 105 120 0 -9 25 41 55 75 91 106 114 0 -10 25 36 51 67 74 107 121 0 -11 22 36 54 72 93 102 122 0 -12 25 42 60 76 89 103 123 0 -8 26 38 51 77 93 105 124 0 -13 27 40 61 77 94 99 119 0 -13 17 43 54 73 85 108 124 0 -1 28 40 62 71 84 108 125 0 -12 29 38 53 67 86 108 126 0 -14 28 43 51 78 94 96 117 0 -11 17 42 62 79 92 104 126 0 -4 29 39 57 65 87 109 116 0 -2 27 38 55 78 79 107 127 0 -13 24 44 53 66 83 103 117 0 -15 30 43 55 67 90 105 128 0 -6 22 45 48 78 88 106 119 0 -14 25 33 63 65 73 99 118 0 -6 31 46 64 80 95 102 125 0 -5 18 37 65 79 94 110 113 0 -14 23 44 59 71 88 111 123 0 -13 32 47 62 70 91 109 128 0 -15 23 41 56 76 95 112 0 0 -11 29 41 47 68 69 105 117 0 -10 30 37 64 73 86 111 119 0 -5 32 45 60 69 96 101 127 0 -15 24 48 62 65 96 97 115 0 -3 23 42 64 77 83 109 0 0 -16 18 40 52 69 89 102 112 0 -9 20 49 63 76 94 109 121 0 -15 20 33 66 77 84 110 127 0 -10 21 44 60 80 82 112 126 0 -16 26 41 58 81 92 107 125 0 -3 27 48 59 82 95 110 118 0 -10 27 49 57 71 89 101 124 0 -4 26 42 61 68 90 100 122 0 -6 26 44 50 75 85 101 118 0 -7 28 37 47 66 76 82 114 0 -12 19 43 52 80 88 104 121 0 -2 31 47 56 75 93 108 123 0 -1 31 36 59 81 87 104 124 0 -3 32 39 50 81 97 106 121 0 -12 24 34 54 79 90 98 120 0 -1 19 49 56 82 92 103 122 0 -7 21 35 61 70 93 106 125 0 -14 18 46 60 70 97 107 122 0 -8 31 39 61 63 86 98 127 128 -4 28 34 45 75 97 110 126 0 -16 30 45 63 72 95 100 113 0 -8 21 48 52 74 87 111 114 0 -9 32 46 58 68 83 113 123 0 -11 30 46 53 81 91 99 116 0 -5 29 49 58 78 85 112 120 0 -16 17 35 57 66 80 111 120 0 -1 19 51 54 -2 5 24 50 -3 38 44 52 -4 23 46 58 -6 30 36 63 -7 27 29 47 -8 10 48 55 -9 16 57 60 -11 12 40 61 -13 35 42 45 -14 22 34 62 -15 20 49 53 -17 18 25 32 -21 28 31 56 -26 33 37 41 -39 43 59 64 -1 18 22 64 -2 30 39 56 -3 7 49 54 -4 5 40 41 -6 42 55 60 -8 11 14 27 -9 31 33 38 -10 25 37 53 -12 13 15 28 -16 43 46 47 -17 24 44 45 -19 21 48 58 -20 23 34 63 -26 35 59 62 -29 50 51 57 -32 36 52 61 -1 6 28 41 -2 9 53 58 -3 5 55 64 -4 13 14 51 -7 30 35 48 -8 16 20 24 -10 23 52 57 -11 17 19 39 -12 33 34 43 -15 22 38 46 -18 21 26 49 -25 31 42 47 -27 36 58 59 -29 56 61 62 -32 34 48 50 -27 37 44 60 -40 45 54 63 -1 2 47 52 -3 13 16 21 -4 39 49 60 -5 20 25 62 -6 14 18 53 -7 12 24 26 -8 33 50 54 -9 23 45 64 -10 43 61 63 -11 31 44 51 -15 36 42 56 -17 46 55 57 -19 22 32 37 -28 40 57 59 -6 29 35 38 -23 28 30 37 -25 41 48 64 -1 13 20 26 -2 34 46 61 -3 34 36 39 -4 32 55 56 -5 19 31 45 -7 9 14 59 -8 18 28 35 -10 11 13 60 -12 47 50 58 -15 33 40 48 -16 17 38 41 -21 24 27 63 -22 24 30 53 -29 42 49 64 -43 51 52 62 -42 44 48 54 -1 25 38 61 -2 10 19 41 -3 18 47 63 -4 20 35 57 -5 23 51 60 -6 27 31 49 -7 15 39 45 -8 26 46 53 -9 12 32 62 -11 22 43 54 -14 16 50 55 -17 21 30 40 -29 33 44 59 -8 21 36 37 -37 52 56 58 -1 7 53 57 -2 17 28 62 -3 10 46 59 -4 36 45 47 -5 14 29 39 -6 15 25 54 -9 22 49 51 -11 16 26 34 -12 27 52 55 -13 24 43 56 -18 19 20 50 -23 32 38 40 -30 41 44 58 -31 35 60 64 -33 39 42 63 -5 30 59 61 -1 12 48 60 -2 3 4 37 -6 8 23 62 -7 21 25 34 -9 28 44 47 -10 17 27 35 -11 53 63 64 -13 40 49 52 -14 46 54 56 -15 31 50 61 -16 18 45 51 -19 29 43 55 -20 22 42 58 -24 36 41 57 -5 26 32 57 diff --git a/lib/ldpc/peg/peg-128-64-reg4.code b/lib/ldpc/peg/peg-128-64-reg4.code deleted file mode 100644 index 5e99ac6a..00000000 --- a/lib/ldpc/peg/peg-128-64-reg4.code +++ /dev/null @@ -1,67 +0,0 @@ -128 -64 -9 -1 17 33 50 67 83 98 114 0 -2 18 34 50 68 84 99 115 0 -3 19 35 51 69 85 100 115 0 -4 20 36 52 70 86 101 115 0 -2 20 35 53 71 87 102 113 128 -5 21 33 54 64 88 103 116 0 -6 19 37 55 72 89 98 117 0 -7 22 38 56 73 90 96 116 0 -8 23 34 57 72 91 104 118 0 -7 24 39 58 74 84 100 119 0 -9 22 40 59 74 92 105 120 0 -9 25 41 55 75 91 106 114 0 -10 25 36 51 67 74 107 121 0 -11 22 36 54 72 93 102 122 0 -12 25 42 60 76 89 103 123 0 -8 26 38 51 77 93 105 124 0 -13 27 40 61 77 94 99 119 0 -13 17 43 54 73 85 108 124 0 -1 28 40 62 71 84 108 125 0 -12 29 38 53 67 86 108 126 0 -14 28 43 51 78 94 96 117 0 -11 17 42 62 79 92 104 126 0 -4 29 39 57 65 87 109 116 0 -2 27 38 55 78 79 107 127 0 -13 24 44 53 66 83 103 117 0 -15 30 43 55 67 90 105 128 0 -6 22 45 48 78 88 106 119 0 -14 25 33 63 65 73 99 118 0 -6 31 46 64 80 95 102 125 0 -5 18 37 65 79 94 110 113 0 -14 23 44 59 71 88 111 123 0 -13 32 47 62 70 91 109 128 0 -15 23 41 56 76 95 112 0 0 -11 29 41 47 68 69 105 117 0 -10 30 37 64 73 86 111 119 0 -5 32 45 60 69 96 101 127 0 -15 24 48 62 65 96 97 115 0 -3 23 42 64 77 83 109 0 0 -16 18 40 52 69 89 102 112 0 -9 20 49 63 76 94 109 121 0 -15 20 33 66 77 84 110 127 0 -10 21 44 60 80 82 112 126 0 -16 26 41 58 81 92 107 125 0 -3 27 48 59 82 95 110 118 0 -10 27 49 57 71 89 101 124 0 -4 26 42 61 68 90 100 122 0 -6 26 44 50 75 85 101 118 0 -7 28 37 47 66 76 82 114 0 -12 19 43 52 80 88 104 121 0 -2 31 47 56 75 93 108 123 0 -1 31 36 59 81 87 104 124 0 -3 32 39 50 81 97 106 121 0 -12 24 34 54 79 90 98 120 0 -1 19 49 56 82 92 103 122 0 -7 21 35 61 70 93 106 125 0 -14 18 46 60 70 97 107 122 0 -8 31 39 61 63 86 98 127 128 -4 28 34 45 75 97 110 126 0 -16 30 45 63 72 95 100 113 0 -8 21 48 52 74 87 111 114 0 -9 32 46 58 68 83 113 123 0 -11 30 46 53 81 91 99 116 0 -5 29 49 58 78 85 112 120 0 -16 17 35 57 66 80 111 120 0 diff --git a/lib/ldpc/peg/peg-128-72-reg4.alist b/lib/ldpc/peg/peg-128-72-reg4.alist deleted file mode 100644 index 6bb420a5..00000000 --- a/lib/ldpc/peg/peg-128-72-reg4.alist +++ /dev/null @@ -1,188 +0,0 @@ -56 128 -10 4 -9 9 9 9 9 9 9 9 10 9 9 9 9 9 9 9 9 10 9 9 9 9 10 9 10 9 9 9 9 9 10 9 9 9 9 9 9 9 9 9 9 9 10 9 9 9 10 10 9 9 9 10 9 9 9 8 -4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 -1 15 30 44 58 71 84 100 115 0 -2 16 31 44 59 72 86 101 116 0 -3 17 31 45 60 73 87 102 117 0 -2 18 32 46 58 73 85 103 112 0 -4 19 32 47 61 74 88 104 118 0 -5 20 33 48 62 75 88 105 116 0 -6 19 34 49 63 76 89 105 119 0 -7 15 27 45 64 77 88 106 120 0 -8 15 35 50 59 75 90 107 121 127 -7 21 33 51 65 73 91 108 114 0 -9 22 30 46 59 78 92 99 122 0 -9 19 35 52 60 71 93 109 120 0 -10 20 31 53 63 79 93 107 123 0 -11 15 36 53 66 78 85 110 124 0 -8 23 37 49 67 71 86 111 118 0 -12 22 34 54 68 80 94 109 114 0 -1 24 34 52 65 75 87 97 123 0 -13 25 29 43 69 81 85 100 121 128 -12 17 38 55 63 82 90 101 125 0 -11 26 39 47 56 76 95 106 117 0 -2 27 40 49 69 74 94 108 117 0 -4 16 30 55 64 76 91 103 126 0 -13 17 28 47 65 80 96 111 124 126 -6 18 36 51 70 83 94 111 121 0 -13 16 34 48 57 82 95 112 120 127 -6 28 40 48 58 79 90 113 122 0 -5 27 41 46 67 83 91 109 127 0 -14 16 42 54 63 78 97 100 118 0 -13 27 39 52 70 84 90 114 118 0 -10 22 42 47 64 81 98 110 116 0 -11 22 29 55 60 84 97 108 111 127 -5 26 37 55 57 74 96 98 128 0 -3 21 35 54 62 82 98 104 113 0 -14 21 43 50 68 77 93 110 117 0 -9 24 33 56 69 72 89 110 112 0 -12 26 42 53 62 73 89 99 121 0 -10 25 35 41 57 76 97 101 122 0 -10 18 39 44 66 77 99 102 119 0 -3 29 40 44 61 83 93 106 125 0 -4 23 39 45 65 85 89 107 113 0 -6 26 30 43 61 80 86 108 123 0 -7 19 31 57 69 83 99 113 124 0 -3 24 37 43 66 84 92 105 120 126 -2 24 38 50 70 71 88 102 122 0 -1 20 32 51 68 81 86 102 124 0 -12 23 41 51 59 74 87 106 115 0 -14 28 37 46 62 72 95 114 115 125 -1 28 41 49 61 82 92 103 116 128 -7 25 38 56 60 75 98 103 115 0 -8 29 33 45 58 78 96 109 119 0 -4 25 36 54 67 77 96 105 123 0 -14 20 38 52 66 80 91 104 112 128 -8 18 42 56 68 79 87 104 125 0 -9 23 40 53 70 81 95 101 126 0 -11 21 32 48 67 72 94 107 119 0 -5 17 36 50 64 79 92 100 0 0 -1 17 45 48 -2 4 21 44 -3 33 39 43 -5 22 40 51 -6 27 32 56 -7 24 26 41 -8 10 42 49 -9 15 50 53 -11 12 35 54 -13 30 37 38 -14 20 31 55 -16 19 36 46 -18 23 25 29 -28 34 47 52 -1 8 9 14 -2 22 25 28 -3 19 23 56 -4 24 38 53 -5 7 12 42 -6 13 45 52 -10 33 34 55 -11 16 30 31 -15 40 46 54 -17 35 43 44 -18 37 49 51 -20 32 36 41 -8 21 27 29 -23 26 47 48 -18 31 39 50 -1 11 22 41 -2 3 13 42 -4 5 45 55 -6 10 35 50 -7 16 17 25 -9 12 33 37 -14 24 51 56 -15 32 43 47 -19 44 49 52 -20 29 38 40 -21 26 39 54 -27 37 46 48 -28 30 36 53 -18 34 41 43 -1 2 38 39 -3 8 40 50 -4 11 27 47 -5 20 23 30 -6 25 26 55 -7 15 21 48 -9 34 44 56 -10 24 45 46 -12 17 29 52 -13 14 36 54 -16 28 33 51 -19 22 31 32 -20 35 49 53 -25 32 37 42 -1 4 26 50 -2 9 11 46 -3 12 31 49 -5 39 41 48 -6 33 36 47 -7 13 19 28 -8 22 30 56 -10 17 23 40 -14 38 43 52 -15 27 51 55 -16 34 45 53 -18 21 35 42 -24 29 44 54 -1 12 15 44 -2 35 47 55 -3 4 10 36 -5 21 32 46 -6 9 17 49 -7 20 22 37 -8 34 38 51 -11 14 28 50 -13 26 53 56 -16 23 41 52 -18 30 45 54 -19 25 33 48 -24 27 39 42 -1 29 31 43 -4 14 18 40 -2 15 41 45 -3 17 46 53 -5 6 8 44 -7 35 36 40 -9 19 26 29 -10 22 27 52 -11 43 48 56 -12 13 34 39 -16 21 24 55 -20 25 47 54 -23 32 50 51 -17 28 31 37 -30 32 33 49 -11 36 38 42 -1 18 28 56 -2 19 37 54 -3 38 44 45 -4 22 48 49 -5 33 52 53 -6 7 43 51 -8 20 39 46 -9 13 40 55 -10 21 31 41 -12 16 27 50 -14 30 34 35 -15 23 24 31 -4 25 35 52 -26 33 40 42 -10 16 29 47 -1 46 47 49 -2 6 30 48 -3 20 21 34 -5 15 28 29 -7 38 50 55 -8 12 25 43 -9 18 24 36 -11 26 37 44 -13 17 41 51 -14 23 42 45 -19 39 47 53 -22 23 43 54 -9 25 27 31 -18 32 48 52 diff --git a/lib/ldpc/peg/peg-128-72-reg4.code b/lib/ldpc/peg/peg-128-72-reg4.code deleted file mode 100644 index 09108dbf..00000000 --- a/lib/ldpc/peg/peg-128-72-reg4.code +++ /dev/null @@ -1,59 +0,0 @@ -128 -56 -10 -1 15 30 44 58 71 84 100 115 0 -2 16 31 44 59 72 86 101 116 0 -3 17 31 45 60 73 87 102 117 0 -2 18 32 46 58 73 85 103 112 0 -4 19 32 47 61 74 88 104 118 0 -5 20 33 48 62 75 88 105 116 0 -6 19 34 49 63 76 89 105 119 0 -7 15 27 45 64 77 88 106 120 0 -8 15 35 50 59 75 90 107 121 127 -7 21 33 51 65 73 91 108 114 0 -9 22 30 46 59 78 92 99 122 0 -9 19 35 52 60 71 93 109 120 0 -10 20 31 53 63 79 93 107 123 0 -11 15 36 53 66 78 85 110 124 0 -8 23 37 49 67 71 86 111 118 0 -12 22 34 54 68 80 94 109 114 0 -1 24 34 52 65 75 87 97 123 0 -13 25 29 43 69 81 85 100 121 128 -12 17 38 55 63 82 90 101 125 0 -11 26 39 47 56 76 95 106 117 0 -2 27 40 49 69 74 94 108 117 0 -4 16 30 55 64 76 91 103 126 0 -13 17 28 47 65 80 96 111 124 126 -6 18 36 51 70 83 94 111 121 0 -13 16 34 48 57 82 95 112 120 127 -6 28 40 48 58 79 90 113 122 0 -5 27 41 46 67 83 91 109 127 0 -14 16 42 54 63 78 97 100 118 0 -13 27 39 52 70 84 90 114 118 0 -10 22 42 47 64 81 98 110 116 0 -11 22 29 55 60 84 97 108 111 127 -5 26 37 55 57 74 96 98 128 0 -3 21 35 54 62 82 98 104 113 0 -14 21 43 50 68 77 93 110 117 0 -9 24 33 56 69 72 89 110 112 0 -12 26 42 53 62 73 89 99 121 0 -10 25 35 41 57 76 97 101 122 0 -10 18 39 44 66 77 99 102 119 0 -3 29 40 44 61 83 93 106 125 0 -4 23 39 45 65 85 89 107 113 0 -6 26 30 43 61 80 86 108 123 0 -7 19 31 57 69 83 99 113 124 0 -3 24 37 43 66 84 92 105 120 126 -2 24 38 50 70 71 88 102 122 0 -1 20 32 51 68 81 86 102 124 0 -12 23 41 51 59 74 87 106 115 0 -14 28 37 46 62 72 95 114 115 125 -1 28 41 49 61 82 92 103 116 128 -7 25 38 56 60 75 98 103 115 0 -8 29 33 45 58 78 96 109 119 0 -4 25 36 54 67 77 96 105 123 0 -14 20 38 52 66 80 91 104 112 128 -8 18 42 56 68 79 87 104 125 0 -9 23 40 53 70 81 95 101 126 0 -11 21 32 48 67 72 94 107 119 0 -5 17 36 50 64 79 92 100 0 0 diff --git a/lib/ldpc/peg/peg-128-80-reg3.alist b/lib/ldpc/peg/peg-128-80-reg3.alist deleted file mode 100644 index e2d9e15f..00000000 --- a/lib/ldpc/peg/peg-128-80-reg3.alist +++ /dev/null @@ -1,180 +0,0 @@ -48 128 -8 3 -8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 -3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 17 34 51 66 81 99 113 -2 18 35 50 67 82 100 114 -3 19 36 52 68 82 101 115 -2 20 36 51 69 83 102 116 -4 19 37 53 66 84 103 117 -5 21 38 54 70 85 92 114 -6 22 39 55 66 85 96 118 -7 23 32 56 71 86 103 119 -8 20 40 55 72 86 104 120 -9 19 41 57 73 87 105 121 -10 24 36 56 74 88 106 122 -10 17 33 47 75 89 107 119 -11 21 42 51 76 87 108 123 -1 25 40 58 74 84 109 124 -12 22 42 49 77 90 110 122 -13 26 43 59 68 89 104 113 -13 22 44 57 75 91 106 125 -12 23 37 46 78 88 109 113 -3 27 34 60 65 87 111 126 -6 27 45 61 79 89 98 114 -14 28 34 62 72 92 107 125 -8 27 42 59 71 92 112 117 -15 20 46 57 79 93 101 117 -9 29 45 62 74 94 108 127 -8 30 38 63 73 95 110 125 -16 29 47 64 69 96 110 128 -16 23 48 63 76 94 111 121 -7 25 39 52 70 97 108 116 -4 26 45 63 67 83 90 126 -15 28 39 50 76 88 103 115 -15 26 33 58 65 97 102 127 -14 31 47 52 77 81 93 121 -14 24 37 61 71 82 99 116 -4 31 40 54 80 91 107 122 -5 32 41 58 77 98 111 120 -9 18 49 65 79 85 104 123 -10 30 43 60 69 84 112 123 -1 18 43 48 73 91 98 119 -3 21 46 64 67 86 112 118 -5 24 48 55 75 93 105 128 -2 32 44 62 80 95 99 124 -16 28 41 59 80 83 100 118 -11 33 35 53 72 96 109 115 -11 25 44 60 78 90 100 128 -6 31 35 56 70 95 102 126 -12 17 50 54 68 94 106 120 -13 29 38 53 78 97 105 124 -7 30 49 61 64 81 101 127 -1 14 38 -2 4 41 -3 19 39 -5 29 34 -6 35 40 -7 20 45 -8 28 48 -9 22 25 -10 24 36 -11 12 37 -13 43 44 -15 18 46 -16 17 47 -21 32 33 -23 30 31 -26 27 42 -1 12 46 -2 36 38 -3 5 10 -4 9 23 -6 13 39 -7 15 17 -8 18 27 -11 33 40 -14 28 44 -16 29 31 -19 20 22 -21 30 42 -24 26 47 -25 37 48 -32 34 45 -8 35 41 -12 31 43 -1 19 21 -2 43 45 -3 4 11 -5 18 33 -6 25 47 -7 28 30 -9 14 34 -10 35 42 -13 15 22 -16 37 38 -17 41 44 -20 24 29 -18 23 39 -12 26 32 -27 38 40 -15 36 48 -2 30 46 -1 4 13 -3 28 32 -5 43 47 -6 34 46 -7 9 40 -8 11 45 -10 17 23 -14 31 35 -16 22 42 -19 37 44 -20 33 48 -21 24 41 -25 27 29 -26 39 48 -19 31 36 -1 5 7 -2 29 39 -3 16 46 -4 26 37 -6 28 45 -8 22 33 -9 21 43 -10 25 38 -11 14 24 -12 17 40 -13 27 30 -15 32 35 -18 44 47 -20 23 36 -34 41 42 -1 32 48 -2 3 33 -4 29 42 -5 14 37 -6 7 36 -8 9 39 -10 13 19 -11 18 30 -12 16 20 -15 29 44 -17 34 38 -6 21 22 -23 32 40 -24 27 46 -25 41 45 -7 26 43 -28 31 47 -20 35 38 -1 33 41 -2 42 44 -3 23 48 -4 31 45 -5 8 30 -9 16 36 -10 40 47 -11 17 46 -12 21 34 -13 24 28 -14 18 43 -15 25 26 -19 27 35 -22 37 39 -1 16 18 -2 6 20 -3 30 43 -4 28 33 -5 22 23 -7 39 42 -8 12 38 -9 35 46 -10 27 32 -11 15 34 -13 36 37 -14 41 47 -17 21 25 -19 29 45 -24 31 48 -26 40 44 diff --git a/lib/ldpc/peg/peg-128-80-reg3.code b/lib/ldpc/peg/peg-128-80-reg3.code deleted file mode 100644 index 10064e07..00000000 --- a/lib/ldpc/peg/peg-128-80-reg3.code +++ /dev/null @@ -1,51 +0,0 @@ -128 -48 -8 -1 17 34 51 66 81 99 113 -2 18 35 50 67 82 100 114 -3 19 36 52 68 82 101 115 -2 20 36 51 69 83 102 116 -4 19 37 53 66 84 103 117 -5 21 38 54 70 85 92 114 -6 22 39 55 66 85 96 118 -7 23 32 56 71 86 103 119 -8 20 40 55 72 86 104 120 -9 19 41 57 73 87 105 121 -10 24 36 56 74 88 106 122 -10 17 33 47 75 89 107 119 -11 21 42 51 76 87 108 123 -1 25 40 58 74 84 109 124 -12 22 42 49 77 90 110 122 -13 26 43 59 68 89 104 113 -13 22 44 57 75 91 106 125 -12 23 37 46 78 88 109 113 -3 27 34 60 65 87 111 126 -6 27 45 61 79 89 98 114 -14 28 34 62 72 92 107 125 -8 27 42 59 71 92 112 117 -15 20 46 57 79 93 101 117 -9 29 45 62 74 94 108 127 -8 30 38 63 73 95 110 125 -16 29 47 64 69 96 110 128 -16 23 48 63 76 94 111 121 -7 25 39 52 70 97 108 116 -4 26 45 63 67 83 90 126 -15 28 39 50 76 88 103 115 -15 26 33 58 65 97 102 127 -14 31 47 52 77 81 93 121 -14 24 37 61 71 82 99 116 -4 31 40 54 80 91 107 122 -5 32 41 58 77 98 111 120 -9 18 49 65 79 85 104 123 -10 30 43 60 69 84 112 123 -1 18 43 48 73 91 98 119 -3 21 46 64 67 86 112 118 -5 24 48 55 75 93 105 128 -2 32 44 62 80 95 99 124 -16 28 41 59 80 83 100 118 -11 33 35 53 72 96 109 115 -11 25 44 60 78 90 100 128 -6 31 35 56 70 95 102 126 -12 17 50 54 68 94 106 120 -13 29 38 53 78 97 105 124 -7 30 49 61 64 81 101 127 diff --git a/lib/ldpc/peg/peg-128-80-reg4.alist b/lib/ldpc/peg/peg-128-80-reg4.alist deleted file mode 100644 index 2487ea9b..00000000 --- a/lib/ldpc/peg/peg-128-80-reg4.alist +++ /dev/null @@ -1,180 +0,0 @@ -48 128 -12 4 -11 11 11 11 11 11 11 11 11 11 11 11 11 10 11 11 11 10 10 11 10 11 10 11 10 10 10 10 10 11 10 12 11 11 10 11 11 11 11 11 10 10 11 10 10 11 11 10 -4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 -1 13 26 38 51 62 75 86 99 111 124 0 -2 13 27 39 49 63 76 87 100 112 121 0 -3 14 27 40 52 64 74 88 101 104 123 0 -2 15 28 41 53 65 77 89 102 113 125 0 -4 16 26 41 54 66 71 90 101 114 122 0 -5 15 29 40 55 67 78 91 98 110 126 0 -6 17 30 42 56 63 79 90 103 115 124 0 -7 18 25 43 56 68 80 87 104 113 122 0 -7 13 29 44 52 69 81 92 102 114 127 0 -8 14 29 42 57 66 77 86 97 116 119 0 -9 19 26 45 56 69 76 93 97 110 128 0 -9 14 28 46 54 68 82 91 99 112 118 0 -8 20 31 47 49 69 78 88 105 109 124 0 -1 20 32 42 52 70 76 94 106 117 0 0 -10 15 33 48 52 62 80 93 100 118 119 0 -11 18 31 39 48 67 83 94 97 114 125 0 -12 15 34 37 49 64 73 85 99 116 127 0 -2 21 25 45 55 64 83 92 103 119 0 0 -4 22 33 46 55 65 84 86 107 108 0 0 -11 16 27 45 53 70 79 95 107 111 126 0 -6 13 33 45 57 68 85 96 101 120 0 0 -12 17 25 38 58 67 76 96 107 118 123 0 -5 18 30 44 59 71 77 93 106 120 0 0 -6 20 28 43 50 72 83 86 95 121 127 0 -11 23 28 38 59 73 81 88 108 115 0 0 -10 19 32 49 60 67 75 89 101 108 0 0 -5 22 27 48 54 69 73 96 103 113 0 0 -12 23 35 47 50 62 79 97 106 122 0 0 -3 18 26 47 53 61 82 85 98 108 0 0 -9 22 31 41 58 60 72 87 106 115 116 0 -10 16 30 50 58 65 73 91 104 109 0 0 -10 24 36 41 57 61 78 94 103 111 123 127 -4 17 29 43 59 74 85 89 109 112 128 0 -3 21 34 38 60 63 77 95 105 114 128 0 -7 24 37 46 53 71 74 96 105 110 0 0 -6 19 34 47 51 70 81 91 100 123 125 0 -2 24 31 40 56 66 81 84 95 118 120 0 -1 14 30 37 48 72 78 92 107 122 128 0 -3 23 24 42 55 68 75 93 109 121 125 0 -12 22 32 43 51 71 82 88 102 119 126 0 -1 23 36 44 58 64 80 90 110 112 0 0 -7 19 35 40 59 65 82 90 111 117 0 0 -9 17 36 39 50 66 75 92 105 117 126 0 -4 21 35 39 57 70 80 98 99 115 0 0 -8 25 33 37 54 60 79 94 98 121 0 0 -8 16 34 46 61 62 83 87 102 117 120 0 -11 21 32 44 61 72 74 84 100 113 124 0 -5 20 35 36 51 63 84 89 104 116 0 0 -1 14 38 41 -2 4 18 37 -3 29 34 39 -5 19 33 44 -6 23 27 48 -7 21 24 36 -8 9 35 42 -10 13 45 46 -11 12 30 43 -15 26 31 32 -16 20 25 47 -17 22 28 40 -1 2 9 21 -3 10 12 38 -4 6 15 17 -5 20 31 46 -7 22 33 43 -8 16 23 29 -11 26 36 42 -13 14 24 48 -18 34 44 47 -19 27 30 40 -25 28 39 41 -32 35 37 39 -8 18 22 45 -1 5 11 29 -2 3 20 27 -4 12 24 25 -6 9 10 33 -7 23 31 38 -13 16 30 37 -14 26 40 47 -15 19 21 45 -17 34 36 46 -28 42 44 48 -32 41 43 48 -17 35 38 45 -1 22 25 34 -2 16 43 44 -3 6 37 42 -4 5 30 32 -7 10 14 39 -8 24 33 40 -9 23 41 47 -11 18 20 21 -12 19 35 46 -13 28 29 36 -15 16 27 38 -2 13 17 26 -24 28 31 43 -1 36 40 48 -3 9 14 15 -4 20 29 35 -5 12 27 45 -6 18 19 39 -7 8 11 37 -10 21 32 44 -22 30 31 41 -23 25 33 42 -26 30 34 45 -29 32 46 47 -1 15 28 46 -2 7 34 48 -3 17 18 41 -4 19 31 42 -5 10 37 43 -6 16 22 26 -8 12 21 39 -9 11 13 27 -14 20 36 44 -5 23 35 40 -24 30 38 47 -17 25 27 31 -3 33 35 47 -1 26 39 43 -2 11 14 22 -4 10 23 34 -6 13 32 38 -7 20 28 45 -8 15 41 44 -9 25 36 37 -12 29 40 42 -16 18 24 46 -19 37 47 48 -17 21 29 33 -1 10 19 24 -2 8 30 46 -3 13 25 40 -4 26 33 48 -5 7 41 42 -6 12 31 36 -9 18 38 43 -11 15 23 39 -14 16 32 45 -20 24 34 37 -21 22 27 35 -10 11 16 28 -6 29 44 45 -1 12 17 44 -2 15 36 47 -3 5 21 26 -4 9 40 46 -7 18 27 32 -3 8 31 48 -13 34 35 43 -14 23 28 30 -19 20 22 38 -19 25 26 29 -13 31 33 39 -6 11 35 41 -1 20 32 42 -2 12 33 41 -4 8 27 47 -5 9 16 34 -7 25 30 44 -10 17 30 48 -14 42 43 46 -12 15 22 37 -10 15 18 40 -21 23 37 46 -2 24 39 45 -5 8 28 38 -3 22 32 36 -1 7 13 47 -4 16 36 39 -6 20 40 43 -9 17 24 32 -11 33 34 38 diff --git a/lib/ldpc/peg/peg-128-80-reg4.code b/lib/ldpc/peg/peg-128-80-reg4.code deleted file mode 100644 index 572e6221..00000000 --- a/lib/ldpc/peg/peg-128-80-reg4.code +++ /dev/null @@ -1,51 +0,0 @@ -128 -48 -12 -1 13 26 38 51 62 75 86 99 111 124 0 -2 13 27 39 49 63 76 87 100 112 121 0 -3 14 27 40 52 64 74 88 101 104 123 0 -2 15 28 41 53 65 77 89 102 113 125 0 -4 16 26 41 54 66 71 90 101 114 122 0 -5 15 29 40 55 67 78 91 98 110 126 0 -6 17 30 42 56 63 79 90 103 115 124 0 -7 18 25 43 56 68 80 87 104 113 122 0 -7 13 29 44 52 69 81 92 102 114 127 0 -8 14 29 42 57 66 77 86 97 116 119 0 -9 19 26 45 56 69 76 93 97 110 128 0 -9 14 28 46 54 68 82 91 99 112 118 0 -8 20 31 47 49 69 78 88 105 109 124 0 -1 20 32 42 52 70 76 94 106 117 0 0 -10 15 33 48 52 62 80 93 100 118 119 0 -11 18 31 39 48 67 83 94 97 114 125 0 -12 15 34 37 49 64 73 85 99 116 127 0 -2 21 25 45 55 64 83 92 103 119 0 0 -4 22 33 46 55 65 84 86 107 108 0 0 -11 16 27 45 53 70 79 95 107 111 126 0 -6 13 33 45 57 68 85 96 101 120 0 0 -12 17 25 38 58 67 76 96 107 118 123 0 -5 18 30 44 59 71 77 93 106 120 0 0 -6 20 28 43 50 72 83 86 95 121 127 0 -11 23 28 38 59 73 81 88 108 115 0 0 -10 19 32 49 60 67 75 89 101 108 0 0 -5 22 27 48 54 69 73 96 103 113 0 0 -12 23 35 47 50 62 79 97 106 122 0 0 -3 18 26 47 53 61 82 85 98 108 0 0 -9 22 31 41 58 60 72 87 106 115 116 0 -10 16 30 50 58 65 73 91 104 109 0 0 -10 24 36 41 57 61 78 94 103 111 123 127 -4 17 29 43 59 74 85 89 109 112 128 0 -3 21 34 38 60 63 77 95 105 114 128 0 -7 24 37 46 53 71 74 96 105 110 0 0 -6 19 34 47 51 70 81 91 100 123 125 0 -2 24 31 40 56 66 81 84 95 118 120 0 -1 14 30 37 48 72 78 92 107 122 128 0 -3 23 24 42 55 68 75 93 109 121 125 0 -12 22 32 43 51 71 82 88 102 119 126 0 -1 23 36 44 58 64 80 90 110 112 0 0 -7 19 35 40 59 65 82 90 111 117 0 0 -9 17 36 39 50 66 75 92 105 117 126 0 -4 21 35 39 57 70 80 98 99 115 0 0 -8 25 33 37 54 60 79 94 98 121 0 0 -8 16 34 46 61 62 83 87 102 117 120 0 -11 21 32 44 61 72 74 84 100 113 124 0 -5 20 35 36 51 63 84 89 104 116 0 0 diff --git a/lib/ldpc/peg/peg-144-72-reg4.alist b/lib/ldpc/peg/peg-144-72-reg4.alist deleted file mode 100644 index cad34471..00000000 --- a/lib/ldpc/peg/peg-144-72-reg4.alist +++ /dev/null @@ -1,220 +0,0 @@ -72 144 -9 4 -8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 -4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 -1 19 38 57 74 94 110 128 0 -2 20 39 58 75 95 111 129 0 -3 21 40 59 76 95 108 130 0 -4 22 41 60 69 96 112 131 0 -2 19 42 60 77 97 113 132 0 -5 20 43 61 78 98 114 133 0 -6 22 44 62 79 99 115 127 0 -7 23 41 58 73 100 113 134 0 -8 23 45 63 80 101 114 135 0 -7 24 46 64 81 98 112 136 0 -9 25 47 64 75 102 116 130 0 -9 22 48 59 82 98 117 137 0 -10 25 49 65 80 99 118 132 0 -11 26 50 66 75 96 119 127 0 -12 27 43 67 82 103 120 136 0 -13 28 50 68 82 97 121 138 0 -8 29 47 62 83 104 121 132 0 -13 25 38 53 61 100 111 135 0 -14 22 38 63 83 95 122 133 0 -15 30 41 63 81 105 123 129 0 -1 28 51 64 80 104 119 126 0 -12 24 40 69 84 100 124 133 0 -16 23 52 65 77 106 110 139 0 -11 31 37 55 85 101 118 140 0 -13 32 48 70 77 94 122 140 0 -2 27 53 71 78 101 110 131 0 -4 29 46 71 77 88 124 130 0 -14 24 49 56 86 107 119 130 144 -14 33 47 70 87 108 115 137 0 -6 32 52 69 78 91 125 141 0 -15 26 51 61 76 86 117 140 0 -17 33 51 59 88 109 113 142 0 -6 31 40 54 88 102 111 136 0 -5 33 54 62 86 103 118 141 0 -13 24 44 72 75 103 114 142 0 -15 34 47 67 85 99 110 143 0 -18 28 49 58 89 92 122 131 0 -18 21 38 68 85 91 115 129 0 -11 33 36 58 84 106 121 128 0 -10 20 50 59 90 94 120 135 0 -5 29 42 55 89 106 117 136 0 -3 30 45 61 84 104 115 144 0 -15 20 52 57 89 102 126 142 0 -16 35 53 72 80 102 125 143 0 -9 26 39 71 74 105 125 139 0 -16 30 44 71 85 90 112 134 0 -17 25 55 69 76 105 119 134 0 -10 35 37 63 91 108 113 144 0 -17 27 44 57 87 92 123 143 0 -3 32 46 67 92 96 109 0 0 -10 36 46 60 93 107 111 133 0 -4 35 54 56 74 100 117 138 0 -6 34 39 66 87 93 118 138 0 -7 34 48 55 83 96 120 139 0 -12 35 42 68 79 105 112 141 0 -2 31 51 67 79 107 116 128 0 -1 29 40 73 90 101 125 138 0 -3 19 37 72 87 99 122 139 0 -12 26 45 65 73 92 121 137 0 -14 30 42 66 74 109 114 140 0 -1 36 48 56 81 97 116 134 0 -7 19 50 62 91 107 109 143 0 -17 23 56 70 78 93 120 129 0 -8 36 53 68 86 108 123 142 0 -4 21 39 70 89 98 123 132 0 -18 27 54 66 81 104 106 137 0 -8 31 49 57 82 93 124 127 0 -9 37 43 73 84 95 126 131 0 -18 34 45 72 88 94 116 141 0 -11 21 52 64 79 103 124 135 0 -5 32 41 65 90 97 126 128 0 -16 28 43 60 76 83 127 144 0 -1 21 57 61 -2 5 26 56 -3 42 50 58 -4 27 52 65 -6 34 41 71 -7 30 33 53 -8 10 54 62 -9 17 64 67 -11 12 45 68 -13 40 48 51 -14 24 39 70 -15 22 55 59 -16 18 25 35 -19 28 29 60 -20 31 36 43 -23 44 46 72 -32 47 49 63 -37 38 66 69 -1 5 58 62 -2 6 40 43 -3 38 65 70 -4 7 12 19 -8 9 23 63 -10 22 28 35 -11 13 18 47 -14 31 45 59 -15 26 49 66 -16 21 37 72 -17 27 41 57 -20 42 46 60 -24 33 56 67 -25 30 50 71 -29 32 34 39 -36 53 54 69 -44 48 52 55 -39 51 61 64 -24 48 58 68 -1 18 19 38 -2 45 53 65 -3 22 33 57 -4 8 20 71 -5 41 55 60 -6 15 68 72 -7 35 46 49 -9 42 59 69 -10 27 50 51 -11 17 29 36 -12 25 54 61 -13 28 37 67 -14 16 40 62 -21 31 32 56 -23 30 43 70 -18 26 44 64 -33 34 52 66 -24 41 47 54 -28 52 61 63 -1 43 49 67 -2 8 37 39 -3 12 32 40 -4 5 51 72 -6 18 31 42 -7 17 34 62 -9 19 20 48 -10 11 21 70 -13 23 59 71 -14 53 60 66 -15 36 50 56 -16 38 55 64 -4 22 30 47 -25 29 63 65 -26 27 45 46 -35 44 58 69 -8 57 59 68 -1 45 52 60 -2 11 14 35 -3 31 47 72 -5 23 25 27 -6 26 30 63 -7 55 56 70 -9 13 21 44 -10 20 61 66 -12 15 16 67 -17 19 54 72 -22 39 42 68 -24 36 38 46 -28 31 34 64 -29 49 53 58 -27 32 33 69 -37 41 43 65 -40 46 57 71 -30 38 48 62 -37 49 50 59 -51 53 63 67 -1 25 40 69 -2 3 19 68 -4 14 50 54 -5 16 61 71 -6 10 12 65 -7 13 36 58 -8 18 22 52 -9 24 26 57 -11 33 43 44 -15 34 35 70 -17 21 42 66 -20 45 47 55 -23 39 41 66 -28 51 56 62 -3 29 48 64 -32 50 60 62 -1 23 26 36 -2 18 33 51 -4 10 46 55 -5 8 32 48 -6 9 35 60 -7 29 38 42 -11 56 61 69 -12 31 41 52 -13 24 34 53 -14 21 28 47 -15 40 54 63 -16 17 39 59 -19 25 37 58 -20 49 64 65 -22 27 67 70 -30 44 45 57 -21 43 68 71 -7 14 67 72 -1 39 56 71 -2 20 38 63 -3 11 27 28 -4 26 37 68 -5 13 17 65 -6 19 22 51 -8 46 47 61 -9 18 40 70 -10 15 33 41 -12 29 59 66 -16 52 53 57 -23 45 54 58 -24 25 31 60 -30 34 55 69 -32 35 43 64 -36 44 49 62 -28 42 48 72 diff --git a/lib/ldpc/peg/peg-144-72-reg4.code b/lib/ldpc/peg/peg-144-72-reg4.code deleted file mode 100644 index 78747e92..00000000 --- a/lib/ldpc/peg/peg-144-72-reg4.code +++ /dev/null @@ -1,75 +0,0 @@ -144 -72 -9 -1 19 38 57 74 94 110 128 0 -2 20 39 58 75 95 111 129 0 -3 21 40 59 76 95 108 130 0 -4 22 41 60 69 96 112 131 0 -2 19 42 60 77 97 113 132 0 -5 20 43 61 78 98 114 133 0 -6 22 44 62 79 99 115 127 0 -7 23 41 58 73 100 113 134 0 -8 23 45 63 80 101 114 135 0 -7 24 46 64 81 98 112 136 0 -9 25 47 64 75 102 116 130 0 -9 22 48 59 82 98 117 137 0 -10 25 49 65 80 99 118 132 0 -11 26 50 66 75 96 119 127 0 -12 27 43 67 82 103 120 136 0 -13 28 50 68 82 97 121 138 0 -8 29 47 62 83 104 121 132 0 -13 25 38 53 61 100 111 135 0 -14 22 38 63 83 95 122 133 0 -15 30 41 63 81 105 123 129 0 -1 28 51 64 80 104 119 126 0 -12 24 40 69 84 100 124 133 0 -16 23 52 65 77 106 110 139 0 -11 31 37 55 85 101 118 140 0 -13 32 48 70 77 94 122 140 0 -2 27 53 71 78 101 110 131 0 -4 29 46 71 77 88 124 130 0 -14 24 49 56 86 107 119 130 144 -14 33 47 70 87 108 115 137 0 -6 32 52 69 78 91 125 141 0 -15 26 51 61 76 86 117 140 0 -17 33 51 59 88 109 113 142 0 -6 31 40 54 88 102 111 136 0 -5 33 54 62 86 103 118 141 0 -13 24 44 72 75 103 114 142 0 -15 34 47 67 85 99 110 143 0 -18 28 49 58 89 92 122 131 0 -18 21 38 68 85 91 115 129 0 -11 33 36 58 84 106 121 128 0 -10 20 50 59 90 94 120 135 0 -5 29 42 55 89 106 117 136 0 -3 30 45 61 84 104 115 144 0 -15 20 52 57 89 102 126 142 0 -16 35 53 72 80 102 125 143 0 -9 26 39 71 74 105 125 139 0 -16 30 44 71 85 90 112 134 0 -17 25 55 69 76 105 119 134 0 -10 35 37 63 91 108 113 144 0 -17 27 44 57 87 92 123 143 0 -3 32 46 67 92 96 109 0 0 -10 36 46 60 93 107 111 133 0 -4 35 54 56 74 100 117 138 0 -6 34 39 66 87 93 118 138 0 -7 34 48 55 83 96 120 139 0 -12 35 42 68 79 105 112 141 0 -2 31 51 67 79 107 116 128 0 -1 29 40 73 90 101 125 138 0 -3 19 37 72 87 99 122 139 0 -12 26 45 65 73 92 121 137 0 -14 30 42 66 74 109 114 140 0 -1 36 48 56 81 97 116 134 0 -7 19 50 62 91 107 109 143 0 -17 23 56 70 78 93 120 129 0 -8 36 53 68 86 108 123 142 0 -4 21 39 70 89 98 123 132 0 -18 27 54 66 81 104 106 137 0 -8 31 49 57 82 93 124 127 0 -9 37 43 73 84 95 126 131 0 -18 34 45 72 88 94 116 141 0 -11 21 52 64 79 103 124 135 0 -5 32 41 65 90 97 126 128 0 -16 28 43 60 76 83 127 144 0 diff --git a/lib/ldpc/peg/peg2alist b/lib/ldpc/peg/peg2alist deleted file mode 100755 index da710f92..00000000 --- a/lib/ldpc/peg/peg2alist +++ /dev/null @@ -1,37 +0,0 @@ -#!/opt/local/bin/octave -qf -# read a parity check matrix produced by the peg algorithm and -# convert to alist format so that it can be read using alist_to_pcheck -arg_list=argv(); -filename=arg_list{1}; -fid=fopen(filename,"r"); -N=fscanf(fid,"%d",[1]); -M=fscanf(fid,"%d",[1]); -pcheck=zeros(M,N); -max_bits_in_check=fscanf(fid,"%d",[1]); -for i=1:M - vec=fscanf(fid,"%d",[max_bits_in_check]); - pcheck(i,vec(vec>0))=1; -endfor - -max_bits_in_check2=max(sum(pcheck')); -max_checks_per_bit=max(sum(pcheck)); -printf("%d %d\n",M,N); -printf("%d %d\n",max_bits_in_check2,max_checks_per_bit); -printf("%d ",sum(pcheck')); -printf("\n"); -printf("%d ",sum(pcheck)); -printf("\n"); -for i=1:M - vec=find(pcheck(i,:)>0); - pr=zeros(1,max_bits_in_check2); - pr(1:size(vec)(2))=vec; - printf("%d ",pr); - printf("\n"); -endfor -for i=1:N - vec=find(pcheck(:,i)>0); - pr=zeros(1,max_checks_per_bit); - pr(1:size(vec)(1))=vec; - printf("%d ",pr) - printf("\n"); -endfor diff --git a/lib/ldpc/peg/peg_128_80.pchk b/lib/ldpc/peg/peg_128_80.pchk deleted file mode 100644 index c3dc1b1b..00000000 --- a/lib/ldpc/peg/peg_128_80.pchk +++ /dev/null @@ -1,51 +0,0 @@ -128 -48 -9 -1 17 34 51 66 81 99 111 124 -2 18 35 50 67 82 100 112 125 -3 19 36 52 68 82 101 111 126 -2 20 36 51 69 83 102 113 127 -4 19 37 53 66 84 103 114 128 -5 21 38 54 70 85 92 114 0 -6 22 39 55 66 85 96 110 0 -7 23 32 56 71 86 103 115 0 -8 20 40 55 72 86 104 116 0 -9 19 41 57 73 87 105 116 0 -10 24 36 56 74 88 105 117 125 -10 17 33 47 75 89 106 118 128 -11 21 42 51 76 87 107 119 0 -1 25 40 58 74 84 107 113 0 -12 22 42 49 77 90 108 118 125 -13 26 43 59 68 89 104 120 124 -13 22 44 57 75 91 109 113 0 -12 23 37 46 78 88 107 112 0 -3 27 34 60 65 87 109 118 0 -6 27 45 61 79 89 98 112 0 -14 28 34 62 72 92 106 112 127 -8 27 42 59 71 92 110 121 126 -15 20 46 57 79 93 101 115 124 -9 29 45 62 74 94 108 121 0 -8 30 38 63 73 95 109 111 128 -16 29 47 64 69 96 109 117 126 -16 23 48 63 76 94 110 116 125 -7 25 39 52 70 97 106 117 124 -4 26 45 63 67 83 90 119 123 -15 28 39 50 76 88 103 121 123 -15 26 33 58 65 97 102 122 0 -14 31 47 52 77 81 93 116 0 -14 24 37 61 71 82 99 122 0 -4 31 40 54 80 91 106 115 122 -5 32 41 58 77 98 104 117 0 -9 18 49 65 79 85 104 119 128 -10 30 43 60 69 84 108 115 123 -1 18 43 48 73 91 98 114 127 -3 21 46 64 67 86 108 113 0 -5 24 48 55 75 93 107 120 126 -2 32 44 62 80 95 99 114 0 -16 28 41 59 80 83 100 118 0 -11 33 35 53 72 96 105 111 0 -11 25 44 60 78 90 100 120 122 -6 31 35 56 70 95 102 121 0 -12 17 50 54 68 94 105 119 0 -13 29 38 53 78 97 110 123 0 -7 30 49 61 64 81 101 120 127 diff --git a/lib/ldpc/peg/sfpeg1.code b/lib/ldpc/peg/sfpeg1.code deleted file mode 100644 index c3dc1b1b..00000000 --- a/lib/ldpc/peg/sfpeg1.code +++ /dev/null @@ -1,51 +0,0 @@ -128 -48 -9 -1 17 34 51 66 81 99 111 124 -2 18 35 50 67 82 100 112 125 -3 19 36 52 68 82 101 111 126 -2 20 36 51 69 83 102 113 127 -4 19 37 53 66 84 103 114 128 -5 21 38 54 70 85 92 114 0 -6 22 39 55 66 85 96 110 0 -7 23 32 56 71 86 103 115 0 -8 20 40 55 72 86 104 116 0 -9 19 41 57 73 87 105 116 0 -10 24 36 56 74 88 105 117 125 -10 17 33 47 75 89 106 118 128 -11 21 42 51 76 87 107 119 0 -1 25 40 58 74 84 107 113 0 -12 22 42 49 77 90 108 118 125 -13 26 43 59 68 89 104 120 124 -13 22 44 57 75 91 109 113 0 -12 23 37 46 78 88 107 112 0 -3 27 34 60 65 87 109 118 0 -6 27 45 61 79 89 98 112 0 -14 28 34 62 72 92 106 112 127 -8 27 42 59 71 92 110 121 126 -15 20 46 57 79 93 101 115 124 -9 29 45 62 74 94 108 121 0 -8 30 38 63 73 95 109 111 128 -16 29 47 64 69 96 109 117 126 -16 23 48 63 76 94 110 116 125 -7 25 39 52 70 97 106 117 124 -4 26 45 63 67 83 90 119 123 -15 28 39 50 76 88 103 121 123 -15 26 33 58 65 97 102 122 0 -14 31 47 52 77 81 93 116 0 -14 24 37 61 71 82 99 122 0 -4 31 40 54 80 91 106 115 122 -5 32 41 58 77 98 104 117 0 -9 18 49 65 79 85 104 119 128 -10 30 43 60 69 84 108 115 123 -1 18 43 48 73 91 98 114 127 -3 21 46 64 67 86 108 113 0 -5 24 48 55 75 93 107 120 126 -2 32 44 62 80 95 99 114 0 -16 28 41 59 80 83 100 118 0 -11 33 35 53 72 96 105 111 0 -11 25 44 60 78 90 100 120 122 -6 31 35 56 70 95 102 121 0 -12 17 50 54 68 94 105 119 0 -13 29 38 53 78 97 110 123 0 -7 30 49 61 64 81 101 120 127 diff --git a/lib/ldpc/peg/sfpeg1.deg b/lib/ldpc/peg/sfpeg1.deg deleted file mode 100644 index 7d208a69..00000000 --- a/lib/ldpc/peg/sfpeg1.deg +++ /dev/null @@ -1,3 +0,0 @@ -2 -3 4 -.8 .2 diff --git a/lib/ldpc/peg/sfpeg2.alist b/lib/ldpc/peg/sfpeg2.alist deleted file mode 100644 index 410bae7e..00000000 --- a/lib/ldpc/peg/sfpeg2.alist +++ /dev/null @@ -1,180 +0,0 @@ -48 128 -9 4 -9 9 8 8 8 8 8 8 8 8 8 9 8 9 8 8 8 9 8 8 9 8 8 9 8 8 8 9 8 8 9 8 8 8 9 8 9 8 8 8 8 8 8 8 9 8 8 8 -3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 -1 17 34 51 66 81 99 113 127 -2 18 35 50 67 82 100 114 128 -3 19 36 52 68 82 101 115 0 -2 20 36 51 69 83 102 116 0 -4 19 37 53 66 84 103 117 0 -5 21 38 54 70 85 92 114 0 -6 22 39 55 66 85 96 118 0 -7 23 32 56 71 86 103 119 0 -8 20 40 55 72 86 104 120 0 -9 19 41 57 73 87 105 118 0 -10 24 36 56 74 88 106 120 0 -10 17 33 47 75 89 107 121 126 -11 21 42 51 76 87 108 122 0 -1 25 40 58 74 84 109 122 126 -12 22 42 49 77 90 110 123 0 -13 26 43 59 68 89 104 113 0 -13 22 44 57 75 91 106 124 0 -12 23 37 46 78 88 109 113 128 -3 27 34 60 65 87 111 123 0 -6 27 45 61 79 89 98 114 0 -14 28 34 62 72 92 107 122 125 -8 27 42 59 71 92 112 117 0 -15 20 46 57 79 93 101 117 0 -9 29 45 62 74 94 108 119 128 -8 30 38 63 73 95 110 124 0 -16 29 47 64 69 96 110 125 0 -16 23 48 63 76 94 111 120 0 -7 25 39 52 70 97 108 116 127 -4 26 45 63 67 83 90 121 0 -15 28 39 50 76 88 103 115 0 -15 26 33 58 65 97 102 125 128 -14 31 47 52 77 81 93 120 0 -14 24 37 61 71 82 99 116 0 -4 31 40 54 80 91 107 119 0 -5 32 41 58 77 98 111 124 127 -9 18 49 65 79 85 104 124 0 -10 30 43 60 69 84 112 119 127 -1 18 43 48 73 91 98 121 0 -3 21 46 64 67 86 112 118 0 -5 24 48 55 75 93 105 122 0 -2 32 44 62 80 95 99 118 0 -16 28 41 59 80 83 100 123 0 -11 33 35 53 72 96 109 115 0 -11 25 44 60 78 90 100 117 0 -6 31 35 56 70 95 102 123 126 -12 17 50 54 68 94 106 125 0 -13 29 38 53 78 97 105 121 0 -7 30 49 61 64 81 101 126 0 -1 14 38 0 -2 4 41 0 -3 19 39 0 -5 29 34 0 -6 35 40 0 -7 20 45 0 -8 28 48 0 -9 22 25 0 -10 24 36 0 -11 12 37 0 -13 43 44 0 -15 18 46 0 -16 17 47 0 -21 32 33 0 -23 30 31 0 -26 27 42 0 -1 12 46 0 -2 36 38 0 -3 5 10 0 -4 9 23 0 -6 13 39 0 -7 15 17 0 -8 18 27 0 -11 33 40 0 -14 28 44 0 -16 29 31 0 -19 20 22 0 -21 30 42 0 -24 26 47 0 -25 37 48 0 -32 34 45 0 -8 35 41 0 -12 31 43 0 -1 19 21 0 -2 43 45 0 -3 4 11 0 -5 18 33 0 -6 25 47 0 -7 28 30 0 -9 14 34 0 -10 35 42 0 -13 15 22 0 -16 37 38 0 -17 41 44 0 -20 24 29 0 -18 23 39 0 -12 26 32 0 -27 38 40 0 -15 36 48 0 -2 30 46 0 -1 4 13 0 -3 28 32 0 -5 43 47 0 -6 34 46 0 -7 9 40 0 -8 11 45 0 -10 17 23 0 -14 31 35 0 -16 22 42 0 -19 37 44 0 -20 33 48 0 -21 24 41 0 -25 27 29 0 -26 39 48 0 -19 31 36 0 -1 5 7 0 -2 29 39 0 -3 16 46 0 -4 26 37 0 -6 28 45 0 -8 22 33 0 -9 21 43 0 -10 25 38 0 -11 14 24 0 -12 17 40 0 -13 27 30 0 -15 32 35 0 -18 44 47 0 -20 23 36 0 -34 41 42 0 -1 32 48 0 -2 3 33 0 -4 29 42 0 -5 14 37 0 -6 7 36 0 -8 9 39 0 -10 13 19 0 -11 18 30 0 -12 16 20 0 -15 29 44 0 -17 34 38 0 -6 21 22 0 -23 32 40 0 -24 27 46 0 -25 41 45 0 -7 26 43 0 -28 31 47 0 -20 35 38 0 -1 33 41 0 -2 42 44 0 -3 23 48 0 -4 31 45 0 -5 8 30 0 -9 16 36 0 -10 40 47 0 -11 17 46 0 -12 21 34 0 -13 24 28 0 -14 18 43 0 -15 25 26 0 -19 27 35 0 -22 37 39 0 -1 16 18 0 -2 6 20 0 -3 30 43 0 -4 28 33 0 -5 22 23 44 -7 10 39 41 -8 24 34 37 -9 11 27 32 -12 29 38 47 -13 14 21 40 -15 19 42 45 -17 25 35 36 -21 26 31 46 -12 14 45 48 -1 28 35 37 -2 18 24 31 diff --git a/lib/ldpc/peg/sfpeg2.code b/lib/ldpc/peg/sfpeg2.code deleted file mode 100644 index 0082bd37..00000000 --- a/lib/ldpc/peg/sfpeg2.code +++ /dev/null @@ -1,51 +0,0 @@ -128 -48 -9 -1 17 34 51 66 81 99 113 127 -2 18 35 50 67 82 100 114 128 -3 19 36 52 68 82 101 115 0 -2 20 36 51 69 83 102 116 0 -4 19 37 53 66 84 103 117 0 -5 21 38 54 70 85 92 114 0 -6 22 39 55 66 85 96 118 0 -7 23 32 56 71 86 103 119 0 -8 20 40 55 72 86 104 120 0 -9 19 41 57 73 87 105 118 0 -10 24 36 56 74 88 106 120 0 -10 17 33 47 75 89 107 121 126 -11 21 42 51 76 87 108 122 0 -1 25 40 58 74 84 109 122 126 -12 22 42 49 77 90 110 123 0 -13 26 43 59 68 89 104 113 0 -13 22 44 57 75 91 106 124 0 -12 23 37 46 78 88 109 113 128 -3 27 34 60 65 87 111 123 0 -6 27 45 61 79 89 98 114 0 -14 28 34 62 72 92 107 122 125 -8 27 42 59 71 92 112 117 0 -15 20 46 57 79 93 101 117 0 -9 29 45 62 74 94 108 119 128 -8 30 38 63 73 95 110 124 0 -16 29 47 64 69 96 110 125 0 -16 23 48 63 76 94 111 120 0 -7 25 39 52 70 97 108 116 127 -4 26 45 63 67 83 90 121 0 -15 28 39 50 76 88 103 115 0 -15 26 33 58 65 97 102 125 128 -14 31 47 52 77 81 93 120 0 -14 24 37 61 71 82 99 116 0 -4 31 40 54 80 91 107 119 0 -5 32 41 58 77 98 111 124 127 -9 18 49 65 79 85 104 124 0 -10 30 43 60 69 84 112 119 127 -1 18 43 48 73 91 98 121 0 -3 21 46 64 67 86 112 118 0 -5 24 48 55 75 93 105 122 0 -2 32 44 62 80 95 99 118 0 -16 28 41 59 80 83 100 123 0 -11 33 35 53 72 96 109 115 0 -11 25 44 60 78 90 100 117 0 -6 31 35 56 70 95 102 123 126 -12 17 50 54 68 94 106 125 0 -13 29 38 53 78 97 105 121 0 -7 30 49 61 64 81 101 126 0 diff --git a/lib/ldpc/peg/sfpeg2.deg b/lib/ldpc/peg/sfpeg2.deg deleted file mode 100644 index fb023b77..00000000 --- a/lib/ldpc/peg/sfpeg2.deg +++ /dev/null @@ -1,3 +0,0 @@ -2 -3 4 -.9 .1 diff --git a/lib/ldpc/peg/sfpeg3.alist b/lib/ldpc/peg/sfpeg3.alist deleted file mode 100644 index e2d9e15f..00000000 --- a/lib/ldpc/peg/sfpeg3.alist +++ /dev/null @@ -1,180 +0,0 @@ -48 128 -8 3 -8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 -3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 17 34 51 66 81 99 113 -2 18 35 50 67 82 100 114 -3 19 36 52 68 82 101 115 -2 20 36 51 69 83 102 116 -4 19 37 53 66 84 103 117 -5 21 38 54 70 85 92 114 -6 22 39 55 66 85 96 118 -7 23 32 56 71 86 103 119 -8 20 40 55 72 86 104 120 -9 19 41 57 73 87 105 121 -10 24 36 56 74 88 106 122 -10 17 33 47 75 89 107 119 -11 21 42 51 76 87 108 123 -1 25 40 58 74 84 109 124 -12 22 42 49 77 90 110 122 -13 26 43 59 68 89 104 113 -13 22 44 57 75 91 106 125 -12 23 37 46 78 88 109 113 -3 27 34 60 65 87 111 126 -6 27 45 61 79 89 98 114 -14 28 34 62 72 92 107 125 -8 27 42 59 71 92 112 117 -15 20 46 57 79 93 101 117 -9 29 45 62 74 94 108 127 -8 30 38 63 73 95 110 125 -16 29 47 64 69 96 110 128 -16 23 48 63 76 94 111 121 -7 25 39 52 70 97 108 116 -4 26 45 63 67 83 90 126 -15 28 39 50 76 88 103 115 -15 26 33 58 65 97 102 127 -14 31 47 52 77 81 93 121 -14 24 37 61 71 82 99 116 -4 31 40 54 80 91 107 122 -5 32 41 58 77 98 111 120 -9 18 49 65 79 85 104 123 -10 30 43 60 69 84 112 123 -1 18 43 48 73 91 98 119 -3 21 46 64 67 86 112 118 -5 24 48 55 75 93 105 128 -2 32 44 62 80 95 99 124 -16 28 41 59 80 83 100 118 -11 33 35 53 72 96 109 115 -11 25 44 60 78 90 100 128 -6 31 35 56 70 95 102 126 -12 17 50 54 68 94 106 120 -13 29 38 53 78 97 105 124 -7 30 49 61 64 81 101 127 -1 14 38 -2 4 41 -3 19 39 -5 29 34 -6 35 40 -7 20 45 -8 28 48 -9 22 25 -10 24 36 -11 12 37 -13 43 44 -15 18 46 -16 17 47 -21 32 33 -23 30 31 -26 27 42 -1 12 46 -2 36 38 -3 5 10 -4 9 23 -6 13 39 -7 15 17 -8 18 27 -11 33 40 -14 28 44 -16 29 31 -19 20 22 -21 30 42 -24 26 47 -25 37 48 -32 34 45 -8 35 41 -12 31 43 -1 19 21 -2 43 45 -3 4 11 -5 18 33 -6 25 47 -7 28 30 -9 14 34 -10 35 42 -13 15 22 -16 37 38 -17 41 44 -20 24 29 -18 23 39 -12 26 32 -27 38 40 -15 36 48 -2 30 46 -1 4 13 -3 28 32 -5 43 47 -6 34 46 -7 9 40 -8 11 45 -10 17 23 -14 31 35 -16 22 42 -19 37 44 -20 33 48 -21 24 41 -25 27 29 -26 39 48 -19 31 36 -1 5 7 -2 29 39 -3 16 46 -4 26 37 -6 28 45 -8 22 33 -9 21 43 -10 25 38 -11 14 24 -12 17 40 -13 27 30 -15 32 35 -18 44 47 -20 23 36 -34 41 42 -1 32 48 -2 3 33 -4 29 42 -5 14 37 -6 7 36 -8 9 39 -10 13 19 -11 18 30 -12 16 20 -15 29 44 -17 34 38 -6 21 22 -23 32 40 -24 27 46 -25 41 45 -7 26 43 -28 31 47 -20 35 38 -1 33 41 -2 42 44 -3 23 48 -4 31 45 -5 8 30 -9 16 36 -10 40 47 -11 17 46 -12 21 34 -13 24 28 -14 18 43 -15 25 26 -19 27 35 -22 37 39 -1 16 18 -2 6 20 -3 30 43 -4 28 33 -5 22 23 -7 39 42 -8 12 38 -9 35 46 -10 27 32 -11 15 34 -13 36 37 -14 41 47 -17 21 25 -19 29 45 -24 31 48 -26 40 44 diff --git a/lib/ldpc/peg/sfpeg3.code b/lib/ldpc/peg/sfpeg3.code deleted file mode 100644 index 10064e07..00000000 --- a/lib/ldpc/peg/sfpeg3.code +++ /dev/null @@ -1,51 +0,0 @@ -128 -48 -8 -1 17 34 51 66 81 99 113 -2 18 35 50 67 82 100 114 -3 19 36 52 68 82 101 115 -2 20 36 51 69 83 102 116 -4 19 37 53 66 84 103 117 -5 21 38 54 70 85 92 114 -6 22 39 55 66 85 96 118 -7 23 32 56 71 86 103 119 -8 20 40 55 72 86 104 120 -9 19 41 57 73 87 105 121 -10 24 36 56 74 88 106 122 -10 17 33 47 75 89 107 119 -11 21 42 51 76 87 108 123 -1 25 40 58 74 84 109 124 -12 22 42 49 77 90 110 122 -13 26 43 59 68 89 104 113 -13 22 44 57 75 91 106 125 -12 23 37 46 78 88 109 113 -3 27 34 60 65 87 111 126 -6 27 45 61 79 89 98 114 -14 28 34 62 72 92 107 125 -8 27 42 59 71 92 112 117 -15 20 46 57 79 93 101 117 -9 29 45 62 74 94 108 127 -8 30 38 63 73 95 110 125 -16 29 47 64 69 96 110 128 -16 23 48 63 76 94 111 121 -7 25 39 52 70 97 108 116 -4 26 45 63 67 83 90 126 -15 28 39 50 76 88 103 115 -15 26 33 58 65 97 102 127 -14 31 47 52 77 81 93 121 -14 24 37 61 71 82 99 116 -4 31 40 54 80 91 107 122 -5 32 41 58 77 98 111 120 -9 18 49 65 79 85 104 123 -10 30 43 60 69 84 112 123 -1 18 43 48 73 91 98 119 -3 21 46 64 67 86 112 118 -5 24 48 55 75 93 105 128 -2 32 44 62 80 95 99 124 -16 28 41 59 80 83 100 118 -11 33 35 53 72 96 109 115 -11 25 44 60 78 90 100 128 -6 31 35 56 70 95 102 126 -12 17 50 54 68 94 106 120 -13 29 38 53 78 97 105 124 -7 30 49 61 64 81 101 127 diff --git a/lib/ldpc/peg/sfpeg3.deg b/lib/ldpc/peg/sfpeg3.deg deleted file mode 100644 index 0fb5a574..00000000 --- a/lib/ldpc/peg/sfpeg3.deg +++ /dev/null @@ -1,3 +0,0 @@ -1 -3 -1.0 diff --git a/lib/ldpc/print-gen.c b/lib/ldpc/print-gen.c deleted file mode 100755 index 53d339e7..00000000 --- a/lib/ldpc/print-gen.c +++ /dev/null @@ -1,139 +0,0 @@ -/* PRINT-CODE.C - Print a Low Density Parity Check code's matrices. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "rand.h" -#include "alloc.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char *gen_file; - int dprint; - int i, j; - - dprint = 0; - if (argc>1 && strcmp(argv[1],"-d")==0) - { dprint = 1; - argc -= 1; - argv += 1; - } - - if (!(gen_file = argv[1]) || argv[2]) - { usage(); - } - - read_gen(gen_file,0,1); - - switch (type) - { - case 's': - { - printf("\nGenerator matrix in %s (sparse representation):\n\n",gen_file); - - printf("Column order (message bits at end):\n"); - for (j = 0; j<N; j++) - { if (j%20==0) printf("\n"); - printf(" %3d",cols[j]); - } - printf("\n\n"); - - printf("Row order:\n"); - for (i = 0; i<M; i++) - { if (i%20==0) printf("\n"); - printf(" %3d",rows[i]); - } - printf("\n\n"); - - if (dprint) - { mod2dense *Ld, *Ud; - Ld = mod2dense_allocate(M,M); - Ud = mod2dense_allocate(M,N); - mod2sparse_to_dense(L,Ld); - mod2sparse_to_dense(U,Ud); - printf("L:\n\n"); - mod2dense_print(stdout,Ld); - printf("\n"); - printf("U:\n\n"); - mod2dense_print(stdout,Ud); - printf("\n"); - } - else - { printf("L:\n\n"); - mod2sparse_print(stdout,L); - printf("\n"); - printf("U:\n\n"); - mod2sparse_print(stdout,U); - printf("\n"); - } - - break; - } - - case 'd': case 'm': - { - if (type=='d') - { printf("\nGenerator matrix in %s (dense representation):\n\n",gen_file); - } - if (type=='m') - { printf("\nGenerator matrix in %s (mixed representation):\n\n",gen_file); - } - - printf("Column order (message bits at end):\n"); - for (j = 0; j<N; j++) - { if (j%20==0) printf("\n"); - printf(" %3d",cols[j]); - } - printf("\n\n"); - - printf (type=='d' ? "Inv(A) X B:\n\n" : "Inv(A):\n\n"); - mod2dense_print(stdout,G); - printf("\n"); - - break; - } - - default: - { fprintf(stderr,"Unknown type of generator matrix file\n"); - exit(1); - } - } - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr,"Usage: print-gen [ -d ] gen-file\n"); - exit(1); -} diff --git a/lib/ldpc/print-pchk.c b/lib/ldpc/print-pchk.c deleted file mode 100755 index b9e96327..00000000 --- a/lib/ldpc/print-pchk.c +++ /dev/null @@ -1,114 +0,0 @@ -/* PRINT-PCHK.C - Print the parity check matrix for a code. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "rand.h" -#include "alloc.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - mod2dense *D; - mod2sparse *T; - - char *pchk_file; - int dprint, trans; - - dprint = 0; - trans = 0; - - for (;;) - { - if (argc>1 && strcmp(argv[1],"-d")==0) - { dprint = 1; - argc -= 1; - argv += 1; - } - else if (argc>1 && strcmp(argv[1],"-t")==0) - { trans = 1; - argc -= 1; - argv += 1; - } - else - { break; - } - } - - if (!(pchk_file = argv[1]) || argv[2]) - { usage(); - } - - read_pchk(pchk_file); - - if (trans) - { T = mod2sparse_allocate(N,M); - mod2sparse_transpose(H,T); - } - - if (dprint) - { if (trans) - { D = mod2dense_allocate(N,M); - mod2sparse_to_dense(T,D); - printf("\nTranspose of parity check matrix in %s (dense format):\n\n", - pchk_file); - mod2dense_print(stdout,D); - } - else - { D = mod2dense_allocate(M,N); - mod2sparse_to_dense(H,D); - printf("\nParity check matrix in %s (dense format):\n\n",pchk_file); - mod2dense_print(stdout,D); - } - } - else /* sparse */ - { if (trans) - { printf("\nTranspose of parity check matrix in %s (sparse format):\n\n", - pchk_file); - mod2sparse_print(stdout,T); - } - else - { printf("\nParity check matrix in %s (sparse format):\n\n",pchk_file); - mod2sparse_print(stdout,H); - } - } - - printf("\n"); - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr,"Usage: print-pchk [ -d ] [ -t ] pchk-file\n"); - exit(1); -} diff --git a/lib/ldpc/progs.html b/lib/ldpc/progs.html deleted file mode 100755 index 8bb50d35..00000000 --- a/lib/ldpc/progs.html +++ /dev/null @@ -1,80 +0,0 @@ -<HTML><HEAD> - -<TITLE> Programs for Low Density Parity Check Codes </TITLE> - -</HEAD><BODY> - - -<H1> Programs for Low Density Parity Check Codes </H1> - -Programs are available for creating LDPC codes, encoding messages, -simulating transmission through a channel, and decoding the received -message. There are links here to the general documentation on each of -these operations, and to the detailed documentation on the relevant -programs. - -<P>The programs names below are followed by the form of arguments they -take; a similar usage message is displayed when a program is run with -no arguments. In these descriptions, things to be entered literally -are in roman font, descriptions of something to be supplied are in -italic. Arguments in square brackets are optional. A vertical bar -separates alternatives. Dots represent indefinite repetition. - -<P>Many of the arguments are file names, which can be a dash ("-") in -order to specify that standard input or standard output is to be used. -(However, you can't use standard input or output for more than one thing.) - -<P>Click on a main title below for general information on that aspect -of the software, or on the name of a program for detailed information. - -<P><A HREF="pchk.html">Creating a parity check matrix for a code</A>: -<BLOCKQUOTE><PRE> -<A HREF="pchk.html#make-pchk">make-pchk</A> <I>pchk-file n-checks n-bits row</I>:<I>col ...</I> - -<A HREF="pchk.html#alist-to-pchk">alist-to-pchk</A> [ -t ] <I>alist-file pchk-file</I> - -<A HREF="pchk.html#pchk-to-alist">pchk-to-alist</A> [ -t ] [ -z ] <I>pchk-file alist-file</I> - -<A HREF="pchk.html#print-pchk">print-pchk</A> [ -d ] [ -t ] <I>pchk-file</I> - -<A HREF="pchk.html#make-ldpc">make-ldpc</A> <I>pchk-file n-checks n-bits seed method</I> -</PRE></BLOCKQUOTE> - -<P><A HREF="encoding.html">Encoding message blocks as codewords</A>: -<BLOCKQUOTE><PRE> -<A HREF="encoding.html#make-gen">make-gen</A> <I>pchk-file gen-file method</I> - -<A HREF="encoding.html#print-gen">print-gen</A> [ -d ] <I>gen-file</I> - -<A HREF="encoding.html#encode">encode</A> [ -f ] <I>pchk-file gen-file source-file encoded-file</I> -</PRE></BLOCKQUOTE> - -<P><A HREF="channel.html">Transmitting bits through a simulated channel:</A> -<BLOCKQUOTE><PRE> -<A HREF="channel.html#transmit">transmit</A> <I>encoded-file</I>|<I>n-zeros received-file seed channel</I> -</PRE></BLOCKQUOTE> - -<P><A HREF="decoding.html">Decoding received blocks:</A> -<BLOCKQUOTE><PRE> -<A HREF="decoding.html#decode">decode</A> [ -f ] [ -t | -T ] <I>pchk-file received-file decoded-file</I> [ <I>bp-file</I> ] <I>channel method</I> - -<A HREF="decoding.html#extract">extract</A> <I>gen-file decoded-file extracted-file</I> -</PRE></BLOCKQUOTE> - -<P><A HREF="support.html">Support programs:</A> -<BLOCKQUOTE><PRE> -<A HREF="support.html#rand-src">rand-src</A> <I>source-file seed n-bits</I> - -<A HREF="support.html#verify">verify</A> [ -t ] <I>pchk-file decoded-file</I> [ <I>gen-file</I> [ <I>source-file</I> ] ] -</PRE></BLOCKQUOTE> - -See also the discussions of <A HREF="dep-H.html">linear dependence in -parity check matrices</A> and of <A HREF="sparse-LU.html">sparse LU -decomposition methods</A>, and the <A HREF="examples.html">examples -of program usage</A>. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/rand-src.c b/lib/ldpc/rand-src.c deleted file mode 100755 index 31a2410d..00000000 --- a/lib/ldpc/rand-src.c +++ /dev/null @@ -1,86 +0,0 @@ -/* RAND-SRC.C - Generate random message bits. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -#include "open.h" -#include "rand.h" - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - int seed, bs, nb; - char *file, *n_bits; - char junk; - int i, j; - FILE *f; - - if (!(file = argv[1]) - || !argv[2] || sscanf(argv[2],"%d%c",&seed,&junk)!=1 - || !(n_bits = argv[3]) - || argv[4]) - { usage(); - } - - if (sscanf(n_bits,"%d%c",&nb,&junk)==1) - { if (nb<=0) usage(); - bs = 1; - } - else if (sscanf(n_bits,"%dx%d%c",&bs,&nb,&junk)==2) - { if (nb<=0 || bs<=0) usage(); - } - else - { usage(); - } - - f = open_file_std(file,"w"); - if (f==NULL) - { fprintf(stderr,"Can't create source file: %s\n",file); - exit(1); - } - - rand_seed(10*seed+2); - - for (i = 0; i<nb; i++) - { for (j = 0; j<bs; j++) - { fprintf(f,"%d",rand_int(2)); - } - fprintf(f,"\n"); - } - - if (ferror(f) || fclose(f)!=0) - { fprintf(stderr,"Error writing random source blocks to %s\n",file); - exit(1); - } - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr,"Usage: rand-src source-file seed n-bits\n"); - exit(1); -} diff --git a/lib/ldpc/rand-test.c b/lib/ldpc/rand-test.c deleted file mode 100755 index ea9d2fb0..00000000 --- a/lib/ldpc/rand-test.c +++ /dev/null @@ -1,266 +0,0 @@ -/* RAND-TEST.C - Program to test random number generators. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* Usage: - - rand-test seed generator { parameters } / sample-size [ low high bins ] - -Using the seed given, tests the random number generator identified by -the second argument, for the parameter values specified. The possible -generators and required parameters are as follows: - - uniform Uniform from [0,1) - uniopen Uniform from (0,1) - int n Uniform from the set { 0, 1, ..., (n-1) } - gaussian From Gaussian with mean zero and unit variance - exp From exponential with mean one - cauchy From Cauchy centred at zero with unit width - gamma alpha From Gamma with shape parameter (and mean) alpha - beta a b From Beta with parameters a and b - -The size of the sample to use is also specified. The program reports -the mean and variance of the sample. A histogram is also printed if a -low and high range and number of bins are for it are specified. - -These tests are not really adequate to detect subtle forms of bias due -to use of pseudo-random numbers, but are hopefully good enough to find -most programming errors. - -*/ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> - -#include "rand.h" - - -#define Max_bins 1000 /* Maximum number of histogram bins */ - -static void usage (void); - - -/* MAIN PROGRAM. */ - -main -( int argc, - char **argv -) -{ - int seed, sample_size, bins, np; - double low, high; - char *generator; - double p1, p2; - - double mean, variance; - double tmean, tvariance; - int undef_mean, undef_variance; - - int count[Max_bins]; - int under, over; - - char **ap; - double x; - int i, n; - - bins = 0; - - if (argc<5) usage(); - - if ((seed = atoi(argv[1]))==0 && strcmp(argv[1],"0")!=0) usage(); - - generator = argv[2]; - - if (strcmp(generator,"uniform")==0) np = 0; - else if (strcmp(generator,"uniopen")==0) np = 0; - else if (strcmp(generator,"int")==0) np = 1; - else if (strcmp(generator,"poisson")==0) np = 1; - else if (strcmp(generator,"gaussian")==0) np = 0; - else if (strcmp(generator,"exp")==0) np = 0; - else if (strcmp(generator,"cauchy")==0) np = 0; - else if (strcmp(generator,"gamma")==0) np = 1; - else if (strcmp(generator,"beta")==0) np = 2; - else - { fprintf(stderr,"Unknown generator: %s\n",generator); - exit(1); - } - - ap = argv+3; - - if (np>0) - { if (*ap==0 || (p1 = atof(*ap++))<=0) usage(); - } - if (np>1) - { if (*ap==0 || (p2 = atof(*ap++))<=0) usage(); - } - - if (*ap==0 || strcmp(*ap++,"/")!=0) usage(); - - if (*ap==0 || (sample_size = atoi(*ap++))<=0) usage(); - - if (*ap!=0) - { low = atof(*ap++); - if (*ap==0) usage(); - high = atof(*ap++); - if (high<=low) usage(); - if (*ap==0 || (bins = atoi(*ap++))<=0) usage(); - if (bins>Max_bins) - { fprintf(stderr,"Too many histogram bins\n"); - exit(1); - } - } - - if (*ap!=0) usage(); - - printf("\nTest of %s(",generator); - if (np>0) printf("%.4f",p1); - if (np>1) printf(",%.4f",p2); - printf(") generator using sample of size %d with seed %d\n\n", - sample_size, seed); - - undef_mean = undef_variance = 0; - - if (strcmp(generator,"uniform")==0) - { tmean = 0.5; - tvariance = 1.0/12.0; - } - else if (strcmp(generator,"uniopen")==0) - { tmean = 0.5; - tvariance = 1.0/12.0; - } - else if (strcmp(generator,"int")==0) - { tmean = (p1-1)/2; - tvariance = p1*p1/3.0 - p1/2.0 + 1/6.0 - tmean*tmean; - } - else if (strcmp(generator,"poisson")==0) - { tmean = p1; - tvariance = p1; - } - else if (strcmp(generator,"gaussian")==0) - { tmean = 0; - tvariance = 1; - } - else if (strcmp(generator,"exp")==0) - { tmean = 1; - tvariance = 1; - } - else if (strcmp(generator,"cauchy")==0) - { undef_mean = 1; - undef_variance = 1; - } - else if (strcmp(generator,"gamma")==0) - { tmean = p1; - tvariance = p1; - } - else if (strcmp(generator,"beta")==0) - { tmean = p1 / (p1+p2); - tvariance = (p1*p2) / ((p1+p2)*(p1+p2)*(p1+p2+1)); - } - else - { abort(); - } - - mean = 0; - variance = 0; - - if (bins>0) - { for (i = 0; i<bins; i++) count[i] = 0; - under = over = 0; - } - - rand_seed(seed); - - for (n = 0; n<sample_size; n++) - { - if (strcmp(generator,"uniform")==0) x = rand_uniform(); - else if (strcmp(generator,"uniopen")==0) x = rand_uniopen(); - else if (strcmp(generator,"int")==0) x = rand_int((int)p1); - else if (strcmp(generator,"poisson")==0) x = rand_poisson(p1); - else if (strcmp(generator,"gaussian")==0) x = rand_gaussian(); - else if (strcmp(generator,"exp")==0) x = rand_exp(); - else if (strcmp(generator,"cauchy")==0) x = rand_cauchy(); - else if (strcmp(generator,"gamma")==0) x = rand_gamma(p1); - else if (strcmp(generator,"beta")==0) x = rand_beta(p1,p2); - else abort(); - - mean += x; - variance += x*x; - - if (bins>0) - { if (x<low) - { under += 1; - } - else - { i = (int) ((x-low)/((high-low)/bins)); - if (i>=bins) - { over += 1; - } - else - { count[i] += 1; - } - } - } - } - - mean /= sample_size; - variance /= sample_size; - variance -= mean*mean; - - printf("Sample mean: %.4f",mean); - if (undef_mean) - { printf(" (true value: undefined)\n"); - } - else - { printf(" (true value: %.4f)\n",tmean); - } - - printf("Sample variance: %.4f",variance); - if (undef_variance) - { printf(" (true value: undefined)\n"); - } - else - { printf(" (true value: %.4f)\n",tvariance); - } - printf("\n"); - - if (bins!=0) - { printf("Histogram:\n"); - printf(" under : %8d %.5f\n\n", - under, (double)under / sample_size); - for (i = 0; i<bins; i++) - { printf(" %10.4f - %10.4f : %8d %.5f\n", - i*(high-low)/bins + low, (i+1)*(high-low)/bins + low, - count[i], (double)count[i] / sample_size); - } - printf("\n over : %8d %.5f\n", - over, (double)over / sample_size); - printf("\n"); - } - - exit(0); -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -static void usage (void) -{ - fprintf(stderr, - "Usage: rand-test seed generator { parameters } / sample-size [ low high bins ]\n"); - - exit(1); -} diff --git a/lib/ldpc/rand.c b/lib/ldpc/rand.c deleted file mode 100755 index 2031600b..00000000 --- a/lib/ldpc/rand.c +++ /dev/null @@ -1,567 +0,0 @@ -/* RAND.C - Random number generation module. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -/* Random generation routines at the end of this file are taken from the - GNU C library, see the copyright notice there. */ - - -/* NOTE: See rand.html for documentation on these procedures. */ - - -#include <stdlib.h> -#include <stdint.h> -#include <stdio.h> -#include <string.h> -#include <math.h> - -#include "rand.h" - - -static long int this_nrand48 (unsigned short int [3]); - /* Local version of nrand48 */ - - -/* This module uses the 'this_nrand48' pseudo-random number generator from the - GNU C library, included below, but renamed to 'this_nrand48'. The - output of this generator is combined with a file of real random numbers. - - Many of the methods used in this module may be found in the following - reference: - - Devroye, L. (1986) Non-Uniform Random Variate Generation, - New York: Springer-Verlag. - - The methods used here are not necessarily the fastest available. They're - selected to be reasonably fast while also being easy to write. -*/ - - -/* CONSTANT PI. Defined here if not in <math.h>. */ - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - - -/* TABLES OF REAL RANDOM NUMBERS. A file of 100000 real random numbers - (NOT pseudo-random) is used in conjunction with pseudo-random numbers - for extra insurance. These are employed in the form of five tables - of 5000 32-bit integers. - - The file must be located at the path given by RAND_FILE, which should - be defined on the "cc" command line. */ - -#define Table_size 5000 /* Number of words in each table */ - -static int rn[N_tables][Table_size]; /* Random number tables */ - - -/* STATE OF RANDOM NUMBER GENERATOR. */ - -static int initialized = 0; /* Has module been initialized? */ - -static rand_state state0; /* Default state structure */ - -static rand_state *state; /* Pointer to current state */ - - -/* INITIALIZE MODULE. Sets things up using the default state structure, - set as if rand_seed had been called with a seed of one. */ - -static void initialize (void) -{ - int i, j, k, w; - char b; - FILE *f; - - if (!initialized) - { - f = fopen(RAND_FILE,"rb"); - - if (f==NULL) - { fprintf(stderr,"Can't open file of random numbers (%s)\n",RAND_FILE); - exit(1); - } - - for (i = 0; i<N_tables; i++) - { for (j = 0; j<Table_size; j++) - { w = 0; - for (k = 0; k<4; k++) - { if (fread(&b,1,1,f)!=1) - { fprintf(stderr,"Error reading file of random numbers (%s)\n", - RAND_FILE); - exit(1); - } - w = (w<<8) | (b&0xff); - } - rn[i][j] = w; - } - } - - state = &state0; - - initialized = 1; - - rand_seed(1); - } -} - - -/* SET CURRENT STATE ACCORDING TO SEED. */ - -void rand_seed -( int seed -) -{ - int j; - - if (!initialized) initialize(); - - state->seed = seed; - - state->state48[0] = seed>>16; - state->state48[1] = seed&0xffff; - state->state48[2] = rn[0][(seed&0x7fffffff)%Table_size]; - - for (j = 0; j<N_tables; j++) - { state->ptr[j] = seed%Table_size; - seed /= Table_size; - } -} - - -/* SET STATE STRUCTURE TO USE. */ - -void rand_use_state -( rand_state *st -) -{ - if (!initialized) initialize(); - - state = st; -} - - -/* RETURN POINTER TO CURRENT STATE. */ - -rand_state *rand_get_state (void) -{ - if (!initialized) initialize(); - - return state; -} - - -/* GENERATE RANDOM 31-BIT INTEGER. Not really meant for use outside this - module. */ - -int rand_word(void) -{ - int v; - int j; - - if (!initialized) initialize(); - - v = this_nrand48(state->state48); - - for (j = 0; j<N_tables; j++) - { v ^= rn[j][state->ptr[j]]; - } - - for (j = 0; j<N_tables && state->ptr[j]==Table_size-1; j++) - { state->ptr[j] = 0; - } - - if (j<N_tables) - { state->ptr[j] += 1; - } - - return v & 0x7fffffff; -} - - -/* GENERATE UNIFORMLY FROM [0,1). */ - -double rand_uniform (void) -{ - return (double)rand_word() / (1.0+(double)0x7fffffff); -} - - -/* GENERATE UNIFORMLY FORM (0,1). */ - -double rand_uniopen (void) -{ - return (0.5+(double)rand_word()) / (1.0+(double)0x7fffffff); -} - - -/* GENERATE RANDOM INTEGER FROM 0, 1, ..., (n-1). */ - -int rand_int -( int n -) -{ - return (int) (n * rand_uniform()); -} - - -/* GENERATE INTEGER FROM 0, 1, ..., (n-1), WITH GIVEN DISTRIBUTION. */ - -int rand_pickd -( double *p, - int n -) -{ - double t, r; - int i; - - t = 0; - for (i = 0; i<n; i++) - { if (p[i]<0) abort(); - t += p[i]; - } - - if (t<=0) abort(); - - r = t * rand_uniform(); - - for (i = 0; i<n; i++) - { r -= p[i]; - if (r<0) return i; - } - - /* Return value with non-zero probability if we get here due to roundoff. */ - - for (i = 0; i<n; i++) - { if (p[i]>0) return i; - } - - abort(); -} - - -/* SAME PROCEDURE AS ABOVE, BUT WITH FLOAT ARGUMENT. */ - -int rand_pickf -( float *p, - int n -) -{ - double t, r; - int i; - - t = 0; - for (i = 0; i<n; i++) - { if (p[i]<=0) abort(); - t += p[i]; - } - - if (t<=0) abort(); - - r = t * rand_uniform(); - - for (i = 0; i<n; i++) - { r -= p[i]; - if (r<0) return i; - } - - /* Return value with non-zero probability if we get here due to roundoff. */ - - for (i = 0; i<n; i++) - { if (p[i]>0) return i; - } - - abort(); -} - - -/* GENERATE RANDOM PERMUTATION OF INTEGERS FROM 1 TO N. */ - -void rand_permutation -( int *perm, /* Place to store permutation */ - int n /* Number of integers to permute */ -) -{ - int i, j, t; - - for (i = 0; i<n; i++) - { perm[i] = i+1; - } - - for (i = 0; i<n; i++) - { t = perm[i]; - j = i + rand_int(n-i); - perm[i] = perm[j]; - perm[j] = t; - } -} - - -/* POISSON GENERATOR. The method used is simple, but not very fast. See - Devroye, p. 503. Very large means are done using Gaussian approximation. */ - -int rand_poisson -( double lambda -) -{ int v; - if (lambda>10000) - { v = (int) (lambda + rand_gaussian()*sqrt(lambda) + 0.5); - } - else - { v = 0; - for (;;) - { lambda -= rand_exp(); - if (lambda<=0) break; - v += 1; - } - } - return v; -} - - -/* GAUSSIAN GENERATOR. Done by using the Box-Muller method, but only one - of the variates is retained (using both would require saving more state). - See Devroye, p. 235. - - As written, should never deliver exactly zero, which may sometimes be - helpful. */ - -double rand_gaussian (void) -{ - double a, b; - - a = rand_uniform(); - b = rand_uniopen(); - - return cos(2.0*M_PI*a) * sqrt(-2.0*log(b)); -} - - -/* EXPONENTIAL GENERATOR. See Devroye, p. 29. Written so as to never - return exactly zero. */ - -double rand_exp (void) -{ - return -log(rand_uniopen()); -} - - -/* LOGISTIC GENERATOR. Just inverts the CDF. */ - -double rand_logistic (void) -{ double u; - u = rand_uniopen(); - return log(u/(1-u)); -} - - -/* CAUCHY GENERATOR. See Devroye, p. 29. */ - -double rand_cauchy (void) -{ - return tan (M_PI * (rand_uniopen()-0.5)); -} - - -/* GAMMA GENERATOR. Generates a positive real number, r, with density - proportional to r^(a-1) * exp(-r). See Devroye, p. 410 and p. 420. - Things are fiddled to avoid ever returning a value that is very near - zero. */ - -double rand_gamma -( double a -) -{ - double b, c, X, Y, Z, U, V, W; - - if (a<0.00001) - { X = a; - } - - else if (a<=1) - { - U = rand_uniopen(); - X = rand_gamma(1+a) * pow(U,1/a); - } - - else if (a<1.00001) - { X = rand_exp(); - } - - else - { - b = a-1; - c = 3*a - 0.75; - - for (;;) - { - U = rand_uniopen(); - V = rand_uniopen(); - - W = U*(1-U); - Y = sqrt(c/W) * (U-0.5); - X = b+Y; - - if (X>=0) - { - Z = 64*W*W*W*V*V; - - if (Z <= 1 - 2*Y*Y/X || log(Z) <= 2 * (b*log(X/b) - Y)) break; - } - } - } - - return X<1e-30 && X<a ? (a<1e-30 ? a : 1e-30) : X; -} - - -/* BETA GENERATOR. Generates a real number, r, in (0,1), with density - proportional to r^(a-1) * (1-r)^(b-1). Things are fiddled to avoid - the end-points, and to make the procedure symmetric between a and b. */ - -double rand_beta -( double a, - double b -) -{ - double x, y, r; - - do - { x = rand_gamma(a); - y = rand_gamma(b); - r = 1.0 + x/(x+y); - r = r - 1.0; - } while (r<=0.0 || r>=1.0); - - return r; -} - - -/* ROUTINES FROM THE GNU C LIBRARY. These were modified to extract - only the routines used here, and to allow them to be included in - this module without any possible name conflict with other modules. - Inclusion here ensures that these routines are always available, and - operate in exactly the same way on all systems. The routines as copied - below are still easily useable by other programs by simply inserting - this source code into an appropriate source file. - - The following is the copyright notice for these routines: - - Copyright (C) 1995, 1996, 1997, 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. - - The GNU Lesser General Public License is included with these source - files in the file LGPL. */ - -#include <errno.h> -#include <limits.h> -#include <sys/types.h> - -struct this_drand48_data - { - unsigned short int x[3]; /* Current state. */ - unsigned short int old_x[3]; /* Old state. */ - unsigned short int c; /* Additive const. in congruential formula. */ - unsigned short int init; /* Flag for initializing. */ - unsigned long long int a; /* Factor in congruential formula. */ - }; - -/* Global state for non-reentrant functions. */ - -struct this_drand48_data libc_this_drand48_data; - -static int this_nrand48_r (unsigned short int xsubi[3], - struct this_drand48_data *buffer, - long int *result); - -/* Internal function to compute next state of the generator. */ - -static int this_drand48_iterate (unsigned short int xsubi[3], - struct this_drand48_data *buffer); - -static long int this_nrand48 (xsubi) - unsigned short int xsubi[3]; -{ - long int result; - - (void) this_nrand48_r (xsubi, &libc_this_drand48_data, &result); - - return result; -} - -static int this_nrand48_r (xsubi, buffer, result) - unsigned short int xsubi[3]; - struct this_drand48_data *buffer; - long int *result; -{ - /* Compute next state. */ - if (this_drand48_iterate (xsubi, buffer) < 0) - return -1; - - /* Store the result. */ - if (sizeof (unsigned short int) == 2) - *result = xsubi[2] << 15 | xsubi[1] >> 1; - else - *result = xsubi[2] >> 1; - - return 0; -} - -static int this_drand48_iterate (xsubi, buffer) - unsigned short int xsubi[3]; - struct this_drand48_data *buffer; -{ - uint64_t X; - uint64_t result; - - /* Initialize buffer, if not yet done. */ - if (!buffer->init) - { - buffer->a = 0x5deece66dull; - buffer->c = 0xb; - buffer->init = 1; - } - - /* Do the real work. We choose a data type which contains at least - 48 bits. Because we compute the modulus it does not care how - many bits really are computed. */ - - X = (uint64_t) xsubi[2] << 32 | (uint32_t) xsubi[1] << 16 | xsubi[0]; - - result = X * buffer->a + buffer->c; - - xsubi[0] = result & 0xffff; - xsubi[1] = (result >> 16) & 0xffff; - xsubi[2] = (result >> 32) & 0xffff; - - return 0; -} diff --git a/lib/ldpc/rand.h b/lib/ldpc/rand.h deleted file mode 100755 index bb896d40..00000000 --- a/lib/ldpc/rand.h +++ /dev/null @@ -1,54 +0,0 @@ -/* RAND.H - Interface to random number generation procedures. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* STATE OF RANDOM NUMBER GENERATOR. */ - -#define N_tables 5 /* Number of tables of real random numbers */ - -typedef struct -{ int seed; /* Seed state derives from */ - int ptr[N_tables]; /* Pointers for tables of real random numbers */ - unsigned short state48[3]; /* State of 'rand48' pseudo-random generator */ -} rand_state; - - -/* BASIC PSEUDO-RANDOM GENERATION PROCEDURES. */ - -void rand_seed (int); /* Initialize current state structure by seed */ - -void rand_use_state (rand_state *); /* Start using given state structure */ -rand_state *rand_get_state (void); /* Return pointer to current state */ - -int rand_word (void); /* Generate random 31-bit positive integer */ - - -/* GENERATORS FOR VARIOUS DISTRIBUTIONS. */ - -double rand_uniform (void); /* Uniform from [0,1) */ -double rand_uniopen (void); /* Uniform from (0,1) */ - -int rand_int (int); /* Uniform from 0, 1, ... (n-1) */ -int rand_pickd (double *, int); /* From 0 ... (n-1), with given distribution */ -int rand_pickf (float *, int); /* Same as above, but with floats */ -void rand_permutation (int *, int); /* Random permutation */ - -int rand_poisson (double); /* Poisson with given mean */ -double rand_gaussian (void); /* Gaussian with mean zero and unit variance */ -double rand_logistic (void); /* Logistic centred at zero with unit width */ -double rand_cauchy (void); /* Cauchy centred at zero with unit width */ -double rand_gamma (double); /* Gamma with given shape parameter */ -double rand_exp (void); /* Exponential with mean one */ -double rand_beta (double, double); /* Beta with given parameters */ diff --git a/lib/ldpc/rand.html b/lib/ldpc/rand.html deleted file mode 100755 index 5754b86a..00000000 --- a/lib/ldpc/rand.html +++ /dev/null @@ -1,306 +0,0 @@ -<HTML><HEAD> - -<TITLE> Random Variate Generation Routines </TITLE> - -</HEAD><BODY> - - -<H1> Random Variate Generation Routines </H1> - -<P>This module provides facilities for basic pseudo-random number generation, -and for generation of random variates from various common distributions. - -<P>All the random generation procedures use the same underlying -"stream" of random numbers. This stream is generated using the -<TT>nrand48</TT> pseudo-random generation procedure found on most Unix -systems, with the output being combined with a limited supply of real -random numbers from the file "randfile" in the source -directory for this software, in order to reduce the chances that the -pseudo-random numbers aren't random enough. - -<P>A pseudo-random number stream is determined by an integer -<I>seed</I>, which is typically set by the user for each experimental -run (eg, to 1, 2, 3, etc. for successive runs). The state of the -random number stream can be saved in a structure of type -<TT>rand_state</TT>, and later restored. For example, the state could -be saved in a file at the end of a run, and restored if it is later -decided that the run should be continued for longer. - -<P>The methods for generating random variates from various distributions -are mostly taken from the following reference: -<BLOCKQUOTE> - Devroye, L. (1986) <I>Non-Uniform Random Variate Generation</I>, - New York: Springer-Verlag. -</BLOCKQUOTE> -The methods used here are not necessarily the fastest available. They were -selected to be reasonably fast while also being easy to write. - -<P><B>Header file required</B>: <TT>rand.h</TT> - - -<A NAME="get-set-sec"> -<P><HR> -<CENTER><BIG>Setting and saving the state</BIG></CENTER> -</A> - - -<A NAME="seed"><HR><B>rand_seed</B>: -Set the state from an integer seed.</A> - -<BLOCKQUOTE><PRE> -void rand_seed -( int seed; /* Seed to set state based on */ -) -</PRE></BLOCKQUOTE> - -<P>Sets the random number generator to a state that is determined from -the integer <TT>seed</TT>. Setting the seed the same on two occasions, -and then calling exactly the same sequence of random generation -procedures, should produce exactly the same sequence of random -variates. (Note: this may not be true, however, if computers with -different architectures are used on the two occasions.) - -<P>Sequential seeds should produce streams that are pretty much -independent (unlike the situation for some pseudo-random number -generators). Setting the seed randomly according to the time or day, -or some such, without recording what it was, is <B>not</B> -recommended, since the results are then not reproducible. - -<P><A NAME="get_state"><HR><B>rand_get_state</B>: -Get a pointer to the current state.</A> - -<BLOCKQUOTE><PRE> -rand_state *rand_get_state (void) -</PRE></BLOCKQUOTE> - -Returns a pointer to the current state of the random number generator, -which is a structure of type <TT>rand_state</TT>. The only use for this -pointer is to use it to save a copy of the current state someplace. - - -<P><A NAME="use_state"><HR><B>rand_use_state</B>: -Set the state to use from now on.</A> - -<BLOCKQUOTE><PRE> -void rand_use_state -( rand_state *state /* Pointer to a previously saved state */ -) -</PRE></BLOCKQUOTE> - -Sets the random number generator to the state pointed to by the argument. -This state must be valid. The only way to get a valid state is by using -<TT>rand_get_state</TT>. - - -<A NAME="uniform-sec"> -<P><HR> -<CENTER><BIG>Generating uniform random variates</BIG></CENTER> -</A> - - -<A NAME="uniform"><HR><B>rand_uniform</B>: -Generate uniformly from [0,1).</A> - -<BLOCKQUOTE><PRE> -double rand_uniform (void) -</PRE></BLOCKQUOTE> - -Returns a random number that is uniformly distributed between 0 and 1, -with a value of exactly 0 being possible, but with a value of exactly 1 -not being possible. - -<P><A NAME="uniopen"><HR><B>rand_uniopen</B>: -Generate uniformly from (0,1).</A> - -<BLOCKQUOTE><PRE> -double rand_uniopen (void) -</PRE></BLOCKQUOTE> - -Returns a random number that is uniformly distributed between 0 and 1, -with neither a value of exactly 0 nor a value of exactly 1 -being possible. - - -<A NAME="discrete-sec"> -<P><HR> -<CENTER><BIG>Generating discrete random variates</BIG></CENTER> -</A> - - -<A NAME="int"><HR><B>rand_int</B>: -Pick an integer uniformly from <I>0</I> to <I>n-1</I>.</A> - -<BLOCKQUOTE><PRE> -int rand_int -( int n /* Number of integers (from 0) to pick from */ -) -</PRE></BLOCKQUOTE> - -<P>Randomly picks an integer from the set { <TT>0, 1, ..., n-1</TT> }, -with each integer being equally probable. The probabilities may -become somewhat unequal, however, if <TT>n</TT> is very large, -approaching 2<SUP><SMALL>31</SMALL></SUP>. - - -<P><A NAME="pickd"><HR><B>rand_pickd</B>: Pick an integer from <I>0</I> -to <I>n-1</I> with given probabilities (as doubles).</A> - -<BLOCKQUOTE><PRE> -int rand_pickd -( double *p, /* Array of probabilities, of length n */ - int n /* Number of integers (from 0) to pick from */ -) -</PRE></BLOCKQUOTE> - -<P>Randomly picks an integer from the set { <TT>0, 1, ..., n-1</TT> }, -with probabilities given by the array of double-precision numbers -passed as the first argument. These numbers need not sum to one, but they -must be non-negative, and must not all be zero. The actual -probabilities used are obtained by dividing each number in this array -by the sum of all the numbers. - -<P>If one of the probabilities is exactly zero, it is guaranteed that -the corresponding integer will not be picked. - - -<P><A NAME="pickf"><HR><B>rand_pickf</B>: Pick an integer from <I>0</I> -to <I>n-1</I> with given probabilities (as floats).</A> - -<BLOCKQUOTE><PRE> -int rand_pickf -( float *p, /* Array of probabilities, of length n */ - int n /* Number of integers (from 0) to pick from */ -) -</PRE></BLOCKQUOTE> - -<P>This procedure is the same as <A HREF="#pickd"><TT>rand_pickd</TT></A> -except that the array giving the probabilities is an array of single-precision -floating point numbers, rather than double-precision. - - -<A NAME="poisson"><HR><B>rand_poisson</B>: -Generate a non-negative integer from a Poisson distribution.</A> - -<BLOCKQUOTE><PRE> -int rand_poisson -( double lambda /* Mean of the Poisson distribution */ -) -</PRE></BLOCKQUOTE> - -<P>Generates a non-negative integer from the Poisson distribution with mean -<tt>lambda</tt>. - - -<P><A NAME="permutation"><HR><B>rand_permutation</B>: Generate a random -permutation of integers from <i>1</i> to <i>n</i>.</A> - -<BLOCKQUOTE><PRE> -int rand_permutation -( int *perm, /* Place to store the permutation */ - int n /* Number of integers to permute */ -) -</PRE></BLOCKQUOTE> - -<P>Stores a random permutation of the integers from <i>1</i> to <i>n</i> in the -array perm, which must be at least <i>n</i> long. All permutations are -equally likely. - - -<A NAME="continuous-sec"> -<P><HR> -<CENTER><BIG>Generating continuous random variates</BIG></CENTER> -</A> - - -<A NAME="gaussian"><HR><B>rand_gaussian</B>: -Generate a standard Gaussian (normal) random variate.</A> - -<BLOCKQUOTE><PRE> -double rand_gaussian (void) -</PRE></BLOCKQUOTE> - -<P>Generates a random value drawn from the Gaussian (normal) distribution -with mean zero and standard deviation one, whose density function is -proportional to exp(-<I>x<SUP><SMALL>2</SMALL></SUP></I>/2), with <I>x</I> -being any real value. - - -<A NAME="logistic"><HR><B>rand_logistic</B>: -Generate a logistic random variate.</A> - -<BLOCKQUOTE><PRE> -double rand_logistic (void) -</PRE></BLOCKQUOTE> - -<P>Generates a random value drawn from the logistic distribution with -location parameter zero and width parameter one, whose density -function is proportional to -exp(-<I>x</I>) / [1 + exp(-<I>x</I>)]<SUP><SMALL>2</SMALL></SUP>, -with <I>x</I> being any real value. - - -<P><A NAME="cauchy"><HR><B>rand_cauchy</B>: -Generate a Cauchy random variate.</A> - -<BLOCKQUOTE><PRE> -double rand_cauchy (void) -</PRE></BLOCKQUOTE> - -<P>Generates a random value drawn from the Cauchy distribution with centre -at zero and width one, whose density function is proportional to -1 / (1+<I>x<SUP><SMALL>2</SMALL></SUP></I>), with <I>x</I> being any real value. - - -<P><A NAME="gamma"><HR><B>rand_gamma</B>: -Generate a gamma-distributed random variate.</A> - -<BLOCKQUOTE><PRE> -double rand_gamma -( double A /* Shape parameter */ -) -</PRE></BLOCKQUOTE> - -<P>Generates a random value drawn from the gamma distribution with -positive shape parameter <I>A</I>, whose density function is proportional -to <I>x<SUP><SMALL>A-1</SMALL></SUP></I> exp(-<I>x</I>), with <I>x</I> -being any positive real. This procedure will never return a value that is -exactly zero. - - -<P><A NAME="exp"><HR><B>rand_exp</B>: -Generate an exponentially-distributed random variate.</A> - -<BLOCKQUOTE><PRE> -double rand_exponential (void) -</PRE></BLOCKQUOTE> - -<P>Generates a random value drawn from the exponential distribution with -mean one, whose density function is exp(-<I>x</I>), with <I>x</I> being -any positive real. This procedure will never return a value that is -exactly zero. - -<P>Note: This is a common special case of the gamma distribution. - - -<P><A NAME="beta"><HR><B>rand_beta</B>: -Generate a beta-distributed random variate.</A> - -<BLOCKQUOTE><PRE> -double rand_beta -( double A, /* Parameters of distribution */ - double B -) -</PRE></BLOCKQUOTE> - -<P>Generates a random value drawn from the beta distribution with positive -parameters <I>A</I> and <I>B</I>, whose density function is proportional -to <I>x<SUP><SMALL>A-1</SMALL></SUP>(1-x)<SUP><SMALL>B-1</SMALL></SUP></I>, -with <I>x</I> being any real in the interval (0,1). This procedure -will never return a value that is exactly zero or exactly one. - - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/randfile b/lib/ldpc/randfile Binary files differdeleted file mode 100755 index 3d33d61e..00000000 --- a/lib/ldpc/randfile +++ /dev/null diff --git a/lib/ldpc/rcode.c b/lib/ldpc/rcode.c deleted file mode 100755 index 84d6fd92..00000000 --- a/lib/ldpc/rcode.c +++ /dev/null @@ -1,217 +0,0 @@ -/* RCODE.C - Procedures to read parity check and generator matrices. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -#include "alloc.h" -#include "intio.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" - - -/* VARIABLES DECLARED IN RCODE.H. These global variables are set to - representations of the parity check and generator matrices by read_pchk - and read_gen. */ - -mod2sparse *H; /* Parity check matrix */ - -int M; /* Number of rows in parity check matrix */ -int N; /* Number of columns in parity check matrix */ - -char type; /* Type of generator matrix representation (s/d/m) */ -int *cols; /* Ordering of columns in generator matrix */ - -mod2sparse *L, *U; /* Sparse LU decomposition, if type=='s' */ -int *rows; /* Ordering of rows in generator matrix (type 's') */ - -mod2dense *G; /* Dense or mixed representation of generator matrix, - if type=='d' or type=='m' */ - - -/* READ PARITY CHECK MATRIX. Sets the H, M, and N global variables. If an - error is encountered, a message is displayed on standard error, and the - program is terminated. */ - -void read_pchk -( char *pchk_file -) -{ - FILE *f; - - f = open_file_std(pchk_file,"rb"); - if (f==NULL) - { fprintf(stderr,"Can't open parity check file: %s\n",pchk_file); - exit(1); - } - - if (intio_read(f)!=('P'<<8)+0x80) - { fprintf(stderr,"File %s doesn't contain a parity check matrix\n",pchk_file); - exit(1); - } - - H = mod2sparse_read(f); - - if (H==0) - { fprintf(stderr,"Error reading parity check matrix from %s\n",pchk_file); - exit(1); - } - - M = mod2sparse_rows(H); - N = mod2sparse_cols(H); - - fclose(f); -} - - -/* READ GENERATOR MATRIX. The parity check matrix must have already been - read, unless the last argument is set to 1. The generator matrix must be - compatible with the parity check matrix, if it has been read. If the - second argument is 1, only the column ordering (the last N-M of which are - the indexes of the message bits) is read, into the 'cols' global variable. - Otherwise, everything is read, into the global variables appropriate - to the representation. The 'type' global variable is set to a letter - indicating which represention is used. - - If an error is encountered, a message is displayed on standard error, - and the program is terminated. */ - -void read_gen -( char *gen_file, /* Name of generator matrix file */ - int cols_only, /* Read only column ordering? */ - int no_pchk_file /* No parity check file used? */ -) -{ - int M2, N2; - FILE *f; - int i; - - f = open_file_std(gen_file,"rb"); - if (f==NULL) - { fprintf(stderr,"Can't open generator matrix file: %s\n",gen_file); - exit(1); - } - - if (intio_read(f)!=('G'<<8)+0x80) - { fprintf(stderr,"File %s doesn't contain a generator matrix\n",gen_file); - exit(1); - } - - if (fread (&type, 1, 1, f) != 1) goto error; - - M2 = intio_read(f); - N2 = intio_read(f); - - if (feof(f) || ferror(f)) goto error; - - if (no_pchk_file) - { M = M2; - N = N2; - } - else - { if (M2!=M || N2!=N) - { fprintf(stderr, - "Generator matrix and parity-check matrix are incompatible\n"); - exit(1); - } - } - - cols = chk_alloc (N, sizeof *cols); - rows = chk_alloc (M, sizeof *rows); - - for (i = 0; i<N; i++) - { cols[i] = intio_read(f); - if (feof(f) || ferror(f)) goto error; - } - - if (!cols_only) - { - switch (type) - { - case 's': - { - for (i = 0; i<M; i++) - { rows[i] = intio_read(f); - if (feof(f) || ferror(f)) goto error; - } - - if ((L = mod2sparse_read(f)) == 0) goto error; - if ((U = mod2sparse_read(f)) == 0) goto error; - - if (mod2sparse_rows(L)!=M || mod2sparse_cols(L)!=M) goto garbled; - if (mod2sparse_rows(U)!=M || mod2sparse_cols(U)<M) goto garbled; - - break; - } - - case 'd': - { - if ((G = mod2dense_read(f)) == 0) goto error; - - if (mod2dense_rows(G)!=M || mod2dense_cols(G)!=N-M) goto garbled; - - break; - } - - case 'm': - { - if ((G = mod2dense_read(f)) == 0) goto error; - - if (mod2dense_rows(G)!=M || mod2dense_cols(G)!=M) goto garbled; - - break; - } - - default: - { fprintf(stderr, - "Unknown type of generator matrix in file %s\n",gen_file); - exit(1); - } - } - } - - fclose(f); - - return; - -error: - fprintf(stderr,"Error reading generator matrix from file %s\n",gen_file); - exit(1); - -garbled: - fprintf(stderr,"Garbled generator matrix in file %s\n",gen_file); - exit(1); -} - -// Fortran interface routines for WSJT-X -void init_ldpc_ (char *pfile, char *gfile ) -{ - read_pchk( pfile ); - read_gen( gfile, 0, 0 ); -} - -void fini_ldpc_ () -{ - mod2dense_free (G); - mod2sparse_free (U); - mod2sparse_free (L); - free (cols); - free (rows); - mod2sparse_free (H); -} diff --git a/lib/ldpc/rcode.h b/lib/ldpc/rcode.h deleted file mode 100755 index e311e0ce..00000000 --- a/lib/ldpc/rcode.h +++ /dev/null @@ -1,37 +0,0 @@ -/* RCODE.H - Parity chk and gen matrix storage, and procedures to read them.*/ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - - -/* VARIABLES HOLDING DATA READ. These are declared for real in rcode.c. */ - -extern mod2sparse *H; /* Parity check matrix */ - -extern int M; /* Number of rows in parity check matrix */ -extern int N; /* Number of columns in parity check matrix */ - -extern char type; /* Type of generator matrix representation */ -extern int *cols; /* Ordering of columns in generator matrix */ - -extern mod2sparse *L, *U; /* Sparse LU decomposition, if type=='s' */ -extern int *rows; /* Ordering of rows in generator matrix (type 's') */ - -extern mod2dense *G; /* Dense or mixed representation of generator matrix, - if type=='d' or type=='m' */ - - -/* PROCEDURES FOR READING DATA. */ - -void read_pchk (char *); -void read_gen (char *, int, int); diff --git a/lib/ldpc/refs.html b/lib/ldpc/refs.html deleted file mode 100755 index 5c0d76ef..00000000 --- a/lib/ldpc/refs.html +++ /dev/null @@ -1,58 +0,0 @@ -<HTML><HEAD> - -<TITLE> References on Low Density Parity Check Codes </TITLE> - -</HEAD><BODY> - - -<H1> References on Low Density Parity Check Codes </H1> - -Robert Gallager's original work on low density parity check codes was published -as the following book, based his doctoral dissertation, and a related paper: -<BLOCKQUOTE> -<P>Gallager, R. G. (1963) <I>Low Density Parity Check Codes</I>, - Cambridge, MA: MIT Press. -<P>Gallager, R. G. (1962) ``Low-density parity-check codes'', <I>IRE - Transactions on Information Theory</I>, vol. IT-8, pp. 21-28. -</BLOCKQUOTE> - -More recent work on these codes by David MacKay and myself was published -as follows: -<BLOCKQUOTE> -<P>MacKay, D. J. C. and Neal, R. M. (1996) ``Near Shannon limit performance - of low density parity check codes'', <I>Electronics Letters</I>, - vol. 32, pp. 1645-1646. Reprinted with printing errors corrected - in vol. 33, pp. 457-458. -<P>MacKay, D. J. C. (1999) ``Good error-correcting codes based on very - sparse matrices'', <I>IEEE Transactions on Information Theory</I>, - vol. 45, pp. 399-431. -</BLOCKQUOTE> - -The decoding algorithms described in the above references can visualized -in terms of a ``factor graph'' representation of the code, as described -in the following paper: -<BLOCKQUOTE> -<P>Kschischang, F. R., Frey, B. J., and Loeliger, H.-A. (1998) ``Factor graphs -and the sum-product algorithm'', <I>IEEE Transactions on Information -Theory</I>, vol. 47, pp. 498-519. -</BLOCKQUOTE> - -I presented the application of sparse matrix techniques to encoding of -LDPC codes at the IMA workshop on Codes, Systems and Graphical Models, -Minneapolis, 1999. You can view the slides of this talk <A -HREF="sparse-encode.pdf">here</A>. <B>Note</B>: Due to a bug in the -program I used then, the results shown for the minimal product heuristic in -these slides are somewhat worse than the actual performance. For instance, -the number of bit operations per check bit for for <I>M</I>=3200 with -3 checks per bit is actually around 12.7, not the value around 17 shown -on one of the slides. - -<P>Text and references to many more recent and classical papers can be -obtained via the <A HREF="http://www.ima.umn.edu/csg/">IMA workshop's -web page</A>. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/release.html b/lib/ldpc/release.html deleted file mode 100755 index 558e7cda..00000000 --- a/lib/ldpc/release.html +++ /dev/null @@ -1,244 +0,0 @@ -<HTML><HEAD> - -<TITLE>Release Notes for LDPC-codes Software</TITLE> - -</HEAD><BODY> - - -<H1>Release Notes for LDPC-codes Software</H1> - -These notes describe all the stable public releases of this software. Old -and future releases can be obtained via -<BLOCKQUOTE> -<A HREF="http://www.cs.toronto.edu/~radford/ldpc.software.html"> -<TT>http://www.cs.toronto.edu/~radford/ldpc.software.html</TT></A> -</BLOCKQUOTE> -The current development version is now maintained at -<BLOCKQUOTE> -<A HREF="http://github.com/radfordneal/LDPC-codes"> -<TT>http://github.com/radfordneal/LDPC-code</TT></A> -</BLOCKQUOTE> - -<H2>Version of 2012-02-11.</H2> -This version has a few bug fixes and some minor new features. The major -change is that a source repository for the software is now hosted -at github.com, making it easier for people to create and release -their own versions of this software. -<OL> -<LI> Changed the copyright notice (in the file COPYRIGHT, and elsewhere) - to remove the requirement that my web site be referenced. (Nowadays, - I think users should have no problem finding the sources using a - search engine.) -<LI> Included a copy of the nrand48 routine from the GNU C library - in the rand.c module, to ensure that it is always available - and always the same. (This isn't so on some versions of cygwin.) -<LI> Added a -f option to encode and decode that forces flushing - after writing each block. Useful for allowing encode or - decode to be used as a server, reading and writing blocks - from named pipes. -<LI> Added a -z option for pchk-to-alist to suppress output of 0 - row and column indexes that pad up to the maximum number used. -<LI> Documented the previously undocumented -t options for pchk-to-alist - and alist-to-pchk. -<LI> Changed alist-to-pchk so that it no longer requires zero indexes - that pad out to the maximum needed for a row or column (thanks - to Monica Kolb for suggesting this). -<LI> Changed mod2word type in mod2dense.c to uint32_t, to avoid - wasted space when long is 64 bits (thanks to Mathieu Cunche - and Vincent Roca for suggesting this). -<LI> Fixed bug in distrib.c affecting distributions with a single - number (thanks to Mike Vicuna for pointing it out). -<LI> Fixed bug in -t option for pchk-to-alist (thanks to Andrea Fontana - for reporting this). -<LI> Fixed references in the documentation to mod2sparse_multvec - that should be to mod2sparse_mulvec (thanks to Andrea Fontana - for reporting this). -</OL> - - -<H2>Version of 2006-02-08.</H2> - -The copyright notice has been changed in this release to no longer -restrict use to purposes of research or education. The new copyright -notice can be read <A HREF="index.html#copyright">here</A>. It is now -possible to create LDPC codes with varying numbers of checks per bit -(an extension based on work by Peter Junteng Liu). New programs for -converting to and from the <A -HREF="http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html">alist -format</A> for parity check matrices, used by David MacKay and others, -have also been added. - -<P>The following new features have been added: -<OL> -<LI> The <A HREF="pchk.html#make-ldpc"><TT>make-ldpc</TT></A> program can - new create LDPC codes with varying numbers of checks per bit. The - <A HREF="examples.html">examples</A> now include a code of this sort. -<LI> New programs <A HREF="pchk.html#pchk-to-alist"><TT>pchk-to-alist</TT></A> - and <A HREF="pchk.html#alist-to-pchk"><TT>alist-to-pchk</TT></A> have - been added, which convert to and from <A - HREF="http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html">alist - format</A>. -<LI> A <A HREF="run-examples"><TT>run-examples</TT></A> script has been - added, which runs all the <A HREF="examples.html">examples</A> and - compares with the saved output that I obtained. -</OL> - - -<H2>Version of 2001-11-18.</H2> - -This is a minor release, whose main purpose is fixing bug (1) below. -Also, this release has been tested and found to work with the <A -HREF="http://www.cygwin.com">cygwin</A> Unix environment that runs -under Microsoft Windows. - -<P>The following new feature has been added: -<OL> -<LI> A new <B>-t</B> option has been added to - <A HREF="pchk.html#print-pchk"><TT>print-pchk</TT></A>, which - causes it to print the transpose of the parity check matrix. -</OL> - -The following program module change was made: -<OL> - -<LI> The behaviour of <A - HREF="mod2dense.html#invert_selected">mod2dense_invert_selected</A> - has been changed when the matrix has dependent rows. The result returned - contains the inverse of a sub-matrix in its initial columns. The contents - of the remaining columns up to the number of rows was previously undefined, - but these columns are now set to contain zeros. This was done to fix - bug (1) below. -</OL> - -The following bugs were fixed: -<OL> -<LI> A bug has been fixed in - <A HREF="encoding.html#make-gen"><TT>make-gen</TT></A> - which sometimes - produced invalid `dense' or `mixed' generator matrices when the parity - check matrix had redundant rows. - The `sparse' generator matrices were not affected. The output of the - <A HREF="ex-dep"><TT>ex-dep</TT></A> example has changed slightly as a - result. -<LI> The open mode for reading the file of random numbers has been changed from - "r" to "rb", for compatibility with non-Unix systems. -<LI> <A HREF="mod2sparse.html#copy"><TT>mod2sparse_copy</TT></A> has - been fixed so that it copies the <B>lr</B> and <B>pr</B> fields - of entries. -<LI> The "set -v -e" in the command files for the examples has - been replaced by two commands, "set -e" and "set -v", since some - shells can't set two options at once. -</OL> - -A few minor fixes to the documentation have also been made. - - -<H2>Version of 2001-05-04.</H2> - -Changes and new features regarding programs and associated -documentation and examples: -<OL> -<LI> Warnings have been added to the documentation about the dangers of - using zero codewords for testing (due to the possibility of the decoder - accidently being non-symmetric). The examples have been changed to - not use zero codewords, except for - <A HREF="ex-ham7a"><TT>ex-ham7a</TT></A>, which still - demonstrates this facility. -<LI> Decoding by probability propagation has been changed so that if - a probability ratio gets set to NaN ("not a number", the result of - infinite but conflicting evidence from different sources), the probability - ratio is changed to 1, in hopes that something sensible may result. -<LI> The decoding procedures have been changed to decode a bit to a 1 if - there is a tie, so that any resulting asymmetry in decoding will - make zero decoding less, rather than more, likely. See point (1) above. -<LI> All programs now allow a file name argument to be "-", which specifies - standard input or standard output, as appropriate. The - <A HREF="ex-ldpc36-5000a"><TT>ex-ldpc36-5000a</TT></A> example has been - changed to use this facility in order to avoid creating lots of files. -<LI> Channels with noise from a logistic distribution (AWLN) have been - implemented. For details, - see the <A HREF="channel.html">channel documentation</A>. -<LI> The <B>make-gen</B> program for "dense" or "mixed" options was modified - so that when some parity checks are redundant, others are not declared - redundant when they aren't. This makes the result compatible with - what is obtained with the "sparse" option. The example in the - <A HREF="dep-H.html">discussion of linear dependence in parity check - matrices</A> has changed slightly as a result. -<LI> The messages displayed by the <A HREF="decoding.html#decode">decode</A> - program have changed slightly: The block size is no longer displayed, - and the percentage of bits changed is now shown. The data output - when the <B>-t</B> option is specified now includes the number of - bits changed in each block. -<LI> A new <B>-T</B> option to <A HREF="decoding.html#decode">decode</A> - for displaying - <A HREF="decode-detail.html">detailed information on decoding</A> - has been added. -<LI> Doing a <B>make clean</B> will now remove the files created - by running the <A HREF="examples.html">examples</A>. -<LI> The files created by the <A HREF="examples.html">examples</A> now - start with "<TT>ex-</TT>" and contain a ".", to make them easier to - identify for cleanup, and the saved output file now ends in - "<TT>-out</TT>" rather than "<TT>.out</TT>". -<LI> The scripts for the examples now use the <B>-v</B> option of <B>set</B> - rather than <B>-x</B>, so that the command lines are echoed - faithfully as they are read. -<LI> Two new <A HREF="examples.html">examples</A> have been added: - <TT>ex-dep</TT> demonstrates what happens when parity check matrices - have redundant row, and <TT>ex-wrong-model</TT> investigates what - happens when the wrong model is used to decode. -</OL> -Changes and new features regarding program modules and other internals: -<OL> -<LI> Instructions have been added on - <A HREF="modify.html">how to modify the programs</A>, and some - code has been reorganized to facilitate modifications. -<LI> The makefile has been made trivial, simply recompiling everything - from scratch every time. This is simpler and less error prone - than putting in dependencies. - Compiling all the programs takes only about five seconds on a - modern PC. -<LI> The - <A HREF="mod2dense.html#invert_selected"><TT>mod2dense_invert_selected</TT></A> - procedure has been changed - to take an additional argument in which a permutation of rows is - returned. This extension is needed in order for the result when - the matrix is not of full rank to include as many rows as possible, - as needed for the above modification of <B>make-gen</B>. -<LI> New routines - <A HREF="mod2dense.html#copyrows"><TT>mod2dense_copyrows</TT></A> and - <A HREF="mod2sparse.html#copyrows"><TT>mod2sparse_copyrows</TT></A> have - been added, analogous to the previous routines for copying columns. -<LI> The decoding procedures have been changed to always return the bit - probabilities (previously, one could pass a null pointer to suppress - this). This makes things simpler, and facilitates the production of - detailed trace output when the <B>-T</B> option is used. -</OL> - -The following bugs were fixed: -<OL> -<LI> A problem with <B>print-gen</B> prevented the <B>-d</B> option from working - in most cases. The documentation was also fixed to note what - the <B>L</B> and <B>U</B> matrices printed will look like. -<LI> The documentation for - <A HREF="mod2sparse.html#copycols"><TT>mod2sparse_copycols</TT></A> and - <A HREF="mod2dense.html#copycols"><TT>mod2dense_copycols</TT></A> - was ambiguous. It has been clarified. The dense and sparse - implementations were inconsistent. The sparse version has been changed - to match the dense version, which was and is the only version actually - used in the LDPC software. -<LI> In <TT>decode.c</TT>, a variable declared to be <TT>float</TT> was printed - using "<TT>%f</TT>", which strangely didn't work with one compiler. - It's now declared as <TT>double</TT>. -</OL> - -There were also numerous minor cleanups of program code and documentation. - -<H2>Version of 2000-03-19.</H2> - -This was the first public release. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/run-examples b/lib/ldpc/run-examples deleted file mode 100755 index 7d8859e3..00000000 --- a/lib/ldpc/run-examples +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# Run all the examples, and check the output against the corresponding -out -# file. Note that slight differences are possible when the examples are -# run on different machines, due to slightly different round-off errors. - -for e in `ls ex-* | grep -v "\\." | grep -v .-out` -do - echo Running $e: - $e 2>&1 | diff ${e}-out - - echo " " -done diff --git a/lib/ldpc/sparse-LU.html b/lib/ldpc/sparse-LU.html deleted file mode 100755 index 12874aaa..00000000 --- a/lib/ldpc/sparse-LU.html +++ /dev/null @@ -1,90 +0,0 @@ -<HTML><HEAD> - -<TITLE> Sparse LU Decomposition Methods </TITLE> - -</HEAD><BODY> - - -<H1> Sparse LU Decomposition Methods </H1> - -<P>The sparse modulo-2 matrix LU decomposition routine <A -HREF="mod2sparse.html#decomp"><TT>mod2sparse_decomp</TT></A> (which -is used by the <A HREF="encoding.html#make-gen"><TT>make-gen</TT></A> -program when it is asked to create a sparse generator matrix) tries to -find an sub-matrix of a matrix (for <TT>make-gen</TT>, the parity -check matrix), and an ordering of rows and columns for this -sub-matrix, that leads to the lower-triangular matrix <B>L</B> and the -upper-triangular matrix <B>U</B> making up the LU decomposition being -as sparse as possible. Finding an optimal solution is too difficult, -so instead a heuristic strategy is used. - -<P>The overall algorithm finds <B>L</B> and <B>U</B> a column at a -time, from left to right (as reordered, in the case of <B>U</B>). As -this is done, a copy, <B>B</B>, of the original matrix is modified. -To create column <I>i</I> of <B>L</B> and <B>U</B>, some element with -value 1 in <B>B</B> whose row and column indexes, after reordering, -are both greater than <I>i</I> is found. The row and column of this -element are considered to come next in the reordering, and the -contents of the column containing this element is copied to <B>L</B> -and <B>U</B> (upper elements going to <B>U</B>, lower to <B>L</B>). -The row containing this element is then added to some later rows so as -to clear the lower part of this column to zeros. - -<P>At the first step of this process - selecting an element with value -1 from the later rows and columns - there will often be several -possibilities. Different choices can lead to the final result being -more or less sparse. The possible strategies for picking an element -are identified by the constants <TT>Mod2sparse_first</TT>, -<TT>Mod2sparse_mincol</TT>, and <TT>Mod2sparse_minprod</TT>. These -strategies operate as follows: - -<P><TT>Mod2sparse_first</TT> -<BLOCKQUOTE> -Select the first element with value 1 that is encountered in a top -to bottom, left to right search. -</BLOCKQUOTE> - -<P><TT>Mod2sparse_mincol</TT> -<BLOCKQUOTE> -Select the first element with value 1 that is contained in a column -of <B>B</B> that has the smallest number of 1s of any column. -</BLOCKQUOTE> - -<P><TT>Mod2sparse_minprod</TT> -<BLOCKQUOTE> -Select an element with value 1 for which the product of the number of -1s in that row of <B>B</B> minus one times the number of 1s in that -column of <B>B</B> minus one is as small as possible. -</BLOCKQUOTE> - -<P>The <B>abandon_number</B> and <B>abandon_when</B> parameters can -modify the basic strategy. If <B>abandon_number</B> is greater than -zero, then after <B>abandon_when</B> columns have been selected, -<B>abandon_number</B> of the remaining columns are abandoned as -candidates for possible future selection, the abandoned columns being -those with the greatest number of entries. Abandoning such columns -saves space and time, but may make the final result less sparse than -it would otherwise be, and can possibly result in the matrix appearing -to have lower rank than it actually has. - -<P>The methods described here are fairly straightforward adaptations -of standard methods for sparse square matrices of reals, as described, for -example, in -<BLOCKQUOTE> - I. S. Duff, A. M. Erisman, J. K. Reid (1986) <I>Direct Methods for - Sparse Matrices</I>, Oxford: Clarendon Press. -</BLOCKQUOTE> -In the coding context, however, we are interested in matrices of -modulo-2 elements, and it is enough to find a sparse LU decomposition -of any square sub-matrix that can be obtained by selecting columns of -the rectangular parity check matrix. I talked about the application -of sparse matrix methods to encoding of LDPC codes at the 1999 IMA -workshop on Codes, Systems and Graphical Models (see the <A -HREF="refs.html">references</A>). - - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/sparse-encode.pdf b/lib/ldpc/sparse-encode.pdf Binary files differdeleted file mode 100755 index 30629f31..00000000 --- a/lib/ldpc/sparse-encode.pdf +++ /dev/null diff --git a/lib/ldpc/support.html b/lib/ldpc/support.html deleted file mode 100755 index 921881ab..00000000 --- a/lib/ldpc/support.html +++ /dev/null @@ -1,100 +0,0 @@ -<HTML><HEAD> - -<TITLE> Support Programs </TITLE> - -</HEAD><BODY> - - -<H1> Support Programs </H1> - -The following programs provide support for testing and performance -assessment. - - -<P><A NAME="rand-src"><HR><B>rand-src</B>: Generate random message bits. - -<BLOCKQUOTE><PRE> -rand-src <I>source-file seed n-bits</I> -</PRE></BLOCKQUOTE> - -<P>Creates a file of random messages bits called -<TT><I>source-file</I></TT>, which is suitable for testing the -correctness and performance of other programs. The bits in the file -are independent, and are equally likely to be 0 or 1. They are -generated pseudo-randomly based on <TT><I>seed</I></TT>. The actual -random number seed used will be <TT><I>seed</I></TT> times 10 plus 2, -so that the stream of pseudo-random numbers will not be the same as -any that might have been used by another program. - -<P>The <TT><I>n-bits</I></TT> argument specifies the number of bits to -produce. It can be a single number, or it can consist of a block size -and a number of blocks, written with <TT>x</TT> separating these -numbers, with no spaces. Each block is written as a single line, with -the bits in the block represented by the characters '0' and '1', with -no intervening spaces. If the bit count is given by a single number, -the block size is assumed to be one. - -<P><B>Example:</B> The following command produces a file containing -3 blocks, each consisting of 15 random bits, produced using the pseudo-random -number stream identified by the <TT><I>seed</I></TT> of 17: -<UL><PRE> -<LI>rand-src rsrc 17 15x3 -</PRE></UL> -The contents of the file <TT>rsrc</TT> after this command might be something -like the following: -<BLOCKQUOTE><PRE> -111011000110000 -010010110010111 -100000000000111 -</BLOCKQUOTE></PRE> - - -<P><A NAME="verify"><HR><B>verify</B>: Verify that decoded blocks are -codewords, and that they match the source. - -<BLOCKQUOTE><PRE> -verify [ -t ] <I>pchk-file decoded-file</I> [ <I>gen-file</I> [ <I>source-file</I> ] ] -</PRE></BLOCKQUOTE> - -<P>Checks whether or not the blocks in <TT><I>decoded-file</I></TT> -are codewords, according to the parity check matrix in -<TT><I>pchk-file</I></TT>. If <TT><I>gen-file</I></TT> is specified, -the message bits of the blocks are also checked against the -corresponding blocks of <TT><I>source-file</I></TT>, or against zero -if <TT><I>source-file</I></TT> is not given. (Normally, one would -leave out <TT><I>source-file</I></TT> only if the <A -HREF="channel.html#transmit"><TT>transmit</TT></A> command was used -with an argument specifying that zeros are to be transmitted, rather -than a file of encoded data.) - -<P>A summary of the results is displayed on standard error, giving the -total numbers of blocks, the number with parity check errors, and, if -<TT><I>gen-file</I></TT> was specified, the number of blocks with -source errors and the number with errors of both kinds. If -<TT><I>gen-file</I></TT> was specified, a second -summary line displays the bit error rate from -comparing the decoded message bits with the true message bits (zeros -if no <TT><I>source file</I></TT> was given). - -<P>If the <B>-t</B> option is given, block-by-block results are -printed on standard output in two or three columns, giving the block -number (from zero), the number of parity check errors for that block, -and the number of errors in source bits. The last column is omitted -if <TT><I>gen-file</I></TT> is not specified. The columns are -preceded by a line of headers, so the file is suitable for reading -into the S-Plus or R statistics packages, with a command such as -<BLOCKQUOTE><PRE> -data <- read.table(<I>file</I>,header=T) -</PRE></BLOCKQUOTE> - -<P>Warning messages are displayed on standard error if the number of -bits in <TT><I>decoded-file</I></TT> is not a multiple of the block -length, or if <TT><I>source-file</I></TT> is too short. Newlines -in these files are ignored, even though they would normally occur -at the ends of blocks. - -<HR> - -<A HREF="index.html">Back to index for LDPC software</A> - -</BODY></HTML> diff --git a/lib/ldpc/transmit.c b/lib/ldpc/transmit.c deleted file mode 100755 index 14657d68..00000000 --- a/lib/ldpc/transmit.c +++ /dev/null @@ -1,170 +0,0 @@ -/* TRANSMIT.C - Simulate transmission of bits through a channel. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "channel.h" -#include "open.h" -#include "rand.h" - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char *tfile, *rfile; - FILE *tf, *rf; - int block_size, n_bits; - char junk; - int seed; - int cnt; - int n, b; - - /* Look at arguments. The arguments specifying the channel are looked - at by channel_parse in channel.c */ - - if (!(tfile = argv[1]) - || !(rfile = argv[2]) - || !argv[3] || sscanf(argv[3],"%d%c",&seed,&junk)!=1) - { usage(); - } - - n = channel_parse(argv+4,argc-4); - if (n<=0 || argc-4-n!=0) - { usage(); - } - - /* See if the source is all zeros or a file. */ - - if (sscanf(tfile,"%d%c",&n_bits,&junk)==1 && n_bits>0) - { block_size = 1; - tf = NULL; - } - else if (sscanf(tfile,"%dx%d%c",&block_size,&n_bits,&junk)==2 - && block_size>0 && n_bits>0) - { n_bits *= block_size; - tf = NULL; - } - else - { tf = open_file_std(tfile,"r"); - if (tf==NULL) - { fprintf(stderr,"Can't open encoded file to transmit: %s\n",tfile); - exit(1); - } - } - - /* Open output file. */ - - rf = open_file_std(rfile,"w"); - if (rf==NULL) - { fprintf(stderr,"Can't create file for received data: %s\n",rfile); - exit(1); - } - - /* Set random seed to avoid duplications with other programs. */ - - rand_seed(10*seed+3); - - /* Transmit bits. */ - - for (cnt = 0; ; cnt++) - { - /* Get next bit to transmit. */ - - if (tf) /* Data comes from a file */ - { - for (;;) - { b = getc(tf); - if (b!=' ' && b!='\t' && b!='\n' && b!='\r') - { break; - } - putc(b,rf); - } - - if (b==EOF) break; - - if (b!='0' && b!='1') - { fprintf(stderr,"Bad character (code %d) file being transmitted\n",b); - exit(1); - } - } - - else /* Data is all zeros */ - { - if (cnt>0 && cnt%block_size==0) - { putc('\n',rf); - } - - if (cnt==n_bits) break; - - b = '0'; - } - - b = b=='1'; - - /* Produce the channel output for this transmitted bit. */ - - switch (channel) - { case BSC: - { int bsc_noise; - bsc_noise = rand_uniform() < error_prob; - fprintf (rf, "%d", b^bsc_noise); - break; - } - case AWGN: - { double awgn_noise; - awgn_noise = std_dev * rand_gaussian(); - fprintf (rf, " %+5.2f", b ? 1+awgn_noise : -1+awgn_noise); - break; - } - case AWLN: - { double awln_noise; - awln_noise = lwidth * rand_logistic(); - fprintf (rf, " %+5.2f", b ? 1+awln_noise : -1+awln_noise); - break; - } - default: - { abort(); - } - } - } - - fprintf(stderr,"Transmitted %d bits\n",cnt); - - if (ferror(rf) || fclose(rf)!=0) - { fprintf(stderr,"Error writing received bits to %s\n",rfile); - exit(1); - } - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr, - "Usage: transmit encoded-file|n-zeros received-file seed channel\n"); - channel_usage(); - exit(1); -} diff --git a/lib/ldpc/verify.c b/lib/ldpc/verify.c deleted file mode 100755 index e52f79d8..00000000 --- a/lib/ldpc/verify.c +++ /dev/null @@ -1,254 +0,0 @@ -/* VERIFY.C - Verify encoded or decoded blocks. */ - -/* Copyright (c) 1995-2012 by Radford M. Neal. - * - * Permission is granted for anyone to copy, use, modify, and distribute - * these programs and accompanying documents for any purpose, provided - * this copyright notice is retained and prominently displayed, and note - * is made of any changes made to these programs. These programs and - * documents are distributed without any warranty, express or implied. - * As the programs were written for research purposes only, they have not - * been tested to the degree that would be advisable in any important - * application. All use of these programs is entirely at the user's own - * risk. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "alloc.h" -#include "blockio.h" -#include "open.h" -#include "mod2sparse.h" -#include "mod2dense.h" -#include "mod2convert.h" -#include "rcode.h" -#include "check.h" - -void usage(void); - - -/* MAIN PROGRAM. */ - -int main -( int argc, - char **argv -) -{ - char *coded_file, *source_file; - char *pchk_file, *gen_file; - int table; - - char *sblk, *cblk, *chks; - int seof, ceof; - int srcerr, chkerr, bit_errs; - int i, n; - FILE *srcf, *codef; - - int tot_srcerrs, tot_chkerrs, tot_botherrs, tot_undeterrs, tot_good; - - /* Look at arguments. */ - - table = 0; - if (argc>1 && strcmp(argv[1],"-t")==0) - { table = 1; - argc -= 1; - argv += 1; - } - - if (argc<3 || argc>5) usage(); - - if (!(pchk_file = argv[1]) - || !(coded_file = argv[2])) - { usage(); - } - - gen_file = 0; - source_file = 0; - - if (argv[3]) - { gen_file = argv[3]; - if (argv[4]) - { source_file = argv[4]; - if (argv[5]) - { usage(); - } - } - } - - if ((strcmp(pchk_file,"-")==0) - + (strcmp(coded_file,"-")==0) - + (source_file!=0 && strcmp(source_file,"-")==0) - + (gen_file!=0 && strcmp(gen_file,"-")==0) > 1) - { fprintf(stderr,"Can't read more than one stream from standard input\n"); - exit(1); - } - - /* Read parity check file. */ - - read_pchk(pchk_file); - - if (N<=M) - { fprintf(stderr, - "Number of bits (%d) should be greater than number of checks (%d)\n",N,M); - exit(1); - } - - /* Read generator matrix file, if given, up to the point of finding - out which are the message bits. */ - - if (gen_file!=0) - { read_gen(gen_file,1,0); - } - - /* Open coded file to check. */ - - codef = open_file_std(coded_file,"r"); - if (codef==NULL) - { fprintf(stderr,"Can't open coded file: %s\n",coded_file); - exit(1); - } - - /* Open source file to verify against, if given. */ - - if (source_file!=0) - { - srcf = open_file_std(source_file,"r"); - if (srcf==NULL) - { fprintf(stderr,"Can't open source file: %s\n",source_file); - exit(1); - } - } - - sblk = chk_alloc (N-M, sizeof *sblk); - cblk = chk_alloc (N, sizeof *cblk); - chks = chk_alloc (M, sizeof *chks); - - /* Print header for table. */ - - if (table) - { if (gen_file!=0) - { printf(" block chkerrs srcerrs\n"); - } - else - { printf(" block chkerrs\n"); - } - } - - /* Verify successive blocks. */ - - tot_srcerrs = 0; - tot_chkerrs = 0; - tot_botherrs = 0; - tot_undeterrs = 0; - tot_good = 0; - - bit_errs = 0; - - seof = 0; - ceof = 0; - - for (n = 0; ; n++) - { - /* Read block from coded file. */ - - if (blockio_read(codef,cblk,N)==EOF) - { ceof = 1; - } - - /* Read block from source file, if given. */ - - if (source_file!=0 && !ceof && !seof) - { if (blockio_read(srcf,sblk,N-M)==EOF) - { fprintf(stderr,"Warning: Not enough source blocks (only %d)\n",n); - seof = 1; - } - } - - /* Stop if end of received file. */ - - if (ceof) break; - - /* Check that received block is a code word, and if not find the number of - parity check errors. */ - - chkerr = check(H,cblk,chks); - - /* Check against source block, if provided, or against zeros, if - the generator matrix was provided but no source file. */ - - if (gen_file!=0) - { srcerr = 0; - if (source_file!=0 && !seof) - { for (i = M; i<N; i++) - { if (cblk[cols[i]]!=sblk[i-M]) - { srcerr += 1; - } - } - } - if (source_file==0) - { for (i = M; i<N; i++) - { if (cblk[cols[i]]!=0) - { srcerr += 1; - } - } - } - bit_errs += srcerr; - } - - /* Print table entry. */ - - if (table) - { if (gen_file!=0) - { printf("%6d %7d %7d\n",n,chkerr,srcerr); - } - else - { printf("%6d %7d\n",n,chkerr); - } - } - - /* Increment totals. */ - - if (chkerr) tot_chkerrs += 1; - if (gen_file!=0 && (source_file==0 || !seof)) - { if (srcerr) tot_srcerrs += 1; - if (srcerr && chkerr) tot_botherrs += 1; - if (srcerr && (chkerr==0) ) tot_undeterrs += 1; - if ((srcerr==0) && (chkerr==0) ) tot_good += 1; - } - } - - /* Write final statistics to standard error. Flush standard output - first to avoid mixing of output. */ - - fflush(stdout); - - if (gen_file!=0) - { fprintf(stderr, - "Block counts: tot %d, with chk errs %d, with src errs %d, both %d\n", - n, tot_chkerrs, tot_srcerrs, tot_botherrs, tot_undeterrs); - fprintf(stderr, - "Total good frames: %d Total undetected errors: %d\n", - tot_good, tot_undeterrs); - fprintf(stderr, - "Bit error rate (on message bits only): %.3e\n", - (double)bit_errs/(n*(N-M))); - } - else - { fprintf (stderr, - "Block counts: tot %d, with chk errs %d\n", n, tot_chkerrs); - } - - return 0; -} - - -/* PRINT USAGE MESSAGE AND EXIT. */ - -void usage(void) -{ fprintf(stderr, - "Usage: verify [ -t ] pchk-file decoded-file [ gen-file [ source-file ] ]\n"); - exit(1); -} diff --git a/lib/ldpc_128_90_b_generator.f90 b/lib/ldpc_128_90_b_generator.f90 new file mode 100644 index 00000000..97cb2b85 --- /dev/null +++ b/lib/ldpc_128_90_b_generator.f90 @@ -0,0 +1,41 @@ +character*23 g(38) + +data g/ & + "c555076254d8161b5cf0d3c", & + "de721b14e8339ab48de8e54", & + "e72d0efb6ca44934a896ca0", & + "631b7cc783a5e626c360598", & + "7050206b9b2e40439d17d94", & + "2f31c22ab472282d65cde44", & + "822baa20e8bcd6487d34268", & + "f9a85b9d103459b8ac34830", & + "60335e63618f9e59e031a5c", & + "b106c464771df41ab75884c", & + "3936fcebf87320d200e6b1c", & + "00135e63218f1c59c031e5c", & + "554abf55a1605425b8e8248", & + "2211850e5b32c02e42c85ec", & + "853e66d64fdf2f5cf4237a8", & + "90592d932a0c8e8190e6c50", & + "d0cdf8954d48457b6a43df0", & + "83714b5735b5bcd718887f0", & + "3146c024731df43a3750844", & + "a231a50e5232c0ae40c8dac", & + "8f5f0d73fab5d0d57bb9c48", & + "5650a8094847925466e560c", & + "5842d5c55ff32151f36ca3c", & + "0f571d7bfab4d0c57bfbcc8", & + "bb68edb9987ea6a4f56a214", & + "9d7cb35b100c0e8d07cff80", & + "6774a36c46e8d7b518780b0", & + "b07ca6f22cc3db62ca73fac", & + "d6610575c99c82edcddd028", & + "e64c7bb5d67de03d1fb0824", & + "e9bb04fe35bb65a16e856ec", & + "6c5c41bc591174e3b81e950", & + "49b480238e0623d1dd61e08", & + "c48ae6d581d94c8c2b4a8a0", & + "a16ace594ec778f95e5020c", & + "ef2cd3309b2a4e8e9a98614", & + "06008a62f368d236fbf2998", & + "015fe1f7dd017a9f67be59c"/ diff --git a/lib/ldpc_128_90_b_reordered_parity.f90 b/lib/ldpc_128_90_b_reordered_parity.f90 new file mode 100644 index 00000000..c46719b4 --- /dev/null +++ b/lib/ldpc_128_90_b_reordered_parity.f90 @@ -0,0 +1,184 @@ +data Mn/ & + 10, 25, 37, 0, & + 1, 19, 20, 0, & + 20, 27, 29, 0, & + 3, 22, 36, 0, & + 4, 26, 30, 0, & + 5, 15, 28, 0, & + 6, 21, 23, 0, & + 7, 16, 32, 0, & + 9, 31, 38, 0, & + 10, 13, 18, 0, & + 11, 20, 37, 0, & + 12, 24, 33, 0, & + 14, 25, 33, 0, & + 15, 17, 32, 0, & + 1, 9, 14, 0, & + 2, 16, 17, 0, & + 3, 5, 18, 0, & + 4, 23, 38, 0, & + 6, 24, 37, 0, & + 7, 25, 35, 0, & + 8, 29, 33, 0, & + 10, 30, 36, 0, & + 11, 27, 28, 0, & + 12, 22, 32, 0, & + 13, 17, 21, 0, & + 10, 19, 31, 0, & + 18, 26, 34, 0, & + 1, 5, 30, 0, & + 2, 19, 25, 0, & + 3, 9, 21, 0, & + 4, 8, 11, 0, & + 6, 35, 38, 0, & + 7, 13, 29, 0, & + 12, 20, 26, 0, & + 14, 24, 27, 0, & + 15, 23, 34, 0, & + 16, 31, 37, 0, & + 10, 22, 28, 0, & + 28, 34, 36, 0, & + 1, 37, 38, 0, & + 2, 5, 13, 0, & + 3, 7, 14, 0, & + 4, 16, 19, 0, & + 6, 18, 29, 0, & + 8, 17, 23, 0, & + 9, 33, 36, 0, & + 11, 12, 35, 0, & + 15, 25, 27, 0, & + 20, 30, 32, 0, & + 21, 24, 26, 0, & + 22, 31, 33, 0, & + 1, 3, 17, 0, & + 2, 8, 36, 0, & + 4, 14, 34, 0, & + 5, 20, 24, 0, & + 6, 12, 30, 0, & + 7, 19, 37, 0, & + 9, 22, 23, 0, & + 10, 27, 35, 0, & + 11, 25, 38, 0, & + 13, 28, 31, 0, & + 11, 15, 29, 0, & + 16, 18, 21, 0, & + 26, 27, 32, 0, & + 1, 4, 10, 0, & + 2, 9, 29, 32, & + 3, 6, 20, 33, & + 5, 21, 31, 34, & + 7, 8, 15, 30, & + 12, 13, 14, 16, & + 17, 22, 26, 37, & + 15, 18, 36, 38, & + 19, 22, 24, 35, & + 12, 23, 25, 28, & + 1, 13, 32, 33, & + 2, 11, 14, 18, & + 3, 10, 26, 38, & + 4, 24, 31, 32, & + 5, 6, 17, 25, & + 7, 9, 24, 28, & + 8, 9, 34, 37, & + 16, 20, 23, 35, & + 19, 21, 27, 30, & + 16, 26, 29, 36, & + 1, 22, 25, 29, & + 2, 3, 15, 37, & + 4, 12, 21, 36, & + 5, 8, 14, 19, & + 6, 7, 10, 34, & + 11, 17, 19, 33, & + 1, 12, 31, 0, & + 2, 4, 33, 0, & + 3, 16, 30, 0, & + 1, 2, 24, 0, & + 5, 23, 27, 0, & + 6, 28, 32, 0, & + 7, 17, 36, 0, & + 8, 22, 38, 0, & + 9, 18, 20, 0, & + 10, 21, 29, 0, & + 11, 13, 34, 0, & + 4, 20, 22, 0, & + 7, 11, 21, 0, & + 14, 35, 37, 0, & + 15, 19, 26, 0, & + 3, 28, 29, 0, & + 9, 13, 35, 0, & + 14, 17, 30, 0, & + 10, 15, 33, 0, & + 5, 12, 37, 0, & + 18, 25, 32, 0, & + 8, 16, 27, 0, & + 19, 34, 38, 0, & + 24, 25, 36, 0, & + 2, 28, 35, 0, & + 19, 23, 36, 0, & + 3, 12, 34, 0, & + 9, 15, 16, 0, & + 4, 5, 7, 0, & + 1, 8, 21, 0, & + 6, 13, 22, 0, & + 11, 24, 30, 0, & + 8, 26, 35, 0, & + 6, 26, 31, 0, & + 14, 32, 38, 0, & + 18, 23, 33, 0, & + 2, 27, 34, 0, & + 17, 29, 31, 0/ + +data Nm/ & + 2, 15, 28, 40, 52, 65, 75, 85, 91, 94, 120, 0, & + 16, 29, 41, 53, 66, 76, 86, 92, 94, 115, 127, 0, & + 4, 17, 30, 42, 52, 67, 77, 86, 93, 106, 117, 0, & + 5, 18, 31, 43, 54, 65, 78, 87, 92, 102, 119, 0, & + 6, 17, 28, 41, 55, 68, 79, 88, 95, 110, 119, 0, & + 7, 19, 32, 44, 56, 67, 79, 89, 96, 121, 124, 0, & + 8, 20, 33, 42, 57, 69, 80, 89, 97, 103, 119, 0, & + 21, 31, 45, 53, 69, 81, 88, 98, 112, 120, 123, 0, & + 9, 15, 30, 46, 58, 66, 80, 81, 99, 107, 118, 0, & + 1, 10, 22, 26, 38, 59, 65, 77, 89, 100, 109, 0, & + 11, 23, 31, 47, 60, 62, 76, 90, 101, 103, 122, 0, & + 12, 24, 34, 47, 56, 70, 74, 87, 91, 110, 117, 0, & + 10, 25, 33, 41, 61, 70, 75, 101, 107, 121, 0, 0, & + 13, 15, 35, 42, 54, 70, 76, 88, 104, 108, 125, 0, & + 6, 14, 36, 48, 62, 69, 72, 86, 105, 109, 118, 0, & + 8, 16, 37, 43, 63, 70, 82, 84, 93, 112, 118, 0, & + 14, 16, 25, 45, 52, 71, 79, 90, 97, 108, 128, 0, & + 10, 17, 27, 44, 63, 72, 76, 99, 111, 126, 0, 0, & + 2, 26, 29, 43, 57, 73, 83, 88, 90, 105, 113, 116, & + 2, 3, 11, 34, 49, 55, 67, 82, 99, 102, 0, 0, & + 7, 25, 30, 50, 63, 68, 83, 87, 100, 103, 120, 0, & + 4, 24, 38, 51, 58, 71, 73, 85, 98, 102, 121, 0, & + 7, 18, 36, 45, 58, 74, 82, 95, 116, 126, 0, 0, & + 12, 19, 35, 50, 55, 73, 78, 80, 94, 114, 122, 0, & + 1, 13, 20, 29, 48, 60, 74, 79, 85, 111, 114, 0, & + 5, 27, 34, 50, 64, 71, 77, 84, 105, 123, 124, 0, & + 3, 23, 35, 48, 59, 64, 83, 95, 112, 127, 0, 0, & + 6, 23, 38, 39, 61, 74, 80, 96, 106, 115, 0, 0, & + 3, 21, 33, 44, 62, 66, 84, 85, 100, 106, 128, 0, & + 5, 22, 28, 49, 56, 69, 83, 93, 108, 122, 0, 0, & + 9, 26, 37, 51, 61, 68, 78, 91, 124, 128, 0, 0, & + 8, 14, 24, 49, 64, 66, 75, 78, 96, 111, 125, 0, & + 12, 13, 21, 46, 51, 67, 75, 90, 92, 109, 126, 0, & + 27, 36, 39, 54, 68, 81, 89, 101, 113, 117, 127, 0, & + 20, 32, 47, 59, 73, 82, 104, 107, 115, 123, 0, 0, & + 4, 22, 39, 46, 53, 72, 84, 87, 97, 114, 116, 0, & + 1, 11, 19, 37, 40, 57, 71, 81, 86, 104, 110, 0, & + 9, 18, 32, 40, 60, 72, 77, 98, 113, 125, 0, 0/ + +data nrw/ & +11,11,11,11,11,11,11,11,11,11,11,11,10,11,11,11, & +11,10,12,10,11,11,10,11,11,11,10,10,11,10,10,11, & +11,11,10,11,11,10/ + +data ncw/ & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, & +4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3/ diff --git a/lib/ldpc_128_90_generator.f90 b/lib/ldpc_128_90_generator.f90 new file mode 100644 index 00000000..200d1703 --- /dev/null +++ b/lib/ldpc_128_90_generator.f90 @@ -0,0 +1,41 @@ +character*23 g(38) + +data g/ & + "a08ea80879050a5e94da994", & + "59f3b48040ca089c81ee880", & + "e4070262802e31b7b17d3dc", & + "95cbcbaf032dc3d960bacc8", & + "c4d79b5dcc21161a254ffbc", & + "93fde9cdbf2622a70868424", & + "e73b888bb1b01167379ba28", & + "45a0d0a0f39a7ad2439949c", & + "759acef19444bcad79c4964", & + "71eb4dddf4f5ed9e2ea17e0", & + "80f0ad76fb247d6b4ca8d38", & + "184fff3aa1b82dc66640104", & + "ca4e320bb382ed14cbb1094", & + "52514447b90e25b9e459e28", & + "dd10c1666e071956bd0df38", & + "99c332a0b792a2da8ef1ba8", & + "7bd9f688e7ed402e231aaac", & + "00fcad76eb647d6a0ca8c38", & + "6ac8d0499c43b02eed78d70", & + "2c2c764baf795b4788db010", & + "0e907bf9e280d2624823dd0", & + "b857a6e315afd8c1c925e64", & + "8deb58e22d73a141cae3778", & + "22d3cb80d92d6ac132dfe08", & + "754763877b28c187746855c", & + "1d1bb7cf6953732e04ebca4", & + "2c65e0ea4466ab9f5e1deec", & + "6dc530ca37fc916d1f84870", & + "49bccbbee152355be7ac984", & + "e8387f3f4367cf45a150448", & + "8ce25e03d67d51091c81884", & + "b798012ffa40a93852752c8", & + "2e43307933adfca37adc3c8", & + "ca06e0a42ca1ec782d6c06c", & + "c02b762927556a7039e638c", & + "4a3e9b7d08b6807f8619fac", & + "45e8030f68997bb68544424", & + "7e79362c16773efc6482e30"/ diff --git a/lib/ldpc_128_90_reordered_parity.f90 b/lib/ldpc_128_90_reordered_parity.f90 new file mode 100644 index 00000000..b3a5e9b8 --- /dev/null +++ b/lib/ldpc_128_90_reordered_parity.f90 @@ -0,0 +1,176 @@ +data Mn/ & + 21, 34, 36, & + 1, 8, 28, & + 2, 9, 37, & + 3, 7, 19, & + 4, 16, 32, & + 2, 5, 22, & + 6, 13, 25, & + 10, 31, 33, & + 11, 24, 27, & + 12, 15, 23, & + 14, 18, 26, & + 17, 20, 29, & + 17, 30, 34, & + 6, 34, 35, & + 1, 10, 30, & + 3, 18, 23, & + 4, 12, 25, & + 5, 28, 36, & + 7, 14, 21, & + 8, 15, 31, & + 9, 27, 32, & + 11, 19, 35, & + 13, 16, 37, & + 20, 24, 38, & + 21, 22, 26, & + 12, 29, 33, & + 1, 17, 35, & + 2, 28, 30, & + 3, 10, 32, & + 4, 8, 36, & + 5, 19, 29, & + 6, 20, 27, & + 7, 22, 37, & + 9, 11, 33, & + 13, 24, 26, & + 14, 31, 34, & + 15, 16, 25, & + 13, 18, 38, & + 8, 20, 23, & + 1, 32, 33, & + 2, 17, 19, & + 3, 24, 34, & + 4, 7, 38, & + 5, 11, 31, & + 6, 18, 21, & + 9, 15, 36, & + 10, 16, 28, & + 12, 26, 30, & + 14, 27, 29, & + 22, 25, 35, & + 23, 30, 32, & + 4, 11, 37, & + 1, 14, 23, & + 2, 8, 25, & + 3, 13, 27, & + 5, 10, 37, & + 6, 16, 31, & + 7, 15, 18, & + 9, 22, 24, & + 12, 19, 36, & + 17, 26, 38, & + 20, 21, 33, & + 20, 28, 35, & + 4, 29, 34, & + 1, 26, 36, & + 2, 23, 34, & + 3, 9, 38, & + 5, 6, 17, & + 7, 27, 35, & + 8, 14, 32, & + 10, 15, 22, & + 11, 18, 29, & + 12, 13, 28, & + 16, 19, 33, & + 21, 25, 31, & + 24, 30, 37, & + 1, 3, 21, & + 2, 18, 31, & + 4, 6, 9, & + 5, 8, 33, & + 7, 29, 32, & + 10, 13, 19, & + 11, 22, 23, & + 12, 27, 34, & + 14, 15, 30, & + 16, 27, 38, & + 17, 28, 37, & + 20, 25, 26, & + 5, 24, 35, & + 3, 6, 36, & + 1, 12, 31, & + 2, 4, 33, & + 3, 16, 30, & + 1, 2, 24, & + 5, 23, 27, & + 6, 28, 32, & + 7, 17, 36, & + 8, 22, 38, & + 9, 18, 20, & + 10, 21, 29, & + 11, 13, 34, & + 4, 14, 20, & + 11, 30, 38, & + 14, 35, 37, & + 15, 19, 26, & + 3, 28, 29, & + 7, 8, 9, & + 5, 18, 34, & + 13, 15, 17, & + 12, 16, 35, & + 10, 23, 25, & + 19, 21, 37, & + 17, 27, 31, & + 24, 25, 36, & + 1, 18, 19, & + 6, 26, 33, & + 22, 31, 32, & + 3, 20, 22, & + 4, 21, 27, & + 2, 13, 29, & + 6, 7, 12, & + 15, 24, 32, & + 9, 25, 30, & + 23, 37, 38, & + 5, 16, 26, & + 11, 14, 28, & + 33, 36, 38, & + 8, 10, 35/ + +data Nm/ & + 2, 15, 27, 40, 53, 65, 77, 91, 94, 115, 0, & + 3, 6, 28, 41, 54, 66, 78, 92, 94, 120, 0, & + 4, 16, 29, 42, 55, 67, 77, 90, 93, 106, 118, & + 5, 17, 30, 43, 52, 64, 79, 92, 102, 119, 0, & + 6, 18, 31, 44, 56, 68, 80, 89, 95, 108, 125, & + 7, 14, 32, 45, 57, 68, 79, 90, 96, 116, 121, & + 4, 19, 33, 43, 58, 69, 81, 97, 107, 121, 0, & + 2, 20, 30, 39, 54, 70, 80, 98, 107, 128, 0, & + 3, 21, 34, 46, 59, 67, 79, 99, 107, 123, 0, & + 8, 15, 29, 47, 56, 71, 82, 100, 111, 128, 0, & + 9, 22, 34, 44, 52, 72, 83, 101, 103, 126, 0, & + 10, 17, 26, 48, 60, 73, 84, 91, 110, 121, 0, & + 7, 23, 35, 38, 55, 73, 82, 101, 109, 120, 0, & + 11, 19, 36, 49, 53, 70, 85, 102, 104, 126, 0, & + 10, 20, 37, 46, 58, 71, 85, 105, 109, 122, 0, & + 5, 23, 37, 47, 57, 74, 86, 93, 110, 125, 0, & + 12, 13, 27, 41, 61, 68, 87, 97, 109, 113, 0, & + 11, 16, 38, 45, 58, 72, 78, 99, 108, 115, 0, & + 4, 22, 31, 41, 60, 74, 82, 105, 112, 115, 0, & + 12, 24, 32, 39, 62, 63, 88, 99, 102, 118, 0, & + 1, 19, 25, 45, 62, 75, 77, 100, 112, 119, 0, & + 6, 25, 33, 50, 59, 71, 83, 98, 117, 118, 0, & + 10, 16, 39, 51, 53, 66, 83, 95, 111, 124, 0, & + 9, 24, 35, 42, 59, 76, 89, 94, 114, 122, 0, & + 7, 17, 37, 50, 54, 75, 88, 111, 114, 123, 0, & + 11, 25, 35, 48, 61, 65, 88, 105, 116, 125, 0, & + 9, 21, 32, 49, 55, 69, 84, 86, 95, 113, 119, & + 2, 18, 28, 47, 63, 73, 87, 96, 106, 126, 0, & + 12, 26, 31, 49, 64, 72, 81, 100, 106, 120, 0, & + 13, 15, 28, 48, 51, 76, 85, 93, 103, 123, 0, & + 8, 20, 36, 44, 57, 75, 78, 91, 113, 117, 0, & + 5, 21, 29, 40, 51, 70, 81, 96, 117, 122, 0, & + 8, 26, 34, 40, 62, 74, 80, 92, 116, 127, 0, & + 1, 13, 14, 36, 42, 64, 66, 84, 101, 108, 0, & + 14, 22, 27, 50, 63, 69, 89, 104, 110, 128, 0, & + 1, 18, 30, 46, 60, 65, 90, 97, 114, 127, 0, & + 3, 23, 33, 52, 56, 76, 87, 104, 112, 124, 0, & + 24, 38, 43, 61, 67, 86, 98, 103, 124, 127, 0/ + +data nrw/ & +10,10,11,10,11,11,10,10,10,10,10,10,10,10,10,10,10,10, & +10,10,10,10,10,10,10,10,11,10,10,10,10,10,10,10,10,10, & +10,10/ + +ncw=3 diff --git a/lib/ldpcsim128_90.f90 b/lib/ldpcsim128_90.f90 new file mode 100644 index 00000000..05b424b7 --- /dev/null +++ b/lib/ldpcsim128_90.f90 @@ -0,0 +1,135 @@ +program ldpcsim128_90 + +! Simulate the performance of the (128,90) code that is used in +! the second incarnation of MSK144. + + use packjt77 + integer, parameter:: NRECENT=10, N=128, K=90, M=N-K + character*12 recent_calls(NRECENT) + character*37 msg,msgsent,msgreceived + character*77 c77 + character*8 arg + integer*1 codeword(N), message77(77) + integer*1 apmask(N),cw(N) + integer*1 msgbits(77) + integer*4 i4Msg6BitWords(13) + integer nerrtot(0:N),nerrdec(0:N) + logical unpk77_success + real*8 rxdata(N), rxavgd(N) + real llr(N) + + do i=1,NRECENT + recent_calls(i)=' ' + enddo + nerrtot=0 + nerrdec=0 + + nargs=iargc() + if(nargs.ne.4) then + print*,'Usage: ldpcsim niter navg #trials s ' + print*,'eg: ldpcsim 10 1 1000 0.75' + return + endif + call getarg(1,arg) + read(arg,*) max_iterations + call getarg(2,arg) + read(arg,*) navg + call getarg(3,arg) + read(arg,*) ntrials + call getarg(4,arg) + read(arg,*) s + + rate=real(77)/real(N) + + write(*,*) "rate: ",rate + write(*,*) "niter= ",max_iterations," navg= ",navg," s= ",s + + msg="K1ABC RR73; W9XYZ <KH1/KH7Z> -12" + i3=0 + n3=1 + call pack77(msg,i3,n3,c77) + call unpack77(c77,msgsent,unpk77_success) + read(c77,'(77i1)') msgbits + + write(*,*) "message sent ",msgsent + + write(*,*) 'msgbits' + write(*,'(77i1)') msgbits + +! msgbits is the 77-bit message, codeword is 128 bits + call encode_128_90(msgbits,codeword) + +! call init_random_seed() + + write(*,*) "Eb/N0 SNR2500 ngood nundetected sigma psymerr" + do idb = 14,0,-1 + db=idb/2.0-1.0 + sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) + ngood=0 + nue=0 + nbadcrc=0 + nsumerr=0 + + do itrial=1, ntrials + rxavgd=0d0 + do iav=1,navg +! call sgran() +! Create a realization of a noisy received word + do i=1,N + rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran() + enddo + rxavgd=rxavgd+rxdata + enddo + rxdata=rxavgd + nerr=0 + do i=1,N + if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1 + enddo + nerrtot(nerr)=nerrtot(nerr)+1 + + rxav=sum(rxdata)/N + rx2av=sum(rxdata*rxdata)/N + rxsig=sqrt(rx2av-rxav*rxav) + rxdata=rxdata/rxsig +! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of +! magnitude in UER + if( s .lt. 0 ) then + ss=sigma + else + ss=s + endif + + llr=2.0*rxdata/(ss*ss) + + apmask=0 +! max_iterations is max number of belief propagation iterations + call bpdecode128_90(llr, apmask, max_iterations, message77, cw, nharderrors, niterations) + +! If the decoder finds a valid codeword, nharderrors will be .ge. 0. + if( nharderrors .ge. 0 ) then + write(c77,'(77i1)') message77 + call unpack77(c77,msgreceived,unpk77_success) + nhw=count(cw.ne.codeword) + if(nhw.eq.0) then ! this is a good decode + ngood=ngood+1 + nerrdec(nerr)=nerrdec(nerr)+1 + else ! this is an undetected error + nue=nue+1 + endif + endif + nsumerr=nsumerr+nerr + enddo + + snr2500=db+10*log10(rate*2000.0/2500.0) ! symbol rate is 2000 s^-1 and ref BW is 2500 Hz. + pberr=real(nsumerr)/real(ntrials*N) + write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,7x,f5.2,3x,e10.3)") db,snr2500,ngood,nue,ss,pberr + + enddo + + open(unit=23,file='nerrhisto.dat',status='unknown') + do i=0,N + write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10) + enddo + close(23) + +end program ldpcsim128_90 diff --git a/lib/ldpcsim144.f90 b/lib/ldpcsim144.f90 deleted file mode 100644 index 66dbfbf0..00000000 --- a/lib/ldpcsim144.f90 +++ /dev/null @@ -1,175 +0,0 @@ -program ldpcsim - -use, intrinsic :: iso_c_binding -use iso_c_binding, only: c_loc,c_size_t -use hashing -use packjt -parameter(NRECENT=10) -character*12 recent_calls(NRECENT) -character*22 msg,msgsent,msgreceived -character*8 arg -integer*1, allocatable :: codeword(:), decoded(:), message(:) -integer*1, target:: i1Msg8BitBytes(10) -integer*1 i1hash(4) -integer*1 msgbits(80) -integer*4 i4Msg6BitWords(13) -integer ihash -integer nerrtot(128),nerrdec(128) -real*8, allocatable :: lratio(:), rxdata(:), rxavgd(:) -real, allocatable :: yy(:), llr(:) -equivalence(ihash,i1hash) - -do i=1,NRECENT - recent_calls(i)=' ' -enddo -nerrtot=0 -nerrdec=0 - -nargs=iargc() -if(nargs.ne.4) then - print*,'Usage: ldpcsim niter navg #trials s ' - print*,'eg: ldpcsim 10 1 1000 0.75' - return -endif -call getarg(1,arg) -read(arg,*) max_iterations -call getarg(2,arg) -read(arg,*) navg -call getarg(3,arg) -read(arg,*) ntrials -call getarg(4,arg) -read(arg,*) s - -! don't count hash bits as data bits -N=128 -K=72 -rate=real(K)/real(N) - -write(*,*) "rate: ",rate - -write(*,*) "niter= ",max_iterations," navg= ",navg," s= ",s - -allocate ( codeword(N), decoded(K), message(K) ) -allocate ( lratio(N), rxdata(N), rxavgd(N), yy(N), llr(N) ) - -msg="K9AN K1JT EN50" - call packmsg(msg,i4Msg6BitWords,itype,.false.) !Pack into 12 6-bit bytes - call unpackmsg(i4Msg6BitWords,msgsent,.false.,' ') !Unpack to get msgsent - write(*,*) "message sent ",msgsent - - i4=0 - ik=0 - im=0 - do i=1,12 - nn=i4Msg6BitWords(i) - do j=1, 6 - ik=ik+1 - i4=i4+i4+iand(1,ishft(nn,j-6)) - i4=iand(i4,255) - if(ik.eq.8) then - im=im+1 -! if(i4.gt.127) i4=i4-256 - i1Msg8BitBytes(im)=i4 - ik=0 - endif - enddo - enddo - - ihash=nhash(c_loc(i1Msg8BitBytes),int(9,c_size_t),146) - ihash=2*iand(ihash,32767) !Generate the 8-bit hash - i1Msg8BitBytes(10)=i1hash(1) !Hash code to byte 10 - mbit=0 - do i=1, 10 - i1=i1Msg8BitBytes(i) - do ibit=1,8 - mbit=mbit+1 - msgbits(mbit)=iand(1,ishft(i1,ibit-8)) - enddo - enddo - call encode_msk144(msgbits,codeword) - call init_random_seed() - -write(*,*) "Eb/N0 SNR2500 ngood nundetected nbadhash sigma" -do idb = -6, 14 - db=idb/2.0-1.0 - sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) - ngood=0 - nue=0 - nbadhash=0 - - do itrial=1, ntrials - rxavgd=0d0 - do iav=1,navg - call sgran() -! Create a realization of a noisy received word - do i=1,N - rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran() - enddo - rxavgd=rxavgd+rxdata - enddo - rxdata=rxavgd - nerr=0 - do i=1,N - if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1 - enddo - nerrtot(nerr)=nerrtot(nerr)+1 - -! Correct signal normalization is important for this decoder. - rxav=sum(rxdata)/N - rx2av=sum(rxdata*rxdata)/N - rxsig=sqrt(rx2av-rxav*rxav) - rxdata=rxdata/rxsig -! To match the metric to the channel, s should be set to the noise standard deviation. -! For now, set s to the value that optimizes decode probability near threshold. -! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of -! magnitude in UER - if( s .lt. 0 ) then - ss=sigma - else - ss=s - endif - - llr=2.0*rxdata/(ss*ss) - lratio=exp(llr) - yy=rxdata - -! max_iterations is max number of belief propagation iterations -! call ldpc_decode(lratio, decoded, max_iterations, niterations, max_dither, ndither) -! call amsdecode(yy, max_iterations, decoded, niterations) -! call bitflipmsk144(rxdata, decoded, niterations) - call bpdecode144(llr, max_iterations, decoded, niterations) - -! If the decoder finds a valid codeword, niterations will be .ge. 0. - if( niterations .ge. 0 ) then - call extractmessage144(decoded,msgreceived,nhashflag,recent_calls,nrecent) - if( nhashflag .ne. 1 ) then - nbadhash=nbadhash+1 - endif - nueflag=0 - -! Check the message plus hash against what was sent. - do i=1,K - if( msgbits(i) .ne. decoded(i) ) then - nueflag=1 - endif - enddo - if( nhashflag .eq. 1 .and. nueflag .eq. 0 ) then - ngood=ngood+1 - nerrdec(nerr)=nerrdec(nerr)+1 - else if( nhashflag .eq. 1 .and. nueflag .eq. 1 ) then - nue=nue+1; - endif - endif - enddo - snr2500=db-3.5 - write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2)") db,snr2500,ngood,nue,nbadhash,ss - -enddo - -open(unit=23,file='nerrhisto.dat',status='unknown') -do i=1,128 - write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10) -enddo -close(23) - -end program ldpcsim diff --git a/lib/msk144_testmsg.f90 b/lib/msk144_testmsg.f90 new file mode 100644 index 00000000..e1cff131 --- /dev/null +++ b/lib/msk144_testmsg.f90 @@ -0,0 +1,47 @@ + parameter (MAXTEST=75,NTEST=43) + character*37 testmsg(MAXTEST) + data testmsg(1:NTEST)/ & + "CQ K1ABC FN42", & + "K1ABC W9XYZ EN37", & + "W9XYZ K1ABC -11", & + "K1ABC W9XYZ R-09", & + "W9XYZ K1ABC RRR", & + "K1ABC W9XYZ 73", & + "K1ABC W9XYZ RR73", & + "CQ KH1/KH7Z", & + "CQ TEST K1ABC/R FN42", & + "K1ABC/R W9XYZ EN37", & + "W9XYZ K1ABC/R R FN42", & + "K1ABC/R W9XYZ RR73", & + "CQ TEST K1ABC FN42", & + "K1ABC/R W9XYZ/R R FN42", & + "CQ G4ABC/P IO91", & + "G4ABC/P PA9XYZ JO22", & + "PA9XYZ 590003 IO91NP", & + "G4ABC/P R 570007 JO22DB", & + "PA9XYZ G4ABC/P RR73", & + "CQ PJ4/K1ABC", & + "PJ4/K1ABC <W9XYZ>", & + "W9XYZ <PJ4/K1ABC> -11", & + "<PJ4/K1ABC> W9XYZ R-09", & + "<W9XYZ> PJ4/K1ABC RRR", & + "PJ4/K1ABC <W9XYZ> 73", & + "CQ W9XYZ EN37", & + "<W9XYZ> YW18FIFA", & + "<YW18FIFA> W9XYZ -11", & + "W9XYZ <YW18FIFA> R-09", & + "YW18FIFA <W9XYZ> RRR", & + "<W9XYZ> YW18FIFA 73", & + "TNX BOB 73 GL", & + "CQ YW18FIFA", & + "<YW18FIFA> KA1ABC", & + "KA1ABC <YW18FIFA> -11", & + "<YW18FIFA> KA1ABC R-17", & + "<KA1ABC> YW18FIFA RR73", & + "<YW18FIFA> KA1ABC 73", & + "123456789ABCDEF012", & + "<KA1ABC WB9XYZ> -03", & + "<KA1ABC WB9XYZ> R+03", & + "<KA1ABC WB9XYZ> RRR", & + "<KA1ABC WB9XYZ> 73"/ + diff --git a/lib/msk144code.f90 b/lib/msk144code.f90 index f49bebca..81a18515 100644 --- a/lib/msk144code.f90 +++ b/lib/msk144code.f90 @@ -3,12 +3,11 @@ program msk144code ! Provides examples of message packing, bit and symbol ordering,
! LDPC encoding, and other necessary details of the MSK144 protocol.
- use packjt
- character msg*22,msgsent*22,decoded,bad*1,msgtype*13,mygrid*6
+ use packjt77
+ character*77 c77
+ character msg*37,msgsent*37,decoded,bad*1,msgtype*18
integer*4 i4tone(144)
- logical*1 bcontest
- include 'testmsg.f90'
- data mygrid/'FN20qi'/
+ include 'msk144_testmsg.f90'
nargs=iargc()
if(nargs.ne.1) then
@@ -25,44 +24,57 @@ program msk144code call getarg(1,msg)
nmsg=1
if(msg(1:2).eq."-t") then
- testmsg(NTEST+1)="<KA1ABC WB9XYZ> -03"
- testmsg(NTEST+2)="<KA1ABC WB9XYZ> R+03"
- testmsg(NTEST+3)="<KA1ABC WB9XYZ> RRR"
- testmsg(NTEST+4)="<KA1ABC WB9XYZ> 73"
- testmsg(NTEST+5)="KA1ABC WB9XYZ R EN37"
- nmsg=NTEST+5
+ nmsg=NTEST
endif
write(*,1010)
-1010 format(" Message Decoded Err? Type"/ &
- 74("-"))
+1010 format(4x,"Message",31x,"Decoded",29x,"Err i3.n3"/100("-"))
+
do imsg=1,nmsg
if(nmsg.gt.1) msg=testmsg(imsg)
call fmtmsg(msg,iz) !To upper case, collapse multiple blanks
- i1=len(trim(msg))-5
- bcontest=.false.
- if(msg(i1:i1+1).eq.'R ') bcontest=.true.
- ichk=0
- call genmsk144(msg,mygrid,ichk,bcontest,msgsent,i4tone,itype)
-
+ call genmsk_128_90(msg,ichk,msgsent,i4tone,itype)
+ i3=-1
+ n3=-1
+ call pack77(msg,i3,n3,c77)
msgtype=""
- if(itype.eq.1) msgtype="Std Msg"
- if(itype.eq.2) msgtype="Type 1 prefix"
- if(itype.eq.3) msgtype="Type 1 suffix"
- if(itype.eq.4) msgtype="Type 2 prefix"
- if(itype.eq.5) msgtype="Type 2 suffix"
- if(itype.eq.6) msgtype="Free text"
- if(itype.eq.7) msgtype="Hashed calls"
-
+ if(i3.eq.0) then
+ if(n3.eq.0) msgtype="Free text"
+ if(n3.eq.1) msgtype="DXpedition mode"
+ if(n3.eq.2) msgtype="EU VHF Contest"
+ if(n3.eq.3) msgtype="ARRL Field Day"
+ if(n3.eq.4) msgtype="ARRL Field Day"
+ if(n3.eq.5) msgtype="Telemetry"
+ if(n3.ge.6) msgtype="Undefined type"
+ endif
+ if(i3.eq.1) msgtype="Standard msg"
+ if(i3.eq.2) msgtype="EU VHF Contest"
+ if(i3.eq.3) msgtype="ARRL RTTY Roundup"
+ if(i3.eq.4) msgtype="Nonstandard calls"
+ if(i3.ge.5) msgtype="Undefined msg type"
+ if(i3.ge.1) n3=-1
+ if(i4tone(41).lt.0) then
+ msgtype="Sh msg"
+ i3=-1
+ endif
bad=" "
- if(msgsent.ne.msg) bad="*"
- write(*,1020) imsg,msg,msgsent,bad,itype,msgtype
-1020 format(i2,'.',2x,a22,2x,a22,3x,a1,i3,": ",a13)
+ if(msg.ne.msgsent) bad="*"
+ if(i3.eq.0.and.n3.ge.0) then
+ write(*,1020) imsg,msg,msgsent,bad,i3,n3,msgtype
+1020 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',i1,1x,a18)
+ elseif(i3.ge.1) then
+ write(*,1022) imsg,msg,msgsent,bad,i3,msgtype
+1022 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',1x,1x,a18)
+ elseif(i3.lt.0) then
+ write(*,1024) imsg,msg,msgsent,bad,msgtype
+1024 format(i2,'.',1x,a37,1x,a37,1x,a1,6x,a18)
+ endif
+
enddo
if(nmsg.eq.1) then
n=144
- if(msg(1:1).eq."<") n=40
+ if(i4tone(41).lt.0) n=40
write(*,1030) i4tone(1:n)
1030 format(/'Channel symbols'/(72i1))
endif
diff --git a/lib/msk144d2.f90 b/lib/msk144d2.f90 deleted file mode 100644 index 47eb43b6..00000000 --- a/lib/msk144d2.f90 +++ /dev/null @@ -1,138 +0,0 @@ -program msk144d2 - - ! Test the msk144 decoder for WSJT-X - - use options - use timer_module, only: timer - use timer_impl, only: init_timer - use readwav - - character c - character*80 line - character*512 datadir - character*500 infile - character*12 mycall,hiscall - character*6 mygrid - character(len=500) optarg - - logical :: display_help=.false. - logical*1 bShMsgs - logical*1 bcontest - logical*1 btrain - logical*1 bswl - - type(wav_header) :: wav - - integer*2 id2(30*12000) - integer*2 ichunk(7*1024) - - real*8 pcoeffs(5) - - type (option) :: long_options(9) = [ & - option ('ndepth',.true.,'c','ndepth',''), & - option ('dxcall',.true.,'d','hiscall',''), & - option ('evemode',.true.,'e','Must be used with -s.',''), & - option ('frequency',.true.,'f','rxfreq',''), & - option ('help',.false.,'h','Display this help message',''), & - option ('mycall',.true.,'m','mycall',''), & - option ('nftol',.true.,'n','nftol',''), & - option ('rxequalize',.false.,'r','Rx Equalize',''), & - option ('short',.false.,'s','enable Sh','') & - ] - t0=0.0 - ndepth=3 - ntol=100 - nrxfreq=1500 - mycall='' - mygrid='EN50WC' - hiscall='' - bShMsgs=.false. - bcontest=.false. - btrain=.false. - bswl=.false. - datadir='.' - pcoeffs=0.d0 - - do - call getopt('c:d:ef:hm:n:rs',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.) - if( nstat .ne. 0 ) then - exit - end if - select case (c) - case ('c') - read (optarg(:narglen), *) ndepth - case ('d') - read (optarg(:narglen), *) hiscall - case ('e') - bswl=.true. - case ('f') - read (optarg(:narglen), *) nrxfreq - case ('h') - display_help = .true. - case ('m') - read (optarg(:narglen), *) mycall - case ('n') - read (optarg(:narglen), *) ntol - case ('r') - btrain=.true. - case ('s') - bShMsgs=.true. - end select - end do - - if(display_help .or. nstat.lt.0 .or. nremain.lt.1) then - print *, '' - print *, 'Usage: msk144d [OPTIONS] file1 [file2 ...]' - print *, '' - print *, ' msk144 decode pre-recorded .WAV file(s)' - print *, '' - print *, 'OPTIONS:' - do i = 1, size (long_options) - call long_options(i) % print (6) - end do - go to 999 - endif - - call init_timer ('timer.out') - call timer('msk144 ',0) - ndecoded=0 - do ifile=noffset+1,noffset+nremain - call get_command_argument(ifile,optarg,narglen) - infile=optarg(:narglen) - call timer('read ',0) - call wav%read (infile) - i1=index(infile,'.wav') - if( i1 .eq. 0 ) i1=index(infile,'.WAV') - read(infile(i1-6:i1-1),*,err=998) nutc - inquire(FILE=infile,SIZE=isize) - npts=min((isize-216)/2,360000) - read(unit=wav%lun) id2(1:npts) - close(unit=wav%lun) - call timer('read ',1) - - do i=1,npts-7*1024+1,7*512 - ichunk=id2(i:i+7*1024-1) - tsec=(i-1)/12000.0 - tt=sum(float(abs(id2(i:i+7*512-1)))) - if( tt .ne. 0.0 ) then - call mskrtd(ichunk,nutc,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall,bShMsgs, & - bcontest,btrain,pcoeffs,bswl,datadir,line) - if( index(line,"&") .ne. 0 .or. & - index(line,"^") .ne. 0 .or. & - index(line,"!") .ne. 0 .or. & - index(line,"@") .ne. 0 ) then - write(*,*) line - endif - endif - enddo - enddo - - call timer('msk144 ',1) - call timer('msk144 ',101) - go to 999 - -998 print*,'Cannot read from file:' - print*,infile - -999 continue -end program msk144d2 diff --git a/lib/msk144decodeframe.f90 b/lib/msk144decodeframe.f90 index 5d5e1555..19da8493 100644 --- a/lib/msk144decodeframe.f90 +++ b/lib/msk144decodeframe.f90 @@ -1,20 +1,20 @@ -subroutine msk144decodeframe(c,softbits,msgreceived,nsuccess,recent_calls,nrecent) +subroutine msk144decodeframe(c,softbits,msgreceived,nsuccess) ! use timer_module, only: timer - + use packjt77 parameter (NSPM=864) - character*22 msgreceived - character*12 recent_calls(nrecent) + character*37 msgreceived + character*77 c77 complex cb(42) complex cfac,cca,ccb complex c(NSPM) - integer*1 decoded(80) + integer*1 decoded77(77),apmask(128),cw(128) integer s8(8),hardbits(144) real*8 dt, fs, pi, twopi real cbi(42),cbq(42) real pp(12) real softbits(144) real llr(128) - logical first + logical first,unpk77_success data first/.true./ data s8/0,1,1,1,0,0,1,0/ save first,cb,fs,pi,twopi,dt,s8,pp @@ -87,19 +87,25 @@ subroutine msk144decodeframe(c,softbits,msgreceived,nsuccess,recent_calls,nrecen ssig=sqrt(s2av-sav*sav) softbits=softbits/ssig - sigma=0.75 + sigma=0.60 llr(1:48)=softbits(9:9+47) llr(49:128)=softbits(65:65+80-1) llr=2.0*llr/(sigma*sigma) max_iterations=10 -! call timer('bpdec144 ',0) - call bpdecode144(llr,max_iterations,decoded,niterations) -! call timer('bpdec144 ',1) - if( niterations .ge. 0.0 ) then - call extractmessage144(decoded,msgreceived,nhashflag,recent_calls,nrecent) - if( nhashflag .gt. 0 ) then !Hash codes match, so print it - nsuccess=1 +! call timer('bpdec128_90 ',0) + apmask=0 + call bpdecode128_90(llr,apmask,max_iterations,decoded77,cw,nharderror,niterations) +! call timer('bpdec128_90 ',1) + if( nharderror .ge. 0 .and. nharderror .lt. 18 ) then + nsuccess=1 + write(c77,'(77i1)') decoded77 + read(c77(72:77),'(2b3)') n3,i3 + if( (i3.eq.0.and.(n3.eq.1 .or. n3.eq.3 .or. n3.eq.4 .or. n3.gt.5)) .or. i3.eq.3 .or. i3.gt.4 ) then + nsuccess=0 + else + call unpack77(c77,msgreceived,unpk77_success) + if(.not.unpk77_success) nsuccess=0 endif endif diff --git a/lib/msk144sd.f90 b/lib/msk144sd.f90 deleted file mode 100644 index 267fff54..00000000 --- a/lib/msk144sd.f90 +++ /dev/null @@ -1,197 +0,0 @@ -program msk144sd -! -! A simple decoder for slow msk144. -! Can be used as a (slow) brute-force multi-decoder by looping -! over a set of carrier frequencies. -! - use options - use timer_module, only: timer - use timer_impl, only: init_timer - use readwav - - parameter (NRECENT=10) - parameter (NSPM=864) - parameter (NPATTERNS=4) - - character ch - character*80 line - character*500 infile - character*12 mycall,hiscall - character*6 mygrid - character(len=500) optarg - character*22 msgreceived - character*12 recent_calls(NRECENT) - - complex cdat(30*375) - complex c(NSPM) - complex ct(NSPM) - - real softbits(144) - real xmc(NPATTERNS) - - logical :: display_help=.false. - - type(wav_header) :: wav - - integer iavmask(8) - integer iavpatterns(8,NPATTERNS) - integer npkloc(10) - - integer*2 id2(30*12000) - integer*2 ichunk(7*1024) - - data iavpatterns/ & - 1,1,1,1,0,0,0,0, & - 0,1,1,1,1,0,0,0, & - 0,0,1,1,1,1,0,0, & - 1,1,1,1,1,1,0,0/ - data xmc/2.0,4.5,2.5,3.0/ - - type (option) :: long_options(2) = [ & - option ('frequency',.true.,'f','rxfreq',''), & - option ('help',.false.,'h','Display this help message','') & - ] - t0=0.0 - ntol=100 - nrxfreq=1500 - - do - call getopt('f:h',long_options,ch,optarg,narglen,nstat,noffset,nremain,.true.) - if( nstat .ne. 0 ) then - exit - end if - select case (ch) - case ('f') - read (optarg(:narglen), *) nrxfreq - case ('h') - display_help = .true. - end select - end do - - if(display_help .or. nstat.lt.0 .or. nremain.lt.1) then - print *, '' - print *, 'Usage: msk144sd [OPTIONS] file1 [file2 ...]' - print *, '' - print *, ' decode pre-recorded .WAV file(s)' - print *, '' - print *, 'OPTIONS:' - do i = 1, size (long_options) - call long_options(i) % print (6) - end do - go to 999 - endif - - call init_timer ('timer.out') - call timer('msk144 ',0) - ndecoded=0 - do ifile=noffset+1,noffset+nremain - call get_command_argument(ifile,optarg,narglen) - infile=optarg(:narglen) - call timer('read ',0) - call wav%read (infile) - i1=index(infile,'.wav') - if( i1 .eq. 0 ) i1=index(infile,'.WAV') - read(infile(i1-6:i1-1),*,err=998) nutc - inquire(FILE=infile,SIZE=isize) - npts=min((isize-216)/2,360000) - read(unit=wav%lun) id2(1:npts) - close(unit=wav%lun) - call timer('read ',1) - -! do if=1,89 ! brute force multi-decoder - fo=nrxfreq -! fo=(if-1)*25.0+300.0 - call msksddc(id2,npts,fo,cdat) - np=npts/32 - ntol=200 ! actual ntol is ntol/32=6.25 Hz. Detection window is 12.5 Hz wide - fc=1500.0 - call msk144spd(cdat,np,ntol,ndecodesuccess,msgreceived,fc,fest,tdec,navg,ct, & - softbits,recent_calls,nrecent) - nsnr=0 ! need an snr estimate - if( ndecodesuccess .eq. 1 ) then - fest=fo+fest-fc ! fudging because spd thinks input signal is at 1500 Hz - goto 900 - endif -! If short ping decoder doesn't find a decode - npat=NPATTERNS - do iavg=1,npat - iavmask=iavpatterns(1:8,iavg) - navg=sum(iavmask) - deltaf=4.0/real(navg) ! search increment for frequency sync - npeaks=4 - ntol=200 - fc=1500.0 - call msk144sync(cdat(1:6*NSPM),6,ntol,deltaf,iavmask,npeaks,fc, & - fest,npkloc,nsyncsuccess,xmax,c) - if( nsyncsuccess .eq. 0 ) cycle - - do ipk=1,npeaks - do is=1,3 - ic0=npkloc(ipk) - if(is.eq.2) ic0=max(1,ic0-1) - if(is.eq.3) ic0=min(NSPM,ic0+1) - ct=cshift(c,ic0-1) - call msk144decodeframe(ct,softbits,msgreceived,ndecodesuccess, & - recent_calls,nrecent) - if(ndecodesuccess .gt. 0) then - tdec=tsec+xmc(iavg)*tframe - fest=fo+(fest-fc)/32.0 - goto 900 - endif - enddo !Slicer dither - enddo !Peak loop - enddo - -! enddo -900 continue - if( ndecodesuccess .gt. 0 ) then - write(*,1020) nutc,nsnr,tdec,nint(fest),' % ',msgreceived,navg -1020 format(i6.6,i4,f5.1,i5,a3,a22,i4) - endif - enddo - - call timer('msk144 ',1) - call timer('msk144 ',101) - go to 999 - -998 print*,'Cannot read from file:' - print*,infile - -999 continue -end program msk144sd - -subroutine msksddc(id2,npts,fc,cdat) - -! The msk144 detector/demodulator/decoder will decode signals -! with carrier frequency, fc, in the range fN/4 +/- 0.03333*fN. -! -! For slow MSK144 with nslow=32: -! fs=12000/32=375 Hz, fN=187.5 Hz -! -! This routine accepts input samples with fs=12000 Hz. It -! downconverts and decimates by 32 to center a signal with input carrier -! frequency fc at new carrier frequency 1500/32=46.875 Hz. -! The analytic signal is returned. - - parameter (NFFT1=30*12000,NFFT2=30*375) - integer*2 id2(npts) - complex cx(0:NFFT1) - complex cdat(30*375) - - dt=1.0/12000.0 - df=1.0/(NFFT1*dt) - icenter=int(fc/df+0.5) - i46p875=int(46.875/df+0.5) - ishift=icenter-i46p875 - cx=cmplx(0.0,0.0) - cx(1:npts)=id2 - call four2a(cx,NFFT1,1,-1,1) - cx=cshift(cx,ishift) - cx(1)=0.5*cx(1) - cx(2*i46p875+1:)=cmplx(0.0,0.0) - call four2a(cx,NFFT2,1,1,1) - cdat(1:npts/32)=cx(0:npts/32-1)/NFFT1 - return - -end subroutine msksddc - diff --git a/lib/msk144signalquality.f90 b/lib/msk144signalquality.f90 index 24a146c6..3caaa349 100644 --- a/lib/msk144signalquality.f90 +++ b/lib/msk144signalquality.f90 @@ -1,11 +1,10 @@ subroutine msk144signalquality(cframe,snr,freq,t0,softbits,msg,dxcall, & btrain,datadir,nbiterrors,eyeopening,pcoeffs) - character*22 msg,msgsent + character*37 msg,msgsent character*12 dxcall character*12 training_dxcall character*12 trained_dxcall - character*6 mygrid character*512 pcoeff_filename character*8 date character*10 time @@ -23,7 +22,6 @@ subroutine msk144signalquality(cframe,snr,freq,t0,softbits,msg,dxcall, & integer msgbits(144) integer values(8) - logical*1 bcontest logical*1 btrain logical*1 first logical*1 currently_training @@ -91,10 +89,8 @@ subroutine msk144signalquality(cframe,snr,freq,t0,softbits,msg,dxcall, & enddo ! generate tones from decoded message - mygrid="EN50" ichk=0 - bcontest=.false. - call genmsk144(msg,mygrid,ichk,bcontest,msgsent,i4tone,itype) + call genmsk_128_90(msg,ichk,msgsent,i4tone,itype) ! reconstruct message bits from tones msgbits(1)=0 diff --git a/lib/msk144sim.f90 b/lib/msk144sim.f90 index 28f17e61..3472d882 100644 --- a/lib/msk144sim.f90 +++ b/lib/msk144sim.f90 @@ -4,21 +4,18 @@ program msk144sim parameter (NMAX=15*12000) real pings(0:NMAX-1) real waveform(0:NMAX-1) - character*6 mygrid - character arg*8,msg*22,msgsent*22,fname*40 + character arg*8,msg*37,msgsent*37,fname*40 real wave(0:NMAX-1) !Simulated received waveform real*8 twopi,freq,phi,dphi0,dphi1,dphi type(hdr) h !Header for .wav file integer*2 iwave(0:NMAX-1) integer itone(144) !Message bits - logical*1 bcontest - data mygrid/"EN50wc"/ nargs=iargc() - if(nargs.ne.6) then - print*,'Usage: msk144sim message freq width nslow snr nfiles' - print*,'Example: msk144sim "K1ABC W9XYZ EN37" 1500 0.12 1 2 1' - print*,' msk144sim "K1ABC W9XYZ EN37" 1500 2.5 32 15 1' + if(nargs.ne.5) then + print*,'Usage: msk144sim message freq width snr nfiles' + print*,'Example: msk144sim "K1ABC W9XYZ EN37" 1500 0.12 2 1' + print*,' msk144sim "K1ABC W9XYZ EN37" 1500 2.5 15 1' go to 999 endif call getarg(1,msg) @@ -27,32 +24,38 @@ program msk144sim call getarg(3,arg) read(arg,*) width call getarg(4,arg) - read(arg,*) nslow - call getarg(5,arg) read(arg,*) snrdb - call getarg(6,arg) + call getarg(5,arg) read(arg,*) nfiles !sig is the peak amplitude of the ping. sig=sqrt(2.0)*10.0**(0.05*snrdb) h=default_header(12000,NMAX) i1=len(trim(msg))-5 - bcontest=.false. - if(msg(i1:i1+1).eq.'R ') bcontest=.true. ichk=0 - call genmsk144(msg,mygrid,ichk,bcontest,msgsent,itone,itype) - twopi=8.d0*atan(1.d0) + itype=1 + call genmsk_128_90(msg,ichk,msgsent,itone,itype) + write(*,*) 'Requested message: ',msg + write(*,*) 'Message sent : ',msgsent + write(*,*) 'Tones: ' + if(itone(41).ge.0) then + write(*,'(1x,72i1)') itone(1:72) + write(*,'(1x,72i1)') itone(73:144) + else + write(*,'(1x,40i1)') itone(1:40) + endif + twopi=8.d0*atan(1.d0) nsym=144 - nsps=6*nslow + nsps=6 if( itone(41) .lt. 0 ) nsym=40 - baud=2000.d0/nslow + baud=2000.d0 dphi0=twopi*(freq-0.25d0*baud)/12000.d0 dphi1=twopi*(freq+0.25d0*baud)/12000.d0 phi=0.0 k=0 nreps=NMAX/(nsym*nsps) - print*,nsym,nslow,nsps,baud,freq + do jrep=1,nreps do i=1,nsym if( itone(i) .eq. 0 ) then @@ -73,7 +76,7 @@ program msk144sim go to 999 endif - if(nslow.eq.1) call makepings(pings,NMAX,width,sig) + call makepings(pings,NMAX,width,sig) ! call sgran() do ifile=1,nfiles !Loop over requested number of files @@ -86,8 +89,7 @@ program msk144sim fac=sqrt(6000.0/2500.0) do i=0,NMAX-1 xx=gran() - if(nslow.eq.1) wave(i)=pings(i)*waveform(i) + fac*xx - if(nslow.gt.1) wave(i)=sig*waveform(i) + fac*xx + wave(i)=pings(i)*waveform(i) + fac*xx iwave(i)=30.0*wave(i) enddo diff --git a/lib/msk144spd.f90 b/lib/msk144spd.f90 index dcba3599..2bc6dcfe 100644 --- a/lib/msk144spd.f90 +++ b/lib/msk144spd.f90 @@ -1,13 +1,13 @@ subroutine msk144spd(cbig,n,ntol,nsuccess,msgreceived,fc,fret,tret,navg,ct, & - softbits,recent_calls,nrecent) + softbits) ! MSK144 short-ping-decoder + use packjt77 use timer_module, only: timer parameter (NSPM=864, MAXSTEPS=100, NFFT=NSPM, MAXCAND=5, NPATTERNS=6) - character*22 msgreceived - character*12 recent_calls(nrecent) + character*37 msgreceived complex cbig(n) complex cdat(3*NSPM) !Analytic signal complex c(NSPM) @@ -179,8 +179,7 @@ subroutine msk144spd(cbig,n,ntol,nsuccess,msgreceived,fc,fret,tret,navg,ct, & if( is.eq.2) ic0=max(1,ic0-1) if( is.eq.3) ic0=min(NSPM,ic0+1) ct=cshift(c,ic0-1) - call msk144decodeframe(ct,softbits,msgreceived,ndecodesuccess, & - recent_calls,nrecent) + call msk144decodeframe(ct,softbits,msgreceived,ndecodesuccess) if( ndecodesuccess .gt. 0 ) then tret=(nstart(icand)+NSPM/2)/fs fret=fest diff --git a/lib/msk40decodeframe.f90 b/lib/msk40decodeframe.f90 index ae75ddf9..2023412e 100644 --- a/lib/msk40decodeframe.f90 +++ b/lib/msk40decodeframe.f90 @@ -1,19 +1,19 @@ subroutine msk40decodeframe(c,mycall,hiscall,xsnr,bswl,nhasharray, & - recent_calls,nrecent,msgreceived,nsuccess) + msgreceived,nsuccess) ! use timer_module, only: timer + use packjt77 parameter (NSPM=240) character*4 rpt(0:15) - character*6 mycall,hiscall,mycall0,hiscall0 - character*22 hashmsg,msgreceived - character*12 recent_calls(nrecent) + character*12 mycall,hiscall,mycall0,hiscall0 + character*37 hashmsg,msgreceived complex cb(42) complex cfac,cca complex c(NSPM) integer*1 cw(32) integer*1 decoded(16) integer s8r(8),hardbits(40) - integer nhasharray(nrecent,nrecent) + integer nhasharray(MAXRECENT,MAXRECENT) real*8 dt, fs, pi, twopi real cbi(42),cbq(42) real pp(12) @@ -59,7 +59,7 @@ subroutine msk40decodeframe(c,mycall,hiscall,xsnr,bswl,nhasharray, & hashmsg=trim(mycall)//' '//trim(hiscall) if( hashmsg .ne. ' ' .and. hiscall .ne. '' ) then ! protect against blank mycall/hiscall call fmtmsg(hashmsg,iz) - call hash(hashmsg,22,ihash) + call hash(hashmsg,37,ihash) ihash=iand(ihash,4095) else ihash=9999 ! so that it can never match a received hash @@ -115,7 +115,6 @@ subroutine msk40decodeframe(c,mycall,hiscall,xsnr,bswl,nhasharray, & max_iterations=5 call bpdecode40(llr,max_iterations,decoded,niterations) - if( niterations .ge. 0.0 ) then call encode_msk40(decoded,cw) nhammd=0 @@ -133,33 +132,28 @@ subroutine msk40decodeframe(c,mycall,hiscall,xsnr,bswl,nhasharray, & enddo nrxrpt=iand(imsg,15) nrxhash=(imsg-nrxrpt)/16 - if(nhammd.le.4 .and. cord .lt. 0.65 .and. & nrxhash.eq.ihash .and. nrxrpt.ge.7) then -!write(*,*) 'decodeframe 1',nbadsync,nhammd,cord,nrxhash,nrxrpt,ihash,xsnr,sigma nsuccess=1 write(msgreceived,'(a1,a,1x,a,a1,1x,a4)') "<",trim(mycall), & trim(hiscall),">",rpt(nrxrpt) return elseif(bswl .and. nhammd.le.4 .and. cord.lt.0.65 .and. nrxrpt.ge.7 ) then - do i=1,nrecent - do j=i+1,nrecent + do i=1,MAXRECENT + do j=i+1,MAXRECENT if( nrxhash .eq. nhasharray(i,j) ) then nsuccess=2 write(msgreceived,'(a1,a,1x,a,a1,1x,a4)') "<",trim(recent_calls(i)), & trim(recent_calls(j)),">",rpt(nrxrpt) -!write(*,*) 'decodeframe 2',nbadsync,nhammd,cord,nrxhash,nrxrpt,ihash,xsnr,sigma elseif( nrxhash .eq. nhasharray(j,i) ) then nsuccess=2 write(msgreceived,'(a1,a,1x,a,a1,1x,a4)') "<",trim(recent_calls(j)), & trim(recent_calls(i)),">",rpt(nrxrpt) -!write(*,*) 'decodeframe 3',nbadsync,nhammd,cord,nrxhash,nrxrpt,ihash,xsnr,sigma endif enddo enddo if(nsuccess.eq.0) then nsuccess=3 -!write(*,*) 'decodeframe 4',bswl,nbadsync,nhammd,cord,nrxhash,nrxrpt,ihash,xsnr,sigma,nsuccess write(msgreceived,'(a1,i4.4,a1,1x,a4)') "<",nrxhash,">",rpt(nrxrpt) endif endif diff --git a/lib/msk40spd.f90 b/lib/msk40spd.f90 index c8af1a49..63532ae9 100644 --- a/lib/msk40spd.f90 +++ b/lib/msk40spd.f90 @@ -1,13 +1,13 @@ -subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray,recent_calls, & - nrecent,nsuccess,msgreceived,fc,fret,tret,navg) +subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & + nsuccess,msgreceived,fc,fret,tret,navg) ! msk40 short-ping-decoder + use packjt77 use timer_module, only: timer parameter (NSPM=240, MAXSTEPS=150, NFFT=NSPM, MAXCAND=5, NPATTERNS=6) - character*6 mycall,hiscall - character*22 msgreceived - character*12 recent_calls(nrecent) + character*12 mycall,hiscall + character*37 msgreceived complex cbig(n) complex cdat(3*NSPM) !Analytic signal complex c(NSPM) @@ -19,7 +19,6 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray,recent_calls, & integer navpatterns(3,NPATTERNS) integer navmask(3) integer nstart(MAXCAND) - integer nhasharray(nrecent,nrecent) logical ismask(NFFT) logical*1 bswl real detmet(-2:MAXSTEPS+3) @@ -181,7 +180,7 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray,recent_calls, & if( is.eq.3) ic0=min(NSPM,ic0+1) ct=cshift(c,ic0-1) call msk40decodeframe(ct,mycall,hiscall,xsnr,bswl,nhasharray, & - recent_calls,nrecent,msgreceived,ndecodesuccess) + msgreceived,ndecodesuccess) if( ndecodesuccess .gt. 0 ) then !write(*,*) icand, iav, ipk, is, tret, fret, msgreceived tret=(nstart(icand)+NSPM/2)/fs diff --git a/lib/mskrtd.f90 b/lib/mskrtd.f90 index 5712c71a..622c05f3 100644 --- a/lib/mskrtd.f90 +++ b/lib/mskrtd.f90 @@ -1,25 +1,26 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & - bshmsg,bcontest,btrain,pcoeffs,bswl,datadir,line) + bshmsg,btrain,pcoeffs,bswl,datadir,line) ! Real-time decoder for MSK144. ! Analysis block size = NZ = 7168 samples, t_block = 0.597333 s ! Called from hspec() at half-block increments, about 0.3 s + use packjt77 + parameter (NZ=7168) !Block size parameter (NSPM=864) !Number of samples per message frame parameter (NFFT1=8192) !FFT size for making analytic signal parameter (NPATTERNS=4) !Number of frame averaging patterns to try - parameter (NRECENT=10) !Number of recent calls to remember parameter (NSHMEM=50) !Number of recent SWL messages to remember character*4 decsym !"&" for mskspd or "^" for long averages - character*22 msgreceived !Decoded message - character*22 msglast,msglastswl !Used for dupechecking + character*37 msgreceived !Decoded message + character*37 msglast,msglastswl !Used for dupechecking character*80 line !Formatted line with UTC dB T Freq Msg character*12 mycall,hiscall + character*13 mycall13 character*6 mygrid - character*12 recent_calls(NRECENT) - character*22 recent_shmsgs(NSHMEM) + character*37 recent_shmsgs(NSHMEM) character*512 datadir complex cdat(NFFT1) !Analytic signal @@ -30,7 +31,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & integer iavmask(8) integer iavpatterns(8,NPATTERNS) integer npkloc(10) - integer nhasharray(NRECENT,NRECENT) + integer nhasharray(MAXRECENT,MAXRECENT) integer nsnrlast,nsnrlastswl real d(NFFT1) @@ -39,7 +40,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & real xmc(NPATTERNS) real*8 pcoeffs(5) - logical*1 bshmsg,bcontest,btrain,bswl + logical*1 bshmsg,btrain,bswl logical*1 first logical*1 bshdecode logical*1 seenb4 @@ -54,31 +55,36 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & 1,1,1,1,1,1,1,0/ data xmc/2.0,4.5,2.5,3.5/ !Used to set time at center of averaging mask save first,tsec0,nutc00,pnoise,cdat,msglast,msglastswl, & - nsnrlast,nsnrlastswl,recent_calls,nhasharray,recent_shmsgs + nsnrlast,nsnrlastswl,nhasharray,recent_shmsgs,mycall13 if(first) then tsec0=tsec nutc00=nutc0 pnoise=-1.0 - do i=1,nrecent - recent_calls(i)(1:12)=' ' + do i=1,MAXRECENT + recent_calls(i)(1:13)=' ' enddo do i=1,nshmem - recent_shmsgs(i)(1:22)=' ' + recent_shmsgs(i)(1:37)=' ' enddo - msglast=' ' - msglastswl=' ' + msglast=' ' + msglastswl=' ' nsnrlast=-99 nsnrlastswl=-99 + mycall13=mycall//" " + call save_hash_call(mycall13,n10,n12,n22) ! Make sure that my callsign is in hashtable first=.false. endif fc=nrxfreq +! Reset if mycall changes + if(mycall13(1:12).ne.mycall) first=.true. + ! Dupe checking setup if(nutc00.ne.nutc0 .or. tsec.lt.tsec0) then ! reset dupe checker - msglast=' ' - msglastswl=' ' + msglast=' ' + msglastswl=' ' nsnrlast=-99 nsnrlastswl=-99 nutc00=nutc0 @@ -86,7 +92,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & tframe=float(NSPM)/12000.0 line=char(0) - msgreceived=' ' + msgreceived=' ' max_iterations=10 niterations=0 d(1:NZ)=id2 @@ -116,10 +122,12 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & ! 3 frames along with 2- and 3-frame averages. np=8*NSPM call msk144spd(cdat,np,ntol,ndecodesuccess,msgreceived,fc,fest,tdec,navg,ct, & - softbits,recent_calls,nrecent) + softbits) + bshdecode=.false. if(ndecodesuccess.eq.0 .and. (bshmsg.or.bswl)) then - call msk40spd(cdat,np,ntol,mycall(1:6),hiscall(1:6),bswl,nhasharray, & - recent_calls,nrecent,ndecodesuccess,msgreceived,fc,fest,tdec,navg) + call msk40spd(cdat,np,ntol,mycall,hiscall,bswl,nhasharray, & + ndecodesuccess,msgreceived,fc,fest,tdec,navg) + if(ndecodesuccess .ge.1) bshdecode=.true. endif if( ndecodesuccess .ge. 1 ) then tdec=tsec+tdec @@ -150,8 +158,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & if(is.eq.2) ic0=max(1,ic0-1) if(is.eq.3) ic0=min(NSPM,ic0+1) ct=cshift(c,ic0-1) - call msk144decodeframe(ct,softbits,msgreceived,ndecodesuccess, & - recent_calls,nrecent) + call msk144decodeframe(ct,softbits,msgreceived,ndecodesuccess) if(ndecodesuccess .gt. 0) then tdec=tsec+xmc(iavg)*tframe goto 900 @@ -182,9 +189,6 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & endif nsnr=nint(snr0) - bshdecode=.false. - if( msgreceived(1:1) .eq. '<' ) bshdecode=.true. - if(.not. bshdecode) then call msk144signalquality(ct,snr0,fest,tdec,softbits,msgreceived,hiscall, & btrain,datadir,ncorrected,eyeopening,pcoeffs) @@ -192,7 +196,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & decsym=' & ' if( btrain ) decsym=' ^ ' - if( msgreceived(1:1).eq.'<') then + if( bshdecode ) then ncorrected=0 eyeopening=0.0 endif @@ -207,12 +211,10 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & msglast=msgreceived nsnrlast=nsnr if(.not. bshdecode) then - call update_hasharray(recent_calls,nrecent,nhasharray) - if(bcontest) call fix_contest_msg(mygrid,msgreceived) + call update_hasharray(nhasharray) endif - write(line,1020) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived, & - navg,ncorrected,eyeopening,char(0) -1020 format(i6.6,i4,f5.1,i5,a4,a22,i2,i3,f5.1,a1) + write(line,1021) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived,char(0) +1021 format(i6.6,i4,f5.1,i5,a4,a37,a1) elseif(bswl .and. ndecodesuccess.ge.2) then seenb4=.false. do i=1,nshmem @@ -227,8 +229,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & if(bflag) then msglastswl=msgreceived nsnrlastswl=nsnr - write(line,1020) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived, & - navg,ncorrected,eyeopening,char(0) + write(line,1021) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived,char(0) endif endif 999 tsec0=tsec @@ -237,8 +238,8 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & end subroutine mskrtd subroutine update_recent_shmsgs(message,msgs,nsize) - character*22 msgs(nsize) - character*22 message + character*37 msgs(nsize) + character*37 message logical*1 seen seen=.false. diff --git a/lib/packjt.f90 b/lib/packjt.f90 index ad05b573..5557214f 100644 --- a/lib/packjt.f90 +++ b/lib/packjt.f90 @@ -398,7 +398,7 @@ subroutine packbits(dbits,nsymd,m0,sym) 900 return end subroutine unpackgrid - subroutine packmsg(msg0,dat,itype,bcontest) + subroutine packmsg(msg0,dat,itype) ! Packs a JT4/JT9/JT65 message into twelve 6-bit symbols @@ -419,14 +419,10 @@ subroutine packbits(dbits,nsymd,m0,sym) character*12 c1,c2 character*4 c3 character*6 grid6 - logical text1,text2,text3,bcontest + logical text1,text2,text3 itype=1 - if(bcontest) then - call to_contest_msg(msg0,msg) - else - msg=msg0 - end if + msg=msg0 call fmtmsg(msg,iz) if(msg(1:3).eq.'CQ ' .and. msg(4:4).ge.'0' .and. msg(4:4).le.'9' & @@ -538,13 +534,13 @@ subroutine packbits(dbits,nsymd,m0,sym) return end subroutine packmsg - subroutine unpackmsg(dat,msg,bcontest,mygrid) + subroutine unpackmsg(dat,msg) parameter (NBASE=37*36*10*27*27*27) parameter (NGBASE=180*180) integer dat(:) - character c1*12,c2*12,grid*4,msg*22,grid6*6,psfx*4,junk2*4,mygrid*6 - logical cqnnn,bcontest + character c1*12,c2*12,grid*4,msg*22,grid6*6,psfx*4,junk2*4 + logical cqnnn cqnnn=.false. nc1=ishft(dat(1),22) + ishft(dat(2),16) + ishft(dat(3),10)+ & @@ -658,8 +654,6 @@ subroutine packbits(dbits,nsymd,m0,sym) msg(4:4).ge.'A' .and. msg(4:4).le.'Z' .and. & msg(5:5).eq.' ') msg='CQ '//msg(3:) - if(bcontest) call fix_contest_msg(mygrid,msg) - if(msg(1:5).eq.'CQ 00' .and. msg(6:6).ge.'0' .and. & msg(6:6).le.'9') msg='CQ '//msg(6:) @@ -714,13 +708,15 @@ subroutine packbits(dbits,nsymd,m0,sym) return end subroutine packtext - subroutine unpacktext(nc1,nc2,nc3,msg) + subroutine unpacktext(nc1a,nc2a,nc3a,msg) character*22 msg character*44 c data c/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ +-./?'/ - nc3=iand(nc3,32767) !Remove the "plain text" bit + nc1=nc1a + nc2=nc2a + nc3=iand(nc3a,32767) !Remove the "plain text" bit if(iand(nc1,1).ne.0) nc3=nc3+32768 nc1=nc1/2 if(iand(nc2,1).ne.0) nc3=nc3+65536 diff --git a/lib/platanh.f90 b/lib/platanh.f90 new file mode 100644 index 00000000..e610366d --- /dev/null +++ b/lib/platanh.f90 @@ -0,0 +1,24 @@ +subroutine platanh(x,y) + isign=+1 + z=x + if( x.lt.0 ) then + isign=-1 + z=abs(x) + endif + if( z.le. 0.664 ) then + y=x/0.83 + return + elseif( z.le. 0.9217 ) then + y=isign*(z-0.4064)/0.322 + return + elseif( z.le. 0.9951 ) then + y=isign*(z-0.8378)/0.0524 + return + elseif( z.le. 0.9998 ) then + y=isign*(z-0.9914)/0.0012 + return + else + y=isign*7.0 + return + endif +end subroutine platanh diff --git a/lib/pltanh.f90 b/lib/pltanh.f90 new file mode 100644 index 00000000..4c6c2b6d --- /dev/null +++ b/lib/pltanh.f90 @@ -0,0 +1,24 @@ +subroutine pltanh(x,y) + isign=+1 + z=x + if( x.lt.0 ) then + isign=-1 + z=abs(x) + endif + if( z.le. 0.8 ) then + y=0.83*x + return + elseif( z.le. 1.6 ) then + y=isign*(0.322*z+0.4064) + return + elseif( z.le. 3.0 ) then + y=isign*(0.0524*z+0.8378) + return + elseif( z.lt. 7.0 ) then + y=isign*(0.0012*z+0.9914) + return + else + y=isign*0.9998 + return + endif +end subroutine pltanh diff --git a/lib/qra64a.f90 b/lib/qra64a.f90 index 2f128ac0..56d59e52 100644 --- a/lib/qra64a.f90 +++ b/lib/qra64a.f90 @@ -128,7 +128,7 @@ subroutine qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, & 10 decoded=' ' if(irc.ge.0) then - call unpackmsg(dat4,decoded,.false.,' ') !Unpack the user message + call unpackmsg(dat4,decoded) !Unpack the user message call fmtmsg(decoded,iz) if(index(decoded,"000AAA ").ge.1) then ! Suppress a certain type of garbage decode. diff --git a/lib/qra64code.f90 b/lib/qra64code.f90 index 0f9c16bf..5846ec8d 100644 --- a/lib/qra64code.f90 +++ b/lib/qra64code.f90 @@ -30,11 +30,11 @@ program QRA64code do imsg=1,nmsg if(nmsg.gt.1) msg=testmsg(imsg) - call fmtmsg(msg,iz) !To upper, collapse mult blanks + call fmtmsg(msg,iz) !To upper, collapse mult blanks msg0=msg !Input message call chkmsg(msg,cok,nspecial,flip) !See if it includes "OOO" report msg1=msg !Message without "OOO" - call packmsg(msg1,dgen,itype,.false.) !Pack message into 12 six-bit bytes + call packmsg(msg1,dgen,itype) !Pack message into 12 six-bit bytes msgtype="" if(itype.eq.1) msgtype="Std Msg" if(itype.eq.2) msgtype="Type 1 pfx" @@ -45,7 +45,7 @@ program QRA64code call qra64_enc(dgen,sent) !Encode using QRA64 - call unpackmsg(dgen,decoded,.false.,' ') !Unpack the user message + call unpackmsg(dgen,decoded) !Unpack the user message call fmtmsg(decoded,iz) ii=imsg write(*,1020) ii,msg0,decoded,itype,msgtype diff --git a/lib/stdmsg.f90 b/lib/stdmsg.f90 index 599287bb..cc50f580 100644 --- a/lib/stdmsg.f90 +++ b/lib/stdmsg.f90 @@ -1,21 +1,43 @@ -function stdmsg(msg0,bcontest,mygrid)
+function stdmsg(msg0)
- ! Is msg0 a standard "JT-style" message?
+ ! Returns .true. if msg0 a standard "JT-style" message
+
+ ! i3.n3
+ ! 0.0 Free text
+ ! 0.1 DXpeditiion mode
+ ! 0.2 EU VHF Contest
+ ! 0.3 ARRL Field Day <=16 transmitters
+ ! 0.4 ARRL Field Day >16 transmitters
+ ! 0.5 telemetry
+ ! 0.6
+ ! 0.7
+ ! 1 Standard 77-bit structured message (optional /R)
+ ! 2 EU VHF Contest (optional /P)
+ ! 3 ARRL RTTY Contest
+ ! 4 Nonstandard calls
use iso_c_binding, only: c_bool
use packjt
- character*22 msg0,msg1,msg
- character*6 mygrid
- integer dat(12)
- logical(c_bool), value :: bcontest
+ use packjt77
+
+ character*37 msg0,msg1
+ character*77 c77
logical(c_bool) :: stdmsg
msg1=msg0
- i0=index(msg1,' OOO ')
- if(i0.gt.10) msg1=msg0(1:i0)
- call packmsg(msg0,dat,itype,logical(bcontest))
- call unpackmsg(dat,msg,logical(bcontest),mygrid)
- stdmsg=(msg.eq.msg1) .and. (itype.ge.0) .and. itype.ne.6
+ i3=-1
+ n3=-1
+ call pack77(msg1,i3,n3,c77)
+ stdmsg=(i3.gt.0 .or. n3.gt.0)
+!###
+! rewind 82
+! do i=1,nzhash
+! write(82,3082) i,nzhash,callsign(i),ihash10(i),ihash12(i),ihash22(i)
+!3082 format(2i5,2x,a13,3i10)
+! enddo
+! flush(82)
+!###
+
return
end function stdmsg
diff --git a/lib/sync4.f90 b/lib/sync4.f90 index c7f33b47..9bfe6c60 100644 --- a/lib/sync4.f90 +++ b/lib/sync4.f90 @@ -1,5 +1,5 @@ -subroutine sync4(dat,jz,ntol,NFreeze,MouseDF,mode,mode4,minwidth, &
- dtx,dfx,snrx,snrsync,ccfblue,ccfred1,flip,width,ps0)
+subroutine sync4(dat,jz,ntol,nfqso,mode,mode4,minwidth,dtx,dfx,snrx, &
+ snrsync,flip,width)
! Synchronizes JT4 data, finding the best-fit DT and DF.
@@ -8,14 +8,10 @@ subroutine sync4(dat,jz,ntol,NFreeze,MouseDF,mode,mode4,minwidth, & parameter (NSMAX=525) !Max number of half-symbol steps
integer ntol !Range of DF search
real dat(jz)
- real psavg(NHMAX) !Average spectrum of whole record
- real ps0(450) !Avg spectrum for plotting
real s2(NHMAX,NSMAX) !2d spectrum, stepped by half-symbols
real ccfblue(-5:540) !CCF with pseudorandom sequence
- real ccfred(-450:450) !Peak of ccfblue, as function of freq
- real red(-450:450) !Peak of ccfblue, as function of freq
- real ccfred1(-224:224) !Peak of ccfblue, as function of freq
- real tmp(1260)
+ real ccfred(NHMAX) !Peak of ccfblue, as function of freq
+ real red(NHMAX) !Peak of ccfblue, as function of freq
integer ipk1(1)
integer nch(7)
logical savered
@@ -23,9 +19,6 @@ subroutine sync4(dat,jz,ntol,NFreeze,MouseDF,mode,mode4,minwidth, & data nch/1,2,4,9,18,36,72/
save
-! write(*,3001) 'A',ntol,nfreeze,mousedf,mode,mode4,minwidth
-!3001 format(a1,6i6)
-
! Do FFTs of twice symbol length, stepped by half symbols. Note that
! we have already downsampled the data by factor of 2.
nsym=207
@@ -34,69 +27,53 @@ subroutine sync4(dat,jz,ntol,NFreeze,MouseDF,mode,mode4,minwidth, & nq=nfft/4
nsteps=jz/nq - 1
df=0.5*11025.0/nfft
- psavg(1:nh)=0.
+ ftop=nfqso + 7*mode4*df
+ if(ftop.gt.11025.0/4.0) then
+ print*,'*** Rx Freq is set too high for this sybmode ***'
+ go to 900
+ endif
+
if(mode.eq.-999) width=0. !Silence compiler warning
do j=1,nsteps !Compute spectrum for each step, get average
k=(j-1)*nq + 1
call ps4(dat(k),nfft,s2(1,j))
- psavg(1:nh)=psavg(1:nh) + s2(1:nh,j)
- enddo
-
- nsmo=min(10*mode4,150)
- call flat1b(psavg,nsmo,s2,nh,nsteps,NHMAX,NSMAX) !Flatten spectra
-
- if(mode4.ge.9) call smo(psavg,nh,tmp,mode4/4)
-
- i0=132
- do i=1,450
- ps0(i)=5.0*(psavg(i0+2*i) + psavg(i0+2*i+1) - 2.0)
enddo
! Set freq and lag ranges
- famin=200.0 + 3*mode4*df
- fbmax=2700.0 - 3*mode4*df
- fa=famin
- fb=fbmax
- if(NFreeze.eq.1) then
- fa=max(famin,1270.46+MouseDF-ntol)
- fb=min(fbmax,1270.46+MouseDF+ntol)
- else
- fa=max(famin,1270.46+MouseDF-600)
- fb=min(fbmax,1270.46+MouseDF+600)
- endif
- ia=fa/df - 3*mode4 !Index of lowest tone, bottom of range
- ib=fb/df - 3*mode4 !Index of lowest tone, top of range
- i0=nint(1270.46/df)
- irange=450
- if(ia-i0.lt.-irange) ia=i0-irange
- if(ib-i0.gt.irange) ib=i0+irange
+ ia=(nfqso-ntol)/df !Index of lowest tone, bottom of search range
+ ib=(nfqso+ntol)/df !Index of lowest tone, top of search range
+ iamin=nint(100.0/df)
+ if(ia.lt.iamin) ia=iamin
+ ibmax=nint(2700.0/df) - 6*mode4
+ if(ib.gt.ibmax) ib=ibmax
+
lag1=-5
lag2=59
syncbest=-1.e30
+ snrx=-26.0
ccfred=0.
- jmax=-1000
- jmin=1000
+ red=0.
+ i0=nint(nfqso/df)
do ich=minwidth,7 !Find best width
kz=nch(ich)/2
savered=.false.
- do i=ia+kz,ib-kz !Find best frequency channel for CCF
+ iaa=ia+kz
+ ibb=ib-kz
+ do i=iaa,ibb !Find best frequency channel for CCF
call xcor4(s2,i,nsteps,nsym,lag1,lag2,ich,mode4,ccfblue,ccf0, &
lagpk0,flip)
- j=i-i0 + 3*mode4
- if(j.ge.-372 .and. j.le.372) then
- ccfred(j)=ccf0
- jmax=max(j,jmax)
- jmin=min(j,jmin)
- endif
-
+ ccfred(i)=ccf0
+
! Find rms of the CCF, without main peak
call slope(ccfblue(lag1),lag2-lag1+1,lagpk0-lag1+1.0)
sync=abs(ccfblue(lagpk0))
+! write(*,3000) ich,i,i*df,ccf0,sync,syncbest
+!3000 format(2i5,4f12.3)
! Find best sync value
- if(sync.gt.syncbest) then
+ if(sync.gt.syncbest*1.03) then
ipk=i
lagpk=lagpk0
ichpk=ich
@@ -106,10 +83,12 @@ subroutine sync4(dat,jz,ntol,NFreeze,MouseDF,mode,mode4,minwidth, & enddo
if(savered) red=ccfred
enddo
-
+ if(syncbest.lt.-1.e29) go to 900
ccfred=red
-! width=df*nch(ichpk)
- dfx=(ipk-i0 + 3*mode4)*df
+ call pctile(ccfred(iaa:ibb),ibb-iaa+1,45,base)
+ ccfred=ccfred-base
+
+ dfx=ipk*df
! Peak up in time, at best whole-channel frequency
call xcor4(s2,ipk,nsteps,nsym,lag1,lag2,ichpk,mode4,ccfblue,ccfmax, &
@@ -132,48 +111,36 @@ subroutine sync4(dat,jz,ntol,NFreeze,MouseDF,mode,mode4,minwidth, & enddo
rms=sqrt(sq/nsq)
snrsync=max(0.0,db(abs(ccfblue(lagpk)/rms - 1.0)) - 4.5)
- snrx=-26.
- if(mode4.eq.2) snrx=-25.
- if(mode4.eq.4) snrx=-24.
- if(mode4.eq.9) snrx=-23.
- if(mode4.eq.18) snrx=-22.
- if(mode4.eq.36) snrx=-21.
- if(mode4.eq.72) snrx=-20.
- snrx=snrx + snrsync
-
dt=2.0/11025.0
istart=xlag*nq
dtx=istart*dt
- ccfred1=0.
- jmin=max(jmin,-224)
- jmax=min(jmax,224)
- do i=jmin,jmax
- ccfred1(i)=ccfred(i)
+
+ ipk1=maxloc(ccfred)
+ ccf10=0.5*maxval(ccfred)
+ do i=ipk1a,ia,-1
+ if(ccfred(i).le.ccf10) exit
+ enddo
+ i1=i
+ do i=ipk1a,ib
+ if(ccfred(i).le.ccf10) exit
enddo
+ nw=i-i1
+ width=nw*df
- ipk1=maxloc(ccfred1) - 225
+ sq=0.
ns=0
- s=0.
- iw=min(mode4,(ib-ia)/4)
- do i=jmin,jmax
- if(abs(i-ipk1a).gt.iw) then
- s=s+ccfred1(i)
+ iaa=max(ipk1a-10*nw,ia)
+ ibb=min(ipk1a+10*nw,ib)
+ jmax=2*mode4/3
+ do i=iaa,ibb
+ j=abs(i-ipk1a)
+ if(j.gt.nw .and. j.lt.jmax) then
+ sq=sq + ccfred(j)*ccfred(j)
ns=ns+1
endif
enddo
- base=s/ns
- ccfred1=ccfred1-base
- ccf10=0.5*maxval(ccfred1)
- do i=ipk1a,jmin,-1
- if(ccfred1(i).le.ccf10) exit
- enddo
- i1=i
- do i=ipk1a,jmax
- if(ccfred1(i).le.ccf10) exit
- enddo
- width=(i-i1)*df
+ rms=sqrt(sq/ns)
+ snrx=10.0*log10(ccfred(ipk1a)/rms) - 41.2
- return
+900 return
end subroutine sync4
-
-include 'flat1b.f90'
diff --git a/lib/sync65.f90 b/lib/sync65.f90 index e0bc924a..4a681a0a 100644 --- a/lib/sync65.f90 +++ b/lib/sync65.f90 @@ -57,8 +57,9 @@ subroutine sync65(nfa,nfb,naggressive,ntol,nqsym,ca,ncand,nrobust, & freq=i*df itry=0 ! if(naggressive.gt.0 .and. ntol.lt.1000 .and. ccfmax.ge.thresh0) then - if(naggressive.gt.0 .and. ccfmax.ge.thresh0) then - if(i.ne.ipk) cycle +! if(naggressive.gt.0 .and. ccfmax.ge.thresh0) then + if(bVHF) then + if(i.ne.ipk .or. ccfmax.lt.thresh0) cycle itry=1 ncand=ncand+1 else diff --git a/lib/syncmsk.f90 b/lib/syncmsk.f90 index be28a3bb..0e26d46f 100644 --- a/lib/syncmsk.f90 +++ b/lib/syncmsk.f90 @@ -294,7 +294,7 @@ subroutine syncmsk(cdat,npts,jpk,ipk,idf,rmax,snr,metric,decoded) 1012 format(9b8.8) read(c72,1014) i4Msg6BitWords 1014 format(12b6.6) - call unpackmsg(i4Msg6BitWords,decoded,.false.,' ') !Unpack to get msgsent + call unpackmsg(i4Msg6BitWords,decoded) !Unpack to get msgsent endif if(decoded.ne.' ') exit enddo diff --git a/lib/testmsg.f90 b/lib/testmsg.f90 index 661c390a..eae851d6 100644 --- a/lib/testmsg.f90 +++ b/lib/testmsg.f90 @@ -16,7 +16,7 @@ "KA1ABC WB9XYZ RRR", & "KA1ABC WB9XYZ 73", & "KA1ABC WB9XYZ", & - "CQ 000 WB9XYZ EN34", & + "CQ 010 WB9XYZ EN34", & "CQ 999 WB9XYZ EN34", & "CQ EU WB9XYZ EN34", & "CQ WY WB9XYZ EN34", & diff --git a/lib/unpackmsg144.f90 b/lib/unpackmsg144.f90 deleted file mode 100644 index 96423ff6..00000000 --- a/lib/unpackmsg144.f90 +++ /dev/null @@ -1,117 +0,0 @@ - subroutine unpackmsg144(dat,msg,c1,c2) -! special unpackmsg for MSK144 - returns call1 and call2 to enable -! maintenance of a recent-calls-heard list - - use packjt - parameter (NBASE=37*36*10*27*27*27) - parameter (NGBASE=180*180) - integer dat(12) - character c1*12,c2*12,grid*4,msg*22,grid6*6,psfx*4,junk2*4 - logical cqnnn - - cqnnn=.false. - nc1=ishft(dat(1),22) + ishft(dat(2),16) + ishft(dat(3),10)+ & - ishft(dat(4),4) + iand(ishft(dat(5),-2),15) - - nc2=ishft(iand(dat(5),3),26) + ishft(dat(6),20) + & - ishft(dat(7),14) + ishft(dat(8),8) + ishft(dat(9),2) + & - iand(ishft(dat(10),-4),3) - - ng=ishft(iand(dat(10),15),12) + ishft(dat(11),6) + dat(12) - - if(ng.ge.32768) then - call unpacktext(nc1,nc2,ng,msg) - c1(1:12)=' ' - c2(1:12)=' ' - go to 100 - endif - - call unpackcall(nc1,c1,iv2,psfx) - if(iv2.eq.0) then - ! This is an "original JT65" message - if(nc1.eq.NBASE+1) c1='CQ ' - if(nc1.eq.NBASE+2) c1='QRZ ' - nfreq=nc1-NBASE-3 - if(nfreq.ge.0 .and. nfreq.le.999) then - write(c1,1002) nfreq - 1002 format('CQ ',i3.3) - cqnnn=.true. - endif - endif - - call unpackcall(nc2,c2,junk1,junk2) - call unpackgrid(ng,grid) - - if(iv2.gt.0) then - ! This is a JT65v2 message - do i=1,4 - if(ichar(psfx(i:i)).eq.0) psfx(i:i)=' ' - enddo - - n1=len_trim(psfx) - n2=len_trim(c2) - if(iv2.eq.1) msg='CQ '//psfx(:n1)//'/'//c2(:n2)//' '//grid - if(iv2.eq.2) msg='QRZ '//psfx(:n1)//'/'//c2(:n2)//' '//grid - if(iv2.eq.3) msg='DE '//psfx(:n1)//'/'//c2(:n2)//' '//grid - if(iv2.eq.4) msg='CQ '//c2(:n2)//'/'//psfx(:n1)//' '//grid - if(iv2.eq.5) msg='QRZ '//c2(:n2)//'/'//psfx(:n1)//' '//grid - if(iv2.eq.6) msg='DE '//c2(:n2)//'/'//psfx(:n1)//' '//grid - if(iv2.eq.7) msg='DE '//c2(:n2)//' '//grid - if(iv2.eq.8) msg=' ' - go to 100 - else - - endif - - grid6=grid//'ma' - call grid2k(grid6,k) - if(k.ge.1 .and. k.le.450) call getpfx2(k,c1) - if(k.ge.451 .and. k.le.900) call getpfx2(k,c2) - - i=index(c1,char(0)) - if(i.ge.3) c1=c1(1:i-1)//' ' - i=index(c2,char(0)) - if(i.ge.3) c2=c2(1:i-1)//' ' - - msg=' ' - j=0 - if(cqnnn) then - msg=c1//' ' - j=7 !### ??? ### - go to 10 - endif - - do i=1,12 - j=j+1 - msg(j:j)=c1(i:i) - if(c1(i:i).eq.' ') go to 10 - enddo - j=j+1 - msg(j:j)=' ' - - 10 do i=1,12 - if(j.le.21) j=j+1 - msg(j:j)=c2(i:i) - if(c2(i:i).eq.' ') go to 20 - enddo - if(j.le.21) j=j+1 - msg(j:j)=' ' - - 20 if(k.eq.0) then - do i=1,4 - if(j.le.21) j=j+1 - msg(j:j)=grid(i:i) - enddo - if(j.le.21) j=j+1 - msg(j:j)=' ' - endif - - 100 continue - if(msg(1:6).eq.'CQ9DX ') msg(3:3)=' ' - if(msg(1:2).eq.'E9' .and. & - msg(3:3).ge.'A' .and. msg(3:3).le.'Z' .and. & - msg(4:4).ge.'A' .and. msg(4:4).le.'Z' .and. & - msg(5:5).eq.' ') msg='CQ '//msg(3:) - - return - end subroutine unpackmsg144 diff --git a/lib/update_hasharray.f90 b/lib/update_hasharray.f90 index 0f9c872e..baf50329 100644 --- a/lib/update_hasharray.f90 +++ b/lib/update_hasharray.f90 @@ -1,21 +1,21 @@ -subroutine update_hasharray(recent_calls,nrecent,nhasharray) - - character*12 recent_calls(nrecent) - character*22 hashmsg - integer nhasharray(nrecent,nrecent) +subroutine update_hasharray(nhasharray) + + use packjt77 + character*37 hashmsg + integer nhasharray(MAXRECENT,MAXRECENT) nhasharray=-1 - do i=1,nrecent - do j=i+1,nrecent + do i=1,MAXRECENT + do j=i+1,MAXRECENT if( recent_calls(i)(1:1) .ne. ' ' .and. recent_calls(j)(1:1) .ne. ' ' ) then hashmsg=trim(recent_calls(i))//' '//trim(recent_calls(j)) call fmtmsg(hashmsg,iz) - call hash(hashmsg,22,ihash) + call hash(hashmsg,37,ihash) ihash=iand(ihash,4095) nhasharray(i,j)=ihash hashmsg=trim(recent_calls(j))//' '//trim(recent_calls(i)) call fmtmsg(hashmsg,iz) - call hash(hashmsg,22,ihash) + call hash(hashmsg,37,ihash) ihash=iand(ihash,4095) nhasharray(j,i)=ihash endif diff --git a/lib/wsprd/README b/lib/wsprd/README index 4579d2d3..141c2fb2 100755 --- a/lib/wsprd/README +++ b/lib/wsprd/README @@ -9,16 +9,21 @@ USAGE: OPTIONS: -a <path> path to writeable data files, default="." + -B disable block demodulation - use single-symbol noncoherent demod -c write .c2 file at the end of the first pass + -C maximum number of decoder cycles per bit, default 10000 + -d deeper search. Slower, a few more decodes -e x (x is transceiver dial frequency error in Hz) -f x (x is transceiver dial frequency in MHz) -H do not use (or update) the hash table + -J use the stack decoder instead of Fano decoder -m decode wspr-15 .wav file + -o n (0<=n<=5), decoding depth for OSD, default is disabled -q quick mode - doesn't dig deep for weak signals -s single pass mode, no subtraction (same as original wsprd) -v verbose mode (shows dupes) -w wideband mode - decode signals within +/- 150 Hz of center - -z x (x is fano metric table bias, default is 0.42) + -z x (x is fano metric table bias, default is 0.45) infile can be either .wav or .c2 @@ -35,8 +40,19 @@ subband center frequency. The wideband option (-w) extends this to +/- 150 Hz. wsprd maintains a hashtable and will decode all three types of wspr messages. An option (-H) is available to turn off use of the hashtable. +Decoding is attempted using soft symbols derived using single-symbol +noncoherent detection. If decoding fails, then soft symbols derived using +block demodulation over 2- and 3-symbol blocks are used in subsequent +decoding attempts. For slower computers, block demodulation can be +disabled with the -B command line option. + The symbols are decoded using Phil Karn's sequential decoder routine, -fano.c. +fano.c. The -J option replaces the Fano algorithm with the Jelinek +"stack-bucket" algorithm. If the -o command line option is enabled, then +an ordered-statistics decoder (OSD) is invoked if the Fano (or Jelinek) algorithm +fails. The OSD is a complete decoder, meaning that it always returns a codeword. +A returned codeword is considered valid only if the unpacked decode contains +a callsign that is already in the hashtable. NOTES: This program attempts to maximize the number of successful decodes per transmit diff --git a/lib/fsk4hf/osd300.f90 b/lib/wsprd/osdwspr.f90 index 565f4ce5..42b8e949 100644 --- a/lib/fsk4hf/osd300.f90 +++ b/lib/wsprd/osdwspr.f90 @@ -1,9 +1,12 @@ -subroutine osd300(llr,apmask,ndeep,decoded,cw,nhardmin,dmin) -! -! An ordered-statistics decoder for the (300,60) code. +subroutine osdwspr(ss,apmask,ndeep,cw,nhardmin,dmin) ! -include "ldpc_300_60_params.f90" +use iso_c_binding +parameter (N=162, K=50, L=32) +!integer*1 p1(L),p2(L),p3(L),p4(L) +integer*1 gg(64) + +real ss(N) integer*1 apmask(N),apmaskr(N) integer*1 gen(K,N) integer*1 genmrb(K,N),g2(N,K) @@ -11,33 +14,26 @@ integer*1 temp(K),m0(K),me(K),mi(K),misub(K),e2sub(N-K),e2(N-K),ui(N-K) integer*1 r2pat(N-K) integer indices(N),nxor(N) integer*1 cw(N),ce(N),c0(N),hdec(N) -integer*1 decoded(K) -integer indx(N) -real llr(N),rx(N),absrx(N) +integer indx(N),ndeep,nhardmin +real rx(N),absrx(N),dmin logical first,reset data first/.true./ +data gg/1,1,0,1,0,1,0,0,1,0,0,0,1,1,0,0,1,0,1,0,0,1,0,1,1,1,0,1,1,0,0,0, & + 0,1,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,1,0,0,1,0,0,1,0,1,1,1,1,1,1/ + save first,gen if( first ) then ! fill the generator matrix gen=0 - do i=1,M - do j=1, 15 - read(g(i)(j:j),"(Z1)") istr - do jj=1, 4 - irow=(j-1)*4+jj - if( btest(istr,4-jj) ) gen(irow,i)=1 - enddo - enddo + gen(1,1:2*L)=gg(1:2*L) + do i=2,K + gen(i,:)=cshift(gen(i-1,:),-2) enddo - do irow=1,K - gen(irow,M+irow)=1 - enddo -first=.false. + first=.false. endif -! Re-order received vector to place systematic msg bits at the end. -rx=llr(colorder+1) -apmaskr=apmask(colorder+1) +rx=ss/127.0 +apmaskr=apmask ! Hard decisions on the received word. hdec=0 @@ -93,49 +89,49 @@ rx=rx(indices) apmaskr=apmaskr(indices) call mrbencode(m0,c0,g2,N,K) + nxor=ieor(c0,hdec) nhardmin=sum(nxor) dmin=sum(nxor*absrx) - cw=c0 ntotal=0 nrejected=0 -if(ndeep.eq.0) goto 998 ! norder=0 +if(ndeep.le.0) goto 998 ! norder=0 if(ndeep.gt.5) ndeep=5 if( ndeep.eq. 1) then nord=1 npre1=0 npre2=0 - nt=120 - ntheta=12 + nt=66 + ntheta=16 elseif(ndeep.eq.2) then nord=1 npre1=1 npre2=0 - nt=120 - ntheta=12 + nt=66 + ntheta=16 elseif(ndeep.eq.3) then - nord=1 + nord=2 npre1=1 - npre2=1 - nt=120 - ntheta=12 - ntau=15 + npre2=0 + nt=66 + ntheta=22 + ntau=16 elseif(ndeep.eq.4) then nord=2 npre1=1 - npre2=0 - nt=120 - ntheta=12 - ntau=15 + npre2=1 + nt=66 + ntheta=22 + ntau=16 elseif(ndeep.eq.5) then nord=3 npre1=1 - npre2=1 - nt=80 - ntheta=40 - ntau=16 + npre2=0 + nt=66 + ntheta=22 + ntau=20 endif do iorder=1,nord @@ -240,13 +236,11 @@ if(npre2.eq.1) then endif 998 continue -! Re-order the codeword to place message bits at the end. +! Re-order the codeword to as-received order. cw(indices)=cw hdec(indices)=hdec -decoded=cw(M+1:N) -cw(colorder+1)=cw ! put the codeword back into received-word order return -end subroutine osd300 +end subroutine osdwspr subroutine mrbencode(me,codeword,g2,N,K) integer*1 me(K),codeword(N),g2(N,K) diff --git a/lib/wsprd/wsprd.c b/lib/wsprd/wsprd.c index 48ec1fae..2e4c3c23 100644 --- a/lib/wsprd/wsprd.c +++ b/lib/wsprd/wsprd.c @@ -43,6 +43,9 @@ #include "wsprsim_utils.h" #define max(x,y) ((x) > (y) ? (x) : (y)) + +extern void osdwspr_ (float [], unsigned char [], int *, unsigned char [], int *, float *); + // Possible PATIENCE options: FFTW_ESTIMATE, FFTW_ESTIMATE_PATIENT, // FFTW_MEASURE, FFTW_PATIENT, FFTW_EXHAUSTIVE #define PATIENCE FFTW_ESTIMATE @@ -59,8 +62,6 @@ unsigned char pr3[162]= 0,0,0,0,0,0,0,1,1,0,1,0,1,1,0,0,0,1,1,0, 0,0}; -unsigned long nr; - int printdata=0; //*************************************************************************** @@ -73,18 +74,18 @@ unsigned long readc2file(char *ptr_to_infile, float *idat, float *qdat, char *c2file[15]; FILE* fp; - buffer=calloc(2*65536,sizeof(float)); - fp = fopen(ptr_to_infile,"rb"); if (fp == NULL) { fprintf(stderr, "Cannot open data file '%s'\n", ptr_to_infile); return 1; } - unsigned long nread=fread(c2file,sizeof(char),14,fp); - nread=fread(&ntrmin,sizeof(int),1,fp); - nread=fread(&dfreq,sizeof(double),1,fp); + fread(c2file,sizeof(char),14,fp); + fread(&ntrmin,sizeof(int),1,fp); + fread(&dfreq,sizeof(double),1,fp); *freq=dfreq; - nread=fread(buffer,sizeof(float),2*45000,fp); + + buffer=calloc(2*65536,sizeof(float)); + unsigned long nread=fread(buffer,sizeof(float),2*45000,fp); fclose(fp); *wspr_type=ntrmin; @@ -93,13 +94,13 @@ unsigned long readc2file(char *ptr_to_infile, float *idat, float *qdat, idat[i]=buffer[2*i]; qdat[i]=-buffer[2*i+1]; } + free(buffer); if( nread == 2*45000 ) { return nread/2; } else { return 1; } - free(buffer); } //*************************************************************************** @@ -132,15 +133,16 @@ unsigned long readwavfile(char *ptr_to_infile, int ntrmin, float *idat, float *q FILE *fp; short int *buf2; - buf2 = calloc(npoints,sizeof(short int)); fp = fopen(ptr_to_infile,"rb"); if (fp == NULL) { fprintf(stderr, "Cannot open data file '%s'\n", ptr_to_infile); return 1; } - nr=fread(buf2,2,22,fp); //Read and ignore header - nr=fread(buf2,2,npoints,fp); //Read raw data + + buf2 = calloc(npoints,sizeof(short int)); + fread(buf2,2,22,fp); //Read and ignore header + fread(buf2,2,npoints,fp); //Read raw data fclose(fp); realin=(float*) fftwf_malloc(sizeof(float)*nfft1); @@ -154,8 +156,8 @@ unsigned long readwavfile(char *ptr_to_infile, int ntrmin, float *idat, float *q for (i=npoints; i<(size_t)nfft1; i++) { realin[i]=0.0; } - free(buf2); + fftwf_execute(PLAN1); fftwf_free(realin); @@ -648,30 +650,27 @@ unsigned long writec2file(char *c2filename, int trmin, double freq { int i; float *buffer; - buffer=calloc(2*45000,sizeof(float)); - FILE *fp; fp = fopen(c2filename,"wb"); if( fp == NULL ) { fprintf(stderr, "Could not open c2 file '%s'\n", c2filename); - free(buffer); return 0; } unsigned long nwrite = fwrite(c2filename,sizeof(char),14,fp); nwrite = fwrite(&trmin, sizeof(int), 1, fp); nwrite = fwrite(&freq, sizeof(double), 1, fp); + buffer=calloc(2*45000,sizeof(float)); for(i=0; i<45000; i++) { buffer[2*i]=idat[i]; buffer[2*i+1]=-qdat[i]; } - nwrite = fwrite(buffer, sizeof(float), 2*45000, fp); + free(buffer); if( nwrite == 2*45000 ) { return nwrite; } else { - free(buffer); return 0; } } @@ -693,6 +692,7 @@ void usage(void) printf(" -H do not use (or update) the hash table\n"); printf(" -J use the stack decoder instead of Fano decoder\n"); printf(" -m decode wspr-15 .wav file\n"); + printf(" -o n (0<=n<=5), decoding depth for OSD, default is disabled\n"); printf(" -q quick mode - doesn't dig deep for weak signals\n"); printf(" -s single pass mode, no subtraction (same as original wsprd)\n"); printf(" -v verbose mode (shows dupes)\n"); @@ -708,7 +708,7 @@ int main(int argc, char *argv[]) extern char *optarg; extern int optind; int i,j,k; - unsigned char *symbols, *decdata, *channel_symbols; + unsigned char *symbols, *decdata, *channel_symbols, *apmask, *cw; signed char message[]={-9,13,-35,123,57,-39,64,0,0,0,0}; char *callsign, *call_loc_pow; char *ptr_to_infile,*ptr_to_infile_suffix; @@ -718,18 +718,21 @@ int main(int argc, char *argv[]) char uttime[5],date[7]; int c,delta,maxpts=65536,verbose=0,quickmode=0,more_candidates=0, stackdecoder=0; int writenoise=0,usehashtable=1,wspr_type=2, ipass, nblocksize; + int nhardmin,ihash; int writec2=0,maxdrift; int shift1, lagmin, lagmax, lagstep, ifmin, ifmax, worth_a_try, not_decoded; unsigned int nbits=81, stacksize=200000; unsigned int npoints, metric, cycles, maxnp; float df=375.0/256.0/2; float freq0[200],snr0[200],drift0[200],sync0[200]; + float fsymbs[162]; int shift0[200]; float dt=1.0/375.0, dt_print; double dialfreq_cmdline=0.0, dialfreq, freq_print; double dialfreq_error=0.0; float fmin=-110, fmax=110; float f1, fstep, sync1, drift1; + float dmin; float psavg[512]; float *idat, *qdat; clock_t t0,t00; @@ -738,15 +741,18 @@ int main(int argc, char *argv[]) struct result { char date[7]; char time[5]; float sync; float snr; float dt; double freq; char message[23]; float drift; - unsigned int cycles; int jitter; int blocksize; unsigned int metric; }; + unsigned int cycles; int jitter; int blocksize; unsigned int metric; + unsigned char osd_decode; }; struct result decodes[50]; char *hashtab; hashtab=calloc(32768*13,sizeof(char)); int nh; - symbols=calloc(nbits*2,sizeof(char)); - decdata=calloc(11,sizeof(char)); - channel_symbols=calloc(nbits*2,sizeof(char)); + symbols=calloc(nbits*2,sizeof(unsigned char)); + apmask=calloc(162,sizeof(unsigned char)); + cw=calloc(162,sizeof(unsigned char)); + decdata=calloc(11,sizeof(unsigned char)); + channel_symbols=calloc(nbits*2,sizeof(unsigned char)); callsign=calloc(13,sizeof(char)); call_loc_pow=calloc(23,sizeof(char)); float allfreqs[100]; @@ -765,6 +771,7 @@ int main(int argc, char *argv[]) int block_demod=1; //Default is to use block demod on pass 2 int subtraction=1; int npasses=2; + int ndepth=-1; //Depth for OSD float minrms=52.0 * (symfac/64.0); //Final test for plausible decoding delta=60; //Fano threshold step @@ -779,7 +786,7 @@ int main(int argc, char *argv[]) idat=calloc(maxpts,sizeof(float)); qdat=calloc(maxpts,sizeof(float)); - while ( (c = getopt(argc, argv, "a:BcC:de:f:HJmqstwvz:")) !=-1 ) { + while ( (c = getopt(argc, argv, "a:BcC:de:f:HJmo:qstwvz:")) !=-1 ) { switch (c) { case 'a': data_dir = optarg; @@ -812,6 +819,9 @@ int main(int argc, char *argv[]) case 'm': //15-minute wspr mode wspr_type = 15; break; + case 'o': //use ordered-statistics-decoder + ndepth=(int) strtol(optarg,NULL,10); + break; case 'q': //no shift jittering quickmode = 1; break; @@ -881,10 +891,10 @@ int main(int argc, char *argv[]) // fdiag=fopen("wsprd_diag","a"); if((ftimer=fopen(timer_fname,"r"))) { - //Accumulate timing data - nr=fscanf(ftimer,"%f %f %f %f %f %f %f", - &treadwav,&tcandidates,&tsync0,&tsync1,&tsync2,&tfano,&ttotal); - fclose(ftimer); + //Accumulate timing data + fscanf(ftimer,"%f %f %f %f %f %f %f", + &treadwav,&tcandidates,&tsync0,&tsync1,&tsync2,&tfano,&ttotal); + fclose(ftimer); } ftimer=fopen(timer_fname,"w"); @@ -1242,7 +1252,9 @@ int main(int argc, char *argv[]) int idt, ii, jittered_shift; float y,sq,rms; not_decoded=1; - int ib=1, blocksize; + int osd_decode=0; + int ib=1, blocksize; + int n1,n2; while( ib <= nblocksize && not_decoded ) { blocksize=ib; idt=0; ii=0; @@ -1278,6 +1290,34 @@ int main(int argc, char *argv[]) } tfano += (float)(clock()-t0)/CLOCKS_PER_SEC; + + if( (ndepth >= 0) && not_decoded ) { + for(i=0; i<162; i++) { + fsymbs[i]=symbols[i]-127; + } + osdwspr_(fsymbs,apmask,&ndepth,cw,&nhardmin,&dmin); + for(i=0; i<162; i++) { + symbols[i]=255*cw[i]; + } + fano(&metric,&cycles,&maxnp,decdata,symbols,nbits, + mettab,delta,maxcycles); + for(i=0; i<11; i++) { + if( decdata[i]>127 ) { + message[i]=decdata[i]-256; + } else { + message[i]=decdata[i]; + } + } + unpack50(message,&n1,&n2); + if( !unpackcall(n1,callsign) ) break; + callsign[12]=0; + ihash=nhash(callsign,strlen(callsign),(uint32_t)146); + if(strncmp(hashtab+ihash*13,callsign,13)==0) { + not_decoded=0; + osd_decode =1; + break; + } + } } idt++; @@ -1285,7 +1325,7 @@ int main(int argc, char *argv[]) } ib++; } - + if( worth_a_try && !not_decoded ) { ndecodes_pass++; @@ -1347,6 +1387,7 @@ int main(int argc, char *argv[]) decodes[uniques-1].jitter=ii; decodes[uniques-1].blocksize=blocksize; decodes[uniques-1].metric=metric; + decodes[uniques-1].osd_decode=osd_decode; } } } @@ -1378,11 +1419,11 @@ int main(int argc, char *argv[]) decodes[i].time, decodes[i].snr,decodes[i].dt, decodes[i].freq, (int)decodes[i].drift, decodes[i].message); fprintf(fall_wspr, - "%6s %4s %3d %3.0f %5.2f %11.7f %-22s %2d %5u %4d %4d %4d\n", + "%6s %4s %3d %3.0f %5.2f %11.7f %-22s %2d %5u %4d %4d %4d %2u\n", decodes[i].date, decodes[i].time, (int)(10*decodes[i].sync), decodes[i].snr, decodes[i].dt, decodes[i].freq, decodes[i].message, (int)decodes[i].drift, decodes[i].cycles/81, - decodes[i].jitter,decodes[i].blocksize,decodes[i].metric); + decodes[i].jitter,decodes[i].blocksize,decodes[i].metric,decodes[i].osd_decode); fprintf(fwsprd, "%6s %4s %3d %3.0f %4.1f %10.6f %-22s %2d %5u %4d\n", decodes[i].date, decodes[i].time, (int)(10*decodes[i].sync), diff --git a/lib/xcor4.f90 b/lib/xcor4.f90 index 9e1f5a52..9e4aff59 100644 --- a/lib/xcor4.f90 +++ b/lib/xcor4.f90 @@ -37,7 +37,7 @@ subroutine xcor4(s2,ipk,nsteps,nsym,lag1,lag2,ich,mode4,ccf,ccf0, & ccfmax=0.
ccfmin=0.
- nw=nch(ich)
+ nw=nch(min(max(ich,1),7))
do j=1,nsteps
n=2*mode4
|
