Changes to be committed:

deleted:    dspl/doc/en/latex/Makefile
modified:   dspl/dox/doxyfile_en
modified:   dspl/dox/doxyfile_ru
modified:   dspl/dox/en/fft.dox
modified:   dspl/dox/en/filter_an.dox
modified:   dspl/dox/en/filter_ap.dox
modified:   dspl/dox/en/filter_fir.dox
modified:   dspl/dox/en/filter_ft.dox
modified:   dspl/dox/en/filter_iir.dox
modified:   dspl/dox/en/fourier_series.dox
modified:   dspl/src/dspl_internal.h
modified:   dspl/src/fft.c
modified:   dspl/src/fft_subkernel.c
modified:   examples/Makefile
modified:   examples/src/array_test.c
modified:   examples/src/bessel_i0.c
modified:   examples/src/butter_ap_test.c
modified:   examples/src/cheby1_ap_test.c
modified:   examples/src/cheby2_ap_test.c
modified:   examples/src/dft_test.c
modified:   examples/src/ellip_ap_test.c
modified:   examples/src/fft_cmplx_test.c
modified:   examples/src/fft_test.c
modified:   examples/src/idft_cmplx_test.c
modified:   examples/src/ifft_cmplx_test.c
pull/6/head
Dsplib 2020-07-08 23:28:59 +03:00
rodzic 46fb728d56
commit adf9e6f06d
25 zmienionych plików z 1130 dodań i 1148 usunięć

Wyświetl plik

@ -1,23 +0,0 @@
LATEX_CMD=pdflatex
all: refman.pdf
pdf: refman.pdf
refman.pdf: clean refman.tex
$(LATEX_CMD) refman
makeindex refman.idx
$(LATEX_CMD) refman
latex_count=8 ; \
while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\
do \
echo "Rerunning latex...." ;\
$(LATEX_CMD) refman ;\
latex_count=`expr $$latex_count - 1` ;\
done
makeindex refman.idx
$(LATEX_CMD) refman
clean:
rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf

Wyświetl plik

@ -1,4 +1,4 @@
# Doxyfile 1.8.15 # Doxyfile 1.8.18
# This file describes the settings to be used by the documentation system # This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project. # doxygen (www.doxygen.org) for a project.
@ -197,6 +197,16 @@ SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO JAVADOC_AUTOBRIEF = NO
# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
# such as
# /***************
# as being the beginning of a Javadoc-style comment "banner". If set to NO, the
# Javadoc-style will behave just like regular comments and it will not be
# interpreted by doxygen.
# The default value is: NO.
JAVADOC_BANNER = NO
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
# line (until the first dot) of a Qt-style comment as the brief description. If # line (until the first dot) of a Qt-style comment as the brief description. If
# set to NO, the Qt-style will behave just like regular Qt-style comments (thus # set to NO, the Qt-style will behave just like regular Qt-style comments (thus
@ -253,12 +263,6 @@ TAB_SIZE = 2
ALIASES = ALIASES =
# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class"
# will allow you to use the command class in the itcl::class meaning.
TCL_SUBST =
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C. For # only. Doxygen will then generate output that is more tailored for C. For
# instance, some of the names that are used will be different. The list of all # instance, some of the names that are used will be different. The list of all
@ -299,14 +303,14 @@ OPTIMIZE_OUTPUT_SLICE = NO
# parses. With this tag you can assign which parser to use for a given # parses. With this tag you can assign which parser to use for a given
# extension. Doxygen has a built-in mapping, but you can override or extend it # extension. Doxygen has a built-in mapping, but you can override or extend it
# using this tag. The format is ext=language, where ext is a file extension, and # using this tag. The format is ext=language, where ext is a file extension, and
# language is one of the parsers supported by doxygen: IDL, Java, Javascript, # language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, # Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL,
# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: # Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser # FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
# tries to guess whether the code is fixed or free formatted code, this is the # tries to guess whether the code is fixed or free formatted code, this is the
# default for Fortran type files), VHDL, tcl. For instance to make doxygen treat # default for Fortran type files). For instance to make doxygen treat .inc files
# .inc files as Fortran files (default is PHP), and .f files as C (default is # as Fortran files (default is PHP), and .f files as C (default is Fortran),
# Fortran), use: inc=Fortran f=C. # use: inc=Fortran f=C.
# #
# Note: For files without extension you can use no_extension as a placeholder. # Note: For files without extension you can use no_extension as a placeholder.
# #
@ -329,7 +333,7 @@ MARKDOWN_SUPPORT = YES
# to that level are automatically included in the table of contents, even if # to that level are automatically included in the table of contents, even if
# they do not have an id attribute. # they do not have an id attribute.
# Note: This feature currently applies only to Markdown headings. # Note: This feature currently applies only to Markdown headings.
# Minimum value: 0, maximum value: 99, default value: 0. # Minimum value: 0, maximum value: 99, default value: 5.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. # This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
TOC_INCLUDE_HEADINGS = 0 TOC_INCLUDE_HEADINGS = 0
@ -465,6 +469,12 @@ EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO EXTRACT_PRIVATE = NO
# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
# methods of a class will be included in the documentation.
# The default value is: NO.
EXTRACT_PRIV_VIRTUAL = NO
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation. # scope will be included in the documentation.
# The default value is: NO. # The default value is: NO.
@ -519,8 +529,8 @@ HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
# (class|struct|union) declarations. If set to NO, these declarations will be # declarations. If set to NO, these declarations will be included in the
# included in the documentation. # documentation.
# The default value is: NO. # The default value is: NO.
HIDE_FRIEND_COMPOUNDS = NO HIDE_FRIEND_COMPOUNDS = NO
@ -543,7 +553,7 @@ INTERNAL_DOCS = NO
# names in lower-case letters. If set to YES, upper-case letters are also # names in lower-case letters. If set to YES, upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ # allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows # in case and if your file system supports case sensitive file names. Windows
# and Mac users are advised to set this option to NO. # (including Cygwin) ands Mac users are advised to set this option to NO.
# The default value is: system dependent. # The default value is: system dependent.
CASE_SENSE_NAMES = NO CASE_SENSE_NAMES = NO
@ -839,8 +849,10 @@ INPUT_ENCODING = UTF-8
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, # *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice. # *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen
# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd,
# *.vhdl, *.ucf, *.qsf and *.ice.
FILE_PATTERNS = *.c \ FILE_PATTERNS = *.c \
*.cc \ *.cc \
@ -1285,9 +1297,9 @@ HTML_TIMESTAMP = YES
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
# documentation will contain a main index with vertical navigation menus that # documentation will contain a main index with vertical navigation menus that
# are dynamically created via Javascript. If disabled, the navigation index will # are dynamically created via JavaScript. If disabled, the navigation index will
# consists of multiple levels of tabs that are statically embedded in every HTML # consists of multiple levels of tabs that are statically embedded in every HTML
# page. Disable this option to support browsers that do not have Javascript, # page. Disable this option to support browsers that do not have JavaScript,
# like the Qt help browser. # like the Qt help browser.
# The default value is: YES. # The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
@ -1300,7 +1312,7 @@ HTML_DYNAMIC_MENUS = YES
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
HTML_DYNAMIC_SECTIONS = NO HTML_DYNAMIC_SECTIONS = YES
# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
# shown in the various tree structured indices initially; the user can expand # shown in the various tree structured indices initially; the user can expand
@ -1438,7 +1450,7 @@ QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace # Project output. For more information please see Qt Help Project / Namespace
# (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
# The default value is: org.doxygen.Project. # The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
@ -1446,7 +1458,7 @@ QHP_NAMESPACE = org.doxygen.Project
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual # Help Project output. For more information please see Qt Help Project / Virtual
# Folders (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- # Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-
# folders). # folders).
# The default value is: doc. # The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
@ -1455,7 +1467,7 @@ QHP_VIRTUAL_FOLDER = doc
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom # filter to add. For more information please see Qt Help Project / Custom
# Filters (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
# filters). # filters).
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
@ -1463,7 +1475,7 @@ QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see Qt Help Project / Custom # custom filter to add. For more information please see Qt Help Project / Custom
# Filters (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
# filters). # filters).
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
@ -1471,7 +1483,7 @@ QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see: # project's filter section matches. Qt Help Project / Filter Attributes (see:
# http://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
QHP_SECT_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS =
@ -1512,7 +1524,7 @@ ECLIPSE_DOC_ID = org.doxygen.Project
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
DISABLE_INDEX = YES DISABLE_INDEX = NO
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information. If the tag # structure should be generated to display hierarchical information. If the tag
@ -1555,6 +1567,17 @@ TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO EXT_LINKS_IN_WINDOW = NO
# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg
# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see
# https://inkscape.org) to generate formulas as SVG images instead of PNGs for
# the HTML output. These images will generally look nicer at scaled resolutions.
# Possible values are: png The default and svg Looks nicer but requires the
# pdf2svg tool.
# The default value is: png.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FORMULA_FORMAT = png
# Use this tag to change the font size of LaTeX formulas included as images in # Use this tag to change the font size of LaTeX formulas included as images in
# the HTML documentation. When you change the font size after a successful # the HTML documentation. When you change the font size after a successful
# doxygen run you need to manually remove any form_*.png images from the HTML # doxygen run you need to manually remove any form_*.png images from the HTML
@ -1575,8 +1598,14 @@ FORMULA_FONTSIZE = 14
FORMULA_TRANSPARENT = YES FORMULA_TRANSPARENT = YES
# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
# to create new LaTeX commands to be used in formulas as building blocks. See
# the section "Including formulas" for details.
FORMULA_MACROFILE =
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# https://www.mathjax.org) which uses client side Javascript for the rendering # https://www.mathjax.org) which uses client side JavaScript for the rendering
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When # installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path # enabled you may also need to install MathJax separately and configure the path
@ -1584,7 +1613,7 @@ FORMULA_TRANSPARENT = YES
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
USE_MATHJAX = NO USE_MATHJAX = YES
# When MathJax is enabled you can set the default output format to be used for # When MathJax is enabled you can set the default output format to be used for
# the MathJax output. See the MathJax site (see: # the MathJax output. See the MathJax site (see:
@ -1604,7 +1633,7 @@ MATHJAX_FORMAT = HTML-CSS
# Content Delivery Network so you can quickly see the result without installing # Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of # MathJax. However, it is strongly recommended to install a local copy of
# MathJax from https://www.mathjax.org before deployment. # MathJax from https://www.mathjax.org before deployment.
# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/. # The default value is: https://cdn.jsdelivr.net/npm/mathjax@2.
# This tag requires that the tag USE_MATHJAX is set to YES. # This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
@ -1646,7 +1675,7 @@ MATHJAX_CODEFILE =
SEARCHENGINE = NO SEARCHENGINE = NO
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be # When the SERVER_BASED_SEARCH tag is enabled the search engine will be
# implemented using a web server instead of a web client using Javascript. There # implemented using a web server instead of a web client using JavaScript. There
# are two flavors of web server based searching depending on the EXTERNAL_SEARCH # are two flavors of web server based searching depending on the EXTERNAL_SEARCH
# setting. When disabled, doxygen will generate a PHP script for searching and # setting. When disabled, doxygen will generate a PHP script for searching and
# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
@ -1750,10 +1779,11 @@ LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex MAKEINDEX_CMD_NAME = makeindex
# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to # The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to
# generate index for LaTeX. # generate index for LaTeX. In case there is no backslash (\) as first character
# it will be automatically added in the LaTeX code.
# Note: This tag is used in the generated output file (.tex). # Note: This tag is used in the generated output file (.tex).
# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. # See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat.
# The default value is: \makeindex. # The default value is: makeindex.
# This tag requires that the tag GENERATE_LATEX is set to YES. # This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_MAKEINDEX_CMD = \makeindex LATEX_MAKEINDEX_CMD = \makeindex
@ -2247,12 +2277,6 @@ EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES EXTERNAL_PAGES = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of 'which perl').
# The default file (with absolute path) is: /usr/bin/perl.
PERL_PATH = /usr/bin/perl
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration options related to the dot tool # Configuration options related to the dot tool
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -2266,15 +2290,6 @@ PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = NO CLASS_DIAGRAMS = NO
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see:
# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
MSCGEN_PATH =
# You can include diagrams made with dia in doxygen documentation. Doxygen will # You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The # then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides. # DIA_PATH tag allows you to specify the directory where the dia binary resides.

Wyświetl plik

@ -1,4 +1,4 @@
# Doxyfile 1.8.15 # Doxyfile 1.8.18
# This file describes the settings to be used by the documentation system # This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project. # doxygen (www.doxygen.org) for a project.
@ -197,6 +197,16 @@ SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO JAVADOC_AUTOBRIEF = NO
# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
# such as
# /***************
# as being the beginning of a Javadoc-style comment "banner". If set to NO, the
# Javadoc-style will behave just like regular comments and it will not be
# interpreted by doxygen.
# The default value is: NO.
JAVADOC_BANNER = NO
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
# line (until the first dot) of a Qt-style comment as the brief description. If # line (until the first dot) of a Qt-style comment as the brief description. If
# set to NO, the Qt-style will behave just like regular Qt-style comments (thus # set to NO, the Qt-style will behave just like regular Qt-style comments (thus
@ -253,12 +263,6 @@ TAB_SIZE = 2
ALIASES = ALIASES =
# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class"
# will allow you to use the command class in the itcl::class meaning.
TCL_SUBST =
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C. For # only. Doxygen will then generate output that is more tailored for C. For
# instance, some of the names that are used will be different. The list of all # instance, some of the names that are used will be different. The list of all
@ -299,14 +303,14 @@ OPTIMIZE_OUTPUT_SLICE = NO
# parses. With this tag you can assign which parser to use for a given # parses. With this tag you can assign which parser to use for a given
# extension. Doxygen has a built-in mapping, but you can override or extend it # extension. Doxygen has a built-in mapping, but you can override or extend it
# using this tag. The format is ext=language, where ext is a file extension, and # using this tag. The format is ext=language, where ext is a file extension, and
# language is one of the parsers supported by doxygen: IDL, Java, Javascript, # language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, # Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL,
# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: # Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser # FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
# tries to guess whether the code is fixed or free formatted code, this is the # tries to guess whether the code is fixed or free formatted code, this is the
# default for Fortran type files), VHDL, tcl. For instance to make doxygen treat # default for Fortran type files). For instance to make doxygen treat .inc files
# .inc files as Fortran files (default is PHP), and .f files as C (default is # as Fortran files (default is PHP), and .f files as C (default is Fortran),
# Fortran), use: inc=Fortran f=C. # use: inc=Fortran f=C.
# #
# Note: For files without extension you can use no_extension as a placeholder. # Note: For files without extension you can use no_extension as a placeholder.
# #
@ -329,7 +333,7 @@ MARKDOWN_SUPPORT = YES
# to that level are automatically included in the table of contents, even if # to that level are automatically included in the table of contents, even if
# they do not have an id attribute. # they do not have an id attribute.
# Note: This feature currently applies only to Markdown headings. # Note: This feature currently applies only to Markdown headings.
# Minimum value: 0, maximum value: 99, default value: 0. # Minimum value: 0, maximum value: 99, default value: 5.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. # This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
TOC_INCLUDE_HEADINGS = 0 TOC_INCLUDE_HEADINGS = 0
@ -465,6 +469,12 @@ EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO EXTRACT_PRIVATE = NO
# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
# methods of a class will be included in the documentation.
# The default value is: NO.
EXTRACT_PRIV_VIRTUAL = NO
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation. # scope will be included in the documentation.
# The default value is: NO. # The default value is: NO.
@ -519,8 +529,8 @@ HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
# (class|struct|union) declarations. If set to NO, these declarations will be # declarations. If set to NO, these declarations will be included in the
# included in the documentation. # documentation.
# The default value is: NO. # The default value is: NO.
HIDE_FRIEND_COMPOUNDS = NO HIDE_FRIEND_COMPOUNDS = NO
@ -543,7 +553,7 @@ INTERNAL_DOCS = NO
# names in lower-case letters. If set to YES, upper-case letters are also # names in lower-case letters. If set to YES, upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ # allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows # in case and if your file system supports case sensitive file names. Windows
# and Mac users are advised to set this option to NO. # (including Cygwin) ands Mac users are advised to set this option to NO.
# The default value is: system dependent. # The default value is: system dependent.
CASE_SENSE_NAMES = NO CASE_SENSE_NAMES = NO
@ -839,8 +849,10 @@ INPUT_ENCODING = UTF-8
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, # *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice. # *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen
# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd,
# *.vhdl, *.ucf, *.qsf and *.ice.
FILE_PATTERNS = *.c \ FILE_PATTERNS = *.c \
*.cc \ *.cc \
@ -1285,9 +1297,9 @@ HTML_TIMESTAMP = YES
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
# documentation will contain a main index with vertical navigation menus that # documentation will contain a main index with vertical navigation menus that
# are dynamically created via Javascript. If disabled, the navigation index will # are dynamically created via JavaScript. If disabled, the navigation index will
# consists of multiple levels of tabs that are statically embedded in every HTML # consists of multiple levels of tabs that are statically embedded in every HTML
# page. Disable this option to support browsers that do not have Javascript, # page. Disable this option to support browsers that do not have JavaScript,
# like the Qt help browser. # like the Qt help browser.
# The default value is: YES. # The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
@ -1438,7 +1450,7 @@ QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace # Project output. For more information please see Qt Help Project / Namespace
# (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
# The default value is: org.doxygen.Project. # The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
@ -1446,7 +1458,7 @@ QHP_NAMESPACE = org.doxygen.Project
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual # Help Project output. For more information please see Qt Help Project / Virtual
# Folders (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- # Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-
# folders). # folders).
# The default value is: doc. # The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
@ -1455,7 +1467,7 @@ QHP_VIRTUAL_FOLDER = doc
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom # filter to add. For more information please see Qt Help Project / Custom
# Filters (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
# filters). # filters).
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
@ -1463,7 +1475,7 @@ QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see Qt Help Project / Custom # custom filter to add. For more information please see Qt Help Project / Custom
# Filters (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
# filters). # filters).
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
@ -1471,7 +1483,7 @@ QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see: # project's filter section matches. Qt Help Project / Filter Attributes (see:
# http://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES. # This tag requires that the tag GENERATE_QHP is set to YES.
QHP_SECT_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS =
@ -1555,6 +1567,17 @@ TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO EXT_LINKS_IN_WINDOW = NO
# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg
# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see
# https://inkscape.org) to generate formulas as SVG images instead of PNGs for
# the HTML output. These images will generally look nicer at scaled resolutions.
# Possible values are: png The default and svg Looks nicer but requires the
# pdf2svg tool.
# The default value is: png.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FORMULA_FORMAT = png
# Use this tag to change the font size of LaTeX formulas included as images in # Use this tag to change the font size of LaTeX formulas included as images in
# the HTML documentation. When you change the font size after a successful # the HTML documentation. When you change the font size after a successful
# doxygen run you need to manually remove any form_*.png images from the HTML # doxygen run you need to manually remove any form_*.png images from the HTML
@ -1575,8 +1598,14 @@ FORMULA_FONTSIZE = 14
FORMULA_TRANSPARENT = YES FORMULA_TRANSPARENT = YES
# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
# to create new LaTeX commands to be used in formulas as building blocks. See
# the section "Including formulas" for details.
FORMULA_MACROFILE =
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# https://www.mathjax.org) which uses client side Javascript for the rendering # https://www.mathjax.org) which uses client side JavaScript for the rendering
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When # installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path # enabled you may also need to install MathJax separately and configure the path
@ -1584,7 +1613,7 @@ FORMULA_TRANSPARENT = YES
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
USE_MATHJAX = NO USE_MATHJAX = YES
# When MathJax is enabled you can set the default output format to be used for # When MathJax is enabled you can set the default output format to be used for
# the MathJax output. See the MathJax site (see: # the MathJax output. See the MathJax site (see:
@ -1604,7 +1633,7 @@ MATHJAX_FORMAT = HTML-CSS
# Content Delivery Network so you can quickly see the result without installing # Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of # MathJax. However, it is strongly recommended to install a local copy of
# MathJax from https://www.mathjax.org before deployment. # MathJax from https://www.mathjax.org before deployment.
# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/. # The default value is: https://cdn.jsdelivr.net/npm/mathjax@2.
# This tag requires that the tag USE_MATHJAX is set to YES. # This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
@ -1646,7 +1675,7 @@ MATHJAX_CODEFILE =
SEARCHENGINE = NO SEARCHENGINE = NO
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be # When the SERVER_BASED_SEARCH tag is enabled the search engine will be
# implemented using a web server instead of a web client using Javascript. There # implemented using a web server instead of a web client using JavaScript. There
# are two flavors of web server based searching depending on the EXTERNAL_SEARCH # are two flavors of web server based searching depending on the EXTERNAL_SEARCH
# setting. When disabled, doxygen will generate a PHP script for searching and # setting. When disabled, doxygen will generate a PHP script for searching and
# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
@ -1750,10 +1779,11 @@ LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex MAKEINDEX_CMD_NAME = makeindex
# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to # The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to
# generate index for LaTeX. # generate index for LaTeX. In case there is no backslash (\) as first character
# it will be automatically added in the LaTeX code.
# Note: This tag is used in the generated output file (.tex). # Note: This tag is used in the generated output file (.tex).
# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. # See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat.
# The default value is: \makeindex. # The default value is: makeindex.
# This tag requires that the tag GENERATE_LATEX is set to YES. # This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_MAKEINDEX_CMD = \makeindex LATEX_MAKEINDEX_CMD = \makeindex
@ -2247,12 +2277,6 @@ EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES EXTERNAL_PAGES = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of 'which perl').
# The default file (with absolute path) is: /usr/bin/perl.
PERL_PATH = /usr/bin/perl
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration options related to the dot tool # Configuration options related to the dot tool
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -2266,15 +2290,6 @@ PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = NO CLASS_DIAGRAMS = NO
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see:
# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
MSCGEN_PATH =
# You can include diagrams made with dia in doxygen documentation. Doxygen will # You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The # then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides. # DIA_PATH tag allows you to specify the directory where the dia binary resides.

