diff --git a/lib/ldpc/COPYRIGHT b/lib/ldpc/COPYRIGHT deleted file mode 100755 index 9cd0d7f65..000000000 --- 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 0ca12aceb..000000000 --- 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 7106bb0ae..000000000 --- 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 5f539ee84..000000000 --- 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 45aa36a47..000000000 --- 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 dd34af58a..000000000 --- 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 21831ded1..000000000 --- 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 -#include -#include -#include - -#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; iN) - { bad_alist_file(); - } - } - - cw = (int *) chk_alloc (N, sizeof *cw); - - for (j = 0; jM) - { 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; iN || 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; jM || !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 f289ceb84..000000000 --- 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 -#include - -#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 aa1fb1738..000000000 --- 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 c9d08632a..000000000 --- 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 -#include - -#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; i0) - { 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 -#include -#include -#include - -#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 0522e856d..000000000 --- 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 ad5129195..000000000 --- a/lib/ldpc/channel.html +++ /dev/null @@ -1,182 +0,0 @@ - - - Transmission Through a Simulated Channel - - - - -

Transmission Through a Simulated Channel

- -

Once a codeword has been found to represent a source message, it -can be sent through a channel, 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. - -

For a Binary Symmetric Channel (BSC), each bit sent -results in a bit being received. The bit received differs from the -bit sent with some error probability, p, 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: -

-P(receive 1 | send 1) = P(receive 0 | send 0) = 1-p
-P(receive 1 | send 0) = P(receive 0 | send 1) = p -
- -

For an Additive White Gaussian Noise (AWGN) channel, the -data received at each time is equal to the data sent plus Gaussian -noise with mean zero and some standard deviation, s, -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: -

-data received | send 1 ~ N(+1,s2)
-data received | send 0 ~ N(-1,s2) -
- -

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 R will then be the same as is obtained -using a code that repeats each bit n times, and sends these -bits at rate nR (assuming optimal decoding of each bit by -thresholding the sum of the n channel outputs corresponding to -that bit). Another way of looking at this scaling for s 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. - -

To account for this, it is common to compare codes for AWGN -channels in terms of their bit error rate and the value of -

-Eb / N0 -= 1 / 2Rs2 -
-at which they operate, where R=K/N is the rate -of the code, and s 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 -Eb / -N0 in decibels (db), equal to -10 log10(Eb -/ N0). - -

The Additive White Logistic Noise (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 -

-(1/w) exp(-n/w) / [1 + exp(-n/w)]2 -
-where n is the amount of noise, and w is a width parameter -for the distribution, analogous to the s parameter for -Gaussian noise. (However, w is not equal to the standard deviation -for the logistic distribution, which is -sqrt(pi2/3)w.) Note: 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. - - -


transmit: Transmit bits through a -simulated channel. - -
-transmit encoded-file|n-zeros received-file seed channel
-
-
-where channel is one of the following: -
-bsc error-probability
-
-awgn standard-deviation
-
-awln width
-
-
-
- -

Simulates the transmission of the bits in -encoded-file through a channel, with the received data -being stored in received-file. Typically, -encoded-file will have been produced by the encode program, but it could -also come from rand-src -or another program. If newlines separate blocks in -encoded-file, these block boundaries will be preserved -in received-file. - -

Alternatively, a count of zeros to transmit can be given, rather -than a encoded-file. This count can be the product of the -block size and the number of blocks, written with x -separating these numbers, with no spaces. The -received-file 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. Warning: 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. - -

The transmission will be corrupted by random noise, which will be -generated pseudo-randomly based on seed. The actual -random seed used will be seed 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. - -

The fourth argument specifies the type of channel, currently either -bsc (or BSC) for the Binary Symmetric Channel, or -awgn (or AWGN) for the Additive White Gaussian -Noise channel, or awln (or AWLN) for the Additive White -Logistic Noise channel. The channel type is followed by an argument -specifying the characteristics of the channel, as follows: -

-

BSC: The probability that a bit will be flipped by noise - ie, the - probability that the bit received is an error. - -

AWGN: The standard deviation of the Gaussian noise that is added to the - encodings of the bits. - -

AWLN: The width parameter of the logistic distribution for the noise - that is added to the encodings of the bits. -

- -See the description of channel transmission -for more details. - -

Examples: The command: -

    -
  • transmit 10x3 rec 1 bsc 0.1 -
-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 rec: -
-0000000000
-1000000000
-0100000000
-
-If an AWGN channel is used instead, as follows: -
    -
  • transmit 10x3 rec 1 awgn 0.5 -
-then the file rec will contain data such as: -
- -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
-
- -
- -Back to index for LDPC software - - diff --git a/lib/ldpc/check.c b/lib/ldpc/check.c deleted file mode 100755 index e22b1dd9b..000000000 --- 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 -#include -#include - -#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; i1); - } - - 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; i0) - { 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; j0 && 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 7ac005446..000000000 --- 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 68029115f..000000000 --- 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 -#include -#include - -#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=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; jmaxlk) - { for (j = 0; 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; jpr = 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; ilr = 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; jpr = 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 - - Detailed Decoding Trace Information - - - - -

Detailed Decoding Trace Information

- -The -T option to decode -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. - - -

Enum-bit and Enum-block decoding methods

- -For source messages with K bits, 2K lines are output -for each block, containing the following information: -
- - - - - - - - - - -
block The number of the block, from zero
decoding A possible decoding for the message bits, expressed as a hexadecimal - number. The other bits are determined by the message bits.
likelihood The likelihood for this decoding (ie, the probability of obtaining - the data received if this was the message sent).
-
- -For these methods, the number of "iterations" (output with the --t option) is always 2K. - - -

Prprp decoding method

- -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: -
- - - - - - - - - - - - - - - - - - - - - - - - - -
block The number of the block, from zero
iter The number of an iteration, zero for the initial state.
changed 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.)
perrs The number of parity check errors in the current tentative - decoding.
loglik The log likelihood of the current tentative decoding.
Eperrs 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.
Eloglik The expected log likelihood of a decoding found by randomly picking - a value for each bit, independently, according to the current bit - probabilities. -
entropy The entropy (in bits) of the distribution defined by the current bit - probablities, assumed to apply to bits independently.
-
- -The number of "iterations" (output with the -t option) is -the obvious count of probability propagation iterations. The -initial state does not count as an iteration. - -
- -Back to decoding documentation
-Back to index for LDPC software - - diff --git a/lib/ldpc/decode.c b/lib/ldpc/decode.c deleted file mode 100755 index ec04f2e44..000000000 --- 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 -#include -#include -#include - -#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; i0) - { 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= 2^31 */ - fflush(stdout); - } - - /* Write decoded block. */ - - blockio_write(df,dblk,N); - - /* Write bit probabilities, if asked to. */ - - if (pfile) - { for (j = 0; j - - Decoding Received Blocks - - - - -

Decoding Received Blocks

- -Transmitted codewords are decoded from the received data on the basis -of the likelihood 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 likelihood -ratio in favour of a 1, which is P(data | bit is 1) / P(data | -bit is 0). - -

For a Binary Symmetric Channel with error probability p, -the likelihood ratio in favour of a 1 bit is as follows: -

- If the received data was +1: (1-p) / p
- If the received data was -1: p / (1-p) -
-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 s, the -likelihood ratio in favour of a 1 bit when data y was received is -
- exp ( 2y / s2 ) -
-For an Additive White Logistic Noise channel, the corresponding -likelihood ratio is -d1/d0, -where -d1=e1 -/ (1+e1)2 and -d0=e0 -/ (1+e0)2, -with e1=exp(-(y-1)/w) and -e0=exp(-(y+1)/w). -
- -

It is usual to consider codewords to be equally likely a -priori. 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 linear dependence in parity check matrices. -This minor complication is mostly ignored here, except by the exhaustive -enumeration decoding methods. - -

Assuming equal a priori 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. - -

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. - -

Decoding by probability propagation

- -

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 references for details. Below, I give a fairly -intuitive description of the algorithm. - -

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. - -

The begin, information about each bit of the codeword derived from -the received data for that bit alone is expressed as a probability -ratio, 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 a priori. 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 other parity checks, -along with the data received for the bit. - -

For each parity check, the algorithm maintains separate -likelihood ratios (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 other -bits participating in this check being 1, as derived from the -probability ratios for these bits with respect to this check. - -

The algorithm alternates between recalculating the likelihood -ratios for each check, which are stored in the lr fields of the -parity check matrix entries, and recalculating the probability ratios -for each bit, which are stored in the pr fields of the entries -in the sparse matrix representation of the parity check matrix. (See -the documentation on representation of -sparse matrices for details on these entries.) - -

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 -

- t - = product of [ 1 / (1+pi) - - pi / - (1+pi) ] - = product of [ 2 / (1+pi) - 1 ] -
-where the product is over the probability ratios -pi for the other bits participating -in this check. Factor i in this product is equal to probability -of bit 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 -t 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-t)/(1+t). - -

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-1 by the running product of the factors from i+1 on -gives the product needed for bit 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. - -

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 other -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. - -

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. - -

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. - - -


decode: Decode blocks of received data -into codewords. - -
-decode [ -f ] [ -t | -T ] pchk-file received-file decoded-file [ bp-file ] channel method
-
-
-where channel is one of: -
-bsc error-probability
-
-awgn standard-deviation
-
-awln width
-
-and method is one of: -
-enum-block gen-file
-
-enum-bit gen-file
-
-prprp [-]max-iterations
-
-
-
- -

Decodes the blocks in received-file, which are -assumed to be have been received through the specified channel. The -results written to decoded-file 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 -bp-file, if given. - -

A newline is output at the end of each block written to -decoded-file and bp-file. Newlines in -received-file are ignored. A warning is displayed on -standard error if the number of bits in received-file -is not a multiple of the block length. - -

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. - -

If the -t 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: -

- - - - - - - - - - - - - -
block The number of the block, from zero
iterations The number of "iterations" used in decoding. What exactly an iteration - is depends on the decoding method used (see - here).
valid Has the value 1 if the decoding is a valid codeword, 0 if not.
changed 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.
-
-The file produced is is suitable for -reading into the S-Plus or R statistics packages, with a command such as -
-data <- read.table(file,header=T)
-
- -

If instead the -T option is given, detailed information on -the process of decoding each block will be written to standard output. -For a description, see the documentation -on detailed decoding trace information. - -

The type of channel that is assumed is specified after the file -name arguments. This may currently be either bsc (or -BSC) for the Binary Symmetric Channel, or awgn (or -AWGN) for the Additive White Gaussian Noise channel, or -awln (or AWLN) for the Additive White Logistic Noise -channel. The channel type is followed by an argument specifying the -assumed characteristics of the channel, as follows: -

-

BSC: The probability that a bit will be flipped by noise - ie, the - probability that the bit received is an error. - -

AWGN: The standard deviation of the Gaussian noise added to the - encodings of the bits. - -

AWLN: The width parameter of the logistic distribution for the noise - that is added to the encodings of the bits. -

-See the description of channel transmission -for more about these channels. - -

Following the channel specification is a specification of the -decoding method to use. The enum-block and enum-bit -methods find the optimal decoding by exhaustive enumeration of -codewords derived from all possible source messages. They differ in -that enum-block decodes to the most likely codeword, whereas -enum-bit 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 linear -dependence in parity check matrices). - -

The prprp decoding method decodes using probability propagation. The maximum number of -iterations of probability propagation to do is given following -prprp. 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 -bp-file 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. - -

If the -f option is given, output to decoded-file -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. - - -


extract: Extract the message bits from a block. - -
-extract gen-file decoded-file extracted-file
-
- -

