⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.c

📁 大师写的二代小波经典之作
💻 C
字号:
/* *  -*- Mode: ANSI C -*- *  $Id: util.c,v 1.4 1996/08/16 17:25:54 fernande Exp $ *  $Source: /sgi.acct/sweldens/cvs/liftpack/Util/util.c,v $ *  Author: Gabriel Fernandez * *  This file contains the definition of useful mathematical and *  general comparison functions. *//* do not edit anything above this line *//* System header files */#include <assert.h>#include <math.h>#include <stdio.h>/* FLWT header files */#include <constant.h>#include <flwtdef.h>#include <memchk.h>#include <util.h>/* code */Fltmin3( Flt a, Flt b, Flt c ){    Flt m = MIN( a, b );    return MIN( m, c );}Fltmax3( Flt a, Flt b, Flt c ){    Flt m = MAX( a, b );    return MAX( m, c );}Fltmin4( Flt a, Flt b, Flt c, Flt d ){    Flt m = MIN( a, b );    m = MIN( m, c );    return MIN( m, d );}Fltmax4( Flt a, Flt b, Flt c, Flt d ){    Flt m = MAX( a, b );    m = MAX( m, c );    return MAX( m, d );}intzeroEps( const Flt x, const Flt eps ){    return ( -eps < x ) && ( x < eps );}intzero( const Flt x ){    const Flt __negeps_f = (Flt)-100 * m_eps_f;    const Flt __poseps_f = (Flt) 100 * m_eps_f;    return ( __negeps_f < x ) && ( x < __poseps_f );}FltlogBaseN( const Flt x, const Flt n ){    return ( (Flt)((Flt)log((Flt)x)/(Flt)log((Flt)n)) );}/* should be called only for positive powers of two */int logbasetwo( int x ){    int ret = 0;      /* must be positive */    assert( x > 0 );    while( !(x & 1) ){        x >>= 1;        ret++;    }      /* must have been a power of two */    assert( x == 1 );    return ret;}/* true if x >=0 and x is a power of two */int ispoweroftwo( int x ){    if( !x ) return 1;    assert( x > 0 );    while( !(x & 1) )        x >>= 1;    return x == 1;}/* given x, returns 2^ceil(log_2 x) */int nextpoweroftwo( int x ){    int ret = 1;    if( !x ) return 0;    assert( x > 0 );      while( ret < x )        ret <<= 1;    return ret;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -