24小时热门版块排行榜    

CyRhmU.jpeg
查看: 871  |  回复: 5

sitp_710

铁虫 (小有名气)

[求助] 编译提示"vector.h"无法找到,大家能帮测试下这个小波变换程序吗?已有3人参与

在网站上找到了个二进小波变换程序,想学些下,在VC6.0和VS2010环境下都提示无法找到Vector.h的编译错误,大家能帮我看看问题出在哪里吗?谢谢!
程序我贴在下面,也可参考原网站:http://my.oschina.net/zmjerry/blog/8503

头文件:

/*
* Copyright (c) 2008-2011 Zhang Ming (M. Zhang), zmjerry@163.com
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 2 or any later version.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
*    this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. A copy of the GNU General Public License is available at:
* http://www.fsf.org/licensing/licenses
*/


/*****************************************************************************
*                                    bwt.h
*
* Dyadic Wavelet Transform.
*
* These routines are designed for computing the dyadic wavelet transform
* and it's inverse transform using quadratic spline wavelet.
*
* To distinguish with the "dwt" (discrete wavelet transform), we call this
* file as "bwt", but in fact, it should be dyadic wavelet transform.                                                                                 *
*
* Zhang Ming, 2010-03, Xi'an Jiaotong University.
*****************************************************************************/


#ifndef BWT_H
#define BWT_H


#include <vector.h>
#include <utilities.h>


namespace splab
{

    template<typename Type> Vector< Vector<Type> > bwt( const Vector<Type>&,
                                                        int );
    template<typename Type> Vector<Type> ibwt( const Vector< Vector<Type> >&,
                                               int );


    #include <bwt-impl.h>

}
// namespace splab


#endif
// BWT_H
实现文件:

/*
* Copyright (c) 2008-2011 Zhang Ming (M. Zhang), zmjerry@163.com
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 2 or any later version.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
*    this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. A copy of the GNU General Public License is available at:
* http://www.fsf.org/licensing/licenses
*/


/*****************************************************************************
*                                  bwt-impl.h
*
* Implementation for Dyadic Wavelet Transform.
*
* Zhang Ming, 2010-03, Xi'an Jiaotong University.
*****************************************************************************/


/**
* Forward Transform.
* The decomposition levels is specified by integer "J". The decomposed
* coefficients are stroed in a "Vector< vector<Type> >" structure.
* Detial coefficients are stored from 1st to Jth row, and approximation
* coefficients are stored at the last row, i.e. the (J+1)th row.
*/
template <typename Type>
Vector< Vector<Type> > bwt( const Vector<Type> &xn, int J )
{
    // lowpass decomposition filter
    Vector<Type> ld(4);
    ld[0] = 0.125;                ld[1] = 0.375;
    ld[2] = 0.375;                ld[3] = 0.125;
    ld = Type(RT2) * ld;
    int ldZeroStart = 1;

    // highpass decomposition filter
    Vector<Type> hd(2);
    hd[0] = -0.5;                hd[1] = 0.5;
    hd = Type(RT2) * hd;
    int hdZeroStart = 0;

    // initializing the coefficients
    int N = xn.size();
    Vector< Vector<Type> > coefs(J+1);
    for( int i=0; i<J; ++i )
        coefs.resize(N);

    Vector<Type> approx(N);
    Vector<Type> a(xn);

    // get the inversion of filters
    Vector<Type> ll = flip(ld);
    Vector<Type> hh = flip(hd);

    int llZeroStart = 0,
        hhZeroStart = 0,
        p = 1;

    for( int j=0; j<J; ++j )
    {
        // compute the 0 position of the new filters
        llZeroStart = ll.size()-1 - p*ldZeroStart;
        hhZeroStart = hh.size()-1 - p*hdZeroStart;

        for( int i=0; i<N; ++i )
        {
            Type sum = 0;

            // compute the approximation coefficients
            for( int k=0; k<ll.size(); k+=p )
            {
                int index = mod( i+llZeroStart-k, N );
                sum += ll[k]*a[index];
            }
            approx = sum;

            // compute the detial coefficients
            sum = 0;
            for( int k=0; k<hh.size(); k+=p )
            {
                int index = mod( i+hhZeroStart-k, N );
                sum += hh[k]*a[index];
            }
            coefs[j] = sum;
        }

        a = approx;

        // dyadic upsampling
        ll = dyadUp( ll, 1 );
        hh = dyadUp( hh, 1 );
        p *= 2;
    }

    coefs[J] = approx;
    return coefs;
}