Given a file of codewords in decoded-file (usually, -decoded blocks output by decode), and a -generator matrix from gen-file (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 extracted-file. - -

A newline is output at the end of each block written to -extracted-file. Newlines in -decoded-file are ignored. A warning is displayed on -standard error if the number of bits in decoded-file -is not a multiple of the block length. - -


- -Back to index for LDPC software - - diff --git a/lib/ldpc/dep-H.html b/lib/ldpc/dep-H.html deleted file mode 100755 index b80b2a5c2..000000000 --- a/lib/ldpc/dep-H.html +++ /dev/null @@ -1,85 +0,0 @@ - - - Linear Dependence in Parity Check Matrices - - - - -

Linear Dependence in Parity Check Matrices

- -

If a code is specified by means of a M by N parity -check matrix, H, in which some rows are linearly dependent - a -situation that is usually avoided - it would be possible to map more -than the usual K=N-M message bits into a codeword, since one or -more rows of H could have been deleted without affecting which -bit vectors are codewords. - -

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 description of generator matrix -representations, this is accomplished by partially computing -what would normally be A-1 (for a -dense or mixed representations) or the L and U matrices -(for a sparse representation), even though singularity prevents this -computation from being carried out fully. - -

Example: The parity check matrix created below is redundant, -since the 10100 row is equal to the sum of the 11000 and 01100 rows. -

    -
  • make-pchk dep.pchk 4 5 0:0 0:1 1:1 1:2 2:0 2:2 3:3 3:4 -
  • 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 - -
  • 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 -
  • 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 -
-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 -A-1B, 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. - -

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. - -

Note that codeword bits that are always zero can arise even when H -does not have linearly dependent rows. For example, if a row of H -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 M independent rows is equivalent to adding additional rows -to H in which only one bit is 1, in order to produce M -independent checks. - -


- -Back to index for LDPC software - - diff --git a/lib/ldpc/distrib.c b/lib/ldpc/distrib.c deleted file mode 100755 index 879c54adf..000000000 --- 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 -#include -#include -#include - -#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; isize; 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; ilist[]). */ - -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 8b4cdbde1..000000000 --- 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 -#include -#include - -/*#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 -#include -#include -#include - -#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 - - Encoding Message Blocks - - - - -

Encoding Message Blocks

- -To use a code to send messages, we must define a mapping from a bit -vector, s, of length K, representing a source message, -to a codeword, x, of length N>K. We will -consider only linear mappings, which can be written in the form -x=GTs, where G -is a generator matrix. For a code with parity check matrix -H, whose codewords satisfy Hx=0, the generator -matrix must satisfy HGT=0. -This software assumes that the number of rows in the parity check -matrix, M, is equal to N-K, as would normally be the -case. - -

This software deals only with systematic encodings, in which -the K bits of s are copied unchanged to some subset of -the N bits of x (the message bits), and the -remaining M=N-K check bits of x 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 K columns of the K by N generator matrix -will then be the identity matrix. - -

However, this software does not 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 decode) 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 extract). - -

This software stores representations of generator matrices in files -in a format that is not human-readable (except by using the print-gen program). However, these -files are readable on a machine with a different architecture -than they were written on. - - -

Generator matrix representations

- -

For simplicity of exposition, it will be assumed for the next few -paragraphs that the message bits are located at the end of the -codeword, so a codeword can be divided into M check bits, -c, followed by K message bits, s. - -

On the above assumption, the parity check matrix, H, can be divided -into an M by M matrix A occupying -the first M columns of H and an M by K matrix -B occupying the remaining columns of H. The requirement that -a codeword, x, satisfy all parity checks (ie, that Hx=0) -can then be written as -

- Ac + Bs = 0 -
-Provided that A is non-singular, it follows that -
- c = A-1Bs -
-A may be singular for some choices of which codeword bits are message -bits, but a choice for which A is non-singular always exists if the -rows of H are linearly independent. It is possible, however, that the -rows of H 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 linear -dependence in parity check matrices for the details. - -

The equation c = A-1Bs -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 G mentioned above.) - -

In the dense representation, the M by K matrix -A-1B is computed, and stored -in a dense format (see the dense modulo-2 -matrix package). A message is encoded by multiplying the -source bits, s, by this matrix to obtain the required check bits. - -

In the mixed representation, the M by M matrix -A-1 is computed and stored in a dense -format, and the M by K matrix B, the right -portion of the parity check matrix, is also stored, in a sparse format -(see the sparse modulo-2 matrix package). -To encode a message, the source vector s is first multiplied on -the left by B, an operation which can be done very quickly if -B is sparse (as it will be for LDPC codes). The result is then -multiplied on the left by A-1. If -M<K, the total time may be less than when using the -dense representation above. - -

The sparse representation goes further, and avoids -explicitly computing A-1, which tends -to be dense even if H is sparse. Instead, a LU -decomposition of A is found, consisting of a lower -triangular matrix L and an upper triangular matrix U for -which LU=A. The effect of multiplying Bs=z by -A-1 can then be obtained by -

- Solving Ly=z for y using forward substitution.
- Solving Uc=y for c using backward substitution. -
-Both of these operations will be fast if L and U are -sparse. Heuristics are used to try to achieve this, by rearranging the -rows and columns of H in the process of selecting A and -finding its LU decomposition. - - -


make-gen: Make a generator matrix from -a parity check matrix. - -
-make-gen pchk-file gen-file method
-
-
-where method is one of the following: -
-sparse [ first | mincol | minprod ] [ abandon-num abandon-when ]
-
-dense [ other-gen-file  ]
-
-mixed [ other-gen-file  ]
-
-
-
- -

Finds a generator matrix for the code whose parity check matrix is -in pchk-file, and writes a representation of this -generator matrix to gen-file. The remaining arguments -specify what representation of the generator matrix is to be used (see -the description above), 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. - -

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 dense and -mixed representations, an other-gen-file 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 -A matrix; redundant rows of H are not allowed with this -option). Otherwise, make-gen 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. - -

The dense representation consists of a dense representation -of the matrix A-1B, where -A is the matrix consisting of the first M columns (after -reordering) of the parity check matrix, and B is the remaining -columns. If H contains redundant rows, there is an additional -reordering of columns of A in order create the same effect as -if the redundant rows came last. - -

The mixed representation consists of a dense representation -of the matrix A-1, where A is -the matrix consisting of the first M columns (after reordering) -of the parity check matrix. The remaining columns of the parity check -matrix, making up the matrix B, are also part of the -representation, but are not written to gen-file, since -they can be obtained from pchk-file. As for mixed -representations, an additional reordering of columns of A may -be needed if H has redundant rows. - -

A sparse representation consists of sparse representations -of the L and U matrices, whose product is A, the -first M columns of the parity check matrix (whose columns and -rows may both have been reordered). The matrix B, consisting -of the remaining columns of the parity check matrix, is also part of -the representation, but it is not written to gen-file, -since it can be obtained from pchk-file. - -

If a sparse representation is chosen, arguments after -sparse specify what heuristic is used when reordering columns -and rows in order to try to make L and U as sparse as -possible. The default if no heuristic is specified is -minprod. If the abandon-num and -abandon-when options are given, some information is -discarded in order to speed up the process of finding L and -U, at a possible cost in terms of how good a result is -obtained. For details on these heuristics, see the descriptions of sparse LU decomposition methods. - -

Example: A dense representation of a generator matrix for the -Hamming code created by the example for make-pchk can be created as follows: -

    -
  • make-gen ham7.pchk ham7.gen dense -Number of 1s per check in Inv(A) X B is 3.0 -
- - -


print-gen: Print a representation of a -generator matrix. - -
-print-gen [ -d ] gen-file
-
- -

Prints in human-readable form the representation of the generator -matrix that is stored in gen-file. The -d -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 description above for details of generator matrix -representations. Note that the L matrix for a sparse representation -will be lower triangular only after the rows are rearranged, and the U -matrix will be upper triangular only after the columns are rearranged. -The matrix B that is part of the sparse -and mixed representations is not printed, since it is not stored -in the gen-file, but is rather a subset of columns -of the parity check matrix. - -

Example: The generator matrix for the -Hamming code created by the example for make-gen can be printed as follows: -

    -
  • 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 -
-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. - -


encode: Encode message blocks as codewords - -
-encode [ -f ] pchk-file gen-file source-file encoded-file
-
- -Encodes message blocks of length K, read from -source-file, as codewords of length N, which -are written to encoded-file, replacing any previous -data in this file. Here, N is the number of columns in the -parity check matrix in pchk-file, and -K=N-M, where M is the number of rows in the -parity check matrix. The generator matrix used, from -gen-file, 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 -pchk-file using
make-gen. - -

A newline is output at the end of each block written to -encoded-file. Newlines in source-file -are ignored. - -

If the -f option is given, output to encoded-file -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. - -


- -Back to index for LDPC software - - diff --git a/lib/ldpc/ex-dep b/lib/ldpc/ex-dep deleted file mode 100755 index 3acebedca..000000000 --- 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 c4df520a7..000000000 --- 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 7ccc08097..000000000 --- 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 eaa4ea522..000000000 --- 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 3bdd4a60f..000000000 --- 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 37ecfc493..000000000 --- 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 7165e4823..000000000 --- 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 0dc1a1cf8..000000000 --- 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 19c4ba080..000000000 --- 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 418ed5c96..000000000 --- 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 f791e0568..000000000 --- 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 f7bae5b91..000000000 --- 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 e8995e54c..000000000 --- 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 3cdb2081e..000000000 --- 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 a8304c6c8..000000000 --- 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 cde814c92..000000000 --- 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 bc94faed1..000000000 --- a/lib/ldpc/examples.html +++ /dev/null @@ -1,87 +0,0 @@ - - - Examples of LDPC Program Usage - - - - -

Examples of LDPC Program Usage

- -

Below, are some command files containing examples of the use of -the LDPC programs, 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 run-examples script runs all the example -scripts and compares their output with the outputs that I obtained (on -a Pentium machine). - -

ex-ham7b, -output in ex-ham7b-out -

-A (7,4) Hamming code used with a BSC. -Demonstrates encoding of random messages and decoding to minimize -bit error rate by exhaustive enumeration. -
- -

ex-ham7a, -output in ex-ham7a-out -

-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. -
- -

ex-dep, -output in ex-dep-out -

-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. -
- -

ex-ldpc-encode, -output in ex-ldpc-encode-out -

-Encodes messages with an LDPC code using sparse, dense, and mixed -representations of the generator matrix. -
- -

ex-ldpc36-1000a, -output in ex-ldpc36-1000a-out -

-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. -
- -

ex-ldpc36-5000a, -output in ex-ldpc36-5000a-out -

-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. -
- -

ex-ldpcvar-5000a, -output in ex-ldpcvar-5000a-out -

-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. -
- -

ex-wrong-model, -output in ex-wrong-model-out -

-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). -
- -
- -Back to index for LDPC software - - diff --git a/lib/ldpc/extract.c b/lib/ldpc/extract.c deleted file mode 100755 index f969f8970..000000000 --- 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 -#include -#include -#include - -#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 - - Github Facilities - - - -

Github Facilities

- -

Starting with the Version of 2012-02-11, the source code repository -for this software is hosted by Github, -and is located at http://github.com/radfordneal/LDPC-codes. -This repository includes the annotated log of changes made since the -Version of 2006-02-08. - -

You can use the facilities at Github to obtain the source-code -repository, report bugs, and contribute to the wiki. - -

Obtaining the source repository, and modifying it

- -

To obtain a copy of the source-code repository, issue the following -command (in a Unix/Linux/Cygwin environment that has git installed): -

-git clone git://github.com/radfordneal/LDPC-codes
-
-This will retrieve the current state of the software, storing it -in the directory LDPC-codes, which you should ensure does not -exist before issuing this command above. - -

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 installation -instructions. - -

The LDPC-codes directory created by the git clone -command is a git repository, which can be manipulated with the various -forms of the git command, which are documented, for example, -here. - -

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. - -

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 Github user, you can set -up your own fork of the software for you and other people to use. - - -

Reporting Bugs

- -You can use the Github "Issues" facility to report bugs in the -software. You have to register as a Github -user to do this (which is free). You can then go here 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. - -
- -Back to index for LDPC software - - diff --git a/lib/ldpc/index.html b/lib/ldpc/index.html deleted file mode 100755 index 11aa1248e..000000000 --- a/lib/ldpc/index.html +++ /dev/null @@ -1,89 +0,0 @@ - - - Software for Low Density Parity Check Codes - - - - -