Wyświetl plik

@ -8,13 +8,15 @@
\struct fft_t \struct fft_t
\brief Fast Fourier Transform Object Data Structure \brief Fast Fourier Transform Object Data Structure
The structure stores pointers to twiddle factors and arrays of intermediate data of the fast Fourier transform algorithm. The structure stores pointers to twiddle factors and arrays of intermediate
data of the fast Fourier transform algorithm.
The DSPL library uses an FFT algorithm for composite size. The DSPL library uses an FFT algorithm for composite size.
\param n \param n
The size of the FFT vector for which memory is allocated in the structure arrays. \n The size of the FFT vector for which memory is allocated
in the structure arrays. \n
The parameter `n` must be equal to an integer power of two (radix 2). \n \n The parameter `n` must be equal to an integer power of two (radix 2). \n \n
@ -39,8 +41,9 @@ The structure is populated with the \ref fft_create function once
before using the FFT algorithm. \n before using the FFT algorithm. \n
A pointer to an object of this structure may be A pointer to an object of this structure may be
reused when calling FFT functions. \n reused when calling FFT functions. \n
Before exiting the program, dedicated memory for twiddle factors and arrays of intermediate data Before exiting the program, dedicated memory for twiddle factors and arrays of
must be cleared by the \ref fft_free function. For example: intermediate data must be cleared by the \ref fft_free function.
For example:
\code \code
fft_t pfft = {0}; /* Structure fft_t and clear all fields */ fft_t pfft = {0}; /* Structure fft_t and clear all fields */
int n = 64; /* FFT size */ int n = 64; /* FFT size */
@ -59,9 +62,10 @@ fft_free(&pfft);
\endcode \endcode
\note \note
It is important to note that if the object `fft_t` was created for the FFT size equal to` n`, It is important to note that if the object `fft_t` was created for the FFT size
it can only be used for FFT of size `n`. \n \n equal to` n`, it can only be used for FFT of size `n`. \n \n
Its also worth noting that the FFT functions independently control the size, and independently allocate the memory of the FFT object, if necessary. Its also worth noting that the FFT functions independently control the size,
and independently allocate the memory of the FFT object, if necessary.
So if you call any function using the `fft_t` structure with filled So if you call any function using the `fft_t` structure with filled
data for the FFT length `k` for calculating the FFT of length`n`, data for the FFT length `k` for calculating the FFT of length`n`,
then the structure arrays will be automatically recreated for the length `n`. then the structure arrays will be automatically recreated for the length `n`.
@ -81,52 +85,53 @@ then the structure arrays will be automatically recreated for the length `n`.
/*! **************************************************************************** /*! ****************************************************************************
\ingroup DFT_GROUP \ingroup DFT_GROUP
\fn int ifft_cmplx(complex_t* x, int n, fft_t* pfft, complex_t* y) \fn int ifft_cmplx(complex_t* x, int n, fft_t* pfft, complex_t* y)
\brief Обратное быстрое преобразование Фурье \brief Inverse fast Fourier transform
Функция рассчитывает \f$ n \f$-точечное обратное быстрое преобразование Фурье Function calculates \f$ n \f$-point IFFT of complex data
от \f$ x(m) \f$, \f$ m = 0 \ldots n-1 \f$. \n \f$ x(m) \f$, \f$ m = 0 \ldots n-1 \f$. \n
\f[ \f[
Y(k) = \frac{1}{N} \sum_{m = 0}^{n-1} x(m) \exp Y(k) = \frac{1}{N} \sum_{m = 0}^{n-1} x(m) \exp
\left( j \frac{2\pi}{n} m k \right), \left( j \frac{2\pi}{n} m k \right),
\f] \f]
где \f$ k = 0 \ldots n-1 \f$. here \f$ k = 0 \ldots n-1 \f$.
Для расчета используется алгоритм БПФ составной длины.
\param[in] x \param[in] x
Указатель на входной комплексный вектор \f$x(m)\f$, Pointer to the input vector \f$x(m)\f$,
\f$ m = 0 \ldots n-1 \f$. \n \f$ m = 0 \ldots n-1 \f$. \n
Размер вектора `[n x 1]`. \n \n Vector size is `[n x 1]`. \n \n
\param[in] n \param[in] n
Размер ОБПФ \f$n\f$. \n IFFT size \f$n\f$. \n
Размер ОБПФ может быть составным вида IFFT size can be composite:
\f$n = n_0 \times n_1 \times n_2 \times \ldots \times n_p \times m\f$, \f$n = n_0 \times n_1 \times n_2 \times \ldots \times n_p \times m\f$,
где \f$n_i = 2,3,5,7\f$, а \f$m \f$ -- here \f$n_i = 2,3,5,7\f$, а \f$m \f$ --
произвольный простой множитель не превосходящий 46340 simple number less than 46340
(см. описание функции \ref fft_create). \n \n (see \ref fft_create function). \n \n
\param[in] pfft \param[in] pfft
Указатель на структуру `fft_t`. \n Pointer to the `fft_t` object. \n
Указатель не должен быть `NULL`. \n This pointer cannot be `NULL`. \n
Структура \ref fft_t должна быть предварительно однократно Structure \ref fft_t should be previously once
заполнена функцией \ref fft_create, и память должна быть filled with the \ref fft_create function, and the memory should be
очищена перед выходом функцией \ref fft_free. \n \n cleared before exiting by the \ref fft_free function. \n \n
\param[out] y \param[out] y
Указатель на вектор результата ОБПФ \f$Y(k)\f$, Pointer to the IFFT result vector \f$Y(k)\f$,
\f$ k = 0 \ldots n-1 \f$. Размер вектора `[n x 1]`. \n \f$ k = 0 \ldots n-1 \f$. \n
Память должна быть выделена. \n \n Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return \return
`RES_OK` если расчет произведен успешно. \n `RES_OK` if IFFT is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n \n Else \ref ERROR_CODE_GROUP "code error".
Пример использования функции `fft`:
IFFT example:
\include ifft_cmplx_test.c \include ifft_cmplx_test.c
Результат работы программы: Result:
\verbatim \verbatim
| x[ 0] = 1.000 0.000 | y[ 0] = -0.517 0.686 | z[ 0] = 1.000 0.000 | | x[ 0] = 1.000 0.000 | y[ 0] = -0.517 0.686 | z[ 0] = 1.000 0.000 |
@ -149,9 +154,7 @@ then the structure arrays will be automatically recreated for the length `n`.
| x[17] = -0.275 -0.961 | y[17] = -0.300 0.588 | z[17] = -0.275 -0.961 | | x[17] = -0.275 -0.961 | y[17] = -0.300 0.588 | z[17] = -0.275 -0.961 |
\endverbatim \endverbatim
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -160,53 +163,53 @@ www.dsplib.org
/*! **************************************************************************** /*! ****************************************************************************
\ingroup DFT_GROUP \ingroup DFT_GROUP
\fn int fft(double* x, int n, fft_t* pfft, complex_t* y) \fn int fft(double* x, int n, fft_t* pfft, complex_t* y)
\brief Быстрое преобразование Фурье вещественного сигнала \brief Fast Fourier transform for the real vector.
Функция рассчитывает \f$ n \f$-точечное быстрое преобразование Фурье Function calculated \f$ n \f$-points FFT for the real vector
вещественного сигнала \f$ x(m) \f$, \f$ m = 0 \ldots n-1 \f$. \n \f$ x(m) \f$, \f$ m = 0 \ldots n-1 \f$. \n
\f[ \f[
Y(k) = \sum_{m = 0}^{n-1} x(m) \exp Y(k) = \sum_{m = 0}^{n-1} x(m) \exp
\left( -j \frac{2\pi}{n} m k \right), \left( -j \frac{2\pi}{n} m k \right),
\f] \f]
где \f$ k = 0 \ldots n-1 \f$. here \f$ k = 0 \ldots n-1 \f$.
Для расчета используется алгоритм БПФ составной длины.
\param[in] x \param[in] x
Указатель на вектор вещественного входного сигнала \f$x(m)\f$, Pointer to the input real vector \f$x(m)\f$,
\f$ m = 0 \ldots n-1 \f$. \n \f$ m = 0 \ldots n-1 \f$. \n
Размер вектора `[n x 1]`. \n \n Vector size is `[n x 1]`. \n \n
\param[in] n \param[in] n
Размер БПФ \f$n\f$. \n FFT size \f$n\f$. \n
Размер БПФ может быть составным вида FFT size can be composite:
\f$n = n_0 \times n_1 \times n_2 \times \ldots \times n_p \times m\f$, \f$n = n_0 \times n_1 \times n_2 \times \ldots \times n_p \times m\f$,
где \f$n_i = 2,3,5,7\f$, а \f$m \f$ -- here \f$n_i = 2,3,5,7\f$, а \f$m \f$ --
произвольный простой множитель не превосходящий 46340 simple number less than 46340
(см. описание функции \ref fft_create). \n \n (see \ref fft_create function). \n \n
\param[in] pfft \param[in] pfft
Указатель на структуру `fft_t`. \n Pointer to the `fft_t` object. \n
Указатель не должен быть `NULL`. \n This pointer cannot be `NULL`. \n
Структура \ref fft_t должна быть предварительно однократно Structure \ref fft_t should be previously once
заполнена функцией \ref fft_create, и память должна быть filled with the \ref fft_create function, and the memory should be
очищена перед выходом функцией \ref fft_free. \n \n cleared before exiting by the \ref fft_free function. \n \n
\param[out] y \param[out] y
Указатель на комплексный вектор результата БПФ \f$Y(k)\f$, Pointer to the FFT result complex vector \f$Y(k)\f$,
\f$ k = 0 \ldots n-1 \f$. \n \f$ k = 0 \ldots n-1 \f$. \n
Размер вектора `[n x 1]`. \n Vector size is `[n x 1]`. \n
Память должна быть выделена. \n \n Memory must be allocated. \n \n
\return \return
`RES_OK` если расчет произведен успешно. \n `RES_OK` if FFT is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n \n Else \ref ERROR_CODE_GROUP "code error".
Пример использования функции `fft`:
Example:
\include fft_test.c \include fft_test.c
Результат работы программы: Result:
\verbatim \verbatim
y[ 0] = 91.000 0.000 y[ 0] = 91.000 0.000
@ -225,9 +228,7 @@ y[12] = -7.000 -14.536
y[13] = -7.000 -30.669 y[13] = -7.000 -30.669
\endverbatim \endverbatim
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -238,54 +239,52 @@ www.dsplib.org
/*! **************************************************************************** /*! ****************************************************************************
\ingroup DFT_GROUP \ingroup DFT_GROUP
\fn int fft_cmplx(complex_t* x, int n, fft_t* pfft, complex_t* y) \fn int fft_cmplx(complex_t* x, int n, fft_t* pfft, complex_t* y)
\brief Быстрое преобразование Фурье комплексного сигнала \brief Fast Fourier transform for the complex vector.
Функция рассчитывает \f$ n \f$-точечное быстрое преобразование Фурье Function calculated \f$ n \f$-points FFT for the complex vector
комплексного сигнала \f$ x(m) \f$, \f$ m = 0 \ldots n-1 \f$. \n \f$ x(m) \f$, \f$ m = 0 \ldots n-1 \f$. \n
\f[ \f[
Y(k) = \sum_{m = 0}^{n-1} x(m) \exp Y(k) = \sum_{m = 0}^{n-1} x(m) \exp
\left( -j \frac{2\pi}{n} m k \right), \left( -j \frac{2\pi}{n} m k \right),
\f] \f]
где \f$ k = 0 \ldots n-1 \f$. here \f$ k = 0 \ldots n-1 \f$.
Для расчета используется алгоритм БПФ составной длины.
\param[in] x \param[in] x
Указатель на вектор комплексного Pointer to the input complex vector \f$x(m)\f$,
входного сигнала \f$x(m)\f$, \f$ m = 0 \ldots n-1 \f$. \n \f$ m = 0 \ldots n-1 \f$. \n
Размер вектора `[n x 1]`. \n \n Vector size is `[n x 1]`. \n \n
\param[in] n \param[in] n
Размер БПФ \f$n\f$. \n FFT size \f$n\f$. \n
Размер БПФ может быть составным вида FFT size can be composite:
\f$n = n_0 \times n_1 \times n_2 \times n_3 \times \ldots \times n_p \times m\f$, \f$n = n_0 \times n_1 \times n_2 \times \ldots \times n_p \times m\f$,
где \f$n_i = 2,3,5,7\f$, а \f$m \f$ -- here \f$n_i = 2,3,5,7\f$, а \f$m \f$ --
произвольный простой множитель не превосходящий 46340 simple number less than 46340
(см. описание функции \ref fft_create). \n \n (see \ref fft_create function). \n \n
\param[in] pfft \param[in] pfft
Указатель на структуру `fft_t`. \n Pointer to the `fft_t` object. \n
Указатель не должен быть `NULL`. \n This pointer cannot be `NULL`. \n
Структура \ref fft_t должна быть предварительно однократно Structure \ref fft_t should be previously once
заполнена функцией \ref fft_create, и память должна быть filled with the \ref fft_create function, and the memory should be
очищена перед выходом функцией \ref fft_free. \n \n cleared before exiting by the \ref fft_free function. \n \n
\param[out] y \param[out] y
Указатель на комплексный вектор Pointer to the FFT result complex vector \f$Y(k)\f$,
результата БПФ \f$Y(k)\f$, \f$ k = 0 \ldots n-1 \f$. \n
\f$ k = 0 \ldots n-1 \f$. Vector size is `[n x 1]`. \n
Размер вектора `[n x 1]`. \n Memory must be allocated. \n \n
Память должна быть выделена. \n \n
\return \return
`RES_OK` если расчет произведен успешно. \n `RES_OK` if FFT is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n \n Else \ref ERROR_CODE_GROUP "code error".
Пример использования функции `fft`:
Example:
\include fft_cmplx_test.c \include fft_cmplx_test.c
Результат работы программы: Result:
\verbatim \verbatim
y[ 0] = -0.517 0.686 y[ 0] = -0.517 0.686
@ -308,9 +307,7 @@ y[16] = -0.161 0.525
y[17] = -0.300 0.588 y[17] = -0.300 0.588
\endverbatim \endverbatim
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -319,74 +316,64 @@ www.dsplib.org
/*! **************************************************************************** /*! ****************************************************************************
\ingroup DFT_GROUP \ingroup DFT_GROUP
\fn int fft_create(fft_t* pfft, int n) \fn int fft_create(fft_t* pfft, int n)
\brief Заполнение структуры `fft_t` для алгоритма БПФ \brief Function creates and fill `fft_t` structure.
Функция производит выделение памяти и рассчет векторов The function allocates memory and calculates twiddle factors
поворотных коэффициентов `n`-точечного БПФ для структуры `fft_t`. of the `n`-point FFT for the structure` fft_t`.
\param[in,out] pfft \param[in,out] pfft
Указатель на структуру `fft_t`. \n Pointer to the `fft_t` object. \n
Указатель не должен быть `NULL`. \n \n Pointer cannot be `NULL`. \n \n
\param[in] n \param[in] n
Размер БПФ \f$n\f$. \n FFT size \f$n\f$. \n
Размер БПФ может быть составным вида FFT size can be composite
\f$n = n_0 \times n_1 \times n_2 \ldots \times n_p \times m\f$, \f$n = n_0 \times n_1 \times n_2 \ldots \times n_p \times m\f$,
где \f$n_i = 2,3,5,7\f$, а \f$m \f$ -- here \f$n_i = 2,3,5,7\f$, and \f$m \f$ --
произвольный простой множитель не превосходящий 46340. \n arbitrary prime factor not exceeding 46340. \n
Таким образом алгоритм БПФ поддерживает произвольные длины, равные целой Thus, the FFT algorithm supports arbitrary integer lengths.
степени чисел 2,3,5,7, а также различные их комбинации. \n degrees of numbers 2,3,5,7, as well as their various combinations. \n
Так например, при \f$ n = 725760 \f$ структура будет успешно заполнена, For example, with \f$ n = 725760 \f$ the structure will be successfully filled,
потому что because
\f$725760 = 2 \cdot 3 \cdot 4 \cdot 5 \cdot 6 \cdot 7 \cdot 9 \cdot 16 \f$, \f$ 725760 = 2 \cdot 3 \cdot 4 \cdot 5 \cdot 6 \cdot 7 \cdot 9 \cdot 16 \f$. \n
т.е. получается как произведение множителей 2,3,5,7. \n If \f$ n = 172804 = 43201 \cdot 4 \f$ then the structure will also be
При \f$ n = 172804 = 43201 \cdot 4 \f$ структура также будет успешно заполнена, successfully filled, because the simple factor in \f$ n \f$ does not
потому что простой множитель входящий в \f$n\f$ не превосходит 46340. \n exceed 46340. \n
Для размера \f$ n = 13 \cdot 17 \cdot 23 \cdot 13 = 66079 \f$ For size \f$ n = 13 \cdot 17 \cdot 23 \cdot 13 = 66079 \f$
функция вернет ошибку, поскольку 66079 больше 46340 и не является результатом the function will return an error since 66079 is greater than 46340 and is
произведения чисел 2,3,5,7. \n \n not the result of the product of numbers 2,3,5,7. \n \n
\return \return
`RES_OK` если структура заполнена успешно. \n `RES_OK` if FFT structure is created and filled successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n \n Else \ref ERROR_CODE_GROUP "code error".
\note \note
Некоторые компиляторы при создании структуры не обнуляют ее содержимое. Some compilers do not nullify its contents when creating a structure.
Поэтому рекомендуется произвести обнуление структуры после ее объявления: Therefore, it is recommended to reset the structure after its declaration:
\code{.cpp} \code{.cpp}
fft_t pfft; /* объявляем объект fft_t */ fft_t pfft = {0}; /* fill and fields of fft_t as zeros*/
int n = 64; /* Размер БПФ */ int n = 64; /* FFT size */
/*
бнуляем все поля и указатели.
Данные шаг рекомендуется ввиду того, что некоторые
компиляторы при создании переменной не инициализируют ее нулем.
*/
memset(&pfft, 0, sizeof(fft_t));
int err; int err;
/* создаем объект для 64-точечного БПФ */ /* Create fft_t object for 64-points FFT */
err = fft_create(&pfft, n); err = fft_create(&pfft, n);
/* ................................... */ /* ................................... */
/* очистить память объекта БПФ */ /* Clear fft_t structure */
fft_free(&pfft); fft_free(&pfft);
\endcode \endcode
Перед выходом из программы выделенную в структуре память Before exiting the program, the memory allocated in the structure
необходимо очистить функцией \ref fft_free . \n \n need to clear by \ref fft_free function. \n \n
\note \note
Магия числа 46340 заключается в том, что \f$\sqrt{2^{31}} = 46340.95\f$. \n The "magic number" 46340 because \f$\sqrt{2^{31}} = 46340.95\f$. \n
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -400,17 +387,15 @@ www.dsplib.org
/*! **************************************************************************** /*! ****************************************************************************
\ingroup DFT_GROUP \ingroup DFT_GROUP
\fn void fft_free(fft_t *pfft) \fn void fft_free(fft_t *pfft)
\brief Очистить структуру `fft_t` алгоритма БПФ \brief Free `fft_t` structure.
Функция производит очищение памяти промежуточных данных The function clears the intermediate data memory
и векторов поворотных коэффициентов структуры `fft_t`. and vectors of FFT twiddle factors of the structure `fft_t`.
\param[in] pfft \param[in] pfft
Указатель на структуру `fft_t`. \n Pointer to the `fft_t` object. \n
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -423,34 +408,28 @@ www.dsplib.org
/*! **************************************************************************** /*! ****************************************************************************
\ingroup DFT_GROUP \ingroup DFT_GROUP
\fn int fft_shift(double* x, int n, double* y) \fn int fft_shift(double* x, int n, double* y)
\brief Перестановка спектральных отсчетов дискретного преобразования Фурье \brief Perform a shift of the vector `x`, for use with the `fft` and `ifft`
functions, in order
Функция производит <a href="http://en.dsplib.org/content/dft_freq/dft_freq.html">
<a href="http://ru.dsplib.org/content/dft_freq/dft_freq.html"> to move the frequency 0 to the center
перестановку спектральных отсчетов ДПФ </a> of the vector `y`.
</a> и переносит нулевую частоту в центр вектора ДПФ. \n
Данная функция обрабатывает вещественные входные и выходные вектора
и может применяться для перестановки
амплитудного или фазового спектра.
\param[in] x \param[in] x
Указатель на исходный вектор ДПФ. \n Pointer to the input vector (FFT or IFFT result). \n
Размер вектора `[n x 1]`. \n \n Vector size is `[n x 1]`. \n \n
\param[in] n \param[in] n
Размер ДПФ \f$n\f$ (размер векторов до и после перестановки). \n \n Input and output vector size. \n \n
\param[out] y \param[out] y
Указатель на вектор результата перестановки. \n Pointer to the output vector with frequency 0 in the center. \n
Размер вектора `[n x 1]`. \n Vector size is `[n x 1]`. \n
Память должна быть выделена. \n \n Memory must be allocated. \n \n
\return \return
`RES_OK` если перестановка произведена успешно. \n `RES_OK` if function is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */

Wyświetl plik

@ -2,65 +2,50 @@
/*! **************************************************************************** /*! ****************************************************************************
\ingroup FILTER_ANALYSIS_GROUP \ingroup FILTER_ANALYSIS_GROUP
\fn int freqs(double* b, double* a, int ord, double* w, int n, complex_t *h) \fn int freqs(double* b, double* a, int ord, double* w, int n, complex_t *h)
\brief Analog filter frequency response \f$ H(j \omega) \f$ calculation
\brief Расчет комплексного коэффициента передачи Function calculates analog filter frequaency response \f$ H(j \omega)\f$
\f$ H(j \omega) \f$ аналогового фильтра. corresponds to transfer function \f$ H(s) \f$:
Функция рассчитывает значения комплексного коэффициента передачи
\f$ H(j \omega)\f$ аналогового фильтра, заданного коэффициентами
передаточной функции \f$ H(s) \f$:
\f[ \f[
H(s) = \frac {\sum_{k = 0}^{N} b_k s^k} H(s) = \frac {\sum_{k = 0}^{N} b_k s^k}
{\sum_{m = 0}^{N} a_m s^m}, {\sum_{m = 0}^{N} a_m s^m},
\f] \f]
где \f$ N \f$ - порядок фильтра (параметр `ord`). here \f$ N \f$ - filter order (equals to `ord`).
Комплексный коэффициент передачи рассчитывается путем
подстановки \f$ s = j \omega \f$.
\param[in] b \param[in] b
Указатель на вектор коэффициентов числителя Pointer to the transfer function \f$ H(s) \f$
передаточной функции \f$ H(s) \f$. \n numerator coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n \n Vector size is `[ord+1 x 1]`. \n \n
\param[in] a \param[in] a
Указатель на вектор коэффициентов знаменателя Pointer to the transfer function \f$ H(s) \f$
передаточной функции \f$ H(s) \f$. \n denominator coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n \n Vector size is `[ord+1 x 1]`. \n \n
\param[in] ord \param[in] ord
Порядок фильтра. Количество коэффициентов числителя и Filter order. \n
знаменателя передаточной функции \f$ H(s) \f$ Transfer function \f$ H(s) \f$ numerator and denominator
равно `ord+1`. \n \n coefficients number equals `ord+1`. \n \n
\param[in] w \param[in] w
Указатель на вектор значений циклической частоты \f$ \omega \f$ (рад/с), Pointer to the angular frequency \f$ \omega \f$ (rad/s),
для которого будет рассчитан комплексный which used for frequency response \f$ H(j \omega) \f$ calculation. \n
коэффициент передачи \f$ H(j \omega) \f$. \n Vector size is `[n x 1]`. \n \n
Размер вектора `[n x 1]`. \n \n
\param[in] n \param[in] n
Размер вектора циклической частоты `w`. \n \n The size of the angular frequency vector `w`. \n \n
\param[out] h \param[out] h
Указатель на вектор комплексного коэффициента передачи \f$ H(j \omega) \f$, Pointer to the frequency response vector \f$ H(j \omega) \f$,
рассчитанного для циклической частоты `w`. \n corresponds to angular frequency `w`. \n
Размер вектора `[n x 1]`. \n Vector size is `[n x 1]`. \n
Память должна быть выделена. \n \n Memory must be allocated. \n \n
\return \return `RES_OK` if frequency response vector is calculated successfully. \n
`RES_OK` Комплексноый коэффициент передачи рассчитан успешно. \n Else \ref ERROR_CODE_GROUP "code error".
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -75,79 +60,74 @@ www.dsplib.org
int flag, double* mag, double* phi, double* tau) int flag, double* mag, double* phi, double* tau)
\brief \brief
Расчет амплитудно-частотной (АЧХ), фазочастотной характеристик (ФЧХ), а также Magnitude, phase response and group delay vectors calculation
группового времени запаздывания (ГВЗ) цифрового или аналогового или фильтра. for digital or analog filter corresponds to \f$H(s)\f$, or \f$H(z)\f$
transfer function.
Функция рассчитывает АЧХ, ФЧХ и ГВЗ аналогового или цифрового фильтра, заданного
передаточной характеристикой \f$H(s)\f$, или \f$H(z)\f$ соответственно
\param[in] b \param[in] b
Указатель на вектор коэффициентов числителя Pointer to the \f$ H(s) \f$ or \f$H(z)\f$ transfer function
передаточной функции \f$ H(s) \f$. \n numerator coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n \n Vector size is `[ord+1 x 1]`. \n \n
\param[in] a \param[in] a
Указатель на вектор коэффициентов знаменателя Pointer to the \f$ H(s) \f$ or \f$H(z)\f$ transfer function
передаточной функции \f$ H(s) \f$. \n denominator coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n \n Vector size is `[ord+1 x 1]`. \n \n
\param[in] ord \param[in] ord
Порядок фильтра. Количество коэффициентов Filter order. \n
числителя и знаменателя передаточной Transfer function \f$ H(s) \f$ or \f$H(z)\f$ numerator
функции \f$ H(s) \f$ равно `ord+1`. \n \n and denominator coefficients number equals `ord+1`. \n \n
\param[in] w \param[in] w
Указатель на вектор значений циклической частоты \f$ \omega \f$ (рад/с), Pointer to the angular frequency \f$ \omega \f$ (rad/s),
для которого будет рассчитаны АЧХ, ФЧХ и ГВЗ аналогового фильтра, which used for analog filter characteristics calculation
если установлен флаг `DSPL_FLAG_ANALOG`. \n (flag sets as `DSPL_FLAG_ANALOG`). \n
В случае если флаг `DSPL_FLAG_ANALOG` не установлен, то вектор частоты `w` For digital filter (flag sets as `DSPL_FLAG_DIGITAL`),
используется как нормированная частота комплексного коэффициента передачи parameter `w` describes normalized frequency of
\f$ H \left(\mathrm{e}^{j\omega} \right) \f$ цифрового фильтра. \n frequency response \f$ H \left(\mathrm{e}^{j\omega} \right) \f$.
В этом случае характеристика цифрового фильтра является Digital filter frequency response is \f$ 2\pi \f$-periodic function,
\f$ 2\pi \f$-периодической, и вектор частоты может содержать and vector `w` advisable to set from 0 to \f$ \pi \f$,
произвольные значения, однако целесообразно задавать or from 0 to \f$ 2\pi \f$, or from \f$ -\pi \f$ to \f$ \pi \f$.
его от 0 до \f$ \pi \f$, а такжет от 0 до \f$ 2\pi \f$, или Vector size is `[n x 1]`. \n \n
от \f$ -\pi \f$ до \f$ \pi \f$. \n
Размер вектора `[n x 1]`. \n \n
\param[in] n \param[in] n
Размер вектора циклической частоты `w`. \n \n Size of frequency vector `w`. \n \n
\param[in] flag \param[in] flag
Комбинация флагов, которые задают расчет параметров: \n Binary flags to set calculation rules: \n
\verbatim \verbatim
DSPL_FLAG_ANALOG Коэффициенты относятся к аналоговому фильтру DSPL_FLAG_ANALOG Coefficients corresponds to analog filter
DSPL_FLAG_LOGMAG АЧХ рассчитывать в логарифмическом масштабе DSPL_FLAG_DIGITAL Coefficients corresponds to digital filter
DSPL_FLAG_UNWRAP раскрывать периодичность ФЧХ DSPL_FLAG_LOGMAG Calculate magnitude in logarithmic scale (in dB)
DSPL_FLAG_UNWRAP Unwrap radian phases by adding multiples of 2*pi
\endverbatim \endverbatim
\param[out] mag \param[out] mag
Указатель на вектор АЧХ. \n Pointer to the filter magnitude vector. \n
Размер вектора `[n x 1]`. \n Vector size is `[n x 1]`. \n
Память должна быть выделена. \n If pointer is `NULL`, then magnitude will not calculted. \n \n
Если указатель `NULL`, то расчет АЧХ не производится. \n \n
\param[out] phi \param[out] phi
Указатель на вектор ФЧХ. \n Pointer to the phase response vector. \n
Размер вектора `[n x 1]`. \n Vector size is `[n x 1]`. \n
Память должна быть выделена. \n If pointer is `NULL`, then phase response will not calculted. \n \n
Если указатель `NULL`, то расчет ФЧХ не производится. \n \n
\param[out] tau \param[out] tau
Указатель на вектор ГВЗ. \n Pointer to the group delay vector. \n
Размер вектора `[n x 1]`. \n Vector size is `[n x 1]`. \n
Память должна быть выделена. \n If pointer is `NULL`, then group delay will not calculted. \n \n
Если указатель `NULL`, то расчет ГВЗ не производится. \n \n
\return \return
`RES_OK` Параметры фильтра рассчитаны успешно. \n \return `RES_OK` if function is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
Пример использования функции `filter_freq_resp`: Example:
\include butter_ap_test.c \include butter_ap_test.c
Результат работы программы: Result:
\verbatim \verbatim
b[ 0] = 1.002 a[ 0] = 1.002 b[ 0] = 1.002 a[ 0] = 1.002
@ -158,22 +138,19 @@ b[ 4] = 0.000 a[ 4] = 1.000
\endverbatim \endverbatim
\n \n
В каталоге `dat` будут созданы три файла: \n In `dat` folder will be created 3 files: \n
\verbatim \verbatim
butter_ap_test_mag.txt АЧХ фильтра butter_ap_test_mag.txt magnitude
butter_ap_test_phi.txt ФЧХ фильтра butter_ap_test_phi.txt phase response
butter_ap_test_tau.txt ГВЗ фильтра butter_ap_test_tau.txt group delay
\endverbatim \endverbatim
Кроме того программа GNUPLOT произведет построение следующих графиков In addition, GNUPLOT will build the following graphs from data stored in files:
по сохраненным в файлах данным:
\image html butter_ap_test.png \image html butter_ap_test.png
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -189,72 +166,56 @@ www.dsplib.org
\ingroup FILTER_ANALYSIS_GROUP \ingroup FILTER_ANALYSIS_GROUP
\fn int freqz(double* b, double* a, int ord, double* w, int n, complex_t *h) \fn int freqz(double* b, double* a, int ord, double* w, int n, complex_t *h)
\brief Расчет комплексного коэффициента передачи \brief Function calculates the digital filter frequency response
\f$ H \left(e^{j \omega} \right)\f$ цифрового фильтра. \f$ H \left(e^{j \omega} \right)\f$ corresponds to transfer function \f$H(z)\f$.
Функция рассчитывает значения комплексного коэффициента передачи
\f$ H \left(e^{j \omega} \right)\f$ цифрового фильтра, заданного
коэффициентами передаточной функции \f$H(z)\f$:
Digital filter transfer function:
\f[ \f[
H(z) = \frac {\sum_{k = 0}^{N} b_k z^{-k}} H(z) = \frac{\sum\limits_{k = 0}^{N} b_k z^{-k}}
{\sum_{m = 0}^{N} a_m z^{-m}}, {\sum\limits_{m = 0}^{N} a_m z^{-m}},
\f] \f]
here \f$N\f$ --- filter order (parameter `ord`). \n
где \f$N\f$ --- порядок фильтра (параметр `ord`). \n Frequency response \f$ H \left(e^{j \omega} \right)\f$ we can get
if substitude \f$z = e^{j \omega} \f$. \n
Комплексный коэффициент передачи рассчитывается путем
подстановки \f$z = e^{j \omega} \f$. \n
\param[in] b \param[in] b
Указатель на вектор коэффициентов числителя Pointer to the \f$ H(z) \f$ transfer function
передаточной функции \f$H(z)\f$. \n numerator coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n \n Vector size is `[ord+1 x 1]`. \n \n
\param[in] a \param[in] a
Указатель на вектор коэффициентов знаменателя Pointer to the \f$H(z)\f$ transfer function
передаточной функции \f$H(z)\f$. \n denominator coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n \n Vector size is `[ord+1 x 1]`. \n \n
\param[in] ord \param[in] ord
Порядок фильтра. Количество коэффициентов числителя и знаменателя Filter order. \n
передаточной функции \f$H(z)\f$ равно `ord+1`. \n \n Transfer function \f$H(z)\f$ numerator
and denominator coefficients number equals `ord+1`. \n \n
\param[in] w \param[in] w
Указатель на вектор значений нормированной циклической частоты \f$\omega\f$, Pointer to the normalized frequency of digital filter
для которого будет рассчитан комплексный коэффициент передачи frequency response \f$ H \left(\mathrm{e}^{j\omega} \right) \f$. \n
\f$ H \left(e^{j \omega} \right)\f$. \n Digital filter frequency response is \f$ 2\pi \f$-periodic function,
Размер вектора `[n x 1]`. \n \n and vector `w` advisable to set from 0 to \f$ \pi \f$,
or from 0 to \f$ 2\pi \f$, or from \f$ -\pi \f$ to \f$ \pi \f$.
Vector size is `[n x 1]`. \n \n
\param[in] n \param[in] n
Размер вектора нормированной циклической частоты `w`. \n \n Size of frequency vector `w`. \n \n
\param[out] h \param[out] h
Указатель на вектор комплексного коэффициента передачи Pointer to the frequency response vector
\f$ H \left(e^{j \omega} \right)\f$, рассчитанного для \f$ H \left(\mathrm{e}^{j\omega} \right) \f$,
циклической частоты `w`. \n corresponds to normalized frequency `w`. \n
Размер вектора `[n x 1]`. \n Vector size is `[n x 1]`. \n
Память должна быть выделена. \n \n Memory must be allocated. \n \n
\return `RES_OK` if frequaency response vector is calculated successfully. \n
Else \ref ERROR_CODE_GROUP "code error".
\return \author Sergey Bakhurin www.dsplib.org
`RES_OK` Комплексный коэффициент передачи расcчитан успешно. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n
\note
Комплексный коэффициент передачи \f$ H \left(e^{j \omega} \right)\f$
цифрового фильтра представляет собой \f$ 2 \pi-\f$периодическую функцию
нормированной циклической частоты \f$\omega\f$.
Поэтому анализ цифровых фильтров целесообразно вести на одном периоде
повторения \f$ H \left(e^{j \omega} \right)\f$, т.е. в интервале
\f$\omega\f$ от 0 до \f$2 \pi\f$, или от \f$-\pi\f$ до \f$ \pi\f$. \n
Кроме того известно, что для фильтра с вещественными коэффициентами
\f$ H \left(e^{j \omega} \right) = H^* \left(e^{-j \omega} \right)\f$,
а значит, анализ цифрового фильтра с вещественными коэффициентами
достаточно вести для нормированной частоты \f$\omega\f$ от 0 до \f$\pi\f$.
\author
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */

Wyświetl plik

@ -8,75 +8,72 @@
\fn int butter_ap(double Rp, int ord, double* b, double* a) \fn int butter_ap(double Rp, int ord, double* b, double* a)
\brief \brief
Расчет передаточной характеристики \f$ H(s) \f$ аналогового Function calculates the transfer function \f$ H(s) \f$ coefficients of
нормированного ФНЧ Баттерворта. analog normalized lowpass Butterworth filter.
Функция рассчитывает коэффициенты передаточной характеристики \f$H(s)\f$ Analog normalized lowpass filter magnitude ripple equals \f$ -R_p \f$ dB
аналогового нормированного ФНЧ Баттерворта порядка `ord` с частотой среза for angular frequency \f$ \omega \f$ from 0 to 1 rad/s.
1 рад/с по уровню \f$ -R_p \f$ дБ.
\param[in] Rp \param[in] Rp
Неравномерность АЧХ в полосе пропускания (дБ). \n Magnitude ripple in passband (dB). \n
Параметр задает уровень искажений в полосе от 0 до 1 рад/с. \n This parameter sets maximum filter distortion from 0 to 1 rad/s frequency. \n
Значение должно быть положительным. \n Parameter must be positive. \n
\n \n
\param[in] ord \param[in] ord
Порядок фильтра. \n Filter order. \n
Количество коэффициентов числителя и знаменателя Filter coefficients number equals `ord+1` for numerator and denominator
передаточной функции \f$H(s)\f$ равно `ord+1`. \n of transfer function \f$ H(s) \f$ \n
\n \n
\param[out] b \param[out] b
Указатель на вектор коэффициентов числителя Pointer to the vector of transfer function \f$H(s)\f$
передаточной функции \f$H(s)\f$. \n numerator coefficient. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\param[out] a \param[out] a
Указатель на вектор коэффициентов знаменателя Pointer to the vector of transfer function \f$H(s)\f$
передаточной функции \f$H(s)\f$. \n denominator coefficient. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\return \return
`RES_OK` --- фильтр рассчитан успешно. \n `RES_OK` if filter coefficients is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\n \n
Пример использования функции `butter_ap`: Example:
\include butter_ap_test.c \include butter_ap_test.c
Результат работы программы: Result:
\verbatim \verbatim
b[ 0] = 1.965 a[ 0] = 1.965 b[ 0] = 1.002 a[ 0] = 1.002
b[ 1] = 0.000 a[ 1] = 3.138 b[ 1] = 0.000 a[ 1] = 2.618
b[ 2] = 0.000 a[ 2] = 2.505 b[ 2] = 0.000 a[ 2] = 3.418
b[ 3] = 0.000 a[ 3] = 1.000 b[ 3] = 0.000 a[ 3] = 2.615
b[ 4] = 0.000 a[ 4] = 1.000
\endverbatim \endverbatim
\n \n
В каталоге `dat` будут созданы три файла: \n In `dat` folder will be created 3 files: \n
\verbatim \verbatim
butter_ap_test_mag.txt АЧХ фильтра butter_ap_test_mag.txt magnitude
butter_ap_test_phi.txt ФЧХ фильтра butter_ap_test_phi.txt phase response
butter_ap_test_tau.txt ГВЗ фильтра butter_ap_test_tau.txt group delay
\endverbatim \endverbatim
Кроме того программа GNUPLOT произведет построение следующих графиков In addition, GNUPLOT will build the following graphs from data stored in files:
по сохраненным в файлах данным:
\image html butter_ap_test.png \image html butter_ap_test.png
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -92,67 +89,58 @@ www.dsplib.org
complex_t* p, int* np) complex_t* p, int* np)
\brief \brief
Расчет массивов нулей и полюсов передаточной функции Function calculates arrays of zeros and poles for analog normlized lowpass
\f$ H(s) \f$ аналогового нормированного ФНЧ Баттерворта. Batterworth filter transfer function \f$ H(s) \f$ order `ord` .
Функция рассчитывает значения нулей и полюсов передаточной функции Analog normalized lowpass filter magnitude ripple equals \f$ -R_p \f$ dB
\f$ H(s)\f$ аналогового нормированного ФНЧ Баттерворта порядка `ord` for angular frequency \f$ \omega \f$ from 0 to 1 rad/s.
с частотой среза 1 рад/с по уровню \f$-R_p\f$ дБ. \n
\param[in] ord \param[in] ord
Порядок фильтра. \n Filter order. \n
Number of zeros and poles of filter can be less or equal `ord`. \n
\n \n
\param[in] rp \param[in] rp
Неравномерность АЧХ в полосе пропускания (дБ). \n Magnitude ripple in passband (dB). \n
Параметр задает уровень искажений в полосе от 0 до 1 рад/с. \n This parameter sets maximum filter distortion from 0 to 1 rad/s frequency. \n
Значение должно быть положительным. \n Parameter must be positive. \n
\n \n
\param[out] z \param[out] z
Указатель на массив комплексных нулей Pointer to the \f$ H(s) \f$ zeros array. \n
передаточной характеристики \f$ H(s)\f$. \n Maximum vector size is `[ord x 1]`. \n
Максимальный размер вектора вектора `[ord x 1]`. \n Memory must be allocated for maximum vector size. \n
Память должна быть выделена. \n
\n \n
\param[out] nz \param[out] nz
Указатель на переменную количества нулей Pointer to the variable which keep number of finite zeros \f$ H(s) \f$. \n
передаточной характеристики \f$ H(s)\f$. \n Number of finite zeros which was calculated and saved in vector `z`. \n
По данному указателю будет записано количество Pointer cannot be `NULL`. \n
нулей фильтра, которые были рассчитаны и
помещены в вектор `z`. \n
Память должна быть выделена. \n
\n \n
\param[out] p \param[out] p
Указатель на массив комплексных полюсов Pointer to the \f$ H(s) \f$ poles array. \n
передаточной характеристики \f$ H(s)\f$. \n Maximum vector size is `[ord x 1]`. \n
Максимальный размер вектора вектора `[ord x 1]`. \n Memory must be allocated for maximum vector size. \n
Память должна быть выделена. \n
\n \n
\param[out] np \param[out] np
Указатель на переменную количества полюсов Pointer to the variable which keep number of
передаточной характеристики \f$ H(s)\f$. \n calculated poles of \f$ H(s) \f$. \n
По данному укащзателю будет записано количество нулей фильтра, которые Pointer cannot be `NULL`. \n
были рассчитны и помещены в вектор `p`. \n
Память должна быть выделена. \n
\n \n
\return \return
`RES_OK` --- массивы нулей и полюсов рассчитаны успешно. \n `RES_OK` if zeros and poles is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\n \n
\note \note
Нормированный ФНЧ Баттерворта не имеет нулей, поэтому массив нулей `z` Normalized Butterworth lowpass filter has no finite zeros.
не будет изменен, а по указателю `nz` будет записан 0. \n So `z` vector will not changed and in pointer `nz` will write 0 value. \n
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -167,51 +155,48 @@ www.dsplib.org
\fn int cheby1_ap(double Rp, int ord, double* b, double* a) \fn int cheby1_ap(double Rp, int ord, double* b, double* a)
\brief \brief
Расчет передаточной характеристики \f$ H(s) \f$ аналогового Function calculates the transfer function \f$ H(s) \f$ coefficients of
нормированного ФНЧ Чебышёва первого рода. analog normalized lowpass Chebyshev type 1 filter.
Функция рассчитывает коэффициенты передаточной характеристики Analog normalized lowpass filter magnitude ripple equals \f$ -R_p \f$ dB
\f$ H(s)\f$ аналогового нормированного ФНЧ Чебышёва первого рода for angular frequency \f$ \omega \f$ from 0 to 1 rad/s.
порядка `ord` с частотой среза 1 рад/с по уровню \f$-R_p\f$ дБ. \n
Особенностью фильтра Чебышёва первого рода являются
равноволновые пульсации АЧХ в полосе пропускания.
\param[in] Rp \param[in] Rp
Неравномерность АЧХ в полосе пропускания (дБ). \n Magnitude ripple in passband (dB). \n
Параметр задает уровень искажений в полосе от 0 до 1 рад/с. \n This parameter sets maximum filter distortion from 0 to 1 rad/s frequency. \n
Значение должно быть положительным. \n Parameter must be positive. \n
\n \n
\param[in] ord \param[in] ord
Порядок фильтра. \n Filter order. \n
Количество коэффициентов числителя и знаменателя Filter coefficients number equals `ord+1` for numerator and denominator
передаточной функции \f$ H(s)\f$ равно `ord+1`. \n of transfer function \f$ H(s) \f$ \n
\n \n
\param[out] b \param[out] b
Указатель на вектор коэффициентов числителя передаточной функции \f$H(s)\f$. \n Pointer to the vector of transfer function \f$H(s)\f$
Размер вектора `[ord+1 x 1]`. \n numerator coefficient. \n
Память должна быть выделена. \n Vector size is `[ord+1 x 1]`. \n
Memory must be allocated. \n
\n \n
\param[out] a \param[out] a
Указатель на вектор коэффициентов знаменателя Pointer to the vector of transfer function \f$H(s)\f$
передаточной функции \f$H(s)\f$. \n denominator coefficient. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\return \return
`RES_OK` --- фильтр рассчитан успешно. \n `RES_OK` if filter coefficients is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\n \n
Пример использования функции `cheby1_ap`: Example:
\include cheby1_ap_test.c \include cheby1_ap_test.c
Результат работы программы: Result:
\verbatim \verbatim
b[ 0] = 0.125 a[ 0] = 0.177 b[ 0] = 0.125 a[ 0] = 0.177
@ -222,23 +207,19 @@ b[ 4] = 0.000 a[ 4] = 1.000
\endverbatim \endverbatim
\n \n
В каталоге `dat` будут созданы три файла: \n In `dat` folder will be created 3 files: \n
\verbatim \verbatim
cheby1_ap_test_mag.txt АЧХ фильтра cheby1_ap_test_mag.txt magnitude
cheby1_ap_test_phi.txt ФЧХ фильтра cheby1_ap_test_phi.txt phase response
cheby1_ap_test_tau.txt ГВЗ фильтра cheby1_ap_test_tau.txt group delay
\endverbatim \endverbatim
\n
Кроме того программа GNUPLOT произведет построение следующих графиков In addition, GNUPLOT will build the following graphs from data stored in files:
по сохраненным в файлах данным:
\image html cheby1_ap_test.png \image html cheby1_ap_test.png
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -253,64 +234,58 @@ www.dsplib.org
\fn int cheby1_ap_zp( int ord, double rp, complex_t *z, int* nz, \fn int cheby1_ap_zp( int ord, double rp, complex_t *z, int* nz,
complex_t* p, int* np) complex_t* p, int* np)
\brief \brief
Расчет массивов нулей и полюсов передаточной функции \f$ H(s) \f$ Function calculates arrays of zeros and poles for analog normlized lowpass
аналогового нормированного ФНЧ Чебышёва первого рода. Chebyshev type 1 filter transfer function \f$ H(s) \f$ order `ord` .
Analog normalized lowpass filter magnitude ripple equals \f$ -R_p \f$ dB
for angular frequency \f$ \omega \f$ from 0 to 1 rad/s.
Функция рассчитывает значения нулей и полюсов передаточной функции
\f$ H(s)\f$ аналогового нормированного ФНЧ Чебышёва первого рода
порядка `ord` с частотой среза 1 рад/с по уровню \f$-R_p\f$ дБ, с
неравномерностью в полосе пропускания \f$ R_p \f$ дБ. \n
\param[in] ord \param[in] ord
Порядок фильтра. \n Filter order. \n
Number of zeros and poles of filter can be less or equal `ord`. \n
\n \n
\param[in] rp \param[in] rp
Неравномерность АЧХ в полосе пропускания (дБ). \n Magnitude ripple in passband (dB). \n
Параметр задает уровень искажений в полосе от 0 до 1 рад/с. \n This parameter sets maximum filter distortion from 0 to 1 rad/s frequency. \n
Значение должно быть положительным. \n Parameter must be positive. \n
\n \n
\param[out] z \param[out] z
Указатель на массив комплексных нулей Pointer to the \f$ H(s) \f$ zeros array. \n
передаточной характеристики \f$ H(s)\f$. \n Maximum vector size is `[ord x 1]`. \n
Максимальный размер вектора вектора `[ord x 1]`. \n Memory must be allocated for maximum vector size. \n
Память должна быть выделена. \n
\n \n
\param[out] nz \param[out] nz
Указатель на переменную количества нулей Pointer to the variable which keep number of finite zeros \f$ H(s) \f$. \n
передаточной функции \f$H(s)\f$. \n Number of finite zeros which was calculated and saved in vector `z`. \n
По данному указателю будет записано количество нулей фильтра, Pointer cannot be `NULL`. \n
которые были рассчитаны и помещены в вектор `z`. \n
Память должна быть выделена. \n
\n \n
\param[out] p \param[out] p
Указатель на массив комплексных полюсов Pointer to the \f$ H(s) \f$ poles array. \n
передаточной характеристики \f$H(s)\f$. \n Maximum vector size is `[ord x 1]`. \n
Максимальный размер вектора вектора `[ord x 1]`. \n Memory must be allocated for maximum vector size. \n
Память должна быть выделена. \n
\n \n
\param[out] np \param[out] np
Указатель на переменную количества полюсов передаточной функции \f$ H(s)\f$. \n Pointer to the variable which keep number of
По данному укащзателю будет записано количество нулей фильтра, которые были calculated poles of \f$ H(s) \f$. \n
рассчитны и помещены в вектор `p`. \n Pointer cannot be `NULL`. \n
Память должна быть выделена. \n
\n \n
\return \return
`RES_OK` --- массивы нулей и полюсов рассчитаны успешно. \n `RES_OK` if zeros and poles is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\n
\note \note
Нормированный ФНЧ Чебышёва первого рода не имеет нулей, поэтому массив Normalized Chebyshev type 1 lowpass filter has no finite zeros.
нулей `z` не будет изменен, а по указателю `nz` будет записан 0. \n So `z` vector will not changed and in pointer `nz` will write 0 value. \n
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -323,47 +298,50 @@ www.dsplib.org
\fn int cheby2_ap(double Rs, int ord, double *b, double *a) \fn int cheby2_ap(double Rs, int ord, double *b, double *a)
\brief \brief
Расчет передаточной характеристики \f$ H(s) \f$ аналогового Function calculates the transfer function \f$ H(s) \f$ coefficients of
нормированного ФНЧ Чебышёва второго рода. analog normalized lowpass Chebyshev type 2 filter.
Функция рассчитывает коэффициенты передаточной характеристики \f$H(s)\f$ Analog normalized Chebyshev type 2 filter lowpass filter has \f$Rs\f$ dB
аналогового нормированного ФНЧ Чебышёва второго рода порядка `ord` suppression in stopband.
с частотой заграждения 1 рад/с по уровню \f$-R_s\f$ дБ. \n Also analog normalized Chebyshev type 2 filter magnitude equals \f$-Rs\f$ dB
for angular frequency \f$\omega = 1\f$ rad/s.
Особенностью фильтра Чебышёва второго рода являются: \n
1) равноволновые пульсации АЧХ в полосе заграждения. \n
2) уровень АЧХ \f$H(j\cdot 1) = -R_s\f$ дБ. \n
\param[in] Rs \param[in] Rs
Уровень подавления в полосе пропускания (дБ). \n Suppression level in stopband (dB). \n
Значение должно быть положительным. \n This parameter sets filter supression for \f$\omega \geq 1\f$ rad/s frequency. \n
Parameter must be positive. \n
\n \n
\param[in] ord \param[in] ord
Порядок фильтра. \n Filter order. \n
Количество коэффициентов числителя и знаменателя Filter coefficients number equals `ord+1` for numerator and denominator
передаточной функции \f$H(s)\f$ равно `ord+1`. \n of transfer function \f$ H(s) \f$ \n
\n \n
\param[out] b \param[out] b
Указатель на вектор коэффициентов числителя Pointer to the vector of transfer function \f$H(s)\f$
передаточной функции \f$H(s)\f$. \n numerator coefficient. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\param[out] a \param[out] a
Указатель на вектор коэффициентов знаменателя Pointer to the vector of transfer function \f$H(s)\f$
передаточной функции \f$H(s)\f$. \n denominator coefficient. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
Пример использования функции `cheby1_ap`: \return
`RES_OK` if filter coefficients is calculated successfully. \n
Else \ref ERROR_CODE_GROUP "code error".
\n
Example:
\include cheby2_ap_test.c \include cheby2_ap_test.c
Результат работы программы: Result:
\verbatim \verbatim
b[ 0] = 0.008 a[ 0] = 0.008 b[ 0] = 0.008 a[ 0] = 0.008
@ -374,28 +352,19 @@ b[ 4] = 0.001 a[ 4] = 1.000
\endverbatim \endverbatim
\n \n
В каталоге `dat` будут созданы три файла: \n In `dat` folder will be created 3 files: \n
\verbatim \verbatim
cheby2_ap_test_mag.txt АЧХ фильтра cheby2_ap_test_mag.txt magnitude
cheby2_ap_test_phi.txt ФЧХ фильтра cheby2_ap_test_phi.txt phase response
cheby2_ap_test_tau.txt ГВЗ фильтра cheby2_ap_test_tau.txt group delay
\endverbatim \endverbatim
\n
Кроме того программа GNUPLOT произведет построение следующих графиков In addition, GNUPLOT will build the following graphs from data stored in files:
по сохраненным в файлах данным:
\image html cheby2_ap_test.png \image html cheby2_ap_test.png
\author Sergey Bakhurin www.dsplib.org
\return
`RES_OK` --- фильтр рассчитан успешно. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n
\author
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -408,60 +377,60 @@ www.dsplib.org
complex_t* p, int* np) complex_t* p, int* np)
\brief \brief
Расчет массивов нулей и полюсов передаточной функции \f$ H(s) \f$ Function calculates arrays of zeros and poles for analog normlized lowpass
аналогового нормированного ФНЧ Чебышёва второго рода. Chebyshev type 2 filter transfer function \f$ H(s) \f$ order `ord` .
Функция рассчитывает значения нулей и полюсов передаточной функции Analog normalized Chebyshev type 2 filter lowpass filter has \f$Rs\f$ dB
\f$H(s)\f$ аналогового нормированного ФНЧ Чебышёва второго рода порядка `ord` с suppression in stopband.
частотой заграждения 1 рад/с по уровню \f$-R_s\f$ дБ. \n Also analog normalized Chebyshev type 2 filter magnitude equals \f$-Rs\f$ dB
for angular frequency \f$\omega = 1\f$ rad/s.
\param[in] ord \param[in] ord
Порядок фильтра. \n Filter order. \n
Number of zeros and poles of filter can be less or equal `ord`. \n
\n \n
\param[in] rs \param[in] rs
Уровень подавления АЧХ в полосе загражения (дБ). \n Suppression level in stopband (dB). \n
Параметр задает уровень подавления сигнала в полосе частот от 1 рад/с и выше. \n This parameter sets filter supression for \f$\omega \geq 1\f$ rad/s frequency. \n
Значение должно быть положительным. \n Parameter must be positive. \n
\n \n
\param[out] z \param[out] z
Указатель на массив комплексных нулей передаточной функции \f$H(s)\f$. \n Pointer to the \f$ H(s) \f$ zeros array. \n
Максимальный размер вектора вектора `[ord x 1]`. \n Maximum vector size is `[ord x 1]`. \n
Память должна быть выделена. \n Memory must be allocated for maximum vector size. \n
\n \n
\param[out] nz \param[out] nz
Указатель на переменную количества нулей передаточной функции \f$H(s)\f$. \n Pointer to the variable which keep number of finite zeros \f$ H(s) \f$. \n
По данному указателю будет записано количество нулей фильтра, которые были Number of finite zeros which was calculated and saved in vector `z`. \n
рассчитаны и помещены в вектор `z`. \n Pointer cannot be `NULL`. \n
Память должна быть выделена. \n
\n \n
\param[out] p \param[out] p
Указатель на массив комплексных полюсов передаточной функции \f$H(s)\f$. \n Pointer to the \f$ H(s) \f$ poles array. \n
Максимальный размер вектора вектора `[ord x 1]`. \n Maximum vector size is `[ord x 1]`. \n
Память должна быть выделена. \n Memory must be allocated for maximum vector size. \n
\n \n
\param[out] np \param[out] np
Указатель на переменную количества полюсов передаточной функции \f$H(s)\f$. \n Pointer to the variable which keep number of
По данному указателю будет записано количество нулей calculated poles of \f$ H(s) \f$. \n
фильтра, которые были Pointer cannot be `NULL`. \n
рассчитаны и помещены в вектор `p`. \n
Память должна быть выделена. \n
\n \n
\return \return
`RES_OK` --- массивы нулей и полюсов рассчитаны успешно. \n `RES_OK` if zeros and poles is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\n
Пример использования функции `cheby2_ap_zp`: Example:
\include cheby2_ap_zp_test.c \include cheby2_ap_zp_test.c
Результат работы программы: Result:
\verbatim \verbatim
Chebyshev type 2 zeros: Chebyshev type 2 zeros:
@ -482,9 +451,7 @@ www.dsplib.org
p[ 6] = -0.852 -0.642 j p[ 6] = -0.852 -0.642 j
\endverbatim \endverbatim
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -496,52 +463,53 @@ www.dsplib.org
\fn int ellip_ap(double rp, double rs, int ord, double* b, double* a) \fn int ellip_ap(double rp, double rs, int ord, double* b, double* a)
\brief \brief
Расчет передаточной характеристики \f$ H(s) \f$ аналогового Function calculates the transfer function \f$ H(s) \f$ coefficients of
нормированного эллиптического ФНЧ. analog normalized lowpass elliptic filter order `ord` with passband ripple
`rp` dB and stopband suppression equals `rs` dB.
Функция рассчитывает коэффициенты передаточной характеристики \f$H(s)\f$
аналогового нормированного эллиптического ФНЧ порядка `ord`
с частотой среза 1 рад/с по уровню \f$-R_p\f$ дБ. \n
Особенностью эллиптического фильтра являются равноволновые пульсации
АЧХ как в полосе пропускания, так и в полосе заграждения, в результате
чего обеспечиваеся минимальная переходная полоса фильтра. \n
\param[in] rp \param[in] rp
Уровень пульсаций в полосе пропускания (дБ). \n Magnitude ripple in passband (dB). \n
Значение должно быть положительным. \n This parameter sets maximum filter distortion from 0 to 1 rad/s frequency. \n
Parameter must be positive. \n
\n \n
\param[in] Rs
Уровень подавления в полосе заграждения (дБ). \n \param[in] rs
Значение должно быть положительным. \n Suppression level in stopband (dB). \n
This parameter sets filter supression for \f$\omega \geq 1\f$ rad/s frequency. \n
Parameter must be positive. \n
\n \n
\param[in] ord \param[in] ord
Порядок фильтра. \n Filter order. \n
Количество коэффициентов числителя и знаменателя Filter coefficients number equals `ord+1` for numerator and denominator
передаточной функции \f$H(s)\f$ равно `ord+1`. \n of transfer function \f$ H(s) \f$ \n
\n \n
\param[out] b \param[out] b
Указатель на вектор коэффициентов числителя Pointer to the vector of transfer function \f$H(s)\f$
передаточной функции \f$H(s)\f$. \n numerator coefficient. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\param[out] a \param[out] a
Указатель на вектор коэффициентов знаменателя Pointer to the vector of transfer function \f$H(s)\f$
передаточной функции \f$H(s)\f$. \n denominator coefficient. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
Пример использования функции `ellip_ap`: \return
`RES_OK` if filter coefficients is calculated successfully. \n
Else \ref ERROR_CODE_GROUP "code error".
\n
Example:
\include ellip_ap_test.c \include ellip_ap_test.c
Результат работы программы: Result:
\verbatim \verbatim
b[ 0] = 0.268 a[ 0] = 0.301 b[ 0] = 0.268 a[ 0] = 0.301
@ -552,28 +520,19 @@ b[ 4] = 0.001 a[ 4] = 1.000
\endverbatim \endverbatim
\n \n
В каталоге `dat` будут созданы три файла: \n In `dat` folder will be created 3 files: \n
\verbatim \verbatim
ellip_ap_test_mag.txt АЧХ фильтра ellip_ap_test_mag.txt magnitude
ellip_ap_test_phi.txt ФЧХ фильтра ellip_ap_test_phi.txt phase response
ellip_ap_test_tau.txt ГВЗ фильтра ellip_ap_test_tau.txt group delay
\endverbatim \endverbatim
\n
Кроме того программа GNUPLOT произведет построение следующих графиков In addition, GNUPLOT will build the following graphs from data stored in files:
по сохраненным в файлах данным:
\image html ellip_ap_test.png \image html ellip_ap_test.png
\author Sergey Bakhurin www.dsplib.org
\return
`RES_OK` --- фильтр рассчитан успешно. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n
\author
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -589,67 +548,68 @@ www.dsplib.org
\ingroup IIR_FILTER_DESIGN_GROUP \ingroup IIR_FILTER_DESIGN_GROUP
\fn int filter_zp2ab(complex_t *z, int nz, complex_t *p, int np, int ord, \fn int filter_zp2ab(complex_t *z, int nz, complex_t *p, int np, int ord,
double* b, double* a) double* b, double* a)
\brief Функция пересчета нулей и полюсов аналогового фильтра в коэффициенты \brief
передаточной характеристики \f$ H(s) \f$ Function recalculates complex zeros and poles of transfer function \f$ H(s) \f$
to the coefficients of \f$ H(s) \f$ numerator and denominator polynomials.
Transfer function can we described as:
\f[ \f[
H(s) = H(s) =
\frac{\sum_{n = 0}^{N_z} b_n \cdot s^n}{\sum_{m = 0}^{N_p} a_m \cdot s^m} = \frac{\sum\limits_{n = 0}^{N_z} b_n s^n}{\sum\limits_{m = 0}^{N_p} a_m s^m} =
\frac{\prod_{n = 0}^{N_z}(s-z_n)}{\prod_{m = 0}^{N_p} (s-p_m)} \frac{\prod\limits_{n = 0}^{N_z}(s-z_n)}{\prod\limits_{m = 0}^{N_p} (s-p_m)}
\f] \f]
\param[in] z \param[in] z
Указатель на массив нулей передаточной характеристики. \n Pointer to the vector of transfer function zeros. \n
Размер вектора `[nz x 1]`. \n Vector size is `[nz x 1]`. \n
Указатель может быть `NULL` если фильтр не имеет конечных нулей (`nz=0`). \n Pointer can be `NULL` if filter has no finite zeros (`nz=0`). \n
\n \n
\param[in] nz \param[in] nz
Размер вектора нулей передаточной характеристики (может быть равен 0). \n Number of fitite zeros (can be zero). \n
\n \n
\param[in] p \param[in] p
Указатель на массив полюсов передаточной характеристики. \n Pointer to the vector of transfer function poles. \n
Размер вектора `[np x 1]`. \n Vector size is `[np x 1]`. \n
Указатель не может быть `NULL`. \n This pointer cannot be `NULL`. \n
Память должна быть выделена. \n
\n \n
\param[in] np \param[in] np
Размер вектора полюсов передаточной характеристики (не может быть равен 0). \n Size of vector of transfer function poles (`p` vector size). \n
\n \n
\param[in] ord \param[in] ord
Порядок фильтра для которого рассчитаны нули и полюса. \n Filter order. \n
Количество коэффициентов числителя и знаменателя Number of \f$H(s)\f$ numerator and denominator coefficients equals `ord+1`. \n
передаточной функции \f$H(s)\f$ равно `ord+1`. \n \n \n
\param[out] b \param[out] b
Указатель на вектор коэффициентов числителя передаточной функции \f$H(s)\f$. \n Pointer to the vector of transfer function \f$H(s)\f$
Размер вектора `[ord+1 x 1]`. \n numerator coefficient. \n
Память должна быть выделена. \n Vector size is `[ord+1 x 1]`. \n
Memory must be allocated. \n
\n \n
\param[out] a \param[out] a
Указатель на вектор коэффициентов знаменателя Pointer to the vector of transfer function \f$H(s)\f$
передаточной функции \f$H(s)\f$. \n denominator coefficient. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\return \return
`RES_OK` --- пересчет произведен успешно. \n `RES_OK` if filter coefficients is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\n
\note \note
Функция возвращает вещественные значения коэффициентов `b` и `a` Function calculates real `b` and `a` coefficients of \f$H(s)\f$.
передаточной функции. Это означает, что вектора нулей и полюсов It means that zeros and poles vectors must have real values or conjugate pairs
должны хранить вещественные значения или комплексно-сопряженные пары to get zeros image part of `b` and `a` coefficients. This function ignores
нулей и полюсов, потому что мнимая часть коэффициентов `b` и `a` image part of `b` and `a` coeeffitients if the requirements for zeros
игнорируется и не сохраняется. and poles are not fulfilled.
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */

Wyświetl plik

@ -3,130 +3,121 @@
/*! **************************************************************************** /*! ****************************************************************************
\ingroup FIR_FILTER_DESIGN_GROUP \ingroup FIR_FILTER_DESIGN_GROUP
\fn int DSPL_API fir_linphase(int ord, double w0, double w1, int filter_type, \fn int DSPL_API fir_linphase(int ord, double w0, double w1, int filter_type,
int win_type, double win_param, double* h) int win_type, double win_param, double* h)
\brief \brief
Расчет коэффициентов линейно-фазового КИХ-фильтра Function calculates linear-phase FIR filter coefficients by window method
методом оконного взвешивания.
Функция рассчитывает коэффициенты передаточной характеристики FIR filter transfer function is
\f[ \f[
H(z) = \sum_{n = 0}^{ord} h_n z^{-n} H(z) = \sum_{n = 0}^{ord} h_n z^{-n}.
\f] \f]
цифрового линейно-фазового КИХ-фильтра фильтра.
\param[in] ord \param[in] ord
Порядок фильтра (количество элементов задержки). \n Filter order. \n
Количество коэффициентов фильтра равно `ord+1`. \n Number of FIR filter coefficients is `ord+1`. \n
\n \n
\param[in] w0 \param[in] w0
Нормированная частота среза ФНЧ или ФВЧ, Normalized cutoff frequency for lowpass and highpass filter,
или левая частота среза для полосового и режекторного фильтра. \n or left cutoff frequency for bandpass or bandstop filter. \n
\n \n
\param[in] w1 \param[in] w1
Правая частота среза полосового и режекторного фильтра. \n Right normalized cutoff frequency for bandpass or bandstop filter. \n
Данный параметр игнорируется для ФНЧ и ФВЧ. \n This parameter is ignored for lowpass or highpass filters. \n
Частота `w1` должна быть больше `w0`. \n Frequecny `w1` must be higher than `w0`. \n
\n \n
\param[in] filter_type \param[in] filter_type
Тип фильтра. \n Filter type. \n
Данный параметр определяет тип фильтра This parameter can be one of follow: \n
и может принимать одно из значений: \n
\verbatim \verbatim
DSPL_FILTER_LPF - фильтр нижних частот; DSPL_FILTER_LPF - lowpass filter;
DSPL_FILTER_HPF - фильтр верхних частот; DSPL_FILTER_HPF - highpass filter;
DSPL_FILTER_BPASS - полосовой фильтр; DSPL_FILTER_BPASS - bandpass filter;
DSPL_FILTER_BSTOP - режекторный фильтр. DSPL_FILTER_BSTOP - bandstop filter.
\endverbatim \endverbatim
\n \n
\n \n
\param [in] win_type \param [in] win_type
Тип оконной функции. \n Window function type. \n
Может принимать одно из следующих значений: \n This parameter can be one of follow: \n
\verbatim \verbatim
------------------------------------------------------------------------- -------------------------------------------------------------------------
Значение win_type | Описание win_type | Description
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_BARTLETT | Непараметрическое окно Бартлетта DSPL_WIN_BARTLETT | Nonparametric Bartlett window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_BARTLETT_HANN | Непараметрическое окно Бартлетта-Ханна DSPL_WIN_BARTLETT_HANN | Nonparametric Bartlett-Hann window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_BLACKMAN | Непараметрическое окно Блэкмана DSPL_WIN_BLACKMAN | Nonparametric Blackman window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_BLACKMAN_HARRIS | Непараметрическое окно Блэкмана-Харриса DSPL_WIN_BLACKMAN_HARRIS | Nonparametric Blackman-Harris window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_BLACKMAN_NUTTALL | Непараметрическое окно Блэкмана-Натталла DSPL_WIN_BLACKMAN_NUTTALL | Nonparametric Blackman-Nuttall
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_CHEBY | Параметрическое окно Дольф-Чебышева. DSPL_WIN_CHEBY | Parametric Dolph-Chebyshev window.
| Параметр win_param задает уровень | Parametr `win_param` sets sidelobe attenuation
| боковых лепестков в дБ. | level in dB.
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_COS | Непараметрическое косинус-окно DSPL_WIN_COS | Nonparametric Cosine window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_FLAT_TOP | Непараметрическое окно с максимально DSPL_WIN_FLAT_TOP | Nonparametric maxflat window
| плоской вершиной
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_GAUSSIAN | Параметрическое окно Гаусса DSPL_WIN_GAUSSIAN | Nonparametric Gauss window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_HAMMING | Непараметрическое окно Хемминга DSPL_WIN_HAMMING | Nonparametric Hamming window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_HANN | Непараметрическое окно Ханна DSPL_WIN_HANN | Nonparametric Hann window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_KAISER | Параметрическое окно Кайзера DSPL_WIN_KAISER | Parametric Kaiser window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_LANCZOS | Непараметрическое окно Ланкзоса DSPL_WIN_LANCZOS | Nonparametric Lanczos window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_NUTTALL | Непараметрическое окно Натталла DSPL_WIN_NUTTALL | Nonparametric Nuttall window
-----------------------------|------------------------------------------- -----------------------------|-------------------------------------------
DSPL_WIN_RECT | Непараметрическое прямоугольное окно DSPL_WIN_RECT | Nonparametric rectangular window
------------------------------------------------------------------------- -------------------------------------------------------------------------
\endverbatim \endverbatim
\n \n
\n \n
\param [in] win_param \param [in] win_param
Параметр окна. \n Parameter value for parametric windows. \n
Данный параметр применяется только для параметрических оконных функций. \n This parameter is used for parametric windows only and is ignored for
Для непараметрических окон игнорируется. \n nonparametric windows. \n
\n \n
\param[out] h \param[out] h
Указатель на вектор коэффициентов линейно-фазового КИХ-фильтраю \f$H(z)\f$. \n Pointer to the linear-phase FIR filter coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memoru must be allocated. \n
\n \n
\note \note
Для соблюдения условия линейной ФЧХ используются Only symmetric windows can achieve linear-phase FIR filter. \n \n
только симметричные окна. \n \n Bandstop filter type (`filter_type = DSPL_FILTER_BSTOP`) requires
Расчет режекторного линейно-фазового КИХ-фильтра only even filter order `ord`.
(если `filter_type = DSPL_FILTER_BSTOP`) производится только If `filter_type = DSPL_FILTER_BSTOP` and `ord` is odd then function
для фильтров чётного порядка `ord`. returns `ERROR_FILTER_ORD` code.
В случае нечетного порядка `ord` функция вернет код ошибки `ERROR_FILTER_ORD`.
\n \n
\return \return
`RES_OK` `RES_OK` if filter coefficients is calculated successfully. \n
Фильтр рассчитан успешно. \n Else \ref ERROR_CODE_GROUP "code error".
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n
Пример использования функции: Example:
\include fir_linphase_test.c \include fir_linphase_test.c
Программа расчитывает коэффициенты и АЧХ линейно-фазовых КИХ-фильтрова нижних, This function calculates coeffictiens of lowpass, highpass, bandpass
верхних частот, полосовых и режекторных с применением различных весовых окон: and bandstop linear-phase FIR filters by using different kind of windows.
прямоугольное, Хемминга, Илэкмана и Блэкмана-Харриса. \n Also program calculates filter magnitudes and plots. \n
Полученные АЧХ выводятся на график
\image html fir_linphase_test.png \image html fir_linphase_test.png
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */

Wyświetl plik