/**
* Backword Transform.
* The reconstruction livel is specified by integer "level", and
* "levle" should between "0"(the approximation component) and "J"
* (the original signal).
*/
template <typename Type>
Vector<Type> ibwt( const Vector< Vector<Type> > &coefs, int level )
{
    Vector<Type> lr(4);
    lr[0] = 0.125;                lr[1] = 0.375;
    lr[2] = 0.375;                lr[3] = 0.125;
    lr = Type(RT2) * lr;
    int lrZeroStart = 1;

    Vector<Type> hr(6);
    hr[0] =        -0.03125;        hr[1] = -0.21875;        hr[2] = -0.6875;
    hr[3] = 0.6875;                hr[4] = 0.21875;        hr[5] = 0.03125;
    hr = Type(RT2) * hr;
    int hrZeroStart = 2;

    int J = coefs.dim() - 1;
    if( (level < 0) || (level > J) )
    {
        cout << "invalid reconstruction level!" << endl;
        return Vector<Type>(0);
    }

    int N = coefs[0].dim();
    Vector<Type> a = coefs[J];
    Vector<Type> xn(N);

    Vector<Type> ll = lr;
    Vector<Type> hh = hr;
    int llZeroStart = 0;
    int hhZeroStart = 0;
    int p = 1;

    // get the Jth level filters
    for( int j=0; j<level-1; ++j )
    {
        p *= 2;
        ll = dyadUp( ll, 1 );
        hh = dyadUp( hh, 1 );
    }

    for( int j=level-1; j>=0; --j )
    {
        // compute the 0 position of the new filters
        llZeroStart = p*lrZeroStart;
        hhZeroStart = p*hrZeroStart;

        // compute the jth approximation coefficients
        for( int i=0; i<N; ++i )
        {
            Type sum = 0;
            for( int k=0; k<ll.size(); k+=p )
            {
                int index = mod( i+llZeroStart-k, N );
                sum += ll[k]*a[index];
            }

            for( int k=0; k<hh.size(); k+=p )
            {
                int index = mod( i+hhZeroStart-k, N );
                sum += hh[k]*coefs[j][index];
            }

            xn = sum/2;
        }

        a = xn;

        // dyadic downsampling
        ll = dyadDown( ll, 0 );
        hh = dyadDown( hh, 0 );
        p /= 2;
    }

    return xn;
}
测试代码:

/*****************************************************************************
*                               bwt_test.cpp
*
* Dyadic wavelet transform testing.
*
* Zhang Ming, 2010-03, Xi'an Jiaotong University.
*****************************************************************************/


#define BOUNDS_CHECK

#include <iostream>
#include <bwt.h>
#include <timing.h>


using namespace std;
using namespace splab;


const int Ls = 100;


int main()
{

    /************************** [ signal ] *************************/
    Vector<double> s(Ls);
    for(int i=0; i<Ls; i++)
    {
        if(i<Ls/4)
            s = 0.0;
        else if(i<2*Ls/4)
            s = 1.0;
        else if(i<3*Ls/4)
            s = 3.0;
        else
            s = 0.0;
    }

    /*************************** [ BWT ] ***************************/
    int level = 3;
    Timing cnt;
    double runtime = 0.0;
    cout << "Taking dyadic wavelet transform." << endl;
    cnt.start();
    Vector< Vector<double> > coefs = bwt( s, level );
    cnt.stop();
    runtime = cnt.read();
    cout << "The running time = " << runtime << " (s)" << endl << endl;

    /*************************** [ IBWT ] **************************/
    cout << "Taking inverse dyadic wavelet transform." << endl;
    cnt.start();
    Vector<double> x = ibwt( coefs, level );
    cnt.stop();
    runtime = cnt.read();
    cout << "The running time = " << runtime << " (s)" << endl << endl;

    cout << "The relative error is : norm(s-x) / norm(s) = "
         << norm(s-x)/norm(s) << endl << endl;

    return 0;
}
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

fxj126

木虫 (小有名气)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
sitp_710: 金币+10, ★★★很有帮助, 感谢答复 2016-05-28 08:35:23
直接#include<vector>试试?
2楼2016-05-27 16:30:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

sitp_710

铁虫 (小有名气)

引用回帖:
2楼: Originally posted by fxj126 at 2016-05-27 16:30:19
直接#include<vector>试试?

感谢答复!在bwt.h头文件中,改写为include<vector>,找不到vector.h的编译错误没有了,又出现如下一些错误提示:
错误        1        error C1083: 无法打开包括文件:“utilities.h”: No such file or directory
        2        IntelliSense: 无法打开 源 文件 "timing.h"       
        3        IntelliSense: 未定义标识符 "Vector"       
还有一些其他的错误,请问这几个头文件是编译器提供公有的,还是原作者编写的但没有提供的头文件?谢谢!
编译提示"vector.h"无法找到,大家能帮测试下这个小波变换程序吗?
错误提示.JPG

3楼2016-05-28 08:43:26
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wruieasy

铁虫 (初入文坛)

【答案】应助回帖

是不是忘记下载vector.h和vector.cpp了?Vecotr类在vector.h被定义?
4楼2016-05-31 22:06:56
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

林坑帕克

新虫 (初入文坛)

【答案】应助回帖

是不是忘记下载vector.h和vector.cpp了?Vecotr类在vector.h被定义?
5楼2016-11-23 11:24:34
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

sitp_710

铁虫 (小有名气)

是的,我已解决,后来找到这个文件了!

发自小木虫Android客户端
6楼2016-11-23 14:08:05
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 sitp_710 的主题更新
信息提示
请填处理意见