Software for Low Density Parity Check Codes

- -

Version in development. - -

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. - -

This and past versions of the software are available here, -from Radford Neal's -web page. The source code for this software is also hosted at Github, -where there is a copy -of these documentation pages for the latest release. Github also -provides facilities for bug reporting and discussion. - -

Index to Documentation

- -Download and installation instructions -
- How to get and compile the programs and modules. -
-Github facilities -
- How to get the source repository, report bugs, etc. -
-Release notes -
- A log of changes made in each release of this software. -
-Software and program usage documentation -
- General documentation on the methods implemented, and details of - program usage. -
-Examples of program usage -
- Examples using simple Hamming codes, and using more interesting LDPC codes. -
-How to modify the programs -
- Notes on how to add new channel types, new decoding methods, etc. -
-Module documentation -
- Modules used by the programs for modulo-2 matrix - operations and random number generation. -
-References -
- Classic and more recent papers on LDPC codes and related topics. -
- -

Copyright and Lack of Warranty

- -

Except as otherwise specified, all of this software and -documentation is copyright © 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/install.html b/lib/ldpc/install.html deleted file mode 100755 index f6966ab58..000000000 --- a/lib/ldpc/install.html +++ /dev/null @@ -1,82 +0,0 @@ - - - Installing the LDPC Software - - - -

Installing the LDPC Software

- -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 Cygwin -Unix-like environment that runs under Microsoft Windows. The -installation instructions below assume that you are using a Unix-like -system. - -

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: -

- Tar - file of LDPC software (0.9 Megabytes)
- Gzipped - tar file of LDPC software (0.4 Megabytes) -
- -

Once you obtain the tar file (and uncompress it with gunzip if -necessary), you should extract the files with the following Unix command: -

-tar xf LDPC-yyyy-mm-dd.tar
-
-This will create a source directory called LDPC-yyyy-mm-dd, and place -all the source, documentation, and other files in this directory. - -

If you prefer for this directory to be called something else, -rename it now, before compiling the programs, since the file -randfile in this directory, containing natural random numbers, -is accessed according to its path when the programs were compiled. - -

Once the tar command above has finished, you should change into the -newly-created directory, and type -

-make
-
-If all goes well, this should compile all the programs (except for some -test programs, which can be compiled with make test). You -may want to edit the file Makefile before running make -in order to change compilation options, such as the optimization level. - -

You can run the programs from this source directory, or you can copy -them to some other directory by running the LDPC-install -shell file. For instance, to install them in a bin directory in your -home directory, do the following: -

-./LDPC-install $HOME/bin
-
- -

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 index.html 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 -

-file:path-to-software/index.html
-
-where path-to-software is the full path (starting with "/") -to the directory where you've put the software. - -

The command -

-make clean
-
-will remove all the compiled programs, as well as the files created when -the examples are run, and core, if it -exists. - -
- -Back to index for LDPC software - - diff --git a/lib/ldpc/intio.c b/lib/ldpc/intio.c deleted file mode 100755 index bfa8db9f3..000000000 --- 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 -#include - -#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 03979d0ce..000000000 --- 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 e925b4a54..000000000 --- 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 deleted file mode 100644 index ae887a463..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-128-80-denev20.gen and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-128-80-denev20.pchk b/lib/ldpc/jtmode_codes/peg-128-80-denev20.pchk deleted file mode 100644 index dac8ee61c..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-128-80-denev20.pchk and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-128-80-denev7.gen b/lib/ldpc/jtmode_codes/peg-128-80-denev7.gen deleted file mode 100644 index 9c73857d2..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-128-80-denev7.gen and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-128-80-denev7.pchk b/lib/ldpc/jtmode_codes/peg-128-80-denev7.pchk deleted file mode 100644 index 0985c5a8a..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-128-80-denev7.pchk and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-128-80-reg3.gen b/lib/ldpc/jtmode_codes/peg-128-80-reg3.gen deleted file mode 100644 index 30414fdb5..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-128-80-reg3.gen and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-128-80-reg3.pchk b/lib/ldpc/jtmode_codes/peg-128-80-reg3.pchk deleted file mode 100644 index e257b2cfe..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-128-80-reg3.pchk and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-128-80-reg4.gen b/lib/ldpc/jtmode_codes/peg-128-80-reg4.gen deleted file mode 100644 index 092a667e7..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-128-80-reg4.gen and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-128-80-reg4.pchk b/lib/ldpc/jtmode_codes/peg-128-80-reg4.pchk deleted file mode 100644 index 9d8649c8b..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-128-80-reg4.pchk and /dev/null differ 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 deleted file mode 100644 index 977aa9113..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-198-72-irreg-8x3-2x4.gen and /dev/null differ 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 deleted file mode 100644 index 5fa60e7a6..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-198-72-irreg-8x3-2x4.pchk and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-198-72-reg3.gen b/lib/ldpc/jtmode_codes/peg-198-72-reg3.gen deleted file mode 100644 index 15241c91a..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-198-72-reg3.gen and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-198-72-reg3.pchk b/lib/ldpc/jtmode_codes/peg-198-72-reg3.pchk deleted file mode 100644 index dd8e45612..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-198-72-reg3.pchk and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-198-72-reg4.gen b/lib/ldpc/jtmode_codes/peg-198-72-reg4.gen deleted file mode 100644 index 66c4bae99..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-198-72-reg4.gen and /dev/null differ diff --git a/lib/ldpc/jtmode_codes/peg-198-72-reg4.pchk b/lib/ldpc/jtmode_codes/peg-198-72-reg4.pchk deleted file mode 100644 index 4de31430e..000000000 Binary files a/lib/ldpc/jtmode_codes/peg-198-72-reg4.pchk and /dev/null differ diff --git a/lib/ldpc/make-gen.c b/lib/ldpc/make-gen.c deleted file mode 100755 index 4c9480470..000000000 --- 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 -#include -#include - -#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; i0) - { 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 -#include -#include -#include - -#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; jdistrib_size(d)) - { abort(); - } - left = part[z]; - } - for (k = 0; k=0; k--) - { u[k] = k%M; - } - - uneven = 0; - t = 0; - z = 0; - left = part[z]; - - for (j = 0; jdistrib_size(d)) - { abort(); - } - left = part[z]; - } - - for (k = 0; k0) - { 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; i1) - { 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; z1 && 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; j0) - { 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; in) - { abort(); - } - - while (usedtrunc[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 7459ca9b8..000000000 --- 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 -#include -#include -#include - -#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 430eec0b4..000000000 --- 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 eac257ff5..000000000 --- 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 -#include -#include - -#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 -#include -#include - -#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; imod2sparse_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 - - Modulo-2 Matrix Sparse/Dense Conversion - - - - -

Modulo-2 Matrix Sparse/Dense Conversion

- -

The routines below convert modulo-2 matrices between the form used by -the routines for dense modulo-2 matrices -and the form used by the routines for sparse -modulo-2 matrices. - -

Header files required: -mod2sparse.h mod2dense.h mod2convert.h - - -


mod2sparse_to_dense: -Convert a modulo-2 matrix from sparse to dense form. - -
-void mod2sparse_to_dense 
-( mod2sparse *m,  /* Sparse matrix to convert */
-  mod2dense *r    /* Place to store result */
-)
-
- -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. - - -


mod2dense_to_sparse: -Convert a modulo-2 matrix from dense to sparse form. - -
-void mod2dense_to_sparse 
-( mod2dense *m,  /* Dense matrix to convert */
-  mod2sparse *r  /* Place to store result */
-)
-
- -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. - - -
- -Back to index for LDPC software - - diff --git a/lib/ldpc/mod2dense-test-out b/lib/ldpc/mod2dense-test-out deleted file mode 100755 index e38525b6c..000000000 --- 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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 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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 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 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 f38ad54f0..000000000 --- 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 -#include -#include - -#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 -#include -#include - -#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; jn_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; jn_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; jn_words; k++) - { r->col[j][k] = m->col[j][k]; - } - for ( ; kn_words; k++) - { r->col[j][k] = 0; - } - } - - for ( ; jn_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(m)) - { fprintf(stderr,"mod2dense_copyrows: Row index out of range\n"); - exit(1); - } - for (j = 0; jmod2dense_rows(r)) - { fprintf(stderr, - "mod2dense_copycols: Destination matrix has fewer rows than source\n"); - exit(1); - } - - for (j = 0; j=mod2dense_cols(m)) - { fprintf(stderr,"mod2dense_copycols: Column index out of range\n"); - exit(1); - } - for (k = 0; kn_words; k++) - { r->col[j][k] = m->col[cols[j]][k]; - } - for ( ; kn_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; in_rows); - if (ferror(f)) return 0; - - intio_write(f,m->n_cols); - if (ferror(f)) return 0; - - for (j = 0; jn_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; jn_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> mod2_wordsize_shift; - v = 1 << (j1 & mod2_wordsize_mask); - - p = m->col[j1]; - k1 = 0; - - for (j2 = 0; j2col[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; jn_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; jn_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; jcol[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> mod2_wordsize_shift; - b0 = i & mod2_wordsize_mask; - - for (j = i; jcol[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; jcol[j][k0],b0)) - { s = m->col[j]; - t = m->col[i]; - for (k = k0; kcol[j]; - t = r->col[i]; - for (k = 0; kn_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> mod2_wordsize_shift; - b0 = rows[i] & mod2_wordsize_mask; - - for (j = i; jcol[cols[j]][k0],b0)) break; - } - - if (jcol[j][k0],b0)) - { s = m->col[j]; - t = m->col[c]; - for (k = 0; kcol[j]; - t = r->col[c]; - for (k = 0; kcol[cols[j]]; - for (k = 0; kn_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> mod2_wordsize_shift; - b0 = i & mod2_wordsize_mask; - - for (j = i; jcol[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; jcol[j][k0],b0)) - { s = m->col[j]; - t = m->col[i]; - for (k = k0; kcol[j]; - t = r->col[i]; - for (k = 0; k /* 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 2b8313873..000000000 --- a/lib/ldpc/mod2dense.html +++ /dev/null @@ -1,487 +0,0 @@ - - - Dense Modulo-2 Matrix Routines - - - - -

Dense Modulo-2 Matrix Routines

- -

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. - -

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 sparse modulo-2 matrix routines. Matrices -can be converted between these two formats using the module-2 matrix conversion routines. - -

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. - - -

Representation of dense matrices

- -

This module represents a matrix by a pointer to a structure of type -mod2dense. 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. - - -

Header files required: -mod2dense.h - - - -


-
Dimension Macros
-
- -
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 mod2dense_allocate: -
-mod2dense_rows(m)   /* Returns the number of rows in m */
-
-mod2dense_cols(m)   /* Returns the number of columns in m */
-
- - - -


-
Allocating and Freeing Dense Modulo-2 Matrices
-
- - -
mod2dense_allocate: -Allocate space for a dense module-2 matrix.
- -
-mod2dense *mod2dense_allocate 
-( int n_rows,    /* Number of rows in matrix */
-  int n_cols     /* Number of columns in matrix */
-)
-
- -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 mod2dense_free once it is no longer in use. - -


mod2dense_free: -Free the space occupied by a dense module-2 matrix. - -
-void mod2dense_free 
-( mod2dense *m   /* Pointer to matrix to free */
-)
-
- -Frees the space occupied by the matrix for re-use. The pointer passed -should no longer be used. - - - -


-
Copying and Clearing Dense Modulo-2 Matrices
-
- -
mod2dense_clear: -Set all elements of a matrix to zero.
- -
-void mod2dense_clear
-( mod2dense *m   /* Pointer to matrix to clear */
-)
-
- -Sets all of the elements of the matrix passed to 0. - -


mod2dense_copy: -Copy the contents of one matrix to another. - -
-void mod2dense_copy
-( mod2dense *m   /* Pointer to matrix to copy from */
-  mod2dense *r   /* Pointer to matrix to receive data */
-)
-
- -Copies the contents of the first matrix passed, m, to the -second matrix passed, r, which must already have been -allocated, and must have at least as many rows and columns as the -first. If r is larger than m, its elements that have -row or column indexes greater than the dimension of m are set -to zeros. - - -