@ -2,62 +2,57 @@
\ingroup IIR_FILTER_DESIGN_GROUP \ingroup IIR_FILTER_DESIGN_GROUP
\fn int low2high (double* b, double* a, int ord, double w0, double w1, \fn int low2high (double* b, double* a, int ord, double w0, double w1,
double* beta, double* alpha) double* beta, double* alpha)
\brief Частотное преобразование ФНЧ-ФВЧ \brief Lowpass to highpass filter frequency transform
Функция производит перобразование передаточной функции \f$ H(s) \f$ Function transforms lowpass filter transfer function \f$ H(s) \f$
аналогового ФНЧ с частотой среза `w0` рад/c to the highpass filter transfer function \f$ F(s) \f$.
в передаточную функцию \f$ F(s) \f$ аналоговго ФВЧ с частотой среза `w1` рад/c.
Неравномерность АЧХ в полосе пропускания, уровень подавления в полосе Filter order, magnitude ripple in passband and stopband
заграждения и порядок фильтра остаются неизменными. supression still the same.
\param[in] b \param[in] b
Указатель на вектор коэффициентов числителя передаточной функции \f$H(s)\f$ Pointer to the lowpass filter transfer function \f$H(s)\f$ numerator
исходного аналогового ФНЧ. \n coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n
\n \n
\param[in] a \param[in] a
Указатель на вектор коэффициентов знаменателя передаточной функции \f$H(s)\f$ Pointer to the lowpass filter transfer function \f$H(s)\f$ denominator
исходного аналогового ФНЧ. \n coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n
\n \n
\param[in] ord \param[in] ord
Порядок исходного фильтра и фильтра после переобразования. \n Filter order. \n
\n \n
\param[in] w0 \param[in] w0
Частота среза исходного ФНЧ. \n Lowpass filter cutoff frequency. \n
\n \n
\param[in] w1 \param[in] w1
Требуемая частота среза ФВЧ после преобразования. \n Highpass filter cutoff frequency after transformation. \n
\n \n
\param[in,out] beta \param[in,out] beta
Указатель на вектор коэффициентов числителя передаточной функции \f$F(s)\f$ Pointer to the highwpass filter transfer function \f$F(s)\f$ numerator
ФВЧ после преобразования. \n coefficients vector after transformation. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\param[in,out] alpha \param[in,out] alpha
Указатель на вектор коэффициентов знаменателя передаточной функции \f$F(s)\f$ Pointer to the highwpass filter transfer function \f$F(s)\f$ denominator
аналогового ФВЧ после преобразования. \n coefficients vector after transformation. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\return \return
`RES_OK` --- преобразование рассчитано успешно. \n `RES_OK` if filter coefficients is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -70,61 +65,59 @@ www.dsplib.org
\ingroup IIR_FILTER_DESIGN_GROUP \ingroup IIR_FILTER_DESIGN_GROUP
\fn int low2low(double* b, double* a, int ord, double w0, double w1, \fn int low2low(double* b, double* a, int ord, double w0, double w1,
double* beta, double* alpha) double* beta, double* alpha)
\brief Частотное преобразование ФНЧ-ФНЧ
Функция производит преобразование передаточной функции \f$ H(s) \f$ Lowpass to lowpass filter frequency transform
аналогового ФНЧ с частотой среза `w0` рад/c
в передаточную функцию \f$ F(s) \f$ аналоговго ФНЧ с частотой среза `w1` рад/c.
Неравномерность АЧХ в полосе пропускания, уровень подавления в полосе Function transforms lowpass filter transfer function \f$ H(s) \f$
заграждения и порядок фильтра остаются неизменными. to the lowpass filter transfer function \f$ F(s) \f$
with other cutoff frequency.
Filter order, magnitude ripple in passband and stopband
supression still the same.
\param[in] b \param[in] b
Указатель на вектор коэффициентов числителя передаточной функции \f$H(s)\f$ Pointer to the input lowpass filter transfer function \f$H(s)\f$ numerator
исходного аналогового ФНЧ. \n coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n
\n \n
\param[in] a \param[in] a
Указатель на вектор коэффициентов знаменателя передаточной функции \f$H(s)\f$ Pointer to the input lowpass filter transfer function \f$H(s)\f$ denominator
исходного аналогового ФНЧ. \n coefficients vector. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n
\n \n
\param[in] ord \param[in] ord
Порядок исходного фильтра и фильтра после преобразования. \n Filter order. \n
\n \n
\param[in] w0 \param[in] w0
Частота среза исходного ФНЧ. \n Input lowpass filter cutoff frequency. \n
\n \n
\param[in] w1 \param[in] w1
Требуемая частота среза ФНЧ после преобразования. \n Lowpass filter cutoff frequency after transformation. \n
\n \n
\param[in,out] beta Указатель на вектор коэффициентов числителя \param[in,out] beta
передаточной функции \f$F(s)\f$ ФНЧ после преобразования. \n Pointer to the lowpass filter transfer function \f$F(s)\f$ numerator
Размер вектора `[ord+1 x 1]`. \n coefficients vector after transformation. \n
Память должна быть выделена. \n Vector size is `[ord+1 x 1]`. \n
Memory must be allocated. \n
\n \n
\param[in,out] alpha \param[in,out] alpha
Указатель на вектор коэффициентов знаменателя передаточной функции \f$F(s)\f$ Pointer to the lowpass filter transfer function \f$F(s)\f$ denominator
аналогового ФНЧ после преобразования. \n coefficients vector after transformation. \n
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\return \return
`RES_OK` --- Преоборазование расчитано успешно. \n `RES_OK` if filter coefficients is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -140,9 +133,9 @@ www.dsplib.org
\fn int ratcompos( double* b, double* a, int n, \fn int ratcompos( double* b, double* a, int n,
double* c, double* d, int p, double* c, double* d, int p,
double* beta, double* alpha) double* beta, double* alpha)
\brief Рациональная композиця \brief Rational composition
Функция рассчитывает композицию вида \f$Y(s) = (H \circ F)(s) = H(F(s))\f$, где Function calcultes composition \f$Y(s) = (H \circ F)(s) = H(F(s))\f$, here
\f[ \f[
H(s) = \frac{\sum\limits_{m = 0}^{n} b_m s^m} H(s) = \frac{\sum\limits_{m = 0}^{n} b_m s^m}
@ -153,65 +146,59 @@ Y(s) = \frac{\sum\limits_{m = 0}^{n p} \beta_m s^m}
{\sum\limits_{k = 0}^{n p} \alpha_k s^k} {\sum\limits_{k = 0}^{n p} \alpha_k s^k}
\f] \f]
Функция рациональной композиции необходима для произведения частотных This function is using for filter frequency transform.
преобразований передаточных характеристик аналоговых и цифровых фильтров,
а также для билинейного преобразования передаточных характеристик аналоговых
фильтров в соответствующие передаточные характеристики цифровых фильтров.
\param[in] b \param[in] b
Указатель на вектор коэффициентов числителя функции \f$H(s)\f$. \n Pointer to the \f$H(s)\f$ polynomial function
Размер вектора `[n+1 x 1]`. \n numerator coefficients vector. \n
Память должна быть выделена. \n Vector size is `[n+1 x 1]`. \n
\n \n
\param[in] a \param[in] a
Указатель на вектор коэффициентов знаменателя функции \f$H(s)\f$. \n Pointer to the \f$H(s)\f$ polynomial function
Размер вектора `[n+1 x 1]`. \n denominator coefficients vector. \n
Память должна быть выделена. \n Vector size is `[n+1 x 1]`. \n
\n \n
\param[in] n \param[in] n
Порядок полиномов рациональной функции \f$H(s)\f$. \n Order of \f$H(s)\f$ numerator and denominator polynomials. \n
\n \n
\param[in] c \param[in] c
Указатель на вектор коэффициентов числителя функции \f$F(s)\f$. \n Pointer to the \f$F(s)\f$ polynomial function
Размер вектора `[p+1 x 1]`. \n numerator coefficients vector. \n
Память должна быть выделена. \n Vector size is `[p+1 x 1]`. \n
\n \n
\param[in] d \param[in] d
Указатель на вектор коэффициентов знаменателя функции \f$F(s)\f$. \n Pointer to the \f$F(s)\f$ polynomial function
Размер вектора `[p+1 x 1]`. \n denominator coefficients vector. \n
Память должна быть выделена. \n Vector size is `[p+1 x 1]`. \n
\n \n
\param[in] p \param[in] p
Порядок полиномов рациональной Order of \f$F(s)\f$ numerator and denominator polynomials. \n
функции \f$F(s)\f$. \n
\n \n
\param[in,out] beta \param[in,out] beta
Указатель на вектор коэффициентов Pointer to the numerator coefficients vector of
числителя функции \f$Y(s) = (H \circ F)(s)\f$. \n \f$Y(s) = (H \circ F)(s)\f$. \n
Размер вектора `[n*p+1 x 1]`. \n Vector size is `[n*p+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\param[in,out] alpha \param[in,out] alpha
Указатель на вектор коэффициентов знаменателя Pointer to the denominator coefficients vector of
функции \f$Y(s) = (H \circ F)(s)\f$. \n \f$Y(s) = (H \circ F)(s)\f$. \n
Размер вектора `[n*p+1 x 1]`. \n Vector size is `[n*p+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\return \return
`RES_OK` --- Рациональная композиция рассчитана успешно. \n `RES_OK` if rational composition is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */

Wyświetl plik

@ -5,74 +5,71 @@
\fn int bilinear(double* bs, double* as, int ord, double* bz, double* az) \fn int bilinear(double* bs, double* as, int ord, double* bz, double* az)
\brief \brief
Билинейное преобразование передаточной характеристики аналогового Transform a s-plane analog filter transfer function \f$H(s)\f$ to the
фильтра \f$H(s)\f$, в передаточную характеристику цифрового фильтра \f$H(z)\f$. digital filter transfer function \f$H(z)\f$.
Функция рассчитывает коэффициенты передаточной характеристики \f$H(z)\f$ Bilinear transform is rational composition:
цифрового фильтра путем дробно-рациональной подстановки вида
\f[ \f[
s \leftarrow \frac{1 - z^{-1}}{1 - z^{-1}}. s \leftarrow \frac{1 - z^{-1}}{1 - z^{-1}}.
\f] \f]
Порядок цифрового фильтра при этом остается равным порядку аналогового фильтра, Digital filter order, passband magnitude ripple and stopband suppression
а ось частот \f$\Omega\f$ аналогового фильтра связана c осью частот still the same after bilinear transform as analog filter.
\f$\omega\f$ цифрового фильтра соотношением:
Frequency \f$\Omega\f$ of analog filter and frequency
\f$\omega\f$ of digital filter relations:
\f[ \f[
\Omega = \tan(\omega / 2). \Omega = \tan(\omega / 2).
\f] \f]
\param[in] bs \param[in] bs
Указатель на вектор коэффициентов числителя передаточной функции \f$H(s)\f$ Pointer to the vector of analog filter \f$H(s)\f$
исходного аналогового фильтра. \n numerator coefficients.
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n
\n \n
\param[in] as \param[in] as
Указатель на вектор коэффициентов знаменателя передаточной функции \f$H(s)\f$ Pointer to the vector of analog filter \f$H(s)\f$
исходного аналогового фильтра. \n denominator coefficients vector.
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n
\n \n
\param[in] ord \param[in] ord
Порядок фильтра. \n Analog and digital filters order. \n
Количество коэффициентов числителя и знаменателя передаточных функций
\f$H(s)\f$ и \f$H(z)\f$ аналогового и цифрового фильтров равно `ord+1`. \n
\n \n
\param[out] bz \param[out] bz
Указатель на вектор коэффициентов числителя передаточной функции \f$H(z)\f$ Pointer to the vector of digital filter \f$H(z)\f$
полученного цифрового фильтра. \n numerator coefficients after bilinear transform.
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\param[out] az \param[out] az
Указатель на вектор коэффициентов знаменателя передаточной функции \f$H(z)\f$ Pointer to the vector of digital filter \f$H(z)\f$
полученного цифрового фильтра. \n denominator coefficients after bilinear transform.
Размер вектора `[ord+1 x 1]`. \n Vector size is `[ord+1 x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\return \return
`RES_OK` --- фильтр рассчитан успешно. \n `RES_OK` if bilinear transform is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
Пример использования функции `bilinear`: Example:
\include bilinear_test.c \include bilinear_test.c
Данная программа производит расчет передаточной характеристики аналогового This program calculates the transfer function \f$H(s)\f$ of analog
фильтра Чебышева первого рода, с частотой среза равной 1 рад/с, и производит Chebyshev filter of the first kind, with a cutoff frequency of 1 rad/s,
билинейное преобразование в цифровой, с частотой среза равной 0.5. and produces bilinear trandform to digital filter,
with a normilized cutoff frequency equals 0.5.
Результат работы программы: Result:
\verbatim \verbatim
bz[0] = 0.246 az[0] = 4.425 bz[0] = 0.246 az[0] = 4.425
@ -83,14 +80,12 @@ bz[4] = 0.246 az[4] = 1.034
err = 0 err = 0
\endverbatim \endverbatim
Кроме этого производится расчет АЧХ полученного цифрового фильтра и строится In addition, the frequency response of the resulting digital filter
график АЧХ пакетом GNUPLOT is calculated and plotted by GNUPLOT package.
\image html bilinear.png \image html bilinear.png
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -104,91 +99,86 @@ www.dsplib.org
\fn int iir(double rp, double rs, int ord, double w0, double w1, \fn int iir(double rp, double rs, int ord, double w0, double w1,
int type, double* b, double* a) int type, double* b, double* a)
\brief \brief
Функция расчета коэффициентов передаточной характеристики \f$H(z)\f$ Digital IIR filter design.
цифрового фильтра БИХ.
Функция рассчитывает коэффициенты передаточной характеристики \f$H(z)\f$ The function calculates the coefficients of the digital IIR filter
цифрового фильтра, которые могут быть использованы в функции \ref filter_iir transfer fucntion \f$ H(z) \f$.
Filter coeffitients can be used in \ref filter_iir function
\param[in] rp \param[in] rp
Уровень неравномерности квадрата АЧХ в полосе пропускания фильтра (дБ). \n Magnitude ripple in passband (dB). \n
Размер вектора `[ord+1 x 1]`. \n
\n \n
\param[in] rs \param[in] rs
Уровень подавления в полосе заграждения фильтра (дБ).\n Suppression level in stopband (dB). \n
\n \n
\param[in] ord \param[in] ord
Порядок фильтра. \n Filter order. \n
Количество коэффициентов числителя и знаменателя передаточной Number of \f$H(z)\f$ numerator and denominator coefficients is `ord+1`. \n
функции \f$H(z)\f$ цифрового фильтров равно `ord+1`. \n For bandpass and bandstop filters `ord` must be even. \n
Для полосовых и режекторных фильтров параметр `ord` должен быть чётным. \n
\n \n
\param[in] w0 \param[in] w0
Нормированная частота среза ФНЧ или ФВЧ, или левая частота среза для Normalized cutoff frequency (from 0 to 1) for lowpass or highpass filter. \n
полосового и режекторного фильтра.\n Or left normalized cutoff frequency (from 0 to 1) for
bandpass and bandstop filter. \n
\n \n
\param[in] w1 \param[in] w1
Правая частота среза полосового и режекторного фильтра. \n Right normalized cutoff frequency (from 0 to 1) for
Данный параметр игнорируется для ФНЧ и ФВЧ. \n bandpass and bandstop filter. \n
This parameter is ingnored for lowpass and highpass filters.
\n \n
\param[in] type \param[in] type
Тип фильтра. \n Filter type. \n
Данный параметр определяет тип фильтра и образуется This patameter sets combination of filter type (one of follow): \n
набором флагов типа фильтра: \n
\verbatim \verbatim
DSPL_FILTER_LPF - фильтр нижних частот; DSPL_FILTER_LPF - lowpass filter;
DSPL_FILTER_HPF - фильтр верхних частот; DSPL_FILTER_HPF - highpass filter;
DSPL_FILTER_BPASS - полосовой фильтр; DSPL_FILTER_BPASS - bandpass filter;
DSPL_FILTER_BSTOP - режекторный фильтр, DSPL_FILTER_BSTOP - bandstop filter,
\endverbatim \endverbatim
а также флагов типа аппроксимации АЧХ фильтра: and of filter approximation type (one of follow):
\verbatim \verbatim
DSPL_FILTER_BUTTER - фильтр Баттерворта; DSPL_FILTER_BUTTER - Butterworth filter;
DSPL_FILTER_CHEBY1 - фильтр Чебышева первого рода; DSPL_FILTER_CHEBY1 - Chebyshev of the first kind filter;
DSPL_FILTER_CHEBY2 - фильтр Чебышева второго рода; DSPL_FILTER_CHEBY2 - Chebyshev of the second kind filter;
DSPL_FILTER_ELLIP - эллиптический фильтр. DSPL_FILTER_ELLIP - Elliptic filter.
\endverbatim \endverbatim
\n \n
\n \n
\param[out] b \param[out] b
Указатель на вектор коэффициентов Pointer to the transfer function \f$H(z)\f$
числителя передаточной функции \f$H(z)\f$. \n numerator coefficients vector. \n
Размер вектора `ord+1`. \n Vector size is `ord+1`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\param[out] a \param[out] a
Указатель на вектор коэффициентов знаменателя передаточной Pointer to the transfer function \f$H(z)\f$
функции \f$H(z)\f$. \n denominator coefficients vector. \n
Размер вектора `ord+1`. \n Vector size is `ord+1`. \n
Память должна быть выделена. \n
\n \n
\return \return
`RES_OK` --- Фильтр рассчитан успешно. \n `RES_OK` if filter is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
Пример использования функции: Example:
\include iir_test.c \include iir_test.c
Данная программа производит расчет коэффициентов фильтров This program calcultes filter coefficients for different flags `type`.
при различном сочетании флагов параметра `type`.
Кроме этого производится расчет АЧХ полученных цифровых фильтров и выводится на In addition, the filters magnitudes
график АЧХ пакетом GNUPLOT is calculated and plotted by GNUPLOT package.
\image html iir_test.png \image html iir_test.png
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */

Wyświetl plik

@ -4,64 +4,55 @@
int nw, double* w, complex_t* y) int nw, double* w, complex_t* y)
\brief \brief
Расчет коэффициентов разложения в ряд Фурье Fourier series coefficient calculation for periodic signal
Функция рассчитывает спектр периодического сигнала при усечении ряда Фурье \n
\param[in] t \param[in] t
Указатель на массив моментов времени дискретизации исходного сигнала `s`. \n Pointer to the time vector. \n
Размер вектора вектора `[nt x 1]`. \n Vector size is `[nt x 1]`. \n
Память должна быть выделена. \n
\n \n
\param[in] s \param[in] s
Указатель на массив значений исходного сигнала`s`. \n Pointer to the signal corresponds to time `t`. \n
Размер вектора `[nt x 1]`. \n Vector size is `[nt x 1]`. \n
Память должна быть выделена. \n
\n \n
\param[in] nt \param[in] nt
Размер выборки исходного сигнала. \n Size of time and signal vectors. \n
Значение должно быть положительным. \n This value must be positive. \n
\n \n
\param[in] period \param[in] period
Период повторения сигнала. \n Signal time period. \n
\n \n
\param[in] nw \param[in] nw
Размер усеченного ряда Фурье. \n Number of Fourie series coefficients. \n
\n \n
\param[out] w \param[out] w
Указатель на массив частот спектра периодического сигнала. \n Pointer to the frequency vector (rad/s). \n
Размер вектора `[nw x 1]`. \n Vector size is `[nw x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\param[out] y \param[out] y
Указатель массив комплексных значений спектра периодического сигнала. \n Pointer to the complex Fourier series coefficients vector. \n
Размер вектора `[nw x 1]`. \n Vector size is `[nw x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\return \return
`RES_OK` --- коэффициенты ряда Фурье рассчитаны успешно. \n `RES_OK` if function is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\note \note
Для расчета спектра сигнала используется численное интегрирование Numerical integration is used for Fourier series coefficients calculation.
исходного сигнала методом трапеций. Данная функция не является This function is not effective.
эффективной. Для увеличения скорости расчета спектра сигнала To increase the speed of calculation of the signal spectrum
целесообразнее использовать алгоритмы дискретного it is more expedient to use fast Fourier transform algorithms.
и быстрого преобразования Фурье.
\n \n
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */
@ -73,61 +64,56 @@ www.dsplib.org
\ingroup DFT_GROUP \ingroup DFT_GROUP
\fn int fourier_series_rec(double* w, complex_t* s, int nw, \fn int fourier_series_rec(double* w, complex_t* s, int nw,
double* t, int nt, complex_t* y) double* t, int nt, complex_t* y)
\brief Восстановление сигнала при усечении ряда Фурье \brief Time signal reconstruction from Fourier series coefficients.
Функция рассчитывает восстановленный сигнал при усечении ряда Фурье: Function reconstructs the time signal:
\f[ \f[
s(t) = \sum\limits_{n = 0}^{n_{\omega}-1} S(\omega_n) \exp(j\omega_n t) s(t) = \sum\limits_{n = 0}^{n_{\omega}-1} S(\omega_n) \exp(j\omega_n t)
\f] \f]
\param[in] w \param[in] w
Указатель на массив частот \f$\omega_n\f$ усеченного ряда Фурье. \n Pointer to the Fourier series spectrum frequency vector \f$\omega_n\f$. \n
Размер вектора `[nw x 1]`. \n Vector size is `[nw x 1]`. \n
Память должна быть выделена и заполнена. \n
\n \n
\param[in] s \param[in] s
Указатель на массив значений спектра \f$S(\omega_n)\f$. \n Pointer to the Fourier series coefficients vector \f$S(\omega_n)\f$. \n
Размер вектора `[nw x 1]`. \n Vector size is `[nw x 1]`. \n
Память должна быть выделена и заполнена. \n
\n \n
\param[in] nw \param[in] nw
Количество членов усеченного ряда Фурье. \n Number of Fourier series coefficients. \n
Значение должно быть положительным. \n This value must be positive. \n
\n \n
\param[in] t Указатель на массив временных отсчетов \param[in] t
восстановленного сигнала. \n Pointer to the reconstructed signal time vector. \n
Размер вектора `[nt x 1]`. \n Vector size is `[nt x 1]`. \n
Память должна быть выделена и заполнена. \n
\n \n
\param[in] nt \param[in] nt
Размер вектора времени и восстановленного сигнала. \n Size of time vector and reconstructed signal vector . \n
\n \n
\param[out] y \param[out] y
Указатель на массив восстановленного сигнала. \n Pointer to the reconstructed signal vector. \n
Размер вектора `[nt x 1]`. \n Vector size is `[nt x 1]`. \n
Память должна быть выделена. \n Memory must be allocated. \n
\n \n
\return \return
`RES_OK` --- восстановление сигнала прошло успешно. \n `RES_OK` if function is calculated successfully. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n Else \ref ERROR_CODE_GROUP "code error".
\note \note
Выходной восстановленный сигнал в общем случае является комплексным. The output reconstructed signal is generally complex.
Однако при соблюдении свойств симметрии векторов `w` и `s` относительно However, subject to the symmetry properties of the vectors `w` and` s`
нулевой частоты получим мнимую часть элементов вектора `y` на уровне ошибок with respect to zero frequency we get the imaginary part of the vector `y`
округления числа с двойной точностью. Ничтожно малую мнимую часть в этом случае at the EPS level. The negligible imaginary part in this case
можно игнорировать. can be ignored.
\n \n
\author \author Sergey Bakhurin www.dsplib.org
Бахурин Сергей
www.dsplib.org
***************************************************************************** */ ***************************************************************************** */

Wyświetl plik

@ -57,11 +57,16 @@ void dft5 (complex_t *x, complex_t* y);
#define DFT7_W8 -0.874842290961656665615465 #define DFT7_W8 -0.874842290961656665615465
void dft7 (complex_t *x, complex_t* y); void dft7 (complex_t *x, complex_t* y);
#define DFT8_W 0.707106781186548
void dft8 (complex_t *x, complex_t* y);
void transpose2x4(complex_t *x, complex_t* y);
void transpose4x2(complex_t *x, complex_t* y);
#define DFT16_W1 0.923879532511287 #define DFT16_W1 0.923879532511287
#define DFT16_W2 0.382683432365090 #define DFT16_W2 0.382683432365090
#define DFT16_W3 0.707106781186548 #define DFT16_W3 0.707106781186548
void dft16 (complex_t *x, complex_t* y); void dft16 (complex_t *x, complex_t* y);
void transpose4x4(complex_t *x, complex_t* y); void transpose4x4(complex_t *x, complex_t* y);

Wyświetl plik

@ -122,6 +122,7 @@ int fft_krn(complex_t* t0, complex_t* t1, fft_t* p, int n, int addr)
n1 = 1; n1 = 1;
if(n%16== 0) { n1 = 16; goto label_size; } if(n%16== 0) { n1 = 16; goto label_size; }
if(n%7 == 0) { n1 = 7; goto label_size; } if(n%7 == 0) { n1 = 7; goto label_size; }
if(n%8 == 0) { n1 = 8; goto label_size; }
if(n%5 == 0) { n1 = 5; goto label_size; } if(n%5 == 0) { n1 = 5; goto label_size; }
if(n%4 == 0) { n1 = 4; goto label_size; } if(n%4 == 0) { n1 = 4; goto label_size; }
if(n%3 == 0) { n1 = 3; goto label_size; } if(n%3 == 0) { n1 = 3; goto label_size; }
@ -159,7 +160,11 @@ label_size:
if(n1 == 7) if(n1 == 7)
for(k = 0; k < n2; k++) for(k = 0; k < n2; k++)
dft7(t0+7*k, t1+7*k); dft7(t0+7*k, t1+7*k);
if(n1 == 8)
for(k = 0; k < n2; k++)
dft8(t0+8*k, t1+8*k);
if(n1 == 5) if(n1 == 5)
for(k = 0; k < n2; k++) for(k = 0; k < n2; k++)
@ -221,6 +226,7 @@ int DSPL_API fft_create(fft_t* pfft, int n)
n2 = 1; n2 = 1;
if(s%16== 0) { n2 = 16; goto label_size; } if(s%16== 0) { n2 = 16; goto label_size; }
if(s%7 == 0) { n2 = 7; goto label_size; } if(s%7 == 0) { n2 = 7; goto label_size; }
if(s%8 == 0) { n2 = 8; goto label_size; }
if(s%5 == 0) { n2 = 5; goto label_size; } if(s%5 == 0) { n2 = 5; goto label_size; }
if(s%4 == 0) { n2 = 4; goto label_size; } if(s%4 == 0) { n2 = 4; goto label_size; }
if(s%3 == 0) { n2 = 3; goto label_size; } if(s%3 == 0) { n2 = 3; goto label_size; }

Wyświetl plik

@ -173,6 +173,10 @@ void dft5 (complex_t *x, complex_t* y)
} }
/*******************************************************************************
7 points DFT (Winograd algorithm)
*******************************************************************************/
void dft7 (complex_t *x, complex_t* y) void dft7 (complex_t *x, complex_t* y)
{ {
complex_t sum[31]; complex_t sum[31];
@ -193,6 +197,7 @@ void dft7 (complex_t *x, complex_t* y)
/* Winograd paper mistake?! */ /* Winograd paper mistake?! */
RE(sum[5]) = RE(x[2]) + RE(x[5]); RE(sum[5]) = RE(x[2]) + RE(x[5]);
IM(sum[5]) = IM(x[2]) + IM(x[5]); IM(sum[5]) = IM(x[2]) + IM(x[5]);
/* Winograd paper mistake?! */ /* Winograd paper mistake?! */
RE(sum[6]) = RE(x[2]) - RE(x[5]); RE(sum[6]) = RE(x[2]) - RE(x[5]);
IM(sum[6]) = IM(x[2]) - IM(x[5]); IM(sum[6]) = IM(x[2]) - IM(x[5]);
@ -314,6 +319,60 @@ void dft7 (complex_t *x, complex_t* y)
} }
/*******************************************************************************
8 points DFT
*******************************************************************************/
void dft8 (complex_t *x, complex_t* y)
{
complex_t t0[8];
complex_t t1[8];
double tmp;
transpose2x4(x, t0);
dft4(t0, t1);
dft4(t0+4, t1+4);
/* 0.707106781186548 - 707106781186548i */
tmp = (RE(t1[5]) + IM(t1[5])) * DFT8_W;
IM(t1[5]) = (IM(t1[5]) - RE(t1[5])) * DFT8_W;
RE(t1[5]) = tmp;
/* 0.000000000000000 - 1.000000000000000i */
tmp = RE(t1[6]);
RE(t1[6]) = IM(t1[6]);
IM(t1[6]) = -tmp;
/* -0.707106781186548 - 707106781186548i */
tmp = (IM(t1[7]) - RE(t1[7])) * DFT8_W;
IM(t1[7]) = -(IM(t1[7]) + RE(t1[7])) * DFT8_W;
RE(t1[7]) = tmp;
transpose4x2(t1, t0);
RE(t1[0]) = RE(t0[0]) + RE(t0[1]);
IM(t1[0]) = IM(t0[0]) + IM(t0[1]);
RE(t1[1]) = RE(t0[0]) - RE(t0[1]);
IM(t1[1]) = IM(t0[0]) - IM(t0[1]);
RE(t1[2]) = RE(t0[2]) + RE(t0[3]);
IM(t1[2]) = IM(t0[2]) + IM(t0[3]);
RE(t1[3]) = RE(t0[2]) - RE(t0[3]);
IM(t1[3]) = IM(t0[2]) - IM(t0[3]);
RE(t1[4]) = RE(t0[4]) + RE(t0[5]);
IM(t1[4]) = IM(t0[4]) + IM(t0[5]);
RE(t1[5]) = RE(t0[4]) - RE(t0[5]);
IM(t1[5]) = IM(t0[4]) - IM(t0[5]);
RE(t1[6]) = RE(t0[6]) + RE(t0[7]);
IM(t1[6]) = IM(t0[6]) + IM(t0[7]);
RE(t1[7]) = RE(t0[6]) - RE(t0[7]);
IM(t1[7]) = IM(t0[6]) - IM(t0[7]);
transpose2x4(t1, y);
}
/******************************************************************************* /*******************************************************************************
16 points DFT (Winograd algorithm) 16 points DFT (Winograd algorithm)
*******************************************************************************/ *******************************************************************************/
@ -391,6 +450,42 @@ void dft16 (complex_t *x, complex_t* y)
} }
/*******************************************************************************
4 x 2 matrix transpose
*******************************************************************************/
void transpose4x2(complex_t *x, complex_t* y)
{
RE(y[ 0]) = RE(x[ 0]); IM(y[ 0]) = IM(x[ 0]);
RE(y[ 1]) = RE(x[ 4]); IM(y[ 1]) = IM(x[ 4]);
RE(y[ 2]) = RE(x[ 1]); IM(y[ 2]) = IM(x[ 1]);
RE(y[ 3]) = RE(x[ 5]); IM(y[ 3]) = IM(x[ 5]);
RE(y[ 4]) = RE(x[ 2]); IM(y[ 4]) = IM(x[ 2]);
RE(y[ 5]) = RE(x[ 6]); IM(y[ 5]) = IM(x[ 6]);
RE(y[ 6]) = RE(x[ 3]); IM(y[ 6]) = IM(x[ 3]);
RE(y[ 7]) = RE(x[ 7]); IM(y[ 7]) = IM(x[ 7]);
}
/*******************************************************************************
2 x 4 matrix transpose
*******************************************************************************/
void transpose2x4(complex_t *x, complex_t* y)
{
RE(y[ 0]) = RE(x[ 0]); IM(y[ 0]) = IM(x[ 0]);
RE(y[ 1]) = RE(x[ 2]); IM(y[ 1]) = IM(x[ 2]);
RE(y[ 2]) = RE(x[ 4]); IM(y[ 2]) = IM(x[ 4]);
RE(y[ 3]) = RE(x[ 6]); IM(y[ 3]) = IM(x[ 6]);
RE(y[ 4]) = RE(x[ 1]); IM(y[ 4]) = IM(x[ 1]);
RE(y[ 5]) = RE(x[ 3]); IM(y[ 5]) = IM(x[ 3]);
RE(y[ 6]) = RE(x[ 5]); IM(y[ 6]) = IM(x[ 5]);
RE(y[ 7]) = RE(x[ 7]); IM(y[ 7]) = IM(x[ 7]);
}
/******************************************************************************* /*******************************************************************************
4 x 4 matrix transpose 4 x 4 matrix transpose
*******************************************************************************/ *******************************************************************************/

Wyświetl plik

@ -25,11 +25,11 @@ all: $(EXE_FILES)
$(RELEASE_DIR)/%.exe:$(OBJ_DIR)/%.o $(DSPL_O) $(RELEASE_DIR)/%.exe:$(OBJ_DIR)/%.o $(DSPL_O)
$(CC) $< $(DSPL_O) -o $@ -ldl -lm $(CC) $< $(DSPL_O) -o $@ $(LFLAGS)
$(OBJ_DIR)/%.o:$(SRC_DIR)/%.c $(OBJ_DIR)/%.o:$(SRC_DIR)/%.c
$(CC) $(CFLAGS) $< -o $@ -ldl -lm $(CC) $(CFLAGS) $< -o $@ $(LFLAGS)
$(DSPL_O):$(DSPL_C) $(DSPL_O):$(DSPL_C)
$(CC) $(CFLAGS) $(DSPL_C) -o $(DSPL_O) $(CC) $(CFLAGS) $(DSPL_C) -o $(DSPL_O)

Wyświetl plik

@ -5,8 +5,8 @@
int main() int main()
{ {
void* handle; // DSPL handle void* handle; /* DSPL handle */
handle = dspl_load(); // Load DSPL function handle = dspl_load(); /* Load DSPL function */
double a[5] = {0.0, 1.0, 2.0, 3.0, 4.0}; double a[5] = {0.0, 1.0, 2.0, 3.0, 4.0};
double b[5] = {5.0, 6.0, 7.0, 8.0, 9.0}; double b[5] = {5.0, 6.0, 7.0, 8.0, 9.0};
@ -17,27 +17,27 @@ int main()
err = vector_dot(a, b, 5, &r); err = vector_dot(a, b, 5, &r);
printf("\n\ndot product result: %d a^T * b = %f ", err, r); printf("\n\ndot product result: %d a^T * b = %f ", err, r);
// Concatenate arrays a and b. Result keeps to the array c /* Concatenate arrays a and b. Result keeps to the array c */
err = concat((void*)a, 5*sizeof(double), err = concat((void*)a, 5*sizeof(double),
(void*)b, 5*sizeof(double), (void*)c); (void*)b, 5*sizeof(double), (void*)c);
printf("\n\nconcatenation result: %d\n\narray c = ", err); printf("\n\nconcatenation result: %d\n\narray c = ", err);
for(k = 0; k < 10; k++) for(k = 0; k < 10; k++)
printf("%6.1f", c[k]); printf("%6.1f", c[k]);
// Decimate array c 2 times. Result keeps to the array d /* Decimate array c 2 times. Result keeps to the array d */
err = decimate(c, 10, 2, d, &n); err = decimate(c, 10, 2, d, &n);
printf("\n\ndecimation result: %d\n\narray d = ", err); printf("\n\ndecimation result: %d\n\narray d = ", err);
for (k = 0; k < n; k++) for (k = 0; k < n; k++)
printf("%6.1f", d[k]); printf("%6.1f", d[k]);
// find max abs value /* find max abs value */
double am[5] = {0.0, 2.0, -5.0, 4.0, 2.0}; double am[5] = {0.0, 2.0, -5.0, 4.0, 2.0};
double m; double m;
int ind; int ind;
err = find_max_abs(am, 5, &m, &ind); err = find_max_abs(am, 5, &m, &ind);
printf("\n\nmax absolute value: %8.1f (index %d)", m, ind); printf("\n\nmax absolute value: %8.1f (index %d)", m, ind);
/* Flip in place */
printf("\n\nFlipip function test:\n\n"); printf("\n\nFlipip function test:\n\n");
double x[5] = {0.0, 1.0, 2.0, 3.0, 4.0}; double x[5] = {0.0, 1.0, 2.0, 3.0, 4.0};
int i; int i;
@ -58,8 +58,8 @@ int main()
for(i = 0; i < 5; i++) for(i = 0; i < 5; i++)
printf("%6.1f%+.1fj ", RE(y[i]), IM(y[i])); printf("%6.1f%+.1fj ", RE(y[i]), IM(y[i]));
/* free dspl handle */
dspl_free(handle); // free dspl handle dspl_free(handle);
return err; return err;
} }

Wyświetl plik

@ -42,7 +42,7 @@ int main(int argc, char* argv[])
/* free dspl handle */ /* free dspl handle */
dspl_free(hdspl); dspl_free(hdspl);
return 0; return 0;
} }

Wyświetl plik

@ -3,8 +3,11 @@
#include <string.h> #include <string.h>
#include "dspl.h" #include "dspl.h"
#define ORD 3 /* Filter order */
#define N 1000 #define ORD 3
/* Frequency response vector size */
#define N 1000
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@ -13,42 +16,42 @@ int main(int argc, char* argv[])
void* hplot; /* GNUPLOT handle */ void* hplot; /* GNUPLOT handle */
/* Load DSPL functions */ /* Load DSPL functions */
hdspl = dspl_load(); hdspl = dspl_load();
double a[ORD+1]; /* Коэффициенты числителя H(s) */ double a[ORD+1]; /* H(s) numerator coefficients vector */
double b[ORD+1]; /* Коэффициенты знаменателя H(s) */ double b[ORD+1]; /* H(s) denominator coefficients vector */
double Rp = 1.0; /* Неравномерность АЧХ (к-т передачи на частоте 1 рад/c) */ double Rp = 1.0; /* Magnitude ripple from 0 to 1 rad/s */
double w[N]; /* Циклическая частота рад/c */ double w[N]; /* Angular frequency (rad/s) */
double mag[N]; /* АЧХ фильтра */ double mag[N]; /* Filter Magnitude (dB) */
double phi[N]; /* ФЧХ фильтра */ double phi[N]; /* Phase response */
double tau[N]; /* ГВЗ фильтра */ double tau[N]; /* Group delay */
int k; int k;
/* Расчет коэффициентов фильтра */ /* H(s) coefficients calculation */
int res = butter_ap(Rp, ORD, b, a); int res = butter_ap(Rp, ORD, b, a);
if(res != RES_OK) if(res != RES_OK)
printf("error code = 0x%8x\n", res); printf("error code = 0x%8x\n", res);
/* Печать векторов коэффициентов */ /* Print H(s) coefficients */
for(k = 0; k < ORD+1; k++) for(k = 0; k < ORD+1; k++)
printf("b[%2d] = %9.3f a[%2d] = %9.3f\n", k, b[k], k, a[k]); printf("b[%2d] = %9.3f a[%2d] = %9.3f\n", k, b[k], k, a[k]);
/* Частота в логарифмическом масштабе от 0.01 до 100 рад/с */ /* Frequency in logarithmic scale from 0.01 to 100 rad/s */
logspace(-2.0, 2.0, N , DSPL_SYMMETRIC, w); logspace(-2.0, 2.0, N , DSPL_SYMMETRIC, w);
/* Расчет частотных характеристик рассчитанного фильтра */ /* Filter frequency parameter calculation */
filter_freq_resp(b, a, ORD, w, N, filter_freq_resp(b, a, ORD, w, N,
DSPL_FLAG_LOGMAG|DSPL_FLAG_UNWRAP|DSPL_FLAG_ANALOG, DSPL_FLAG_LOGMAG|DSPL_FLAG_UNWRAP|DSPL_FLAG_ANALOG,
mag, phi, tau); mag, phi, tau);
/* сохранение рассчитанных характеристик в файлы */ /* Write Magnitude, phase response and group delay to the files */
writetxt(w, mag, N, "dat/butter_ap_test_mag.txt"); writetxt(w, mag, N, "dat/butter_ap_test_mag.txt");
writetxt(w, phi, N, "dat/butter_ap_test_phi.txt"); writetxt(w, phi, N, "dat/butter_ap_test_phi.txt");
writetxt(w, tau, N, "dat/butter_ap_test_tau.txt"); writetxt(w, tau, N, "dat/butter_ap_test_tau.txt");
/* plotting by GNUPLOT */ /* plotting by GNUPLOT */
gnuplot_create(argc, argv, 920, 260, "img/butter_ap_test.png", &hplot); gnuplot_create(argc, argv, 920, 260, "img/butter_ap_test.png", &hplot);
gnuplot_cmd(hplot, "set logscale x"); gnuplot_cmd(hplot, "set logscale x");
gnuplot_cmd(hplot, "unset key"); gnuplot_cmd(hplot, "unset key");

Wyświetl plik

@ -3,10 +3,10 @@
#include <string.h> #include <string.h>
#include "dspl.h" #include "dspl.h"
/* Порядок фильтра */ /* Filter order */
#define ORD 4 #define ORD 4
/* размер векторов частотной характеристики фильтра */ /* Frequency response vector size */
#define N 1000 #define N 1000
@ -16,33 +16,33 @@ int main(int argc, char* argv[])
void* hplot; /* GNUPLOT handle */ void* hplot; /* GNUPLOT handle */
hdspl = dspl_load(); /* Load DSPL function */ hdspl = dspl_load(); /* Load DSPL function */
double a[ORD+1]; /* Коэффициенты числителя H(s) */ double a[ORD+1]; /* H(s) numerator coefficients vector */
double b[ORD+1]; /* Коэффициенты знаменателя H(s) */ double b[ORD+1]; /* H(s) denominator coefficients vector */
double Rp = 1.0; /* Неравномерность АЧХ (к-т передачи на частоте 1 рад/c) */ double Rp = 1.0; /* Magnitude ripple from 0 to 1 rad/s */
double w[N]; /* Циклическая частота рад/c */ double w[N]; /* Angular frequency (rad/s) */
double mag[N]; /* АЧХ фильтра */ double mag[N]; /* Filter Magnitude (dB) */
double phi[N]; /* ФЧХ фильтра */ double phi[N]; /* Phase response */
double tau[N]; /* ГВЗ фильтра */ double tau[N]; /* Group delay */
int k; int k;
/* рассчитываем нормированный ФНЧ Чебышева 1 рода */ /* H(s) coefficients calculation */
int res = cheby1_ap(Rp, ORD, b, a); int res = cheby1_ap(Rp, ORD, b, a);
if(res != RES_OK) if(res != RES_OK)
printf("error code = 0x%8x\n", res); printf("error code = 0x%8x\n", res);
/* печать коэффициентов фильтра */ /* Print H(s) coefficients */
for(k = 0; k < ORD+1; k++) for(k = 0; k < ORD+1; k++)
printf("b[%2d] = %9.3f a[%2d] = %9.3f\n", k, b[k], k, a[k]); printf("b[%2d] = %9.3f a[%2d] = %9.3f\n", k, b[k], k, a[k]);
/* вектор частоты в логарифмической шакале от 0.01 до 100 рад/c */ /* Frequency in logarithmic scale from 0.01 to 100 rad/s */
logspace(-2.0, 2.0, N , DSPL_SYMMETRIC, w); logspace(-2.0, 2.0, N , DSPL_SYMMETRIC, w);
/* частотные характеристика фильтра */ /* Filter frequency parameter calculation */
filter_freq_resp(b, a, ORD, w, N, filter_freq_resp(b, a, ORD, w, N,
DSPL_FLAG_LOGMAG|DSPL_FLAG_UNWRAP | DSPL_FLAG_ANALOG, DSPL_FLAG_LOGMAG|DSPL_FLAG_UNWRAP | DSPL_FLAG_ANALOG,
mag, phi, tau); mag, phi, tau);
/* Сохранить характеристики для построения графиков */ /* Write Magnitude, phase response and group delay to the files */
writetxt(w, mag, N, "dat/cheby1_ap_test_mag.txt"); writetxt(w, mag, N, "dat/cheby1_ap_test_mag.txt");
writetxt(w, phi, N, "dat/cheby1_ap_test_phi.txt"); writetxt(w, phi, N, "dat/cheby1_ap_test_phi.txt");
writetxt(w, tau, N, "dat/cheby1_ap_test_tau.txt"); writetxt(w, tau, N, "dat/cheby1_ap_test_tau.txt");

Wyświetl plik

@ -3,23 +3,23 @@
#include <string.h> #include <string.h>
#include "dspl.h" #include "dspl.h"
/* Порядок фильтра */ /* Filter order */
#define ORD 4 #define ORD 4
/* размер векторов частотной характеристики фильтра */ /* Frequency response vector size */
#define N 1000 #define N 1000
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
void* hdspl; /* DSPL handle */ void* hdspl; /* DSPL handle */
void* hplot; /* GNUPLOT handle */ void* hplot; /* GNUPLOT handle */
double a[ORD+1]; /* Коэффициенты числителя H(s) */ double a[ORD+1]; /* H(s) numerator coefficients vector */
double b[ORD+1]; /* Коэффициенты знаменателя H(s) */ double b[ORD+1]; /* H(s) denominator coefficients vector */
double Rs = 60.0; /* Подавление АЧХ в полосе заграждения */ double Rs = 60.0; /* Stopband suppression (dB) */
double w[N]; /* Циклическая частота рад/c */ double w[N]; /* Angular frequency (rad/s) */
double mag[N]; /* АЧХ фильтра */ double mag[N]; /* Filter Magnitude (dB) */
double phi[N]; /* ФЧХ фильтра */ double phi[N]; /* Phase response */
double tau[N]; /* ГВЗ фильтра */ double tau[N]; /* Group delay */
int k; int k;
/* Load DSPL function */ /* Load DSPL function */
@ -30,24 +30,24 @@ int main(int argc, char* argv[])
return -1; return -1;
} }
/* рассчитываем нормированный ФНЧ Чебышева 2 рода */ /* H(s) coefficients calculation */
int res = cheby2_ap(Rs, ORD, b, a); int res = cheby2_ap(Rs, ORD, b, a);
if(res != RES_OK) if(res != RES_OK)
printf("error code = 0x%8x\n", res); printf("error code = 0x%8x\n", res);
/* печать коэффициентов фильтра */ /* Print H(s) coefficients */
for(k = 0; k < ORD+1; k++) for(k = 0; k < ORD+1; k++)
printf("b[%2d] = %9.3f a[%2d] = %9.3f\n", k, b[k], k, a[k]); printf("b[%2d] = %9.3f a[%2d] = %9.3f\n", k, b[k], k, a[k]);
/* вектор частоты в логарифмической шакале от 0.01 до 100 рад/c */ /* Frequency in logarithmic scale from 0.01 to 100 rad/s */
logspace(-2.0, 2.0, N , DSPL_SYMMETRIC, w); logspace(-2.0, 2.0, N , DSPL_SYMMETRIC, w);
/* частотные характеристика фильтра */ /* Filter frequency parameter calculation */
filter_freq_resp(b, a, ORD, w, N, filter_freq_resp(b, a, ORD, w, N,
DSPL_FLAG_LOGMAG|DSPL_FLAG_UNWRAP | DSPL_FLAG_ANALOG, DSPL_FLAG_LOGMAG|DSPL_FLAG_UNWRAP | DSPL_FLAG_ANALOG,
mag, phi, tau); mag, phi, tau);
/* Сохранить характеристики для построения графиков */ /* Write Magnitude, phase response and group delay to the files */
writetxt(w, mag, N, "dat/cheby2_ap_test_mag.txt"); writetxt(w, mag, N, "dat/cheby2_ap_test_mag.txt");
writetxt(w, phi, N, "dat/cheby2_ap_test_phi.txt"); writetxt(w, phi, N, "dat/cheby2_ap_test_phi.txt");
writetxt(w, tau, N, "dat/cheby2_ap_test_tau.txt"); writetxt(w, tau, N, "dat/cheby2_ap_test_tau.txt");

Wyświetl plik

@ -3,26 +3,31 @@
#include <string.h> #include <string.h>
#include "dspl.h" #include "dspl.h"
/* DFT size */
#define N 16 #define N 16
int main() int main()
{ {
void* handle; // DSPL handle void* handle; /* DSPL handle */
handle = dspl_load(); // Load DSPL function handle = dspl_load(); /* Load DSPL function */
double x[N]; /* real input signal */
double x[N]; // real input signal complex_t y[N]; /* DFT vector */
complex_t y[N]; // DFT
int k; int k;
/* fill input signal */
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
x[k] = (double)k; x[k] = (double)k;
/* DFT calculation */
dft(x, N, y); dft(x, N, y);
/* Print result */
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
printf("y[%2d] = %9.3f%9.3f\n", k, RE(y[k]), IM(y[k])); printf("y[%2d] = %9.3f%9.3f\n", k, RE(y[k]), IM(y[k]));
dspl_free(handle); // remember to free the resource /* remember to free the resource */
dspl_free(handle);
return 0; return 0;
} }

Wyświetl plik

@ -3,10 +3,10 @@
#include <string.h> #include <string.h>
#include "dspl.h" #include "dspl.h"
/* Порядок фильтра */ /* Filter order */
#define ORD 4 #define ORD 4
/* размер векторов частотной характеристики фильтра */ /* Frequency response vector size */
#define N 1000 #define N 1000
@ -16,34 +16,34 @@ int main(int argc, char* argv[])
void* hplot; /* GNUPLOT handle */ void* hplot; /* GNUPLOT handle */
hdspl = dspl_load(); /* Load DSPL function */ hdspl = dspl_load(); /* Load DSPL function */
double a[ORD+1]; /* Коэффициенты числителя H(s) */ double a[ORD+1]; /* H(s) numerator coefficients vector */
double b[ORD+1]; /* Коэффициенты знаменателя H(s) */ double b[ORD+1]; /* H(s) denominator coefficients vector */
double Rp = 1.0; /* Неравномерность АЧХ (к-т передачи на частоте 1 рад/c) */ double Rp = 1.0; /* Magnitude ripple from 0 to 1 rad/s */
double Rs = 60.0;/* Подавление в полосе заграждения (дБ) */ double Rs = 60.0;/* Stopband suppression (dB) */
double w[N]; /* Циклическая частота рад/c */ double w[N]; /* Angular frequency (rad/s) */
double mag[N]; /* АЧХ фильтра */ double mag[N]; /* Filter Magnitude (dB) */
double phi[N]; /* ФЧХ фильтра */ double phi[N]; /* Phase response */
double tau[N]; /* ГВЗ фильтра */ double tau[N]; /* Group delay */
int k; int k;
/* рассчитываем нормированный ФНЧ Чебышева 1 рода */ /* H(s) coefficients calculation */
int res = ellip_ap(Rp, Rs, ORD, b, a); int res = ellip_ap(Rp, Rs, ORD, b, a);
if(res != RES_OK) if(res != RES_OK)
printf("error code = 0x%8x\n", res); printf("error code = 0x%8x\n", res);
/* печать коэффициентов фильтра */ /* Print H(s) coefficients */
for(k = 0; k < ORD+1; k++) for(k = 0; k < ORD+1; k++)
printf("b[%2d] = %9.3f a[%2d] = %9.3f\n", k, b[k], k, a[k]); printf("b[%2d] = %9.3f a[%2d] = %9.3f\n", k, b[k], k, a[k]);
/* вектор частоты в логарифмической шакале от 0.01 до 100 рад/c */ /* Frequency in logarithmic scale from 0.01 to 100 rad/s */
logspace(-2.0, 2.0, N , DSPL_SYMMETRIC, w); logspace(-2.0, 2.0, N , DSPL_SYMMETRIC, w);
/* частотные характеристика фильтра */ /* Filter frequency parameter calculation */
filter_freq_resp(b, a, ORD, w, N, filter_freq_resp(b, a, ORD, w, N,
DSPL_FLAG_LOGMAG|DSPL_FLAG_UNWRAP | DSPL_FLAG_ANALOG, DSPL_FLAG_LOGMAG|DSPL_FLAG_UNWRAP | DSPL_FLAG_ANALOG,
mag, phi, tau); mag, phi, tau);
/* Сохранить характеристики для построения графиков */ /* Write Magnitude, phase response and group delay to the files */
writetxt(w, mag, N, "dat/ellip_ap_test_mag.txt"); writetxt(w, mag, N, "dat/ellip_ap_test_mag.txt");
writetxt(w, phi, N, "dat/ellip_ap_test_phi.txt"); writetxt(w, phi, N, "dat/ellip_ap_test_phi.txt");
writetxt(w, tau, N, "dat/ellip_ap_test_tau.txt"); writetxt(w, tau, N, "dat/ellip_ap_test_tau.txt");

Wyświetl plik

@ -3,38 +3,37 @@
#include <string.h> #include <string.h>
#include "dspl.h" #include "dspl.h"
/* FFT size */
#define N 18 #define N 18
int main() int main()
{ {
void* handle; // DSPL handle void* handle; /* DSPL handle */
handle = dspl_load(); // Загрузка DSPL handle = dspl_load(); /* Load libdspl */
complex_t x[N]; /* Input signal array */
complex_t x[N]; // массив входного сигнала complex_t y[N]; /* Output signal array */
complex_t y[N]; // массив результата БПФ fft_t pfft = {0}; /* FFT object (fill zeros) */
fft_t pfft; // FFT объект
int k; int k;
memset(&pfft, 0, sizeof(fft_t)); // Заполняем FFT структуру нулями /* Fill FFT structure */
fft_create(&pfft, N);
fft_create(&pfft, N); // Создаем FFT структуру для длины N /* Fill input signal x[k] = exp(j*k) */
// заполняем массив входного сигнала
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
{ {
RE(x[k]) = (double)cos((double)k); RE(x[k]) = (double)cos((double)k);
IM(x[k]) = (double)sin((double)k); IM(x[k]) = (double)sin((double)k);
} }
fft_cmplx(x, N, &pfft, y); // FFT /* FFT */
fft_cmplx(x, N, &pfft, y);
// Печать результата /* print result */
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
printf("y[%2d] = %9.3f%9.3f\n", k, RE(y[k]), IM(y[k])); printf("y[%2d] = %9.3f%9.3f\n", k, RE(y[k]), IM(y[k]));
fft_free(&pfft); // Очищаем структуру fft_t fft_free(&pfft); /* Clear fft_t object */
dspl_free(handle); // Очищаем dspl handle dspl_free(handle); /* Clear DSPL handle */
return 0; return 0;
} }

Wyświetl plik

@ -3,35 +3,37 @@
#include <string.h> #include <string.h>
#include "dspl.h" #include "dspl.h"
/* FFT size */
#define N 14 #define N 14
int main() int main()
{ {
void* handle; // DSPL handle void* handle; /* DSPL handle */
handle = dspl_load(); // Загрузка DSPL handle = dspl_load(); /* Load libdspl */
double x[N]; /* Input signal array */
double x[N]; // массив входного сигнала complex_t y[N]; /* Output signal array */
complex_t y[N]; // массив результата БПФ fft_t pfft = {0}; /* FFT object (fill zeros) */
fft_t pfft; // FFT объект
int k; int k;
memset(&pfft, 0, sizeof(fft_t)); // Заполняем FFT структуру нулями
/* Fill FFT structure */
fft_create(&pfft, N);
fft_create(&pfft, N); // Создаем FFT структуру для длины N /* Fill input signal x[k] = k */
// заполняем массив входного сигнала
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
x[k] = (double)k; x[k] = (double)k;
fft(x, N, &pfft, y); // FFT /* FFT */
fft(x, N, &pfft, y);
// Печать результата /* print result */
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
printf("y[%2d] = %9.3f%9.3f\n", k, RE(y[k]), IM(y[k])); printf("y[%2d] = %9.3f%9.3f\n", k, RE(y[k]), IM(y[k]));
fft_free(&pfft); // Очищаем структуру fft_t fft_free(&pfft); /* Clear fft_t object */
dspl_free(handle); // Очищаем dspl handle dspl_free(handle); /* Clear DSPL handle */
return 0; return 0;
} }

Wyświetl plik

@ -7,28 +7,33 @@
int main() int main()
{ {
void* handle; // DSPL handle void* handle; /* DSPL handle */
handle = dspl_load(); // Load DSPL function handle = dspl_load(); /* Load DSPL function */
complex_t x[N]; // complex input signal complex_t x[N]; /* complex input signal */
complex_t y[N]; // DFT complex_t y[N]; /* DFT */
complex_t z[N]; // IDFT complex_t z[N]; /* IDFT */
int k; int k;
/* Fill input signal */
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
{ {
RE(x[k]) = (double)k; RE(x[k]) = (double)k;
IM(x[k]) = 0.0; IM(x[k]) = 0.0;
} }
/* DFT */
dft_cmplx(x,N,y); dft_cmplx(x,N,y);
/* IDFT */
idft_cmplx(y,N,z); idft_cmplx(y,N,z);
/* print result */
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
printf("x[%2d] = %9.3f%+9.3fj, z[%2d] = %9.3f%+9.3f\n", printf("x[%2d] = %9.3f%+9.3fj, z[%2d] = %9.3f%+9.3f\n",
k, RE(x[k]), IM(x[k]), k, RE(z[k]), IM(z[k])); k, RE(x[k]), IM(x[k]), k, RE(z[k]), IM(z[k]));
dspl_free(handle); // remember to free the resource dspl_free(handle); /* remember to free the resource */
return 0; return 0;
} }

Wyświetl plik

@ -7,38 +7,39 @@
int main() int main()
{ {
void* handle; // DSPL handle void* handle; /* DSPL handle */
handle = dspl_load(); // Загрузка DSPL handle = dspl_load(); /* Load libdspl */
complex_t x[N]; /* Input signal array */
complex_t x[N]; // массив входного сигнала complex_t y[N]; /* FFT Output signal array */
complex_t y[N]; // массив результата БПФ complex_t z[N]; /* IFFT Output signal array */
complex_t z[N]; // массив результата ОБПФ fft_t pfft = {0}; /* FFT object (fill zeros) */
fft_t pfft; // FFT объект
int k; int k;
memset(&pfft, 0, sizeof(fft_t)); // Заполняем FFT структуру нулями /* Fill FFT structure */
fft_create(&pfft, N);
fft_create(&pfft, N); // Создаем FFT структуру для длины N
/* Fill input signal x[k] = exp(j*k) */
// заполняем массив входного сигнала
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
{ {
RE(x[k]) = (double)cos((double)k); RE(x[k]) = (double)cos((double)k);
IM(x[k]) = (double)sin((double)k); IM(x[k]) = (double)sin((double)k);
} }
fft_cmplx(x, N, &pfft, y); // FFT /* FFT */
fft_cmplx(x, N, &pfft, y);
ifft_cmplx(y, N, &pfft, z); // IFFT
// Печать результата /* FFT */
ifft_cmplx(y, N, &pfft, z);
/* print result */
for(k = 0; k < N; k++) for(k = 0; k < N; k++)
{ {
printf("| x[%2d] = %9.3f%9.3f ", k, RE(x[k]), IM(x[k])); printf("| x[%2d] = %9.3f%9.3f ", k, RE(x[k]), IM(x[k]));
printf("| y[%2d] = %9.3f%9.3f ", k, RE(y[k]), IM(y[k])); printf("| y[%2d] = %9.3f%9.3f ", k, RE(y[k]), IM(y[k]));
printf("| z[%2d] = %9.3f%9.3f |\n", k, RE(z[k]), IM(z[k])); printf("| z[%2d] = %9.3f%9.3f |\n", k, RE(z[k]), IM(z[k]));
} }
fft_free(&pfft); // Очищаем структуру fft_t fft_free(&pfft); /* Clear fft_t object */
dspl_free(handle); // Очищаем dspl handle dspl_free(handle); /* Clear DSPL handle */
return 0; return 0;
} }