![]() |
Blitz Devel : |
From: Carlos Silva (cas_at_[hidden])
Date: 1998-07-25 19:04:20
Hi,
I would appreciate a lot if someone could give a hint in
how to solve the following problem. In the example I give
below I succeded to compile the program till I got the
expression ["a= sum(A(Range(0, 5))*A(Range(10,15)));"] and
put it in a function then I couldn't compile any more my
example.
Am I forgetting anything?
Thanks in advance for any help.
Carlos Silva.
//////////////////////////////////
#include <blitz/array.h>
using namespace blitz;
void autoCorr(const blitz::Array<float, 1>& frame,
int n_point, blitz::Array<float, 1>& coef);
int main(void)
{
Array<float, 1> A(20), coef(5);
float a;
A(Range(0, 9))= 1.0;
A(Range(10,19))= 2.0;
// Does exactly the same as autoCorr. No problem compiling!
a= sum(A(Range(0, 5))*A(Range(10,15)));
// I can't compile this function (autoCorr).
autoCorr(A, 5, coef);
cout << "A= " << A << endl;
cout << "a= " << a << endl;
return 0;
}
void autoCorr(const blitz::Array<float, 1>& frame,
int n_point, blitz::Array<float, 1>& coef)
{
using namespace blitz;
coef.resize(n_point);
for(int n= 0, l= frame.size() - 1; n < n_point; ++n)
coef(n)= sum(frame(Range(0, l-n)) * frame(Range(n, l)));
}
/* ----------------------------- Compile Error Message ----------
"teste.cc", line 32: error: no instance of overloaded function
"blitz::Array<float, 1>::operator()" matches the argument list
argument types are: (blitz::Range)
coef(n)= sum(frame(Range(0, l-n)) * frame(Range(n, l)));
^
"teste.cc", line 32: error: no instance of overloaded function
"blitz::Array<float, 1>::operator()" matches the argument list
argument types are: (blitz::Range)
coef(n)= sum(frame(Range(0, l-n)) * frame(Range(n, l)));
^
"teste.cc", line 32: error: no instance of overloaded function "sum" matches
the argument list
argument types are: (<error-type>)
coef(n)= sum(frame(Range(0, l-n)) * frame(Range(n, l)));
^
3 errors detected in the compilation of "teste.cc".
make: *** [teste.o] Error 2
-------------------------------------------------------------------- */
/* ------------------------------- Makefile ----------------------
CC = KCC
CFLAGS = --restrict --abstract_pointer --abstract_float \
--strict_warnings +K0 -O0
INCPATH = -I/usr/local/include
LINK = KCC
LFLAGS =
LIBS = -lm -L/usr/local/packages/Blitz++/lib -lblitz -lstdc++
####### Files
HEADERS =
SOURCES = teste.cc
OBJECTS = teste.o
TARGET = teste
####### Implicit rules
.SUFFIXES: .cpp .cxx .cc .C .c
.cpp.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
.cxx.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
.cc.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
.C.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
####### Build rules
all: $(TARGET)
$(TARGET): $(OBJECTS) $(OBJMOC)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
clean:
-rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(TARGET)
-rm -f *~ core
####### Compile
teste.o: teste.cc
----------------------------------------------------------- */
--------------------- blitz-dev list --------------------------------
* To subscribe/unsubscribe: mail to majordomo_at_[hidden], with
"subscribe blitz-dev" or "unsubscribe blitz-dev" in the body of the message
* Blitz++ web page: http://oonumerics.org/blitz/