mod2dense_copyrows: -Copy selected rows from one matrix to another. - -
-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 */
-)
-
- -Copies selected rows of the first matrix, m, to the second -matrix, r, which must already have been allocated, and which -must have at least as many columns as m. The indexes of the -rows to copy are given in order as an array of length the same as -the number of rows in r; duplicates are allowed. Row -indexes start at 0. These rows are copied to r, with the -row indexed by the first entry in rows going to the first -row of r, and so forth. If r has more columns than -m, the extra entries in each row are set to zeros. - - -


mod2dense_copycols: -Copy selected columns from one matrix to another. - -
-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 */
-)
-
- -Copies selected columns of the first matrix, m, to the second -matrix, r, which must already have been allocated, and which -must have at least as many rows as m. The indexes of the -columns to copy are given in order as an array of length the same as -the number of columns in r; duplicates are allowed. Column -indexes start at 0. These columns are copied to r, with the -column indexed by the first entry in cols going to the first -column of r, and so forth. If r has more rows than -m, the extra entries in each column are set to zeros. - - - -


-
Input and Output of Dense Modulo-2 Matrices
-
- -
mod2dense_print: -Print a dense modulo-2 matrix in human-readable form.
- -
-void mod2dense_print
-( FILE *f,       /* File to print to */
-  mod2dense *m   /* Pointer to matrix to print */
-)
-
- -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. - -


mod2dense_write: -Write a dense modulo-2 matrix to a file in machine-readable format. - -
-int mod2dense_write
-( FILE *f,       /* File to write data to */
-  mod2dense *m   /* Pointer to matrix write out */
-)
-
- -Writes a machine-readable representation the dense matrix m to -the file f. 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. - -

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 mod2dense_read even on a machine with a -different byte-ordering. - -

The value returned by mod2dense_write is one if the -operation was successful, zero if an error of some sort occurred. - -


mod2dense_read: -Read a dense modulo-2 matrix from a file. - -
-mod2dense *mod2dense_read
-( FILE *f,       /* File to read data from */
-)
-
- -Reads a dense modulo-2 matrix from the file f. 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 -mod2dense_read is called should have been written by mod2dense_write. Other binary data may -precede or follow this data. - -

The value returned is a pointer to the matrix read, for which space -will have been allocated by mod2dense_read, or zero if an -error occurred (either an error reading the file, or data not in the -right format). - - - -


-
Elementary Operations on Dense Modulo-2 Matrices
-
- -
mod2dense_get: -Get an element of a dense modulo-2 matrix.
- -
-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) */
-)
-
- -Returns the value (0 or 1) of the element in the given row and column -of the matrix m. - -


mod2dense_set: -Set an element of a dense modulo-2 matrix. - -
-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) */
-)
-
- -Set the element in the given row and column of the matrix m to -the specified value. - -


mod2dense_flip: -Flip an element of a dense modulo-2 matrix. - -
-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) */
-)
-
- -Flips the value of the element in the given row and column of the -matrix m, changing it to 0 if it was 1, and to 1 if it was 0. -Returns the new value of this element. - - - -


-
Dense Modulo-2 Matrix Arithmetic and Comparison
-
- -
mod2dense_transpose: -Compute the transpose of a dense modulo-2 matrix.
- -
-void mod2dense_transpose
-( mod2dense *m,   /* Matrix to compute transpose of */
-  mod2dense *r    /* Result of transpose operation */
-)
-
- -Stores the transpose of its first argument, m, in the matrix -pointed to by its second argument, r, which must already have -been allocated, and which must have as many rows as m has -columns, and as many columns as m has rows. The two matrices -m and r must not be the same (ie, the two pointers -passed must be different). - -


mod2dense_add: -Add two dense modulo-2 matrices. - -
-void mod2dense_add
-( mod2dense *m1,  /* Left operand of add */
-  mod2dense *m2,  /* Right operand of add */
-  mod2dense *r    /* Place to store result of add */
-)
-
- -Adds matrices m1 and m2, storing the result in the -matrix pointed to by r. All three matrices must have the same -numbers of rows and columns. It is permissible for r to be the -same as m1 and/or m2. Neither of the first two matrices is -changed by this procedure (unless they are the same as r). - - -


mod2dense_multiply: -Multiply two dense modulo-2 matrices. - -
-void mod2dense_multiply 
-( mod2dense *m1,  /* Left operand of multiply */
-  mod2dense *m2,  /* Right operand of multiply */
-  mod2dense *r    /* Place to store result of multiply */
-)
-
- -Does a matrix multiplication of m1 by m2, and stores the -result in the matrix pointed to by r. The matrices must have -compatible numbers of rows and columns. Neither of the first two -matrices is changed by this procedure. The result matrix, r, -must not be the same as either m1 or m2. - -

The algorithm used runs faster if m2 contains mostly 0s, but -it is also appropriate for matrices with many 1s. - -


mod2dense_equal: -Check whether two dense modulo-2 matrices are equal. - -
-int mod2dense_equal
-( mod2dense *m1, /* Pointers to the two matrices */
-  mod2dense *m2  /*   to compare                 */
-)
-
- -Returns one if every element of m1 is equal to the -corresponding element of m2, and otherwise returns zero. The -two matrices must have the same number of rows and the same number of -columns. - - -


-
Dense Modulo-2 Matrix Inversion
-
- -
mod2dense_invert: -Invert a dense modulo-2 matrix.
- -
-int mod2dense_invert
-( mod2dense *m,   /* Matrix to find inverse of (destroyed) */
-  mod2dense *r    /* Place to store the inverse */
-)
-
- -

Inverts the first matrix passed, m, and stores its inverse in -the second matrix, r. The contents of m are destroyed -by this operation, though it remains a valid matrix for storing into -later. The matrix m must have the same number of rows as -columns. The matrix r must already have been allocated, and -must have the same number of rows and columns as m. The -two matrices passed must not be the same. - -

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). - -

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. - -


mod2dense_forcibly_invert: -Forcibly invert a matrix by changing bits if necessary. - -
-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 */
-)
-
- -

Inverts the first matrix passed, m, and stores its inverse -in the second matrix, r, proceeding with the inversion even if -m is singular, by changing some elements as necessary. The -contents of m are destroyed by this operation, though it -remains a valid matrix for storing into later. The matrix m -must have the same number of rows as columns. The matrix r -must already have been allocated, and must have the same number of -rows and columns as m. The two matrices passed must not be the -same. - -

The value returned is the number of elements of m 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.) - -

See mod2dense_invert for the algorithm used. - -


mod2dense_invert_selected: -Invert a matrix with columns selected from a bigger matrix. - -
-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 */
-)
-
- -

Inverts a matrix obtained by selecting certain columns from the -first matrix passed, m, which must have at least as many -columns as rows. The second matrix passed, r, must already -exist, and must have the same number of rows and columns as m. -The result of inverting the sub-matrix of m is stored in the -corresponding columns of r, with the other columns being set to -garbage (or zero, see below). Normally, one would extract just the -relevant columns afterwards using mod2dense_copycols.) The contents of -m are destroyed (though it remains a valid matrix for storing -into later. The two matrices passed must not be the same. - -

The indexes of the columns selected are stored, in order, in the last -argument, cols, followed by the columns not selected (in -arbitrary order). The argument rows 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. - -

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 -r identified by the initial portions of cols and -rows, 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 m. The remaining portion -of cols up to the number of rows in m will contain -indexes of columns of r that are selected arbitrarily; these -columns will, however, be set to contain all zeros. - -

Note that when the first matrix is square, and non-singular, the -result is NOT in general the same as that obtained by calling mod2dense_invert, since that procedure -orders the columns of the inverse so that it applies to the original -ordering of the columns of the first matrix. - -

See mod2dense_invert for the algorithm used. - -


- -Back to index for LDPC software - - diff --git a/lib/ldpc/mod2sparse-test-out b/lib/ldpc/mod2sparse-test-out deleted file mode 100755 index 5d17ddecf..000000000 --- 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 04c26250a..000000000 --- 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 -#include -#include - -#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 f3f9ba9f6..000000000 --- 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 -#include -#include - -#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; kentry[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; irows[i]; - e->left = e->right = e->up = e->down = e; - e->row = e->col = -1; - } - - for (j = 0; jcols[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; irows[i]; - e->left = e->right = e->up = e->down = e; - } - - for (j = 0; jcols[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; irow,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(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(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; in_rows); - if (ferror(f)) return 0; - - intio_write(f,m->n_cols); - if (ferror(f)) return 0; - - for (i = 0; i=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; - } - - 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)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)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(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_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_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=i) - { found = 1; - goto out_first; - } - e = mod2sparse_next_in_col(e); - } - } - - out_first: - break; - } - - case Mod2sparse_mincol: - { - found = 0; - - for (j = i; j=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=i) - { cr2 = rcnt[mod2sparse_row(e2)]; - if (!found || cc2==1 || (cc2-1)*(cr2-1)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]0 && i==abandon_when) - { - for (k = 0; kk || (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; j0) 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; ii) - { fprintf(stderr, - "mod2sparse_forward_sub: Matrix is not lower-triangular\n"); - exit(1); - } - } - - /* Solve system by forward substitution. */ - - for (i = 0; ii) - { 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 23d8d79f2..000000000 --- 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 1681d4a7e..000000000 --- a/lib/ldpc/mod2sparse.html +++ /dev/null @@ -1,719 +0,0 @@ - - - Sparse Modulo-2 Matrix Routines - - - - -

Sparse Modulo-2 Matrix Routines

- -

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. - -

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 dense modulo-2 matrix routines. Matrices -can be converted between these two formats using the module-2 matrix conversion routines. - -

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. - - -

Representation of sparse matrices

- -

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 -mod2entry, 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 pr and lr, which are -of no significance to this module, but which are used by the routines -for decoding LDPC codes by probability -propagation. - -

The mod2sparse type represents a matrix. It records the -number of rows and columns in the matrix, and contains arrays of -pointers to the mod2entry structures for the first non-zero -element in each row and the first non-zero element in each column. - -

Matrices must be created by the mod2sparse_allocate procedure, which -returns a pointer to a mod2sparse structure. When a matrix -is no longer needed, the space it occupies can be freed with mod2sparse_free. Elements within a matrix, -represented by mod2entry 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 mod2sparse_free, or cleared to all zeros, -with mod2sparse_clear, or used as -the result matrix for copying or arithmetic operations. - - -

Header files required: -mod2sparse.h - - - -


-
Dimension Macros
-
- -
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 mod2sparse_allocate: -
-mod2sparse_rows(m)   /* Returns the number of rows in m */
-
-mod2sparse_cols(m)   /* Returns the number of columns in m */
-
- - - -


-
Traversal Macros
-
- -
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 -mod2sparse_at_end macro. If one is already at this special -entry, moving further wraps one around to the first or last entry. - -

The macros for finding the first or last entry in a row or column -take as their arguments a pointer to the matrix (mod2sparse -*) and a row or column index, starting at zero. The other macros -take as their arguments a pointer to an entry (mod2entry *) -within some matrix. - -

-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 */
-
- - - -


-
Allocating and Freeing Sparse Modulo-2 Matrices
-
- - -
mod2sparse_allocate: -Allocate space for a sparse module-2 matrix.
- -
-mod2sparse *mod2sparse_allocate 
-( int n_rows,     /* Number of rows in matrix */
-  int n_cols      /* Number of columns in matrix */
-)
-
- -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. - -

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 mod2sparse_free once it is no -longer in use. - -


mod2sparse_free: -Free the space occupied by a sparse module-2 matrix. - -
-void mod2sparse_free 
-( mod2sparse *m   /* Pointer to matrix to free */
-)
-
- -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 mod2sparse_clear is called, or the matrix -is used as the destination for other operations. - - - -


-
Copying and Clearing Sparse Modulo-2 Matrices
-
- -
mod2sparse_clear: -Set all elements of a matrix to zero.
- -
-void mod2sparse_clear
-( mod2sparse *m   /* Pointer to matrix to clear */
-)
-
- -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 mod2sparse_free. - - -


mod2sparse_copy: -Copy the contents of one matrix to another. - -
-void mod2sparse_copy
-( mod2sparse *m   /* Pointer to matrix to copy from */
-  mod2sparse *r   /* Pointer to matrix to receive data */
-)
-
- -Copies the contents of the first matrix passed, m, to the -second matrix passed, r, which must already have been -allocated, and must have at least as many rows and columns as the -first. If r is larger than m, its elements that have -row or column indexes greater than the dimension of m are set -to zeros. - -

The space occupied by the previous non-zero entries of r is -freed for general use (which may include being reused immediately for -the copies of the entries in m). - - -


mod2sparse_copyrows: -Copy selected rows from one matrix to another. - -
-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 */
-)
-
- -Copies selected rows of the first matrix, m, to the second -matrix, r, which must already have been allocated, and which -must have at least as many columns as m. The indexes of the -rows to copy are given in order as an array of length the same as -the number of rows in r; duplicates are allowed. Row -indexes start at 0. These rows are copied to r, with the -row indexed by the first entry in rows going to the -first row of r, and so forth. If r has more columns than -m, the extra entries in each row are set to zeros. - -

