Home | Develop | Download | Contact
example_vector_dsp.cpp
1
60#include <Pds/Ra>
61#include <cmath>
62
63int main(void)
64{
66 Pds::Vector A("1 -1 5 -1 1 2 -1");
67 Pds::Vector B("1 2 3");
68
69 A.T().Print("\nA.T():\n"); // Transpose of A
70 B.T().Print("\nB.T():\n"); // Transpose of B
71
72
73 R=A.Conv(B); // Conv(A,B)
74 R.T().Print("\nA.Conv(B).T():\n");
75
76 R=A.Conv1D(B,1,Pds::Ra::Full); // Conv(A,B)
77 R.T().Print("\nA.Conv1D(B,2,Pds::Ra::Full).T():\n");
78
79 R=A.Conv(B,Pds::Ra::Same); // Conv(A,B) with size of A
80 R.T().Print("\nA.Conv(B,Pds::Ra::Same).T():\n");
81
82 R=A.Conv1D(B,1,Pds::Ra::Same); // Conv(A,B) with size of A
83 R.T().Print("\nA.Conv1D(B,1,Pds::Ra::Same).T():\n");
84 std::cout<<Pds::Vector::Conv1DOutputSize(A.Nlin(),B.Nlin(),1,Pds::Ra::Same)<<"\n";
85
86 R=A.Conv1D(B,1,Pds::Ra::Full); // Conv(A,B) with size of A
87 R.T().Print("\nA.Conv1D(B,1,Pds::Ra::Full).T():\n");
88 std::cout<<Pds::Vector::Conv1DOutputSize(A.Nlin(),B.Nlin(),1,Pds::Ra::Full)<<"\n";
89
90 R=A.Conv1D(B,1,Pds::Ra::Valid); // Conv(A,B) with size of A
91 R.T().Print("\nA.Conv1D(B,1,Pds::Ra::Valid).T():\n");
92 std::cout<<Pds::Vector::Conv1DOutputSize(A.Nlin(),B.Nlin(),1,Pds::Ra::Valid)<<"\n";
93
94 R=A.XCorr(B); // XConv(A,B)
95 R.T().Print("\nA.XCorr(B).T():\n");
96
97 R=A.XCorr(B,true); // XConv(A,B) with size of A
98 R.T().Print("\nA.XCorr(B,true).T():\n");
99
100 std::vector<Pds::Vector> Block;
102 A.T().Print("\nA.T():\n"); // Transpose of A
103 Block[0].T().Print("Block[0].T():\t");
104 Block[1].T().Print("Block[1].T():\t");
105
106 Pds::Vector::FlattenVectorBlock(Block).T().Print("Pds::Vector::FlattenVectorBlock(Block).T():\t");
107 return 0;
108}
La clase tipo Pds::Vector . Esta clase genera una matriz de Nlin lineas y 1 columna....
Definition: Vector.hpp:80
Pds::Matrix T(void) const
Transpuesta de si mismo (A), el resultado es cargado en B.
void Print(const std::string &str, unsigned int precision) const
Imprime en pantalla el contenido de la matriz después del texto indicado en str.
Pds::Vector Conv(const Pds::Vector &B, Pds::Ra::Padding Padding=Pds::Ra::Full) const
Calcula la convolución entre A y B.
Pds::Vector Conv1D(const Pds::Vector &B, unsigned int Stride=1, Pds::Ra::Padding Padding=Pds::Ra::Full) const
Calcula la convolución entre A y B.
static std::vector< Pds::Vector > MaxPoolingVectorBlock(const std::vector< Pds::Vector > &A, unsigned int LinPool)
Aplica max pooling a cada matriz de lineas y columnas.
static Pds::Vector FlattenVectorBlock(const std::vector< Pds::Vector > &Block)
Convierte a Pds::Vector un VectorBlock.
static Pds::Size Conv1DOutputSize(unsigned int Anlin, unsigned int Bnlin, unsigned int Stride, Pds::Ra::Padding Padding)
Calcula el tamaño de la matriz resultado de la convolucion de A y B.
Pds::Vector XCorr(const Pds::Vector &B, bool Same=false) const
Calcula la correlacion cruzada entre A y B.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed