/* PLSI: Probabilistic Latent Semantic Indexing Tool $Id: common.h,v 1.3 2002/06/15 17:57:09 taku-ku Exp $; Copyright (C) 2002 Taku Kudo All rights reserved. This is free software with ABSOLUTELY NO WARRANTY. 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 of the License, or (at your option) any later version. 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. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifndef PLSI_COMMON_H #define PLSI_COMMON_H // file suffix rule for each matrix #define PDZ_SUFFIX "pdz" #define PZD_SUFFIX "pzd" #define PWZ_SUFFIX "pwz" #define PZW_SUFFIX "pzw" #define PZ_SUFFIX "pz" #define PD_SUFFIX "pd" #define PW_SUFFIX "pw" // informations of this program #define COPYRIGHT "plsi - PLSI package\nCopyright (C) 2000-2003 Taku Kudo, All rights reserved.\n" template inline T _min (T x, T y) { return (x < y) ? x : y; } template inline T _max (T x, T y) { return (x > y) ? x : y; } #define MAXLEN 1024 // tricky macro for MSVC #ifdef _MSC_VER #define for if (0); else for #endif #include template inline T* _resize (T* ptr, int n, int l, T v) { T *dst = new T [l]; memcpy ((void *)dst, (void *)ptr, sizeof(T)*n); for (int i = n; i < l; i++) dst[i] = v; delete [] ptr; return dst; } template inline T* _append (T* ptr, int n, T v1, T v2) { if (n % MAXLEN == 0) ptr = _resize (ptr, n, n + MAXLEN, v2); ptr[n] = v1; return ptr; } #endif