The space occupied by the previous non-zero entries of r is -freed for general use (which may include being reused immediately for -the copies of the entries in m). - - -


mod2sparse_copycols: -Copy selected columns from one matrix to another. - -
-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 */
-)
-
- -Copies selected columns of the first matrix, m, to the second -matrix, r, which must already have been allocated, and which -must have at least as many rows as m. The indexes of the -columns to copy are given in order as an array of length the same as -the number of columns in r; duplicates are allowed. Column -indexes start at 0. These columns are copied to r, with the -column indexed by the first entry in cols going to the -first column of r, and so forth. If r has more rows than -m, the extra entries in each column are set to zeros. - -

The space occupied by the previous non-zero entries of r is -freed for general use (which may include being reused immediately for -the copies of the entries in m). - - - -


-
Input and Output of Sparse Modulo-2 Matrices
-
- -
mod2sparse_print: -Print a sparse modulo-2 matrix in human-readable form.
- -
-void mod2sparse_print
-( FILE *f,        /* File to print to */
-  mod2sparse *m   /* Pointer to matrix to print */
-)
-
- -The matrix is printed on standard output with one line of output per row, -of the form -
-row: col col col ...
-
-where row is the index of the row, and the col 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. - -


mod2sparse_write: -Write a sparse modulo-2 matrix to a file in machine-readable format. - -
-int mod2sparse_write
-( FILE *f,        /* File to write data to */
-  mod2sparse *m   /* Pointer to matrix write out */
-)
-
- -Writes a machine-readable representation the sparse matrix m to -the file f. 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. - -

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 mod2sparse_read even on a machine with a -different byte-ordering. - -

The value returned by mod2sparse_write is one if the -operation was successful, zero if an error of some sort occurred. - -


mod2sparse_read: -Read a sparse modulo-2 matrix from a file. - -
-mod2sparse *mod2sparse_read
-( FILE *f,        /* File to read data from */
-)
-
- -Reads a sparse modulo-2 matrix from the file f. 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 -mod2sparse_read is called should have been written by mod2sparse_write. Other binary data may -precede or follow this data. - -

The value returned is a pointer to the matrix read, for which space -will have been allocated by mod2sparse_read, or zero if an -error occurred (either an error reading the file, or data not in the -right format). - - - -


-
Elementary Operations on Sparse Modulo-2 Matrices
-
- -
mod2sparse_find: -Look for an entry at a given row and column.
- -
-mod2entry *mod2sparse_find
-( mod2sparse *m,  /* Matrix in which to look for entry */
-  int row,        /* Row index (from 0) */
-  int col         /* Column index (from 0) */
-)
-
- -Looks for an entry at the given row and column in the matrix m, -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). - -

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. - -


mod2sparse_insert: -Insert an entry at a given row and column. - -
-mod2entry *mod2sparse_insert
-( mod2sparse *m,  /* Matrix in which to insert an entry */
-  int row,        /* Row index (from 0) */
-  int col         /* Column index (from 0) */
-)
-
- -Adds a new entry (representing an element with value 1) at the given -row and column position in the matrix m. 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. - -

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. - -

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. - -


mod2sparse_delete: -Delete an entry from a sparse modulo-2 matrix. - -
-void mod2sparse_delete
-( mod2sparse *m,  /* Matrix in which to delete an entry */
-  mod2entry *e    /* Entry to delete - MUST be in m */
-)
-
- -Deletes the entry e from the sparse matrix m, 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. - -

The time required for this operation does not depend on how many -entries are currently in the matrix. - -

Warning: It is an error if e is not an entry of -m. This error is not currently diagnosed, but doing this may -cause serious problems, as it may lead later to entries for m -being erroneously freed when the matrix to which e properly -belongs is freed. - - -


-
Sparse Modulo-2 Matrix Arithmetic and Comparison
-
- -
mod2sparse_transpose: -Compute the transpose of a sparse modulo-2 matrix.
- -
-void mod2sparse_transpose
-( mod2sparse *m,  /* Matrix to compute transpose of */
-  mod2sparse *r   /* Result of transpose operation */
-)
-
- -Stores the transpose of its first argument, m, in the matrix -pointed to by its second argument, r, which must already have -been allocated, and which must have as many rows as m has -columns, and as many columns as m has rows. The two matrices -m and r must not be the same (ie, the two pointers -passed must be different). - -

The space occupied by the previous non-zero entries of r is -freed for general use. - -


mod2sparse_add: -Add two sparse modulo-2 matrices. - -
-void mod2sparse_add
-( mod2sparse *m1, /* Left operand of add */
-  mod2sparse *m2, /* Right operand of add */
-  mod2sparse *r   /* Place to store result of add */
-)
-
- -Adds matrices m1 and m2, storing the result in the -matrix pointed to by r. All three matrices must have the same -numbers of rows and columns. It is permissible for r to be the -same as m1 and/or m2. Neither of the first two matrices is -changed by this procedure (unless they are the same as r). - -

The space occupied by the previous non-zero entries of r is -freed for general use. - - -


mod2sparse_multiply: -Multiply two sparse modulo-2 matrices. - -
-void mod2sparse_multiply 
-( mod2sparse *m1, /* Left operand of multiply */
-  mod2sparse *m2, /* Right operand of multiply */
-  mod2sparse *r   /* Place to store result of multiply */
-)
-
- -Does a matrix multiplication of m1 by m2, and stores the -result in the matrix pointed to by r. The matrices must have -compatible numbers of rows and columns. Neither of the first two -matrices is changed by this procedure. The result matrix, r, -must not be the same as either m1 or m2. - -

The space occupied by the previous non-zero entries of r is -freed for general use. - -


mod2sparse_mulvec: -Multiply a vector by a sparse modulo-2 matrix. - -
-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 */
-)
-
- -Multiplies the vector u on the left by the sparse modulo-2 -matrix m, storing the result in v. Both u and -v are modulo-2 vectors, but are stored unpacked, with one bit -per char. Any non-zero value in u is equivalent to '1'. -The vectors u and v must not overlap. - -


mod2sparse_equal: -Check whether two sparse modulo-2 matrices are equal. - -
-int mod2sparse_equal
-( mod2sparse *m1, /* Pointers to the two matrices */
-  mod2sparse *m2  /*   to compare                 */
-)
-
- -Returns one if every element of m1 is equal to the -corresponding element of m2, and otherwise returns zero. The -two matrices must have the same number of rows and the same number of -columns. - - - -


-
Row/Column Operations on Sparse Modulo-2 Matrices -
- -
mod2sparse_count_row: -Count the number of 1s in a row of a sparse matrix.
- -
-int mod2sparse_count_row
-( mod2sparse *m,  /* Pointer to matrix */
-  int row         /* Index of row to count (from 0) */
-)
-
- -Returns the number of 1s in the given row of the matrix, by counting -the number of entries in that row. - -


mod2sparse_count_col: -Count the number of 1s in a column of a sparse matrix. - -
-int mod2sparse_count_col
-( mod2sparse *m,  /* Pointer to matrix */
-  int col         /* Index of column to count (from 0) */
-)
-
- -Returns the number of 1s in the given column of the matrix, by counting -the number of entries in that column. - -


mod2sparse_add_row: -Add a row to a row of a sparse matrix. - -
-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 */
-)
-
- -Modifies the row with index row1 in the matrix m1 by -adding to that row the row with index row2 in the matrix -m2. The matrix m1 must have at least as many columns as -m2. This operation is performed by inserting entries into the -row of m1 at positions where they exist in the row of m2 -but not in the row of m1, and deleting entries in the row of -m1 that exist in the same position in the row of m2. -The matrix m2 is not modified. - -


mod2sparse_add_col: -Add a column to a column of a sparse matrix. - -
-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 */
-)
-
- -Modifies the column with index col1 in the matrix m1 by -adding to that column the column with index col2 in the matrix -m2. The matrix m1 must have at least as many rows as -m2. This operation is performed by inserting entries into the -column of m1 at positions where they exist in the column of -m2 but not in the column of m1, and deleting entries in -the column of m1 that exist in the same position in the column -of m2. The matrix m2 is not modified. - - - -


-
LU Decomposition of Sparse Modulo-2 Matrices
-
- -
mod2sparse_decomp: -Find an LU decomposition of a sparse modulo-2 (sub-)matrix.
- -
-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 */
-)
-
- -

Takes as input a matrix, A, having M rows and -N columns, and an integer K. Finds an LU decomposition -of a K by K sub-matrix of A. The decomposition -is stored in the matrix L, with M rows and K -columns, and the matrix U, with K rows and N -columns. The product of L and U will be equal to the -K by K submatrix of A obtained by taking only -rows and columns that are given in the first K elements of the -rows and cols arrays, which are set by this procedure, -with this sub-matrix distributed over the original M rows and -N columns. Furthermore, the ordering of the row and column -indexes in these arrays will be set so that if the rows of L -and the columns of U were rearranged in this order, L -would be lower triangular, with zeros in rows past row K, and -U would be upper triangular, with zeros in columns past column -K. The rows array is M long, and the cols -array is N long. The elements in both arrays after the first -K contain the indexes of the rows and columns not selected to -be part of the sub-matrix of A, in arbitrary order. - -

The rows and columns of A are selected in order to try to -make the LU decomposition as sparse as possible, using the strategy -identified by the strategy, abandon_number, and -abandon_when parameters. The possible strategies are -Mod2sparse_first, Mod2sparse_mincol, and -Mod2sparse_minprod. If abandon_number is greater than -zero, it is possible that the matrix will appear to have linearly -dependent rows when it actually does not. See the discussion of sparse LU decomposition -methods for details about these strategies. - -

If A is not of rank K or more, L will contain -some number less than K of non-zero columns, and U will -contain an equal number of non-zero rows. The entries in the -rows and cols 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 K by K sub-matrix of full rank was -found). - -

The matrix A is not altered. The previous contents of -L and U are cleared. - -


mod2sparse_forward_sub: -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 */
-)
-
- -

Solves the system of equations Ly=x for y by -forward substitution, based on L being lower triangular after -its rows are reordered according to the given index array. The -vectors x and y are stored unpacked, one bit per -character. If L is M by K, then x should -be M long, but only the K bits indexed by rows -are looked at. The solution vector, y, must be K long. -Only K rows of L are used, as also determined by the -K indexes in the rows argument. If rows is null, -the first K rows of L and the first K elements of -x are used. - -

If the matrix L does not have 1s on its diagonal (after row -rearrangement), there may be no solution, depending on what x -is. If no solution exists, this procedure returns zero, otherwise it -returns one. Any arbitrary bits in the solution are set to zero. - -


mod2sparse_backward_sub: -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 */
-)
-
- -

Solves Uz=y for z by backward substitution, -based on U being upper triangular after its columns are -reordered according to the given index array. The vectors y -and z are stored unpacked, one bit per character. If U -is K by N, then the solution vector, z, should be -N long, but only the K bits indexed by cols are -set. The vector y must be K long. Only K columns -of U are used, as also determined by the K indexes in -the cols argument. The other columns of U must be zero -(this is not checked, but is necessary for the method used to work). -If cols is null, the first K columns of U and the -first K elements of z are used. - -

If the matrix U 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. - -


- -Back to index for LDPC software - - diff --git a/lib/ldpc/modify.html b/lib/ldpc/modify.html deleted file mode 100755 index 209b3ea7e..000000000 --- a/lib/ldpc/modify.html +++ /dev/null @@ -1,125 +0,0 @@ - - - Notes on Modifying the LDPC Programs - - - - -

Notes on Modifying the LDPC Programs

- -

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 module documentation. - -

Adding a new type of channel

- -

Channels are involved in two programs: -transmit and -decode. -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: -

    -
  1. 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 channel_type - declared in channel.h. You - may also need to declare new global variables to store parameters of - the channel in channel.h and - channel.c. -
  2. Modify the channel_parse and - channel_usage procedures in - channel.c to - parse the specification of the new channel and display an appropriate - usage message. -
  3. 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 transmit.c to write the - new channel's output for each transmitted bit, after randomly generating - any noise (see - the documentation on random number generation). -
  4. Modify decode.c 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. -
  5. Document the new channel type in channel.html - and decoding.html. -
- -

Adding a new decoding procedure

- -A new decoding method can be implemented as follows: -
    -
  1. Decide on a syntax for specifying the method and its parameters, - using the trailing arguments to the - decode program. Pick an - internal name for the method, and add it as a possibility in the - enumerated decoding_method type in - dec.h. You may also need to declare - new variables for the method's parameters in - dec.h and dec.c. -
  2. Modify the argument parsing code in - decode.c - to handle specifications of the new method, and change the usage - procedure to display the syntax for specifying the new method. -
  3. Write a setup procedure for your decoding method, putting it in - dec.c, with a declaration in - dec.h. At a minimum, this procedure - should print headers for the table of detailed decoding information - when the -T option was specified. -
  4. Write a decode procedure implementing your method, putting it in - dec.c, with a declaration in - dec.h. This procedure should output - detailed trace information when the -T option was specified. -
  5. Modify decode.c in the appropriate - places to call the setup procedure and the decode procedure you wrote. -
  6. Document the new decoding method in - decoding.html and - decode-detail.html. -
- -

Adding a new method of making a low-density parity-check matrix

- -

The make-ldpc program can be -changed to add a new method for generating a LDPC code by modifying -make-ldpc.c. A radically different -method might better be implemented by writing a new program of similar -structure. - - -

Adding a new encoding method

- -

A new heuristic for finding a sparse LU decomposition can be -implemented by changing make-gen.c to allow -the new heuristic to be specified on the command line, changing the mod2sparse_decomp procedure -in mod2sparse.c to implement the -heuristic, and documenting the new heuristic in encoding.html, sparse-LU.html, and mod2sparse.html. - -

To implement a completely new encoding method, you will first need -to define a new file format for a generator matrix, modify make-gen.c appropriately to write out this new -format, and modify the read_gen procedure in rcode.c to read this format. You will -need to implement the new method in a procedure in enc.c, and modify encode.c so -that it will call this new procedure when the new method is used. The -enum_decode procedure in dec.c will also -need to be modified so it can call the new encoding method. Finally, -you should document the new method in encoding.html - -

- -


- -Back to index for LDPC software - - diff --git a/lib/ldpc/modules.html b/lib/ldpc/modules.html deleted file mode 100755 index 93228ffe3..000000000 --- a/lib/ldpc/modules.html +++ /dev/null @@ -1,89 +0,0 @@ - - - Modules Used in LDPC Programs - - - - -

Modules Used in LDPC Programs

- -You may need to familiarize yourself with the modules documented here -in order to modify the LDPC programs. -These modules may also be useful for other purposes. - -

Click on the title of a module below for general information, or on -specific routines for detailed documentation. - -

Dense modulo-2 matrix routines: -

-Dimension macros:    mod2dense_rows  mod2dense_cols
-
-Allocation:          Copy/Clear:         Input/Output:    Elementary ops:
-
-mod2dense_allocate   mod2dense_clear     mod2dense_print  mod2dense_get
-mod2dense_free       mod2dense_copy      mod2dense_write  mod2dense_set
-                     mod2dense_copyrows  mod2dense_read   mod2dense_flip
-                     mod2dense_copycols
-
-Matrix arithmetic:   Matrix inversion:
-
-mod2dense_transpose  mod2dense_invert
-mod2dense_add        mod2dense_forcibly_invert
-mod2dense_multiply   mod2dense_invert_selected
-mod2dense_equal
-
- -

Sparse modulo-2 matrix routines: -

-Dimension macros:    mod2sparse_rows  mod2sparse_cols
-
-Traversal macros:    mod2sparse_first_in_row  mod2sparse_next_in_row  ...
-
-Allocation:          Copy/Clear:         Input/Output:     Elementary ops:
-
-mod2sparse_allocate  mod2sparse_clear    mod2sparse_print  mod2sparse_find
-mod2sparse_free      mod2sparse_copy     mod2sparse_write  mod2sparse_insert
-                     mod2sparse_copyrows mod2sparse_read   mod2sparse_delete
-                     mod2sparse_copycols
-
-Matrix arithmetic:   Row/Column ops:       LU decomposition:
-
-mod2sparse_transpose mod2sparse_count_row  mod2sparse_decomp
-mod2sparse_add       mod2sparse_count_col  mod2sparse_forward_sub
-mod2sparse_multiply  mod2sparse_add_row    mod2sparse_backward_sub
-mod2sparse_mulvec    mod2sparse_add_col
-mod2sparse_equal
-
-Discussion of sparse LU decomposition methods. -
- -

Modulo-2 matrix sparse/dense conversion: -

-mod2sparse_to_dense
-mod2dense_to_sparse
-
- -

Random variate generation routines: -

-Set/Get state:   Uniform:       Discrete:         Continuous:
-
-rand_seed        rand_uniform   rand_int          rand_gaussian
-rand_get_state   rand_uniopen   rand_pickd        rand_logistic
-rand_use_state                  rand_pickf        rand_cauchy
-                                rand_poisson      rand_gamma
-                                rand_permutation  rand_exp
-                                                  rand_beta
-
- -

Each of the modules above has a test program, called -module-test. These programs are compiled by the command -

-make tests 
-
-See the source files for these test programs for further information. - -
- -Back to index for LDPC software - - diff --git a/lib/ldpc/msksim.f90 b/lib/ldpc/msksim.f90 deleted file mode 100644 index 6ef50de51..000000000 --- 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 8e850681d..000000000 --- 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 -#include -#include - -#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 2cb88b267..000000000 --- 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 9670105ae..000000000 --- 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 -#include -#include -#include - -#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; imxrw) - { mxrw = rw[i]; - } - } - - cw = (int *) chk_alloc (N, sizeof *cw); - mxcw = 0; - - for (j = 0; jmxcw) - { mxcw = cw[j]; - } - } - - fprintf(af,"%d %d\n",mxrw,mxcw); - - for (i = 0; i - - Creating a Parity Check Matrix - - - - -

Creating a Parity Check Matrix

- -

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 parity check matrix, -H, with M rows and N columns. The valid -codewords are the vectors, x, of length N, for which -Hx=0, where all arithmetic is done modulo-2. Each row -of H represents a parity check on a subset of the bits in -x; all these parity checks must be satisfied for x 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 H that are redundant because they are -linear combinations of other rows. - -

This software stores parity check matrices in files in a sparse -format. These parity-check files are not human-readable -(except by using the print-pchk -program). However, they are readable on a machine with a -different architecture than they were written on. - -

Some LDPC software by David MacKay and others uses the -alist -format 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. - - -

Methods for constructing LDPC codes

- -

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. - -

Many methods for constructing LDPC matrices are described in the -references. Two simple methods are currently -implemented by this software, both of which operate according to the -following scheme: -

    -
  1. Create a preliminary parity check matrix by one of the methods. -
  2. 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. -
  3. 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 linear - dependence in parity check matrices.) -
  4. 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. -
- -

The evencol 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. - -

The evenboth 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. - -

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. - - -


make-pchk: Make a parity check -matrix by explicit specification. - -
-make-pchk pchk-file n-checks n-bits row:col ...
-
- -

Creates a file named pchk-file in -which it stores a parity check matrix with n-checks -rows and n-bits columns. This parity check matrix -consists of all 0s except for 1s at the row:col -positions listed. Rows and columns are numbered starting at zero. -This program is intended primarily for testing and demonstration -purposes. - -

Example: The well-known Hamming code with codewords of -length N=7 and with M=3 parity checks can be can be -created as follows: -

    -
  • 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 -
- - -


alist-to-pchk: Convert a parity -check matrix from alist format to the sparse matrix format used by -this software. - -
-alist-to-pchk [ -t ] alist-file pchk-file
-
- -

Converts a parity check matrix in -alist -format stored in the file named alist-file to -the sparse matrix format used by this software, storing it in the -file named pchk-file. - -

If the -t option is given, the transpose of the parity check -matrix in alist-file is stored in the -pchk-file. - -

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 alist-to-pchk, so no error is reported if -the set of indexes in a row or column description are not those -on a single line. - - -


pchk-to-alist: Convert a parity -check matrix to alist format. - -
-pchk-to-alist [ -t ] [ -z ] pchk-file alist-file
-
- -

Converts a parity check matrix stored in the sparse matrix format -used by this software, in the file named pchk-file, to -the alist -format, storing it in the file named alist-file. - -

If the -t option is given, the transpose of the parity check -matrix is converted to alist format. - -

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, -pchk-to-alist does this, but output of these 0s can be -suppressed by specifying the -z option. (The alist-to-pchk -program will accept alist files produced with or without the -z -option.) - - -


print-pchk: Print a parity check matrix. - -
-print-pchk [ -d ] [ -t ] pchk-file
-
- -

Prints a human-readable representation of the parity check matrix stored -in pchk-file. -The -d 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 -t option is present, what is -printed is the transpose of the parity check matrix. - -

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. - -

The dense display is the obvious array of 0s and 1s. Long lines -are not wrapped. - -

Example: The parity check matrix for the Hamming code created -by the example for make-pchk would print -as follows: -

    -
  • 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 - -
  • 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 -
- - -


make-ldpc: Make a low density parity -check matrix, by random generation. - -
-make-ldpc pchk-file n-checks n-bits seed method
-
-
-where method is one of the following: -
-evencol checks-per-col [ no4cycle ]
-
-evencol checks-distribution [ no4cycle ]
-
-evenboth checks-per-col [ no4cycle ]
-
-evenboth checks-distribution [ no4cycle ]
-
-
-
- -

Creates a Low Density Parity Check matrix with -n-checks rows and n-bits columns. The -parity check matrix will be generated pseudo-randomly by the indicated -method, using a pseudo-random number stream determined by seed. -The actual random number seed used is 10 times seed plus 1, -so as to avoid using the same stream as any of the other programs. - -

Two methods are currently available for creating the LDPC matrix, -specified by evencol or evenboth. Both methods -produce a matrix in which the number of 1s in each column is -approximately checks-per-col, or varies from column -to column according the the checks-distribution. -The evenboth 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. - -

For both methods, the no4cycle 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. - -

A checks-distribution has the form -

-propxcount/propxcount/...
-
-Here, prop is a proportion of columns that have the -associated count. The proportions need not sum to one, -since they will be automatically normalized. For example, 0.3x4/0.2x5 -specifies that 60% of the columns will contain four 1s and 40% will -contain five 1s. - -

See the discussion above for more details -on how these methods construct LDPC matrices. - -

Example 1: The make-ldpc 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 print-pchk. -

    -
  • make-ldpc ldpc.pchk 20 40 1 evenboth 3 -
  • 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 -
- -

Example 2: The two make-ldpc 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. -

    -
  • make-ldpc ldpc.pchk 20 40 1 evenboth 0.3x2/0.6x3/0.1x7 -
  • make-ldpc ldpc.pchk 20 40 1 evenboth 3x2/6x3/1x7 -
  • 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 -
- -
- -Back to index for LDPC software - - - diff --git a/lib/ldpc/peg/128-64-reg4.deg b/lib/ldpc/peg/128-64-reg4.deg deleted file mode 100644 index 7b72d0676..000000000 --- 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 ad8b54a17..000000000 --- a/lib/ldpc/peg/BigGirth.C +++ /dev/null @@ -1,573 +0,0 @@ -#include -#include -#include -#include -#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()"<M=M; - this->N=N; - this->filename=filename; - - mid=new int[M]; - - localGirth=new int[N]; - - nodesInGraph=new NodesInGraph [N]; - for(i=0;ilocalDepth)?localDepth:localGirth[k]; - if(k>0 && localGirth[k]=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=nodesInGraph[i].maxDegParity){ - tmp[i]=1; - } - } - } - index=0; - for(i=0;iEXPAND_DEPTH){//covering all parity nodes or meet the upper bound on cycles - - cycle=mincycles-1; - for(i=0;i=nodesInGraph[i].maxDegParity){ - tmp[i]=1; - } - } - } - - index=0; - for(i=0;inumCur && index!=M){ - delete [] current; - current=NULL; - numCur=cpNumCur; - current=new int[numCur]; - index=0; - for(i=0;imax_col) - max_col=nodesInGraph[i].numOfConnectionParityBit; - - parityCheck_compressed=new int * [M]; - for(i=0;i0;k--){ - for(i=k-1;i>=0;i--){ - if(H[i][k]==1) - for(j=k;jmax_row) max_row=imed; - } - generator_compressed=new int * [max_row]; - for(i=0;i=max_row-1) break; - index++; - } - } - } - for(j=0;jmax_col) max_col=imed; - } - parityCheck_compressed=new int * [M]; - for(i=0;i=max_col-1) break; - index++; - } - } - } - if(verbose) { - cout<<"****************************************************"< -#include // 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 118a63822..000000000 --- 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 77c98b598..000000000 --- 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;itmpCycles[j]) - cyclesTable[i]=tmpCycles[j]; - } - //OUTPUT cycles per symbol node - //cout<<"i="<cyclesTable[i]) girth=cyclesTable[i]; - return(girth); -} - -void CyclesOfGraph::printCyclesTable(void){ - using namespace std; - int i, temp[20]; - /* - for(i=0;i -#include // C++ I/O library header -//#include - -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 18a77197c..000000000 --- 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 3af8369d3..000000000 --- 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 174d64657..000000000 --- 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 feb53aeec..000000000 --- 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 3072b205e..000000000 --- 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 186001399..000000000 --- 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 -#include -#include -#include -#include -#include -#include -#include -#include "BigGirth.h" -#include "Random.h" -#include "CyclesOfGraph.h" - -const double EPS = 1e-6; - -using namespace std; - -void usage() -{ - cout<<"*******************************************************************************************"< " <= 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!"<N) { - cout<<"Error: M must be smaller than N!"< degSeq(N); - - ifstream infn(degFileName.c_str()); - if (!infn) {cout << "\nCannot open file " << degFileName << endl; exit(-1); } - int m; - infn >>m; - std::vector deg(m); - std::vector degFrac(m); - for(int i=0;i>deg[i]; - for(int i=0;i>degFrac[i]; - infn.close(); - double dtmp=0.0; - for(int i=0;iEPS) { - cout.setf(ios::fixed, ios::floatfield); - cout <<"\n Invalid degree distribution (node perspective): sum != 1.0 but "<=0;--j) { - if(dtmp>degFrac[j]) break; - } - if(dtmp -# 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 3c5d54387..000000000 --- a/lib/ldpc/peg/Random.C +++ /dev/null @@ -1,101 +0,0 @@ - -#include -#include -#include "Random.h" - -void Random::bubbleSort(int a[], int size) -{ - for(int pass=1; passa[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=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=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 -// #include - -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 28d2c8f1d..000000000 --- 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 0fb5a574c..000000000 --- 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 b42df5000..000000000 --- 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 a25da9a35..000000000 --- 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 30c8edf97..000000000 --- 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 5e99ac6a3..000000000 --- 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 6bb420a56..000000000 --- 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 09108dbff..000000000 --- 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 e2d9e15f9..000000000 --- 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 10064e072..000000000 --- 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 2487ea9be..000000000 --- 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 572e6221b..000000000 --- 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 cad344714..000000000 --- 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 78747e924..000000000 --- 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 da710f92f..000000000 --- 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 c3dc1b1b9..000000000 --- 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 c3dc1b1b9..000000000 --- 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 7d208a695..000000000 --- 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 410bae7ee..000000000 --- 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 0082bd378..000000000 --- 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 fb023b777..000000000 --- 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 e2d9e15f9..000000000 --- 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 10064e072..000000000 --- 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 0fb5a574c..000000000 --- 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 53d339e71..000000000 --- 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 -#include -#include -#include - -#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 -#include -#include -#include - -#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 8bb50d35e..000000000 --- a/lib/ldpc/progs.html +++ /dev/null @@ -1,80 +0,0 @@ - - - Programs for Low Density Parity Check Codes - - - - -

Programs for Low Density Parity Check Codes

- -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. - -

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. - -

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.) - -

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. - -

Creating a parity check matrix for a code: -

-make-pchk pchk-file n-checks n-bits row:col ...
-
-alist-to-pchk [ -t ] alist-file pchk-file
-
-pchk-to-alist [ -t ] [ -z ] pchk-file alist-file
-
-print-pchk [ -d ] [ -t ] pchk-file
-
-make-ldpc pchk-file n-checks n-bits seed method
-
- -

Encoding message blocks as codewords: -

-make-gen pchk-file gen-file method
-
-print-gen [ -d ] gen-file 
-
-encode [ -f ] pchk-file gen-file source-file encoded-file
-
- -

Transmitting bits through a simulated channel: -

-transmit encoded-file|n-zeros received-file seed channel
-
- -

Decoding received blocks: -

-decode [ -f ] [ -t | -T ] pchk-file received-file decoded-file [ bp-file ] channel method
-
-extract gen-file decoded-file extracted-file
-
- -

Support programs: -

-rand-src source-file seed n-bits
-
-verify [ -t ] pchk-file decoded-file [ gen-file [ source-file ] ]
-
- -See also the discussions of linear dependence in -parity check matrices and of sparse LU -decomposition methods, and the examples -of program usage. - -
- -Back to index for LDPC software - - diff --git a/lib/ldpc/rand-src.c b/lib/ldpc/rand-src.c deleted file mode 100755 index 31a2410dc..000000000 --- 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 -#include -#include - -#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 -#include -#include -#include - -#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; i0) - { if (x=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 -#include -#include -#include -#include - -#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 . */ - -#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; iseed = seed; - - state->state48[0] = seed>>16; - state->state48[1] = seed&0xffff; - state->state48[2] = rn[0][(seed&0x7fffffff)%Table_size]; - - for (j = 0; jptr[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; jptr[j]]; - } - - for (j = 0; jptr[j]==Table_size-1; j++) - { state->ptr[j] = 0; - } - - if (jptr[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; i0) 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; i0) 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; i10000) - { 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=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 , 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 -#include -#include - -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 bb896d406..000000000 --- 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 5754b86a6..000000000 --- a/lib/ldpc/rand.html +++ /dev/null @@ -1,306 +0,0 @@ - - - Random Variate Generation Routines - - - - -

Random Variate Generation Routines

- -

This module provides facilities for basic pseudo-random number generation, -and for generation of random variates from various common distributions. - -

All the random generation procedures use the same underlying -"stream" of random numbers. This stream is generated using the -nrand48 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. - -

A pseudo-random number stream is determined by an integer -seed, 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 -rand_state, 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. - -

The methods for generating random variates from various distributions -are mostly taken from 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 were -selected to be reasonably fast while also being easy to write. - -

Header file required: rand.h - - - -


-
Setting and saving the state
-
- - -
rand_seed: -Set the state from an integer seed.
- -
-void rand_seed
-( int seed;  /* Seed to set state based on */
-)
-
- -

Sets the random number generator to a state that is determined from -the integer seed. 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.) - -

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 not -recommended, since the results are then not reproducible. - -


rand_get_state: -Get a pointer to the current state. - -
-rand_state *rand_get_state (void)
-
- -Returns a pointer to the current state of the random number generator, -which is a structure of type rand_state. The only use for this -pointer is to use it to save a copy of the current state someplace. - - -


rand_use_state: -Set the state to use from now on. - -
-void rand_use_state 
-( rand_state *state  /* Pointer to a previously saved state */
-)
-
- -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 -rand_get_state. - - - -


-
Generating uniform random variates
-
- - -
rand_uniform: -Generate uniformly from [0,1).
- -
-double rand_uniform (void)
-
- -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. - -


rand_uniopen: -Generate uniformly from (0,1). - -
-double rand_uniopen (void)
-
- -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. - - - -


-
Generating discrete random variates
-
- - -
rand_int: -Pick an integer uniformly from 0 to n-1.
- -
-int rand_int 
-( int n  /* Number of integers (from 0) to pick from */
-)
-
- -

Randomly picks an integer from the set { 0, 1, ..., n-1 }, -with each integer being equally probable. The probabilities may -become somewhat unequal, however, if n is very large, -approaching 231. - - -


rand_pickd: Pick an integer from 0 -to n-1 with given probabilities (as doubles). - -
-int rand_pickd
-( double *p,  /* Array of probabilities, of length n */
-  int n       /* Number of integers (from 0) to pick from */
-)
-
- -

Randomly picks an integer from the set { 0, 1, ..., n-1 }, -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. - -

If one of the probabilities is exactly zero, it is guaranteed that -the corresponding integer will not be picked. - - -


rand_pickf: Pick an integer from 0 -to n-1 with given probabilities (as floats). - -
-int rand_pickf
-( float *p,  /* Array of probabilities, of length n */
-  int n      /* Number of integers (from 0) to pick from */
-)
-
- -

This procedure is the same as rand_pickd -except that the array giving the probabilities is an array of single-precision -floating point numbers, rather than double-precision. - - -


rand_poisson: -Generate a non-negative integer from a Poisson distribution. - -
-int rand_poisson
-( double lambda  /* Mean of the Poisson distribution */
-)
-
- -

Generates a non-negative integer from the Poisson distribution with mean -lambda. - - -


rand_permutation: Generate a random -permutation of integers from 1 to n. - -
-int rand_permutation
-( int *perm,  /* Place to store the permutation */
-  int n       /* Number of integers to permute */
-)
-
- -

Stores a random permutation of the integers from 1 to n in the -array perm, which must be at least n long. All permutations are -equally likely. - - - -


-
Generating continuous random variates
-
- - -
rand_gaussian: -Generate a standard Gaussian (normal) random variate.
- -
-double rand_gaussian (void)
-
- -

Generates a random value drawn from the Gaussian (normal) distribution -with mean zero and standard deviation one, whose density function is -proportional to exp(-x2/2), with x -being any real value. - - -


rand_logistic: -Generate a logistic random variate. - -
-double rand_logistic (void)
-
- -

Generates a random value drawn from the logistic distribution with -location parameter zero and width parameter one, whose density -function is proportional to -exp(-x) / [1 + exp(-x)]2, -with x being any real value. - - -


rand_cauchy: -Generate a Cauchy random variate. - -
-double rand_cauchy (void)
-
- -

Generates a random value drawn from the Cauchy distribution with centre -at zero and width one, whose density function is proportional to -1 / (1+x2), with x being any real value. - - -


rand_gamma: -Generate a gamma-distributed random variate. - -
-double rand_gamma
-( double A   /* Shape parameter */
-)
-
- -

Generates a random value drawn from the gamma distribution with -positive shape parameter A, whose density function is proportional -to xA-1 exp(-x), with x -being any positive real. This procedure will never return a value that is -exactly zero. - - -


rand_exp: -Generate an exponentially-distributed random variate. - -
-double rand_exponential (void)
-
- -

Generates a random value drawn from the exponential distribution with -mean one, whose density function is exp(-x), with x being -any positive real. This procedure will never return a value that is -exactly zero. - -

Note: This is a common special case of the gamma distribution. - - -


rand_beta: -Generate a beta-distributed random variate. - -
-double rand_beta
-( double A,  /* Parameters of distribution */
-  double B
-)
-
- -

Generates a random value drawn from the beta distribution with positive -parameters A and B, whose density function is proportional -to xA-1(1-x)B-1, -with x being any real in the interval (0,1). This procedure -will never return a value that is exactly zero or exactly one. - - -


- -Back to index for LDPC software - - diff --git a/lib/ldpc/randfile b/lib/ldpc/randfile deleted file mode 100755 index 3d33d61e2..000000000 Binary files a/lib/ldpc/randfile and /dev/null differ diff --git a/lib/ldpc/rcode.c b/lib/ldpc/rcode.c deleted file mode 100755 index 84d6fd923..000000000 --- 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 -#include -#include - -#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 - - References on Low Density Parity Check Codes - - - - -

References on Low Density Parity Check Codes

- -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: -
-

Gallager, R. G. (1963) Low Density Parity Check Codes, - Cambridge, MA: MIT Press. -

Gallager, R. G. (1962) ``Low-density parity-check codes'', IRE - Transactions on Information Theory, vol. IT-8, pp. 21-28. -

- -More recent work on these codes by David MacKay and myself was published -as follows: -
-

MacKay, D. J. C. and Neal, R. M. (1996) ``Near Shannon limit performance - of low density parity check codes'', Electronics Letters, - vol. 32, pp. 1645-1646. Reprinted with printing errors corrected - in vol. 33, pp. 457-458. -

MacKay, D. J. C. (1999) ``Good error-correcting codes based on very - sparse matrices'', IEEE Transactions on Information Theory, - vol. 45, pp. 399-431. -

- -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: -
-

Kschischang, F. R., Frey, B. J., and Loeliger, H.-A. (1998) ``Factor graphs -and the sum-product algorithm'', IEEE Transactions on Information -Theory, vol. 47, pp. 498-519. -

- -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 here. Note: 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 M=3200 with -3 checks per bit is actually around 12.7, not the value around 17 shown -on one of the slides. - -

Text and references to many more recent and classical papers can be -obtained via the IMA workshop's -web page. - -


- -Back to index for LDPC software - - diff --git a/lib/ldpc/release.html b/lib/ldpc/release.html deleted file mode 100755 index 558e7cda8..000000000 --- a/lib/ldpc/release.html +++ /dev/null @@ -1,244 +0,0 @@ - - -Release Notes for LDPC-codes Software - - - - -

Release Notes for LDPC-codes Software

- -These notes describe all the stable public releases of this software. Old -and future releases can be obtained via -
- -http://www.cs.toronto.edu/~radford/ldpc.software.html -
-The current development version is now maintained at -
- -http://github.com/radfordneal/LDPC-code -
- -

Version of 2012-02-11.

-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. -
    -
  1. 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.) -
  2. 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.) -
  3. 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. -
  4. 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. -
  5. Documented the previously undocumented -t options for pchk-to-alist - and alist-to-pchk. -
  6. 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). -
  7. 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). -
  8. Fixed bug in distrib.c affecting distributions with a single - number (thanks to Mike Vicuna for pointing it out). -
  9. Fixed bug in -t option for pchk-to-alist (thanks to Andrea Fontana - for reporting this). -
  10. Fixed references in the documentation to mod2sparse_multvec - that should be to mod2sparse_mulvec (thanks to Andrea Fontana - for reporting this). -
- - -

Version of 2006-02-08.

- -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 here. 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 alist -format for parity check matrices, used by David MacKay and others, -have also been added. - -

The following new features have been added: -

    -
  1. The make-ldpc program can - new create LDPC codes with varying numbers of checks per bit. The - examples now include a code of this sort. -
  2. New programs pchk-to-alist - and alist-to-pchk have - been added, which convert to and from alist - format. -
  3. A run-examples script has been - added, which runs all the examples and - compares with the saved output that I obtained. -
- - -

Version of 2001-11-18.

- -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 cygwin Unix environment that runs -under Microsoft Windows. - -

The following new feature has been added: -

    -
  1. A new -t option has been added to - print-pchk, which - causes it to print the transpose of the parity check matrix. -
- -The following program module change was made: -
    - -
  1. The behaviour of mod2dense_invert_selected - 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. -
- -The following bugs were fixed: -
    -
  1. A bug has been fixed in - make-gen - 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 - ex-dep example has changed slightly as a - result. -
  2. The open mode for reading the file of random numbers has been changed from - "r" to "rb", for compatibility with non-Unix systems. -
  3. mod2sparse_copy has - been fixed so that it copies the lr and pr fields - of entries. -
  4. 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. -
- -A few minor fixes to the documentation have also been made. - - -

Version of 2001-05-04.

- -Changes and new features regarding programs and associated -documentation and examples: -
    -
  1. 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 - ex-ham7a, which still - demonstrates this facility. -
  2. 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. -
  3. 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. -
  4. All programs now allow a file name argument to be "-", which specifies - standard input or standard output, as appropriate. The - ex-ldpc36-5000a example has been - changed to use this facility in order to avoid creating lots of files. -
  5. Channels with noise from a logistic distribution (AWLN) have been - implemented. For details, - see the channel documentation. -
  6. The make-gen 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 - discussion of linear dependence in parity check - matrices has changed slightly as a result. -
  7. The messages displayed by the decode - 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 -t option is specified now includes the number of - bits changed in each block. -
  8. A new -T option to decode - for displaying - detailed information on decoding - has been added. -
  9. Doing a make clean will now remove the files created - by running the examples. -
  10. The files created by the examples now - start with "ex-" and contain a ".", to make them easier to - identify for cleanup, and the saved output file now ends in - "-out" rather than ".out". -
  11. The scripts for the examples now use the -v option of set - rather than -x, so that the command lines are echoed - faithfully as they are read. -
  12. Two new examples have been added: - ex-dep demonstrates what happens when parity check matrices - have redundant row, and ex-wrong-model investigates what - happens when the wrong model is used to decode. -
-Changes and new features regarding program modules and other internals: -
    -
  1. Instructions have been added on - how to modify the programs, and some - code has been reorganized to facilitate modifications. -
  2. 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. -
  3. The - mod2dense_invert_selected - 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 make-gen. -
  4. New routines - mod2dense_copyrows and - mod2sparse_copyrows have - been added, analogous to the previous routines for copying columns. -
  5. 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 -T option is used. -
- -The following bugs were fixed: -
    -
  1. A problem with print-gen prevented the -d option from working - in most cases. The documentation was also fixed to note what - the L and U matrices printed will look like. -
  2. The documentation for - mod2sparse_copycols and - mod2dense_copycols - 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. -
  3. In decode.c, a variable declared to be float was printed - using "%f", which strangely didn't work with one compiler. - It's now declared as double. -
- -There were also numerous minor cleanups of program code and documentation. - -

Version of 2000-03-19.

- -This was the first public release. - -
- -Back to index for LDPC software - - diff --git a/lib/ldpc/run-examples b/lib/ldpc/run-examples deleted file mode 100755 index 7d8859e3f..000000000 --- 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 12874aaaf..000000000 --- a/lib/ldpc/sparse-LU.html +++ /dev/null @@ -1,90 +0,0 @@ - - - Sparse LU Decomposition Methods - - - - -

Sparse LU Decomposition Methods

- -

The sparse modulo-2 matrix LU decomposition routine mod2sparse_decomp (which -is used by the make-gen -program when it is asked to create a sparse generator matrix) tries to -find an sub-matrix of a matrix (for make-gen, the parity -check matrix), and an ordering of rows and columns for this -sub-matrix, that leads to the lower-triangular matrix L and the -upper-triangular matrix U making up the LU decomposition being -as sparse as possible. Finding an optimal solution is too difficult, -so instead a heuristic strategy is used. - -

The overall algorithm finds L and U a column at a -time, from left to right (as reordered, in the case of U). As -this is done, a copy, B, of the original matrix is modified. -To create column i of L and U, some element with -value 1 in B whose row and column indexes, after reordering, -are both greater than 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 L -and U (upper elements going to U, lower to L). -The row containing this element is then added to some later rows so as -to clear the lower part of this column to zeros. - -

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 Mod2sparse_first, -Mod2sparse_mincol, and Mod2sparse_minprod. These -strategies operate as follows: - -

Mod2sparse_first -

-Select the first element with value 1 that is encountered in a top -to bottom, left to right search. -
- -

Mod2sparse_mincol -

-Select the first element with value 1 that is contained in a column -of B that has the smallest number of 1s of any column. -
- -

Mod2sparse_minprod -

-Select an element with value 1 for which the product of the number of -1s in that row of B minus one times the number of 1s in that -column of B minus one is as small as possible. -
- -

The abandon_number and abandon_when parameters can -modify the basic strategy. If abandon_number is greater than -zero, then after abandon_when columns have been selected, -abandon_number 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. - -

The methods described here are fairly straightforward adaptations -of standard methods for sparse square matrices of reals, as described, for -example, in -

- I. S. Duff, A. M. Erisman, J. K. Reid (1986) Direct Methods for - Sparse Matrices, Oxford: Clarendon Press. -
-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 references). - - -
- -Back to index for LDPC software - - diff --git a/lib/ldpc/sparse-encode.pdf b/lib/ldpc/sparse-encode.pdf deleted file mode 100755 index 30629f31a..000000000 Binary files a/lib/ldpc/sparse-encode.pdf and /dev/null differ diff --git a/lib/ldpc/support.html b/lib/ldpc/support.html deleted file mode 100755 index 921881abd..000000000 --- a/lib/ldpc/support.html +++ /dev/null @@ -1,100 +0,0 @@ - - - Support Programs - - - - -

Support Programs

- -The following programs provide support for testing and performance -assessment. - - -


rand-src: Generate random message bits. - -
-rand-src source-file seed n-bits
-
- -

Creates a file of random messages bits called -source-file, 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 seed. The actual -random number seed used will be seed 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. - -

The n-bits 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 x 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. - -

Example: 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 seed of 17: -

    -
  • rand-src rsrc 17 15x3 -
-The contents of the file rsrc after this command might be something -like the following: -
-111011000110000
-010010110010111
-100000000000111
-
- - -


verify: Verify that decoded blocks are -codewords, and that they match the source. - -
-verify [ -t ] pchk-file decoded-file [ gen-file [ source-file ] ]
-
- -

Checks whether or not the blocks in decoded-file -are codewords, according to the parity check matrix in -pchk-file. If gen-file is specified, -the message bits of the blocks are also checked against the -corresponding blocks of source-file, or against zero -if source-file is not given. (Normally, one would -leave out source-file only if the transmit command was used -with an argument specifying that zeros are to be transmitted, rather -than a file of encoded data.) - -

A summary of the results is displayed on standard error, giving the -total numbers of blocks, the number with parity check errors, and, if -gen-file was specified, the number of blocks with -source errors and the number with errors of both kinds. If -gen-file 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 source file was given). - -

If the -t 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 gen-file 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 -

-data <- read.table(file,header=T)
-
- -

Warning messages are displayed on standard error if the number of -bits in decoded-file is not a multiple of the block -length, or if source-file is too short. Newlines -in these files are ignored, even though they would normally occur -at the ends of blocks. - -


- -Back to index for LDPC software - - diff --git a/lib/ldpc/transmit.c b/lib/ldpc/transmit.c deleted file mode 100755 index 14657d686..000000000 --- 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 -#include -#include -#include - -#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 e52f79d86..000000000 --- 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 -#include -#include -#include - -#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