Index: /tags/DPC_V0/Poubelle/PI/Makefile
===================================================================
--- /tags/DPC_V0/Poubelle/PI/Makefile	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/Makefile	(revision 1307)
@@ -0,0 +1,227 @@
+MODULECXXREPNAME := PI
+MODULEDECCXXFLAGS := -msg_quiet
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libPI.a
+$(LIB)libPI.a : $(OBJ)lut.o $(OBJ)parradapter.o $(OBJ)pi3ddrw.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapview.o $(OBJ)picmapx.o $(OBJ)picons.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawer.o $(OBJ)pidrawwin.o $(OBJ)pidrwtools.o $(OBJ)pievthandler.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pigraph3d.o $(OBJ)pigraphgen.o $(OBJ)pigraphps.o $(OBJ)pigraphuc.o $(OBJ)pigraphx.o $(OBJ)piimage.o $(OBJ)piimgtools.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)piperiodx.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)pistzwin.o $(OBJ)pisurfdr.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o
+	$(AR) $(ARFLAGS)  $@ $? 
+ifeq ($(CXX),cxx)
+	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS) -L$(LIB) -lPI -lSysTools -o $(OBJ)xx.x -Hf
+endif 
+ 
+clean:
+	rm -f $(OBJ)lut.o $(OBJ)parradapter.o $(OBJ)pi3ddrw.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapview.o $(OBJ)picmapx.o $(OBJ)picons.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawer.o $(OBJ)pidrawwin.o $(OBJ)pidrwtools.o $(OBJ)pievthandler.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pigraph3d.o $(OBJ)pigraphgen.o $(OBJ)pigraphps.o $(OBJ)pigraphuc.o $(OBJ)pigraphx.o $(OBJ)piimage.o $(OBJ)piimgtools.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)piperiodx.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)pistzwin.o $(OBJ)pisurfdr.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o
+ifeq ($(CXX),cxx)
+	cd $(REPM); rm -f *.o
+endif 
+ 
+$(OBJ)lut.o: lut.cc /home/ansari/DPC/Include/defs.h lut.h
+$(OBJ)parradapter.o: parradapter.cc parradapter.h \
+ /home/ansari/DPC/Include/defs.h /home/ansari/DPC/Include/machine.h \
+ lut.h
+$(OBJ)pi3ddrw.o: pi3ddrw.cc pi3ddrw.h pisysdep.h pidrawer.h pibwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h \
+ picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h pigraphuc.h \
+ pievthandler.h psfile.h pigraph3d.h pibwdgx.h pigraphps.h \
+ pidrwtools.h pistdwdgx.h pistdwdggen.h pioptmenux.h pioptmenugen.h \
+ pimenux.h pimenugen.h piwindowx.h piwindowgen.h picontainerx.h \
+ picontainergen.h piapplx.h piapplgen.h pimenubarx.h pimenubargen.h \
+ picons.h
+$(OBJ)piapplgen.o: piapplgen.cc piapplgen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h pisysdep.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimenubarx.h pimenubargen.h \
+ pimenux.h pimenugen.h picons.h pistdwdgx.h pistdwdggen.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraphps.h
+$(OBJ)piapplx.o: piapplx.cc piapplx.h piapplgen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h pisysdep.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimenubarx.h pimenubargen.h \
+ pimenux.h pimenugen.h picons.h pistdwdgx.h pistdwdggen.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraphps.h
+$(OBJ)pibwdggen.o: pibwdggen.cc pibwdggen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/DPC/Include/defs.h picmap.h picmapx.h \
+ picmapgen.h pigraphx.h pigraphgen.h pigraphuc.h pievthandler.h \
+ psfile.h pidrawer.h pigraphps.h pidrwtools.h pistdwdgx.h \
+ pistdwdggen.h pioptmenux.h pioptmenugen.h pimenux.h pimenugen.h \
+ piwindowx.h piwindowgen.h picontainerx.h picontainergen.h piapplx.h \
+ piapplgen.h pimenubarx.h pimenubargen.h picons.h pibwdgx.h
+$(OBJ)pibwdgx.o: pibwdgx.cc pixtbaseP.h pibwdgx.h pisysdep.h pibwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h \
+ picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h pigraphuc.h \
+ pievthandler.h psfile.h pigraphps.h pixtbase.h
+$(OBJ)picmap.o: picmap.cc picmap.h pisysdep.h picmapx.h picmapgen.h
+$(OBJ)picmapgen.o: picmapgen.cc picmapgen.h pisysdep.h picmapx.h picmap.h
+$(OBJ)picmapview.o: picmapview.cc picmapview.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h picmap.h picmapx.h picmapgen.h \
+ pigraphx.h pigraphgen.h pigraphuc.h pievthandler.h psfile.h \
+ pigraphps.h
+$(OBJ)picmapx.o: picmapx.cc piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h picmapx.h picmapgen.h pisysdep.h
+$(OBJ)picons.o: picons.cc pisysdep.h pimenux.h pimenugen.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h picons.h \
+ pistdwdgx.h pistdwdggen.h picontainerx.h picontainergen.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraphps.h
+$(OBJ)picontainergen.o: picontainergen.cc picontainergen.h pisysdep.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h
+$(OBJ)picontainerx.o: picontainerx.cc picontainerx.h pisysdep.h \
+ picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h
+$(OBJ)pidrawer.o: pidrawer.cc pidrawer.h pibwdggen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pigraphx.h pigraphgen.h pigraphuc.h \
+ pievthandler.h psfile.h
+$(OBJ)pidrawwin.o: pidrawwin.cc pidrawwin.h pisysdep.h piwindowx.h \
+ piwindowgen.h picontainerx.h picontainergen.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/DPC/Include/defs.h piscdrawwdg.h \
+ pibwdgx.h pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h \
+ pigraphgen.h pigraphuc.h pievthandler.h psfile.h pigraphps.h \
+ pistdwdgx.h pistdwdggen.h pidrawer.h
+$(OBJ)pidrwtools.o: pidrwtools.cc pidrwtools.h pisysdep.h pistdwdgx.h \
+ pistdwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h pioptmenux.h pioptmenugen.h pimenux.h \
+ pimenugen.h piwindowx.h piwindowgen.h picontainerx.h picontainergen.h \
+ piapplx.h piapplgen.h pimenubarx.h pimenubargen.h picons.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraphps.h piscdrawwdg.h \
+ pidrawer.h pi3ddrw.h pigraph3d.h
+$(OBJ)pievthandler.o: pievthandler.cc pievthandler.h pisysdep.h \
+ pimsghandler.h /home/ansari/DPC/Include/defs.h piwdgx.h piwdggen.h \
+ pigraphx.h pigraphgen.h picmap.h picmapx.h picmapgen.h
+$(OBJ)pifilechogen.o: pifilechogen.cc pifilechogen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h
+$(OBJ)pifilechox.o: pifilechox.cc pisysdep.h piapplx.h piapplgen.h \
+ pimsghandler.h /home/ansari/DPC/Include/defs.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimenubarx.h pimenubargen.h \
+ pimenux.h pimenugen.h picons.h pistdwdgx.h pistdwdggen.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraphps.h pifilechox.h \
+ pifilechogen.h piwindowx.h piwindowgen.h
+$(OBJ)pigraph3d.o: pigraph3d.cc pigraph3d.h pisysdep.h pigraphuc.h \
+ pigraphgen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h picmap.h picmapx.h picmapgen.h
+$(OBJ)pigraphgen.o: pigraphgen.cc pigraphgen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h
+$(OBJ)pigraphps.o: pigraphps.cc pigraphps.h pisysdep.h pigraphgen.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h psfile.h
+$(OBJ)pigraphuc.o: pigraphuc.cc pigraphuc.h pisysdep.h pigraphgen.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h
+$(OBJ)pigraphx.o: pigraphx.cc pigraphx.h pisysdep.h pigraphgen.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h
+$(OBJ)piimage.o: piimage.cc piimage.h parradapter.h \
+ /home/ansari/DPC/Include/defs.h /home/ansari/DPC/Include/machine.h \
+ lut.h pisysdep.h pidrawer.h pibwdggen.h piwdgx.h piwdggen.h \
+ pimsghandler.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pigraphuc.h pievthandler.h psfile.h pipixmapx.h pipixmapgen.h \
+ pibwdgx.h pigraphps.h pistdwdgx.h pistdwdggen.h piwindowx.h \
+ piwindowgen.h picontainerx.h picontainergen.h picmapview.h \
+ piimgtools.h pioptmenux.h pioptmenugen.h pimenux.h pimenugen.h \
+ piapplx.h piapplgen.h pimenubarx.h pimenubargen.h picons.h \
+ pidrwtools.h
+$(OBJ)piimgtools.o: piimgtools.cc piimgtools.h pisysdep.h pistdwdgx.h \
+ pistdwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h pioptmenux.h pioptmenugen.h pimenux.h \
+ pimenugen.h piwindowx.h piwindowgen.h picontainerx.h picontainergen.h \
+ piapplx.h piapplgen.h pimenubarx.h pimenubargen.h picons.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraphps.h piimage.h \
+ parradapter.h /home/ansari/DPC/Include/machine.h lut.h pidrawer.h \
+ pipixmapx.h pipixmapgen.h picmapview.h
+$(OBJ)pilistgen.o: pilistgen.cc pilistgen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/DPC/Include/defs.h
+$(OBJ)pilistx.o: pilistx.cc pilistx.h pilistgen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h \
+ picontainerx.h picontainergen.h
+$(OBJ)pimenubargen.o: pimenubargen.cc pimenubargen.h pisysdep.h pimenux.h \
+ pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h piapplx.h piapplgen.h picontainerx.h \
+ picontainergen.h pimenubarx.h picons.h pistdwdgx.h pistdwdggen.h \
+ pibwdgx.h pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h \
+ pigraphgen.h pigraphuc.h pievthandler.h psfile.h pigraphps.h
+$(OBJ)pimenubarx.o: pimenubarx.cc pimenubarx.h pimenubargen.h pisysdep.h \
+ pimenux.h pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h piapplx.h piapplgen.h picontainerx.h \
+ picontainergen.h picons.h pistdwdgx.h pistdwdggen.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraphps.h
+$(OBJ)pimenugen.o: pimenugen.cc pimenugen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/DPC/Include/defs.h
+$(OBJ)pimenux.o: pimenux.cc pisysdep.h pimenubarx.h pimenubargen.h pimenux.h \
+ pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h
+$(OBJ)pimsghandler.o: pimsghandler.cc pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h
+$(OBJ)pioptmenugen.o: pioptmenugen.cc pioptmenugen.h pisysdep.h pimenux.h \
+ pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h
+$(OBJ)pioptmenux.o: pioptmenux.cc pisysdep.h pioptmenux.h pioptmenugen.h \
+ pimenux.h pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h pistdwdgx.h pistdwdggen.h piapplx.h \
+ piapplgen.h picontainerx.h picontainergen.h pimenubarx.h \
+ pimenubargen.h picons.h pibwdgx.h pibwdggen.h picmap.h picmapx.h \
+ picmapgen.h pigraphx.h pigraphgen.h pigraphuc.h pievthandler.h \
+ psfile.h pigraphps.h
+$(OBJ)piperiodx.o: piperiodx.cc piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h piperiodx.h \
+ /home/ansari/DPC/Include/periodic.h
+$(OBJ)pipixmapgen.o: pipixmapgen.cc pipixmapgen.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h picmap.h picmapx.h picmapgen.h \
+ pigraphx.h pigraphgen.h pigraphuc.h pievthandler.h psfile.h \
+ pigraphps.h
+$(OBJ)pipixmapx.o: pipixmapx.cc pipixmapx.h pipixmapgen.h pisysdep.h \
+ pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h picmap.h picmapx.h picmapgen.h \
+ pigraphx.h pigraphgen.h pigraphuc.h pievthandler.h psfile.h \
+ pigraphps.h
+$(OBJ)piscdrawwdg.o: piscdrawwdg.cc piscdrawwdg.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h picmap.h picmapx.h picmapgen.h \
+ pigraphx.h pigraphgen.h pigraphuc.h pievthandler.h psfile.h \
+ pigraphps.h pistdwdgx.h pistdwdggen.h piwindowx.h piwindowgen.h \
+ picontainerx.h picontainergen.h pidrawer.h pidrwtools.h pioptmenux.h \
+ pioptmenugen.h pimenux.h pimenugen.h piapplx.h piapplgen.h \
+ pimenubarx.h pimenubargen.h picons.h parradapter.h \
+ /home/ansari/DPC/Include/machine.h lut.h
+$(OBJ)pistdwdggen.o: pistdwdggen.cc pistdwdggen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h
+$(OBJ)pistdwdgx.o: pistdwdgx.cc pisysdep.h pistdwdgx.h pistdwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h
+$(OBJ)pistzwin.o: pistzwin.cc pistzwin.h pisysdep.h piwindowx.h \
+ piwindowgen.h picontainerx.h picontainergen.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/DPC/Include/defs.h piperiodx.h \
+ /home/ansari/DPC/Include/periodic.h psfile.h pigraphgen.h picmap.h \
+ picmapx.h picmapgen.h
+$(OBJ)pisurfdr.o: pisurfdr.cc pisurfdr.h parradapter.h \
+ /home/ansari/DPC/Include/defs.h /home/ansari/DPC/Include/machine.h \
+ lut.h pi3ddrw.h pisysdep.h pidrawer.h pibwdggen.h piwdgx.h piwdggen.h \
+ pimsghandler.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraph3d.h pibwdgx.h pigraphps.h
+$(OBJ)piwdggen.o: piwdggen.cc piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h picontainergen.h pisysdep.h piwdgx.h \
+ pievthandler.h pigraphx.h pigraphgen.h picmap.h picmapx.h picmapgen.h \
+ psfile.h
+$(OBJ)piwdgx.o: piwdgx.cc piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h picontainerx.h pisysdep.h \
+ picontainergen.h pievthandler.h pigraphx.h pigraphgen.h picmap.h \
+ picmapx.h picmapgen.h
+$(OBJ)piwindowgen.o: piwindowgen.cc piwindowgen.h pisysdep.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h psfile.h pigraphgen.h picmap.h \
+ picmapx.h picmapgen.h
+$(OBJ)piwindowx.o: piwindowx.cc piwindowx.h piwindowgen.h pisysdep.h \
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h
+$(OBJ)pixtbase.o: pixtbase.cc pixtbaseP.h pibwdgx.h pisysdep.h pibwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/DPC/Include/defs.h \
+ picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h pigraphuc.h \
+ pievthandler.h psfile.h pigraphps.h pixtbase.h
+$(OBJ)psfile.o: psfile.cc psfile.h /home/ansari/DPC/Include/defs.h \
+ pisysdep.h pigraphgen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \
+ picmapx.h picmapgen.h
Index: /tags/DPC_V0/Poubelle/PI/PI.o.list
===================================================================
--- /tags/DPC_V0/Poubelle/PI/PI.o.list	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/PI.o.list	(revision 1307)
@@ -0,0 +1,50 @@
+lut.o
+parradapter.o
+pi3ddrw.o
+piapplgen.o
+piapplx.o
+pibwdggen.o
+pibwdgx.o
+picmap.o
+picmapgen.o
+picmapview.o
+picmapx.o
+picons.o
+picontainergen.o
+picontainerx.o
+pidrawer.o
+pidrawwin.o
+pidrwtools.o
+pievthandler.o
+pifilechogen.o
+pifilechox.o
+pigraph3d.o
+pigraphgen.o
+pigraphps.o
+pigraphuc.o
+pigraphx.o
+piimage.o
+piimgtools.o
+pilistgen.o
+pilistx.o
+pimenubargen.o
+pimenubarx.o
+pimenugen.o
+pimenux.o
+pimsghandler.o
+pioptmenugen.o
+pioptmenux.o
+piperiodx.o
+pipixmapgen.o
+pipixmapx.o
+piscdrawwdg.o
+pistdwdggen.o
+pistdwdgx.o
+pistzwin.o
+pisurfdr.o
+piwdggen.o
+piwdgx.o
+piwindowgen.o
+piwindowx.o
+pixtbase.o
+psfile.o
Index: /tags/DPC_V0/Poubelle/PI/Tests/Makefile
===================================================================
--- /tags/DPC_V0/Poubelle/PI/Tests/Makefile	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/Tests/Makefile	(revision 1307)
@@ -0,0 +1,59 @@
+MODULECXXREPNAME := PITest
+MODULEDECCXXFLAGS := -msg_quiet
+include $(EROSDEVREP)/Include/Makefile.h
+
+
+ifdef NOSHLIB
+LIBF =  $(LIB)libPI.a $(LIB)libOutils++.a $(LIB)libcoutils.a 
+LIBS = -L$(LIB) -lPI -lOutils++ -lcoutils -lXm -lXt -lX11 -lm
+ifeq ($(CXX),cxx)
+# librairie des instances de templates cxx
+LIBS := $(LIBS) -lertcxx
+endif
+else
+LIBF =  $(SLB)libPI.so $(SLB)libpeida.so $(SLB)liberosc.so 
+LIBS = -L$(SLB) -lPI -lpeida -lerosc -lnr  -lm
+endif
+
+ifeq (${MACHEROS},Linux)
+  LIBS := $(LIBS) -ldl
+endif
+
+ifndef (NOSHLIB)
+LIBS := $(SLIBS) $(LIBS)
+endif
+
+
+LDLIBS := $(LIBS) $(LDLIBS)
+
+%:%.cc
+%:%.o
+%.o:%.cc
+%.o:%.c
+%:%.c
+
+.PRECIOUS: $(EXE)% $(OBJ)%.o
+
+%:$(EXE)%
+	echo $@ " done"
+
+$(EXE)%:$(OBJ)%.o
+	$(LINK.cc)  -o $@ $< $(LIBS)
+
+$(OBJ)%.o:%.cc
+	$(COMPILE.cc)   $(USERFLAGS) -o $@ $<
+
+$(EXE)%:$(OBJ)%.cc
+	$(LINK.cc) $(USERFLAGS)  -o $@ $< $(LIBS) 
+
+$(EXE)%:$(OBJ)%.c
+	$(LINK.c)  $(USERFLAGS) -o $@ $< $(LIBS) 
+
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -c $(CFLAGS) $(USERFLAGS) -o $@ $< 
+
+
+clean:
+	rm -f $(OBJ)pit0.o $(OBJ)pit1.o $(OBJ)pitcons.o $(OBJ)pitgr.o $(OBJ)pitst.o
+	rm -f $(EXE)pit0 $(EXE)pit1 $(EXE)pitcons $(EXE)pitgr $(EXE)pitst
+	if [ -d $(OBJ)cxxrep_PITest ] ; then cd $(OBJ)cxxrep_PITest ; rm -f *.o ; fi
Index: /tags/DPC_V0/Poubelle/PI/Tests/pit0.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/Tests/pit0.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/Tests/pit0.cc	(revision 1307)
@@ -0,0 +1,301 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <iostream.h>
+
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIMENU_H 
+#include PISTDWDG_H 
+#include PIWIN_H
+#include PIPERIODIC_H
+
+//  ----- Declaration de la classe ArgsWind : Fenetre de dialogue -------
+class ArgsWind : public PIWindow {
+public :
+                ArgsWind(PIApplication *par);
+                ~ArgsWind();
+          void  SetLabels(char *lab1, char *lab2, char *lab3);
+          void  SetTexts(char *tx1, char *tx2, char *tx3);
+          void  GetTexts(char *tx1, char *tx2, char *tx3);
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+  PILabel  * mLab[3];
+  PIButton * mBut[2];
+  PIText * mText[3];
+  };
+
+//  ----- Declaration de notre classe PIApplication (PITApp) -------
+class PITApp : public PIApplication {
+public:
+     PITApp(int narg=0, char* arg[]=NULL);
+     ~PITApp();
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+  PILabel *lab;
+
+private :
+  PIMenu * m[2];
+  PIPeriodX mPeriod;
+  ArgsWind *mAW;
+};
+
+
+
+/* ........................................................... */
+/*              Classe ArgsWindow (methodes)                   */
+/* ........................................................... */
+
+
+/* --Methode-- */
+ArgsWind::ArgsWind(PIApplication *par)
+: PIWindow((PIMsgHandler *)par, "Args", PIWK_dialog, 100, 100, 150, 150)
+{
+int bsx, bsy;
+
+// On definit la taille a partir de la taille par defaut des composantes 
+printf("ArgsWind::ArgsWind() \n");
+PIApplicationPrefCompSize(bsx, bsy);
+// On redefinit la taille de la fenetre
+SetSize(bsx*7, bsy*6);
+
+// Creation de champs "labels"
+mLab[0] = new PILabel(this, "UserArg-1:", bsx*2, bsy, bsx/3, bsy/4); 
+mLab[1] = new PILabel(this, "UserArg-2", bsx*2, bsy, bsx/3, bsy/4 + (bsy/4+bsy) );
+mLab[2] = new PILabel(this, "UserArg-3", bsx*2, bsy, bsx/3, bsy/4 + 2*(bsy/4+bsy) );
+
+// Creation de champs textes 
+mText[0] = new PIText(this, "UsArg1", bsx*4, bsy, bsx*2+(bsx*2/3), bsy/4);
+mText[0]->SetText("Hello ");
+mText[1] = new PIText(this, "UsArg2", bsx*4, bsy, bsx*2+(bsx*2/3), bsy/4 + (bsy/4+bsy) );
+mText[1]->SetText("1. -1.");
+mText[2] = new PIText(this, "UsArg3", bsx*4, bsy, bsx*2+(bsx*2/3), bsy/4 + 2*(bsy/4+bsy) );
+mText[2]->SetText("1. -1.");
+
+// Creation de bouton d'action 
+//  Attention : Numero de message pour Process()
+mBut[0] = new PIButton(this, "OK",  555, bsx*2, bsy, bsx, 4.5*bsy);
+mBut[1] = new PIButton(this, "Cancel", 777, bsx*2, bsy, 4*bsx, 4.5*bsy);
+
+//  Taille et position proportionnelles a la taille de la fenetre pour les elements
+for(int i=0; i<3; i++) {
+  mLab[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
+  mText[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
+  }
+for(int ii=0; ii<2; ii++) mBut[ii]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
+
+}
+
+/* --Methode-- */
+ArgsWind::~ArgsWind()
+{
+for(int i=0; i<3; i++)
+  {
+  delete mLab[i];
+  delete mText[i];
+  }
+
+delete mBut[0]; 
+delete mBut[1]; 
+}
+
+/* --Methode-- */
+void ArgsWind::SetLabels(char *lab1, char *lab2, char *lab3)
+// Permet de changer les etiquettes (les label)
+{
+mLab[0]->SetLabel(lab1);
+mLab[1]->SetLabel(lab2);
+mLab[2]->SetLabel(lab3);
+}
+
+/* --Methode-- */
+void ArgsWind::SetTexts(char *tx1, char *tx2, char *tx3)
+// Permet de changer les contenu des champs texte
+{
+mText[0]->SetText(tx1);
+mText[1]->SetText(tx2);
+mText[2]->SetText(tx3);
+
+}
+
+/* --Methode-- */
+void ArgsWind::GetTexts(char *tx1, char *tx2, char *tx3)
+// Permet de recuperer les contenus des champs texte
+// ATTENTION : Il faut qu'il y ait assez de place 
+// ds tx1, tx2, tx3 pour que la fonction puisse y copier 
+// les chaines
+{
+strcpy(tx1, mText[0]->GetText().c_str());
+strcpy(tx2, mText[1]->GetText().c_str());
+strcpy(tx3, mText[2]->GetText().c_str());
+}
+
+/* --Methode-- */
+void ArgsWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+float xmin, xmax, ymin, ymax;
+float fmin, fmax;
+
+switch (UserMsg(msg))
+  {
+  case 777:   // Bouton cancel - On s'en va 
+    this->Hide();
+    break;
+
+  case 555:    // Bouton OK
+// On recupere les textes des 3 champs :
+    printf("ArgsWind::Process() Txt[0] = %s \n", mText[0]->GetText().c_str());
+    sscanf(mText[1]->GetText().c_str(),"%g %g", &xmin, &xmax);
+    printf("... XMin/Max= %g %g \n", xmin, xmax);
+    this->Hide();
+    break;    
+  }
+    
+return;
+}
+
+
+/* ........................................................... */
+/*               Classe PITApp (methodes)                      */
+/* ........................................................... */
+
+static void mypact(void *);
+
+/* --Methode-- */
+PITApp::PITApp(int narg, char* arg[])
+: PIApplication(270, 100, narg, arg), mPeriod(1)   // Periode de 1 seconde pour le "timer"
+{
+
+//  Menus, les numeros ds AppendItem sont les numeros de messages
+//  qui seront passes a Process() et permettent d'identifier l'action
+
+//  Creation du premier menu  
+//  Update :
+//  Mis a jour du Label se trouvant ds la fenetre principal avec l'heure
+//  Start, Stop :
+//  Demarrage et Arret d'une fonction Timer (PIPeriodic) pour 
+//  la mise a jour periodique de ce champ
+//  Exit : 
+//  Arret et sortie du programme
+  cout << " PITApp::PITApp() - Creating menus " << endl;
+m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("Update", 10101);
+m[0]->AppendItem("Start", 10102);
+m[0]->AppendItem("Stop", 10103);
+m[0]->AppendItem("ArgsWindow", 10104);
+m[0]->AppendItem("Exit", 10105);
+// On accroche le menu au Menubar
+AppendMenu(m[0]);
+
+m[1] = new PIMenu(Menubar(),"Edit");
+m[1]->AppendItem("Cut", 10201);
+m[1]->AppendItem("Copy", 10202);
+m[1]->AppendItem("Paste", 10203);
+// On accroche le menu au Menubar
+AppendMenu(m[1]);
+
+
+// Creation de deux labels - Un pour l'heure, l'autre pour X-Y 
+// de la fenetre histo
+  cout << " PITApp::PITApp() - Creating PILabel " << endl;
+lab = new PILabel(this->MainWin(), "time", 250, 50, 10, 10);
+
+mPeriod.SetAction(mypact);
+
+// Fenetre de dialogue
+mAW = new ArgsWind(this);
+SetReady();
+}
+
+/* --Methode-- */
+PITApp::~PITApp()
+{
+delete m[0]; delete m[1]; delete lab;
+delete mAW;
+}  
+
+/* --Methode-- */
+void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
+{
+
+char strg[64];
+
+// Gestion des actions en fonctions des messages
+
+switch(UserMsg(msg))    {
+
+    case 10101:     // On met a l'heure
+      mypact(NULL);    
+      break;
+
+    case 10102:
+      mPeriod.Start();   // On demarre la montre 
+      break;
+
+    case 10103:
+      mPeriod.Stop();    // On arrete la montre 
+      break;
+
+    case 10104 :     // Apparition de la fenetre de dialogue
+      mAW->Show();
+      break;
+
+    case 10105:          // Sortie d'application
+      Stop();
+      break;
+
+    case 10201:          // 2 eme menu
+    case 10202:          //    "   "
+    case 10203:          //    "   "
+      printf("PITApp::Process() Msg= %d (%d - %d) Menu 2 not implemented \n",
+              (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+      break;
+
+    default :
+      printf("PITApp::Process() Msg= %d (%d - %d)??? \n", 
+            (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+     break;
+    
+  }
+return;
+}
+
+static PITApp * app;
+
+/* Nouvelle-Fonction */
+void mypact(void *)
+// Fonction pour lire l'heure de la machine et mettre a jour le champ label
+{
+time_t tm;
+char *s;
+time(&tm);
+s = ctime(&tm);
+// printf("mypact_Info:  %d  (%s)", tm, s);
+app->lab->SetLabel((string)s);
+return;
+}
+
+// ................................................................
+//                   programme principal 
+// ................................................................
+
+int main(int narg, char *arg[])
+{
+if ( (narg > 1) && (strcmp(arg[1],"-h") == 0) ) {
+  printf("pit0 : Standard widget test \n");
+  printf("  Usage : pit0 [Xt options] \n");
+  }
+//  Creation de l'objet application et appel de Run()
+app = new PITApp(narg, arg);
+puts("appel de Application.Run() ... ");
+app->Run();
+
+delete app;
+exit(0);
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/Tests/pit1.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/Tests/pit1.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/Tests/pit1.cc	(revision 1307)
@@ -0,0 +1,526 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <iostream.h>
+
+#include "pisysdep.h"
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PISTDWDG_H 
+#include PIBWDG_H
+#include "piscdrawwdg.h"
+#include "pievthandler.h"
+#include "parradapter.h"
+
+
+/*  Exemple d'utilisation PIBaseWdg - Creation d'une nouvelle composante graphique  */
+
+// ---- Declaration de la classe ExBWdg --------
+class ExBWdg : public PIBaseWdg
+{
+public:
+// Les methodes ...
+
+                  ExBWdg(PIContainerGen *par, char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual         ~ExBWdg();
+
+// Traitement des evenements   
+//  virtual void   Resize();
+  virtual void   Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+
+  virtual void   But1Press(int x, int y);
+  virtual void   But1Release(int x, int y);
+  virtual void   But2Press(int x, int y);
+  virtual void   But2Release(int x, int y);
+  virtual void   But3Press(int x, int y);
+  virtual void   But3Release(int x, int y);
+  virtual void   Keyboard(int key, PIKeyModifier kmod);
+
+protected:
+  int mfnt, mmrk;
+  int nc;
+  char str[32];
+};
+
+
+/* ........................................................... */
+/*     Classe ExBWdg (Implementation des methodes)             */
+/* ........................................................... */
+
+/* --Methode-- */
+ExBWdg::ExBWdg(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) 
+: PIBaseWdg(par, nom, sx, sy, px, py)
+
+{
+mmrk = mfnt = nc = 0;
+strcpy(str, "Hello !");
+for(int i=strlen(str); i<20; i++) str[i] = ' ';
+str[20] = '\0';
+
+ActivateKeyboard();
+ActivateButton(1);
+ActivateButton(2);
+ActivateButton(3);
+}
+
+/* --Methode-- */
+ExBWdg::~ExBWdg()
+{
+}
+ 
+/* --Methode-- 
+void ExBWdg::Resize()
+{
+}
+*/
+
+/* --Methode-- */
+void ExBWdg::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
+{
+PIFontAtt att[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont};
+PIMarker  pmk[9] = { PI_DotMarker , PI_PlusMarker, PI_CrossMarker,  
+                 PI_CircleMarker, PI_FCircleMarker,
+                 PI_BoxMarker, PI_FBoxMarker,
+                 PI_TriangleMarker, PI_FTriangleMarker };
+EraseWindow();
+g->SelFont(PI_NormalSizeFont, att[mfnt]);
+g->SelMarker(8, pmk[mmrk]);
+
+g->SelLine(PI_NormalLine);
+g->DrawBox(10,10, XSize()-20, YSize()-20);
+
+g->SelLine(PI_ThinLine);
+g->DrawFBox(20, 20, 20, 20);
+g->DrawCircle(30, 30, 15);
+
+g->SelForeground(PI_Red);
+g->DrawFCircle(70, 30, 15);
+
+g->SelForeground(PI_Yellow);
+g->DrawFBox(10, 60, 120, 20);
+
+g->SelForeground(PI_Black);
+g->DrawString(20, 110, str);
+
+g->SelLine(PI_ThinLine);
+g->DrawLine(20, 140, 50, 130);
+g->SelLine(PI_NormalLine);
+g->DrawLine(50, 140, 80, 130);
+g->SelLine(PI_ThickLine);
+g->DrawLine(80, 140, 110, 130);
+
+g->SelForeground(PI_Magenta);
+g->DrawFCircle(120, 30, 15);
+g->SelForeground(PI_Grey);
+g->DrawFCircle(120, 60, 15);
+
+PIGrCoord x[5] = { 20, 35, 50, 65, 80 };
+PIGrCoord y[5] = { 150, 150, 150, 150, 150 };
+
+g->SelForeground(PI_Black);
+g->DrawMarkers(x, y, 5);
+return;
+}
+
+
+static char strbuff[128];
+/* --Methode-- */
+void ExBWdg::But1Press(int x, int y)
+{
+SelPointerShape(PI_CrossPointer);
+sprintf(strbuff,"Pos X= %d Y= %d", x, y);
+mWGrC->SelFont(PI_NormalSizeFont, PI_BoldFont);
+mWGrC->DrawString(x+10, y, strbuff);
+Send(Msg(), PIMsg_Active);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But1Release(int x, int y)
+{
+SelPointerShape(PI_ArrowPointer);
+Refresh();
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But2Press(int x, int y)
+{
+if (++mfnt > 2)  mfnt = 0;
+if (++mmrk > 8)  mmrk = 0; 
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But2Release(int x, int y)
+{
+Refresh();
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But3Press(int x, int y)
+{
+SelPointerShape(PI_HandPointer);
+mWGrC->SelForeground(PI_Blue);
+mWGrC->DrawFBox(XSize()/3, YSize()/3, XSize()/8, YSize()/8);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But3Release(int x, int y)
+{
+mWGrC->SelForeground(PI_White);
+mWGrC->DrawFBox(XSize()/3, YSize()/3, XSize()/8, YSize()/8);
+mWGrC->SelForeground(PI_Black);
+SelPointerShape(PI_ArrowPointer);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::Keyboard(int key, PIKeyModifier kmod)
+{
+str[nc] = key;  str[nc+1] = '\0';
+if (++nc > 30)  nc = 0;
+char buf[16];
+
+if (key == PIK_Return) { Refresh(); nc = 0; return; }
+mWGrC->SelFont(PI_NormalSizeFont, PI_BoldFont);
+sprintf(buf," %c (%3d) ", (char) key, key, (int)kmod);
+mWGrC->DrawOpaqueString(20, 75, buf);
+
+if ( (kmod == PIKM_Alt) && (key == 'c') ) {
+  printf("ExBWdg::Keyboard: Test-Copy ... \n"); 
+  ClaimSelection();
+}
+if ( (kmod == PIKM_Alt) && (key == 'v') ) {
+  printf("ExBWdg::Keyboard: Test-Paste ... \n"); 
+  RequestSelection();
+}
+
+return;
+}
+
+// ----- Exemple d'une classe heritant de PIScDrawWdg ----
+/* ........................................................... */
+/*                         Classe ScSample                     */
+/* ........................................................... */
+
+class ScSample : public PIScDrawWdg {
+public:
+  ScSample(PIContainerGen *par, char *nom,
+           int sx=10, int sy=10, int px=0, int py=0);
+  virtual ~ScSample();
+};
+
+static double fpol(double x) {return (0.3*x*x*x-x*x+7.);}
+static float xpts[10] =  {-2.4, -2  , -1., 1., 1.7, 2.2, 3., 3.75, 4.3,  4.8};
+static float ypts[10] =   {-5  , -1.5, 2.5, 5., 8.0, 12., 9., 6.00, 2.2, -3.0};
+
+ScSample::ScSample(PIContainerGen *par, char *nom,
+                  int sx, int sy, int px, int py)
+:PIScDrawWdg(par, nom, sx, sy, px, py)
+
+{
+// Definition des limites
+SetLimits(-3,5,-10,15);
+
+// Creation et ajout d'un drawer de fonctions
+PIFuncDrawer* mfd = new PIFuncDrawer(fpol);
+mfd->SetColAtt(PI_Blue);
+mfd->SetLineAtt(PI_NormalLine);
+AddScDrawer(mfd,true);
+
+// Creation et ajout d'un drawer de points
+PIYfXDrawer* mxyd = new PIYfXDrawer(new P1DAdapter<float>(xpts, 10, false), 
+                                    new P1DAdapter<float>(ypts, 10, false), true);
+mxyd->SetColAtt(PI_Magenta);
+mxyd->SetMarkerAtt(7, PI_FBoxMarker);
+AddScDrawer(mxyd, true);
+
+// Ajout de texte
+BaseDrawer()->SetFontAtt(PI_NormalSizeFont, PI_BoldFont);
+BaseDrawer()->ElAddText(-2.8, 12., "---- ScSample ----", PI_Red);
+BaseDrawer()->ElAddText(-2.8, 10.,  "f(x)=0.3*x^3-x^2+7.", PI_Red);
+
+SetAxesFlags(kAxesDflt);
+}
+
+ScSample::~ScSample()
+{
+}
+
+//      ----------- Une classe EventHandler ----------
+class MyEvHandler :  public PIEventHandler {
+public :
+			MyEvHandler();
+			~MyEvHandler();
+  virtual void		Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  virtual void		ProcessEvent();
+  inline bool 		GrabOK() { return(grabok); }
+
+protected :
+  PIScreenBuffer* mscb;
+  int mposx, mposy;
+  int mposx2, mposy2;
+  int msx, msy;
+  bool grabok;
+};
+
+/* --Methode-- */
+MyEvHandler::MyEvHandler()
+        : PIEventHandler()
+{
+mscb = new PIScreenBuffer(100, 100);
+msx = 100;   msy = 100;
+mposx = mposy = 0;
+mposx2 = mposy2 = 0;
+grabok = false;
+}
+
+/* --Methode-- */
+MyEvHandler::~MyEvHandler()
+{
+delete mscb;
+}
+
+/* --Methode-- */
+void MyEvHandler::Draw(PIGraphic* g, int, int, int, int)
+{
+if (GrabOK()) {
+  printf("MyEvHandler::Draw() : Copying from ScreenBuffer to wdg (%lx) \n", (unsigned long)CurrentWdg());
+  mscb->CopyToWdg(CurrentWdg(), 0, 0, msx, msy, CurrentWdg()->XSize()/2, CurrentWdg()->YSize()/2);
+  }
+else printf("MyEvHandler::Draw() : Grab first from source \n");
+}
+
+/* --Methode-- */
+void MyEvHandler::ProcessEvent()
+{
+printf("MyEvHandler::ProcessEvent() \n");
+switch (EventType()) {
+
+  case PIEvent_But3Press : 
+    mposx = GetPosX();
+    mposy = GetPosY();
+    break;
+
+  case PIEvent_But3Release : 
+    mposx2 = GetPosX();
+    mposy2 = GetPosY();
+    printf("MyEvHandler::ProcessEvent(): Rectangle(%d,%d - %d,%d) \n", mposx, mposy, mposx2, mposy2);
+//    ((PIBaseWdg*)CurrentWdg())->WindowGraphic()->DrawBox(mposx, mposy, (mposx2-mposx), (mposy2-mposy));
+    break;
+
+  case PIEvent_Keyboard :
+    if ((GetKeyMod() == PIKM_Alt) && ((GetKey() == 'G') || (GetKey() == 'g')) ) {
+      printf("MyEvHandler::ProcessEvent(): Grabbing(%dx%d) from Wdg(%lx)@(%d,%d) \n", 
+             msx, msy, (unsigned long)CurrentWdg(), mposx, mposy);
+      mscb->CopyFromWdg(CurrentWdg(), mposx, mposy, msx, msy, 0, 0);
+      grabok = true;
+      }
+    break;
+
+  default :
+    printf("MyEvHandler::ProcessEvent(): Unexpected Event (Type = %d) received \n", (int)EventType());
+    break;
+  }
+
+return;
+}
+
+/* ........................................................... */
+/*                       Classe PITApp                         */
+/* ........................................................... */
+class PITApp : public PIApplication {
+public:
+     PITApp(int narg=0, char* arg[]=NULL);
+     ~PITApp();
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+private :
+  PIMenu* m[2];
+  PIText* txt;
+  MyEvHandler* evh;
+  PIWindow* mcurwin;
+  PIWdg* mdrhw;
+  PIWdg* mevhw;
+  PIWdg* mcurw;  
+};
+
+
+/* --Methode-- */
+PITApp::PITApp(int narg, char* arg[])
+: PIApplication(300, 100, narg, arg)
+{
+
+//  Menus, les numeros ds AppendItem sont les numeros de messages
+//  qui seront passes a Process() et permettent d'identifier l'action
+
+//  Creation du premier menu  
+
+m[0] = new PIMenu(Menubar(),"Actions");
+m[0]->AppendItem("Info", 10101);
+m[0]->AppendItem("New ExBwdg", 10102);
+m[0]->AppendItem("New ScSample", 10103);
+m[0]->AppendItem("Exit", 10105);
+// On accroche le menu au Menubar
+AppendMenu(m[0]);
+
+m[1] = new PIMenu(Menubar(),"Edit");
+m[1]->AppendItem("Copy", 10201);
+m[1]->AppendItem("Paste", 10202);
+// On accroche le menu au Menubar
+AppendMenu(m[1]);
+
+// Creation d' zone texte multiligne
+txt = new PIText(MainWin(), "mltext", 290, 90, 5, 5);
+txt->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+txt->SetMutiLineMode(true);
+txt->SetTextEditable(false);
+txt->SetText("");
+
+evh = new MyEvHandler; 
+mcurwin = NULL;
+mcurw = NULL;  
+mdrhw = NULL;
+mdrhw = NULL;
+SetReady();
+}
+
+/* --Methode-- */
+PITApp::~PITApp()
+{
+delete m[0]; delete m[1]; delete txt;
+}  
+
+static int nbwin = 0;
+/* --Methode-- */
+void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
+{
+
+char strg[256];
+
+// Gestion des actions en fonctions des messages
+
+if ( ( ModMsg(msg) == PIMsg_Active) || (ModMsg(msg) == PIMsg_Close) ) {
+  PIWdg *sndw;
+  sndw = (PIWdg *)sender;      
+  if (sndw->kind() ==  PIWindow::ClassId)  {
+    if (ModMsg(msg) == PIMsg_Close)  { 
+//      printf("PITApp::Process()/Debug : Closing Window %lx \n", (long)sender);
+      if (mcurwin->UserData() == mcurw) mcurw = NULL;
+      if (mcurwin->UserData() == mdrhw) mdrhw = NULL;
+      if (mcurwin->UserData() == mevhw) mevhw = NULL;
+      delete (PIWindow *)sender;  
+      mcurwin = NULL;  
+      }
+    else mcurwin = (PIWindow *)sender;
+  }
+  else if ( ModMsg(msg) ==  PIMsg_Active) mcurw = sndw;
+}
+
+else switch(UserMsg(msg))    {
+
+    case 10101:     // Info 
+      txt->SetText("pit1: PITApp \n PIBaseWdg - PIScDrawWdg test \n ExBWdg (:PIBaseWdg) Creation \n ScSample (:PIScDrawWdg) creation");
+    break;
+
+    case 10102: // Creation d'un ExBWdg
+      {
+      nbwin++;
+      sprintf(strg, "Creation ExBwdg \n Fenetre No %d \n Test keyborard, button 1/2/3", nbwin);
+      txt->SetText(strg);
+      sprintf(strg,"Window %d - ExBwdg", nbwin);
+      PIWindow* wp = new PIWindow(this, strg, PIWK_normal,  250, 250, 150, 150);
+      wp->SetAutoDelChilds(true);
+      ExBWdg* exb  = new ExBWdg(wp, "bwdg", 250, 250, 0, 0);
+      exb->SetBinding(PIBK_fixed,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+      wp->SetUserData(exb);
+      wp->Show();
+      }
+    break;
+
+    case 10103:   // Creation d'un ScSample
+      {
+      nbwin++;
+      sprintf(strg, "Creation Scsample \n Fenetre No %d \n Button 1 -> mouse position \n Button 2 -> Zoom \n keyboard <Alt>O <Alt>V", nbwin);
+      txt->SetText(strg);
+      sprintf(strg,"Window %d - ScSample", nbwin);
+      PIWindow* wp = new PIWindow(this, strg, PIWK_normal,  400, 400, 200, 200);
+      wp->SetAutoDelChilds(true);
+      ScSample* sc  = new ScSample(wp, "scsample", 400, 400, 0, 0);
+      sc->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+      wp->SetUserData(sc);
+      wp->Show();
+      }
+      break;
+
+    case 10105:          // Sortie d'application
+      Stop();
+      break;
+
+
+    case 10201:          // 2 eme menu  Copy
+      if (mcurw == NULL) { printf("PITApp::Process()/Warning : Select a window for copy \n"); 
+        sprintf(strg, "Warning : Select a window for copy");
+        txt->SetText(strg);
+        }
+      else {
+        printf("Adding EventHandler to Wdg %lx", (long)mcurw);
+        sprintf(strg, "Adding EventHandler to Wdg %lx \n, Use button 3 to select copy zone \n, <Alt>G to Get copy",
+                (long)mcurw);
+        txt->SetText(strg);
+        if (mevhw != NULL) mevhw->RemoveEventHandler(evh);  mevhw = NULL;  
+        mcurw->AddEventHandler(evh, PIEvent_But3Press | PIEvent_But3Release | PIEvent_Keyboard, false);
+        }
+      break;
+      
+    case 10202:          //   2eme Menu - Paste
+      if (mcurw == NULL) { printf("PITApp::Process()/Warning : Select a window for paste \n"); 
+        sprintf(strg, "Warning : Select a window for paste");
+        txt->SetText(strg);
+        }
+      else {
+        printf("Adding DrawHandler to Wdg %lx \n - Refreshing Wdg", (long)mcurw);
+        sprintf(strg, "Adding DrawHandler to Wdg %lx \n - Refreshing Wdg", (long)mcurw);
+        txt->SetText(strg); 
+        mcurw->AddDrawHandler(evh, false); 
+        mdrhw = mcurw;
+        ((PIBaseWdg*)mcurw)->Refresh();
+        }
+      break;
+      
+    default :
+      //      printf("PITApp::Process() Msg= %d (%d - %d)??? \n", 
+      //            (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+     break;
+    
+  }
+return;
+}
+
+
+// ................................................................
+//                   programme principal 
+// ................................................................
+
+int main(int narg, char *arg[])
+{
+if ( (narg > 1) && (strcmp(arg[1],"-h") == 0) ) {
+  printf("pit1 : ExBWdg (:PIBaseWdg) / ScSample (:PIScDrawWdg) test \n");
+  printf("  Usage : pit1 [Xt options] \n");
+  }
+//  Creation de l'objet application et appel de Run()
+PITApp* app = new PITApp(narg, arg);
+// puts("appel de Application.Run() ... ");
+app->Run();
+
+delete app;
+exit(0);
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/Tests/pitcons.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/Tests/pitcons.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/Tests/pitcons.cc	(revision 1307)
@@ -0,0 +1,289 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <iostream.h>
+#include <X11/Intrinsic.h>
+#include <Xm/Xm.h>  // Pour *DBG*
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIMENU_H 
+#include PISTDWDG_H 
+#include PIWIN_H
+#include "picons.h"
+
+class PITApp : public PIApplication {
+public:
+     PITApp(int narg=0, char* arg[]=NULL);
+     ~PITApp();
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL
+);
+
+// protected :
+     
+  PIMenu * m[2];
+  PIWindow *mCurW;
+  PIButton *but[2];
+};
+
+
+static PIConsole* scons=NULL;
+static PIConsole* cons=NULL;
+
+/* --Methode-- */
+PITApp::PITApp(int narg, char* arg[])
+: PIApplication(600, 300, narg, arg)
+{
+
+
+m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("NewConsole", 10101);
+m[0]->AppendItem("StdOut", 10102);
+m[0]->AppendItem("StdOut-2", 10103);
+m[0]->AppendItem("StdErr", 10104);
+m[0]->AppendItem("StdErr-2", 10105);
+m[0]->AppendItem("AccCmd", 10110);
+m[0]->AppendItem("AccCmd-2", 10111);
+m[0]->AppendItem("Exit", 10177,"Q");
+// On accroche le menu au Menubar
+AppendMenu(m[0]);
+
+
+m[1] = new PIMenu(Menubar(),"Actions");
+m[1]->AppendItem("Normal", 10201);
+m[1]->AppendItem("Bold", 10202);
+m[1]->AppendItem("Italique", 10203);
+m[1]->AppendItem("Reverse", 10204);
+m[1]->AppendItem("Print", 10205);
+m[1]->AppendItem("PrintNNL", 10206);
+m[1]->AppendItem("COUT", 10207);
+m[1]->AppendItem("PrintErr", 10208);
+m[1]->AppendItem("CERR", 10209);
+
+AppendMenu(m[1]);
+
+but[0] = but[1] = NULL;
+
+but[0] = new PIButton(MainWin(), "OK", 501, 50,  25, 30, 10);
+but[1] = new PIButton(MainWin(), "Cancel", 502, 50,  25, 100, 10);
+// printf("---DBG--- %lx %lx %lx \n", XtWindow(MainWin()->XtWdg()), 
+//       XtWindow(but[0]->XtWdg()), XtWindow(but[1]->XtWdg()) ); 
+
+scons = new PIConsole(MainWin(), "PIConsole", 4540, 120, 70, 600, 250, 0, 50 );
+
+// printf("---DBG-2=== %lx %lx % \n", XtWindow(PIXtTopWdg()), 
+//       XtWindow(scons->XtWdg()));
+
+int kkk;
+for(kkk=0; kkk<10; kkk++) { 
+  scons->AddStr("A-B-C-JHGTREWQ====Reza Ansari");
+  scons->AddChar('\n'); 
+  }
+for(kkk=0; kkk<5; kkk++) {
+  scons->AddStr("**** CMV ****", PIVA_Bold);
+  scons->AddStr(" Hello, Comment ca va ? Salam - Bye, Bye ",PIVA_Ital); 
+  scons->AddChar('\n'); 
+  }
+  
+
+scons->AcceptCmd(true);
+// RedirectOutStream(scons);
+// RedirectErrStream(scons);
+
+
+ 
+mCurW = NULL;    // Fenetre courante
+SetReady();
+}
+
+/* --Methode-- */
+PITApp::~PITApp()
+{
+}  
+
+static int lines = 0;
+
+/* --Methode-- */
+void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+int i,l;
+char buff[128];
+
+/*   Debug version Motif
+XmNavigationType navtyp;
+Boolean trav;
+
+Arg  wargs[2];
+navtyp = 0;
+trav = FALSE;
+XtSetArg(wargs[0],XmNnavigationType, &navtyp);  
+XtSetArg(wargs[1],XmNtraversalOn, &trav);  
+XtGetValues(((PIWdg*)sender)->XtWdg(), wargs, 2);
+
+printf("-- DBG -- PITApp::Process() Widget= %lx (%lx) \n", (long) ((PIWdg*)sender)->XtWdg(), (long)sender);
+printf(" NavType = %d  (None=%d)  Trav= %d (False=%d) \n", (int)navtyp, (int)XmNONE, (int)trav, (int)FALSE);
+*/
+
+
+if ( ( ModMsg(msg) == PIMsg_Active) || (ModMsg(msg) == PIMsg_Close) ) {
+  PIWdg *sndw;
+  sndw = (PIWdg *)sender;      
+  if (sndw->kind() ==  PIWindow::ClassId)  {
+    if (ModMsg(msg) == PIMsg_Close)  { 
+      printf("PITApp::Process()/Debug : Closing Window %lx \n", (long)sender);
+      delete (PIWindow *)sender;  
+      mCurW = NULL; }
+    else  mCurW = (PIWindow *)sender;
+  }
+}
+else
+  {
+  switch(UserMsg(msg))
+    {
+    case 4540: 
+      if (ModMsg(msg) == PIMsg_OK) 
+        printf("Cmd from Console L=%d [%s] \n", strlen((char*)data), (char*)data ); 
+      else 
+        printf("Console Msg= %d Mod = %d \n",UserMsg(msg), ModMsg(msg));
+      break; 
+
+// --------- 1er menu ----------
+    case 10101: 
+      {
+      PIWindow* win = new PIWindow(this, "Console-2", PIWK_normal, 500, 200, 200, 200);
+      win->SetAutoDelChilds(true);
+      win->Show();
+      cons = new PIConsole(win, "PIConsole-2", 4560, 100, 60, 500, 200, 0, 0 );
+      int kkk;
+      for(kkk=0; kkk<20; kkk++) { 
+        cons->AddStr("A-B-C-JHGTREWQ====Reza Ansari");
+        cons->AddChar('\n'); 
+        }
+      for(kkk=0; kkk<25; kkk++) {
+        cons->AddStr("**** CMV ****", PIVA_Bold);
+        cons->AddStr(" Hello, Comment ca va ? Salam - Bye, Bye ",PIVA_Ital); 
+        cons->AddChar('\n'); 
+        }
+      }
+      break;
+    case 10102: 
+      RedirectOutStream(scons);
+      break;
+
+    case 10103: 
+      RedirectOutStream(cons);
+      break;
+
+    case 10104: 
+      RedirectErrStream(scons);
+      break;
+
+    case 10105: 
+      RedirectErrStream(cons);
+      break;
+
+    case 10110 :
+      if (scons) scons->AcceptCmd(true);
+      break;
+    case 10111 :
+      if (cons) cons->AcceptCmd(true);
+      break;
+
+    case 10177:          // Sortie d'application
+      Stop();
+      break;
+
+// ----------  2eme menu --------
+  case 10207 :
+    for(l=0; l<3; l++) 
+      cout << "TApp: Test-Cout (K= " << l << ") " << endl ; 
+    break;
+  case 10205 :
+    for(l=0; l<4; l++) 
+      printf("TApp: Test-Redirect Print %d - %d \n", l, lines); lines++;
+    break;
+  case 10206 :
+      printf("TApp: T-Print NNL %d n", lines);
+    break;
+
+  case 10209 :
+    for(l=0; l<2; l++) 
+      cerr << "TApp: CERR--Test (K= " << l << ") " << endl ; 
+    break;
+  case 10208 :
+    for(l=0; l<8; l++) 
+      fprintf(stderr, "TApp: StdErr Redirect  %d - %d \n", l, lines);  lines++;
+    break;
+
+  case 10204 :
+    for(l=0; l<1; l++) {
+      sprintf(buff, "TApp: Line type Reverse No %d ", lines);
+      scons->AddStr(buff, PIVA_Reverse, false);
+      sprintf(buff, "Normal  ");
+      scons->AddStr(buff, PIVA_Def, false);
+      sprintf(buff, "Bold  ");
+      scons->AddStr(buff, PIVA_Bold, false);
+      lines++;
+    }   
+    scons->Refresh();
+    break;
+  
+  case 10202 :
+    for(l=0; l<3; l++) {
+      sprintf(buff, "TApp: Line type Bold No %d \n", lines);
+      scons->AddStr(buff, PIVA_Bold, false);
+      lines++;
+    }   
+    scons->Refresh();
+    break;
+  
+  case 10203 :
+    for(l=0; l<3; l++) {
+      sprintf(buff, "Line type Italique No %d \n", lines);
+      scons->AddStr(buff, PIVA_Ital, false);
+      lines++;
+    }   
+    scons->Refresh();
+    break;
+  
+  case 10201 :
+    for(l=0; l<3; l++) {
+      sprintf(buff, "Tapp: Line type Normal No %d \n", lines);
+      scons->AddStr(buff, PIVA_Def, false);
+      lines++;
+    }   
+    scons->Refresh();
+    break;
+
+
+    default :
+      printf("PIDemoApp::Process() Msg= %d (%d - %d)??? \n", 
+            (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+     break;
+    }
+  }
+return;
+}
+
+
+static PITApp * app;
+
+
+int main(int narg, char *arg[])
+{
+
+  // PeidaStarRecoInitiator InitStar;
+
+app = new PITApp(narg, arg);
+app->SetBusy();
+puts("appel de Application.Run() ... ");
+app->SetReady();
+app->Run();
+
+delete app;
+exit(0);
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/Tests/pitgr.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/Tests/pitgr.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/Tests/pitgr.cc	(revision 1307)
@@ -0,0 +1,406 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include <iostream.h>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIMENU_H 
+#include PISTDWDG_H 
+#include PIWIN_H
+#include PIPERIODIC_H
+
+#include "pidrawwin.h"
+#include "piscdrawwdg.h"
+#include "piimage.h"
+#include "parradapter.h"
+
+#include "psfile.h"
+
+#include "piimgtools.h"
+#include "pidrwtools.h"
+
+#include "pisurfdr.h"
+
+
+//  ---------- classe PITApp -----------------------
+class PITApp : public PIApplication {
+public:
+     PITApp(int narg=0, char* arg[]=NULL);
+     ~PITApp();
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+  PIMenu* m[3];
+  PIText* txt;
+  PIPixmap* zoom;  
+  PICMapView* cmapv;
+  PIWindow *mCurW;
+};
+
+
+/* --Methode-- */
+PITApp::PITApp(int narg, char* arg[])
+: PIApplication(360, 130, narg, arg) 
+{
+
+m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("Info", 10101);
+m[0]->AppendItem("Close", 10110);
+m[0]->AppendItem("Exit", 10150);
+// On accroche le menu au Menubar
+AppendMenu(m[0]);
+
+// 2eme Menu
+
+m[1] = new PIMenu(Menubar(),"Graphics");
+m[1]->AppendItem("Sin(x)/x", 10201);
+m[1]->AppendItem("YfXDrawer", 10202);
+m[1]->AppendItem("2-Drawers", 10203);
+m[1]->AppendItem("Surf-3D", 10204);
+m[1]->AppendItem("Surf-3D-Color", 10205);
+m[1]->AppendItem("Image", 10206);
+
+AppendMenu(m[1]);
+
+
+m[2] = new PIMenu(Menubar(),"Tools");
+m[2]->AppendItem("ShowImageTools", 10301);
+m[2]->AppendItem("ShowDrawerTools", 10302);
+m[2]->AppendItem("PostScript (EPS)", 10305);
+AppendMenu(m[2]);
+
+MainWin()->SetSize(360,130);
+zoom = new PIPixmap(MainWin(), "Zoom", 90, 90, 5, 5);
+// zoom->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+cmapv = new PICMapView(MainWin(), "CMapView", 350, 25, 5, 100);
+// cmapv->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+// Creation d' zone texte multiligne
+txt = new PIText(MainWin(), "mltext", 250, 90, 105, 5);
+// txt->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+txt->SetMutiLineMode(true);
+txt->SetTextEditable(false);
+txt->SetText("");
+
+SetReady();
+}
+
+/* --Methode-- */
+PITApp::~PITApp()
+{
+for(int i=0; i<3; i++)  delete m[i]; 
+delete txt;
+delete cmapv;
+delete zoom;
+}  
+
+
+static int nbwin = 0;
+static int numpsf = 0;
+static int fgswcol = 0;
+
+static double fsinc(double x) {if ( (x>-1.e-8) && (x<1.e-8) ) return(0.); else return (sin(x)/x);}
+
+/* --Methode-- */
+void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+char strg[64];
+int i,j;
+
+if ( ( ModMsg(msg) == PIMsg_Active) || (ModMsg(msg) == PIMsg_Close) ) {
+  PIWdg *sndw;
+  sndw = (PIWdg *)sender;      
+  if (sndw->kind() ==  PIWindow::ClassId)  {
+    if (ModMsg(msg) == PIMsg_Close)  { 
+      printf("PITApp::Process()/Debug : Closing Window %lx \n", (long)sender);
+      delete (PIWindow *)sender;  
+      mCurW = NULL; }
+    else  mCurW = (PIWindow *)sender;
+  }
+}
+else
+  {
+  switch(UserMsg(msg))
+    {
+
+// --------- 1er menu ----------
+    case 10101:     
+      txt->SetText("pitgr: PI Graphics Tests \n * 2-D graphics \n * 3-D Graphics \n Image display ");
+      break;
+
+    case 10110 :
+      if (mCurW)  { mCurW->Hide();  delete mCurW;}
+      mCurW = NULL;
+      break;
+
+    case 10150:          // Sortie d'application
+      Stop();
+      break;
+
+
+// ----------  3eme menu --------
+    case 10301 :
+      PIImgTools::ShowPIImgTools();
+      break;
+    case 10302 :
+      PIDrwTools::ShowPIDrwTools();
+      break;
+    case 10305 :
+      if(mCurW) {
+        char buff[64];
+        sprintf(buff, "pigr_%d.eps", numpsf);        numpsf++;
+        printf("Creating EPS File %s (Encapsulated PostScript) \n", buff);
+        PSFile *mps;
+	mps = new PSFile(buff);
+	mCurW->PSPrint(mps,0,0);
+	delete mps;
+        }
+      break;
+
+// ----------  2eme menu --------
+
+    case 10201 :        //  Trace de la fonction sin(x)/x
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIScDrawWdg Creation\n Sin(x)/x \n Button 1 -> Coord \n  Button 2 Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      PIFuncDrawer* mfd = new PIFuncDrawer(fsinc);
+      mfd->SetColAtt(PI_Gold);
+      mfd->SetLineAtt(PI_NormalLine);
+      nbwin++; sprintf(strg,"2D Graphics (PI W %d)", nbwin);
+      PIWindow* wp = new PIWindow(this, strg, PIWK_normal,  300, 300, 150, 150);
+      wp->SetAutoDelChilds(true);
+      PIScDrawWdg* scd = new PIScDrawWdg(wp, "scwdg-sinc", 300, 300, 0, 0);
+      scd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
+      scd->SetLimits(0.1, 30., -1., 1.);
+      scd->AddScDrawer(mfd,true);
+      scd->BaseDrawer()->ElAddText(2, 0.8, "Y = Sin(x)/x", PI_Red);
+      scd->SetTitles(" --- PIFuncDrawer (Sin(x)/x) --- ");
+      wp->Show();    // On affiche  la fenetre 
+      SetReady();    //  souris->pointeur , on n'est plus occupe
+      }
+      break;
+
+
+    case 10202 :    // Trace Test de PIYfXDrawer
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIScDrawWdg Creation\n PIYfXDrawer \n Button 1 -> Coord \n  Button 2 Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      float* vpx = new float[30]; 
+      float* vpy = new float[30]; 
+      int i;   double x;
+      for(i=0; i<30; i++) { x = 8.*i/30;  vpx[i] = x;  vpy[i] = 3*cos(x)+2*sin(x); }
+      PIYfXDrawer* mxyd = new   PIYfXDrawer( new P1DAdapter<float>(vpx, 30, true), 
+                                            new P1DAdapter<float>(vpy, 30, true), true); 
+      mxyd->SetColAtt(PI_Red);
+      mxyd->SetMarkerAtt(7, PI_FTriangleMarker);
+
+      nbwin++; sprintf(strg,"2D Graphics (PI W %d)", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 300, 300, 300, 300);
+      PIScDrawWdg* scd = new PIScDrawWdg(awp, "scwdg-YfX", 300, 300, 0, 0);
+      scd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
+      scd->AddScDrawer(mxyd,true);
+      scd->SetTitles(" --- PIYfXDrawer (3*cons(x)+2*sin(x)) --- ");
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+      SetReady();
+      }
+      break;
+
+    case 10203 :    // FunDrawer + PIYfXDrawer
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIScDrawWdg Creation\n PIYfXDrawer + FuncDrawer(Sin(x)/x) \n Button 1 -> Coord \n  Button 2 Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      float* vpx = new float[30]; 
+      float* vpy = new float[30]; 
+      int i;   double x;
+      for(i=0; i<30; i++) { x = 8.*i/30;  vpx[i] = x;  vpy[i] = 3*cos(x)+2*sin(x); }
+      PIYfXDrawer* mxyd = new   PIYfXDrawer( new P1DAdapter<float>(vpx, 30, true), 
+                                             new P1DAdapter<float>(vpy, 30, true), true); 
+
+      mxyd->SetColAtt(PI_Magenta);
+      mxyd->SetMarkerAtt(7, PI_FBoxMarker);
+
+      PIFuncDrawer* mfd = new PIFuncDrawer(fsinc);
+      mfd->SetColAtt(PI_Blue);
+      mfd->SetLineAtt(PI_NormalLine);
+
+      nbwin++; sprintf(strg,"2D Graphics (PI W %d)", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 400, 400, 300, 300);
+      PIScDrawWdg* scd = new PIScDrawWdg(awp, "scwdg-YfX", 400, 400, 0, 0);
+      scd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
+      scd->AddScDrawer(mxyd,true);
+      scd->AddScDrawer(mfd,true);
+      scd->SetTitles(" --- PIYfXDrawer + PIFuncDrawer --- ");
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+
+      SetReady();
+      }
+      break;
+
+    case 10206 :
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIImage Creation\n Image Display \n Button 1 -> Coord/value \n  Button 2 Select Rectangle \n Butt on 3 Move \n <Alt>O <Alt>V <Alt>C \n Try ImageTools");
+ 
+      int sx, sy;
+      sx = 400; 
+      sy = 600;
+      printf(" Creating Image (%dx%d) ... ", sx, sy);
+      float* img = new float[sx*sy];
+      int i, j, k, kk, i0, j0;
+      double lamp, amp,x,y;
+      for(k=0; k<sx*sy; k++)   img[k] = 1000.+(random()%200-100);
+//   On genere 500 etoiles
+      for(k=0; k<500; k++) {
+        i0 = 20+random()%(sx-20);
+        j0 = 20+random()%(sy-20);
+        lamp = 2.0+0.012*(random()%100);
+        amp = pow(10., lamp);
+//        if (k%5 == 0)  printf(" DBG %d %d - %g \n", i0, j0, flux);
+        for(i=i0-15; i<i0+15; i++) {
+          if(i<0 || i>=sx) continue;
+          for(j=j0-15; j<j0+15; j++) {
+            if(j<0 || j>=sy) continue;
+            x = i-i0;  y = j-j0;
+            kk = j*sx+i;
+            img[kk] += amp*exp(-(x*x)/7.-(y*y)/8.);
+            }
+	}
+      }
+      printf("  >> OK \n");
+     
+      nbwin++; sprintf(strg,"Image (PI W %d)", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, sx, sy, 300, 300);
+      PIImage * pii = new PIImage(awp, "fitsimage", sx, sy, 0, 0);
+      pii->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+      pii->SetZoomWin(zoom, false);
+      pii->SetCMapWin(cmapv, false);
+      pii->ShowCursor(true);
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+      pii->SetImage(new P2DAdapter<float>(img, sx, sy, true), true);
+      SetReady();
+      }
+      break;
+
+
+//    Dessins 3D  
+    case 10204:         
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIDraw3DWdg Creation\n 3-D Surf Display \n Button 1 \n (Shift) Button 2 Rotate \n Button Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      printf(" Creating Matrix 80x60  ... ");
+      float* tf = new float[60*80];
+      int i,j,k;
+      double xp,yp,rp;
+      for(i=0; i<80; i++)
+        for(j=0; j<60; j++) { 
+           xp = i-30;   yp = j-20;
+           rp = (xp*xp)/16.+(yp*yp)/9.;
+           tf[j*80+i] = 10.*exp(-rp);
+           xp = i-50;   yp = j-28;
+           rp = (xp*xp)/9.+(yp*yp)/9.;
+           tf[j*80+i] += 4.*exp(-rp);
+        }
+      printf("  >> OK \n");
+
+      nbwin++; sprintf(strg,"3D Surf (PI W %d)", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 500, 500, 200, 200);
+      PISurfaceDrawer* sd = new PISurfaceDrawer(new P2DAdapter<float>(tf, 80, 60, true), true, true, true);
+      PIDraw3DWdg* drw3 = new PIDraw3DWdg(awp, "ex3ddrw", 500, 500, 0, 0);
+      drw3->SetBinding(PIBK_fixed , PIBK_fixed , PIBK_fixed, PIBK_fixed);
+      drw3->AddDrawer3D(sd, false);
+      drw3->SetTitles(" --- PISurfaceDrawer (80x60) --- ");
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+      SetReady();
+      }
+      break;
+
+    case 10205:         
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIDraw3DWdg Creation\n 3-D Surf Display \n Button 1 \n (Shift) Button 2 Rotate \n Button Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      printf(" Creating Matrix 50x50  ... ");
+      float * tf = new float[2500];
+      int i,j;
+      double xp,yp,rp;
+      for(i=0; i<50; i++)
+        for(j=0; j<50; j++) { 
+           xp = i-15;   yp = j-25;
+           rp = (xp*xp)/16.+(yp*yp)/16.;
+           tf[j*50+i] = 11.*exp(-rp);
+           xp = i-35;   yp = j-15;
+           rp = (xp*xp)/9.+(yp*yp)/9.;
+           tf[j*50+i] += 3.*exp(-rp);
+           xp = i-45;   yp = j-40;
+           rp = (xp*xp)/10.+(yp*yp)/20.;
+           tf[j*50+i] += 6.*exp(-rp);
+        }
+      printf("  >> OK \n");
+
+      nbwin++; sprintf(strg,"PI W# %d 3D Surf", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 500, 500, 200, 200);
+      PISurfaceDrawer* sd = new PISurfaceDrawer(new P2DAdapter<float>(tf, 50, 50, true), true, true, true);
+      if (fgswcol%3 == 0) sd->SetColMapId(CMAP_COLRJ32);
+      else if (fgswcol%3 == 1) sd->SetColMapId(CMAP_COLBR32);
+      else sd->SetColMapId(CMAP_COLRV32);
+      fgswcol++;
+      PIDraw3DWdg* drw3 = new PIDraw3DWdg(awp, "ex3ddrw", 600, 600, 0, 0);
+      drw3->SetBinding(PIBK_fixed , PIBK_fixed , PIBK_fixed, PIBK_fixed);
+      drw3->AddDrawer3D(sd, false);
+      drw3->SetTitles(" --- PISurfaceDrawer (50x50) --- ");
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+      SetReady();
+      }
+      break;
+
+    default :
+//      printf("PITApp::Process() Msg= %d (%d - %d)??? \n", 
+//            (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+     break;
+    }
+  }
+return;
+}
+
+
+// ................................................................
+//                   programme principal 
+// ................................................................
+
+int main(int narg, char *arg[])
+{
+
+if ( (narg > 1) && (strcmp(arg[1],"-h") == 0) ) {
+  printf("pitgr : PI 2D Graphics/ 3D Surface plot/ Image Display Tests  \n");
+  printf("  Usage : pitgr [Xt options] \n");
+  }
+
+
+PITApp* app = new PITApp(narg, arg);
+int sx,sy;
+PIApplicationPrefCompSize(sx, sy);
+printf("##### pit-main() PrefCompSize= %d %d ##### \n", sx, sy);
+PIApplicationScreenSize(sx, sy);
+printf("##### pit-main() ScreenSize= %d %d ##### \n", sx, sy);
+PIColorMap* cmap = new PIColorMap(CMAP_GREY32);
+printf("##### pit-main() NbTotColors=%d Already Allocated= %d ##### \n", 
+       cmap->TotNbColors(), cmap->NbAllocColors());
+app->Run();
+
+delete cmap;
+delete app;
+exit(0);
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/Tests/pitst.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/Tests/pitst.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/Tests/pitst.cc	(revision 1307)
@@ -0,0 +1,435 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+/*  Ceci est un programme test des differents composants de PI : PEIDA Interactif */
+/*                 Reza ,  96-98                                                  */
+
+/*   C'est ecrit n'importe comment !     */
+ 
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PIOPTMENU_H 
+#include PISTDWDG_H 
+#include PIBWDG_H 
+#include PIPIXMAP_H 
+#include PIFILECHO_H 
+#include PILIST_H
+
+#include "piscdrawwdg.h"
+
+/*
+int SysBeep(int n)
+{
+for(int i=0; i<n; i++)  putchar('\007');
+return(0);
+}
+*/
+
+class PITestApp : public PIApplication {
+public:
+	PITestApp(int sx, int sy);
+	~PITestApp();
+
+	virtual void	Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+    PIMenu  *m[5];
+    PIMenu  *mc[2];
+    PICheckBox * ckb;
+    PIText * text;
+    PIButton * bouton;
+    PIButton * bouton2, * bouton3, * bouton4, * bouton5;
+    PIButton * bouton11, * bouton12, * bouton13,* bouton14 ,* bouton15 ;
+    PILabel * label;
+    PIScale * scl;
+    PIMenu  * menu;
+    PIOptMenu * opt, * opt2;
+    bool stnewmen[2];
+
+};
+
+
+
+PITestApp::PITestApp(int sx, int sy)
+: PIApplication(550, 350)
+{
+char ans[128];
+   m[0] = new PIMenu(Menubar(),"File");
+   m[0]->AppendItem("Open", 10101);
+   m[0]->AppendItem("Close", 10102);
+   m[0]->AppendItem("New", 10103);
+//   m[0]->AppendItem("ScBar", 10105);
+   m[0]->AppendItem("Quit", 10104);
+
+   m[1] = new PIMenu(Menubar(),"Edit");
+   m[1]->AppendItem("Copier", 10201);
+   m[1]->AppendItem("Coller", 10202);
+   m[1]->AppendItem("Couper", 10203);
+   m[1]->AppendCheckItem("Check It", 10205);
+   mc[0] = new PIMenu(m[1], "Cascade");
+   mc[0]->AppendItem("EdeCas-1", 10221);
+   mc[0]->AppendItem("EdeCas-2", 10222);
+   mc[0]->AppendItem("EdeCas-3", 10223);
+   m[1]->AppendPDMenu(mc[0]);
+
+   m[2] = new PIMenu(Menubar(),"Operation");
+   m[2]->AppendItem("AddItem", 10301);
+   m[2]->AppendItem("DelItemName", 10302);
+   m[2]->AppendItem("DelItemMsg", 10303);
+
+   m[3] = new PIMenu(Menubar(),"Special");
+   m[3]->AppendItem("Spec-Opt1", 10401);
+   m[3]->AppendItem("Spec-Opt2", 10402);
+   m[3]->AppendItem("Spec-Cascade", 10403);
+   mc[1] = new PIMenu(m[3], "Spec-Cascade");
+   mc[1]->AppendItem("Spec-Cas-1", 10441);
+   mc[1]->AppendItem("Spec-Cas-2", 10442);
+   mc[1]->AppendItem("Spec-Cas-3", 10443);
+   m[3]->AppendPDMenu(mc[1]);
+   m[3]->AppendCheckItem("Checkable", 10414);
+
+   m[4] = new PIMenu(Menubar(),"AddMenu2");
+   m[4]->AppendItem("option-A", 10501);
+   m[4]->AppendItem("option-B", 10502);
+   m[4]->AppendItem("option-C", 10503);
+
+   AppendMenu(m[0]);
+   AppendMenu(m[1]);   
+   AppendMenu(m[2]);
+
+  ckb = new PICheckBox(this->MainWin(), "CheckBox", 166, 60, 20, 10, 10);
+  text = new PIText(this->MainWin(), "TEXTE", 180, 30, 20,40);
+  text->SetMsg(7440);
+  label  = new PILabel(this->MainWin(), "Label", 180, 20, 20,80);
+  label->SetBorderWidth(1);
+  bouton = new PIButton(this->MainWin(), "->Menu", 33, 60, 25, 20, 120);
+  bouton2 = new PIButton(this->MainWin(), "Dialog", 333, 60, 25, 100, 120);
+  bouton3 = new PIButton(this->MainWin(), "ScDraw", 433, 60, 25, 180, 120);
+  bouton4 = new PIButton(this->MainWin(), "Pixmap", 133, 60, 25, 260, 120);
+  bouton5 = new PIButton(this->MainWin(), "List", 533, 60, 25, 340, 120);
+
+  scl = new PIScale(this->MainWin(), "Scale", 88, kSDirRtoL, 200, 20, 10, 150);
+  scl->SetMinMax(5, 45);
+
+  int psx, psy;
+  PrefCompSz(psx, psy);
+  cout << " Creation bouton 11 -14 avec Sx,Sy= " << psx << " , " << psy << endl;
+
+  bouton11 = new PIButton(this->MainWin(), "AddMen-1", 1133, psx*1.5, psy, 20, 250);
+  bouton12 = new PIButton(this->MainWin(), "AddMen-2", 1233, psx*1.5, psy, 40+psx*1.5, 250);
+  stnewmen[0] = stnewmen[1] = false;
+  bouton13 = new PIButton(this->MainWin(), "Ready/Bloc", 1333, psx*1.5, psy, 20, 300);
+  bouton14 = new PIButton(this->MainWin(), "TS-BWdg", 1433, psx*1.5, psy, 40+psx*1.5, 300);
+  bouton15 = new PIButton(this->MainWin(), "TS-MenuIt", 1533, psx*1.5, psy, 60+psx*3, 300);
+
+//  XSync(PIXDisplay(), FALSE);
+//  printf("Creation PIPUMenu DoIt-1... \n");   gets(ans);
+  menu = new PIMenu(this->MainWin(), "myMenu");
+//  XSync(PIXDisplay(), FALSE);
+//  printf("Apres Creation PIPUMenu -AppendItem() 1 ... \n");   gets(ans);
+
+  menu->AppendItem("DoIt-1", 4401);
+//  XSync(PIXDisplay(), FALSE);
+//  printf("Apres Creation PIPUMenu -AppendItem() 2 ... \n");   gets(ans);
+
+  menu->AppendItem("DoIt-2", 4402);
+  menu->AppendItem("DoIt-25", 4425);
+  menu->AppendItem("DoIt-26", 4426);
+  menu->AppendItem("Check-33", 4433);
+
+//  XSync(PIXDisplay(), FALSE);
+//  printf("Creation PIPUMenu Copier ... \n");   gets(ans);
+
+
+  opt = new PIOptMenu(this->MainWin(), "Option-Menu-1", 120, 25, 10, 200);
+  opt->AppendItem("Linear", 5601);
+  opt->AppendItem("Log.", 5602);
+  opt->AppendItem("Sqrt", 5603);
+  opt->AppendItem("Expon", 5604);
+  opt->AppendItem("Polyn", 5605);
+
+  string ops = "Sqrt";
+  opt->SetValueStr(ops);
+
+  opt2 = new PIOptMenu(this->MainWin(), "Option-Menu-1", 120, 25, 150, 200);
+  opt2->AppendItem("Copier", 80201);
+  opt2->AppendItem("Coller", 80202);
+  opt2->AppendItem("Couper", 80203);
+  opt2->AppendItem("Undo", 80204);
+  opt2->AppendItem("Select-All", 80205);
+  
+}
+
+PITestApp::~PITestApp()
+{
+  delete ckb;
+  delete text;
+  delete label;
+  delete bouton;
+  delete bouton2;
+  delete bouton3;
+  delete bouton4;
+  delete bouton5;
+  delete bouton11;
+  delete bouton12;
+  delete bouton13;
+  delete bouton14;
+  delete bouton15;
+  delete menu;
+  delete m[0]; delete m[1]; delete m[2]; delete m[3]; delete m[4];
+  delete mc[0]; delete mc[1];
+  delete opt;
+  delete opt2;
+  delete scl;
+}
+
+/* ........................................................... */
+/*                         Classe ScSample                     */
+/* ........................................................... */
+
+class ScSample : public PIScDrawWdg {
+public:
+  ScSample(PIContainerGen *par, char *nom,
+           int sx=10, int sy=10, int px=0, int py=0);
+  virtual ~ScSample();
+};
+
+static double fpol(double x) {return (0.3*x*x*x-x*x+7.);}
+static double fx2(double x) {return (0.5*x*x);}
+
+ScSample::ScSample(PIContainerGen *par, char *nom,
+                  int sx, int sy, int px, int py)
+:PIScDrawWdg(par, nom, sx, sy, px, py)
+
+{
+// Definition des limites
+SetLimits(-3,5,-10,15);
+
+// Creation et ajout d'un drawer de fonctions
+PIFuncDrawer* mfd = new PIFuncDrawer(fpol);
+mfd->SetColAtt(PI_Blue);
+mfd->SetLineAtt(PI_NormalLine);
+AddScDrawer(mfd,true);
+PIFuncDrawer* mfd2 = new PIFuncDrawer(fx2);
+mfd2->SetColAtt(PI_Red);
+mfd2->SetLineAtt(PI_NormalLine);
+AddScDrawer(mfd2,true);
+SetAxesFlags(kAxesDflt);
+}
+
+ScSample::~ScSample()
+{
+}
+
+static ScSample *scs1, *scs2, *scs3;
+static PIScrollBar *scb, *scb2;
+
+static PIWindow * wp3, *wp4, *wp5, *wp6;
+static PIPixmap * pxm;
+static unsigned char  pixels[25000];
+static PIFileChooser *pfc;
+static bool  fgpxm = false;
+static bool  fgt = false;
+static bool  fgt2 = false;
+static bool  fgt3 = false;
+
+static PIListX * pil;
+
+void
+PITestApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+  static int x = 0;
+  static numsg=8800;
+
+  char truc[256];
+  sprintf(truc,"< %ld - %d (%d)>",msg,x++, (int)((PIWdgGen *)sender)->kind());
+  this->label->SetLabel(truc);
+  sprintf(truc,"[%d] Msg= %ld (%d-%d) Kind=(%d)  Data= (%ld - %lx)",x, msg, (int)UserMsg(msg),
+         (int)ModMsg(msg), (int)((PIWdgGen *)sender)->kind(), (long)data, (long)data);
+  puts(truc);
+
+  if (ModMsg(msg) == PIMsg_Active) 
+     printf("Process: Setting active Wdg (%lx) \n", (long)sender); 
+
+  if (ModMsg(msg) == PIMsg_Close)
+    {
+    printf("Close Message received (Sender= %lx)\n", (long)sender);
+    return;
+    }
+
+  msg = UserMsg(msg);
+  if (msg == 33) { ckb->SetState(true);  menu->Show(); }
+    
+  if (msg == 133)
+    {
+    if (!fgpxm)  { wp3->Show();  fgpxm = true; }
+    for (int i=0; i<25000; i++)  pixels[i] = rand()%256;
+    if ((x % 3) == 0)  pxm->SetColMapId(CMAP_GREY32);
+    if ((x % 3) == 1)  pxm->SetColMapId(CMAP_COLRJ32);
+    if ((x % 3) == 2)  pxm->SetColMapId(CMAP_COLBR32);
+    }
+
+  if (msg == 333)  wp4->Show();
+  if ( (msg == 6001) || (msg == 6002) )  wp4->Hide();
+
+  if (msg == 433)
+    {
+    if (fgt2) { wp5->Hide();   fgt2 = false; }
+    else { wp5->Show();   fgt2 = true; }
+    }
+
+  if (msg == 533)
+    {
+    if (fgt3) { wp6->Hide(); fgt3 = false; }
+    else { wp6->Show(); fgt3 = true; }
+    }
+
+  if ( (msg == 1133) || (msg == 1233) )  {  // On ajoute ou on enleve un  menu du menu-bar
+    int idxmen = (msg-1133)/100;
+    cout << " Add/Remove Menu idxmen= " << idxmen << " Bool= " 
+         << Menubar()->IsSensitive(m[idxmen+3])  << " ( " << stnewmen[idxmen] << ")" << endl;
+    if ( Menubar()->IsSensitive(m[idxmen+3]) ) 
+      { Menubar()->RemoveMenu(m[idxmen+3]); stnewmen[idxmen] = false; }
+    else  { Menubar()->AppendMenu(m[idxmen+3]); stnewmen[idxmen] = true; }
+  }
+
+  if (msg == 1333) {  // Changement de sensibilite de Menu-Bar (par SetBusy())
+    cout << " SetSens() Menubar,  State= " <<  GetState()  << endl;
+    if (GetState() != kReadyState)  SetReady();
+    else  SetBlocked();
+  }
+
+  if (msg == 1533) {  // Changement de sensibilite de  Cascade
+    cout << " ChangeSensitivity()  Cascade Bool= " <<  m[1]->IsSensitive("Cascade")  << endl;
+    if (m[1]->IsSensitive("Cascade") )  m[1]->SetSensitivity("Cascade", false); 
+    else  m[1]->SetSensitivity("Cascade", true); 
+  }
+
+  if (msg == 1433) {  // Changement de sensibilite de  BaseWidget (ScSample)
+    if (scs1->IfSensitive())  scs1->SetUnSensitive();
+    else scs1->SetSensitive();
+  }
+//  if (msg == 555)   (this->menu)->Show(); 
+
+  if (msg == 10105)  scb->SetSlSize(atoi(((char *)text->GetText().c_str())));
+  if (msg == 10104)  Stop();
+  if (msg == 10101)  { pfc->AcceptNewFile(false); pfc->Show(); }
+  if (msg == 10103)  { pfc->AcceptNewFile(true); pfc->Show(); }
+
+  if ((msg == 10205) || (msg == 166))  { // CheckItem Menu  or checkbox
+    cout << "PITestApp::Process CheckItem/Box Menu (" << msg 
+         << ") State=" <<  *((bool *)data) << endl; 
+  }
+
+  if (msg == 10301)  
+   { 
+   numsg++;    
+   string nit;
+   nit = text->GetText();
+   m[1]->AppendItem((char *)nit.c_str(), numsg); 
+   opt2->SetValue(numsg);
+   }
+
+  if (msg == 10302)  { m[1]->DeleteItem((char *)text->GetText().c_str()); }
+  if (msg == 10303)  
+    {
+    string nit;
+    nit = text->GetText();
+    long ml =  atol(nit.c_str());
+    m[1]->DeleteItemMsg(ml);
+    opt2->SetValue(10201);
+    }
+
+
+  if (msg > 9000) printf("PITestApp::MenubarReturn: %d --> %lx \n", msg, (long)data);
+  if (msg == 5000)  
+    { 
+    if (data) 
+      { 
+      printf("PITestApp::Process(5000) OK from PIFileChooser: %s \n", (char *)data); 
+    }
+    else printf("PITestApp::Process(5000) Cancel from PIFileChooser (data=NULL) \n");  }
+
+  if ((msg / 100) == 56) 
+    printf("PITestApp::Process(%d) : %lx \n", (int)msg, (long)data); 
+
+  if (msg == 8811) printf("PITestApp::Process(8811) ScrollBar( %d ) \n", *( (int*)data) );
+  else if (msg == 8821) printf("PITestApp::Process(8821) ScrollBar( %d ) \n", *( (int*)data) );
+
+}
+
+int main(int narg, char *arg[])
+{
+  int mii;
+
+  if (narg < 2) {
+    printf("Usage pitst str1 [str2 ....] \n");  exit(1); 
+  }
+
+  PITestApp * app;
+  app = new PITestApp(350, 350);
+
+
+  wp4 = new PIWindow(app, "Window-4", PIWK_dialog,  200, 200, 350, 350);
+  PIButton bt1(wp4, "OK", 6001, 60, 30, 20, 160);
+  PIButton bt2(wp4, "Cancel", 6002, 60, 30, 100, 160);
+  bt1.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  bt2.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  PILabel  lb1(wp4, "Editable", 40, 30, 10, 10);
+    lb1.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  PIText  tx1(wp4, "A00", 100, 30, 60, 10);  
+    tx1.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  tx1.SetText("Hello");
+  tx1.SetTextEditable(false);
+  //  PILabel  lb2(wp4, "", 30, 20, 10, 40);
+  PIText  tx2(wp4, "A11", 180, 100, 15, 50);
+  tx2.SetMutiLineMode(true);
+  tx2.SetText(" Bonjour, \n Comment ca va ? \n A demain. ");
+    tx2.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+
+  wp3 = new PIWindow(app, "Window-3", PIWK_normal, 200, 200, 350, 350);
+  pxm = new PIPixmap(wp3, "myPixmap", 150, 150, 10, 10);
+  pxm->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed,PIBK_fixed );
+  pxm->SetPixmap(pixels, 150, 150);
+
+  wp5 = new PIWindow(app, "Window-5", PIWK_normal,  420, 450, 200, 200);
+  scs1 = new ScSample(wp5, "ScSample", 200, 200, 0, 0);
+  scs1->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  scs2 = new ScSample(wp5, "ScSample", 160, 160, 220, 20);
+  printf("DBG-WP5 (A) , SCS2, SzC %d %d , Sz %d %d Pos %d %d \n", wp5->XSize(),
+         wp5->YSize(), scs2->XSize(), scs2->YSize(),scs2->XPos(), scs2->YPos() ); 
+//  scs2->SetBinding(PIBK_elastic,PIBK_fixed,PIBK_fixed,PIBK_elastic);
+  scs2->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  printf("DBG-WP5 (B) , SCS2, SzC %d %d , Sz %d %d Pos %d %d \n", wp5->XSize(),
+         wp5->YSize(), scs2->XSize(), scs2->YSize(),scs2->XPos(), scs2->YPos() ); 
+
+  scb = new PIScrollBar(wp5, "ScBar", 8811, kSDirUpDown, 15, 420, 405, 0);
+  scb->SetBinding(PIBK_free,PIBK_fixed,PIBK_fixed,PIBK_fixed);
+  scb->ActivateDrag(true);
+  scb2 = new PIScrollBar(wp5, "ScBar", 8821, kSDirRtoL, 420, 15, 0, 425);
+  scb2->SetBinding(PIBK_fixed,PIBK_free,PIBK_fixed,PIBK_fixed);
+
+  scs3 = new ScSample(wp5, "ScSample", 200, 200, 100, 220);
+  scs3->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+
+  pfc = new PIFileChooser(app,"FileChooser", 5000); 
+//  pfc->SetPath("/exp/eros/ImagRed/");
+
+  wp6 = new PIWindow(app, "Window-List", PIWK_normal,  200, 250, 300, 400);
+  pil = new PIListX(wp6, "MyList", 200, 250, 0, 0);
+  pil->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed,PIBK_fixed);
+  for(mii=1; mii<narg; mii++)
+    {
+//    printf("AppendItem[%d] - %s (%ld) \n", mii, arg[mii],  3330+mii);  
+     pil->AppendItem(arg[mii], 3330+mii);  
+//    puts("Append-OK");
+    }
+  pil->SetMultipleSelect(true);
+  pil->SelectItem("user.cc");
+//  Int32 ioNumber = 100;
+  app->Run();
+  delete app;
+  exit(0);
+}
Index: /tags/DPC_V0/Poubelle/PI/exclude
===================================================================
--- /tags/DPC_V0/Poubelle/PI/exclude	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/exclude	(revision 1307)
@@ -0,0 +1,28 @@
+piapplmac.cc
+pibwdgmac.cc
+picmapmac.cc
+picontainermac.cc
+pifilechomac.cc
+pigraphmac.cc
+pilistmac.cc
+pimenubarmac.cc
+pimenumac.cc
+pioptmenumac.cc
+pipixmapmac.cc
+pippapplmac.cc
+pippwindowmac.cc
+pistdwdgmac.cc
+piwdgmac.cc
+piwindowmac.cc
+pippapplmac.cc
+pipplist.cc
+pippmenubar.cc
+pippoptmenu.cc
+pippviewadapter.cc
+pippwindowmac.cc
+piupdattachment.cc
+pierrdisp.cc
+piup.cc
+piup_def.cc
+xdispim.c
+piup.c
Index: /tags/DPC_V0/Poubelle/PI/lut.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/lut.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/lut.cc	(revision 1307)
@@ -0,0 +1,106 @@
+// Classe Look-Up-Table  pour convertir image en entree ds
+// une table de couleur.
+//       Classe LUT              R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "defs.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "lut.h"
+
+
+/* --Methode-- */
+
+LUT::LUT(double min, double max, unsigned short ncol, int typ, int ntable) 
+{
+int nlev;
+
+bornes=NULL;  
+nlev = ncol-2;
+if (nlev < 1)  nlev = 1;
+bornes = new double[nlev+1];
+
+if (bornes == NULL)  return;
+type = typ;  nLevel = nlev;
+SetLut(min, max, typ);
+table = NULL;  
+ComputeTable(ntable);
+return;
+}
+
+/* --Methode-- */
+LUT::~LUT()
+{
+if (type<0)  return;
+delete[] bornes;
+delete[] table;
+}
+
+/* --Methode-- */
+void LUT::SetLut(double min, double max, int typ)
+{
+
+if ( (typ != kLutType_Lin) && (typ != kLutType_Log) )  typ = kLutType_Lin;
+type = typ;
+if (max <= min)  max = min+1.;
+if (nLevel > 0)
+  {
+  int i;
+  double dx;
+  double dlx;
+  switch (typ)
+    {
+    case kLutType_Lin :
+      dx = (max-min)/(double)nLevel;
+      for(i=0; i<nLevel; i++)
+        bornes[i] = min+(double)i*dx;
+      break;
+    case kLutType_Log :
+      dlx = log(max-min) / (double)nLevel;
+      for(i=0; i<nLevel; i++)
+        bornes[i] = min+(double)exp((double)i*dlx);
+      break;
+    default:
+      for(i=0; i<nLevel; i++)
+        bornes[i] = min;
+      break;
+    }
+  bornes[nLevel] = max; 
+  }
+else  bornes[0] = 0.5*(min+max);
+return; 
+}
+
+/* --Methode-- */
+void LUT::Print()
+{
+int i;
+
+printf("LUT_Info: Type= %d NLevel= %d Min,Max= %g %g \n",
+       type, nLevel, bornes[0], bornes[nLevel]);
+for(i=0; i<=nLevel; i++)
+  printf("..Bornes[%d] = %g \n", i, bornes[i]);
+return;
+}
+
+/* --Methode-- */
+unsigned short LUT::Apply(double x)
+{
+int i;
+for(i=0;i<=nLevel;i++)  
+  if (x < bornes[i])  return(i);
+return(nLevel+1);
+}
+
+/* --Methode-- */
+void LUT::ComputeTable(int nt)
+{
+if (nt < 0) nt = 16*(nLevel+2);
+else if (nt < (nLevel+2))  nt = (nLevel+2);
+table = new unsigned short [nt-2];
+tablebinwidth = (Max()-Min())/(nt-2);
+double x = Min()+0.5*tablebinwidth;
+for(int i=0; i<nt-2; i++)  { table[i] = Apply(x); x += tablebinwidth; }
+}
Index: /tags/DPC_V0/Poubelle/PI/lut.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/lut.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/lut.h	(revision 1307)
@@ -0,0 +1,54 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe Look-Up-Table  pour convertir image en entree ds
+// une table de couleur.
+//       Classe LUT              R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef LUT_SEEN
+#define LUT_SEEN
+
+// LUT : Look-Up-Table avec nLevel bins entre min et max
+// Apply retourne * 0 < min   * nLevel+1 > max 
+// et de 1 a nLevel pour min<=x<max
+
+// Type de lut possibles (Seul Lineaire implemente 05/95
+enum {kLutType_Lin=1, kLutType_Log=2};
+
+class LUT 
+{
+public:
+  
+  LUT(double min, double max, unsigned short ncol=16, int typ=kLutType_Lin, int ntable=-1);
+  ~LUT();
+  void SetLut(double min, double max, int typ=0);
+  void Print();
+  unsigned short Apply(double x);
+  inline unsigned short ApplyFast(double x)
+    { 
+    if (x < Min())  return(0);
+    if (x >= Max() )  return(nLevel+1);  
+    int k = (int)((x-Min())/tablebinwidth);
+    return(table[k]); 
+    } 
+
+  inline double Min() { return(bornes[0]); };
+  inline double Max() { return(bornes[nLevel]); };
+  inline int Type() { return(type); };
+  inline int NCol() { return(nLevel+2); };
+
+protected:
+  void ComputeTable(int nt);
+
+  int type;
+  int nLevel;
+  double * bornes;
+  unsigned short * table;
+  double tablebinwidth;
+
+};
+
+#endif
+
+
+
+  
Index: /tags/DPC_V0/Poubelle/PI/parradapter.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/parradapter.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/parradapter.cc	(revision 1307)
@@ -0,0 +1,371 @@
+//     Classes ArrayAdapter           R. Ansari  05/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+// #include "ctimer.h"   Pour mesure TCPU 
+#include "parradapter.h"
+
+/* --Methode-- */
+P1DArrayAdapter::P1DArrayAdapter(int sz)
+{
+mSize=sz;
+DefineXCoordinate(0, 1.);
+}
+
+/* --Methode-- */
+P1DArrayAdapter::~P1DArrayAdapter()
+{
+}
+
+/* --Methode-- */
+void P1DArrayAdapter::DefineXCoordinate(double x0, double dx)
+{
+mOx = x0;  mDx = dx;
+}
+
+/* --Methode-- */
+double P1DArrayAdapter::X(int i)
+{
+return(mOx+mDx*i);
+}
+
+/* --Methode-- */
+P2DArrayAdapter::P2DArrayAdapter(int sx, int sy)
+{
+sX = sx; sY = sy; 
+sgnX = sgnY = 1;
+offX = offY = 0;
+invX = invY = eXY = false;
+DefineXYCoordinates(0.,0.,1.,1.);
+}
+
+/* --Methode-- */
+P2DArrayAdapter::~P2DArrayAdapter()
+{
+}
+
+/* --Methode-- */
+void P2DArrayAdapter::ConfigureAxes(bool invx, bool invy, bool exy, int sx, int sy)
+{
+invX = invx;  invY = invy;  eXY = exy; 
+if ( (sx > 0) && (sy > 0) )   { sX = sx; sY = sy; }
+if (invX) { sgnX = -1;  offX = sX-1; } 
+else { sgnX = 1; offX = 0; }
+if (invY) { sgnY = -1;  offY = sY-1; } 
+else { sgnY = 1; offY = 0; }
+}
+
+/* --Methode-- */
+void P2DArrayAdapter::DefineXYCoordinates(double x0, double y0, double dx, double dy)
+{
+mOx = x0;   mOy = y0;
+mDx = dx;   mDy = dy;
+}
+
+/* --Methode-- */
+void P2DArrayAdapter::XYfromxy(int ix, int iy, double& x, double& y)
+{
+x = mOx+ix*mDx;
+y = mOy+iy*mDy; 
+}
+
+/* --Methode-- */
+int P2DArrayAdapter::CheckDyn(double& min, double& max, double& moy, double& sig, int& nbnul, int& nbsat, int vit)
+{
+// TIMEF ; 
+double m = 0.;
+double s = 0.;
+double dv; 
+
+int n9 = 0;
+int n0 = 0;
+
+if (min >= max) { min = -9.e19; max = 9.e19; }
+double minpix = max;
+double maxpix = min; 
+double pixv;
+// printf("DEBUG_CHECKDYN-IN %d - %g %g ", vit, min, max);
+
+int n = 0;
+if (vit < 1) vit = 1;
+if (sX*sY/vit < 1000) {
+  vit = sX*sY/1000;
+  if (vit < 1) vit = 1;
+}
+
+// printf(" -> vit=%d \n", vit);
+for(int j=0; j<sY; j++) 
+  for(int i=0; i<sX; i++)   {
+    if (++n % vit != 0)  continue;
+    pixv = Value(i,j);
+    if (pixv <= max && pixv >= min) {  
+      if (pixv < minpix)  minpix = pixv;
+      if (pixv > maxpix)  maxpix = pixv; 
+      dv = (double)pixv;
+      m += dv;  s += (dv*dv);
+      }
+    else  {  
+      if (pixv > max)  n9++;
+      if (pixv < min)  n0++; 
+    }
+  }
+
+nbnul = n0*vit;  nbsat = n9*vit;
+min = minpix;  max = maxpix; 
+
+n -= (n0+n9);
+if (n > 0)
+  { dv = (double)n;  m /= dv;  s = s/dv - m*m;
+  if (s>0.)  s = sqrt(s);  else s = 0.;
+  moy = m;  sig = s; }
+else { moy = 0.;  sig = -1.; }
+
+// printf("DEBUG_CHECKDYN: %d %g %g - %g %g \n", n, min, max, moy, sig);
+return(n);
+}
+
+
+/* --Methode-- */
+void P2DArrayAdapter::ComputeLut_PicHisto(double& min, double& max, int nbsig, double fracmax)
+{
+// TIMEF ; 
+int MINNBIN = 64;
+int MAXNBIN = 1024;
+
+int nbin = sX*sY/10;
+nbin = (nbin < MINNBIN) ? MINNBIN : ((nbin > MAXNBIN) ? MAXNBIN : nbin );
+int vitesse = sX*sY / 20000;
+vitesse = (vitesse < 1) ? 1 : ((vitesse > 25) ? 25 : vitesse );
+
+
+//  Variable decrivant l'histogramme 
+double minhis, maxhis, binwidth;
+int under,over,tothis;
+int *phis;
+int *q;
+
+double MINDYNAMIC = 1.e-8;          /* Gamme dynamique minimale (MaxAff-MinAff)*/
+double FRACPIC = 0.6065;            /*  Valeur de exp(-0.5)   */
+
+
+
+if ( min >= (max-MINDYNAMIC) ) { 
+  int nbnul, nbsat, nok;
+  double moy, sig; 
+  nok = CheckDyn(min, max, moy, sig, nbnul, nbsat, vitesse);
+  if (nok < 1) { min=0.; max = 1.;  return; }
+  }
+if ( min >= (max-MINDYNAMIC) )  max = min+MINDYNAMIC;
+minhis = min;
+maxhis = max;
+binwidth = (maxhis-minhis) / nbin;
+if (binwidth < MINDYNAMIC/MINNBIN) { 
+  binwidth = MINDYNAMIC/MINNBIN;
+  maxhis = nbin*binwidth + minhis;
+  }
+// printf("DEBUG nbin minhis maxhis binwidth = %d %g %g %g \n", nbin, minhis, maxhis, binwidth);
+
+/* allocation dynamique de memoire et mise a zero de l'histogramme */
+phis = new int_4[nbin];
+for ( q=phis ; q<phis+nbin ; *q++ = 0 )  ;
+under = over = tothis = 0;
+
+//  Boucle sur les pixels   
+//  Pour aller plus vite, on prend un pixel sur vitesse   
+int kk = 0;
+int bin;
+for(int j=0; j<sY; j++)
+  for(int i=0; i<sX; i++) {
+    if ( (++kk % vitesse) != 0) continue;
+   /* remplissage de l'histogramme */
+    bin = (int)((Value(i, j) - minhis) / binwidth) ;
+    if ( bin < 0 )  under++;
+    else  {
+      if (bin < nbin) { (*(phis+bin))++; tothis++; }
+      else   over++; 
+      }
+    }     /*  Fin de for : Boucle sur les pixels   */
+
+/*  On verifie qu'il y a eu une entree ds l'histo */
+if (tothis <= 0)
+  { delete[] phis;  return; }
+  
+/* recherche du maximum */
+int binmax = -1 ; 
+int hmax = -1 ; 
+q = phis;
+for (kk = 0 ; kk < nbin ;  kk++, q++ )
+  if ( *(q) > hmax ) {hmax = *(q) ; binmax = kk ;}
+
+if ( (binmax < 0) || (binmax >= nbin) )
+  { delete[] phis;  return; }
+
+
+/*   On va chercher le sigma du fond  SigmaLeft, SigmaRight */
+int hmin = (int) ( (double)(hmax) * FRACPIC ) ;
+
+int sigr = 0;
+q = phis+binmax;
+while ( ((*q) > hmin) && (sigr < (nbin-binmax)) )  { sigr++;  q++; }
+int sigl = 0;
+q = phis+binmax;
+while ( ((*q) > hmin) && (sigl < binmax) )  { sigl++; q--; }
+
+
+if (nbsig == 0) nbsig = 1;
+if (nbsig < 0)  {  /*   On considere le cas ou NbSigmas est negatif   */
+  if ( (bin = binmax+nbsig*sigl) < 0 )  bin = 0;
+  min = minhis + (double)bin*binwidth;
+  if ( (bin = binmax-nbsig*sigr) >= nbin ) bin = nbin-1;
+  max = minhis + (double)bin*binwidth;
+  if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
+  delete[] phis;  return; 
+  }
+
+// NbSigma positif 
+if ( (bin = binmax+nbsig*sigl) >= nbin ) {
+  min = minhis + binmax*binwidth;
+  max = maxhis;
+  if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
+  delete[] phis;  return;
+  }
+
+min = minhis + bin*binwidth;
+
+/*   Calcul du nb de pixel entre MinAff et ValSat  */
+int nbpix = 0;
+for( q = phis+bin ; q < phis+nbin ; q++)  nbpix += (*q);
+nbpix = (int_4)((double)nbpix * fracmax);
+int nbpix2 = 0; q = phis+bin; 
+int k = bin;
+while( (nbpix2 < nbpix) && (k < nbin) )  
+  { nbpix2 += (*q); k++; q++; }
+
+max = minhis + (double)k*binwidth;
+delete[] phis;
+if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
+
+return;
+}
+
+
+/* --Methode-- */
+unsigned char * P2DArrayAdapter::ComputePixmap(LUT* lut, int ofx, int ofy, int zm, 
+                int xwsz, int ywsz, unsigned char * opix, int * oxsp, int * oysp)
+{
+// TIMEF ; 
+unsigned char *pix, *pp, ucp;
+int zmm=1;
+int npx, npy, nppx, nppy, nszp, oszp;
+int i,j,k,l;
+double vpx;
+
+
+if ( (XSize() <= 0) || (YSize() <= 0) || (lut == NULL) ) 
+  { *oxsp = *oysp = 0; return(NULL); }
+
+npx = XSize()-ofx;
+npy = YSize()-ofy;
+
+if ((zm == 0) || (zm == -1))  zm = 1;
+
+if (zm >= 1)
+  {
+  if (npx > (xwsz/zm))  npx = xwsz/zm; 
+  if (npy > (ywsz/zm))  npy = ywsz/zm;
+  nppx = npx*zm;   nppy = npy*zm;
+  }
+else
+  {
+  zmm = -zm;
+  nppx = npx/zmm;   nppy = npy/zmm;
+  if (nppx > xwsz)  nppx = xwsz; 
+  if (nppy > ywsz)  nppy = ywsz;
+  npx = nppx*zmm;   npy = nppy*zmm; 
+  }
+
+oszp = (*oxsp)*(*oysp);
+nszp = nppx*nppy;
+if ( oszp != nszp )
+  {
+  if (opix)  delete[] opix;
+  pix = new unsigned char[nppx*nppy];
+  if (pix == NULL)  { *oxsp = *oysp = 0; ; return(NULL); }
+  }
+else  pix = opix;
+*oxsp = nppx; *oysp = nppy;
+
+/*
+printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n", 
+      ofx, ofy, zm, npx,nppx, npy,nppy);
+*/
+
+pp = pix;
+if (eXY) { // Echange Axe X,Y 
+  if (zm == 1)  {  // Pas de zoom  
+    for(j=ofy; j<ofy+npy; j++)
+      for(i=ofx; i<ofx+npx; i++) 
+        { *pp = (unsigned char) lut->ApplyFast( 
+                this->Value(j*sgnX+offX, i*sgnY+offY));  
+           pp++; }
+    }
+  else if (zm < -1) {       // Compression 
+    double fv = (double)(zmm*zmm); 
+    for(j=ofy; j<ofy+npy; j+=zmm)
+      for(i=ofx; i<ofx+npx; i+=zmm) {
+        vpx = 0;
+        for(l=0; l<zmm; l++)
+          for(k=0; k<zmm; k++)
+            vpx += this->Value( (j+l)*sgnX+offX, (i+k)*sgnY+offY);
+        *pp = (unsigned char) lut->ApplyFast(vpx/fv); 
+        pp++;
+        }
+    }
+  else  {      // Agrandissement
+    for(j=ofy; j<ofy+npy; j++)
+      for(i=ofx; i<ofx+npx; i++)  {
+        ucp = (unsigned char) lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY));
+        for(l=0; l<zm; l++)  {
+          pp = pix+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
+          for(k=0; k<zm; k++)  { *pp = ucp; pp++; }  
+	  }
+        }
+    }
+  }     // Fin du cas avec echange d'axe X/Y 
+else {
+  if (zm == 1)  {  // Pas de zoom  
+    for(j=ofy; j<ofy+npy; j++)
+      for(i=ofx; i<ofx+npx; i++) 
+        { *pp = (unsigned char) lut->ApplyFast( 
+                this->Value(i*sgnX+offX, j*sgnY+offY));  
+           pp++; }
+    }
+  else if (zm < -1) {       // Compression 
+    double fv = (double)(zmm*zmm); 
+    for(j=ofy; j<ofy+npy; j+=zmm)
+      for(i=ofx; i<ofx+npx; i+=zmm) {
+        vpx = 0;
+        for(l=0; l<zmm; l++)
+          for(k=0; k<zmm; k++)
+            vpx += this->Value( (i+k)*sgnX+offX, (j+l)*sgnY+offY);
+        *pp = (unsigned char) lut->ApplyFast(vpx/fv); 
+        pp++;
+        }
+    }
+  else  {      // Agrandissement
+    for(j=ofy; j<ofy+npy; j++)
+      for(i=ofx; i<ofx+npx; i++)  {
+        ucp = (unsigned char) lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY));
+        for(l=0; l<zm; l++)  {
+          pp = pix+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
+          for(k=0; k<zm; k++)  { *pp = ucp; pp++; }  
+	  }
+        }
+    }
+  }
+return(pix);
+}
+
Index: /tags/DPC_V0/Poubelle/PI/parradapter.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/parradapter.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/parradapter.h	(revision 1307)
@@ -0,0 +1,118 @@
+// This may look like C code, but it is really -*- C++ -*-
+//     Classes ArrayAdapter           R. Ansari  05/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+
+#ifndef PARRADAPTER_SEEN
+#define PARRADAPTER_SEEN
+
+#include "defs.h"
+#include "machine.h"
+#include "lut.h"
+
+class P1DArrayAdapter {
+public :
+                  P1DArrayAdapter(int sz=0);
+  virtual         ~P1DArrayAdapter();
+ 
+  virtual double  Value(int i) = 0;
+  inline  int     Size() { return (mSize) ; }
+  virtual void    DefineXCoordinate(double x0, double dx);
+  virtual double  X(int i);
+     
+protected :
+  int mSize;
+  double mOx, mDx;
+};
+
+// Cette classe est un adaptateur pour les PIImages et 
+// autres classes de PI qui operent sur des structures 
+// de type Tableaux 2-D (images, ...) 
+
+class P2DArrayAdapter {
+public :
+                  P2DArrayAdapter(int sx=0, int sy=0);
+  virtual 	  ~P2DArrayAdapter();
+
+  void  	  ConfigureAxes(bool invx=false, bool invy=false, bool exy=false,
+                                int sx=-1, int sy=-1);
+
+  inline void     GetAxesConfiguration(bool& invx, bool& invy, bool& exy)
+                               { invx = invX; invy = invY; exy = eXY; }
+
+  virtual void    DefineXYCoordinates(double x0, double y0, double dx, double dy);
+// Doit etre defini par les classes derivees
+  virtual double  Value(int ix, int iy) = 0;   
+
+  virtual void    XYfromxy(int ix, int iy, double& x, double& y);
+
+  inline  int     XSize() { return ( eXY ? sY : sX ) ; }
+  inline  int     YSize() { return ( eXY ? sX : sY ) ; }
+
+  inline  void    XYCoord(int i, int j, double& x, double& y)
+                         { int ix, iy;  IJ2xy(i, j, ix, iy); 
+                           XYfromxy(ix, iy, x, y); }
+  inline  void    Coord(int i, int j, double& x, double& y)
+                       { int ix, iy;  double f; IJ2xy(i, j, ix, iy); 
+                       XYfromxy(ix, iy, x, y); if (eXY) {f=x; x=y; y=f; } }
+  inline  double  operator() (int i, int j) 
+                         { int ix, iy;  IJ2xy(i, j, ix, iy); 
+                         return Value(ix, iy); }
+  inline void     IJ2xy(int i, int j, int& x, int& y)
+                  { if  (eXY) {int ii = i; i = j; j = ii; }
+                  x = i*sgnX+offX; y = j*sgnY+offY; 
+                  return; }
+
+//    Calcul Min-Max, Moy-Sig
+  virtual int     CheckDyn(double& min, double& max, double& moy, double& sig, int& nbnul, int& nbsat, int vit=10);
+//    Calcul AutoLut
+  virtual void    ComputeLut_PicHisto(double& min, double& max, int nbsig=1, double fracmax=0.95);
+
+//    Calcul pixmap avec un LUT
+  virtual unsigned char * ComputePixmap(LUT* lut, int ofx, int ofy, int zm, 
+                           int xwsz, int ywsz, unsigned char * opix, 
+                           int * oxsp, int * oysp);
+protected :
+  int sX, sY;
+  double mOx, mDx, mOy, mDy;
+  int sgnX, sgnY;
+  int offX, offY;
+  bool invX, invY, eXY;
+};
+
+template <class T> 
+class P1DAdapter : public P1DArrayAdapter {
+public :
+                  P1DAdapter(T* data, int sz, bool ad=false) :
+                    P1DArrayAdapter(sz)
+                    { aDel = ad; mData = data; }
+
+  virtual 	  ~P1DAdapter() { if ( (aDel) && (mData != NULL) ) delete[] mData; }
+  virtual double  Value(int i) 
+                    {  if ( (i < 0) || (i >= mSize) ) return(0.); 
+                    return(mData[i]); }
+protected :
+  bool aDel;
+  T* mData;
+};
+
+
+template <class T> 
+class P2DAdapter : public P2DArrayAdapter {
+public :
+                  P2DAdapter(T* data, int sx, int sy, bool ad=false) :
+                    P2DArrayAdapter(sx, sy)
+                    { aDel = ad; mData = data; }
+
+  virtual 	  ~P2DAdapter() { if ( (aDel) && (mData != NULL) ) delete[] mData; }
+  virtual double   Value(int ix, int iy) 
+                    {  if ( (ix < 0)  || (iy < 0) || (ix >= sX) || (iy >= sY) ) return(0.); 
+                    return(mData[ix+iy*sX]); }
+protected :
+  bool aDel;
+  T* mData;
+};
+
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pi.rsc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pi.rsc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pi.rsc	(revision 1307)
@@ -0,0 +1,28 @@
+PeidaInt*background:                         LightGrey
+PeidaInt*default*background:                 LightGrey
+PeidaInt*bottomShadowColor:                  Black
+PeidaInt*default*bottomShadowColor:          Black
+PeidaInt*Foreground:                         Black
+PeidaInt*default*Foreground:                 Black
+PeidaInt*topShadowColor:                     White
+PeidaInt*default*topShadowColor:             White
+PeidaInt*borderColor:                        Black
+
+PeidaInt*XmLabel.borderWidth:                1
+PeidaInt*XmScrollBar*background:             LightBlue
+PeidaInt*XmDrawingArea*background:           Black
+PeidaInt*XmPushButton*borderWidth:           0
+
+PeidaInt*XmText*XmNshadowThickness:          1
+PeidaInt*XmText*XmNhighlightThickness:          2
+
+PeidaInt*DefMenubar*XtNwidth:           250
+PeidaInt*DefMenubar*XtNheight:          30
+
+PeidaInt*fontList:           -*-helvetica-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1
+PeidaInt*default*fontList:    -*-helvetica-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1
+
+# Attention, ne pas mettre de blanc a la fin du nom de fonte
+PeidaInt*fontFamilyName:   *-helvetica
+
+PeidaInt*XmToggleButton*selectColor:                  Red
Index: /tags/DPC_V0/Poubelle/PI/pi3ddrw.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pi3ddrw.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pi3ddrw.cc	(revision 1307)
@@ -0,0 +1,725 @@
+// Module PI : Peida Interactive PIDrawer3D PIDraw3DWdg
+// Drawer et DrawWidget 3D       R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "pi3ddrw.h"
+#include "pidrwtools.h"
+
+
+// ......................................................................
+// ........................  Classe PIDrawer3D ..........................
+// ......................................................................
+//++
+// Class	PIDrawer3D
+// Lib		PI
+// include	pidrawer.h
+//
+//	Classe pour la création d'objets, capables de produire
+//	un dessin 3D dans une composante graphique.
+//--
+//++
+// Links	Parent
+// PIDrawer
+//--
+//++
+// Links	Voir aussi
+// PIGraphic3D
+// PIDraw3DWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIDrawer3D()
+//	Cosntructeur
+// void Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, -
+//               double dax, double day, double co, double dco=0.2)
+//	Définition de la vue 3D. Voir "PIGraphic3D::Set3DCS_Obs(...)"
+// void Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, -
+//                double dax, double day, double dco=0.2, double psi=0.)
+//	Définition de la vue 3D. Voir "PIGraphic3D::Set3DCS(...)"
+// bool Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, -
+//                double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco)
+//	Renvoie la définition de la Vue-3D. Retourne "true " si définie par "Set3DView_Obs()"
+// void Draw3DBoxe(PIGraphic3D* g3, double xx1, double xx2, double yy1, double yy2,  -
+//                 double zz1, double zz2, double xl1, double xl2, -
+//                 double yl1, double yl2, double zl1, double zl2)
+//	Trace une boîte avec les coordonnées matérialisant la vue 3D.
+//--
+
+/* --Methode-- */
+PIDrawer3D::PIDrawer3D()
+        : PIDrawer()
+{
+  xO = yC = 0.; zO = -10.;
+  xC = yC = zC = 0.;
+  tO = fO = pO = 0.; 
+  daxO = dayO = 0.25;
+  lCO = 10.;  dlCO = 3.;  
+  v3D_obs = false;
+  x3Min = y3Min = z3Min = -1.;  
+  x3Max = y3Max = z3Max = 1.;
+}
+
+/* --Methode-- */
+PIDrawer3D::~PIDrawer3D()
+{
+}
+
+/* --Methode-- */
+void PIDrawer3D::Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                               double dax, double day, double co, double dco)
+{
+  tO = teta;  fO = phi;  pO = psi;
+  daxO = dax;  dayO = day;
+  lCO = co;   dlCO = dco;
+  v3D_obs = true;
+}
+
+/* --Methode-- */
+void PIDrawer3D::Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, 
+                           double dax, double day, double dco, double psi)
+{
+  xC = xc;  yC = yc;  zC = zc;
+  xO = xo;  yO = yo;  zO = zo;
+  pO = psi;
+  daxO = dax;  dayO = day;
+  dlCO = dco;
+  v3D_obs = false;
+}
+
+/* --Methode-- */
+bool PIDrawer3D::Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo,
+                           double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco)
+{
+  xo = xO;  yo = yO;  zo = zO;
+  xc = xC;  yc = yC;  zc = zC;
+  teta = tO;  phi = fO;  psi = pO;
+  dax = daxO;   day = dayO;
+  co = lCO;     dco = dlCO;
+  return(v3D_obs);
+}
+
+/* --Methode-- */
+PIGraphicUC* PIDrawer3D::SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g)
+{
+  mBWdg = drw;
+  xW0 = x0;   yW0 = y0;
+  xWd = dx;   yWd = dy;
+  if (mGrUC)  delete mGrUC;
+  PIGraphic3D* gr3d;
+  gr3d = new PIGraphic3D(g, x0, y0, dx, dy);
+  if (v3D_obs)  gr3d->Set3DCS_Obs(xO, yO, zO, tO, fO, pO, daxO, dayO, lCO, dlCO);
+  else  gr3d->Set3DCS(xC,yC,zC, xO, yO, zO, daxO, dayO, dlCO, pO);
+  mGrUC = gr3d;
+  return(gr3d); 
+}
+
+/* --Methode-- */
+void PIDrawer3D::DrawAxes(PIGraphicUC* g)
+{
+  if (axesFlags == kAxesNone) return;
+#if defined(__DECCXX) || defined(__KCC__)
+  PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+  PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+  Draw3DBoxe(g3, XMin3(), XMax3(), YMin3(), YMax3(), ZMin3(), ZMax3(),
+                 XMin3(), XMax3(), YMin3(), YMax3(), ZMin3(), ZMax3());  
+}
+
+/* --Methode-- */
+void PIDrawer3D::Draw3DBoxe(PIGraphic3D* g3, 
+                            double xx1, double xx2, double yy1, double yy2, 
+                            double zz1, double zz2, double xl1, double xl2, 
+                            double yl1, double yl2, double zl1, double zl2)
+{
+  if (mLAtt == PI_NotDefLineAtt)    g3->SelLine(PI_ThinLine);
+  if (mFSz == PI_NotDefFontSize)    g3->SelFontSz((YMax()-YMin())/150.);
+
+  PIGrCoord x1,y1,z1,x2,y2,z2;
+  char strg[64];
+  int k;
+  int NTicks = 5;  // Nb de ticks sur chaque axe
+
+  x1 = xx1;  y1 = yy1;  z1 = zz1;
+  x2 = xx2;   y2 = yy1;   z2 = zz1; 
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  y1 = y2 = yy2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  z1 = z2 = zz2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  y1 = y2 = yy1;  
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+
+// Trace des ticks et labels axe X :
+  x1 = x2 = xx1;   y1 = y2 = yy1;  z1 = z2 = zz1;
+  for (k=0; k<NTicks; k++) {
+    x1 = x2 = (xx1+(double)k*(xx2-xx1)/(NTicks-1.));
+    z1 = zz1; z2 = zz1-0.02*(zz2-zz1);
+    y1 = y2 = yy1;
+    g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+    z2 = zz1-0.05*(zz2-zz1); 
+    y2 = yy1-0.075*(yy2-yy1);  
+    sprintf(strg,"%.2g", xl1+(double)k*(xl2-xl1)/(NTicks-1.));
+    g3->DrawString3D(x2, y2, z2, strg);
+    }
+  x2 = xx2+0.075*(xx2-xx1);  y2 = yy1;   z2 = zz1-0.05*(zz2-zz1); 
+  g3->DrawString3D(x2, y2, z2, "X");
+
+  x1 = xx1;  y1 = yy1;  z1 = zz1;
+  x2 = xx1;   y2 = yy2;   z2 = zz1; 
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  z1 = z2 = zz2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx1;  
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx2;   y1 = y2 = yy1;  z1 = z2 = zz1;
+  for (k=1; k<NTicks; k++) {   // Attention, par le tick 0 pour Y
+    y1 = y2 = (yy1+(double)k*(yy2-yy1)/(NTicks-1.));
+    z2 = zz1-0.02*(zz2-zz1);
+    x1 = x2 = xx2; 
+    g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+    z2 = zz1-0.05*(zz2-zz1); 
+    x2 = xx2+0.075*(xx2-xx1);  
+    sprintf(strg,"%.2g", yl1+(double)k*(yl2-yl1)/(NTicks-1.));
+    g3->DrawString3D(x2, y2, z2, strg);
+    }
+  x2 = xx2;  y2 = yy2+0.075*(yy2-yy1);   z2 = zz1-0.05*(zz2-zz1); 
+  g3->DrawString3D(x2, y2, z2, "Y");
+
+  x1 = xx1;  y1 = yy1;  z1 = zz1;
+  x2 = xx1;   y2 = yy1;   z2 = zz2; 
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  y1 = y2 = yy2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx1;  
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx1;   y1 = y2 = yy1;  z1 = z2 = zz1;
+  for (k=0; k<NTicks; k++) {
+    z1 = z2 = (zz1+(double)k*(zz2-zz1)/(NTicks-1.));
+    y2 = yy1-0.015*(yy2-yy1);
+    x2 = xx1-0.015*(xx2-xx1);
+    g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+    x2 = xx1-0.1*(xx2-xx1);  
+    y2 = yy1-0.1*(yy2-yy1);  
+    sprintf(strg,"%.2g", zl1+(double)k*(zl2-zl1)/(NTicks-1.));
+    g3->DrawString3D(x2, y2, z2, strg);
+    }
+  x2 = xx1-0.075*(xx2-xx1);  y2 = yy1-0.075*(yy2-yy1);   z2 = zz2+0.05*(zz2-zz1); 
+  g3->DrawString3D(x2, y2, z2, "Z");
+
+}
+
+// ......................................................................
+// .......................  Classe PIDraw3DWdg ..........................
+// ......................................................................
+
+//++
+// Class	PIDraw3DWdg
+// Lib		PI
+// include	pi3ddrw.h
+//
+//   	Classe pour la l'affichage et la manipulation d'un ensemble
+//	de *Drawer3D* avec la gestion de zoom, rotation, déplacement
+//	d'objet.
+//	* Bouton-1 : Envoie le message "PIMsg_Active".
+//	* Bouton-2 : Permet de faire tourner l'observateur (caméra) 
+//	autour de l'objet.
+//	* Shift-Bouton-2 : Permet de tourner l'objet en maintenant 
+//	la caméra fixe. Cette fonction peut-être réalisée sans le shift
+//	à partir du centre de l'objet, en l'ayant préalablement activée
+//	par <Alt>S.
+//	* Bouton-3 : Gestion de zoom (On approche/ éloigne la caméra, ou 
+//	on change l'angle d'ouverture) 
+//
+//	Gestion du clavier :
+//	* <Alt>G : Affichage d'une fenêtre de changement des attributs graphiques
+//	* <Alt>O : Action identique a <Alt>G
+//	* <Alt>V : Copier/*Coller* Ajout du texte du buffer copier/coller
+//	sur l'objet à la position courante de la souris
+//	* <Alt>Z : Supprime les textes et signes ajoutés au dessin.
+//	* <Alt>A : Active/desactive l'affichage des axes
+//	* <Alt>R : Reinitialise la vue 3D (vue par défaut) et rafraichit le dessin.
+//	* <Alt>S : Active/desactive le mode de rotation d'objet sans Shift
+//
+//--
+//++
+// Links	Parents
+// PIBaseWdg
+//--
+//++
+// Links	Voir aussi
+// PIDrawer3D
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIDraw3DWdg(PIContainerGen *par, char *nom, int sx=100, int sy=100, int px=0, int py=0)
+//	Constructeur
+// long	 kind()
+//	Renvoie le type de l'objet ("=PIDraw3DWdg::ClassId")
+// int AddDrawer3D(PIDrawer3D*, bool ad=false)
+//	Ajoute un Drawer3D
+//--
+
+/* --Methode-- */
+PIDraw3DWdg::PIDraw3DWdg(PIContainerGen *par, char *nom, int sx, int sy, int px, int py)
+        : PIBaseWdg(par, nom, sx, sy, px, py)
+{  
+  vfixed = false;
+//  SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true);
+  SetDefaultDrawRectangle(0., 0., 1., 1., true);
+  mBDrw = new PIElDrawer;
+  mBDrw->SetLimits(0.12,0.88, 0.12,0.88, kAxeDirLtoR,kAxeDirDownUp);
+  AddDrawer(mBDrw, 0.12, 0.12, 0.88, 0.88, true, false, false);
+  mPx = mPy = 0;
+
+  lPx = lPy = 0;
+  lCol = PI_Black;
+  cTeta = cPhi = 0.;  cUlen = 1.;
+
+  ActivateKeyboard();
+  ActivateButton(2);    //  Pour pouvoir tourner la camera
+  ActivateMove(2);      
+  ActivateButton(3);    //  Pour deplacer la camera le long de son axe
+  ActivateMove(3);
+  ActivateButton(1);    
+
+  mGr3d = new PIGraphic3D(mWGrC, 0, 0, sx, sy);
+  rOfg = false;
+  axfg = true;
+  skcfg = false;
+}
+
+/* --Methode-- */
+PIDraw3DWdg::~PIDraw3DWdg()
+{
+  delete mBDrw;
+  delete mGr3d;
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                                double dax, double day, double co, double dco)
+{
+  mGr3d->Set3DCS_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  list<int>::iterator it;
+  for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+#if defined(__DECCXX) || defined(__KCC__)
+    (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)))->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+#else
+    ((PIDrawer3D*)(GetDrawerId(*it)))->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+#endif
+  vfixed = true;
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, 
+                            double dax, double day, double dco, double psi)
+{
+  mGr3d->Set3DCS(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+  list<int>::iterator it;
+  for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+#if defined(__DECCXX) || defined(__KCC__)
+    (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)))->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+#else
+    ((PIDrawer3D*)(GetDrawerId(*it)))->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+#endif
+  vfixed = true;
+}
+
+/* --Methode-- */
+bool PIDraw3DWdg::Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, 
+                            double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco)
+{
+  return(mGr3d->Get3DCS(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco));
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::Update3DView()
+{
+  list<int>::iterator it = m3DrIl.begin();
+  if (it == m3DrIl.end())  return;
+#if defined(__DECCXX) || defined(__KCC__)
+  PIDrawer3D* dr3 = dynamic_cast<PIDrawer3D*>(GetDrawerId(*it));
+#else
+  PIDrawer3D* dr3 = (PIDrawer3D*)(GetDrawerId(*it));
+#endif
+  if (dr3 == NULL)  return;
+  dr3->UpdateLimits();
+  double xo, yo, zo, xc, yc, zc, teta, phi, psi, dax, day, co, dco;
+  bool vobs;
+  vobs = dr3->Get3DView(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  if (vobs) Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+  Refresh();
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::SetDrawers3DView()
+{
+  double xc, yc, zc, xo, yo, zo;
+  double teta, phi, psi;
+  double dax, day, co, dco;
+  bool vo;
+  vo = mGr3d->Get3DCS( xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  list<int>::iterator it;
+
+#if defined(__DECCXX) || defined(__KCC__)
+  if (vo)   for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)))->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else   for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)))->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);    
+#else
+  if (vo)   for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    ((PIDrawer3D*)(GetDrawerId(*it)))->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else   for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    ((PIDrawer3D*)(GetDrawerId(*it)))->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);    
+#endif
+
+}
+
+/* --Methode-- */
+int PIDraw3DWdg::AddDrawer3D(PIDrawer3D* dr3, bool ad)
+{
+if (!vfixed)  { 
+  dr3->UpdateLimits();
+  double xo, yo, zo, xc, yc, zc, teta, phi, psi, dax, day, co, dco;
+  bool vobs;
+  vobs = dr3->Get3DView(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  if (vobs) Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+  }
+else { 
+  double xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco;
+  if ( Get3DView(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco) ) 
+      dr3->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else  dr3->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, co, psi);
+  }
+int id = AddDrawer(dr3, false, false, ad);
+if (m3DrIl.size() == 0)  dr3->SetAxesFlags(kStdAxes);
+m3DrIl.push_back(id);
+return(id);
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::RemoveDrawer(int id)
+{
+  list<int>::iterator it;
+  for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    if ( (*it) == id )  { m3DrIl.erase(it);  break; }
+  PIBaseWdg::RemoveDrawer(id);
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::DeleteDrawers()
+{
+  m3DrIl.erase(m3DrIl.begin(),  m3DrIl.end());
+  PIBaseWdg::DeleteDrawers();
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Keyboard(int key, PIKeyModifier kmod)
+{
+if (kmod == PIKM_Alt) {
+  if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller)  
+  if (key == 'Z' || key == 'z') { mBDrw->ElDelAll();  Refresh(); } // Pour supprimer tous les signes 
+  if (key == 'O' || key == 'o' || key == 'G' || key == 'g') { 
+    PIDrwTools::SetCurrentBaseWdg(this);
+    PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
+    }
+  if (key == 'A' || key == 'a')  {    // On affiche ou on enleve les axes
+    axfg = !axfg;
+    list<int>::iterator it;
+    if (axfg) 
+      for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)  
+         GetDrawerId(*it)->SetAxesFlags(kAxesNone);
+    else { 
+      it = m3DrIl.begin(); 
+      if (it != m3DrIl.end())  GetDrawerId(*it)->SetAxesFlags(kStdAxes);
+      }
+    Refresh(); 
+    }
+//  <Alt>S active la sensibilite de la zone centrale pour tourner l'objet
+  if (key == 'S' || key == 's')  skcfg = !skcfg;  
+  if (key == 'R' || key == 'r')  Update3DView();
+  }
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
+{
+if (typ != PICP_string) return;
+int ll = (l<256) ? l+1 : 256;
+char pc[256];
+strncpy(pc, (char*)pdata, ll-1);  pc[ll-1] = '\0';
+// printf("PIDraw3DWdg::PasteSelection() / Debug  %s - %d %d -> %g %g \n", pc, 
+//        mPx, mPy, (double)mPx/(double)XSize(), 1.-(double)mPy/(double)YSize());
+mBDrw->ElAddText((double)mPx/(double)XSize(), 1.-(double)mPy/(double)YSize(), pc );
+mBDrw->Refresh();
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::But2Press(int x, int y)
+{
+  mGr3d->SetBaseGraphic(mWGrC, 0, 0, XSize(), YSize());
+  double xo, yo, zo;
+  double teta, phi, psi;
+  double dax, day, co, dco;
+  mGr3d->Get3DCS(cXc, cYc, cZc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+//   puts("\n PIDraw3DWdg::But2Press() ");
+//   mGr3d->PrintCS();
+  lPx = x;  lPy = y;
+
+// Pour savoir si on se trouve ds la zone centrale   
+  int czx = XSize()/10;
+  int czy = YSize()/10;
+  PIKeyModifier kmod;
+  unsigned long tm;
+  GetLastEventInfo(kmod, tm);
+  rOfg = false;
+  if (kmod ==  PIKM_Shift)  rOfg = true;
+  else if (skcfg) {
+    int dmix = x-XSize()/2;
+    int dmiy = y-YSize()/2;
+    if (dmix < 0) dmix = -dmix;
+    if (dmiy < 0) dmiy = -dmiy;
+    if ((dmix < czx) && (dmiy < czy))  rOfg = true;
+    }
+
+  cUlen = 0.5*(dax+day)*co*0.3;    cDax = dax;   cDay = day;  clCO = co; 
+  cTeta = teta;   cPhi = phi;
+  SelPointerShape(PI_TDLRArrowPointer);
+  lCol = mWGrC->GetForeground();
+  //  mWGrC->SelForeground(GetBackgroundColor());
+  mWGrC->SelForeground(PI_Magenta);
+/*
+  {
+  char buff[256];
+  sprintf(buff, "But2Press() C=%g %g %g  T,P=%g %g   ", xc, yc, zc, cTeta, cPhi); 
+  mWGrC->DrawOpaqueString(0,20,buff);
+  }
+*/
+  DrawXYZAxes();
+  if (rOfg)  { czx /= 2;   czy /= 2;  mWGrC->DrawBox(XSize()/2-czx, YSize()/2-czy, czx*2, czy*2); }
+ 
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Ptr2Move(int x, int y)
+{
+  DrawXYZAxes();
+  double teta, phi;
+
+  if (rOfg) { 
+    phi = cPhi + (M_PI*0.25*(double)(x-lPx)/XSize());
+    teta = cTeta - (M_PI*0.25*(double)(y-lPy)/YSize());
+    mGr3d->RotateObject(teta, phi, false);
+    }
+  else {
+    phi = cPhi - (M_PI*0.5*(double)(x-lPx)/XSize());
+    teta = cTeta + (M_PI*0.5*(double)(y-lPy)/YSize());
+    mGr3d->RotateObserver(teta, phi, 0., false);
+    }
+/*  {
+  char buff[256];
+  sprintf(buff, "Ptr2Move() T,P=%g %g -> %g %g  ", cTeta, cPhi, teta, phi); 
+  mWGrC->DrawOpaqueString(0,20,buff);
+  }
+*/
+  DrawXYZAxes();
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::But2Release(int x, int y)
+{
+  DrawXYZAxes();
+  if (rOfg) {
+    int czx = XSize()/20;
+    int czy = YSize()/20;
+    mWGrC->DrawBox(XSize()/2-czx, YSize()/2-czy, czx*2, czy*2);
+    }
+
+//  puts("\n PIDraw3DWdg::But2Release()");
+//  mGr3d->PrintCS();
+  SelPointerShape(PI_ArrowPointer);
+  mWGrC->SelForeground(lCol);
+  SetDrawers3DView();
+  Refresh();
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::But3Press(int x, int y)
+{
+  double xo, yo, zo;
+  double teta, phi, psi;
+  double dax, day, co, dco;
+  mGr3d->Get3DCS(cXc, cYc, cZc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  mGr3d->SetBaseGraphic(mWGrC, 0, 0, XSize(), YSize());
+  lPx = x;  lPy = y;  
+  cUlen = 0.5*(dax+day)*co*0.3;    cDax = dax;   cDay = day;  clCO = co;
+  cTeta = teta;   cPhi = phi;
+  SelPointerShape(PI_TDLRArrowPointer);
+  lCol = mWGrC->GetForeground();
+  //  mWGrC->SelForeground(GetBackgroundColor());
+  mWGrC->SelForeground(PI_Magenta);
+/*
+  {
+  char buff[256];
+  sprintf(buff, "But3Press() C=%g %g %g  O= %g %g %g  L= %g   ", xc, yc, zc, xo, yo, zo, co); 
+  mWGrC->DrawOpaqueString(0,20,buff);
+  }
+*/
+  DrawXYZAxes();
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Ptr3Move(int x, int y)
+{
+  DrawXYZAxes();
+  double rapx = (double)(lPx-x)/XSize();
+  if (rapx > 0.) rapx = rapx*2.+1;
+  else rapx += 1.;
+  if (rapx < 0.3)  rapx = 0.3;
+  if (rapx > 3.)  rapx = 3.;
+  double rapy = (double)(y-lPy)/YSize();
+  if (rapy > 0.) rapy = rapy*2.+1;
+  else rapy += 1.;
+  if (rapy < 0.3)  rapy = 0.3;
+  if (rapy > 3.)  rapy = 3.;
+/*
+  {
+  char buff[256];
+  sprintf(buff, "Ptr3Move() Rap=%g %g -> %g %g %g     ", rapx, rapy, rapy*clCO, rapx*cDax, rapx*cDay);
+  mWGrC->DrawOpaqueString(0,20,buff);
+  }
+*/
+  mGr3d->ZoomInOut(rapy*clCO, rapx*cDax, rapx*cDay, false);
+  DrawXYZAxes();
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::But3Release(int x, int y)
+{
+  DrawXYZAxes();
+  SelPointerShape(PI_ArrowPointer);
+  mWGrC->SelForeground(lCol);
+  SetDrawers3DView();
+  Refresh();
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::DrawXYZAxes()
+{
+  mWGrC->SelGOMode(PI_GOXOR);
+  PIGrCoord x1,y1,z1,x2,y2,z2;
+  x1 = cXc;  y1 = cYc;  z1 = cZc;
+  x2 = cXc+cUlen;   y2 = cYc;   z2 = cZc; 
+  mGr3d->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x2 = cXc+cUlen*1.1;
+  mGr3d->DrawString3D(x2, y2, z2, "X");
+  x2 = cXc;   y2 = cYc+cUlen;   z2 = cZc; 
+  mGr3d->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  y2 = cYc+cUlen*1.1;
+  mGr3d->DrawString3D(x2, y2, z2, "Y");   
+  x2 = cXc;   y2 = cYc;   z2 = cZc+cUlen; 
+  mGr3d->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  z2 = cZc+cUlen*1.1;
+  mGr3d->DrawString3D(x2, y2, z2, "Z");   
+//   mGr3d->DrawCircle(0., 0., daxO*0.30);
+  char buff[256];
+  double xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco;
+  mGr3d->Get3DCS(xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco);
+  sprintf(buff, " C: %g %g %g -> O: %g %g %g  (T/P0= %g %g)     ", xc,yc,zc, xo, yo, zo, cTeta, cPhi);
+  mWGrC->DrawString(0,20,buff);
+  sprintf(buff, " T,P= %g %g %g lCO= %g  dax= %g %g UL=%g    ", teta,phi,psi,co,dax,day,cUlen); 
+  mWGrC->DrawString(0,40,buff);
+  mWGrC->SelGOMode(PI_GOCopy);  
+
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::But1Press(int x, int y)
+{
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+  mPx = x;  mPy = y;
+  if ( (x > 50) || ( y > 50) ) return; 
+  Update3DView();
+}
+
+/*   Pour debugger sur bouton-3 
+static int isw = 0;
+void PIDraw3DWdg::But3Press(int x, int y)
+x -= XSize()/2;
+y -= YSize()/2;
+
+double fx = (double)x/XSize(); 
+double fy = (double)y/YSize(); 
+if ( (fx<0.2) && (fx>-0.2) && (fy<0.2) && (fy>-0.2) ) {
+  
+  if ((isw%3) == 0) { 
+    Set3DView(0., 0., 0., 0., 0., -3. , 0.3, 0.3, 2); 
+    puts("\n Set3DView(0., 0., 0., 0., 0., -3. , 0.3, 0.3, 2)");
+  }
+  else if ((isw%3) == 1) { 
+    Set3DView(0., 0., 0., 2., 1., 3. , 0.3, 0.3, 2);
+    puts("\n Set3DView(0., 0., 0., 2., 1., 3. , 0.3, 0.3, 2)");
+  }
+  else if ((isw%3) == 2) { 
+    Set3DView_Obs(0.,4.,0.,3.14159/2.,-3.14159/2.,0.,0.25,0.25,4.,2.);
+    puts("\n Set3DView_Obs(0.,4.,0.,3.14159/2.,3.14159/2.,0.,0.25,0.25,4.,2.)");
+  }
+  isw++;
+  mGr3d->PrintCS();
+  double xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco;
+  mGr3d->Get3DCS(xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco);
+  mGr3d->Set3DCS(xc,yc,zc,xo,yo,zo,dax,day,dco,psi);
+  mGr3d->PrintCS();
+  mGr3d->Set3DCS_Obs(xo,yo,zo,teta,phi,psi,dax,day,co,dco);
+  mGr3d->PrintCS();
+  puts(" --------------------- \n");
+  Refresh();
+  return;
+}
+if ((x > 0) && (y > 0) )  { 
+  puts(" But3Press()Set3DView(0., 0., 0., 5., 0., 0. , 0.3, 0.3, 2)");
+  Set3DView(0., 0., 0., 5., 0., 0. , 0.3, 0.3, 2);
+}
+else if ((x < 0) && (y > 0) )  { 
+  puts(" But3Press()Set3DView(0., 0., 0., 0., 5., 1. , 0.3, 0.3, 2) ");
+  Set3DView(0., 0., 0., 0., 5., 1. , 0.3, 0.3, 2);
+}
+else  if ((x < 0) && (y < 0) ) {
+  puts(" But3Press()Set3DView(0., 0., 0., 1., 1., 5. , 0.3, 0.3, 2)");
+  Set3DView(0., 0., 0., 1., 1., 5. , 0.3, 0.3, 2);
+}
+else {
+  puts(" But3Press()Set3DView(0., 0., 0., -3., -3., 3. , 0.3, 0.3, 2)");
+  Set3DView(0., 0., 0., -3., -3., 3. , 0.3, 0.3, 2);
+}
+
+Refresh();
+*/
Index: /tags/DPC_V0/Poubelle/PI/pi3ddrw.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pi3ddrw.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pi3ddrw.h	(revision 1307)
@@ -0,0 +1,124 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive PIDrawer3D PIDraw3DWdg
+// Drawer et DrawWidget 3D       R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIDRW3D_H_SEEN
+#define PIDRW3D_H_SEEN
+
+#include "pisysdep.h"
+#include "pidrawer.h"
+#include "pigraph3d.h"
+
+#include PIBWDG_H
+
+
+// -----------------  Traceur (Drawer) 3D  -------------------
+
+class PIDrawer3D : public PIDrawer
+{
+public :
+			PIDrawer3D();
+  virtual		~PIDrawer3D();
+
+  virtual void		Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                                      double dax, double day, double co, double dco=0.2);
+  virtual void       	Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, 
+                                  double dax, double day, double dco=0.2, double psi=0.);
+  bool           	Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo,
+                                  double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco);
+  
+  virtual PIGraphicUC*	SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g);
+
+  virtual void       	DrawAxes(PIGraphicUC* g);
+  virtual void       	Draw3DBoxe(PIGraphic3D* g3, double xx1, double xx2, double yy1, double yy2, 
+                                                    double zz1, double zz2, double xl1, double xl2, 
+                                                    double yl1, double yl2, double zl1, double zl2);
+
+  double XMin3() const {return x3Min;}
+  double XMax3() const {return x3Max;}
+  double YMin3() const {return y3Min;}
+  double YMax3() const {return y3Max;}
+  double ZMin3() const {return z3Min;}
+  double ZMax3() const {return z3Max;}
+
+protected :
+  double xO, yO, zO;  // Position observateur = camera
+  double xC, yC, zC;  // Position centre du champ
+  double tO,fO,pO;    // Orientation observateur (Teta, Phi, Psi, Angles d Euler)
+  double daxO, dayO;  // Demi-ouverture de la camera suivant les deux axes de projection (xp/zp, yp/zp) 
+  double lCO, dlCO;   // Distance Camera-Centre du champ et profondeur de champ 
+  bool v3D_obs;      // Si defini par Set3DView_Obs 
+  double x3Min, x3Max;  // Pour delimiter le cube 3D 
+  double y3Min, y3Max;  // Pour delimiter le cube 3D 
+  double z3Min, z3Max;  // Pour delimiter le cube 3D 
+};
+
+
+//------------------------------ Classe PIDrawer3D --------------------
+
+class PIDraw3DWdg : public PIBaseWdg {
+public:
+  enum {ClassId = 5500};
+
+			PIDraw3DWdg(PIContainerGen *par, char *nom,
+                                    int sx=100, int sy=100, int px=0, int py=0);
+  virtual		~PIDraw3DWdg();
+  virtual long		kind() {return ClassId; }
+
+
+  virtual void		Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                                      double dax, double day, double co, double dco=0.2);
+  virtual void       	Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, 
+                                  double dax, double day, double dco=0.2, double psi=0.);
+  bool           	Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, 
+                                  double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco);
+
+  virtual void          Update3DView();   // Vue 3-D a partir de Drawer No 1
+
+  inline void	     	SetTitles(const char* tt=NULL, const char* tb=NULL)
+                                  { mBDrw->SetTitles(tt, tb); }
+  inline void	     	SetTitles(string const & tt, string const & tb)
+                                  { mBDrw->SetTitles(tt, tb); }
+
+  int                   AddDrawer3D(PIDrawer3D*, bool ad=false);   // Ajoute un Drawer 
+
+//  Pour tenir trace des Drawers-3D qui sont detruits 
+  virtual void      	RemoveDrawer(int id);       
+  virtual void       	DeleteDrawers();            
+
+  virtual void		But1Press(int x, int y);
+
+  virtual void		But2Press(int x, int y);
+  virtual void		But2Release(int x, int y);
+  virtual void		Ptr2Move(int x, int y);
+
+  virtual void		But3Press(int x, int y);
+  virtual void		But3Release(int x, int y);
+  virtual void		Ptr3Move(int x, int y);
+
+  virtual void 		Keyboard(int key, PIKeyModifier kmod);
+  virtual void 		PasteSelection(unsigned int typ, void *pdata, unsigned int l);
+
+
+protected :
+  virtual void		SetDrawers3DView();
+  virtual void		DrawXYZAxes();
+
+  PIElDrawer* mBDrw;   // Objet traceur d'elements de fond
+  int mPx, mPy;        // Position pointeur - Bouton-1 
+  
+  bool vfixed;       // SetView fait ou pas
+  list<int> m3DrIl;  // Liste des Id drawers 3D 
+  PIGraphic3D* mGr3d;   // PIGraphic3D courante
+  int lPx, lPy;         // dernier position pointeur
+  PIColors lCol;        // Couleur
+  double cTeta, cPhi, cUlen;    // Pour garder valeurs avant rotation, Unite de longeur
+  double cXc, cYc, cZc;         // Pour garder position du centre de champ 
+  double clCO, cDax, cDay;      // Pour garder les valeurs avant Zoom In/Out
+  bool  rOfg;                  // si Vrai  on fait tourner l'objet et pas la camera
+  bool  axfg;                  // si Vrai on trace les axes
+  bool  skcfg;                 // si Vrai click-2 au centre -> rotation objet
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piapplgen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piapplgen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piapplgen.cc	(revision 1307)
@@ -0,0 +1,161 @@
+//  Classe de base d'objets application pour 
+//  les programmes graphiques interactives
+//
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+//++
+// Class	PIApplication
+// Lib		PI
+// include	piapplgen.h
+//
+//	Classe de base pour l'objet application. L'objet PIApplication 
+//	doit être créé avant la création des autres objets de PI.
+//	La classe "PIApplication" a implémentation dépendante 
+//	du systeme utilisé (Mac, XWindow, ...). La classe "PIApplicationGen" 
+//	est la classe qui définit l'interface, et ne doit pas être instanciée 
+//	directement (Méthodes virtuelles pures). Les objets instanciés sont 
+//	de la classes "PIApplication" et le fichier entête correspondant est 
+//	"PIAPP_H" défini dans "pisysdep.h".
+//--
+//++
+// Links	Parents
+// PIMsgHandler
+//--
+//++
+// Titre	Constructeur
+//--
+//++
+// PIApplication(int sx=200, int sy=30, int narg=0, char *arg[]=NULL)
+//	Constructeur. "sx,sy" est la taille de la fenêtre principale
+//	(ou PIContainer) associée à l'application. Des arguments
+//	optionnels, par exemple celle de la ligne de commande peuvent 
+//	être transmis à l'objet PIApplication. Dans le cas d'Unix/XWindow
+//	par exemple, les options reconnues par la Xtoolkit peuvent 
+//	être passées à l'objet application.
+//--
+
+//++
+// Titre	Méthodes
+//--
+//++
+// PIContainer*   MainWin()
+//	Renvoie le pointeur de l'objet "PIContainer" associé à l'application.
+// PIMenubar*   Menubar()
+//	Renvoie le pointeur de l'objet "PIMenubar" associé à l'application.
+// void AppendMenu(PIMenu *pdm)
+//	Ajoute le "PIMenu *pdm" au Menubar de l'application. Le titre 
+//	du menu dans le menubar est le nom de l'objet menu. 
+// void Run() Stop
+//	Démarre, arrête la boucle d'événements.
+//--
+
+
+#include "piapplgen.h"
+
+// Variable qui contient le pointeur de l'application courante
+// permet de recuperer la taille pref pour la fonction globale 
+static PIApplicationGen * curapp = NULL;
+
+PIApplicationGen::PIApplicationGen()
+:topcont(NULL), menubar(NULL), mState(0)
+{
+curapp = this;   
+}
+
+PIApplicationGen::~PIApplicationGen()
+{}
+
+
+void PIApplicationGen::AppendMenu(PIMenu *pdm)
+{
+if (menubar)
+  menubar->AppendMenu(pdm);
+return;
+}
+
+//++
+// void SetReady()
+//	Modifie l'état global de l'application - Pssage à l'état normal,
+//	prêt à traiter les actions utilisateur.
+// void SetBusy()
+//	Passage en mode de calcul - La souris prend la forme de la montre
+//	pour la fenêtre principale
+// void SetBlocked()
+//	Passge en mode bloqué. La barre de menu devient insensible
+// int GetState()
+//	Renvoie l'état global de l'application "(kReadyState, kBusyState, kBlockedState)".
+//--
+void PIApplicationGen::SetReady()
+{
+mState = kReadyState;
+}
+
+void PIApplicationGen::SetBusy()
+{
+mState = kBusyState;
+}
+
+void PIApplicationGen::SetBlocked()
+{
+mState = kBlockedState;
+}
+
+int PIApplicationGen::GetState()
+{
+return mState;
+}
+
+//++
+// Titre	Redirection StdOut, StdErr
+//	Il est possible de rediriger les flots de sortie
+//	standard et d'erreur vers un objet PIConsol.
+//--
+
+//++
+// void  RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def)
+//	Redirige le flot de sortie ("stdout" sous Unix) vers l'objet 
+//	PIConsole "cons". si "cons==NULL", redirection 
+//	sur le flot original.
+//
+// void  RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Def)
+//	Redirige le flot des messages d'erreur ("stderr" sous Unix) 
+//	vers l'objet PIConsole "cons". si "cons==NULL", redirection
+//	 sur le flot original.
+//--
+
+//++
+// Titre	Informations globales
+//	Les méthodes suivantes permettent d'acceder aux informations  
+//	concernant l'écran (tailles, ...). Des fonctions globales sont 
+//	prévues ( "PIApplicationPrefCompSize()" et "PIApplicationScreenSize()" )
+//	afin d'obtenir ces informations sans avoir besoin d'une instance de la 
+//	classes application.
+//--
+//++
+// void  PIApplicationPrefCompSize(int& szx, int& szy)
+//	Fonction globale
+// void  PrefCompSz(int& szx, int& szy)
+//	Renvoie la taille préférée pour les composantes standard. "szx,szy" 
+//	est la taille (en pixels) pour un champ texte, ou un bouton "(PIText, PIButton)" 
+//	avec l'étiquette ou un contenu de 6 caractères (Ex: Cancel).
+//
+// void  PIApplicationScreenSize()
+//	Fonction globale
+// void  ScreenSz(int& szx, int& szy)
+//	Renvoie la taille en pixels de l'écran
+//  
+//--
+
+void     PIApplicationPrefCompSize(int& szx, int& szy)
+{
+szx = szy = 10;
+if (curapp)  curapp->PrefCompSz(szx, szy);
+return; 
+}
+void     PIApplicationScreenSize(int& szx, int& szy)
+{
+szx = szy = 500;
+if (curapp)  curapp->ScreenSz(szx, szy);
+return; 
+}
Index: /tags/DPC_V0/Poubelle/PI/piapplgen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piapplgen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piapplgen.h	(revision 1307)
@@ -0,0 +1,48 @@
+#ifndef PIAPPLGEN_H_SEEN
+#define PIAPPLGEN_H_SEEN
+
+#include "pimsghandler.h"
+#include "pisysdep.h"
+#include PICONT_H
+#include PIMENUBAR_H
+#include "picons.h"
+
+
+class PIApplicationGen : public PIMsgHandler {
+public:
+        enum { kReadyState=0, kBusyState=1, kBlockedState=2 };
+
+				  PIApplicationGen();
+	virtual		          ~PIApplicationGen();
+	
+	virtual void              Run()=0;
+	virtual void              Stop()=0;
+
+        virtual void              SetReady();
+        virtual void              SetBusy(); 
+        virtual void              SetBlocked();
+        virtual int               GetState();
+
+
+	virtual PIContainer*      MainWin() {return topcont;}
+        virtual PIMenubar*        Menubar() {return menubar;}
+
+        virtual void              AppendMenu(PIMenu *pdm);
+
+        virtual void              PrefCompSz(int& szx, int& szy) = 0;
+        virtual void              ScreenSz(int& szx, int& szy) = 0;
+
+        virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def)  = 0;
+        virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital|PIVA_Red) = 0;
+
+protected:
+    PIContainer               *topcont;
+    PIMenubar                 *menubar;
+    int                       mState;
+};
+
+//   Fonction globale pour recuperer la taille standard des composants (taille x,y) 
+void     PIApplicationPrefCompSize(int& szx, int& szy);  
+void     PIApplicationScreenSize(int& szx, int& szy);  
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piapplmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piapplmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piapplmac.cc	(revision 1307)
@@ -0,0 +1,112 @@
+
+#include "piapplmac.h"
+#include "pippmenubar.h"
+#include "pippapplmac.h"
+#include "piwindowmac.h"
+
+#include <LApplication.h>
+#include <LGrowZone.h>
+#include <UDrawingState.h>
+#include <UMemoryMgr.h>
+#include <SIOUX.h>
+#include <LAttachment.h>
+
+class PIInit {
+public:
+  PIInit() {
+    SIOUXSettings.initializeTB = false;
+    SIOUXSettings.standalone = false;
+    SIOUXSettings.setupmenus = false;
+    SIOUXSettings.showstatusline = true;
+  }
+};
+
+PIInit piInit;
+
+class PISIOUXAttachment : public LAttachment {
+public:
+  PISIOUXAttachment();
+protected:
+ virtual void	ExecuteSelf(
+							MessageT		inMessage,
+							void			*ioParam);
+};
+
+PISIOUXAttachment::PISIOUXAttachment()
+: LAttachment()
+{}
+
+void PISIOUXAttachment::ExecuteSelf(MessageT msg, void* p)
+{
+  if (msg == msg_Event)
+    mExecuteHost = !SIOUXHandleOneEvent((EventRecord*)p);
+  if (!mExecuteHost)
+    UDesktop::NormalizeWindowOrder();
+}
+
+PIApplicationMac::PIApplicationMac(int sx, int sy, int /*narg*/, char** /*arg*/)
+{
+  SIOUXSettings.initializeTB = false;
+  SIOUXSettings.standalone = false;
+  SIOUXSettings.setupmenus = false;
+  SIOUXSettings.showstatusline = true;
+									// Set Debugging options
+	SetDebugThrow_(debugAction_Alert);
+	SetDebugSignal_(debugAction_Alert);
+
+	InitializeHeap(3);				// Initialize Memory Manager
+									// Parameter is number of Master Pointer
+									//   blocks to allocate
+	
+									// Initialize standard Toolbox managers
+	UQDGlobals::InitializeToolbox(&qd);
+	
+	new LGrowZone(20000);			// Install a GrowZone function to catch
+									//    low memory situations.
+									
+		// Register functions to create core PowerPlant classes
+	
+	RegisterAllPPClasses();
+
+	macAppli = new PIPPApplMac;
+	macAppli->AddAttachment(new PISIOUXAttachment);
+	
+    menubar = new PIMenubar(this, "DefMenubar");
+    topcont = new PIWindowMac(this, "TopLevel", PIWK_floating, sx, sy, 10, 45);
+}
+
+
+PIApplicationMac::~PIApplicationMac()
+{
+	delete macAppli;
+}
+
+void
+PIApplicationMac::Run()
+{
+    topcont->Show();
+	macAppli->Run();
+}
+
+void
+PIApplicationMac::Stop()
+{
+	macAppli->DoQuit();
+}
+
+/* --Methode-- */
+int PIApplicationMac::PrefXSize()
+{
+  return(10);  // $CHECK$ A remplacer Reza 13/02/98 
+}
+
+/* --Methode-- */
+int PIApplicationMac::PrefYSize()
+{
+  return(18);  // $CHECK$ A remplacer Reza 13/02/98 
+}
+
+void PIApplicationMac::RedirectOutStream(PIConsole* cons, unsigned char va)
+{}
+void PIApplicationMac::RedirectErrStream(PIConsole* cons, unsigned char va)
+{}
Index: /tags/DPC_V0/Poubelle/PI/piapplmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piapplmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piapplmac.h	(revision 1307)
@@ -0,0 +1,26 @@
+#ifndef PIAPPLMAC_H_SEEN
+#define PIAPPLMAC_H_SEEN
+
+#include "piapplgen.h"
+
+class LApplication;
+class PIApplicationMac : public PIApplicationGen {
+public:
+					PIApplicationMac(int sx=200, int sy=30, int narg=0, char *arg[]=NULL);
+	virtual		   ~PIApplicationMac();
+	
+	virtual void    Run();
+	virtual void    Stop();
+	
+  virtual int     PrefXSize();
+  virtual int     PrefYSize();
+
+        virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
+        virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital);
+//protected:
+	LApplication* macAppli;
+};
+
+typedef PIApplicationMac PIApplication;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piapplx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piapplx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piapplx.cc	(revision 1307)
@@ -0,0 +1,304 @@
+#include <stdio.h>
+#include <X11/cursorfont.h>
+#include "piapplx.h"
+#include "picontainerx.h"
+
+
+// Pour rediriger stdout 
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <iostream.h>
+
+
+// #define DEBUG_APPLX
+
+static Cursor a_curs[3];
+static bool a_fgcur=false;
+
+//  Voir fichier pimenux.cc , Pour resoudre certains conflits avec les WindowManagers
+void SetTopWdgForMenuX(SysDWdg mtw);
+
+static PIApplication* cur_piapp = NULL;
+PIApplication* PIApplicationGetApp() { return cur_piapp; }
+
+
+// Classe de container special pour top-container de Application X
+
+class PITopContAppX : public PIContainer {
+public :
+	    	PITopContAppX(PIContainer *par, char *nom,
+                          int sx=10, int sy=10, int px=0, int py=0);
+   virtual  	~PITopContAppX(); 
+
+   virtual void SetSize(int sx, int sy);
+   virtual void SetPos(int px, int py);
+};
+
+/* --Methode-- */
+PITopContAppX::PITopContAppX(PIContainer *par, char *nom, int sx, int sy, int px, int py)
+        : PIContainer(par, nom, sx, sy, px, py)
+{
+  SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+}
+
+/* --Methode-- */
+PITopContAppX::~PITopContAppX()
+{
+}
+
+/* --Methode-- */
+void PITopContAppX::SetSize(int sx, int sy)
+{
+Parent()->SetSize(sx+XPos(), sy+YPos());
+PIContainer::SetSize(sx, sy);
+}
+
+/* --Methode-- */
+void PITopContAppX::SetPos(int px, int py)
+{
+}
+
+/* --Methode-- */
+PIApplicationX::PIApplicationX(int sx, int sy, int narg, char *arg[])
+: PIApplicationGen()
+{
+int sxt, syt;
+
+#ifdef DEBUG_APPLX
+puts("PIApplicationX::PIApplicationX()_info : App creation");
+#endif
+mStop = true;
+topwdg = new PIWdgX(narg, arg);
+
+intcont = new PIContainerX((PIMsgHandler *)this, topwdg, "MBCont", 
+                            10, 10, 0, 0);
+// Pb avec les Popup MenuX et certains Window Manager , voir pimenux.cc
+SetTopWdgForMenuX(intcont->XtWdg());
+
+menubar = new PIMenubar(this, "DefMenubar");
+Menubar()->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_free);
+sxt = ( sx > Menubar()->XSize() ) ? sx : Menubar()->XSize();
+syt = ( sy > 0 ) ? sy : 0;
+int msx,msy;
+PrefCompSz(msx, msy);
+//syt += Menubar()->YSize();
+syt += msy;
+MBCont()->SetSize(sxt, syt);
+if (sx < sxt)  sx = sxt;
+if (sy < 10) sy = 10;
+topcont = new PITopContAppX(MBCont(), "TopLevelCont", 
+                            sx, sy, 0, msy);
+topcont->Show();
+MBCont()->Show();
+
+topwdg->Manage();
+
+if (!a_fgcur)
+  {
+  Display *mdsp;
+  mdsp = XtDisplay (topwdg->XtWdg()); 
+  a_curs[0] = XCreateFontCursor(mdsp, XC_arrow);
+  a_curs[1] = XCreateFontCursor(mdsp, XC_X_cursor);
+  a_curs[2] = XCreateFontCursor(mdsp, XC_watch);
+  }
+
+cur_piapp = this;
+mState = -1;
+SetReady();
+}
+
+/* --Methode-- */
+PIApplicationX::~PIApplicationX()
+{
+#ifdef DEBUG_APPLX
+puts("PIApplicationX::~PIApplicationX()_info : App delete");
+#endif
+Display *mdsp;
+mdsp = XtDisplay (topwdg->XtWdg()); 
+topwdg->UnManage();
+delete menubar;
+if (topcont != MBCont())  delete topcont;
+delete intcont;
+delete topwdg;
+XtCloseDisplay(mdsp);
+cur_piapp = NULL;
+return;
+}
+
+/* --Methode-- */
+void PIApplicationX::Run()
+{
+XEvent evt;
+#ifdef DEBUG_APPLX
+puts("PIApplicationX::Run()_info : App Run ");
+#endif
+
+topwdg->SetSize(MBCont()->XSize(), MBCont()->YSize());
+
+int szx, szy, szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+
+// Pour appeler FinishCreate() des objets dans la fenetre principale 
+if (mStop) MBCont()->FinishCreate();   // C'est la premiere fois
+else mStop = true;   // On rerentre apres un stop 
+while (mStop)
+  {
+  XtAppNextEvent(*appctx, &evt);
+  XtDispatchEvent(&evt);
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIApplicationX::SetReady()
+{
+Display * mdsp = XtDisplay (topwdg->XtWdg());
+if (mState != kReadyState)
+  {
+  mState = kReadyState;
+  Menubar()->SetSensitive();
+  XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[0]);
+  }
+XFlush(mdsp);
+}
+
+/* --Methode-- */
+void PIApplicationX::SetBusy()
+{
+Display * mdsp = XtDisplay (topwdg->XtWdg());
+if (mState != kBusyState)
+  {
+  mState = kBusyState;
+  Menubar()->SetSensitive();
+//  if ( XtIsRealized(topwdg->XtWdg()) )
+  XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[2]);
+  }
+XFlush(mdsp);
+}
+
+/* --Methode-- */
+void PIApplicationX::SetBlocked()
+{
+Display * mdsp = XtDisplay (topwdg->XtWdg());
+if (mState != kBlockedState)
+  {
+  mState = kBlockedState;
+  Menubar()->SetUnSensitive();
+  XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[1]);
+  }
+XFlush(mdsp);
+return;
+}
+
+
+/* --Methode-- */
+void PIApplicationX::PrefCompSz(int& szx, int& szy)
+{
+int szf;
+PIXtAppCtx(szx, szy, szf);
+return;
+}
+
+/* --Methode-- */
+void PIApplicationX::ScreenSz(int& szx, int& szy)
+{
+Display * dsp = PIXDisplay();
+szx = DisplayWidth(dsp, DefaultScreen(dsp));
+szy = DisplayHeight(dsp, DefaultScreen(dsp));
+}
+
+
+
+/* Call-Back - Fonction privee de ce fichier */
+static void redirectstream_callback(XtPointer, int *, XtInputId*);
+
+static PIConsole* consstream[2] = {NULL, NULL};
+static unsigned char streamva[2] = { PIVA_Def, PIVA_Ital};
+static int streamno[2] = {0,1};
+static XtInputId inputid[2];
+static int origfiledes[2]={-1, -1};   // descripteurs de fichiers de depart
+
+static void redirectstream_callback(XtPointer cld, int * fd, XtInputId* /*iid*/)
+{
+char buff[128];
+int nr;
+
+int idx = *((int*)cld);
+if (idx != 1) idx = 0; 
+if (!consstream[idx]) return;
+while ( (nr=read(*fd, buff, 127)) > 0 ) {
+  buff[nr] = '\0'; consstream[idx]->AddStr(buff, streamva[idx], false);
+  }
+consstream[idx]->Refresh();
+}
+
+/* --Methode-- */
+void PIApplicationX::RedirectOutStream(PIConsole* cons, unsigned char va)
+{
+if ( origfiledes[0]<0 )  origfiledes[0] = fcntl(1, F_DUPFD);     
+if ( cons == consstream[0]) return;
+if ( (consstream[0]) && (cons) ) { consstream[0] = cons; streamva[0] = va; return; }
+else if (!cons) { 
+  consstream[0] = NULL;  
+  XtRemoveInput(inputid[0]);
+  dup2(origfiledes[0], 1);
+  return;
+  }
+
+consstream[0] = cons; streamva[0] = va;
+
+int p[2];
+pipe(p);
+// Redirection de stdout (fid=1) :  
+close(1);
+dup(p[1]);
+close(p[1]);
+fcntl(p[0], F_SETFL, O_NONBLOCK);
+
+#if (!defined(__GNUG__) && !defined(__aCC__))
+setlinebuf(stdout);
+#endif
+ios::sync_with_stdio();
+
+int szx, szy, szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+inputid[0] = XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, 
+                           redirectstream_callback, (XtPointer) streamno);
+}
+
+/* --Methode-- */
+void PIApplicationX::RedirectErrStream(PIConsole* cons, unsigned char va)
+{
+if ( origfiledes[1]<0 )  origfiledes[1] = fcntl(2, F_DUPFD);     
+if ( cons == consstream[1]) return;
+if ( (consstream[1]) && (cons) ) { consstream[1] = cons; streamva[1] = va; return; }
+else if (!cons) { 
+  consstream[1] = NULL;  
+  XtRemoveInput(inputid[1]);
+  dup2(origfiledes[1], 2);
+  return;
+  }
+
+consstream[1] = cons; streamva[1] = va;
+
+int p[2];
+pipe(p);
+// Redirection de stderr (fid=2) :
+close(2);
+dup(p[1]);
+close(p[1]);
+fcntl(p[0], F_SETFL, O_NONBLOCK);
+
+#if (!defined(__GNUG__) && !defined(__aCC__))
+setlinebuf(stderr);
+#endif
+ios::sync_with_stdio();
+
+int szx, szy, szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+inputid[1] = XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, 
+                           redirectstream_callback, (XtPointer) (streamno+1));
+}
+
Index: /tags/DPC_V0/Poubelle/PI/piapplx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piapplx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piapplx.h	(revision 1307)
@@ -0,0 +1,38 @@
+#ifndef PIAPPLX_H_SEEN
+#define PIAPPLX_H_SEEN
+
+#include "piapplgen.h"
+#include "piwdgx.h"
+#include "picontainerx.h"
+
+class PIApplicationX : public PIApplicationGen {
+public:
+  		            PIApplicationX(int sx=200, int sy=30, int narg=0, char *arg[]=NULL);
+
+  virtual	            ~PIApplicationX();
+	
+  virtual void              Run();
+  virtual void              Stop() { mStop = false; }
+
+  virtual void              SetReady();
+  virtual void              SetBusy(); 
+  virtual void              SetBlocked();
+
+  virtual void              PrefCompSz(int& szx, int& szy);
+  virtual void              ScreenSz(int& szx, int& szy);
+
+  virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
+  virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital|PIVA_Red);
+
+  PIContainer*              MBCont() { return intcont; }
+protected:
+  PIWdg * topwdg;
+  PIContainer * intcont;
+  bool mStop;
+};
+
+typedef PIApplicationX PIApplication;
+
+//  Pour recuperer un objet PIApplication 
+PIApplication* PIApplicationGetApp();
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pibwdggen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pibwdggen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pibwdggen.cc	(revision 1307)
@@ -0,0 +1,607 @@
+// Module PI : Peida Interactive     PIBaseWdg
+// Classe de base pour nouvelles composantes graphiques  96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+
+#include "pibwdggen.h"
+#include "pidrawer.h"
+#include "pigraphps.h"
+#include "pidrwtools.h"
+
+static inline void dbl_swap(double& a, double& b) { double tmp = a; a = b; b = tmp;  } 
+
+//++
+// Class	PIBaseWdg
+// Lib		PI
+// include	pibwdggen.h
+//
+//   	Classe de base pour la création de nouvelles composantes graphiques.
+//	Le traitement des événements liés à l'écran, clavier, souris se fait
+//	à travers des méthodes de cette classe : "Resize()", "But1Press()", ...
+//	La classe "PIBaseWdg" supporte en outre un mécanisme permettant
+//	d'associer un ou plusieurs objets traceur (*Drawer*) capables 
+//	de se dessiner dans la fenêtre associée à l'objet.
+//	La classe "PIBaseWdgGen" définit l'interface et ne peut pas être instanciée 
+//	directement (Méthodes virtuelles pures). Les objets instanciés sont de la 
+//	classe "PIBaseWdg" et le fichier entête correspondant est "PIBWDG_H"
+//	défini dans "pisysdep.h".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Links	Voir aussi
+// PIGraphic
+// PIDrawer
+//--
+
+// ---------- Les methodes de la classe  PIBWdgGen ------------
+
+//++
+// Titre	Constructeur
+//--
+//++
+//  PIBaseWdgGen(PIContainerGen *par, char *nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet contenu dans l'objet *PIContainer* "par", de
+//	taille "sx,sy", se trouvant à la position "px,py" avec le nom "nom"	
+//--
+
+//++
+// Titre	Méthodes
+//--
+//++
+// void  SetBackgroundColor(PIColors col=PI_White)
+//	Choix de la couleur de fond.
+// void  EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0) 
+//	Efface la zone rectangulaire définie par le coin "(x0,y0)" ,
+//	de taille "dx,dy" à l'aide de la couleur de fond.
+// void  SelPointerShape(PIPointer ptr=PI_ArrowPointer) 
+//	Choix de la forme du pointeur (souris) pour la fenêtre 
+//	associée à l'objet.
+//|	PI_ArrowPointer, PI_CrossPointer, PI_HandPointer, PI_TDLRArrowPointer
+// PIColors  GetBackgroundColor()
+//	Renvoie la couleur de fond
+// PIPointer  GetPointerShape() 
+//	Renvoie la forme du pointeur
+//--
+
+//++
+// Titre	Activation du traitement des événements
+//--
+//++
+// void  ActivatePtrCross()
+//	Active l'appel aux méthodes "Enter()" et "Leave()" lorsque la souris
+//	rentre ou sort de la fenêtre correspondante à l'objet
+// void  ActivateButton(int b)
+//	Active l'appel aux méthodes "ButbPress()" et "ButxRelease()" pour
+//	le bouton "b" de la souris ("b=1,2,3")
+// void  ActivateMove(int b) 
+//	Active l'appel aux méthodes "PtrbMove()" lors des mouvements de
+//	la souris avec le bouton "b" enfoncé ("b=1,2,3")
+//	L'appel avec "bid=0" active l'appel à la méthode "PtrMove()"
+//	Lors des mouvements de souris sans bouton enfoncé.
+// void  ActivateKeyboard()
+//	Active l'appel à la méthode "Keyboard()" lors de l'appui sur les 
+//	touches du clavier.
+//--
+
+ 
+/* --Methode-- */
+PIBaseWdgGen::PIBaseWdgGen(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) :
+PIWdg(par, nom, sx, sy, px, py)
+{
+mDrwId=0;   // Compteur des numeros sequentiel des PIDrawer
+mAdfg=false;    // Pour controle d'appel de RemoveDrawer()
+mWGrC = NULL;   // PIGraphic (Contexte graphique) associe a la fenetre}
+                // Doit etre cree par PIBaseWdgX/Mac/... 
+SetDefaultDrawRectangle(0., 0., 1., 1., true);
+SetDefaultDrawerLimits(0., 1., 0., 1., kAxeDirLtoR, kAxeDirUpDown);
+}
+
+/* --Methode-- */
+PIBaseWdgGen::~PIBaseWdgGen()
+{
+delete mWGrC;
+DeleteDrawers();
+if (PIDrwTools::GetCurrentBaseWdg() == this) 
+  PIDrwTools::SetCurrentBaseWdg(NULL);
+}
+ 
+
+/* --Methode-- 
+void PIBaseWdgGen::Refresh()
+{
+if ( IsVisible() )  { 
+  Draw(mWGrC, 0, 0, XSize(), YSize());
+  CallDrawers(mWGrC); 
+}
+return;
+}
+*/
+
+//++
+// Titre	Gestion des événements
+//--
+//++
+// void  Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+//	Méthode appelée lorsqu'il faut redessiner tout ou partie de
+//	la fenêtre. La zone a rafraîchir est determinée par 
+//	"(x0,y0)", "dx,dy" et "g" est l'objet "PIGraphic" 
+//	qui doit être utilisé.
+//	Cette méthode ne doit pas être appelé directement. 
+//	Pour rafraîchir le contenu de la fenêtre, il faut appeler
+//	la méthode "Refresh()"
+// void  Resize()
+//	Méthode appelée lorsque la taille de l'objet est modifiée.
+//	"XSize()", "YSize()" fournissent la nouvelle taille de l'objet.
+// void  Enter()
+//	Méthode appelée lorsque le pointeur rentre dans la fenêtre
+//	(Si "ActivatePtrCross()" a été appelé )
+// void  Leave()
+//	Méthode appelée lorsque le pointeur quitte la fenêtre
+//	(Si "ActivatePtrCross()" a été appelé )
+// void  ButbPress(int x, int y)  (b=1,2,3)
+//	Méthode appelée lorsque le bouton "b=1,2,3" de la souris est enfoncé.
+//	"x,y" : Position de la souris
+//	(Si "ActivateButton(b)" a été appelé )
+// void  ButbRelease(int x, int y)   (b=1,2,3)
+//	Méthode appelée lorsque le bouton "b=1,2,3" de la souris est relaché.
+//	"x,y" : Position de la souris
+//	(Si "ActivateButton(b)" a été appelé )
+// void  PtrMove(int x, int y)
+//	Méthode appelée lors des mouvements de la souris. "x,y" : Position de la souris
+//	(Si "ActivateMove(0)" a été appelé )
+// void  PtrbMove(int x, int y)     (b=1,2,3)
+//	Méthode appelée lors des mouvements de la souris, avec le 
+//	bouton "b=1,2,3" appuyé. "x,y" : Position de la souris
+//	(Si "ActivateMove(b)" a été appelé )
+// void  Keyboard(int key, PIKeyModifier kmod)
+//	Méthode appelée en réponse à des actions sur le clavier.
+//	"key" est le code ASCII de la touche enfoncé - "kmod" indique
+//	si des touches speciaux étaient enfoncés en même temps.
+//|	kmod =  PIKM_Blank |  PIKM_Shift | PIKM_Alt | PIKM_Cntl
+//	Des constantes ont été définis pour certaines touches particulières
+//|	PIK_Return , PIK_Enter , PIK_BackSpace, PIK_Delete
+//|	PIK_Tab , PIK_Escape , PIK_Up , PIK_Down, 
+//|	PIK_Right , PIK_Left , PIK_Previous , PIK_Next
+//--
+
+/* --Methode-- */
+void PIBaseWdgGen::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Draw() Efface la fenetre par defaut ! ");
+#endif
+if (g->kind() != PI_PSFileGraphics) EraseWindow(x0, y0, dx, dy);
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Resize()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Resize()  resize notify ");
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::Enter()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Enter() enter notify ");
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Leave()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Leave() leave notify ");
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::But1Press(int /*x*/, int /*y*/)
+{
+Send(Msg(), PIMsg_Active);
+#ifdef DEBUG_RZXB
+printf ("PIBaseWdgGen::But1Press PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But1Release(int /*x*/, int /*y*/)
+{
+#ifdef DEBUG_RZXB
+printf ("PIBaseWdgGen::ButReleasePosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But2Press(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But2Release(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But3Press(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But3Release(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::PtrMove(int /*x*/, int /*y*/)
+{
+#ifdef DEBUG_RZXB
+printf ("Debug_PIBaseWdgGen::PtrMove PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Ptr1Move(int /*x*/, int /*y*/)
+{
+#ifdef DEBUG_RZXB
+printf ("Debug_PIBaseWdgGen::Ptr1Move PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Ptr2Move(int /*x*/, int /*y*/)
+{
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::Ptr3Move(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Keyboard(int /*key*/, PIKeyModifier /*kmod*/)
+{
+#ifdef DEBUG_RZXB
+printf("PIBaseWdgGen::Keyboard: Key= %d (%c)  Mod= %d \n", key, (char)key, (int)kmod); 
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::PSPrint(PSFile * psf, int ofx, int ofy)
+{
+if (!psf) return;
+PIGraphicPS grpsf(psf, (PIWdg *)this, ofx, ofy);
+Draw(&grpsf, 0, 0, XSize(), YSize());
+CallDrawers(&grpsf); 
+return;
+}
+
+//++
+// Titre	Gestion des traceurs (PIDrawer)
+//	Un même "PIDrawer" peut être attaché simultanement à plusieurs "PIBaseWdg", ainsi
+//	que plusieurs fois au même "PIBaseWdg", avec des identificateurs différents.
+//--
+//++
+// void  SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz=true)
+//	Définition du rectangle d'attachement par défaut. "(x1,y1)" et "(x2,y2)" determinent
+//	les positions des deux coins opposés.
+//	si "psz=true", les coordonnées sont supposées être des facteurs multiplicatifs 
+//	des dimensions de l'objet.
+// void  SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax, -
+//                              int axrl=kAxeDirSame, int ayud=kAxeDirSame)
+//	Définition du système de coordonnées par défaut d'un drawer attaché en "autolim=true"
+//
+//--
+
+/* --Methode-- */
+void PIBaseWdgGen::SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz)
+{
+mDrX1 = x1;  mDrY1 = y1;
+mDrX2 = x2;  mDrY2 = y2;   mDrElastic = psz;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax,
+                                          int axrl, int ayud)
+{
+mDrXmin = xmin;   mDrXmax = xmax; 
+mDrYmin = ymin;   mDrYmax = ymax; 
+mDXdir = axrl;    mDYdir = ayud;
+}
+
+
+//++
+// int  AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, -
+//                bool psz=true, bool clip=true, bool ad=false)
+//	Attachement d'un "PIDrawer" au rectangle défini les coordonnées des deux coins opposés.
+//	si "psz=true", les coordonnées sont supposées être des facteurs multiplicatifs 
+//	des dimensions de l'objet.
+//	si "clip=true", "PIDrawer* drw" ne peut dessiner en dehors de son rectangle
+//	d'attachement.
+//	si "ad=true", le "PIDrawer* drw" est détruit lors de la destruction de l'objet PIBaseWdg.
+//	La méthode retourne l'identificateur du drawer attaché.
+// int  AddDrawer(PIDrawer* drw, bool autolim=false, bool clip=true, bool ad=false)
+//	Ajout d'un "PIDrawer" au rectangle d'attachement par défaut. 
+//	Si "autolim=true", l'objet "PIBaseWdg" impose l'espace de coordonnées utilisateur
+//	à l'aide des valeurs définies par "SetDefaultDrawerLimits()".
+//	Si ""clip=true", "PIDrawer* drw" ne peut dessiner en dehors de son rectangle 
+//	d'attachement.
+//	si "ad=true", le "PIDrawer* drw" est détruit lors de la destruction de l'objet PIBaseWdg.
+//	La méthode retourne l'identificateur du drawer attaché.
+//--
+
+/* --Methode-- */
+int PIBaseWdgGen::AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1,  
+                            PIGrCoord x2, PIGrCoord y2, bool psz, bool clip, bool ad)
+{
+if (drw == NULL)   return(0);
+mDrwId++;
+BWDrwId did;
+did.x1 = x1;  did.y1 = y1;
+did.x2 = x2;  did.y2 = y2;
+did.autoszp = did.autolim = false;   
+did.elastic = psz;  did.clip = clip;
+did.id = mDrwId;  did.ad = ad; 
+did.drw = drw;
+mDrwList.push_back(did);
+drw->Attach(this, mDrwId);
+return(mDrwId);
+}
+
+/* --Methode-- */
+int PIBaseWdgGen::AddDrawer(PIDrawer* drw, bool autolim, bool clip, bool ad)
+{
+if (drw == NULL)   return(0);
+mDrwId++;
+BWDrwId did;
+did.x1 = 0.;  did.y1 = 0.;
+did.x2 = 1.;  did.y2 = 1.;
+did.autoszp = true;   did.autolim = autolim;   
+did.elastic = false;   did.clip = clip;
+did.id = mDrwId;  did.ad = ad; 
+did.drw = drw;
+mDrwList.push_back(did);
+drw->Attach(this, mDrwId);
+return(mDrwId);
+}
+
+
+//++
+// void  MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz=true)
+//	Modification du rectangle d'attachement du PIDrawer avec l'identificateur "id" , retourné
+//	par "AddDrawer()"
+// void  RemoveDrawer(int id)
+//	Ote le drawer "id" de la liste
+// void  DeleteDrawers()
+//	Ote tous les drawers de la liste. Détruit ceux ajoutés avec l'option "ad=true" 
+//--
+
+/* --Methode-- */
+void PIBaseWdgGen::MoveResizeDrawer(int id,  PIGrCoord x1, PIGrCoord y1,  PIGrCoord x2, PIGrCoord y2, bool psz)
+{
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++)  
+  if ((*it).id == id) { 
+    (*it).x1 = x1;  (*it).y1 = y1;
+    (*it).x2 = x2;  (*it).y2 = y2;
+    (*it).elastic = psz;
+    break;
+  }
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::RemoveDrawer(int id)
+{
+if (mAdfg)  return;
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++)
+  if ((*it).id == id) 
+    { (*it).drw->Detach(this, id); mDrwList.erase(it); break; }
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::DeleteDrawers()
+{
+mAdfg = true;
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++)  
+  if ((*it).ad)  delete (*it).drw;
+mDrwList.erase(mDrwList.begin(), mDrwList.end() );
+mAdfg = false;
+return;
+}
+
+//++
+// int  NbDrawers()
+//	Retourne le nombre de PIDrawer attachés
+// PIDrawer*  GetDrawerId(int id)
+//	Retourne le PIDrawer avec l'identificateur id
+// PIDrawer*  GetDrawer(int n)
+//	Retourne le PIDrawer "n=0..NbDrawers()-1" de la liste
+//--
+
+/* --Methode-- */
+int PIBaseWdgGen::NbDrawers()
+{
+return(mDrwList.size());
+}
+
+
+/* --Methode-- */
+PIDrawer* PIBaseWdgGen::GetDrawer(int n)
+{
+if ( (n < 0) || (n >= mDrwList.size()) ) return(NULL);
+return(mDrwList[n].drw);
+}
+
+/* --Methode-- */
+PIDrawer* PIBaseWdgGen::GetDrawerId(int id)
+{
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++)  
+  if ((*it).id == id)  return((*it).drw);
+return(NULL);
+}
+
+
+//++
+// void  CallDrawers(PIGraphic* g, int x0=0, int y0=0, int dx=0, int dy=0)
+//	Appel de la méthode de tracé pour tous les Drawers
+// void  CallDrawer(int id);
+//	Appel de la méthode de tracé pour le drawer avec l'identificateur "id"
+//--
+
+/* --Methode-- */
+void PIBaseWdgGen::CallDrawers(PIGraphic* g, int x0, int y0, int dx, int dy)
+{
+double xmin,ymin, xmax, ymax;
+PIGraphicUC* guc;
+int drx0, dry0, drdx, drdy;
+int ddrx0, ddry0, ddrdx, ddrdy;
+
+if (mDrElastic) { 
+  ddrx0 = (int)((double) mDrX1 * (double)XSize());
+  ddry0 = (int)((double) mDrY1 * (double)YSize());
+  ddrdx = (int)((double) mDrX2 * (double)XSize()) - ddrx0 ;
+  ddrdy = (int)((double) mDrY2 * (double)YSize()) - ddry0 ;
+  }
+else {
+  ddrx0 = (int)mDrX1;   ddry0 = (int)mDrY1;  
+  ddrdx = (int)mDrX2-ddrx0;   ddrdy = (int)mDrY2-ddry0;  
+  }
+
+bool sxy = false;
+if ((dx > 0) && (dy > 0))  sxy = true;
+
+vector<BWDrwId>::iterator it;
+bool fgc=false;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++) {
+  g->SaveGraphicAtt();
+  if ( (*it).autoszp )   // Taille/position  par defaut impose par PIBaseWdg 
+    { drx0 = ddrx0;  dry0 = ddry0;   drdx = ddrdx;  drdy = ddrdy; } 
+  else {
+    if ( (*it).elastic  ) {   // Taille/position defin en fraction de la taille du PIBaseWdg
+      drx0 = (int)((double)(*it).x1 * (double)XSize());
+      dry0 = (int)((double)(*it).y1 * (double)YSize());
+      drdx = (int)((double)(*it).x2 * (double)XSize()) - drx0 ;
+      drdy = (int)((double)(*it).y2 * (double)YSize()) - dry0 ;
+      }
+    else {
+      drx0 = (int)(*it).x1 ;  dry0 = (int)(*it).y1 ; 
+      drdx = (int)(*it).x2-drx0 ;  drdy = (int)(*it).y2-dry0 ; 
+      }
+    }
+// L'ordre des operations ici est importante 
+  if ( (*it).autolim )  
+     (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir);     
+  guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g);
+  if ((*it).clip)  { g->SetClipRectangle(drx0, dry0, drdx , drdy);  fgc = true; }
+  (*it).drw->SelGraAtt(guc);
+  if (sxy) {
+    guc->GrC2UC(x0, y0, xmin, ymin);
+    guc->GrC2UC(x0+dx, y0+dy, xmax, ymax);
+    }
+  else {
+    guc->GrC2UC(0, 0, xmin, ymin);
+    guc->GrC2UC(XSize(), YSize(), xmax, ymax);    
+    } 
+  if (xmin > xmax)  dbl_swap(xmin,xmax);
+  if (ymin > ymax)  dbl_swap(ymin,ymax);
+  (*it).drw->Draw(guc, xmin, ymin, xmax, ymax);
+  g->RestoreGraphicAtt();
+  }
+if (fgc)  g->ClearClipRectangle();
+
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::CallDrawer(int id)
+{
+double xmin,ymin, xmax, ymax;
+PIGraphicUC* guc;
+int drx0, dry0, drdx, drdy;
+int ddrx0, ddry0, ddrdx, ddrdy;
+
+PIGraphic* g = WindowGraphic();
+
+if (mDrElastic) { 
+  ddrx0 = (int)((double) mDrX1 * (double)XSize());
+  ddry0 = (int)((double) mDrY1 * (double)YSize());
+  ddrdx = (int)((double) mDrX2 * (double)XSize()) - ddrx0 ;
+  ddrdy = (int)((double) mDrY2 * (double)YSize()) - ddry0 ;
+  }
+else {
+  ddrx0 = (int)mDrX1;   ddry0 = (int)mDrY1;  
+  ddrdx = (int)mDrX2-ddrx0;   ddrdy = (int)mDrY2-ddry0;  
+  }
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
+  if ((*it).id == id) {
+    g->SaveGraphicAtt();
+    if ( (*it).autoszp )   // Taille/position  par defaut impose par PIBaseWdg 
+      { drx0 = ddrx0;  dry0 = ddry0;   drdx = ddrdx;  drdy = ddrdy; } 
+    else {
+      if ( (*it).elastic  ) {   // Taille/position defin en fraction de la taille du PIBaseWdg
+        drx0 = (int)((double)(*it).x1 * (double)XSize());
+        dry0 = (int)((double)(*it).y1 * (double)YSize());
+        drdx = (int)((double)(*it).x2 * (double)XSize()) - drx0 ;
+        drdy = (int)((double)(*it).y2 * (double)YSize()) - dry0 ;
+        }
+      else {
+        drx0 = (int)(*it).x1 ;  dry0 = (int)(*it).y1 ; 
+        drdx = (int)(*it).x2-drx0 ;  drdy = (int)(*it).y2-dry0 ; 
+        }
+      }
+// L'ordre des operations ici est importante 
+    if ( (*it).autolim ) 
+       (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir);
+    guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g);
+    if ((*it).clip)  g->SetClipRectangle(drx0, dry0, drdx , drdy);
+    (*it).drw->SelGraAtt(guc);
+    guc->GrC2UC(0, 0, xmin, ymin);
+    guc->GrC2UC(XSize(), YSize(), xmax, ymax);     
+    if (xmin > xmax)  dbl_swap(xmin,xmax);
+    if (ymin > ymax)  dbl_swap(ymin,ymax);
+    (*it).drw->Draw(guc, xmin, ymin, xmax, ymax);
+    g->RestoreGraphicAtt();    
+    if ((*it).clip)  g->ClearClipRectangle();
+    break;
+  }
+return;
+}
+
+
+/* --Methode-- */
+PIGraphic* PIBaseWdgGen::WindowGraphic()
+{
+return(mWGrC);
+}
Index: /tags/DPC_V0/Poubelle/PI/pibwdggen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pibwdggen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pibwdggen.h	(revision 1307)
@@ -0,0 +1,127 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIBaseWdgGen
+// Classe de base pour la creation de nouvelles composantes
+// graphiques interactives       
+//                        R.Ansari -  E.Aubourg 96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIBWDGGEN_H_SEEN
+#define PIBWDGGEN_H_SEEN
+
+
+#include "pisysdep.h"
+#include PIWDG_H
+#include PICMAP_H
+#include PIGRAPHIC_H
+#include "pigraphuc.h"
+#include "pievthandler.h"
+#include "psfile.h"
+
+// Mettre dans cet ordre, sinon g++ a des problemes   
+#include <vector>   
+#if defined(__KCC__)
+#include <vector.h>
+#endif
+
+
+enum PIPointer { PI_ArrowPointer = 1, PI_CrossPointer = 2, 
+                 PI_HandPointer = 3, PI_TDLRArrowPointer = 4 };
+
+
+class PIBaseWdgGen : public PIWdg
+{
+public:
+  enum {ClassId = 5000};
+
+// Les methodes ...
+
+                     PIBaseWdgGen(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PIBaseWdgGen();
+
+  virtual long       kind() {return ClassId; }
+
+//  Activation des evenements
+  virtual void       ActivatePtrCross()        = 0;
+  virtual void       ActivateButton(int bid)   = 0;
+  virtual void       ActivateMove(int bid)     = 0;
+  virtual void       ActivateKeyboard()        = 0;
+
+//  Divers : couleur de fond, Effacement fenetre,  forme de la souris
+  virtual void       SetBackgroundColor(PIColors col=PI_White)               = 0;
+  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0)     = 0;
+  virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer)          = 0;
+  virtual PIColors   GetBackgroundColor()                                    = 0;
+  virtual PIPointer  GetPointerShape()                                       = 0;
+  virtual void       AssignKeyboard()                                        = 0;
+
+//  Fonctions qui doivent contenir le dessin du contenu du widget lui-meme
+  virtual void       Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  
+// Traitement des evenements   
+  virtual void       Resize();
+  virtual void       Enter();
+  virtual void       Leave();  
+  virtual void       But1Press(int x, int y);  
+  virtual void       But1Release(int x, int y); 
+  virtual void       But2Press(int x, int y);
+  virtual void       But2Release(int x, int y);
+  virtual void       But3Press(int x, int y);
+  virtual void       But3Release(int x, int y);
+  virtual void       PtrMove(int x, int y);
+  virtual void       Ptr1Move(int x, int y);
+  virtual void       Ptr2Move(int x, int y);
+  virtual void       Ptr3Move(int x, int y);
+  virtual void       Keyboard(int key, PIKeyModifier kmod);
+
+// Acces aux caracteristiques du dernier evenement 
+  virtual void       GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm) = 0;
+
+// PostScript output
+  virtual void       PSPrint(PSFile* psf, int ofx = 0, int ofy = 0);
+
+// ------ Gestion des Drawers  ------
+  friend class PIDrawer;
+  virtual void       SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, 
+                                             PIGrCoord x2, PIGrCoord y2, bool psz=true); 
+  virtual void       SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax,
+                                            int axrl=kAxeDirSame, int ayud=kAxeDirSame); 
+  virtual int        AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, 
+                               PIGrCoord x2, PIGrCoord y2, 
+                               bool psz=true, bool clip=true, bool ad=false);
+  virtual int        AddDrawer(PIDrawer* drw, bool autolim=false, bool clip=true, bool ad=false);
+  virtual void       MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, 
+                                      PIGrCoord x2, PIGrCoord y2, bool psz=true);
+  virtual void       RemoveDrawer(int id);       // Ote un drawer de la liste
+  virtual void       DeleteDrawers();            // Ote tous les drawers, delete des drawers ajoute avec ad=true
+// Acces aux drawers 
+  virtual int        NbDrawers();
+  virtual PIDrawer*  GetDrawerId(int id);   
+  virtual PIDrawer*  GetDrawer(int n);   
+
+//  Trace des Drawers ...          
+  virtual void       CallDrawers(PIGraphic* g, int x0=0, int y0=0, int dx=0, int dy=0); 
+  virtual void       CallDrawer(int id);
+
+// Devrait etre protected - mis ici a cause de cxx  11/07/97  Reza
+  struct BWDrwId { int id; PIGrCoord x1, y1, x2, y2; bool autoszp, autolim, elastic, clip, ad;  PIDrawer* drw; };
+
+  virtual PIGraphic*  WindowGraphic();
+
+// -------------- Variables membre protegees -------------------
+protected:
+  PIGraphicWin* mWGrC;  // PIGraphic (Contexte graphique) associe a la fenetre
+  bool mAdfg;           // Pour la gestion de DeleteDrawers() quand appele par delete de PIBaseWdg
+  int mDrwId;           // Compteur pour DrawerId
+  vector<BWDrwId> mDrwList;
+//  Definition de la zone de trace et limites UC des drawers par defaut  
+  PIGrCoord mDrX1, mDrY1,  mDrX2,  mDrY2;  
+  bool mDrElastic;   // true --> Coord en fraction de la taille 
+  double mDrXmin, mDrXmax, mDrYmin, mDrYmax;   // Limites par defaut - UC
+  int  mDXdir, mDYdir;                        // Sens des axes par defaut
+
+};
+
+
+#endif /* PIBWDGGEN_H_SEEN */
+
Index: /tags/DPC_V0/Poubelle/PI/pibwdgmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pibwdgmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pibwdgmac.cc	(revision 1307)
@@ -0,0 +1,157 @@
+#include <stdio.h>
+
+#include <LString.h>
+#include "pibwdgmac.h"
+#include "piupdattachment.h"
+#include <algobase.h>
+#include <string.h>
+
+#define mGraphic mWGrC  
+
+// Les methodes de la classe  PIBWdgGen
+ 
+/* --Methode-- */
+PIBaseWdgMac::PIBaseWdgMac(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) :
+PIBaseWdgGen(par, nom, sx, sy, px, py) 
+{
+    mGraphic = new PIGraphicMac(this);
+
+    mAdapter->AddAttachment(new PIUpdAttachment(this));
+    mPane->AddAttachment(new PIUpdAttachment(this));
+    cursor = NULL;
+    
+
+}
+
+
+/* --Methode-- */
+PIBaseWdgMac::~PIBaseWdgMac()
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivatePtrCross()
+{
+// toujours actif pour le moment
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivateButton(int /*bid*/)
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivateMove(int /*bid*/)
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivateKeyboard()
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::EraseWindow(int x0, int y0, int dx, int dy)
+{
+  if (mPane->FocusDraw()) {
+     GrafPtr p = mPane->GetMacPort();
+     if (p) EraseRgn(p->visRgn);
+//	   Rect r;
+//	   mPane->CalcPortFrameRect(r);
+//       EraseRect(&r);
+  }
+}
+
+
+
+/* --Methode-- */
+void PIBaseWdgMac::SelPointerShape(PIPointer ptr)
+{
+  CursHandle c;
+  if (mPane->FocusDraw()) {
+    switch(ptr) {
+      case PI_ArrowPointer:
+        cursor = &qd.arrow;
+        break;
+      case PI_CrossPointer:
+        c = GetCursor(crossCursor);
+        HLock((Handle)c);
+        cursor = c ? *c : NULL;
+        break;
+      case PI_HandPointer:
+        c = GetCursor(128);
+        HLock((Handle)c);
+        cursor = c ? *c : NULL;
+        break;
+    }
+  }
+  mPtrS = ptr;
+}
+
+
+
+/* --Methode-- */
+PIPointer  PIBaseWdgMac::GetPointerShape()
+{
+return (mPtrS);
+}
+
+
+
+/* --Methode-- */
+bool PIBaseWdgMac::AdjustCursor()
+{
+  if (cursor) {
+    ::SetCursor(cursor);
+    return true;
+  }
+  return false;
+}
+
+/* --Methode-- 
+void PIBaseWdgMac::Refresh()
+{
+if (mPane->IsVisible())
+  Draw();
+}
+   J'ai mis cette fonction ds PIWdgMac::IsVisible()    Reza $CHECK$  01/12/97 
+*/
+
+
+
+void PIBaseWdgMac::SetBackgroundColor(PIColors col)
+{
+  if (mPane->FocusDraw()) {
+    long color;
+    switch (col) {
+      case PI_Black:
+        color = blackColor;
+        break;
+      case PI_White:
+        color = whiteColor;
+        break;
+      case PI_Red:
+        color = redColor;
+        break;
+      case PI_Blue:
+        color = blueColor;
+        break;
+      case PI_Green:
+        color = greenColor;
+        break;
+      case PI_Yellow:
+        color = yellowColor;
+        break;
+      default:
+        color = blackColor;
+    }
+    mBCol = col;
+    ::BackColor(color);
+  }
+}
+
+PIColors  PIBaseWdgMac::GetBackgroundColor() 
+{
+return (mBCol);
+}
Index: /tags/DPC_V0/Poubelle/PI/pibwdgmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pibwdgmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pibwdgmac.h	(revision 1307)
@@ -0,0 +1,45 @@
+/* Widget Xt pour affichage d'image  Interface Public    */
+/*                                    Reza 10/95         */
+
+#ifndef PIBWDGMAC_H_SEEN
+#define PIBWDGMAC_H_SEEN
+
+#include "pisysdep.h"
+#include "pibwdggen.h"
+
+
+class PIBaseWdgMac : public PIBaseWdgGen
+{
+public:
+// Les methodes ...
+
+                     PIBaseWdgMac(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PIBaseWdgMac();
+
+//  Activation des evenements
+  virtual void       ActivatePtrCross();
+  virtual void       ActivateButton(int bid);
+  virtual void       ActivateMove(int bid);
+  virtual void       ActivateKeyboard();
+
+  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
+  virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer);
+  virtual void       SetBackgroundColor(PIColors col=PI_White);
+  virtual PIColors   GetBackgroundColor();
+  virtual PIPointer  GetPointerShape();
+  virtual void       AssignKeyboard() {}
+
+protected:
+  friend class       PIUpdAttachment;
+  virtual bool       AdjustCursor();
+  CursPtr            cursor;
+  
+
+  PIPointer mPtrS;
+  PIColors  mBCol;
+};
+
+typedef PIBaseWdgMac PIBaseWdg;
+
+#endif /* RZXBASE_H_SEEN */
Index: /tags/DPC_V0/Poubelle/PI/pibwdgx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pibwdgx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pibwdgx.cc	(revision 1307)
@@ -0,0 +1,266 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIBaseWdg
+//                                    Reza 95-96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/cursorfont.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/CoreP.h>
+
+#include "pixtbaseP.h"
+#include "pixtbase.h"
+
+#include "pibwdgx.h"
+
+
+// #define DEBUG_PIBWDGX     Flag pour impression de debug etc ...
+static unsigned long colpixwhite, colpixblack;
+#define NMAXCURS 5 
+static Cursor curs[NMAXCURS];
+
+
+/* --Methode-- */
+PIBaseWdgX::PIBaseWdgX(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) 
+: PIBaseWdgGen(par, nom, sx, sy, px, py)
+
+{
+Arg  wargs[3];
+
+Init();
+mWGrC = NULL; // PIGraphic (Contexte graphique) associe a la fenetre
+finishDone = false;     // FinishCreate() pas encore appele
+
+CreateXtWdg(nom, piXtBaseWidgetClass, NULL, sx, sy, px, py);
+
+XtSetArg(wargs[0],PIXNobject,this); 
+XtSetArg(wargs[1],XtNbackground, colpixwhite);  
+XtSetArg(wargs[2],XtNborderWidth, (Dimension)0);  
+XtSetValues(XtWdg(), wargs, 3);
+
+((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask = 0;
+XtUninstallTranslations(XtWdg());
+
+mPtrS = PI_CrossPointer;
+SelPointerShape();
+// PIGraphic (Contexte graphique) associe a la fenetre
+// Si pas cree par FinishCreate()
+if (!mWGrC) mWGrC = new PIGraphicX(this);   
+Manage();
+}
+
+
+/* --Methode-- */
+PIBaseWdgX::~PIBaseWdgX()
+{
+#ifdef DEBUG_PIBWDGX 
+printf("PIBaseWdgX::~PIBaseWdgX()_Debug: Object= %lx (%lx) Wdg= %lx \n",
+(long)this, (long)(((PIXtBaseWidget)XtWdg())->pixtbase.objet), (long)XtWdg() );  
+#endif
+Arg  wargs[2];
+XtSetArg(wargs[0],PIXNobject,NULL); 
+XtSetValues(XtWdg(), wargs, 1);
+}
+
+/* --Methode-- */
+void PIBaseWdgX::FinishCreate()
+{
+if (finishDone) { 
+  fprintf(stderr, "BUG/PIBaseWdgX::FinishCreate() multiple call \n"); 
+  return; 
+  }
+// appele par la fenetre mere, apres XtRealize()
+// J'active le backing store pour la fenetre X
+XSetWindowAttributes xswa;
+if (!XtIsRealized(XtWdg())) XtRealizeWidget( XtWdg() ) ;
+
+Window mwi = XtWindow(XtWdg());
+
+/*
+XWindowAttributes xwa;
+XGetWindowAttributes(PIXDisplay(), mwi, &xwa);
+printf("PIBaseWdgX::FinishCreate()  BS= %d  (No=%d Map=%d Always=%d) planes=%lx \n", 
+       xwa.backing_store, NotUseful, WhenMapped, Always, (long)xwa.backing_planes);
+*/
+xswa.backing_store = WhenMapped;
+// xswa.backing_planes = ~0;
+// XChangeWindowAttributes(PIXDisplay(), XtWindow(XtWdg()), CWBackingPlanes|CWBackingStore, &xswa);
+XChangeWindowAttributes(PIXDisplay(), mwi, CWBackingStore, &xswa);
+
+// PIGraphic (Contexte graphique) associe a la fenetre
+if (!mWGrC) mWGrC = new PIGraphicX(this);   
+mWGrC->TerminateInit();
+finishDone = true;     // FinishCreate() fait
+} 
+
+/* --Methode-- */
+bool PIBaseWdgX::IsVisible()
+{
+return (finishDone && PIWdg::IsVisible() ); 
+}
+
+/* --Methode-- */
+void PIBaseWdgX::Refresh()
+{
+if ( IsVisible() )  {
+//  EraseWindow();   --> Ne pas faire  Reza 12/98 
+  Draw(mWGrC, 0, 0, XSize(), YSize());
+  CallDrawers(mWGrC); 
+  CallDrawHandlers(0, 0, XSize(), YSize());
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::ActivatePtrCross()
+{
+XtAddEventHandler( XtWdg(), EnterWindowMask | LeaveWindowMask, 
+                   FALSE, event_handler_pixtbase, NULL);
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::ActivateButton(int bid)
+{
+#ifdef DEBUG_PIBWDGX
+printf("PIBaseWdgX::ActivateButton %d \n \n", bid);
+#endif
+if ( (bid < 1) && (bid > 3) ) return; 
+XtAddEventHandler( XtWdg(), ButtonPressMask | ButtonReleaseMask, 
+                   FALSE, event_handler_pixtbase, NULL);
+if (bid == 1)  ((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask |= Button1Mask ;
+else if (bid == 2) ((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask |= Button2Mask ;
+else if (bid == 3) ((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask |= Button3Mask ;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::ActivateMove(int bid)
+{
+#ifdef DEBUG_PIBWDGX
+printf("PIBaseWdgX::ActivateMove %d \n \n", bid);
+#endif
+unsigned long evtmask ;
+
+// bid == 0  -> PointerMove sans bouton 
+if ( (bid < 0) && (bid > 3) ) return; 
+
+if (bid == 0) evtmask = PointerMotionHintMask ;
+else if (bid == 1) evtmask = Button1MotionMask | PointerMotionHintMask ;
+else if (bid == 2) evtmask = Button2MotionMask | PointerMotionHintMask ;
+else if (bid == 3) evtmask = Button3MotionMask | PointerMotionHintMask ;
+XtAddEventHandler( XtWdg(), evtmask, FALSE, event_handler_pixtbase, NULL);
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::ActivateKeyboard()
+{
+XtAddEventHandler( XtWdg(), KeyPressMask, FALSE, event_handler_pixtbase, NULL);
+((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask |= ShiftMask ;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SetBackgroundColor(PIColors col)
+{
+Arg  wargs[2];
+XtSetArg(wargs[0],XtNbackground, mWGrC->GetPixelValueforColor(col) );  
+XtSetValues(XtWdg(), wargs, 1);
+mBCol = col;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::EraseWindow(int x0, int y0, int dx, int dy)
+{
+XClearArea (XtDisplay(XtWdg()),XtWindow(XtWdg()), x0, y0, dx, dy, False );
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SelPointerShape(PIPointer ptr)  
+{
+if (ptr == mPtrS)  return;
+if ( (ptr < 0) || (ptr >= NMAXCURS))  return;
+if ( XtIsRealized(XtWdg()) )
+  XDefineCursor(XtDisplay (XtWdg()), XtWindow(XtWdg()), curs[ptr]);
+mPtrS = ptr;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::AssignKeyboard()
+{
+XSetInputFocus(XtDisplay (XtWdg()), XtWindow(XtWdg()), RevertToParent, PIXGetLastEventTime());
+}
+
+/* --Methode-- */
+PIColors   PIBaseWdgX::GetBackgroundColor()
+{
+return(mBCol);
+}
+
+/* --Methode-- */
+PIPointer  PIBaseWdgX::GetPointerShape()
+{
+return (mPtrS);
+}
+
+/* --Methode-- */
+void PIBaseWdgX::GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm)
+{
+unsigned int st;
+Time t;
+PIXGetLastEventInfo(st, t);
+tm = t;
+kmod = PIKM_Blank;
+if  (st & ShiftMask)   kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+if  (st & ControlMask) kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+if  (st & Mod1Mask)    kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+return;
+}
+
+static bool fgbwdg = false ;
+
+/* --Methode-- */
+void PIBaseWdgX::Init()
+{
+int i;
+
+if (fgbwdg)  return;
+fgbwdg = true;
+
+Display *mdsp = PIXDisplay();
+int scr = XDefaultScreen(mdsp);
+
+colpixwhite = XWhitePixel(mdsp, scr);
+colpixblack = XBlackPixel(mdsp, scr);
+
+curs[0] = XCreateFontCursor(mdsp, XC_X_cursor);
+for(i=1; i<NMAXCURS; i++)  curs[i] = curs[0];
+
+curs[PI_ArrowPointer] =  XCreateFontCursor(mdsp, XC_arrow);
+curs[PI_CrossPointer] =  XCreateFontCursor(mdsp, XC_crosshair);
+curs[PI_HandPointer] =  XCreateFontCursor(mdsp, XC_hand2);
+curs[PI_TDLRArrowPointer] =  XCreateFontCursor(mdsp, XC_fleur);
+
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::eXposeProcess(int x0, int y0, int dx, int dy)                                 
+{ 
+// Appel depuis le PIXtBaseWidget uniquement (ExposeEvt de Xt )
+Draw(mWGrC, x0, y0, dx, dy);
+CallDrawers(mWGrC, x0, y0, dx, dy); 
+return;
+}
Index: /tags/DPC_V0/Poubelle/PI/pibwdgx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pibwdgx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pibwdgx.h	(revision 1307)
@@ -0,0 +1,63 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIBaseWdg
+//                                    Reza  95-96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIBWDGX_H_SEEN
+#define PIBWDGX_H_SEEN
+
+#include "pisysdep.h"
+#include "pibwdggen.h"
+
+#include "pigraphx.h"
+            
+#include "pigraphps.h"
+
+class PIBaseWdgX : public PIBaseWdgGen
+{
+
+public:
+// Les methodes ...
+
+                     PIBaseWdgX(PIContainerGen *par, char *nom,
+                                int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PIBaseWdgX();
+
+  virtual void       FinishCreate();   // appele par la fenetre mere, apres XtRealize()
+
+//  Activation des evenements   
+  virtual void       ActivatePtrCross();
+  virtual void       ActivateButton(int bid);
+  virtual void       ActivateMove(int bid);
+  virtual void       ActivateKeyboard();
+
+//  Divers : couleur de fond, Effacement fenetre,  forme de la souris
+  virtual void       SetBackgroundColor(PIColors col=PI_White);
+  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
+  virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer);
+  virtual PIColors   GetBackgroundColor();
+  virtual PIPointer  GetPointerShape();
+  virtual void       AssignKeyboard();
+
+// Acces aux caracteristiques du dernier evenement 
+  virtual void       GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm);
+
+// On redefinit IsVisible() pour tenir compte de l appel a FinsihCreate  
+  virtual bool       IsVisible();
+
+//  Fonction qui doit etre appelee pour rafraichir la fenetre 
+  virtual void       Refresh();
+
+//  Appel depuis le PIXtBaseWidget uniquement (ExposeEvt de Xt )
+  virtual void       eXposeProcess(int x0, int y0, int dx, int dy);
+ 
+protected:
+  void               Init();
+  PIPointer mPtrS;
+  PIColors mBCol;
+  bool finishDone;       // Si FinsihCreate appele
+};
+
+typedef PIBaseWdgX PIBaseWdg;
+
+#endif /* PIBWDGX_H_SEEN */
Index: /tags/DPC_V0/Poubelle/PI/picmap.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmap.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmap.cc	(revision 1307)
@@ -0,0 +1,362 @@
+// Module PI : Peida Interactive     PIColorMap
+// Gestion de table de couleurs        96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "picmap.h"
+
+//++
+// Class	PIColorMap
+// Lib		PI
+// include	picmap.h
+//
+//   	Classe fournissant les services de gestion des tables de couleur.
+//	Une hiérachie un peu complexe a été mise en place pour 
+//	l'implémentation des tables de couleurs pour chaque système
+//	(Mac, XWindow, ...) :
+//|	PIColorMapGen  -----  PIColorMapX     (=PIColorMapNative)
+//|	                 |--  PIColorMapMac   (=PIColorMapNative)
+//	et la gestion de table de couleurs standard partagée.
+//|	PIColorMapNative (=X,Mac,...) ----- PIColorMap.
+//	La seule classe à utiliser est *PIColorMap* qui fournit 
+//	l'ensemble des services de gestion de table de couleurs.
+//--
+
+#define  MXMAPIDS   10 
+static   int    MapNCols[MXMAPIDS] = {256, 256, 256, 256, 256, 256, 256, 256, 256, 256};
+static   const char*  MapNoms[MXMAPIDS]  = {"Grey32","InvGrey32","ColRJ32","ColBR32",
+                               "ColRV32", "Grey128", "InvGrey128", "ColRJ128",
+                               "ColBR128", "Col16"};
+static   CMapId MapIds[MXMAPIDS] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32,
+                               CMAP_COLBR32, CMAP_COLRV32, CMAP_GREY128, 
+                               CMAP_GREYINV128, CMAP_COLRJ128, CMAP_COLBR128,  
+                               CMAP_COL16 } ;
+
+static   int mColTNums[8192];   // Max 8192 tables differentes pour le moment  
+static   int CTNum = 0;        //  Numero des tables ds mColTNum - s'incremente a chaque creation 
+
+static   int NMaxTableAuto = 0;
+static   PIColorMap* mMaps[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIColorMap(CMapId id)
+//	Constructeur d'une table de couleur standard, identifiée par "CMapId id"
+//|	CMAP_GREY32     :  32 niveaux de gris
+//|	CMAP_GREYINV32  :  32 niveaux gris du blanc au noir
+//|	CMAP_COLRJ32    :  32 couleurs, du Rouge au Jaune/blanc
+//|	CMAP_COLBR32    :  32 couleurs du bleu au rouge (arcenciel)
+//|	CMAP_COLRV32    :  32 couleurs du rouge au violet
+//|	CMAP_GREY128    :  128 niveaux de gris
+//|	CMAP_GREYINV128 :  128 niveaux gris inversé
+//|	CMAP_COLRJ128   :  128 couleurs, du Rouge au Jaune/blanc
+//|	CMAP_COLBR128   :  128 couleurs du bleu au rouge (arcenciel)
+//|	CMAP_COL16      :  16 Couleurs arcenciel
+//|	CMAP_OTHER      :  Table non standard
+//	Toutes les tables de couleurs standard possèdent 256 cellules de couleurs,
+//	contenant 16 ou 32 ou 128 couleurs distinctes.
+//
+// PIColorMap(string const& nom, int nCol)
+//	Constructeur d'une table de "nCol" couleurs identifié par la chaîne "nom".
+// PIColorMap(PIColorMap&)
+//	Constructeur par copie.
+// int Type()
+//	Retourne le type de la table, correspondant à "CMapId id"
+// int NCol()
+//	Retourne le nombre de cellules de couleurs dans la table
+// string const& Nom()
+//	Renvoie le nom de la table.
+//--
+
+PIColorMap::PIColorMap(CMapId id)
+: PIColorMapNative()
+{
+   int k, kdx;
+   string mnom;
+
+   if (NMaxTableAuto == 0) { //  Il faut allouer les tables de depart
+     if ( TotNbColors() > 2048 ) NMaxTableAuto = MXMAPIDS-1;
+     else NMaxTableAuto = 3; 
+     for(k=0; k<NMaxTableAuto; k++)  { 
+        mnom = MapNoms[k]; 
+        mMaps[k] = new PIColorMap(MapIds[k], MapNCols[k], mnom);
+     }
+   }
+
+//  Protection pour valeur de Id  
+   for(kdx=0; kdx<MXMAPIDS; kdx++)  if (id == MapIds[kdx])  break;
+   if (kdx == MXMAPIDS)  { id = MapIds[0];  kdx = 0; }
+   for(k=0; k<NMaxTableAuto; k++)  
+     if (id == mMaps[k]->Type()) {
+       CopyFrom(mMaps[k]);  
+       mCTId = mMaps[k]->mCTId;  mColTNums[mCTId]++;
+       break;
+     }
+   if (Type() != id)  {  // Table pas encore trouve dans la liste
+     k = NMaxTableAuto;
+     if (!mMaps[k] || mMaps[k]->Type() != id) {
+       if ( mMaps[k] ) {  
+         mColTNums[mMaps[k]->mCTId] = 1;  // Je force a liberer les couleurs 
+         delete mMaps[k] ;
+       }
+       mnom = MapNoms[kdx];
+       mMaps[k] = new PIColorMap(MapIds[kdx],  MapNCols[kdx], mnom); 
+     }
+    CopyFrom(mMaps[k]);  
+    mCTId = mMaps[k]->mCTId;  mColTNums[mCTId]++;
+   }
+}
+
+
+PIColorMap::PIColorMap(string const& nom, int nCol)
+: PIColorMapNative(CMAP_OTHER, nCol, nom)
+{
+  MakeColMap();
+  mCTId = CTNum;
+  mColTNums[mCTId] = 1;
+  CTNum++;
+}
+
+PIColorMap::PIColorMap(CMapId id, int nCol, string const& nom)
+: PIColorMapNative(id, nCol, nom)
+{
+  MakeColMap();
+  mCTId = CTNum;
+  mColTNums[mCTId] = 1;
+  CTNum++;
+//  printf("PIColorMap/Debug-Creation:  %d %d - %s ", Type(), NCol(), Nom().c_str());
+//  printf("  ..CRE.. %d %d \n", CTNum-1, mColTNums[CTNum-1]);
+}
+
+PIColorMap::PIColorMap(PIColorMap& cm)
+{
+  CopyFrom(&cm);
+  mCTId = cm.mCTId;
+  mColTNums[mCTId]++;
+}
+
+PIColorMap::~PIColorMap()
+{
+//  printf("PIColorMap/Debug-Delete:  %d %d - %s ", Type(), NCol(), Nom().c_str());
+//  printf("...DEL.CTNum,mColTNums= %d %d (%d %d) ", 
+//        CTNum, mColTNums[CTNum], mCTId,mColTNums[mCTId] );
+  mColTNums[mCTId]--; 
+  if ( mColTNums[mCTId] == 0 )  { FreeColors();  mColTNums[mCTId] = 0; }
+//  printf("\n");
+}
+
+
+//++
+// Titre	Gestion des couleurs
+//	Une structure *PIColor* permet la manipulation des couleurs à 
+//	travers 3 champs de type "unsigned short: 0 ... 65535" définissant
+//	les intensité des couleurs de base: Rouge, Bleue, Vert.
+//|	struct PIColor {
+//|	  unsigned short red;
+//|	  unsigned short green;
+//|	  unsigned short blue; }
+//
+//--
+//++
+// PIColor GetColor(int n)	
+//	Renvoie la couleur de la cellule "n"
+// bool AllocColor(PIColor const& col, int index)
+//	Alloue la couleur définie par "col" dans la cellule numéro "index".
+//	Renvoie "true" si OK, "false" sinon.
+// void  FreeColors()
+//	Libère les couleurs allouées par la table
+// long  TotNbColors()
+//	Renvoie le nombre total de couleurs disponibles 
+//	(Ex 256 pour un système à 8 plans image, 65536 pour 16 plans, etc ...)
+// int  NbAllocColors()
+//	Renvoie le nombre total de couleurs déjà utilisée par l'application
+//--
+
+void PIColorMap::CleanColorMaps()
+{
+  int k;
+  for(k=0; k<MXMAPIDS; k++)  { 
+    if (!mMaps[k])  continue;
+    mMaps[k]->FreeColors();
+    delete mMaps[k];
+  }
+}
+
+/*  Definition d' une table de couleurs  R G B   */
+
+static float R_RGB1[16] =
+{0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};
+static float G_RGB1[16] =
+{0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};
+static float B_RGB1[16] =
+{0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};
+
+
+
+void PIColorMap::MakeColMap()
+{
+  PIColor mycol;
+  int i,j,k;
+
+  switch (mType) {
+
+    case CMAP_GREY32 :
+      for(i=0; i<32; i++) {
+        mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
+        for(k=0; k<8; k++)     AllocColor(mycol, i*8+k);
+      }
+      break;
+    
+
+    case CMAP_GREYINV32 :
+      for(i=0; i<32; i++) {
+        mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
+        for(k=0; k<8; k++)     AllocColor(mycol, mNCol-(i*8+k)-1);
+      }
+      break;
+
+    case CMAP_COL16 :
+      for(i=0; i<16; i++) {
+        mycol.red = (int)(R_RGB1[i]*65535.);
+        mycol.green = (int)(G_RGB1[i]*65535.);
+        mycol.blue =(int)(B_RGB1[i]*65535.) ;
+        for(k=0; k<16; k++)     AllocColor(mycol, i*16+k);
+      }
+      break;
+
+    case CMAP_COLRJ32 :
+      for( i=0; i<32; i++) {
+        if (i < 12)  { 
+          mycol.green = mycol.blue = 0;  
+          mycol.red = 21535+(i*4000);  }
+        else if (i < 24) { 
+          mycol.blue = 0;   mycol.red = 65535;
+          mycol.green = 21535+(i-12)*4000;  }
+        else { 
+          mycol.green = mycol.red = 65535;
+          mycol.blue = 17535+(i-23)*6000; }
+        for(k=0; k<8; k++)   AllocColor(mycol, i*8+k); 
+        }
+      break;
+
+  case CMAP_COLBR32 :
+    for( i=0; i<32; i++) {
+      if (i < 5) { 
+        mycol.green = mycol.red = 0;    // Du bleu sombre au bleu clair
+        mycol.blue = 5535+i*15000; }
+      else if (i < 10) { 
+        mycol.blue = 65535;             // Plein bleu - On rajoute du vert -> bleu clair
+        mycol.green = 5535+(i-5)*9000;
+        mycol.red = 0;  }
+      else if (i < 15) { 
+        mycol.blue = 60000-(i-10)*15000;   // On passe au vert
+        mycol.green = 41535+(i-10)*6000;
+        mycol.red = 0;  }
+      else if (i < 21) { 
+        mycol.blue = 0;
+        mycol.green = 65535;               // Plein vert, on rajoute du rouge -> jaune
+        mycol.red = 5535+(i-15)*12000;  }
+      else if (i < 27) {  
+        mycol.blue = 0;                     //  On diminue vert -> Orange
+        mycol.green = 60000-(i-21)*12000;
+        mycol.red = 65535-(i-21)*2000;  }
+      else {
+        mycol.blue = 0;                     // Plein rouge
+        mycol.green = 0;
+        mycol.red = 57535+(i-27)*2000; }
+
+      for(k=0; k<8; k++)   AllocColor(mycol, i*8+k); 
+      }
+    break;
+
+  case CMAP_COLRV32 :
+    for( i=0; i<32; i++) {
+      if (i < 8) {
+        mycol.green = 15000+(i*5000); mycol.blue = 0;  
+        mycol.red = 15000+(i*5000); }
+      else if (i < 21) {
+        mycol.green = 50000-(i-7)*5000;   
+        if (mycol.green < 0)  mycol.green = 0;
+        mycol.blue = 0;
+        mycol.red = 53535+(i-8)*1000;  }
+      else { 
+        mycol.green = 0;  mycol.red = 65535;
+        mycol.blue = 15535+(i-21)*5000; }
+
+      for(k=0; k<8; k++)   AllocColor(mycol, i*8+k); 
+      }
+    break;
+
+    case CMAP_GREY128 :
+      for(i=0; i<128; i++) {
+        mycol.red = mycol.green = mycol.blue = 2035+(i*500);
+        for(k=0; k<2; k++)     AllocColor(mycol, i*2+k);
+      }
+      break;
+    
+
+    case CMAP_GREYINV128 :
+      for(i=0; i<128; i++) {
+        mycol.red = mycol.green = mycol.blue = 2035+(i*500);
+        for(k=0; k<2; k++)     AllocColor(mycol, mNCol-(i*2+k)-1);
+      }
+      break;
+
+    case CMAP_COLRJ128 :
+      for( i=0; i<128; i++) {
+        if (i < 48)  { 
+          mycol.green = mycol.blue = 0;  
+          mycol.red = 5375+(i*1280);  }
+        else if (i < 96) { 
+          mycol.blue = 0;   mycol.red = 65535;
+          mycol.green = 5375+((i-48)*1280);  }
+        else { 
+          mycol.green = mycol.red = 65535;
+          mycol.blue = 3535+(i-96)*2000; }
+        for(k=0; k<2; k++)   AllocColor(mycol, i*2+k); 
+        }
+      break;
+
+    case CMAP_COLBR128 :
+      for( i=0; i<128; i++) {
+        if (i < 20) { 
+          mycol.green = mycol.red = 0;  // Du bleu sombre au bleu clair
+          mycol.blue = 2835+i*3300; }
+        else if (i < 36) { 
+          mycol.blue = 65535;           // Plein bleu - On rajoute du vert -> bleu clair
+          mycol.green = 3000+(i-20)*2000;
+          mycol.red = 0;  }
+        else if (i < 56) { 
+          mycol.blue = 64600-(i-36)*3400;    // On passe au vert 
+          mycol.green = 32300+(i-36)*1700;
+          mycol.red = 0;  }
+        else if (i < 81) {         
+          mycol.blue = 0;              // Plein vert, on rajoute du rouge -> jaune
+          mycol.green = 65535;
+          mycol.red = 3135+(i-56)*2600;  }
+        else if (i < 96) { 
+          mycol.blue = 0;
+          mycol.green = 63535-(i-80)*2000;
+          mycol.red = 65535;  }
+        else if (i < 112) { 
+          mycol.blue = 0;
+          mycol.green = 30000-(i-96)*2000;
+          mycol.red = 65535-(i-96)*1000;  }
+        else {
+          mycol.blue = 0;
+          mycol.green = 0 ;
+          mycol.red = 50535+(i-112)*1000; }
+
+        for(k=0; k<2; k++)   AllocColor(mycol, i*2+k); 
+      }
+      break;
+
+  default :
+    for(i=0; i<mNCol; i++) {
+      mycol.green = mycol.red = mycol.blue = 0;
+      AllocColor(mycol, i);
+    }
+    break;
+  }
+}
Index: /tags/DPC_V0/Poubelle/PI/picmap.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmap.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmap.h	(revision 1307)
@@ -0,0 +1,45 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIColorMap
+// Gestion de table de couleurs        96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PICMAP_H_SEEN
+#define PICMAP_H_SEEN
+
+#include "pisysdep.h"
+#include PICMAPNTV_H
+
+enum CMapId
+ {
+ CMAP_OTHER       = 0, 
+ CMAP_GREY32      = 1,     // 32 niveaux de gris                    * permanent
+ CMAP_GREYINV32   = 2,     // 32 niveaux gris du blan au noir       * permanent
+ CMAP_COLRJ32     = 3,     // 32 couleurs, du Rouge au Jaune/blanc  * permanent
+ CMAP_COLBR32     = 4,     // 32 couleurs du bleu au rouge
+ CMAP_COLRV32     = 5,     // 32 couleurs 
+ CMAP_GREY128     = 6,     // 128 couleurs  niveaux de gris
+ CMAP_GREYINV128  = 7,     //    "     "      "      " 
+ CMAP_COLRJ128    = 8,     // 128 couleurs du rouge au jaune/blanc
+ CMAP_COLBR128    = 9,     // 128 couleurs du bleu au rouge
+ CMAP_COL16       = 10     // 16 Couleurs Arcenciel
+ };
+
+
+class PIColorMap : public PIColorMapNative {
+public:
+  PIColorMap(CMapId);
+  PIColorMap(string const& nom, int nCol); 
+  PIColorMap(PIColorMap&);
+  virtual ~PIColorMap();
+
+  static void CleanColorMaps();
+
+protected:
+  PIColorMap(CMapId id, int nc, string const& nom);  // Fait l'allocation des couleurs     
+  void     MakeColMap();
+
+  int mCTId;    // Pour tenir trace de la derniere table qui doit liberer les couleurs 
+};
+
+#endif
+
Index: /tags/DPC_V0/Poubelle/PI/picmapgen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmapgen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmapgen.cc	(revision 1307)
@@ -0,0 +1,39 @@
+#include "picmapgen.h"
+#include <list>
+#include <algorithm>
+#if defined(__KCC__)
+#include <list.h>
+#include <algorithm.h>
+#endif
+#include "pisysdep.h"
+#include PICMAPNTV_H
+#include PICMAP_H
+
+
+
+PIColorMapGen::PIColorMapGen()
+{
+  mNom = "";
+  mNCol = 0;
+  mType = -1;
+}
+PIColorMapGen::PIColorMapGen(int id, int nc, string const& nom)
+{
+  mNom = nom;
+  mNCol = nc;
+  mType = id;
+}
+
+
+PIColorMapGen::~PIColorMapGen()
+{
+}
+
+void PIColorMapGen::CopyFromGen(PIColorMapGen* m)
+{
+  mNom = m->mNom;
+  mNCol = m->mNCol;
+  mType = m->mType;
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/picmapgen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmapgen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmapgen.h	(revision 1307)
@@ -0,0 +1,47 @@
+#ifndef PICMAPBASE_H_SEEN
+#define PICMAPBASE_H_SEEN
+
+#include "pisysdep.h"
+#include <string>
+#include <string.h>
+#if defined(__KCC__)
+using std::string ;
+#endif
+
+
+ 
+struct PIColor {
+  unsigned short red;
+  unsigned short green;
+  unsigned short blue;
+};
+
+class PIColorMapGen {
+public:
+  PIColorMapGen();  
+  PIColorMapGen(int id, int nc, string const& nom);  
+  virtual ~PIColorMapGen();
+
+  int Type() const          {return mType;}
+  int NCol() const          {return mNCol;}
+  string const& Nom() const {return mNom;}
+
+  virtual PIColor GetColor(int n)=0;
+  virtual bool AllocColor(PIColor const& col, int index)=0;
+  virtual void FreeColors()=0;     // Desalloue les couleurs
+
+  virtual long   TotNbColors()=0;   // Donne le nombre total de couleurs disponibles
+  virtual int   NbAllocColors()=0;  // Nb de couleurs deja allouees 
+protected:
+  void CopyFromGen(PIColorMapGen*);
+  virtual void CopyFrom(PIColorMapGen*)=0;
+  
+
+  int    mNCol;
+  int    mType;
+  string mNom;
+  
+};
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/picmapmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmapmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmapmac.cc	(revision 1307)
@@ -0,0 +1,114 @@
+#include "picmapmac.h"
+#include <UDebugging.h>
+
+static int NTotAllocCol;
+
+
+PIColorMapMac::PIColorMapMac()
+: PIColorMapGen(), mPalette(NULL), mCTab(NULL)
+{
+}
+
+PIColorMapMac::PIColorMapMac(int id, int nc, string const& nom) 
+: PIColorMapGen(id, nc, nom)
+{
+    int n = nc+2;
+	mCTab = (CTabHandle) ::NewHandle(sizeof(long) + 
+				sizeof(short) + sizeof(short) + 
+				n*sizeof(ColorSpec));
+	(**mCTab).ctFlags = 0;
+	(**mCTab).ctSeed = GetCTSeed();
+	(**mCTab).ctSize = n;
+    ColorSpec* sp = (**mCTab).ctTable;
+    sp[0].rgb.red   = 0;
+    sp[0].rgb.green = 0;
+    sp[0].rgb.blue  = 0;
+    sp[0].value     = 0;
+    sp[1].rgb.red   = 65535;
+    sp[1].rgb.green = 65535;
+    sp[1].rgb.blue  = 65535;
+    sp[1].value     = 1;
+    for (int i=2; i<n; i++) {
+      sp[i].rgb.red   = 0;
+      sp[i].rgb.green = 0;
+      sp[i].rgb.blue  = 0;
+      sp[i].value     = i;
+    }
+  mPalette = NewPalette(mNCol,mCTab,pmTolerant,0);
+}
+
+PIColorMapMac::~PIColorMapMac()
+{
+  DisposePalette(mPalette);
+  DisposeHandle((Handle)mCTab);
+}
+
+/* --Methode-- */
+PIColor PIColorMapMac::GetColor(int n)
+{
+PIColor picr;
+picr.red = picr.green = picr.blue = 0;
+
+if ((n<0) || (n >= NCol()))   
+  return(picr);
+
+RGBColor qdCol;
+GetEntryColor(mPalette,n+2,&qdCol);
+
+picr.red   = qdCol.red;
+picr.green = qdCol.green;
+picr.blue  = qdCol.blue;
+
+return(picr);
+}
+
+
+bool PIColorMapMac::AllocColor(PIColor const& col, int index)
+{
+  if (!mPalette) return false;
+  if ((index < 0) || (index > mNCol))  return(false);
+  
+  RGBColor srcRGB;
+  srcRGB.red   = col.red;
+  srcRGB.green = col.green;
+  srcRGB.blue  = col.blue;
+  
+  SetEntryColor(mPalette,index+2,&srcRGB);
+  ((**mCTab).ctTable)[index+2].rgb = srcRGB;
+  NTotAllocCol++;
+  return true;    //  $CHECK$  retourne true si OK - Reza 01/12/97
+}
+
+long PIColorMapMac::TotNbColors()
+{
+   PixMapHandle pmh = ((CGrafPort*)qd.thePort)->portPixMap;
+   int depth = (**pmh).cmpSize * (**pmh).cmpCount;
+   long nbcol = 1;
+   for (int i=0; i<depth; i++)
+     nbcol *= 2;
+   return nbcol;
+}
+
+void PIColorMapMac::FreeColors()
+{
+  Assert_(mPalette);
+  DisposePalette(mPalette);
+  DisposeCTable(mCTab);
+}
+
+int PIColorMapMac::NbAllocColors()
+{
+return(NTotAllocCol);
+}
+
+
+void PIColorMapMac::CopyFrom(PIColorMapGen* x)
+{
+  CopyFromGen(x);
+  PIColorMapMac* y = (PIColorMapMac*) x;
+  mPalette = y->mPalette;
+  mCTab = y->mCTab;
+  HandToHand(&(Handle)mCTab);
+  HandToHand(&(Handle)mPalette);
+  Assert_(mPalette);
+}
Index: /tags/DPC_V0/Poubelle/PI/picmapmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmapmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmapmac.h	(revision 1307)
@@ -0,0 +1,34 @@
+#ifndef PICMAPMAC_H_SEEN
+#define PICMAPMAC_H_SEEN
+
+#include "picmapgen.h"
+#include <Palettes.h>
+
+
+class PIColorMapMac : public PIColorMapGen {
+public:
+  PIColorMapMac();
+  PIColorMapMac(int id, int nc, string const& nom);  
+  ~PIColorMapMac();
+  
+  virtual PIColor GetColor(int n);
+  virtual bool AllocColor(PIColor const& col, int index);   // $CHECK$  Reza 01/12/97(Modif)
+  virtual void FreeColors();
+
+  virtual long  TotNbColors();
+  virtual int   NbAllocColors();
+  
+  CTabHandle    GetCTab() {return mCTab;}
+protected:
+  void CopyFrom(PIColorMapGen*);
+  
+  CTabHandle    mCTab;
+  PaletteHandle mPalette;
+
+  friend class PIColorMapGen;
+  friend class PIPixmapMac;
+};
+
+typedef PIColorMapMac PIColorMapNative;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/picmapview.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmapview.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmapview.cc	(revision 1307)
@@ -0,0 +1,129 @@
+// Module PI : Peida Interactive     PICMapView
+// Visualisation de table de couleur     R. Ansari  07/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "picmapview.h"
+
+
+
+/* --Methode-- */
+PICMapView::PICMapView(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) 
+: PIBaseWdg(par, nom, sx, sy, px, py)
+
+{
+  cmap = NULL;
+  vmin = 1.;   vmax = -1.; 
+}
+
+
+/* --Methode-- */
+PICMapView::~PICMapView()
+{
+  if (cmap) delete cmap;
+}
+
+ 
+/* --Methode-- */
+void PICMapView::SetColMap(PIColorMap* cmp, float min, float max, bool refr)
+{
+  if (cmp == NULL)   { 
+    if (cmap) delete cmap;
+    cmap = NULL;
+    vmin = 1.;  vmax = -1.;
+    if (refr)  Refresh();  
+    return;
+    }
+  if ( cmap && (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER) 
+       && ((vmin-min) < 1.e-19) &&  ((vmin-min) > -1.e-19) &&
+       ((vmax-max) < 1.e-19) &&  ((vmax-max) > -1.e-19) )  return;
+  if (cmap) delete cmap;
+  cmap = new PIColorMap(*cmp);
+  vmin = min;  vmax = max;
+  if (refr)  Refresh();  
+  return;
+}
+
+/* --Methode-- */
+void PICMapView::SetColMapId(CMapId cmapid, float min, float max, bool refr)
+{
+  if ( cmap && (cmapid == cmap->Type()) && (cmapid != CMAP_OTHER) 
+       && ((vmin-min) < 1.e-19) &&  ((vmin-min) > -1.e-19) &&
+       ((vmax-max) < 1.e-19) &&  ((vmax-max) > -1.e-19) )  return;
+  if (cmap) delete cmap;
+  cmap = new PIColorMap(cmapid);
+  vmin = min;  vmax = max;
+  if (refr)  Refresh();  
+  return;
+}
+
+
+/* --Methode-- */
+void PICMapView::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
+{
+  if (!cmap) { 
+    EraseWindow(0, 0, XSize(), YSize());
+    return;
+    }
+  // On presente la table de couleur verticalement si SizeY > SizeX 
+  // ou horizontale  si SizeX > SizeY
+
+  int sx = XSize(); 
+  int sy = YSize(); 
+
+  int k;
+  if (sx > sy) {    // horizontal
+    int xc, dx;
+    xc = 0;
+    for(k=0; k<cmap->NCol(); k++) {
+      dx = (sx-xc)/(cmap->NCol()-k);
+      g->SelForeground((*cmap), k);
+      g->DrawFBox(xc, 0, dx, sy);
+      xc += dx;
+    }
+  }
+  else  {    // vertical
+    int yc, dy;
+    yc = sy;
+    for(k=0; k<cmap->NCol(); k++) {
+      dy = yc/(cmap->NCol()-k);
+      yc -= dy;
+      g->SelForeground((*cmap), k);
+      g->DrawFBox(0, yc, sx, dy);
+    }
+  }
+  
+  if (vmin > vmax)   return;
+  if ( (cmap->Type() == CMAP_GREY32) || (cmap->Type() == CMAP_GREYINV32) ||
+       (cmap->Type() == CMAP_GREY128) || (cmap->Type() == CMAP_GREYINV128) )  g->SelForeground(PI_Red);
+  else if ( (cmap->Type() == CMAP_COLRJ32) || (cmap->Type() == CMAP_COLRJ128) ) g->SelForeground(PI_Magenta);
+  else g->SelForeground(PI_White);
+
+  if (sx > sy) {    // horizontal
+    int fsz = (sy < 20) ? sy-8 : 12;
+    g->SelFontSzPt(fsz);
+    char buff[32];
+    sprintf(buff, "%.2f", vmin);
+    g->DrawString(4, sy-4, buff);
+    sprintf(buff, "%.2f", vmax);
+    g->DrawString(sx-4-(int)g->CalcStringWidth(buff), sy-4, buff);
+    } 
+  else {   // vertical 
+    int fsz = (sx < 40) ? sx/4 : 12;
+    g->SelFontSzPt(fsz);
+    char buff[32];
+    sprintf(buff, "%.2f", vmin);
+    g->DrawString(4, sy-4, buff);
+    sprintf(buff, "%.2f", vmax);
+    int fa, fd;
+    g->DrawString(4, g->GetFontHeight(fa,fd)+4, buff);
+    } 
+    
+  return;
+}
+
+
+
+
+
+
Index: /tags/DPC_V0/Poubelle/PI/picmapview.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmapview.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmapview.h	(revision 1307)
@@ -0,0 +1,39 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PICMapView
+// Visualisation de table de couleur     R. Ansari  07/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PICMAPVIEW_H_SEEN
+#define PICMAPVIEW_H_SEEN
+
+#include "pisysdep.h"
+
+#include PIBWDG_H
+#include PICMAP_H
+
+class PICMapView : public PIBaseWdg
+{
+public:
+  enum {ClassId = 5150};
+
+                  PICMapView(PIContainerGen *par, char *nom,
+                             int sx=256, int sy=10, int px=0, int py=0);
+  virtual         ~PICMapView();
+
+  virtual long	  kind() {return ClassId; }
+
+  void            SetColMap(PIColorMap* cmp=NULL, float min=1., float max=-1., bool refr=true);
+  void            SetColMapId(CMapId cmapid, float min=1., float max=-1., bool refr=true);
+
+// Traitement des evenements   
+
+  virtual void   Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+
+
+protected:
+  PIColorMap* cmap;
+  float vmin, vmax;
+};
+
+
+#endif 
Index: /tags/DPC_V0/Poubelle/PI/picmapx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmapx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmapx.cc	(revision 1307)
@@ -0,0 +1,192 @@
+#include <stdio.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+#include "piwdgx.h"
+#include "picmapx.h"
+
+/* --Methode-- */
+PIColorMapX::PIColorMapX()    
+: PIColorMapGen()
+{
+mColors = NULL;
+mColRGB = NULL;
+mNewCol = NULL;
+}
+
+/* --Methode-- */
+PIColorMapX::PIColorMapX(int id, int nc, string const& nom)    
+: PIColorMapGen(id, nc, nom)
+{
+
+int n = nc;
+mColors = new PIXColor[n];
+mColRGB = new PIColor[n];
+mNewCol = new bool[n];
+int i;
+for(i=0; i<n; i++)  
+  { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());
+  mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; 
+  mNewCol[i] = false; }
+// printf("PIColorMapX::PIColorMapX(CMapId, int) %d %d \n", mNCol, Type());
+}
+
+
+/* --Methode-- */
+PIColorMapX::~PIColorMapX()
+{
+if (mColors)  delete[] mColors;
+if (mColRGB)  delete[] mColRGB;
+if (mNewCol)  delete[] mNewCol;
+}
+
+
+/* --Methode-- */
+PIColor PIColorMapX::GetColor(int n)
+{
+if ((n<0) || (n >= NCol()))   
+  {
+  PIColor picr;
+  picr.red = picr.green = picr.blue = 0;
+  return(picr);
+  }
+return(mColRGB[n]);
+}
+
+static  Colormap  defxcmap;
+static  int xinicmap = 0;
+static int NTotColors = 0;
+static int NTotAllocCol = 0;
+
+static int nerrallocol = 0;
+
+/* --Methode-- */
+bool PIColorMapX::AllocColor(PIColor const& col, int index)
+{
+XColor myxcol;
+
+if (!xinicmap)  
+  {
+  defxcmap = XDefaultColormap (PIXDisplay(), PIXScreen());
+  xinicmap = 1;
+  }
+
+if ( (index < 0) || (index >= mNCol) )  return(false);
+
+if ( (col.red == 0) && (col.green == 0) && (col.blue == 0) )
+  {
+  mColors[index] = BlackPixel(PIXDisplay(), PIXScreen());
+  mColRGB[index] = col; 
+  mNewCol[index] = false;
+  return(true);
+  }
+
+// Pour diminuer les requetes X, on verifie si la couleur 
+// ne se trouve pas deja dans la table    Reza 19/05/98
+int kc;
+for(kc=0; kc<mNCol; kc++) 
+  if ( (col.red == mColRGB[kc].red) && (col.green == mColRGB[kc].green) &&   (col.blue == mColRGB[kc].blue) )
+    { mColors[index] = mColors[kc];  mColRGB[index] = mColRGB[kc]; 
+    mNewCol[index] = false;  return(true); }
+
+ 
+myxcol.red = col.red; 
+myxcol.blue = col.blue;
+myxcol.green = col.green;
+
+
+if ( XAllocColor(PIXDisplay(), defxcmap, &myxcol) ) {
+  mColors[index] = myxcol.pixel;
+  mColRGB[index] = col; 
+  mNewCol[index] = true;
+//  printf("PIColorMapX::AllocColor()  RGB= %d %d %d \n",
+//         (int) col.red, (int) col.blue, (int) col.green);
+  NTotAllocCol++;  
+  return(true);
+  }
+else {
+  nerrallocol++;
+  if (nerrallocol < 21) printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n",
+         (int) col.red, (int) col.blue, (int) col.green);
+  if (nerrallocol == 20) printf("No more  PIColorMapX::AllocColor() Errors will be reported \n");
+  return(false);
+  }
+}
+
+/* --Methode-- 
+void PIColorMapX::MakeColMap()
+{
+}
+*/
+
+/* --Methode-- */
+void PIColorMapX::FreeColors()
+{
+PIXColor bpix;
+PIColor blc;
+
+if (!xinicmap)  
+  {
+  defxcmap = XDefaultColormap (PIXDisplay(), PIXScreen());
+  xinicmap = 1;
+  }
+
+for (int i=0; i<mNCol; i++)
+  if ( mNewCol[i] )    XFreeColors(PIXDisplay(), defxcmap, mColors+i, 1, 0);
+
+bpix = BlackPixel(PIXDisplay(), PIXScreen());
+blc.red = blc.green = blc.blue = 0;
+{for (int i=0; i<mNCol; i++)  
+  { mColors[i] = bpix;   mColRGB[i] = blc;  mNewCol[i] = false; }
+}
+// printf("PIColorMapX::FreeColors()  Type= %d mNCol= %d \n",
+//        Type(), NCol());
+
+}
+
+
+/* --Methode-- */
+long PIColorMapX::TotNbColors()
+{
+if (NTotColors > 0)  return(NTotColors);
+// Visual* vis;
+// DefaultVisual(PIXDisplay(),  PIXScreen() );
+int k,kk;
+// On calcule le nombre de couleurs a partir du nb de plans image
+kk = DefaultDepth(PIXDisplay(),  PIXScreen() );
+NTotColors = 1;
+for(k=0; k<kk; k++) NTotColors *= 2;
+/*
+ printf("PIColorMapX::TotNbColor() / Debug : Nb Tot Colors = %d - D=%d - NCol=%d NP= %d \n", NTotColors, 
+ DefaultDepth(PIXDisplay(),  PIXScreen()), 
+ DisplayCells(PIXDisplay(),  PIXScreen()), 
+ DisplayPlanes(PIXDisplay(),  PIXScreen()) );
+*/
+return(NTotColors);
+}
+
+/* --Methode-- */
+int PIColorMapX::NbAllocColors()
+{
+return(NTotAllocCol);
+}
+
+
+/* --Methode-- */
+void PIColorMapX::CopyFrom(PIColorMapGen* x)
+{
+  if (mColors)  delete mColors;
+  if (mColRGB)  delete mColRGB;
+  if (mNewCol)  delete mNewCol;
+  CopyFromGen(x);
+  mColors = new PIXColor[mNCol];
+  mColRGB = new PIColor[mNCol];
+  mNewCol = new bool[mNCol];
+  for (int i=0; i<mNCol; i++)  
+    { mColors[i] = ((PIColorMapX *)x)->mColors[i];
+    mColRGB[i] = ((PIColorMapX *)x)->mColRGB[i]; 
+// C'est la table de couleur originale qui est responsable de liberer les couleurs - Reza 8/2/98
+    mNewCol[i] = false; }  
+}
Index: /tags/DPC_V0/Poubelle/PI/picmapx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picmapx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picmapx.h	(revision 1307)
@@ -0,0 +1,35 @@
+#ifndef PICMAPX_H_SEEN
+#define PICMAPX_H_SEEN
+
+#include "picmapgen.h"
+
+typedef   unsigned long PIXColor ;
+
+
+class PIColorMapX : public PIColorMapGen {
+public:
+  PIColorMapX();  
+  PIColorMapX(int id, int nc, string const& nom);  
+  virtual ~PIColorMapX();
+
+  inline PIXColor  Color(int index) 
+    { return ((index < mNCol) ? mColors[index] : 0); } ;
+
+  virtual PIColor GetColor(int n);
+  virtual bool AllocColor(PIColor const& col, int index);
+  virtual void FreeColors();
+
+  virtual long TotNbColors();
+  virtual int  NbAllocColors();
+
+protected:
+  virtual void CopyFrom(PIColorMapGen*);
+  
+  PIXColor  * mColors;     // La table des couleurs ...
+  PIColor   * mColRGB;     // Composantes RGB  
+  bool * mNewCol;          // Nouvelle couleur dans table ou pas
+};
+
+typedef PIColorMapX PIColorMapNative;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/picons.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picons.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picons.cc	(revision 1307)
@@ -0,0 +1,872 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "pisysdep.h"
+#include PIMENU_H
+#include "picons.h"
+
+
+// #define DEBUG_PICONS 1
+
+//  Le menu qui va servir a changer de fontes, couleurs, ...
+// de bouton-3
+static PIMenu* opmc=NULL;
+static int nb_opmc = 0;
+
+/*  --------------------------------------------------------------------------------- */
+/*  ---------  Classe PIConsole : I/O (Ecriture/lecture) texte standard  ------------ */
+/*  --------------------------------------------------------------------------------- */
+
+static int CmdStrLen = 256;
+static int PIVA_Select = 1 << 3;
+
+/* --Methode-- */
+PIConsole::PIConsole(PIContainer* par, char* nom, PIMessage msg,
+                     int nl, int nc, int sx, int sy, int px, int py, bool scb) :
+PIBaseWdg(par, nom, sx, sy, px, py) 
+{
+mNL = (nl > 10) ? nl : 10;
+mNC = (nc > 30) ? nc : 30;
+mText = new char[mNL*mNC];
+mAtt = new unsigned char[mNL*mNC];
+mLPo = new int[mNL];
+mStrBuf = new char[mNC+1];
+mCmdStr = new char[CmdStrLen+1];
+mCCP = mCLC = 0;
+mDCOff = 0;
+mScb = NULL;
+
+SetMsg(msg);
+
+int i;
+for(i=0; i<mNL; i++) {
+  mLPo[i] = i*mNC;
+  ClearLine(i);
+  }
+
+mOffL = 0;
+mNCmdL = 0;
+mCmd = "";
+
+// Pile de rappel des commandes 
+mRStr = NULL;
+mNComm = NMxRecall = 0;
+mRCindx = mRindx = 0;
+mChangeFg = false;
+
+// Copier/coller
+mCPBuffer = NULL;
+mCPBufLen = 0;
+mCPbeginC =  mCPendC = -1;
+mCPbeginL = mCPendL = -1;
+
+SetPrompt("Cmd> ");
+ClrCmd();
+SelectFont();
+SelFgBgCol();
+mCurL = mNL-mWSzL-1; 
+mCurC = 0;
+
+// Pour ajouter un scroll-bar
+AssocScrollBar(par, nom, scb, sx, sy, px, py);
+
+// Pour le menu des options : Fontes, couleur, ...
+if (!opmc) {
+  opmc = new PIMenu(this, "OptCons", k_PopupMenu);
+  opmc->AppendItem("SmallFont", 3101);
+  opmc->AppendItem("NormalFont", 3102);
+  opmc->AppendItem("LargeFont", 3103);
+  opmc->AppendItem("25L x 80C", 3301);
+  opmc->AppendItem("25L x 132C", 3302);
+  opmc->AppendItem("5L x 80C", 3303);
+  opmc->AppendItem("Bkg White", 3201);
+  opmc->AppendItem("Bkg Black", 3202);
+  }
+nb_opmc++;
+
+ActivateKeyboard();  // Gestion de l'edition 
+ActivateButton(1);   //  Action selection / copier - coller 
+ActivateMove(1);     //      "    "     "  
+ActivateButton(2);   //      "    "     "  
+ActivateButton(3);   // Pour afficher le menu des options (Fontes/couleur)
+Manage();
+return;
+}
+
+/* --Methode-- */
+PIConsole::~PIConsole()
+{
+delete[] mText;
+delete[] mAtt;
+delete[] mLPo;
+delete[] mStrBuf;
+delete[] mCmdStr;
+if (mScb) delete mScb;
+nb_opmc--;
+if (nb_opmc == 0) { delete opmc;  opmc=NULL; }
+}
+
+/* --Methode-- */
+void PIConsole::AddChar(char c, unsigned char va, bool ref)
+{
+int l1, l2;
+if (mOffL != 0)  // Decalage d'affichage precedant -> Tout rafraichir 
+  { l1 = mNL-mWSzL-1; l2 = mNL-1;  SetDispOffset(-1); }
+else l1 = l2 = mCurL; 
+if (c == '\n') {
+  mCurC = 0;
+  mCurL++;   
+  }
+else {
+  mText[mLPo[mCurL]+mCurC] = c;
+  mAtt[mLPo[mCurL]+mCurC] = va;
+  if (++mCurC == mNC) {mCurC = 0;  mCurL++; }
+  }
+
+if (mCurL >= (mNL-mNCmdL) ) { // Il faut scroller 
+  ScrollUp();  
+  mCurL = mNL-mNCmdL-1;
+  l1 = mNL-mWSzL-1; 
+  }
+if (l2 < mCurL) l2 = mCurL;
+if (ref) DisplayLines(mWGrC, l1, l2);
+return;
+}
+
+
+/* --Methode-- */
+void PIConsole::AddStr(const char* strg, unsigned char va, bool ref)
+{
+int l1, l2;
+if (mOffL != 0)  // Decalage d'affichage precedant -> Tout rafraichir 
+  { l1 = mNL-mWSzL-1; l2 = mNL-1;  SetDispOffset(-1); }
+else l1 = l2 = mCurL; 
+
+char c;
+while ( (c = *strg) != '\0') {
+  if ( c != '\n' ) {
+    mText[mLPo[mCurL]+mCurC] = c;
+    mAtt[mLPo[mCurL]+mCurC] = va;
+    if (++mCurC == mNC) {mCurC = 0;  mCurL++; }
+    }
+  else { mCurL++; mCurC = 0; } 
+  if (mCurL >= (mNL-mNCmdL) ) { // Il faut scroller 
+    ScrollUp();  
+    mCurL = mNL-mNCmdL-1;
+    l1 = mNL-mWSzL-1; 
+    }
+  strg++;
+  }
+
+if (l2 < mCurL) l2 = mCurL;
+if (ref) DisplayLines(mWGrC, l1, l2);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::SelectFont(PIFontSize sz)
+{
+int asc, desc;
+mWGrC->SelFont(sz);
+mFTaille = sz;
+mFHaut = mWGrC->GetFontHeight(asc, desc);
+mFLarg = (int)mWGrC->CalcStringWidth("ABCDEFGHIJ")/10;
+mWSzL = YSize()/mFHaut - 1;
+mWSzC = XSize()/mFLarg - 2;
+mOffL = 0;
+if (mScb) {
+  mScb->SetMinMax(0, NbLines()-1);
+  mScb->SetSlSize(WindNbLines());
+  mScb->SetValue(0);
+  }
+}
+
+
+/* --Methode-- */
+void PIConsole::AutoSize(int nl, int nc)
+{
+if ( (nl < 1) || (nc < 1) ) {
+  nl = mWSzL;   nc = mNC;
+  }
+if (nc > mNC) nc = mNC;
+int dsz[2];
+dsz[0] = (nc+2)*mFLarg - XSize();
+dsz[1] = (nl+1)*mFHaut - YSize();
+Send(Msg(), PIMsg_ResizeRequest, dsz);
+
+mWSzL = YSize()/mFHaut - 1;
+mWSzC = XSize()/mFLarg - 2;
+/*
+if (mScb) {
+  mScb->SetMinMax(0, NbLines()-1);
+  mScb->SetSlSize(WindNbLines());
+  mScb->SetValue(0);
+  }
+  */
+mOffL = 0;
+}
+
+/* --Methode-- */
+void PIConsole::PreferedSize(int& sx, int& sy)
+{
+sx = (mNC+2)*mFLarg;
+sy = (mWSzL+1)*mFHaut;
+return;
+}
+
+/* --Methode-- */
+void PIConsole::AcceptCmd(bool acc, int nmxrec)
+{
+int l1, l2;
+if (acc) {
+  if (mNCmdL)  return;  // Pas de changement d'etat
+  if (mCurL == (mNL-1) ) { l1 = mNL-mWSzL-1; ScrollUp(); mCurL = (mNL-2); }
+  else l1 = mNL-1;
+  mNCmdL = 1;
+  ClrCmd();
+  UpdCmdLine();
+  l2 = mNL-1;
+  if (nmxrec > 0) {
+    NMxRecall = (nmxrec > 5) ? nmxrec : 5;
+    if (mRStr)  delete[] mRStr;
+    mRStr = new string[NMxRecall];
+    mNComm = mRCindx = mRindx = 0;
+    mRStr[0] = "";
+    }
+  }
+else {
+  if (mNCmdL == 0)  return;  // Pas de changement d'etat
+  mNCmdL = 0;
+  ClearLine(mNL-1);
+  ClrCmd();
+  l1 = l2 = mNL-1;
+  delete[] mRStr;
+  mRCindx = mRindx = 0;
+  }
+DisplayLines(mWGrC, l1, l2);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::SetPrompt(const char* prompt)
+{
+strncpy(mPrompt, prompt, 31);  
+mPrompt[31] = '\0';
+return;
+}
+
+/* --Methode-- */
+void PIConsole::SetDispOffset(int ldeb)
+{
+if (ldeb < 0)    { 
+  if (mScb) mScb->SetValue(0); 
+  mOffL = 0;
+  }
+else mOffL = (ldeb < mNL-mWSzL-1) ? ldeb : mNL-mWSzL-1;
+}
+
+
+/* --Methode-- */
+void PIConsole::Resize()
+{
+mWSzL = YSize()/mFHaut - 1;
+mWSzC = XSize()/mFLarg - 2;
+if (mScb) {
+  mScb->SetMinMax(0, NbLines()-1);
+  mScb->SetSlSize(WindNbLines());
+  mScb->SetValue(0);
+  }
+mOffL = 0;
+}
+
+/* --Methode-- */
+void PIConsole::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
+{
+EraseWindow();
+DisplayLines(g, 0, mNL);
+}
+
+
+/* --Methode-- */
+void PIConsole::Keyboard(int key, PIKeyModifier kmod)
+{
+
+if (kmod == PIKM_Alt) {
+  if (key == 'O' || key == 'o') {   // Menu des options 
+    opmc->SetMsgParent((PIMsgHandler*)this);
+    opmc->Show(); 
+    return;
+    }
+  else if (key == 'A' || key == 'a') {  // Pour tout selectionner
+    mCPbeginC = 0; mCPendC = XSize(); 
+    mCPbeginL = 0;  mCPendL = YSize(); 
+    SaveSelection();
+    return;
+    }
+  }
+
+if (mNCmdL < 1)  return;
+
+int k;
+bool fgfk = false;
+
+if (kmod == PIKM_Cntl) {
+  switch (key) {
+    case 1 :  // <Cntl> A
+      mCCP = 0;
+      break;
+    case 5 :  // <Cntl> E
+      mCCP = mCLC;
+      break;
+    case 11 :  // <Cntl> K
+      mCLC = mCCP;
+      break;
+    }
+  }
+
+else if (kmod == PIKM_Alt) {
+  if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller)
+  }
+
+else if (kmod == PIKM_Blank) {
+  switch (key) {
+    case PIK_Return :    
+    case PIK_Enter :
+      mCmdStr[mCLC] = '\0';
+//      printf("Keyb()-Debug- <CR/Enter> CmdStr= %s (L=%d)\n", mCmdStr, strlen(mCmdStr) );
+// Gestion de rappel des commandes 
+      if (mCLC > 0) {
+        mRStr[mRCindx] = mCmdStr;
+        mRCindx++;  mNComm++;
+        if (mRCindx >= NMxRecall)  mRCindx = 0;
+        mRindx = mRCindx;
+        }
+      mChangeFg = false;
+      mCmd = mCmdStr;
+      ClrCmd();
+      Send( Msg(), PIMsg_OK, NULL);
+      break;
+
+    case PIK_BackSpace :
+    case 127 :    // Touche del
+    case 8 :      // Touche backspace
+      if (mCCP > 0)  { 
+        for(k=mCCP-1; k<mCLC-1; k++)  mCmdStr[k] = mCmdStr[k+1];
+        mCmdStr[mCLC-1] = ' ';   mCCP--;  mCLC--;
+        mChangeFg = true;
+        }
+      //      printf("Keyb()-Debug- Backspace CCP,CLC= %d %d CmdStr= %s (L=%d) \n", mCCP, mCLC, 
+      //      mCmdStr, strlen(mCmdStr));
+      break;
+      
+    case PIK_Up :
+    case PIK_Down :
+//      printf("Keyb()-Debug- CursorUp/Down(%d)  Index= %d %d  \n", key, mRindx, mRCindx);
+      if (mNComm > 0) {
+        if (mChangeFg) { 
+          mCmdStr[mCLC] = '\0';
+          mRStr[mRCindx] = mCmdStr;
+          mChangeFg = false;
+	  }
+        int nmxrec = ((mNComm+1) < NMxRecall) ? mNComm+1 : NMxRecall;
+        if (key == PIK_Up)  {
+          mRindx--; 
+          if (mRindx < 0)  mRindx = 0;
+          }
+        else { 
+          mRindx++;
+          if (mRindx >= nmxrec) mRindx= nmxrec-1;
+          }
+        mCLC = mCCP = mRStr[mRindx].length();
+        for(k=0; k< mCLC; k++)  mCmdStr[k] =  mRStr[mRindx][k];
+        mCmdStr[mCLC] = '\0';      
+        }      
+      break;
+
+    case PIK_Left :
+      if (mCCP > 0)  mCCP--;
+      //      printf("Keyb()-Debug- Left CCP,CLC= %d %d  \n", mCCP, mCLC);
+      break;
+    case PIK_Right :
+      if (mCCP < mCLC)  mCCP++;
+      //      printf("Keyb()-Debug- Right CCP,CLC= %d %d  \n", mCCP, mCLC);
+      break;
+    default :
+      fgfk = true;
+      break;
+    }
+  }
+if ( ( fgfk && (kmod == PIKM_Blank) ) || (kmod == PIKM_Shift)  ) CmdAddChar(key);
+UpdCmdLine();
+// DisplayLines(mNL-1, mNL-1);
+return;
+}
+
+
+/* --Methode-- */
+void PIConsole::But1Press(int x, int y)
+{
+Send(Msg(), PIMsg_Active);
+AssignKeyboard();
+mWGrC->SelGOMode(PI_GOXOR);
+mWGrC->SelForeground(PI_Grey);
+mCPbeginC = x;  mCPbeginL = y;
+mCPendC = mCPendL = -1;
+} 
+
+/* --Methode-- */
+void PIConsole::Ptr1Move(int x, int y)
+{
+if (mCPendC >= 0) mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL);
+mCPendC = x;  mCPendL = y;
+mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL);
+}
+ 
+/* --Methode-- */
+void PIConsole::But1Release(int x, int y)
+{
+if ( (mCPendC >= 0) && (mCPbeginC >= 0) ) { 
+  mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL);
+  mCPendC = x;  mCPendL = y;
+  }
+else { 
+  mCPbeginC =  mCPendC = -1;
+  mCPbeginL = mCPendL = -1;
+  }
+mWGrC->SelGOMode(PI_GOCopy);
+mWGrC->SelForeground(mFgC);
+SaveSelection();
+} 
+
+/* --Methode-- */
+void PIConsole::But2Press(int x, int y)
+{
+RequestSelection();  // Pour recuperer la selection = coller (copier/coller)
+} 
+
+/* --Methode-- */
+void PIConsole::But3Press(int x, int y)
+{
+opmc->SetMsgParent((PIMsgHandler*)this);
+opmc->Show((PIWdg*)this, x, y);
+}
+
+/* --Methode-- */
+void PIConsole::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
+{
+if (typ != PICP_string) return;
+int i;
+char *pc = (char *)pdata;
+for(i=0; i<l; i++) CmdAddChar(pc[i]);
+UpdCmdLine();
+}
+
+/* --Methode-- */
+void PIConsole::SelectionLost()
+{
+// printf("Debug PIConsole::SelectionLost() %lx (L=%d)\n",(long)mCPBuffer, mCPBufLen);
+if (!mCPBuffer) return;
+delete[] mCPBuffer;  
+mCPBuffer = NULL;
+mCPBufLen = 0;
+mCPbeginC =  mCPendC = -1;
+mCPbeginL = mCPendL = -1;
+int i,j;
+int l1,l2;
+l1 = mNL+1; l2 = -1;
+for(i=0; i<mNL; i++)   // On enleve le bit select a tous les caracteres 
+  for(j=0; j<mNC; j++) 
+    if ( mAtt[mLPo[i]+j] & PIVA_Select) {
+      if (l1 > i)  l1 = i;
+      if (l2 < i)  l2 = i;
+      mAtt[mLPo[i]+j] &= ~PIVA_Select ;
+    }
+
+if (IsVisible() && l2 > -1)  DisplayLines(mWGrC, l1, l2);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::SelectionTransferEnd()
+{
+// printf("Debug PIConsole::SelectionTransferEnd() -Rien- %lx (L=%d)\n",(long)mCPBuffer, mCPBufLen);
+}
+
+
+/* --Methode-- */
+void * PIConsole::ProvideSelection(unsigned int& typ, unsigned int& len)
+{
+typ = PICP_string;
+len = mCPBufLen;
+return(mCPBuffer);
+}
+
+/* ----------------------------------------------------------------------------- */
+/*    ---------------------- Methodes protected -------------------------        */
+/* ----------------------------------------------------------------------------- */
+
+
+/* --Methode-- 
+void PIConsole::DebugPrint(int lp)
+{
+printf("PIConsole::DebugPrint() - NL,NC= %d %d - WSzL,C= %d %d Cur= %d %d\n", mNL, mNC, 
+        mWSzL, mWSzC, mCurL, mCurC);
+printf(" OffL, NCmdL= %d %d - mCCP, mCLC= %d %d - LPo= %d %d \n", 
+        mOffL, mNCmdL, mCCP, mCLC, mLPo[mNL-2], mLPo[mNL-1]);
+
+if (lp == 0)  return;
+int i,j;
+for(j=0; j<mNL; j++) {
+  printf("Line[%d] (%d) = ", j, mLPo[j]);
+  for(i=0; i<mNC; i++)  putchar(mText[mLPo[j]+i]);
+  putchar('\n');
+  }
+return;
+}
+*/
+
+//  Gestion du scroll-bar
+static int Scb_Width = 14;
+
+/* --Methode-- */
+void PIConsole::AssocScrollBar(PIContainer* par, char* nom, bool scb, int sx, int sy, int px, int py)
+{
+if (!scb) {
+  mScb = NULL;
+  msgScb = 0;
+  SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+  return;   
+}
+
+sx -= Scb_Width;
+SetSize(sx, sy);
+SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+char name[128];
+strcpy(name,"ScrollBar_");
+strncat(name, nom, 127);
+msgScb = Msg()+55;
+mScb = new PIScrollBar (par, name, msgScb, kSDirDownUp, Scb_Width, sy, px+sx, py);
+mScb->SetBinding(PIBK_free, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+  
+mScb->SetMsgParent(this);
+mScb->SetMinMax(0, NbLines()-1);
+mScb->SetSlSize(WindNbLines());
+mScb->SetValue(0);
+}
+
+/* --Methode-- */
+void PIConsole::ScrollUp()
+{
+int i,l,kpo;
+l = mNL-1-mNCmdL;
+kpo = mLPo[0];
+for(i=0; i<mNL-mNCmdL-1; i++)   mLPo[i] = mLPo[i+1];
+mLPo[l] = kpo;
+ClearLine(l);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::ClearLine(int l)
+{
+if ((l<0) || (l >= mNL)) return;
+int j;
+for(j=0; j<mNC; j++) {
+  mText[mLPo[l]+j] = ' ';
+  mAtt[mLPo[l]+j] = PIVA_Def;
+  }
+return;
+}
+
+/* --Methode-- */
+void PIConsole::DisplayLines(PIGraphicGen* g, int l1, int l2)
+{
+int j,l,k,l0;
+int x,y;
+
+// DBG printf("PIConsole::DisplayLines(%d %d ) -> %d - %lx \n ", l1, l2, 
+//            (int)IsVisible(), (long)XtWindow(XtWdg()));
+
+if (! IsVisible() )   return;
+
+int lva = -1;
+int ccol, cfnt;
+
+PIFontAtt vafat[8] = {PI_RomanFont, PI_BoldFont, PI_ItalicFont,
+                      PI_RomanFont, PI_RomanFont, PI_BoldFont, 
+                      PI_ItalicFont, PI_RomanFont};
+PIColors fgc, bgc, dbgc;
+PIColors col[6] = {PI_Black, PI_Red, PI_Blue, PI_Green, PI_Yellow, PI_Magenta};
+
+g->SelForeground(mFgC);
+g->SelBackground(mBgC);
+fgc =  col[0] = g->GetForeground();
+dbgc = bgc =  g->GetBackground();
+
+int dx = mFLarg;
+int dy = mFHaut/2;
+int dxo2 = dx/2;
+if (dxo2 > 3)  dxo2 = 3;
+int dyo2 = dy/2;
+if (dyo2 > 3)  dyo2 = 3;
+
+g->DrawBox(dxo2, dyo2, (mNC+2)*mFLarg-2*dxo2, (mWSzL+1)*mFHaut-dyo2);
+
+l0 = mNL-mWSzL-mOffL;
+if (l0 < 0) l0 = 0;
+if (l1 < l0) l1 = l0;
+if (++l2 > mNL-mOffL) l2 =  mNL-mOffL;
+
+for(l=l1; l<l2; l++) {
+ y = (l-l0+1)*mFHaut+dy;
+ k = 0;   x = dx;
+ for(j=0; j<mNC; j++) {
+   if (mAtt[mLPo[l]+j] != lva) {
+     if (k > 0) {
+       mStrBuf[k] = '\0';     
+       g->DrawOpaqueString(x, y, mStrBuf);
+       //     printf("l,J,K=%d %d %d - X,Y= %d %d - %s \n", l,j,k,x,y,mStrBuf);
+       x += k*mFLarg;  k = 0;  
+       }
+     lva = mAtt[mLPo[l]+j];
+     cfnt = lva & 15;   //  Index de fonte
+     ccol = lva >> 4;   //  Index de couleur
+     fgc = col[ccol];
+     if (cfnt & PIVA_Select) 
+       { bgc = PI_Grey;   g->SelFont(mFTaille, vafat[cfnt-PIVA_Select]); }
+     else { bgc = dbgc; g->SelFont(mFTaille, vafat[cfnt]); }
+     
+     if (cfnt & PIVA_Reverse) { 
+       g->SelForeground(bgc);
+       g->SelBackground(fgc);
+       }
+     else  { 
+       g->SelForeground(fgc);
+       g->SelBackground(bgc);
+       }
+     }
+   mStrBuf[k] = mText[mLPo[l]+j];
+   k++;
+   }
+   if (k > 0) {
+     mStrBuf[k] = '\0';     
+     g->DrawOpaqueString(x, y, mStrBuf);
+     //     printf("l,J,K=%d %d %d - X,Y= %d %d - %s \n", l,j,k,x,y,mStrBuf);
+   }
+ }
+
+g->SelForeground(fgc);
+g->SelBackground(dbgc);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::UpdCmdLine()
+{
+//  char strg[260];  debug
+int l1,l2;
+l1 = l2 = mNL-1;
+if (mOffL != 0)  // Decalage d'affichage precedant -> Tout rafraichir 
+  { l1 = mNL-mWSzL-1; l2 = mNL-1;  SetDispOffset(-1); }
+
+ClearLine(mNL-1);
+int j1,j2,j,jj2;
+j1 = strlen(mPrompt);
+for(j=0; j<j1; j++) {
+  mText[mLPo[mNL-1]+j] = mPrompt[j];
+  mAtt[mLPo[mNL-1]+j] = PIVA_Def;
+//  strg[j] = mPrompt[j];    debug
+  }  
+jj2 = mWSzC-j1;
+if (mDCOff>=mCCP) mDCOff = 0;
+int koff = ((mCCP-mDCOff) >= jj2) ? mCCP-(jj2/2) : mDCOff;
+mDCOff = koff;
+int kmx = mCLC-koff;
+j2 = j1+kmx;
+if (j2 > mWSzC)  j2 = mWSzC;
+int k = koff;
+for(j=j1; j<j2; j++) {
+  mText[mLPo[mNL-1]+j] = mCmdStr[k];
+  mAtt[mLPo[mNL-1]+j] = PIVA_Bold;
+//  strg[j] = mCmdStr[k];   debug 
+  k++;
+  }  
+
+// strg[j] = '\0';   Debug
+// printf("UpdCmdLine() %d %d - %s (%d) \n [%d %d %d] %d\n", koff,kmx,strg,j1+mCCP-koff, mWSzC, j1, jj2, mCCP-(jj2/2));
+mAtt[mLPo[mNL-1]+j1+mCCP-koff] = PIVA_Reverse;    // Pour le curseur
+DisplayLines(mWGrC, l1, l2);
+}
+
+/* --Methode-- */
+void PIConsole::ClrCmd() 
+{ 
+mCCP = 0; mCLC = 0; mDCOff = 0;
+mCmdStr[0] = '\0'; 
+}  
+
+/* --Methode-- */
+void PIConsole::CmdAddChar(int key)
+{
+  int k, kmx;
+  if ( (mCCP < CmdStrLen) && isprint(key) ) {   // Ajout de caracteres
+    if (mCCP < mCLC)  { // Insertion au milieu de la chaine
+      kmx = (mCLC < CmdStrLen) ? mCLC : CmdStrLen-1;
+      //      printf(" ++DBG++ C=%d L=%d MX=%d KMX=%d\n", mCCP, mCLC, CmdStrLen,kmx);
+      for(k=kmx; k>mCCP; k--) mCmdStr[k] = mCmdStr[k-1];   mCLC = kmx+1;      
+      }
+    mCmdStr[mCCP] = key;  mCCP++; 
+    if (mCCP > mCLC)  mCLC = mCCP;
+    mChangeFg = true;
+    }
+}
+
+
+/* --Methode-- */
+void PIConsole::SelFgBgCol(PIColors fc, PIColors bc)
+{
+mFgC = fc; mBgC = bc;
+SetBackgroundColor(bc);
+}
+
+
+/* --Methode-- */
+void PIConsole::SaveSelection()
+{
+int i,j,k,l;
+int l1, l2, nl, nc;
+
+if (mCPbeginC > mCPendC) { j = mCPbeginC; mCPbeginC = mCPendC ; mCPendC = j; }
+if (mCPbeginL > mCPendL) { j = mCPbeginL; mCPbeginL = mCPendL ; mCPendL = j; }
+
+nc = (mCPendC-mCPbeginC)/mFLarg;
+nl = (mCPendL-mCPbeginL)/mFHaut;
+// printf("*DBG* NC=%d NL=%d \n",nc, nl); 
+l1 = mNL+1; l2 = -1;
+
+if (mCPBuffer) {
+  delete[] mCPBuffer;  
+  mCPBuffer = NULL;
+  mCPBufLen = 0;
+  for(i=0; i<mNL; i++)   // On enleve le bit select a tous les caracteres 
+    for(j=0; j<mNC; j++) 
+      if ( mAtt[mLPo[i]+j] & PIVA_Select) {
+        if (l1 > i)  l1 = i;
+        if (l2 < i)  l2 = i;
+        mAtt[mLPo[i]+j] &= ~PIVA_Select ;
+      }
+  }
+
+// printf("**DBG** Save: C= %d %d  L = %d %d \n", mCPbeginC, mCPendC, mCPbeginL, mCPendL);
+
+
+// On transforme la position sur la fenetre en position en caracteres ds les buffers
+
+mCPbeginC = mCPbeginC/mFLarg-1;
+mCPendC = (int) ( (float)mCPendC/(float)mFLarg-0.8 );
+mCPbeginL = (int) ( (float)mCPbeginL/(float)mFHaut-0.5 ) ;
+mCPendL = (int) ( (float)mCPendL/(float)mFHaut-0.3 ) ;
+// printf("..DBG.. C= %d %d  L = %d %d ", mCPbeginC, mCPendC, mCPbeginL, mCPendL);
+j = mNL-mWSzL-mOffL;
+mCPbeginL += j;  mCPendL += j;
+// printf(" -> %d %d \n", mCPbeginL, mCPendL);
+
+if (mCPbeginC < 0) mCPbeginC = 0;
+if (mCPendC > mNC) mCPendC = mNC;
+if (mCPbeginL < 0) mCPbeginL = 0;
+if (mCPendL > mNL) mCPendL = mNL;
+
+if ( (nc > 0) && (nl > 0) ) {
+if (!ClaimSelection()) { 
+  mCPbeginC = mCPendC = -1;
+  mCPbeginL = mCPendL = -1;
+  if (l2 > -1) DisplayLines(mWGrC, l1, l2);  
+  return;
+  }
+  l = (mCPendC-mCPbeginC+1) * (mCPendL-mCPbeginL);
+  if (l < 0) l = 0;
+  mCPBufLen = l;
+  mCPBuffer = new char[l+1];  
+  k = 0;  
+  for(j=mCPbeginL; j<mCPendL; j++) { 
+    for(i=mCPbeginC; i<mCPendC; i++)  { 
+      mAtt[mLPo[j]+i] |= PIVA_Select;
+      mCPBuffer[k] = mText[mLPo[j]+i]; k++; 
+      }
+    mCPBuffer[k] = '\n'; k++;
+    }
+  mCPBuffer[l] = '\0';
+  if (l1 > mCPbeginL) l1 = mCPbeginL;
+  if (l2 < (mCPendL-1))  l2 = mCPendL-1;
+  }
+else {  
+  l = 0;   
+  mCPbeginC =  mCPendC = mCPbeginL = mCPendL = -1; 
+  mCPBufLen = 0;
+  mCPBuffer = new char[10];  
+  mCPBuffer[0] = mCPBuffer[1] = '\0';
+  }
+
+//  printf("*DBG* Save_Display %d %d \n", l1, l2);
+
+if (l2 > -1) DisplayLines(mWGrC, l1, l2);
+}
+
+/* --Methode-- */
+void PIConsole::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+int off;
+// printf("PIConsole::Process() UserMsg()= %d ModMsg= %d \n", (int)UserMsg(msg), 
+//        (int)ModMsg(msg) );
+
+if (sender == opmc) { // Menu des options 
+  bool fgr = true;
+  switch (UserMsg(msg)) {
+    case 3101 :
+      SelectFont(PI_SmallSizeFont);
+      AutoSize();
+      break;
+    case 3102 :
+      SelectFont(PI_NormalSizeFont);
+      AutoSize();
+      break;
+    case 3103 :
+      SelectFont(PI_BigSizeFont);
+      AutoSize();
+      break;
+    case 3201 :
+      SelFgBgCol(PI_Black, PI_White);
+      break;
+    case 3202 :
+      SelFgBgCol(PI_White, PI_Black);
+      break;
+    case 3203 :
+      SelFgBgCol(PI_Yellow, PI_Black);
+      break;
+    case 3301 :
+      AutoSize(25, 80);
+      break;
+    case 3302 :
+      AutoSize(25, 132);
+      break;
+    case 3303 :
+      AutoSize(5, 80);
+      break;      
+    default :
+      fgr = false;
+      break;
+    }
+  if (fgr) Refresh();
+  }
+// Le traitement du scroll-bar
+else if ((ModMsg(msg) == PIMsg_DataChanged) && (UserMsg(msg) == msgScb) ) {
+  off = * ((int *)data);
+//  printf(" PIConsole::Process() From ScrollBar : Off=%d \n ", off);
+  SetDispOffset(off);
+  Refresh();
+  }
+// Sinon, on retranmet le message
+else ReSend(msg, sender, data); 
+}
+
Index: /tags/DPC_V0/Poubelle/PI/picons.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picons.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picons.h	(revision 1307)
@@ -0,0 +1,116 @@
+// This may look like C code, but it is really -*- C++ -*-
+// composant graphique de type console (terminal) 
+//                    R. Ansari   12/97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PICONSOLE_H
+#define PICONSOLE_H
+
+#include "pisysdep.h"
+
+#include PISTDWDG_H 
+#include PICONT_H
+#include PIBWDG_H
+
+enum PIVAType {    
+  PIVA_Def = 0,
+  PIVA_Bold = 1 << 0,
+  PIVA_Ital = 1 << 1,
+  PIVA_Reverse = 1 << 2,
+//  Le 4eme bit (<<3) est reserve pour l'usage interne (PIVA_Select)
+  PIVA_DefCol = 0,
+  PIVA_Red = 1 << 4,
+  PIVA_Blue = 2 << 4, 
+  PIVA_Green = 3 << 4, 
+  PIVA_Yellow = 4 << 4,
+  PIVA_Magenta = 5 << 4
+};
+
+class PIConsole : public PIBaseWdg {
+public:
+                     PIConsole(PIContainer* par, char* nom, PIMessage msg, int nl, int nc, 
+                               int sx=300, int sy=200, int px=0, int py=0, bool scb=true);
+                     ~PIConsole();
+
+// Interface d utilisation : 
+          void       AddChar(char c, unsigned char va= PIVA_Def, bool ref=true);
+          void       AddStr(const char* strg, unsigned char va= PIVA_Def, bool ref=true);
+
+          void       SelectFont(PIFontSize sz=PI_NormalSizeFont);
+          void       AutoSize(int nl=-1, int nc=-1);
+          void       PreferedSize(int& sx, int& sy);
+          void       AcceptCmd(bool acc=true, int nrecmx=20);
+          void       SetPrompt(const char* prompt); 
+
+  inline  int        WindNbLines() { return mWSzL; }
+  inline  int        NbLines() { return mNL; }          
+  inline  string     GetCmdString() { return(mCmd); }
+
+// Gestion des evenements input/draw 
+  virtual void       Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  virtual void       Resize();
+  virtual void       Keyboard(int key, PIKeyModifier kmod);
+  virtual void       But1Press(int x, int y);
+  virtual void       Ptr1Move(int x, int y);
+  virtual void       But1Release(int x, int y);
+  virtual void       But2Press(int x, int y);
+  virtual void       But3Press(int x, int y);
+
+// Gestion de copier/coller
+  virtual void       PasteSelection(unsigned int typ, void *pdata, unsigned int l);
+  virtual void*      ProvideSelection(unsigned int& typ, unsigned int& len);
+  virtual void       SelectionLost();
+  virtual void       SelectionTransferEnd();
+
+protected:
+          void       AssocScrollBar(PIContainer* par, char* nom, bool scb, int sx, int sy, int px, int py);
+          void       ScrollUp();
+          void       SetDispOffset(int ldeb=-1);
+          void       ClearLine(int l);
+          void       DisplayLines(PIGraphicGen* g, int l1, int l2);
+          void       UpdCmdLine();
+          void       ClrCmd();
+          void       CmdAddChar(int key);
+          void       SelFgBgCol(PIColors fc=PI_Black, PIColors bc=PI_White);
+          void       SaveSelection();  // Pour copier la selection dans un buffer
+
+  virtual void       Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+
+  int mNL, mNC;         // Nb de lignes, colonnes total de la console
+  int mCurL, mCurC;     // Numero de ligne, colonne courante
+  int mWSzL, mWSzC;     // Taille de fenetre en lignes, colonnes
+  int mOffL;            // Offset d affichage (lignes) 
+  int mNCmdL, mLCOff;   // Nb de lignes reserve a l entree des commandes
+  int mDCOff;           // Offset (en caractere) pour l affichage de la ligne de commande
+  char* mText;          // Contenu de la console
+  unsigned char* mAtt;  // Attributs du contenu (bold, ...)
+  int* mLPo;            // Adresse des lignes ds les tableaux mText, mAtt
+  char* mStrBuf;        // Buffer 
+  int mFHaut, mFLarg;   // Hauteur, Largeur des caracteres 
+  PIFontSize mFTaille;  // Taille des caracteres 
+  PIColors mFgC, mBgC;  // Couleur Avant - arriere plan
+  char  mPrompt[32];    // Le prompt
+  char* mCmdStr;        // La commande 
+  int mCCP, mCLC;       // Position du curseur, longeur de la commande
+  string mCmd;          // Le string de la derniere commande validee
+
+// Pour le rappel des commandes
+  int NMxRecall, mNComm;    // Profondeur de la pile de rappels, nb de commandes
+  string * mRStr;           // Stockage des chaines 
+  int mRCindx, mRindx;      // Index pour le rappel
+  bool mChangeFg;           // Texte modifie
+  
+// Gestion du buffer de copie
+  char* mCPBuffer;
+  unsigned int mCPBufLen;
+  int mCPbeginC, mCPbeginL;
+  int mCPendC, mCPendL;
+  
+// S il y a un scroll-bar associe
+  PIScrollBar* mScb;
+  PIMessage msgScb;
+};
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/picontainergen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picontainergen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picontainergen.cc	(revision 1307)
@@ -0,0 +1,289 @@
+//  Classe de base pour les conteneurs de PIWdg pour
+//  programmes graphiques interactives
+//
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+
+#include "picontainergen.h"
+
+//++
+// Class	PIContainer
+// Lib		PI
+// include	picontainergen.h
+//
+//	Classe conteneur gérant un ensemble d'objets "PIWdg". Cette classe 
+//	organise la hiérarchie des objets "PIWdg" et donc aussi des "PIMsgHandler",
+//	contrôle la géométrie des objets "PIWdg" contenus, ainsi que leur 
+//	visibilité et activité. Le positionnement initial est controle par
+//	un objet *PILayoutMgr* qui peut eventuellement modifier la postion
+//	ou la taille de l'objet "PIWdg" ajouté. Les attributs d'attachement
+//	de l'objet ("PIWdg::SetBinding()") contrôle le repositionnement
+//	lors du changement de taille du "PIContainer".
+//	La classe "PIContainer" est une des 
+//	classes de PI qui ont une implementation dépendante du systeme utilisé
+//	(Mac, XWindow, ...). La classe "PIContainerGen" est la classe qui
+//	définit l'interface, et ne pas doit être instanciée directement
+//	(Méthodes virtuelles pures). Les objets instanciés sont de la 
+//	classes "PIContainer" et le fichier entête correspondant est "PICONT_H"
+//	défini dans "pisysdep.h"
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Links	Voir aussi
+// PILayoutMgr
+//--
+//++
+// Titre	Constructeur
+//--
+//++
+// PIContainer(PIContainerGen *par, char *nom, int sx, int sy, int px, int py)
+//	Création d'un objet "PIContainer" dans le conteneur parent "par", de
+//	taille "sx,sy", se trouvant à la position "px,py" avec le nom "nom".
+//	Tous les widgets fils sont détruits (delete) par le destructeur
+//	(voir "SetAutoDelChilds()")
+// long kind()
+//	Renvoie le type de la classe de l'objet ("=PIContainerGen::ClassId") pour cette classe.
+//--
+//++
+// Titre	Méthodes
+//--
+//++
+// void SetLayoutMgr(PILayoutMgr* nlay)
+//	Permet de changer le gestionnaire de positions ("PILayoutMgr") du conteneur,
+//	et donc la stratégie de positionnement des objets "PIWdg" fils. 
+//	le LayoutMgr par défaut n'applique aucune contrainte sur la position
+//	ou la taille des objets ajoutés.
+//	Cette méthode ne peut être appelé que pour un conteneur vide (sans PIWdg fils).
+//	Il est conseillé de l'appeler juste après la création du "PIContainer"
+// PILayoutMgr* GetLayoutMgr()
+//	Retourne le gestionnaire de positions/tailles du conteneur.
+// void Show()
+//	Rend l'objet visible à l'écran. Tous les objets "PIWdg" contenus et qui sont dans 
+//	l'état actif sont visibles.
+// void Hide()
+//	Rend l'objet et tous les objets contenus invisibles.
+// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
+//	Appelle la méthode "PSPrint()" pour tous les objets contenus.
+// void  SetAutoDelChilds(bool ad = true)
+//	Contrôle le comportement de l'objet conteneur vis à vis des objets
+//	contenus lors de la destruction. si "ad=true", les objets contenus 
+//	sont détruits lors de l'appel du destructeur de l'objet conteneur. 
+// int  NbChilds()
+//	Retourne le nombre de "PIWdg" contenus.
+// PIWdg* GetChild(int n)
+//	Retourne le "PIWdg" numéro "n" (0..NbChilds()-1) 
+//--
+//++
+// Titre 	Méthodes particulières
+//	Les méthodes ci-dessous ne doivent pas être appelées directement.
+//--
+//++
+// void ChildAdd(PIWdg* child)
+//	Méthode qui est appelée lors de l'attachement d'un nouvel objet (création)
+//	Appelle la méthode correspondante du "PILayoutMgr"
+// void ChildAdd(PIWdg* child)
+//	Méthode qui est appelée lors du détachement d'un objet (destruction)
+//	Appelle la méthode correspondante du "PILayoutMgr"	
+//--
+
+
+/* --Methode-- */
+PIContainerGen::PIContainerGen(PIContainerGen *par, char *nom, 
+                               int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)  
+{
+stvis = false;
+stfcr = false;
+layout = new PILayoutMgr;
+layout->SetContainer(this); 
+}
+
+
+/* --Methode-- */
+PIContainerGen::~PIContainerGen()
+{
+delete layout;
+}
+
+/* --Methode-- */
+void PIContainerGen::SetLayoutMgr(PILayoutMgr* nlay)
+{
+if (nlay == NULL) return;
+if (NbChilds() > 0) {
+  fprintf(stderr, "PIContainerGen::SetLayoutMgr()/ Error! Container has childs (N = %d) \n", NbChilds()); 
+  return;
+  }
+delete layout;
+layout = nlay;
+layout->SetContainer(this); 
+}
+
+/* --Methode-- */
+void PIContainerGen::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+int i;
+if (!psf)  return;
+if (!Visible())  return;
+for(i=0; i<NbChilds(); i++)  GetChild(i)->PSPrint(psf, ofx+XPos(), ofy+YPos()); 
+return;
+}
+
+/* --Methode-- */
+void PIContainerGen::Show()
+{
+stvis = true;
+Manage();
+return;
+}
+
+/* --Methode-- */
+void PIContainerGen::Hide()
+{
+stvis = false;
+UnManage();
+return;
+}
+
+/* --Methode-- */
+bool PIContainerGen::Visible()
+{
+if (Parent())  return(stvis && Parent()->Visible());
+else return(stvis && IsVisible());
+}
+
+/* --Methode-- */
+void PIContainerGen::ChildAdd(PIWdg* child)
+{
+layout->ChildAdd(child);
+// Reza 13/10/98 : il faut que child->FinishCreate() 
+// soit appele pour les PIWdg ajoute quand le  container est deja affiche et son FinishCreate() appele
+if (stfcr)  child->FinishCreate(); 
+return;
+}
+
+/* --Methode-- */
+void PIContainerGen::ChildDel(PIWdg* child)
+{
+layout->ChildDel(child);
+}
+
+/* --Methode-- */
+int PIContainerGen::NbChilds()
+{
+return(layout->NbChilds());
+}
+
+/* --Methode-- */
+PIWdg* PIContainerGen::GetChild(int n)
+{
+return(layout->GetChild(n));
+}
+
+/* --Methode-- */
+void PIContainerGen::SetAutoDelChilds(bool ad)
+{
+layout->SetAutoDelChilds(ad) ;
+}
+
+
+/* --Methode-- */
+void PIContainerGen::FinishCreate()
+{
+if (stfcr)  return;
+int k;
+for(k=0; k<NbChilds(); k++)  GetChild(k)->FinishCreate();
+stfcr = true;
+}
+
+
+// ------------------------------------------------------------------
+//  Classe PILayoutMgr (Gestionnaire de positions/tailles PIWdg fils
+// ------------------------------------------------------------------
+//++
+// Class	PILayoutMgr
+// Lib		PI
+// include	picontainergen.h
+//
+//	Classe de gestionnaire de positions/tailles initiales des "PIWdg"
+//	fils pour les "PIContainer".
+//	La classe de base n'impose aucune contrainte sur les positions/tailles.
+//--
+//++
+// Links	Voir
+// PIContainer
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PILayoutMgr()
+//	Constructeur
+// void ChildAdd(PIWdg* child)
+//	Méthode appelé lors de l'ajout d'un nouveau "PIWdg" au conteneur.
+// void ChildDel(PIWdg* child)
+//	Méthode appelé lors de la suppression d'un "PIWdg"
+// int  NbChilds() 
+//	Nombre de "PIWdg" gérés.
+// PIWdg* GetChild(int n)
+//	Retourne l'objet "PIWdg" numéro "n"
+//--
+
+#define NCHALGRP 8
+
+/* --Methode-- */
+PILayoutMgr::PILayoutMgr()
+{
+mNCh = 0;
+mACSup = true;   // Suppression automatique des widgets fils au delete
+mPaSup = false;
+mChilds = new (PIWdg* [NCHALGRP]);
+mMxCh = NCHALGRP;
+mCont = NULL;
+}
+
+/* --Methode-- */
+PILayoutMgr::~PILayoutMgr()
+{
+mPaSup = true;   // Pour prevenir ChildDel()
+if (mACSup)
+  for(int i=0; i<mNCh; i++)  delete mChilds[i];
+delete[] mChilds;
+}
+
+/* --Methode-- */
+void PILayoutMgr::ChildAdd(PIWdg* child)
+{
+if (child == NULL)  return;
+if (mNCh == mMxCh)
+  {
+  PIWdg ** och = mChilds;
+  mChilds = new (PIWdg * [mMxCh+NCHALGRP]);
+  for(int i=0; i<mNCh; i++)  mChilds[i] = och[i];
+  delete[] och;
+  mMxCh += NCHALGRP;
+  }  
+mChilds[mNCh] = child;   mNCh++; 
+return;
+}
+
+/* --Methode-- */
+void PILayoutMgr::ChildDel(PIWdg* child)
+{
+if (mPaSup) return;  // Ne rien faire si delete initie par Container-parent : Le LayoutMgr lui-meme
+if ((child == NULL) || (mNCh < 1))  return;
+for(int i=0; i<mNCh; i++)  
+  if (mChilds[i] == child)
+    {
+    mNCh--;
+    mChilds[i] = mChilds[mNCh];
+    break;
+    }
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/picontainergen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picontainergen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picontainergen.h	(revision 1307)
@@ -0,0 +1,72 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive    PIContainerGen
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PICONTAINERBASE_SEEN
+#define PICONTAINERBASE_SEEN
+
+#include "pisysdep.h"
+
+#include PIWDG_H
+
+class PIContainerGen;
+//  Classe gestionnaire du positionnement/tailles des PIWdg d'un PIContainer
+class PILayoutMgr {
+public:
+  			PILayoutMgr();
+  virtual 		~PILayoutMgr();
+
+  inline  void		SetContainer(PIContainerGen* pic) { mCont = pic; }
+
+  virtual void		ChildAdd(PIWdg* child);
+  virtual void		ChildDel(PIWdg* child);
+
+  inline  int		NbChilds() { return(mNCh); }
+  inline  PIWdg*	GetChild(int n) 
+                        { if ( (n < 0) || (n >= mNCh))  return(NULL);
+                        else return (mChilds[n]); }
+  inline  void		SetAutoDelChilds(bool ad = true) { mACSup = ad; } 
+
+protected:
+  PIWdg                ** mChilds;
+  int                  mNCh, mMxCh;
+  bool                 mPaSup, mACSup;
+  PIContainerGen*      mCont;   // Le PIContainer auquel on est attache
+};
+
+// Classe conteneur pour le regroupement hierarchique (Fenetre/MsgHandler) des PIWdg
+class PIContainerGen : public PIWdg 
+{
+public:
+  enum {ClassId = 1500};
+
+               PIContainerGen(PIContainerGen *par, char *nom, 
+                              int sx=10, int sy=10, int px=0, int py=0);
+  virtual      ~PIContainerGen();
+
+  virtual long         kind() {return ClassId; }
+
+  virtual void	       SetLayoutMgr(PILayoutMgr* nlay);
+  inline  PILayoutMgr* GetLayoutMgr() { return(layout); }
+
+  virtual void         PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+  virtual void         Show();
+  virtual void         Hide();
+  virtual bool         Visible();
+
+  virtual void         ChildAdd(PIWdg* child);
+  virtual void         ChildDel(PIWdg* child);
+  virtual int          NbChilds();
+  virtual PIWdg*       GetChild(int n);
+          void         SetAutoDelChilds(bool ad = true);
+
+  virtual void	       FinishCreate(); // appelle FinishCreate() pour les descendants 
+
+protected:
+  bool                 stvis, stfcr;  // Statut visible ou pas, FinishCreate appele ou pas
+  PILayoutMgr*         layout;        // Gestionnaire de positionnement (/tailles) des PIWdg fils
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/picontainermac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picontainermac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picontainermac.cc	(revision 1307)
@@ -0,0 +1,13 @@
+#include "picontainermac.h"
+
+PIContainerMac::PIContainerMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIContainerGen(par, nom, sx, sy, px, py)
+{
+  // Par dfaut, un container est invisible.
+  UnManage();
+}
+
+PIContainerMac::~PIContainerMac()
+{}
+
Index: /tags/DPC_V0/Poubelle/PI/picontainermac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picontainermac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picontainermac.h	(revision 1307)
@@ -0,0 +1,20 @@
+#ifndef PICONTAINERMAC_SEEN
+#define PICONTAINERMAC_SEEN
+
+#include "picontainergen.h"
+#include "pisysdep.h"
+#include <LView.h>
+
+class PIContainerMac : public PIContainerGen {
+public:
+                         PIContainerMac(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIContainerMac();
+  
+protected:
+
+};
+
+typedef PIContainerMac PIContainer;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/picontainerx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picontainerx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picontainerx.cc	(revision 1307)
@@ -0,0 +1,59 @@
+#include "picontainerx.h"
+
+#include <Xm/Form.h>
+
+/* --Methode-- */
+PIContainerX::PIContainerX(PIContainerGen *par, char *nom, 
+                           int sx, int sy, int px, int py) 
+: PIContainerGen(par, nom, sx, sy, px, py)
+{
+if ((sx > 0) && (sy > 0)) 
+  CreateXtWdg(nom, xmFormWidgetClass , NULL, sx, sy, px, py);
+//  CreateXtWdg(nom, xmBulletinBoardWidgetClass , NULL, sx, sy, px, py);
+mTopWdg = NULL;
+}
+
+// constructeur special a utiliser par PIApplicationX ...
+PIContainerX::PIContainerX(PIMsgHandler *par, PIWdgX *parwdg, char *nom,  
+                           int sx, int sy, int px, int py) 
+: PIContainerGen(NULL, nom, sx, sy, px, py)
+{
+SetMsgParent(par);
+if ((sx > 0) && (sy > 0)) 
+  CreateXtWdg(nom, xmFormWidgetClass , parwdg->XtWdg(), sx, sy, px, py);
+mTopWdg = parwdg;
+}
+
+/* --Methode-- */
+PIContainerX::~PIContainerX()
+{}
+
+
+/* --Methode-- */
+void PIContainerX::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+// Traitement specifique pour le top-container de PIApplicationX
+if ((mTopWdg != NULL) && (ModMsg(msg) == PIMsg_ResizeRequest)) {
+  // On change la taille de la fenetre - data est un pointeur sur entier
+  // data[0] represente l'increment (positif ou negatif) en X, data[1] en Y
+  int* nsz = (int*) data;
+  mTopWdg->SetSize(mTopWdg->XSize()+nsz[0], mTopWdg->YSize()+nsz[1]);
+  return;
+  }  
+else ReSend(msg, sender, data);
+}
+
+/* --Methode-- 
+void PIContainerX::Show()
+{
+PIContainerGen::Show();
+Manage();
+}
+
+void PIContainerX::Hide()
+{
+PIContainerGen::Hide();
+UnManage();
+}
+
+*/
Index: /tags/DPC_V0/Poubelle/PI/picontainerx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/picontainerx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/picontainerx.h	(revision 1307)
@@ -0,0 +1,29 @@
+#ifndef PICONTAINERX_SEEN
+#define PICONTAINERX_SEEN
+
+#include "pisysdep.h"
+#include "picontainergen.h"
+
+
+class PIContainerX : public PIContainerGen 
+{
+public:
+	              PIContainerX(PIContainerGen *par, char *nom,
+                           int sx=10, int sy=10, int px=0, int py=0);
+
+// Ce constructeur est a utiliser par PIApplicationX ...
+              	      PIContainerX(PIMsgHandler *par, PIWdgX *parwdg, char *nom,
+                           int sx=10, int sy=10, int px=0, int py=0);
+
+  virtual  	      ~PIContainerX();
+
+// Pour traiter les Resize-Request si TopContainer de PIApplicationX
+  virtual void        Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+protected :
+  PIWdgX* mTopWdg;
+};
+
+typedef PIContainerX PIContainer;
+
+#endif  /* PICONTAINERX_SEEN */
Index: /tags/DPC_V0/Poubelle/PI/pidrawer.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pidrawer.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pidrawer.cc	(revision 1307)
@@ -0,0 +1,640 @@
+// Module PI : Peida Interactive     PIDrawer
+// Classe de traceurs pouvat être attachés à une PIBaseWdg
+//	      E. Aubourg , R.Ansari     96-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pidrawer.h"
+
+//++
+// Class	PIDrawer
+// Lib		PI
+// include	pidrawer.h
+//
+//	Classe pour la création d'objets, capables de se dessiner
+//	dans une composante graphique ("PIBaseWdg").
+//--
+//++
+// Links	Voir
+// PIBaseWdg
+//--
+
+//++
+// Titre	Constructeurs et méthodes
+//--
+
+//++
+// PIDawer()
+//	Constructeur.
+//--
+
+PIDrawer::PIDrawer()
+{
+  mBWdg = NULL; 
+  mGrUC = NULL;
+  xW0 = yW0 = 0; xWd = yWd = 100; 
+  aXdir = false;  // Vrai si Axe X de Droite vers Gauche 
+  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
+  SetLimits(-1, 1, -1, 1, kAxeDirLtoR, kAxeDirDownUp);
+  limitsFixed = 0;
+  SetAxesFlags();   // Pas de trace d'axes par defaut 
+  mDndfg = false;  // Pour controle de l'appel de Detach() si delete
+
+  mFCol = mBCol = PI_NotDefColor;
+  mLAtt = PI_NotDefLineAtt;
+  mFSz = PI_NotDefFontSize;
+  mFAtt = PI_NotDefFontAtt;
+  mMSz = -1;
+  mMrk = PI_NotDefMarker;
+  mCmapid = CMAP_OTHER;
+}
+
+PIDrawer::~PIDrawer()
+{
+  list<DrwBWId>::iterator it;
+  mDndfg = true;
+  for(it = mBWdgList.begin(); it != mBWdgList.end(); it++)
+         (*it).wdg->RemoveDrawer((*it).id);
+  if (mGrUC)  delete mGrUC;
+}
+
+//++
+// Titre	Les axes
+//--
+//++
+// void  SetLimits(double xmin, double xmax, double ymin, double ymax, -
+//                 int axrl=kAxeDirSame, int ayud=kAxeDirSame)
+//	Définit les limites du système de coordonnées.
+//|	kAxeDirSame , kAxeDirAuto
+//|	kAxeDirLtoR , kAxeDirRtoL  (Axe X)
+//|	kAxeDirDownUp , kAxeDirUpDown (Axe Y)	
+// void  GetAxesConfig(int& xa, int& ya) 
+//	Renvoie la configuration des axes.
+// double XMin()  XMax()
+//	Limites de l'axe X
+// double YMin()  YMax()
+//	Limites de l'axe Y
+// void  SetAxesFlags(unsigned int flags=kAxesNone)
+//	Attributs de tracé d'axes
+//|	kStdAxes , kBoxAxes , kTicks , kIntTicks , kExtTicks 
+//|	kMajTicks , kMinTicks , kLabels , kGridOn
+//|	kAxesDflt , kAxesNone
+// unsigned int GetAxesFlags()
+//	Renvoie les attributs de tracé d'axes  
+// void  DrawAxes(PIGraphicUC* g)
+//	Méthode de tracé des axes
+//--
+
+void
+PIDrawer::SetLimits(double xmin, double xmax, double ymin, double ymax,
+                    int axrl, int ayud)
+{
+  if (axrl == kAxeDirAuto) {
+    double ff;
+    if (xmax < xmin)  { axrl = kAxeDirRtoL;   ff=xmin;  xmin=xmax;  xmax=ff; }
+    else  axrl = kAxeDirLtoR;
+  }
+  if (ayud == kAxeDirAuto) {
+    double ff;
+    if (ymax < ymin)  { ayud = kAxeDirUpDown;   ff=ymin;  ymin=ymax;  ymax=ff; }
+    else  ayud = kAxeDirDownUp;
+  }
+  if (xmax <= xmin || ymax <= ymin)
+    return; // $CHECK$ exception ?
+  if (axrl == kAxeDirLtoR)  aXdir = false;
+  else if (axrl == kAxeDirRtoL)  aXdir = true;
+  if (ayud == kAxeDirDownUp)  aYdir = false;
+  else if (ayud == kAxeDirUpDown)  aYdir = true;
+  xMin = xmin;
+  xMax = xmax;
+  yMin = ymin;
+  yMax = ymax;
+  aXFlg = axrl;  aYFlg = ayud;
+  limitsFixed = 1;
+}
+
+void
+PIDrawer::GetAxesConfig(int& xa, int& ya)
+{
+xa = (aXdir) ? kAxeDirRtoL : kAxeDirLtoR;
+ya = (aYdir) ? kAxeDirUpDown : kAxeDirDownUp;
+}
+
+//++
+//  void  Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+//	Méthode qui est appelé lorsquer l'objet PIDrawer doit rafraichir la zone
+//	définie par "xmin-xmax" , "ymin-ymax" dans le système de coordonnées du
+//	PIDrawer.
+//  void  Refresh()
+//	Rafraîchit le dessin du PIDrawer sur tous les PIBaseWdg auxquel il est attaché.
+//  void  UpdateLimits()
+//	Cette méthode doit calculer les limites (X/Y Min-Max) préferées par l'objet
+//	et doit appeler "SetLimits()". L'implementation par défaut ne fait rien.
+//--
+
+void
+PIDrawer::UpdateLimits()
+{
+// Ne fait rien !
+  return;
+}
+
+void
+PIDrawer::Refresh()
+{
+  list<DrwBWId>::iterator it;
+  for(it = mBWdgList.begin(); it != mBWdgList.end(); it++)
+         (*it).wdg->CallDrawer((*it).id);
+
+}
+
+//++
+// Titre	Les attributs graphiques
+//--
+//++
+// void  SetColAtt(PIColors fg=PI_NotDefColor, PIColors bg=PI_NotDefColor)
+//	Modifie la couleur d'avant-plan et de fond par défaut
+// void  SetLineAtt(PILineAtt lat=PI_NotDefLineAtt)
+//	Modifie l'attribut type de ligne
+// void  SetFontAtt(PIFontSize fsz=PI_NotDefFontSize, PIFontAtt fat=PI_NotDefFontAtt)
+//	L'attribut Type de fonte 
+// void  SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker)
+//	L'attribut type et taille de marker
+// void  SetColMapId(CMapId cid=CMAP_OTHER)
+//	L'attribut choix de la table de couleurs
+// void  SelGraAtt(PIGraphicUC* g)
+//	Modifie les attributs graphiques de "g" à partir des attributs courant
+//	de l'objet "PIDrawer"
+// 
+// PIColors  GetFgColAtt()
+//	Renvoie l'attribut de couleur d'avant-plan
+// PIColors  GetBgColAtt()
+//	Renvoie l'attribut de couleur d'arrière-plan
+// PILineAtt  GetLineAtt()
+//	Renvoie l'attribut de ligne
+// PIFontSize GetFontSz()
+//	Renvoie l'attribut de taille de fonte
+// PIFontAtt  GetFontAtt()
+//	Renvoie l'attribut de type de fonte
+// int  GetMarkerSz()
+//	Renvoie l'attribut de taille de marker
+// PIMarker GetMarker()
+//	Renvoie l'attribut de type de marker
+// CMapId GetColMapId()
+//	Renvoie l'attribut de type de table de couleur
+//--
+
+void 
+PIDrawer::SetColAtt(PIColors fg, PIColors bg)
+{
+  mFCol = fg;
+  mBCol = bg;
+}
+
+void 
+PIDrawer::SetLineAtt(PILineAtt lat)
+{
+  mLAtt = lat;
+}
+
+void 
+PIDrawer::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
+{
+  mFSz = fsz;
+  mFAtt = fat;
+}
+
+void 
+PIDrawer::SetMarkerAtt(int sz, PIMarker mrk)
+{
+  mMSz = sz;
+  mMrk = mrk;
+}
+
+void 
+PIDrawer::SetColMapId(CMapId cid)
+{
+  mCmapid = cid;
+}
+
+void 
+PIDrawer::SelGraAtt(PIGraphicUC* g)
+{
+  if (mFCol != PI_NotDefColor)    g->SelForeground(mFCol);
+  if (mBCol != PI_NotDefColor)    g->SelBackground(mBCol);
+  if (mLAtt != PI_NotDefLineAtt)  g->SelLine(mLAtt);
+  if ( (mFSz != PI_NotDefFontSize) || (mFAtt != PI_NotDefFontAtt) )
+                                  g->SelFont(mFSz, mFAtt);
+  if ( (mMrk != PI_NotDefMarker) || (mMSz >= 0) )
+                                  g->SelMarker(mMSz, mMrk);
+}
+
+
+void
+PIDrawer::Attach(PIBaseWdgGen* wdg, int id)
+{
+  if (!wdg) return;
+  DrwBWId bwi;
+  bwi.id = id;  bwi.wdg = wdg;
+  mBWdgList.push_back(bwi);
+  return;
+}
+
+void
+PIDrawer::Detach(PIBaseWdgGen* wdg, int id)
+{
+  if (mDndfg) return;
+  if (!wdg) return;
+  list<DrwBWId>::iterator it;
+  for(it = mBWdgList.begin(); it != mBWdgList.end(); it++)
+     if ( ((*it).id == id) && ((*it).wdg == wdg) ) { mBWdgList.erase(it);  break; }
+  return;
+}
+
+
+PIGraphicUC*
+PIDrawer::SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g)
+{
+  mBWdg = drw;
+  xW0 = x0;   yW0 = y0;
+  xWd = dx;   yWd = dy;
+  if (mGrUC)  delete mGrUC;
+  mGrUC = new PIGraphicUC(g, x0, y0, dx, dy);
+  mGrUC->SetUCS(xMin, xMax, yMin, yMax, aXFlg, aYFlg);
+  return(mGrUC);
+}
+
+/* --Methode-Static-- */
+void PIDrawer::BestTicks(double rmin,double rmax,int nticks,double& majt)
+{
+double d = rmax - rmin;
+double ld = log10(d);
+double fld = floor(fabs(ld));
+double del,del0;
+double fac[4] = {2.,5.,10.,20.};
+if(ld>=0.) { fld -= 1.; del0 = del = pow(10.,fld); }
+else { fld += 2.; del0 = del = pow(10., -fld); }
+int k=0;
+while( d/del > (double) nticks && k<4 ) { del = fac[k]*del0; k++; }
+majt = del;
+}
+
+void
+PIDrawer::CalcTicks()
+{
+  BestTicks(xMin,xMax,7,xMajTickStep);
+  xMinTickStep = xMajTickStep/5;
+  xFirstMajTick = int(xMin / xMajTickStep) * xMajTickStep;
+  if (xFirstMajTick < xMin) xFirstMajTick += xMajTickStep;
+  xFirstMinTick = int(xMin / xMinTickStep) * xMinTickStep;
+  if (xFirstMinTick < xMin) xFirstMinTick += xMinTickStep;
+
+  BestTicks(yMin,yMax,12,yMajTickStep);
+  yMinTickStep = yMajTickStep/5;
+  yFirstMajTick = int(yMin / yMajTickStep) * yMajTickStep;
+  if (yFirstMajTick < yMin) yFirstMajTick += yMajTickStep;
+  yFirstMinTick = int(yMin / yMinTickStep) * yMinTickStep;
+  if (yFirstMinTick < yMin) yFirstMinTick += yMinTickStep;
+
+  yMajTickLen = (xMax-xMin)/100;
+  yMinTickLen = (xMax-xMin)/250;
+  xMajTickLen = (yMax-yMin)/100;
+  xMinTickLen = (yMax-yMin)/250;
+}
+
+void
+PIDrawer::SetAxesFlags(unsigned int flags)
+{
+  axesFlags = flags;
+  if (axesFlags & (kIntTicks | kExtTicks | kMajTicks | kMinTicks))
+    axesFlags |= kTicks;
+  if ((axesFlags & (kTicks | kIntTicks | kExtTicks)) == kTicks)
+    axesFlags |= kIntTicks | kExtTicks;
+  if ((axesFlags & (kTicks | kMajTicks | kMinTicks)) == kTicks)
+    axesFlags |= kMajTicks;
+}
+
+
+void
+PIDrawer::DrawAxes(PIGraphicUC* g)
+{
+  g->NoClip();
+  if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+  else g->SelLine(mLAtt);
+//  On calcule les ticks 
+  CalcTicks();
+
+  unsigned int flags = axesFlags;
+
+  if (flags & kStdAxes) {
+
+    // Les axes
+    
+    g->DrawLine(xMin, 0, xMax, 0);
+    g->DrawLine(0, yMin, 0, yMax);
+
+    // La grille en pointilles
+
+    if (flags & kGridOn) DrawGrid(g);
+  
+    // Les ticks majeurs
+  
+    if (flags & kMajTicks) {
+        DrawHTicks(g, 0, xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawVTicks(g, 0, yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep);
+    }
+    
+    // Les ticks mineurs
+  
+    if (flags & kMinTicks) {
+        DrawHTicks(g, 0, xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawVTicks(g, 0, yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep);
+    }
+    
+    // Les labels
+    
+    if (flags & kLabels) {
+      if (!aYdir)
+        DrawHLabels(g, -xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      else 
+        DrawHLabels(g, xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      if (!aXdir)
+        DrawVLabels(g, -yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+      else 
+        DrawVLabels(g, yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+    }
+    
+  }
+  
+  if (flags & kBoxAxes) {
+  
+    // La boite
+    
+    g->DrawLine(xMin, yMin, xMax, yMin);
+    g->DrawLine(xMax, yMin, xMax, yMax);
+    g->DrawLine(xMax, yMax, xMin, yMax);
+    g->DrawLine(xMin, yMax, xMin, yMin);
+
+    // Longueur des ticks
+    
+    double extXMajTickLen = flags&kExtTicks ? xMajTickLen : 0;
+    double intXMajTickLen = flags&kIntTicks ? xMajTickLen : 0;
+    double extXMinTickLen = flags&kExtTicks ? xMinTickLen : 0;
+    double intXMinTickLen = flags&kIntTicks ? xMinTickLen : 0;
+    double extYMajTickLen = flags&kExtTicks ? yMajTickLen : 0;
+    double intYMajTickLen = flags&kIntTicks ? yMajTickLen : 0;
+    double extYMinTickLen = flags&kExtTicks ? yMinTickLen : 0;
+    double intYMinTickLen = flags&kIntTicks ? yMinTickLen : 0;
+
+    // La grille en pointilles
+
+    if (flags & kGridOn) DrawGrid(g);
+
+    // Les ticks majeurs
+  
+    if (flags & kMajTicks) {
+        DrawHTicks(g, yMin, intXMajTickLen, extXMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawHTicks(g, yMax, extXMajTickLen, intXMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawVTicks(g, xMin, extYMajTickLen, intYMajTickLen, yFirstMajTick, yMajTickStep);
+        DrawVTicks(g, xMax, intYMajTickLen, extYMajTickLen, yFirstMajTick, yMajTickStep);
+    }
+    
+    // Les ticks mineurs
+  
+    if (flags & kMinTicks) {
+        DrawHTicks(g, yMin, intXMinTickLen, extXMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawHTicks(g, yMax, extXMinTickLen, intXMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawVTicks(g, xMin, extYMinTickLen, intYMinTickLen, yFirstMinTick, yMinTickStep);
+        DrawVTicks(g, xMax, intYMinTickLen, extYMinTickLen, yFirstMinTick, yMinTickStep);
+    }
+
+
+    // Les labels
+    
+    if (flags & kLabels) {
+      if (!aYdir) {
+        DrawHLabels(g, yMin-xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(g, yMax+xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
+      }
+      else {
+        DrawHLabels(g, yMin-xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(g, yMax+xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      }
+      if (!aXdir) {
+        DrawVLabels(g, xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+        DrawVLabels(g, xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
+      }
+      else {
+        DrawVLabels(g, xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
+        DrawVLabels(g, xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+      }
+    }
+  }
+  g->Clip();
+}
+
+  
+
+void
+PIDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/)
+{
+}
+
+
+void
+PIDrawer::DrawHTicks(PIGraphicUC* g, double y, double tickUp, double tickDown, double xBeg, double xStep)
+{
+  for (double x=xBeg; x<=xMax; x += xStep)
+    g->DrawLine(x, y-tickDown, x, y+tickUp);
+}
+
+void
+PIDrawer::DrawVTicks(PIGraphicUC* g, double x, double tickLeft, double tickRight, double yBeg, double yStep)
+{
+  for (double y=yBeg; y<=yMax; y += yStep)
+    g->DrawLine(x-tickLeft, y, x+tickRight, y);
+}
+
+void
+PIDrawer::DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, int just)
+{
+  double xOffset = 0;
+  int kk;
+  g->SelFontSz(xMajTickLen*4.);
+  for (double x=xBeg; x<=xMax; x += xStep) {
+      char label[20]; sprintf(label, "%-6g", x);
+      for(kk=0; kk<20; kk++)
+        if (label[kk] == ' ')   { label[kk] = '\0' ; break; }
+      double largeur = g->CalcStringWidth(label);
+      if (just == 1)
+        xOffset = -largeur;
+      else if (just == 0)
+        xOffset = -largeur/2;
+      else
+        xOffset = 0;
+      if (aXdir)  xOffset = -xOffset;
+      g->DrawString(x+xOffset, y, label);
+  }
+}
+
+void
+PIDrawer::DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, int just)
+{
+  double xOffset = 0;
+  g->SelFontSz(xMajTickLen*4.);
+  for (double y=yBeg; y<=yMax; y += yStep) {
+      char label[20]; sprintf(label, "%-6g", y);
+      double largeur = g->CalcStringWidth(label);
+      if (just == 1)
+        xOffset = -largeur;
+      else if (just == 0)
+        xOffset = -largeur/2;
+      else
+        xOffset = 0;
+      if (aXdir)  xOffset = -xOffset;
+      g->DrawString(x+xOffset, y, label);
+  }
+}
+
+void
+PIDrawer::DrawGrid(PIGraphicUC* g)
+{
+  PILineAtt savlineatt = g->GetLineAtt();
+//  g->SelLine(PI_ThinDashedLine);
+  g->SelLine(PI_ThinDottedLine);
+
+  for (double x=xFirstMajTick; x<=xMax; x += xMajTickStep)
+    g->DrawLine(x, yMin, x, yMax);
+
+  for (double y=yFirstMajTick; y<=yMax; y += yMajTickStep)
+    g->DrawLine(xMin, y, xMax, y);
+
+  g->SelLine(savlineatt);
+}
+
+
+/*  --------------------------------------------------------------  */
+/*  ------------------- Classe PIElDrawer ------------------------  */
+/*  --------------------------------------------------------------  */
+
+/* --Methode-- */
+PIElDrawer::PIElDrawer()
+{
+mEn = 0;
+titleT = titleB = "";
+}
+
+/* --Methode-- */
+PIElDrawer::~PIElDrawer()
+{
+}
+
+/* --Methode-- */
+void PIElDrawer::SetTitles(const char* tt, const char* tb)
+{
+if (tt != NULL)  titleT = tt;
+if (tb != NULL)  titleB = tb;
+}
+
+/* --Methode-- */
+void PIElDrawer::SetTitles(string const & tt, string const & tb)
+{
+titleT = tt;  titleB = tb;
+}
+
+/* --Methode-- */
+void  PIElDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/)
+{
+DrawAxes(g);   // Trace des axes 
+
+SelGraAtt(g);   // DrawAxes change certains attributs graphiques
+if (mFSz == PI_NotDefFontSize) g->SelFont(PI_NormalSizeFont);
+// Trace des titres 
+if ( (titleT.length() > 0) || (titleB.length() > 0) ) {
+  aXdir = false;  // Vrai si Axe X de Droite vers Gauche 
+  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
+  PIGrCoord gas, gds;
+  double fx, fy, fh;
+//  fh = g->GetFontHeightUC(gas, gds);
+  fh = 0.075*(YMax()-YMin());
+  if ( titleT.length() > 0) {
+      fx = g->CalcStringWidth(titleT.c_str());
+      if(aXdir) fx = XMax()-(XMax()-XMin()-fx)/2.;
+      else fx = XMin()+(XMax()-XMin()-fx)/2.;
+      if (aYdir) fy = YMin()-fh;
+      else fy = YMax()+fh;
+      g->DrawString(fx, fy, titleT.c_str());
+//      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
+    }
+  if ( titleB.length() > 0) {
+      fx = g->CalcStringWidth(titleB.c_str());
+      if(aXdir) fx = XMax()-(XMax()-XMin()-fx)/2.;
+      else fx = XMin()+(XMax()-XMin()-fx)/2.;
+      if (aYdir) fy =  YMax()+fh*1.5;
+      else fy = YMin()-fh*1.5;
+      g->DrawString(fx, fy, titleB.c_str());
+//      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
+    }
+  }
+DrwElList::iterator it;
+PIColors cc = g->GetForeground();
+for (it = mElist.begin(); it != mElist.end(); it++)
+  {
+  if ((*it).col != PI_NotDefColor)  g->SelForeground((*it).col);
+  switch ( (*it).etyp )
+    {
+    case PIDEL_Line :
+      g->DrawLine((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 
+      break;
+    case PIDEL_Text :
+      g->DrawString((*it).ex, (*it).ey, (char*) ((*it).es.c_str()) ); 
+      break;
+    case PIDEL_Rect :
+      g->DrawBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 
+      break;
+    case PIDEL_FRect :
+      g->DrawFBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 
+      break;
+    case PIDEL_Circ :
+      g->DrawCircle((*it).ex, (*it).ey, (*it).edx ); 
+      break;
+    case PIDEL_FCirc :
+      g->DrawFCircle((*it).ex, (*it).ey, (*it).edx ); 
+      break;
+    default :
+      break;
+    }
+  g->SelForeground(cc);
+  }
+}
+
+
+/* --Methode-- */
+int PIElDrawer::ElAdd(int typ, PIGrCoord x, PIGrCoord  y, PIGrCoord dx, PIGrCoord dy, const char* s, PIColors c)
+{
+DrwEl dre;
+mEn++;
+dre.eid = mEn;  dre.etyp = typ;
+dre.ex = x;   dre.ey = y;
+dre.edx = dx;  dre.edy = dy;
+dre.col = c;
+if (s)  dre.es = s;
+mElist.push_back(dre);
+return(mEn);
+}
+
+/* --Methode-- */
+void  PIElDrawer::ElDel(int id)
+{
+DrwElList::iterator it;
+for (it = mElist.begin(); it != mElist.end(); it++)
+  if ( (*it).eid == id) { mElist.erase(it);   break; }
+return;
+}
+
+/* --Methode-- */
+void  PIElDrawer::ElDelAll()
+{
+mElist.erase(mElist.begin(), mElist.end());
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pidrawer.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pidrawer.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pidrawer.h	(revision 1307)
@@ -0,0 +1,201 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Objets traceur qui peuvent etre attaches a un PIBaseWidget
+//                             R. Ansari  97-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+#ifndef PIDRAWER_H
+#define PIDRAWER_H
+
+#include "pibwdggen.h"
+#include "pigraphuc.h"
+
+#include <list>
+#if defined(__KCC__)
+#include <list.h>
+#endif
+
+enum {
+  kStdAxes     = 0x0001,
+  kBoxAxes     = 0x0002,
+  kTicks       = 0x0004,
+  kIntTicks    = 0x0010,
+  kExtTicks    = 0x0020,
+  kMajTicks    = 0x0040,
+  kMinTicks    = 0x0080,
+  kLabels      = 0x1000,
+  kGridOn      = 0x2000,
+  kAxesDflt    = kStdAxes | kTicks | kLabels,       // Axes trace par defaut
+  kAxesNone    = 0                                  // Pas de trace d axe  
+};
+
+
+class PIDrawer {
+public:
+                     PIDrawer();
+  virtual           ~PIDrawer();
+
+  virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax,
+                               int axrl=kAxeDirSame, int ayud=kAxeDirSame);
+
+  virtual void       DrawAxes(PIGraphicUC* g);
+  virtual void       SetAxesFlags(unsigned int flags=kAxesNone);
+    
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 
+   
+  virtual void       Refresh();      // Recalcule les limites et reaffiche
+  virtual void       UpdateLimits();   // Calcule et change les limites  
+
+  inline double      XMin() const {return xMin;}
+  inline double      XMax() const {return xMax;}
+  inline double      YMin() const {return yMin;}
+  inline double      YMax() const {return yMax;}
+
+  void                GetAxesConfig(int& xa, int& ya);
+  inline unsigned int GetAxesFlags() { return(axesFlags); }
+  
+  inline PIGraphicUC*    GetGraphicUC() { return(mGrUC); }
+
+  inline int          LimitsFixed() const {return limitsFixed;}
+  inline void         FreeLimits() {limitsFixed = 0;}
+
+// Changement des attributs graphiques
+  virtual void       SetColAtt(PIColors fg=PI_NotDefColor, 
+                               PIColors bg=PI_NotDefColor);
+  virtual void       SetLineAtt(PILineAtt lat=PI_NotDefLineAtt);
+  virtual void       SetFontAtt(PIFontSize fsz=PI_NotDefFontSize,
+                                PIFontAtt fat=PI_NotDefFontAtt);
+  virtual void       SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker);
+  virtual void       SetColMapId(CMapId cid=CMAP_OTHER);
+
+  void               SelGraAtt(PIGraphicUC* g);
+
+// Acces aux attributs graphiques
+  inline PIColors    GetFgColAtt()  { return(mFCol); }
+  inline PIColors    GetBgColAtt()  { return(mBCol); }
+  inline PILineAtt   GetLineAtt()   { return(mLAtt); }
+  inline PIFontSize  GetFontSz()    { return(mFSz);  }
+  inline PIFontAtt   GetFontAtt()   { return(mFAtt); }
+  inline int         GetMarkerSz()  { return(mMSz);  }
+  inline PIMarker    GetMarker()    { return(mMrk);  } 
+  inline CMapId      GetColMapId()  { return(mCmapid); }
+
+
+//  --- Methode static ----
+//  Calcul des Distances optimales des subdivisions 
+  static void        BestTicks(double rmin,double rmax,int nticks,double& majt);
+
+//  Les objets/methodes suivants devraient etre protected     
+//  Pb avec acces depuis PIBaseWdgGen (Reza 11/07/97) 
+  virtual  PIGraphicUC*  SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g);
+
+//  Je declare en public a cause de cxx - Reza 11/07/97 
+  struct DrwBWId { int id; PIBaseWdgGen* wdg; };
+  
+protected:
+  friend class PIBaseWdgGen;
+  virtual void       Attach(PIBaseWdgGen*, int id);
+  virtual void       Detach(PIBaseWdgGen*, int id);
+
+  void CalcTicks();
+
+  void DrawHTicks(PIGraphicUC* g, double y, double tickUp, double tickDown, double xBeg, double xStep);
+  void DrawVTicks(PIGraphicUC* g, double x, double tickLeft, double tickRight, double yBeg, double yStep);
+  void DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, int just=0);
+  void DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, int just=0);
+  void DrawGrid(PIGraphicUC* g);
+
+  
+  double xMin, xMax, yMin, yMax;  // Valeurs en unites user
+  int xW0, yW0, xWd, yWd;        // Origine/largeur ds la fenetre de trace
+  bool   aXdir, aYdir;           // Sens des axes horiz, vertical 
+  int aXFlg, aYFlg;
+
+  double xFirstMajTick, xFirstMinTick;
+  double yFirstMajTick, yFirstMinTick;
+  double xMajTickStep, xMinTickStep;
+  double yMajTickStep, yMinTickStep;
+  double xMajTickLen,  xMinTickLen;
+  double yMajTickLen,  yMinTickLen;
+  
+  int limitsFixed;
+  unsigned int axesFlags;
+  
+  PIBaseWdgGen* mBWdg;
+  PIGraphicUC* mGrUC;
+
+  list<DrwBWId>  mBWdgList;
+  bool mDndfg;
+
+//  Gestion d attributs graphiques associes a chaque drawer
+  PIColors           mFCol, mBCol;
+  PILineAtt          mLAtt;
+  PIFontSize         mFSz;
+  PIFontAtt          mFAtt;
+  int                mMSz;
+  PIMarker           mMrk;  
+  CMapId             mCmapid;
+  
+};
+
+
+//  Classe avec gestion d une liste d elements a tracer 
+
+class PIElDrawer : public PIDrawer 
+{
+public:
+  enum { PIDEL_Line = 1, PIDEL_Text = 2,
+         PIDEL_Rect = 3, PIDEL_FRect = 4, 
+         PIDEL_Circ = 5, PIDEL_FCirc = 6 } ; 
+
+                     PIElDrawer();
+  virtual           ~PIElDrawer();
+
+  virtual void	     SetTitles(const char* tt=NULL, const char* tb=NULL);
+  virtual void       SetTitles(string const & tt, string const & tb);
+
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 
+
+  inline int         ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, 
+                               PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL, c) ); }  
+  inline int         ElAddText(PIGrCoord x, PIGrCoord y, const char* s, PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_Text, x, y, 0, 0, s, c) ); }  
+  inline int         ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 
+                               PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL, c) ); }  
+  inline int         ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy,
+                               PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL, c) ); }  
+  inline int         ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_Circ, x, y, r, r, NULL, c) ); }  
+  inline int         ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL, c) ); }  
+
+  void               ElDel(int id);
+  void               ElDelAll();
+
+protected:
+  int                ElAdd(int typ, PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 
+                           const char* s, PIColors c=PI_NotDefColor);
+#ifdef __DECCXX
+public:
+#endif
+  struct DrwEl{
+    int eid, etyp;
+    PIGrCoord ex,ey;
+    PIGrCoord edx,edy;
+    string es;
+    PIColors col;
+  };
+#ifdef __DECCXX
+protected:
+#endif
+  typedef list<DrwEl> DrwElList;
+
+  DrwElList mElist;
+  int mEn;
+
+  string titleT, titleB;       // Titre Haut - Bas
+
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pidrawwin.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pidrawwin.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pidrawwin.cc	(revision 1307)
@@ -0,0 +1,28 @@
+#include "pidrawwin.h"
+
+PIDrawWindow::PIDrawWindow(PIMsgHandler* par, char *nom,
+                               PIWindowKind k, int sx, int sy, int px, int py)
+:PIWindow(par, nom, k, sx, sy, px, py)
+{
+   mDrawWdg = new PIScDrawWdg(this, nom, sx-20, sy-20, 10, 10);
+   mDrawWdg->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);   
+}
+
+
+PIDrawWindow::~PIDrawWindow()
+{
+  delete mDrawWdg;
+}
+
+void
+PIDrawWindow::AddScDrawer(PIDrawer* d, bool ad)
+{
+  mDrawWdg->AddScDrawer(d, ad);
+}
+
+void
+PIDrawWindow::SetAxesFlags(int flags)
+{
+  mDrawWdg->SetAxesFlags(flags);
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pidrawwin.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pidrawwin.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pidrawwin.h	(revision 1307)
@@ -0,0 +1,26 @@
+#ifndef PIDRAWWIN_H
+#define PIDRAWWIN_H
+
+// Une fenetre qui contient un drawwdg...
+
+#include "pisysdep.h"
+#include PIWIN_H
+#include "piscdrawwdg.h"
+
+class PIDrawWindow : public PIWindow {
+public:
+                 PIDrawWindow(PIMsgHandler* par, char *nom, 
+                                PIWindowKind k=PIWK_normal, int sx=10, int sy=10, 
+                                int px=0, int py=0);
+                ~PIDrawWindow();
+                
+ virtual void    AddScDrawer(PIDrawer*, bool ad=false);                
+ virtual void    SetAxesFlags(int flags=-1);
+ inline PIScDrawWdg * DrawWdg() { return mDrawWdg; }
+private:
+  PIScDrawWdg*   mDrawWdg;
+};
+
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pidrwtools.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pidrwtools.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pidrwtools.cc	(revision 1307)
@@ -0,0 +1,472 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Outils de manipulation des PIDrawer  R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+
+#include "pidrwtools.h"
+#include "piscdrawwdg.h"
+#include "pi3ddrw.h"
+
+
+PIDrwTools* PIDrwTools::cwdrwt = NULL;
+PIBaseWdgGen* PIDrwTools::mCurBW = NULL;
+
+/* --Methode-- */
+void PIDrwTools::ShowPIDrwTools() 
+{
+if (cwdrwt == NULL)  cwdrwt = new PIDrwTools(PIApplicationGetApp());
+cwdrwt->Show();
+}
+
+/* --Methode-- */
+void PIDrwTools::SetCurrentBaseWdg(PIBaseWdgGen* cbw)
+{
+if (mCurBW == cbw) return;
+mCurBW = cbw;
+if (cwdrwt)  { 
+  if (mCurBW != NULL)  { 
+    cwdrwt->mNDr = mCurBW->NbDrawers()-1;
+    if (cwdrwt->mNDr < 0)  cwdrwt->mNDr = 0;
+    }
+  else cwdrwt->mNDr = 0;
+  char buff[32];
+  sprintf(buff,"%d", cwdrwt->mNDr);
+  cwdrwt->mNlb->SetLabel(buff);  
+  }
+}
+/* --Methode-- */
+PIBaseWdgGen* PIDrwTools::GetCurrentBaseWdg()
+{
+return(mCurBW);
+}
+
+/* --Methode-- */
+PIDrwTools::PIDrwTools(PIApplication* par)
+: PIWindow((PIMsgHandler*)par, "PIDrawerTools", PIWK_dialog, 240, 240, 150, 150)
+{
+int bsx, bsy, spx, spy;
+
+// On definit la taille a partir de la taille par defaut des composantes 
+// PIApplicationPrefCompSize(bsx, bsy);
+par->PrefCompSz(bsx, bsy);
+spx = bsx/10;
+spy = bsy/4;
+
+int wszx = 5*spx+3.5*bsx; 
+int wszy = (7+3*0.85)*(spy+bsy);
+SetSize(wszx, wszy);
+
+int cpx = spx*2;
+int cpy = spy*2;
+int csx = cpx;
+int csy = cpy;
+mLab[0] = new PILabel(this, "X Min Max", 1.25*bsx, bsy, cpx, cpy);
+cpy += spy+bsy; 
+mLab[1] = new PILabel(this, "Y Min Max", 1.25*bsx, bsy, cpx, cpy);
+mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpy = spy*2;
+cpx += spx+1.25*bsx; 
+mText[0] = new PIText(this, "x_min_max", 2.25*bsx, bsy, cpx, cpy);
+mText[0]->SetText("-1.0  1.0");
+cpy += spy+bsy; 
+mText[1] = new PIText(this, "y_min_max", 2.25*bsx, bsy, cpx, cpy);
+mText[1]->SetText("-1.0  1.0");
+mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpx = spx+0.25*bsx;
+cpy += spy+bsy; 
+mCkb[0] = new PICheckBox(this,"X-RtoL", 2000, bsx, bsy, cpx, cpy);
+cpx += spx+bsx; 
+mCkb[1] = new PICheckBox(this,"Y-UpDn", 2000, bsx, bsy, cpx, cpy);
+cpx += spx+bsx; 
+mCkb[2] = new PICheckBox(this,"Grid", 2000, bsx, bsy, cpx, cpy);
+mCkb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mCkb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mCkb[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpy += spy+bsy; 
+cpx = spx+0.25*bsx;;
+mBut[0] = new PIButton(this, "SetAxes", 2600, bsx*1.5, bsy, cpx, cpy);
+cpx += bsx*1.5+3*spx;
+mBut[1] = new PIButton(this, "AutoLimits", 2700, bsx*1.5, bsy, cpx, cpy);
+mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+int offy = cpy+bsy+spy*2;
+
+//  Option-Menu  Marker, Line, couleur, etc...
+cpx = 2*spx;
+cpy += 3*spy+bsy;
+
+int bsyo = bsy;  
+int spyo = spy; 
+bsy = 0.85*bsy;   spy = 0.85*spy;
+
+mOpt[0] = new PIOptMenu(this, "bwt-opt-0", bsx*1.75, bsy, cpx, cpy);
+mOpt[0]->AppendItem("Def.Col", 100);
+mOpt[0]->AppendItem("Black", 101);
+mOpt[0]->AppendItem("White", 102);
+mOpt[0]->AppendItem("Grey", 103);
+mOpt[0]->AppendItem("Red", 104);
+mOpt[0]->AppendItem("Blue", 105);
+mOpt[0]->AppendItem("Green", 106);
+mOpt[0]->AppendItem("Yellow", 107);
+mOpt[0]->AppendItem("Magenta", 108);
+mOpt[0]->AppendItem("Cyan", 109);
+mOpt[0]->AppendItem("Turquoise", 110);
+mOpt[0]->AppendItem("NavyBlue", 111);
+mOpt[0]->AppendItem("Orange", 112);
+mOpt[0]->AppendItem("SiennaRed", 113);
+mOpt[0]->AppendItem("Purple", 114);
+mOpt[0]->AppendItem("LimeGreen", 115);
+mOpt[0]->AppendItem("Gold", 116);
+mOpt[0]->SetValue(100);
+mOpt[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx += spx+1.75*bsx; 
+mOpt[1] = new PIOptMenu(this, "bwt-opt-1", bsx*1.75, bsy, cpx, cpy);
+mOpt[1]->AppendItem("No.CMap", 200);
+mOpt[1]->AppendItem("Grey32", 201);
+mOpt[1]->AppendItem("GreyInv32", 202);
+mOpt[1]->AppendItem("ColRJ32", 203);
+mOpt[1]->AppendItem("ColBR32", 204);
+mOpt[1]->AppendItem("ColRV32", 205);
+mOpt[1]->AppendItem("Grey128", 206);
+mOpt[1]->AppendItem("GreyInv128", 207);
+mOpt[1]->AppendItem("ColRJ128", 208);
+mOpt[1]->AppendItem("ColBR128", 209);
+mOpt[1]->AppendItem("Col16", 210);
+mOpt[1]->SetValue(200);
+mOpt[1]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+
+cpx = 2*spx;
+cpy += spy+bsy;
+mOpt[2] = new PIOptMenu(this, "bwt-opt-2", bsx*1.75, bsy, cpx, cpy);
+mOpt[2]->AppendItem("Def.Mrk", 300);
+mOpt[2]->AppendItem("Mrk Dot(.)", 301);
+mOpt[2]->AppendItem("Mrk Plus(+)", 302);
+mOpt[2]->AppendItem("Mrk Cross(x)", 303);
+mOpt[2]->AppendItem("Mrk Circle", 304);
+mOpt[2]->AppendItem("Mrk FCircle", 305);
+mOpt[2]->AppendItem("Mrk Box", 306);
+mOpt[2]->AppendItem("Mrk FBox", 307);
+mOpt[2]->AppendItem("Mrk Triangle", 308);
+mOpt[2]->AppendItem("Mrk FTriangle", 309);
+mOpt[2]->AppendItem("Mrk Star", 310);
+mOpt[2]->AppendItem("Mrk FStar", 311);
+mOpt[2]->SetValue(300);
+mOpt[2]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx += spx+1.75*bsx; 
+mOpt[3] = new PIOptMenu(this, "bwt-opt-3", bsx*1.75, bsy, cpx, cpy);
+mOpt[3]->AppendItem("Mrk 1 pt", 401);
+mOpt[3]->AppendItem("Mrk 3 pt", 403);
+mOpt[3]->AppendItem("Mrk 5 pt", 405);
+mOpt[3]->AppendItem("Mrk 7 pt", 407);
+mOpt[3]->AppendItem("Mrk 9 pt", 409);
+mOpt[3]->AppendItem("Mrk 11 pt", 411);
+mOpt[3]->AppendItem("Mrk 13 pt", 413);
+mOpt[3]->AppendItem("Mrk 15 pt", 415);
+mOpt[3]->SetValue(405);
+mOpt[3]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx = 2*spx;
+cpy += spy+bsy;
+mOpt[4] = new PIOptMenu(this, "bwt-opt-4", bsx*1.75, bsy, cpx, cpy);
+mOpt[4]->AppendItem("Def.Font", 500);
+mOpt[4]->AppendItem("Normal-Font", 511);
+mOpt[4]->AppendItem("Bold", 512);
+mOpt[4]->AppendItem("Ital", 513);
+mOpt[4]->AppendItem("Small-Font", 521);
+mOpt[4]->AppendItem("Small-Bold", 522);
+mOpt[4]->AppendItem("Small-Ital", 523);
+mOpt[4]->AppendItem("Big-Font", 531);
+mOpt[4]->AppendItem("Big-Bold", 532);
+mOpt[4]->AppendItem("Big-Ital", 533);
+mOpt[4]->AppendItem("Huge-Font", 541);
+mOpt[4]->AppendItem("Huge-Bold", 542);
+mOpt[4]->AppendItem("Huge-Ital", 543);
+mOpt[4]->SetValue(500);
+mOpt[4]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx += spx+1.75*bsx; 
+mOpt[5] = new PIOptMenu(this, "bwt-opt-5", bsx*1.75, bsy, cpx, cpy);
+mOpt[5]->AppendItem("Def.Line", 600);
+mOpt[5]->AppendItem("Thin-Line", 601);
+mOpt[5]->AppendItem("Normal-Line", 602);
+mOpt[5]->AppendItem("Thick-Line", 603);
+mOpt[5]->AppendItem("ThinDashed", 604);
+mOpt[5]->AppendItem("Dashed-Line", 605);
+mOpt[5]->AppendItem("ThickDashed", 606);
+mOpt[5]->AppendItem("ThinDotted", 607);
+mOpt[5]->AppendItem("Dotted-Line", 608);
+mOpt[5]->AppendItem("ThickDotted", 609);
+mOpt[5]->SetValue(600);
+mOpt[5]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx = 2*spx;
+cpy += spy+bsyo;
+bsy = bsyo; spy = spyo;
+mButdr[0] = new PIButton(this, "-", 3501, bsy, bsy, cpx, cpy);
+cpx += bsy+0.25*spy;
+mNlb = new PILabel(this,"NumDr", bsy, bsy, cpx, cpy);
+mNlb->SetLabel("0");
+mNDr = 0;
+cpx += bsy+0.25*spy;
+mButdr[1] = new PIButton(this, "+", 3502, bsy, bsy, cpx, cpy);
+mButdr[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+mButdr[1]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+mNlb->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx = wszx-1.7*bsx-3*spx;
+mButcf[0] = new PIButton(this, "GetAtt", 2800, 0.85*bsx, bsy, cpx, cpy);
+cpx += 0.85*bsx+spx;
+mButcf[1] = new PIButton(this, "SetAtt", 2900, 0.85*bsx, bsy, cpx, cpy);
+mButcf[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+mButcf[1]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx = spx+0.25*bsx;;
+cpy += spy+bsy;
+mButcf[2] = new PIButton(this, "Refresh", 3000, bsx*1.5, bsy, cpx, cpy);
+mButcf[2]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+cpx += bsx*1.5+3*spx;
+mButcf[3] = new PIButton(this, "Dismiss", 3777, bsx*1.5, bsy, cpx, cpy);
+mButcf[2]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+mButcf[3]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cwdrwt = this;
+
+}
+
+/* --Methode-- */
+PIDrwTools::~PIDrwTools()
+{
+if (cwdrwt == this)  cwdrwt = NULL;
+int i;
+for(i=0; i<2; i++)
+  {
+  delete mLab[i];
+  delete mBut[i];
+  delete mText[i];
+  delete mButcf[i];
+  }
+
+for(i=0; i<3; i++) { delete mCkb[i];   delete mButcf[i]; }
+delete mBut[2];
+for(i=0; i<6; i++)  delete mOpt[i];
+delete mNlb;
+}
+
+//  Declaration des differents attributs graphiques 
+static PIColors cols[17] = { PI_NotDefColor, 
+                     PI_Black, PI_White, PI_Grey, 
+                     PI_Red, PI_Blue, PI_Green, 
+                     PI_Yellow, PI_Magenta, 
+                     PI_Cyan , PI_Turquoise, PI_NavyBlue, 
+                     PI_Orange, PI_SiennaRed, PI_Purple, 
+                     PI_LimeGreen, PI_Gold };
+
+static PIMarker mrk[12] = { PI_NotDefMarker, PI_DotMarker, 
+                            PI_PlusMarker, PI_CrossMarker,
+                            PI_CircleMarker, PI_FCircleMarker,
+                            PI_BoxMarker, PI_FBoxMarker,
+                            PI_TriangleMarker, PI_FTriangleMarker,
+                            PI_StarMarker, PI_FStarMarker };
+static PILineAtt line[10] = { PI_NotDefLineAtt, PI_ThinLine, PI_NormalLine, PI_ThickLine, 
+                              PI_ThinDashedLine, PI_DashedLine, PI_ThickDashedLine, 
+                              PI_ThinDottedLine, PI_DottedLine, PI_ThickDottedLine };
+
+static PIFontAtt fntatt[4] = { PI_NotDefFontAtt, PI_RomanFont, PI_BoldFont, PI_ItalicFont };
+static PIFontSize fntsz[5] = { PI_NotDefFontSize, PI_NormalSizeFont, PI_SmallSizeFont, 
+                               PI_BigSizeFont, PI_HugeSizeFont };
+static CMapId cmap[11] = {  CMAP_OTHER, CMAP_GREY32, CMAP_GREYINV32,
+                            CMAP_COLRJ32, CMAP_COLBR32, CMAP_COLRV32,  
+                            CMAP_GREY128, CMAP_GREYINV128, CMAP_COLRJ128, CMAP_COLBR128, CMAP_COL16 };
+
+/* --Methode-- */
+void PIDrwTools::Show()
+{
+PIWindow::Show();
+char buff[92]; 
+mNDr = 0;
+
+if (mCurBW != NULL)  { 
+  mNDr = mCurBW->NbDrawers()-1;
+  if (mNDr < 0)  mNDr = 0;
+  }
+
+UpdateAttFromDrawer();
+
+mCkb[0]->SetState(false);
+mCkb[1]->SetState(false);
+mCkb[2]->SetState(false);
+
+if ((mCurBW != NULL) && ( mCurBW->kind() == PIScDrawWdg::ClassId ) ) {
+  PIScDrawWdg* scd = ( PIScDrawWdg*)mCurBW;
+  sprintf(buff, "%g  %g", scd->XMin(), scd->XMax());
+  mText[0]->SetText(buff);
+  sprintf(buff, "%g  %g", scd->YMin(), scd->YMax());
+  mText[1]->SetText(buff);
+  int xa, ya;
+  scd->GetAxesConfig(xa, ya);
+  if (xa & kAxeDirRtoL) mCkb[0]->SetState(true);
+  if (ya & kAxeDirUpDown)  mCkb[1]->SetState(true);
+  if (scd->GetAxesFlags() & kGridOn) mCkb[2]->SetState(true);
+  }
+else {
+  mText[0]->SetText("-1.0  1.0");
+  mText[1]->SetText("-1.0  1.0");
+  }
+sprintf(buff, "%d", mNDr);
+mNlb->SetLabel(buff);
+
+
+
+return;
+}
+
+/* --Methode-- */
+void PIDrwTools::UpdateAttFromDrawer()
+{
+
+PIDrawer* dr = NULL;
+
+mOpt[0]->SetValue(100);
+mOpt[1]->SetValue(200);
+mOpt[2]->SetValue(300);
+mOpt[3]->SetValue(405);
+mOpt[4]->SetValue(500);
+mOpt[5]->SetValue(600);
+
+if ( (mCurBW != NULL) && (mCurBW->NbDrawers() > 0) ) 
+  dr = mCurBW->GetDrawer(mNDr);
+
+if (!dr)  return;
+int jj,kk;
+PIColors fc = dr->GetFgColAtt();
+for(kk=0; kk<17; kk++) 
+  if (fc == cols[kk])  { mOpt[0]->SetValue(100+kk);  break; }    
+CMapId cmi = dr->GetColMapId();
+for(kk=0; kk<11; kk++)
+  if (cmi == cmap[kk]) { mOpt[1]->SetValue(200+kk);  break; }  
+PIMarker mk = dr->GetMarker();   
+for(kk=0; kk<12; kk++) 
+  if (mk == mrk[kk])   { mOpt[2]->SetValue(300+kk);  break; }
+kk = dr->GetMarkerSz();
+if (kk < 1)  kk = 1;
+if (kk > 15) kk = 15;
+if (kk%2 == 0) kk++;
+mOpt[3]->SetValue(400+kk);
+PIFontAtt fat = dr->GetFontAtt();
+PIFontSize fsz = dr->GetFontSz();
+for(kk=0; kk<4; kk++)
+  if (fat ==  fntatt[kk]) break;
+for(jj=0; jj<5; jj++) 
+  if (fsz == fntsz[jj])  break;
+
+if (kk >= 4) kk = 3;
+if (jj >= 5) jj = 4;
+mOpt[4]->SetValue(500+jj*10+kk);
+PILineAtt lat = dr->GetLineAtt();
+for(kk=0; kk<10; kk++)
+  if (lat == line[kk])   { mOpt[5]->SetValue(600+kk);  break; }
+
+return;
+}
+
+/* --Methode-- */
+void PIDrwTools::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+msg = UserMsg(msg);
+if (msg == 3777)  { Hide(); return; }
+
+if (mCurBW == NULL)   return;
+
+char strg[64];
+double xmin, xmax, ymin, ymax;
+int axrl = kAxeDirLtoR;
+int ayud = kAxeDirDownUp;
+int k, kk, kkk;
+
+switch (msg) {
+
+  case 2600 :
+    sscanf(mText[0]->GetText().c_str(), "%lg %lg" , &xmin, &xmax);
+    sscanf(mText[1]->GetText().c_str(), "%lg %lg" , &ymin, &ymax);
+    if (mCkb[0]->GetState())  axrl = kAxeDirRtoL ;
+    if (mCkb[1]->GetState())  ayud = kAxeDirUpDown;
+    if ( mCurBW->kind() == PIScDrawWdg::ClassId ) { 
+      ((PIScDrawWdg*)mCurBW)->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud);
+      unsigned int flags = ((PIScDrawWdg*)mCurBW)->GetAxesFlags();
+      if (mCkb[2]->GetState()) ((PIScDrawWdg*)mCurBW)->SetAxesFlags(flags | kGridOn);
+      else  ((PIScDrawWdg*)mCurBW)->SetAxesFlags(flags & ~kGridOn);
+      }
+    else mCurBW->SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);
+    mCurBW->Refresh();
+    break;
+
+  case 2700 :
+    if ( mCurBW->kind() == PIScDrawWdg::ClassId ) ((PIScDrawWdg*)mCurBW)->UpdateLimits();
+    else if ( mCurBW->kind() == PIDraw3DWdg::ClassId) ((PIDraw3DWdg*)mCurBW)->Update3DView();
+    break;
+
+  case 2800 :
+    UpdateAttFromDrawer();
+    break;
+
+  case 2900 :
+  case 3000 :
+    {
+    PIDrawer* drw = mCurBW->GetDrawer(mNDr);
+    if (drw == NULL)  return;
+    k = mOpt[0]->GetValue()-100;
+    if ( (k < 0) || (k > 16) )  k = 0;
+    drw->SetColAtt(cols[k]);
+    k = mOpt[1]->GetValue()-200;
+    if ( (k < 0) || (k > 10) )  k = 0;
+    drw->SetColMapId(cmap[k]);
+    k =  mOpt[2]->GetValue()-300;
+    if ( (k < 0) || (k > 11) )  k = 0;
+    kk =  mOpt[3]->GetValue()-400;
+    if ( (kk < 1) || (kk > 27) )  kk = 1;
+    drw->SetMarkerAtt(kk, mrk[k]);
+    k =  (mOpt[4]->GetValue()-500);
+    kk = k/10;   kkk = k%10;
+    drw->SetFontAtt(fntsz[kk], fntatt[kkk]);
+    k =  mOpt[5]->GetValue()-600;
+    if ( (k < 0) || (k > 9) )  k = 0;
+    drw->SetLineAtt(line[k]);
+    if (msg == 2900) drw->Refresh();
+    else mCurBW->Refresh();
+    }
+    break;        
+
+  case 3501 :
+  case 3502 :
+    if (msg == 3501) {  mNDr--;   if (mNDr < 0)  mNDr = 0; }
+    else { mNDr++;  if (mNDr >= mCurBW->NbDrawers())  mNDr--; }
+    sprintf(strg, "%d", mNDr);
+    mNlb->SetLabel(strg);
+    /*   On ne change pas les options choisies   Reza+cmv 2/10/98  
+    mOpt[0]->SetValue(100);
+    mOpt[1]->SetValue(200);
+    mOpt[2]->SetValue(300);
+    mOpt[3]->SetValue(405);
+    mOpt[4]->SetValue(500);
+    mOpt[5]->SetValue(600);
+    */
+    break;
+
+  default :
+    break;
+  }
+
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pidrwtools.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pidrwtools.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pidrwtools.h	(revision 1307)
@@ -0,0 +1,53 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Outils de manipulation des PIDrawer  R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIDRWTOOLS_H_SEEN
+#define PIDRWTOOLS_H_SEEN
+
+#include "pisysdep.h"
+#include PISTDWDG_H
+#include PIOPTMENU_H
+#include PIWIN_H
+#include PIAPP_H
+#include "pibwdggen.h"
+
+// --------- fenetre de dialogue pour modifs axes et options des Drawers ----------
+// --------------------------------------------------------------------------------
+
+
+class PIDrwTools : public PIWindow 
+{
+public :
+  PIDrwTools(PIApplication* par);
+  ~PIDrwTools();
+  virtual void  Show();
+
+  static PIDrwTools* curlutw;
+  static void ShowPIDrwTools();
+  static void SetCurrentBaseWdg(PIBaseWdgGen* cbw);
+  static PIBaseWdgGen* GetCurrentBaseWdg();
+
+protected:
+  virtual void  UpdateAttFromDrawer();
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+// Pour changer les axes
+  PILabel* mLab[2];
+  PIButton* mBut[2];
+  PIText* mText[2];
+  PICheckBox* mCkb[3];
+// Pour couleur, fontes, etc 
+  PIOptMenu* mOpt[6];
+  PILabel* mNlb;
+  PIButton* mButdr[2];
+  PIButton* mButcf[4];
+  int mNDr;
+  int mtyp, msz;
+//
+  static PIBaseWdgGen* mCurBW;
+  static PIDrwTools* cwdrwt;
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pierrdisp.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pierrdisp.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pierrdisp.cc	(revision 1307)
@@ -0,0 +1,105 @@
+#include "pierrdisp.h"
+#include "utils.h"
+
+
+PIErrorBox::PIErrorBox(PIContainerGen* par, int sx, int sy,
+	     int px, int py)
+: PIBaseWdg(par, "Error Message", sx, sy, px, py)
+{
+  currErrText = "";
+  state = 0;
+}
+
+PIErrorBox::~PIErrorBox()
+{
+}
+
+void
+PIErrorBox::Draw()
+{
+  if (currErrText == "") {
+    SelBackground();
+    EraseWindow();
+  } else {
+    switch(state) {
+    case 0:
+      EraseWindow();
+      SelForeground(PI_Red);
+      DrawFBox(0,0,1000,1000);
+      SelForeground(PI_Black);
+      break;
+    default:
+      SelBackground();
+      SelForeground();
+    }
+    SelFont(PI_BigSizeFont, PI_BoldFont);
+    DrawString(20,30,(char*)currErrText.c_str());
+  }
+}
+
+void
+PIErrorBox::Cycle()
+{
+  state = (state + 1) % 2;
+}
+
+
+
+
+PIErrorDisplay::PIErrorDisplay(PIContainerGen* par, int sx, int sy,
+			       int px, int py)
+: PIContainer(par, "Error Display", sx, sy, px, py), PIPeriodX(1)
+{
+  currErrId = 0;
+
+  errorBox  = new PIErrorBox(this, 150, 80, 0, 0);
+  ackButton = new PIButton(this, "OK", 5000, 40, 20, 155, 20);
+  updButton = new PIButton(this, "Upd", 5001, 40, 20, 155, 50);
+  Start();
+}
+
+PIErrorDisplay::~PIErrorDisplay()
+{
+  delete updButton;
+  delete ackButton;
+  delete errorBox;
+}
+
+void
+PIErrorDisplay::Process(PIMessage msg, PIMsgHandler *sender, void *data)
+{
+msg = UserMsg(msg);
+  switch(msg) {
+  case 5000:
+    // On valide
+    if (currErrId) 
+      AcqAckError(currErrId);
+    UpdData();
+    break;
+  case 5001:
+    UpdData();
+    break;
+    
+  default:
+    PIContainer::Process(msg, sender, data);
+  }
+}
+
+void
+PIErrorDisplay::UpdData()
+{
+  currErrId = 0;
+  char tache[80];
+  char msg[200];
+  int code;
+  int severite;
+  int rc = AcqGetNextError(&currErrId, tache, &code, &severite, msg);
+  if (rc)
+    errorBox->SetText("");
+  else
+    errorBox->SetText(string(tache) + " : (" + itos(code) + "/" +
+		     itos(severite) +") " + msg);
+  errorBox->Draw();
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/pierrdisp.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pierrdisp.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pierrdisp.h	(revision 1307)
@@ -0,0 +1,48 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef PIERRDISP_H_SEEN
+#define PIERRDISP_H_SEEN
+
+#include "pisysdep.h"
+#include PIBWDG_H
+#include PISTDWDG_H
+#include PICONT_H
+#include PIPERIOD_H
+
+#include "errorhandlerc.h"
+
+class PIErrorBox : public PIBaseWdg {
+public:
+  PIErrorBox(PIContainerGen* par, int sx=100, int sy = 50,
+	     int px=0, int py=0);
+  ~PIErrorBox();
+
+  void Draw();
+  
+  void SetText(string const& txt) {currErrText = txt;}
+  void Cycle();
+
+protected:
+  string currErrText;
+  int           state;     // Cycle decoratif en couleurs violentes...  
+};
+
+class PIErrorDisplay : public PIContainer, public PIPeriodic {
+public:
+  
+  PIErrorDisplay(PIContainerGen* par, int sx=150, int sy=50,
+		 int px=0, int py=0);
+  virtual      ~PIErrorDisplay();
+  
+  void          UpdData();
+  void          Process(PIMessage msg, PIMsgHandler *sender, void *data);
+  void          DoPeriodic() {UpdData();}
+protected:
+  int           currErrId;
+
+  PIErrorBox*   errorBox;
+  PIButton*     ackButton;
+  PIButton*     updButton;   // TEMPORAIRE
+};
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pievthandler.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pievthandler.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pievthandler.cc	(revision 1307)
@@ -0,0 +1,141 @@
+// Module PI : Peida Interactive      PIEventHandler
+// Classe Gestionnaire d'evenements (Ecran/Clavier/Souris)
+//                                    R.Ansari  12/98 
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pievthandler.h"
+
+//++
+// Class	PIEventHandler
+// Lib		PI
+// include	pievthandler.h
+//
+//	Classe fournissant les services nécessaires à la création de
+//	gestionnaire d'événements écran-clavier-souris.
+//--
+//++
+// Links	Parents
+// PIMsgHandler
+//--
+//++
+// Links	Voir aussi
+// PIWdg
+//--
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIEventHandler(PIMsgHandler* par=NULL, PIMessage msg = 0)
+//	Constructeur. "par" est le gestionnaire de message parent, et
+//	"msg" le message associé.
+//
+// void	  SetMsg(PIMessage msg = 0)
+//	Modification du message associé.
+// PIMessage  Msg() 
+//	Renvoie le message associé.
+//--
+
+
+
+/* --Methode-- */
+PIEventHandler::PIEventHandler(PIMsgHandler* par, PIMessage msg)
+	: PIMsgHandler(par)
+{
+SetMsg(msg);
+curwdg = NULL;
+event = PIEvent_None;
+posx = posy = 0;
+key = 0;
+keymod = PIKM_Blank;
+evttime = 0;
+}
+
+/* --Methode-- */
+PIEventHandler::~PIEventHandler()
+{
+}
+
+//++
+// Titre	Traitement des événements
+//--
+//++
+// void Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+//	Méthode spécialisée appelée pour retracer le contenu 
+//	d'une partie de l'objet "PIWdg" auquel est attaché l'objet
+//	"PIEventHandler". "PIGraphic* g" fournit les services de 
+//	tracé graphique et "(x0, y0), "dx * dy" définissent le 
+//	rectangle à retracer. L'implementation par défaut ne 
+//	fait rien.
+//
+// void ProcessEvent()
+//	Cette méthode est appelée pour le traitement de tous 
+//	les autres types d'événements. L'implementation par défaut 
+//	ne fait rien. 
+//--
+
+
+/* --Methode-- */
+void PIEventHandler::Draw(PIGraphic*, int, int, int, int)
+{
+return;
+}
+
+/* --Methode-- */
+void PIEventHandler::ProcessEvent()
+{
+return;
+}
+
+/* --Methode-- */
+void PIEventHandler::SetCurrentWdg(PIWdg* wdg)
+{
+curwdg = wdg;
+}
+
+
+//++
+// Titre	Description de l'événement
+//--
+//++
+// PIWdg*  CurrentWdg()
+//	L'objet "PIWdg" source de l'événement.
+// PIEventMask EventType()
+//	Type de l'événement :
+//|	PIEvent_Draw 
+//|	PIEvent_Resize , PIEvent_Enter , PIEvent_Leave
+//|	PIEvent_ButxPress , PIEvent_ButxRelease  (x=1,2,3)
+//|	PIEvent_PtrMove , PIEvent_PtrxMove (x=1,2,3)
+//|	PIEvent_Keyboard
+//
+// int GetPosX()
+//	Position X de la souris
+// int GetPosY()
+//	Position Y de la souris
+// int GetKey()
+//	Code touche du clavier. Code ASCII des caractères ordinaires, ou l'une des constantes:
+//|	PIK_Return , PIK_Enter
+//|	PIK_BackSpace , PIK_Delete
+//|	PIK_Tab , PIK_Escape
+//|	PIK_Up , PIK_Down
+//|	PIK_Right , PIK_Left
+//|	PIK_Previous , PIK_Next
+//
+// PIKeyModifier GetKeyMod()
+//	Code d'une des touches <Shift>, <Alt>, <Cntl> si appuyée en même temps.
+//|	PIKM_Blank , PIKM_Shift , PIKM_Alt , PIKM_Cntl
+//
+// unsigned long GetEventTime()
+//	Temps de l'action en millisecondes.
+//--
+
+/* --Methode-- */
+void PIEventHandler::SetEventInfo(PIEventMask evt, int px, int py, 
+                                  int k, PIKeyModifier km, unsigned long tm)
+{
+event = evt;
+posx = px; posy = py;
+key = k;
+keymod = km;
+evttime = tm;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pievthandler.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pievthandler.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pievthandler.h	(revision 1307)
@@ -0,0 +1,85 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIEventHandler
+// Classe Gestionnaire d'evenements (Ecran/Clavier/Souris) 
+//                                    R.Ansari  12/98 
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIEVTHANDLER_H_SEEN
+#define PIEVTHANDLER_H_SEEN
+
+#include "pisysdep.h"
+#include "pimsghandler.h"
+#include PIWDG_H
+#include PIGRAPHIC_H
+
+
+// ....  KeyModifier (<Shift>, <Control> , <Alt>) and special key values ....
+enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ; 
+
+enum PIKeyValues { PIK_Return = 0xFF0D, PIK_Enter = 0xFF8D , 
+                   PIK_BackSpace = 0xFF08, PIK_Delete = 0xFFFF,
+                   PIK_Tab = 0xFF09, PIK_Escape = 0xFF1B, 
+                   PIK_Up = 0xFF52, PIK_Down = 0xFF54, 
+                   PIK_Right = 0xFF53, PIK_Left = 0xFF51,
+                   PIK_Previous = 0xFF55, PIK_Next = 0xFF56  } ; 
+
+// .......... Event Mask values ..........
+enum PIEventMask {
+     PIEvent_None	  =  0,                  //
+     PIEvent_Draw         =  1 << 0,             // ReDraw window
+     PIEvent_Resize       =  1 << 1,             // window resized
+     PIEvent_Enter        =  1 << 2,             // Pointer entered window
+     PIEvent_Leave        =  1 << 3,             // Pointer leaved window
+     PIEvent_But1Press    =  1 << 4,             // Button-1 Press
+     PIEvent_But1Release  =  1 << 5,             // Button-1 Release
+     PIEvent_But2Press    =  1 << 6,             // Button-2 Press
+     PIEvent_But2Release  =  1 << 7,             // Button-2 Release
+     PIEvent_But3Press    =  1 << 8,             // Button-3 Press
+     PIEvent_But3Release  =  1 << 9,             // Button-3 Release
+     PIEvent_PtrMove      =  1 << 14,            // Pointer moved
+     PIEvent_Ptr1Move     =  1 << 15,            // Pointer moved with button-1
+     PIEvent_Ptr2Move     =  1 << 16,            // Pointer moved with button-2
+     PIEvent_Ptr3Move     =  1 << 17,            // Pointer moved with button-3
+     PIEvent_Keyboard     =  1 << 20             // key-pressed Keyboard
+} ;
+
+
+// -----------------  Class PIEventHandler  -----------------------
+class PIEventHandler : public PIMsgHandler
+{
+public:
+			PIEventHandler(PIMsgHandler* par=NULL, PIMessage msg = 0);
+			~PIEventHandler();
+
+  inline  void		SetMsg(PIMessage msg = 0) { myMsg=msg; }
+  inline  PIMessage	Msg() { return (myMsg); }
+
+  virtual void		Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  virtual void		ProcessEvent();
+
+  virtual  void		SetCurrentWdg(PIWdg* wdg);
+  inline  PIWdg*	CurrentWdg() { return(curwdg); }
+
+  virtual void		SetEventInfo(PIEventMask evt, int px, int py, 
+                                     int k, PIKeyModifier km, unsigned long tm);
+  inline  PIEventMask	EventType() { return(event); }
+  inline  int		GetPosX() { return(posx); }  
+  inline  int		GetPosY() { return(posy); }  
+  inline  int		GetKey() { return(key); }
+  inline  PIKeyModifier GetKeyMod() { return(keymod); }
+  inline  unsigned long GetEventTime() { return(evttime); }
+
+protected:
+  PIMessage	myMsg;	       // associated user message
+
+  PIWdg*	curwdg;        // Current PIWdg, where event originated
+  PIEventMask	event;	       // event type
+  int		posx, posy;    // Pointer Position  
+  int		key;	       // Pressed key-code 
+  PIKeyModifier keymod;	       // Pressed key-modifier (shift, Cntl, ...)
+  unsigned long evttime;       // Event-time in ms  
+};
+
+
+
+#endif  
Index: /tags/DPC_V0/Poubelle/PI/pifilechogen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pifilechogen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pifilechogen.cc	(revision 1307)
@@ -0,0 +1,73 @@
+// Module PI : Peida Interactive     PIFileChooser
+// Selecteur de fichier                    96-97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pifilechogen.h"
+
+
+/************* PIFileChooserGen ************/
+
+//++
+// Class	PIFileChooser
+// Lib		PI
+// include	pifilechogen.h
+//
+//	Composant graphique de type sélecteur de fichier, permettant de choisir 
+//	un nom de fichier et de naviguer dans les répertoires.
+//	"PIFileChooserGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIFileChooser" déclarée dans le fichier
+//	entête "PIFILECHO_H". Le message associé à l'objet est envoyé completé 
+//	avec "PIMsg_OK" si un nom de fichier a été choisi. la variable "data"
+//	est alors un pointeur sur une chaîne de caractères ("char *"), 
+//	contenant le nom complet du fichier. Si aucun fichier n'a été 
+//	sélectionné, le message de l'objet est completé avec "PIMsg_Cancel" et 
+//	le "datä contient le pointeur "NULL".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Titre	Constructeur et méthodes
+//--
+//++
+// PIFileChooser(PIMsgHandler* par, char* nom, PIMessage msg)
+//	Création d'un objet sélecteur de fichier, avec le message "msg".
+// void  Show()
+//	Affiche la fenêtre de sélection des fichiers
+// void  AcceptNewFile(bool acc)
+//	Active ("acc=true") ou désactive la possibilité de spécifier
+//	un nouveau fichier.
+// void  SetPath(string const&)
+//	Définit le chemin d'accès (répertoire) choisi par défaut
+// void  SetFileName(string const&) 
+//	Nom de fichier sélectionné par défaut
+// string  GetPath()
+//	Retourne le chemin d'accès. NON IMPLEMENTE EN X/MOTIF (06/98)
+// string  GetFileName()
+//	Retourne le nom complet du fichier sélectionné. 
+//--
+
+
+PIFileChooserGen::PIFileChooserGen(PIMsgHandler* par, char* nom, PIMessage msg)
+: PIWdg(NULL, nom)
+{
+SetMsg(msg);
+SetMsgParent(par);
+}
+
+PIFileChooserGen::~PIFileChooserGen()
+{}
+
+void PIFileChooserGen::Show()
+{
+return;
+}
+
+
+void PIFileChooserGen::AcceptNewFile(bool)
+{
+return;
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/pifilechogen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pifilechogen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pifilechogen.h	(revision 1307)
@@ -0,0 +1,34 @@
+#ifndef PIFILCHOGEN_H_SEEN
+#define PIFILCHOGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+class PIFileChooserGen : public PIWdg {
+public:
+  enum {ClassId = 2100};
+
+                     PIFileChooserGen(PIMsgHandler* par, char* nom, PIMessage msg);
+  virtual            ~PIFileChooserGen();
+
+  virtual void       Show();
+
+  virtual void       AcceptNewFile(bool acc);
+  virtual void       SetPath(string const&) = 0;
+  virtual void       SetFileName(string const&) = 0;
+
+  virtual string     GetPath() = 0;
+  virtual string     GetFileName() = 0;
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+
+#endif
+
+
+
+
Index: /tags/DPC_V0/Poubelle/PI/pifilechomac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pifilechomac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pifilechomac.cc	(revision 1307)
@@ -0,0 +1,123 @@
+#include "pifilechomac.h"
+
+string PathNameFromDirID(long dirID, short vRefNum);
+
+string PIGetFileName(string dir);
+string PIGetExistingFileName(string dir);
+
+string PIGetFileName(string dir)
+{
+  StandardFileReply reply;
+  
+  
+  string fName;
+  int i = dir.rfind(':');
+  if (i == string::npos)
+    fName = dir;
+  else if (i == dir.length())
+    fName = "";
+  else
+    fName = dir.substr(i+1);
+    
+  LStr255 defaultName(fName.c_str());
+  
+  StandardPutFile("\pSave as:",defaultName,&reply);
+  
+  if (!reply.sfGood) return "";
+  
+  string directory = PathNameFromDirID(reply.sfFile.parID,reply.sfFile.vRefNum);
+  p2cstr(reply.sfFile.name);
+  
+//  return directory + '/' + (char*)reply.sfFile.name;
+  return directory + ':' + (char*)reply.sfFile.name;
+}
+
+string PIGetExistingFileName(string /*dir*/)
+{
+  StandardFileReply reply;
+  SFTypeList typeList;
+  
+  StandardGetFile(NULL,-1,typeList,&reply);
+  
+  if (!reply.sfGood) return "";
+  
+  string directory = PathNameFromDirID(reply.sfFile.parID,reply.sfFile.vRefNum);
+  p2cstr(reply.sfFile.name);
+  
+//  return directory + '/' + (char*)reply.sfFile.name;
+  return directory + ':' + (char*)reply.sfFile.name;
+}
+
+
+string PathNameFromDirID(long dirID, short vRefNum)
+{
+	DirInfo 	block;
+	Str255		directoryName;
+	OSErr		err;
+
+	string fullPathName = "";
+
+	block.ioDrParID = dirID;
+	block.ioNamePtr = directoryName;
+	do {
+			block.ioVRefNum = vRefNum;
+			block.ioFDirIndex = -1;
+			block.ioDrDirID = block.ioDrParID;
+			err = PBGetCatInfoSync(CInfoPBPtr(&block));
+			p2cstr(directoryName);
+			if (fullPathName != "") fullPathName = ':' + fullPathName;
+			fullPathName =  ((char*)directoryName + fullPathName);
+//			fullPathName = '/' + ((char*)directoryName + fullPathName);
+	} while (block.ioDrDirID != 2);
+	return fullPathName;
+}
+
+
+PIFileChooserMac::PIFileChooserMac(PIMsgHandler* par, char* nom, PIMessage msg)
+: PIFileChooserGen(par, nom, msg)
+{
+  mAccNew = false;
+  mFileName = "";
+}
+
+PIFileChooserMac::~PIFileChooserMac()
+{}
+
+void
+PIFileChooserMac::Show()
+{
+  if (mAccNew)
+    mFileName = PIGetFileName("");
+  else
+    mFileName = PIGetExistingFileName("");
+
+// Envoyer un message....
+  if (mFileName == "")
+    Send(Msg(), PIMsg_Cancel, NULL);
+  else
+    Send(Msg(), PIMsg_OK, (void *) (GetFileName().c_str()));
+}
+
+void
+PIFileChooserMac::AcceptNewFile(bool acc)
+{
+  mAccNew = acc;
+}
+
+void
+PIFileChooserMac::SetPath(string const& /*path*/) {}
+void
+PIFileChooserMac::SetFileName(string const& /*fname*/) {}
+
+string
+PIFileChooserMac::GetPath()
+{
+  return "";
+}
+
+string
+PIFileChooserMac::GetFileName()
+{
+  return mFileName;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pifilechomac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pifilechomac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pifilechomac.h	(revision 1307)
@@ -0,0 +1,33 @@
+#ifndef PIFILECHOMAC_H_SEEN
+#define PIFILECHOMAC_H_SEEN
+
+#include <string>
+#include "pisysdep.h"
+#include "pifilechogen.h"
+
+class PIFileChooserMac : public PIFileChooserGen {
+public:
+
+                   PIFileChooserMac(PIMsgHandler* par, char* nom, PIMessage msg);
+  virtual          ~PIFileChooserMac();
+
+  virtual void     Show();
+
+  virtual void     AcceptNewFile(bool acc);
+  virtual void     SetPath(string const& path);
+  virtual void     SetFileName(string const& fname);
+
+  virtual string   GetPath();
+  virtual string   GetFileName();
+
+protected:
+  bool             mAccNew;
+  string           mFileName;
+};
+
+typedef PIFileChooserMac     PIFileChooser ;
+
+#define FILESEP ':'
+
+#endif
+
Index: /tags/DPC_V0/Poubelle/PI/pifilechox.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pifilechox.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pifilechox.cc	(revision 1307)
@@ -0,0 +1,173 @@
+#include<stdio.h>
+#include<string.h>
+
+#include "pisysdep.h"
+
+#include "piapplx.h"
+#include "pifilechox.h"
+
+
+/************* PIFileChooserX ************/
+#include <X11/Shell.h>
+#include <Xm/FileSB.h>
+
+// Pour ces sal... de XmString  (ds piwdgx.cc)
+int CStrFrXmStr(XmString xms, char* buff, int nmx);
+
+// Fonctions privees (CallBack)
+//static void filesel_okact(Widget w, XtPointer *usd, XtPointer *calld);
+static void filesel_cancelact(Widget w, XtPointer *usd, XtPointer *calld);
+
+/* Nouvelle-Fonction */
+void  filesel_okact(Widget /*w*/, XtPointer *usd, 
+                    XmFileSelectionBoxCallbackStruct *calld)
+{
+PIFileChooserX *pif;
+pif = (PIFileChooserX *) usd ;
+pif->mSt = 1;
+pif->MWin()->UnManage();
+//pif->Send(pif->Msg(), (void *) (pif->GetFileName().c_str()));
+CStrFrXmStr(calld->value, pif->mFName, 512); 
+pif->Send( pif->Msg(), PIMsg_OK, (void *) pif->mFName);
+return;
+}
+
+/* Nouvelle-Fonction */
+void  filesel_cancelact(Widget /*w*/, XtPointer *usd, XtPointer */*calld*/)
+{
+PIFileChooserX *pif;
+pif = (PIFileChooserX *) usd ;
+pif->mSt = 0;
+pif->mFName[0] = '\0';
+pif->MWin()->UnManage();
+pif->Send(pif->Msg(), PIMsg_Cancel, NULL);
+return;
+}
+
+static int PIFC_SzX, PIFC_SzY;
+/* --Methode-- */
+PIFileChooserX::PIFileChooserX(PIMsgHandler* par, char* nom, PIMessage msg)
+: PIFileChooserGen(par, nom, msg)
+{
+SysDWdg wdg;
+
+mWin = NULL;
+
+int sx, sy;
+PIApplicationPrefCompSize(sx, sy);
+PIFC_SzX = sx*6;  PIFC_SzY = sy*10;
+mWin = new PIWdgX(NULL, nom, PIFC_SzX, PIFC_SzY, 200, 200);
+mWin->CreateXtWdg(nom, topLevelShellWidgetClass, NULL, PIFC_SzX, PIFC_SzY, 200, 200);
+
+mSt = 0;
+mFName[0] = mFName[511] = '\0';
+
+CreateXtWdg(nom, xmFileSelectionBoxWidgetClass, mWin->XtWdg(), sx, sy, 0, 0);
+XtAddCallback(XtWdg(), XmNokCallback, 
+              (XtCallbackProc)filesel_okact, (XtPointer)this);
+XtAddCallback(XtWdg(), XmNcancelCallback, 
+              (XtCallbackProc)filesel_cancelact, (XtPointer)this);
+// Pour avoir une version simplifiee 
+/* wdg = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_DIR_LIST);
+XtUnmanageChild(wdg);
+wdg = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_DIR_LIST_LABEL);
+XtUnmanageChild(wdg);
+*/
+wdg = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_HELP_BUTTON);
+XtUnmanageChild(wdg);
+
+fnl = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_SELECTION_LABEL);
+fnw = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_TEXT);
+
+Arg warg[2];
+XtSetArg(warg[0], XmNfileTypeMask, XmFILE_REGULAR);
+XtSetValues(XtWdg(), warg, 1);
+
+AcceptNewFile(false);
+Manage();
+}
+
+/* --Methode-- */
+PIFileChooserX::~PIFileChooserX()
+{
+delete mWin;
+}
+
+/* --Methode-- */
+void PIFileChooserX::AcceptNewFile(bool acc)
+{
+if (acc) 
+  {
+  mWin->SetSize( PIFC_SzX, PIFC_SzY*1.25);
+  XtManageChild(fnl);  XtManageChild(fnw); 
+  }
+else 
+  { 
+  mWin->SetSize( PIFC_SzX, PIFC_SzY*1.1);
+  XtUnmanageChild(fnl); XtUnmanageChild(fnw); 
+  }
+}
+
+/* --Methode-- */
+void PIFileChooserX::Show()
+{
+mWin->Manage();
+}
+
+/* --Methode-- */
+void PIFileChooserX::SetPath(string const& path)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)path.c_str(), XmSTRING_DEFAULT_CHARSET);
+Arg warg[2];
+XtSetArg(warg[0], XmNdirectory, xmstr); 
+XtSetValues(XtWdg(), warg, 1);
+XmStringFree(xmstr);
+return;
+}
+
+/* --Methode-- */
+void PIFileChooserX::SetFileName(string const& fname)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)fname.c_str(), XmSTRING_DEFAULT_CHARSET);
+Arg warg[2];
+XtSetArg(warg[0], XmNtextString, xmstr); 
+XtSetValues(XtWdg(), warg, 1);
+XmStringFree(xmstr);
+return;
+}
+
+
+/* --Methode-- */
+string PIFileChooserX::GetFileName()
+{
+
+if (mSt)
+  {
+  XmString xmstr;
+  Arg warg[2];
+
+  XtSetArg(warg[0], XmNtextString, &xmstr);
+  XtGetValues(XtWdg(), warg, 1);
+  CStrFrXmStr(xmstr, mFName, 512); 
+  string s(mFName);
+  XmStringFree(xmstr);
+  return(s);
+  }
+else
+  {
+  mFName[0] = '\0';
+  string s(mFName);
+  return(s);
+  }
+}
+
+/* --Methode-- */
+string PIFileChooserX::GetPath()
+{
+printf("PIFileChooserX::GetPath() not implemented ! \n");
+string s("");
+return(s);
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pifilechox.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pifilechox.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pifilechox.h	(revision 1307)
@@ -0,0 +1,41 @@
+#ifndef PIFILCHOX_H_SEEN
+#define PIFILCHOX_H_SEEN
+
+#include "pisysdep.h"
+#include "pifilechogen.h"
+
+#include PIWIN_H
+
+class PIFileChooserX : public PIFileChooserGen {
+public:
+
+                   PIFileChooserX(PIMsgHandler* par, char* nom, PIMessage msg);
+  virtual          ~PIFileChooserX();
+
+  virtual void     Show();
+
+  virtual void     AcceptNewFile(bool acc);
+  virtual void     SetPath(string const& path);
+  virtual void     SetFileName(string const& fname);
+
+  virtual string   GetPath();
+  virtual string   GetFileName();
+
+  inline PIWdg *   MWin() { return mWin; }
+
+//  Je les declare ici, en public, a cause des callback
+  int mSt;
+  char mFName[512];     
+
+protected:
+  PIWdg * mWin;
+  SysDWdg  fnw, fnl;
+};
+
+typedef PIFileChooserX     PIFileChooser ;
+
+#define FILESEP '/'
+
+
+#endif
+
Index: /tags/DPC_V0/Poubelle/PI/pigfname.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigfname.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigfname.h	(revision 1307)
@@ -0,0 +1,14 @@
+#ifndef PIGFNAME_H_SEEN
+#define PIGFNAME_H_SEEN
+
+#include <string>
+#if defined(__KCC__)
+using std::string ;
+#endif
+
+string PIGetFileName(string = "");
+string PIGetExistingFileName(string = "");
+
+
+#endif
+
Index: /tags/DPC_V0/Poubelle/PI/pigraph3d.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraph3d.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraph3d.cc	(revision 1307)
@@ -0,0 +1,487 @@
+// Module PI : Peida Interactive     PIGraphic3D
+// Trace graphiques 3D               R. Ansari  06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+#include <math.h>
+#include "pigraph3d.h"
+
+//++
+// Class	PIGraphic3D
+// Lib		PI
+// include	pigraph3d.h
+//
+//   	Classe fournissant les services de tracé graphique 
+//	en coordonnées utilisateur, et quelques primitives de tracé 3D
+//--
+//++
+// Links	Parent
+// PIGraphicUC
+//--
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIGraphic3D(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Constructeur d'un objet "PIGraph3D" à partir d'un "PIGraphic* g". L'espace
+//	de travail du nouvel objet "PIGraphic" correspond au rectangle défini par
+//	"(x0,y0)" , "dx,dy" du "PIGraphic" de départ.
+// 
+// int  kind()
+//	Renvoie le type ("= PI_3DGraphics")
+//--
+
+/* --Methode-- */
+PIGraphic3D::PIGraphic3D(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+        : PIGraphicUC(g, x0, y0, dx, dy)
+{
+  int i,j;
+  for(i=0; i<3; i++) 
+    for(j=0; j<3; j++)  RE[i][j] = 0.;
+  RE[0][0] = RE[1][1] = RE[2][2] = 1.;
+  xO = yC = 0.; zO = -10.;
+  xC = yC = zC = 0.;
+  tO = fO = pO = 0.; 
+  daxO = dayO = 0.25;
+  lCO = 10.;  dlCO = 0.2;  
+  sO = false;
+}
+
+/* --Methode-- */
+PIGraphic3D::~PIGraphic3D()
+{
+}
+
+/* --Methode-- */
+int PIGraphic3D::kind() 
+{
+  return PI_3DGraphics; 
+}
+
+//++
+// Titre	Système de coordonnées 3D et projection
+//	Le système de coordonnées 3D est défini par la position de l'observateur (caméra),
+//	la direction de visée ou la position du centre du champ, 
+//	l'ouverture angulaire de la caméra selon les deux 
+//	axes de la projection (X,Y), eventuellement un angle correspondant à la rotation
+//	du plan image ("psi"). Les angles d'Euler ("teta", "phi", "psi" ) sont utilisés
+//	dans la définition du système de coordonnées et la projection est de type 
+//	perspective. 
+//
+//	Les coordonnées utilisateur définissant le plan image ("PIGraphicUC") vont de 
+//	X: "-dax , +dax"   Y : "-day , +day".  
+//--
+
+//++
+// void  Set3DCS_Obs(double xo, double yo, double zo, double teta, double phi, double psi, -
+//                  double dax, double day, double co, double dco=0.2)
+//	Définition du système de projection 3D à l'aide de la position de l'observateur 
+//	et de la direction de visée.
+//|	xo,yo,zo : Position de l'observateur (camera)
+//|	teta,phi : Direction de visee
+//|	psi : rotation du plan image
+//|	dax , day : Ouverture du plan image selon les deux axes = Xmax,Ymax / Z
+//|	co : distance au centre du champ
+//|	dco : profondeur de champ 
+//
+// void  Set3DCS(double xc, double yc, double zc, double xo, double yo, double zo, -
+//               double dax, double day, double dco=0.2, double psi=0.)
+//	Définition du système de projection 3D à partir de la position de l'observateur et 
+//	du centre du champ.
+//|	xc,yc,zc : Position du centre du champ
+//|	xo,yo,zo : Position de l'observateur (camera)
+//|	dax , day : Ouverture du plan image selon les deux axes = Xmax,Ymax / Z
+//|	dco : profondeur de champ 
+//|	psi : rotation du plan image
+//--
+
+#if defined(__KCC__) 
+#ifndef M_PI
+#define M_PI            3.14159265358979323846  /* pi */
+#endif
+#ifndef M_PI_2
+#define M_PI_2          1.57079632679489661923  /* pi/2 */
+#endif
+#endif
+
+static double deuxpi = 2*M_PI;
+
+/* --Methode-- */
+void PIGraphic3D::Set3DCS_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                              double dax, double day, double co, double dco)
+{
+  sO = true;
+  xO = xo;  yO = yo;  zO = zo;
+  while (teta < 0.)  teta += deuxpi;
+  while (teta > deuxpi)  teta -= deuxpi;
+  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
+  while (phi < 0.)  phi += deuxpi;
+  while (phi > deuxpi) phi -= deuxpi;
+  tO = teta;  fO = phi;  pO = psi;
+  if (dax < 0.) dax = -dax;
+  if (day < 0.) day = -day;
+  daxO = dax;  dayO = day;
+  lCO = co;   dlCO = dco;
+// Si on ne met  kAxeDirLtoR, le repere semble etre ds le sens inverse -> kAxeDirRtoL  , Reza 16/10/98
+  SetUCS(-dax, dax, -day, day, kAxeDirRtoL, kAxeDirDownUp);
+  double ct = cos((double)tO);
+  double st = sin((double)tO);
+// (Teta,Phi) = Direction de visee 
+// Les angles d'Euler correspondants sont Teta, Phi+Pi/2
+// Le Pi/2 vient que les rotations d'euler se font dans l'ordre
+//  Autour de oZ d'angle Phi, autour de oN (nouvel axe X) d'angle Teta
+//  Autour du nouvel axe Z (x3) d'angle Psi
+  double cf = cos((double)fO+M_PI_2);
+  double sf = sin((double)fO+M_PI_2);
+  double cp = cos((double)pO);
+  double sp = sin((double)pO);
+  RE[0][0] = cf*cp-sf*ct*sp;     RE[0][1] = sf*cp+cf*ct*sp;      RE[0][2] = st*sp;
+  RE[1][0] = -cf*sp-sf*ct*cp;    RE[1][1] = -sf*sp+cf*ct*cp;     RE[1][2] = st*cp;
+  RE[2][0] = sf*st;              RE[2][1] = -cf*st;              RE[2][2] = ct;
+  cf = cos((double)fO);
+  sf = sin((double)fO);
+  zC = ct*lCO+zO;
+  xC = st*cf*lCO+xO;
+  yC = st*sf*lCO+yO;
+}
+
+/* --Methode-- */
+void PIGraphic3D::Set3DCS(double xc, double yc, double zc, double xo, double yo, double zo, 
+                          double dax, double day, double dco, double psi)
+{
+  sO = false;
+  xO = xo;  yO = yo;  zO = zo;
+  xC = xc;  yC = yc;  zC = zc;
+  double dx,dy,dz;
+// On calcule le vecteur  OC  Observateur -> Centre du champ, ca nous donne donc teta,phi de visee
+  dx = xc-xo;  dy = yc-yo;  dz = zc-zo;
+  if (dax < 0.) dax = -dax;
+  if (day < 0.) day = -day;
+  daxO = dax;  dayO = day;  
+// Si on ne met  kAxeDirLtoR, le repere semble etre ds le sens inverse -> kAxeDirRtoL  , Reza 16/10/98
+  SetUCS(-dax, dax, -day, day, kAxeDirRtoL, kAxeDirDownUp);
+  lCO = sqrt(dx*dx+dy*dy+dz*dz);
+  if (lCO < 1.e-6) {
+    printf("PIGraphic3D::Set3DCS()/Warning : Length(CO) = %g -> CS par defaut \n", lCO);
+    int i,j;
+    for(i=0; i<3; i++) 
+      for(j=0; j<3; j++)  RE[i][j] = 0.;
+    RE[0][0] = RE[1][1] = RE[2][2] = 1.;
+    xO = yC = 0.; zO = -10.;
+    xC = yC = zC = 0.;
+    tO = fO = pO = 0.; 
+    daxO = dayO = 0.25;
+    lCO = 10.;  dlCO = 0.2;      
+    return;
+  }
+  dlCO = dco;
+  double lxy = sqrt(dx*dx+dy*dy);
+  double ct,st,cf,sf;
+  ct = dz/lCO;
+  st = sqrt(1-ct*ct);
+  pO = psi;
+  tO = acos(ct);
+  if (lxy < 1.e-6) { fO = 0.;  cf = 0.;  }
+  else {  cf = dx/lxy;  fO = acos(cf);  if (dy < 0.)  fO = deuxpi-fO;   }
+// (Teta,Phi) = Direction de visee 
+// Les angles d'Euler correspondants sont Teta, Phi+Pi/2
+// Le Pi/2 vient que les rotations d'euler se font dans l'ordre
+//  Autour de oZ d'angle Phi, autour de oN (nouvel axe X) d'angle Teta
+//  Autour du nouvel axe Z (x3) d'angle Psi
+  cf = cos((double)fO+M_PI_2);
+  sf = sin((double)fO+M_PI_2);
+  double cp = cos((double)psi);
+  double sp = sin((double)psi);
+  RE[0][0] = cf*cp-sf*ct*sp;     RE[0][1] = sf*cp+cf*ct*sp;      RE[0][2] = st*sp;
+  RE[1][0] = -cf*sp-sf*ct*cp;    RE[1][1] = -sf*sp+cf*ct*cp;     RE[1][2] = st*cp;
+  RE[2][0] = sf*st;              RE[2][1] = -cf*st;              RE[2][2] = ct;
+}
+
+//++
+// bool Get3DCS(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, -
+//             double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco);
+//	Renvoie les paramètres de définition du système de projection 3D.
+//	"Rc= true" si défini par  "Set3DCS_Obs()"
+//	
+// void  RotateObserver(double teta, double phi, double psi=0., bool rel=true)
+//	Positionne l'observateur (la caméra) en maintenant la position  
+//	du centre de champ fixe. Si "rel=false" : "teta, phi" determine la nouvelle
+//	direction de visée. Si "rel=false" : la direction de visée est tournée
+//	de l'angle "teta,phi". 
+// void  RotateObject(double teta, double phi, bool rel=true)
+//	Repostionne le centre du champ en maintenant la position de l'observateur fixe.
+//	Si "rel=false" : "teta, phi" determine la nouvelle direction de visée.
+//	Si "rel=false" : la direction de visée est tournée de l'angle "teta,phi". 
+// 
+// void  ZoomInOut(double fco, double fdax, double fday, bool rel=true)
+//	Eloigne ou approche l'observateur et modifie l'ouverture du plan image.
+//	si "real=true" : "fco, fdax, fday" sont des facteurs multiplicatifs
+//	par rapport aux valeurs actuelles, sinon des valeurs absolues. 
+//|	fco : distance observateur - centre du champ
+//|	fdax, fday : ouverture du plan image
+//--
+
+/* --Methode-- */
+bool PIGraphic3D::Get3DCS(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, 
+                          double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco)
+{
+  xc = xC;  yc = yC;  zc = zC;
+  xo = xO;  yo = yO;  zo = zO;
+  teta = tO;  phi = fO;  psi = pO;
+  dax = daxO;   day = dayO;
+  co = lCO;     dco = dlCO;
+  return(sO);
+}
+
+
+/* --Methode-- */
+void PIGraphic3D::RotateObserver(double teta, double phi, double psi, bool rel)
+// Positionne l'observateur (la camera) de maniere a ce que la direction de 
+// visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true) 
+// en conservant le centre de champ fixe  
+{
+  if (rel) {
+    teta += tO;
+    phi += fO;
+    psi += pO;
+    }
+  while (teta < 0.)  teta += deuxpi;
+  while (teta > deuxpi)  teta -= deuxpi;
+  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
+  double xo,yo,zo; 
+  zo = -cos((double)teta)*lCO+zC;
+  xo = -sin((double)teta)*cos((double)phi)*lCO+xC;
+  yo = -sin((double)teta)*sin((double)phi)*lCO+yC;
+  Set3DCS(xC,yC,zC, xo,yo,zo, daxO, dayO, dlCO, psi);
+}
+
+/* --Methode-- */
+void PIGraphic3D::RotateObject(double teta, double phi, bool rel)
+// Positionne l'objet (centre du champ) de maniere a ce que la direction de 
+// visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true) 
+// en conservant la position de l'observateur fixe.  
+{
+  if (rel) {
+    teta += tO;
+    phi += fO;
+    }
+  while (teta < 0.)  teta += deuxpi;
+  while (teta > deuxpi)  teta -= deuxpi;
+  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
+  double xc,yc,zc; 
+  zc = cos((double)teta)*lCO+zO;
+  xc = sin((double)teta)*cos((double)phi)*lCO+xO;
+  yc = sin((double)teta)*sin((double)phi)*lCO+yO;
+  Set3DCS(xc,yc,zc, xO,yO,zO, daxO, dayO, dlCO, pO);
+}
+
+/* --Methode-- */
+void PIGraphic3D::ZoomInOut(double fco, double fdax, double fday, bool rel)
+{
+  if (fco < 0.001) fco = 1.;
+  if (fdax < 0.001) fdax = 1.;
+  if (fday < 0.001) fday = 1.;
+  double dl;
+  if (rel) {
+    dl = fco*lCO;  
+    fdax *= daxO;
+    fday *= dayO;
+  }
+  else dl = fco; 
+  double xo,yo,zo; 
+  if (dl < 1.e-5) dl = 1.e-5;
+  zo = zC-cos((double)tO)*dl;
+  xo = xC-sin((double)tO)*cos((double)fO)*dl;
+  yo = yC-sin((double)tO)*sin((double)fO)*dl;
+  Set3DCS(xC,yC,zC, xo,yo,zo, fdax, fday, dlCO, pO);
+//  Set3DCS_Obs(xo, yo, zo, tO, fO, pO, daxO*fda, dayO*fda, dl, dlCO);
+}
+
+/* --Methode-- */
+void PIGraphic3D::C3DC2ObsCS(double x, double y, double z, double& xp, double& yp, double& zp)
+{
+  double xc, yc, zc;
+  xc = x-xO;   yc = y-yO;    zc = z-zO;
+  xp = RE[0][0]*xc+RE[0][1]*yc+RE[0][2]*zc;
+  yp = -RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc;  
+  zp = RE[2][0]*xc+RE[2][1]*yc+RE[2][2]*zc;
+}
+
+/* --Methode-- */
+void PIGraphic3D::Proj3DC2GrC(double x, double y, double z, double& xpix, double& ypix)
+{
+  double xc, yc, zc;
+  double xp, yp, zp;
+  xc = x-xO;   yc = y-yO;    zc = z-zO;
+  xp = RE[0][0]*xc+RE[0][1]*yc+RE[0][2]*zc;   
+  yp = RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc;
+  zp = RE[2][0]*xc+RE[2][1]*yc+RE[2][2]*zc;
+  if ((zp>-1.e-6) && (zp < 1.e-6))   // Protection Divide/0
+    { xpix = ypix = 0.;   return; }
+  xpix = (double)(xOrg + (xp/zp)*xScale);
+  ypix = (double)(yOrg + (yp/zp)*yScale);
+//  printf("-DBG-Proj3DC2GrC() %g %g %g -> %g %g %g -> %g %g %g -> (%g %g)\n", x,y,z,xc,yc,zc,xp,yp,zp,xp/zp,yp/zp);
+//  printf("-DBG- ... (%g %g %g - %g %g) %g %g - %g %g -> %g %g \n", xO,yO,zO, tO,fO, xOrg, yOrg,xScale,yScale ,xpix,ypix);
+}
+
+//++
+// Titre	Primitives de tracé 3D
+//--
+//++
+// void  DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s)
+//	Tracé de chaîne de caractères à la position "(x0,y0,z0)"
+// void  DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s)
+//	Tracé de chaîne opaque à la position "(x0,y0,z0)"
+// void  DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1, -
+//                  PIGrCoord x2, PIGrCoord y2, PIGrCoord z2)
+//	Tracé d'une ligne entre les deux points "(x1,y1,z1)" et "(x2,y2,z2)"
+// void  DrawPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+//	Tracé de contour de polygone - sommets définis par le tableau 
+//	"(x[i],y[i],z[i])" , "i=0..n-1"
+// void  DrawFPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+//	Tracé de polygone - "(x[i],y[i],z[i])" , "i=0..n-1"
+// void  DrawMarker3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0)
+//	Tracé d'un signe (marker) au point "(x0,y0,z0)"
+// void  DrawMarkers3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+//	Tracé de signes (marker) aux points "(x[i],y[i],z[i])" , "i=0..n-1"
+//--
+
+/* --Methode-- */
+void PIGraphic3D::DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  Proj3DC2GrC(x0, y0, z0, xf, yf);
+  mGrC->DrawString(xf, yf, s);
+  return;
+}
+
+/* --Methode-- */
+void PIGraphic3D::DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  Proj3DC2GrC(x0, y0, z0, xf, yf);
+  mGrC->DrawOpaqueString(xf, yf, s);
+  return;
+}
+
+/* --Methode-- */
+void PIGraphic3D::DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1, 
+                             PIGrCoord x2, PIGrCoord y2, PIGrCoord z2)
+{
+  if (!mGrC) return;
+  double xf1, yf1, xf2, yf2;
+  Proj3DC2GrC(x1, y1, z1, xf1, yf1);
+  Proj3DC2GrC(x2, y2, z2, xf2, yf2);
+//  printf("-DBG-DrawLine3D() : %g %g %g -> %g %g | %g %g %g -> %g %g\n", 
+//         (double)x1, (double)y1, (double)z1, xf1, yf1, 
+//         (double)x2, (double)y2, (double)z2, xf2, yf2 );
+  mGrC->DrawLine(xf1, yf1, xf2, yf2);
+}
+
+#define NMXMULTP  30   // Pour multipoint sans new
+
+/* --Methode-- */
+void PIGraphic3D::DrawPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n];  }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawPolygon(pxc, pyc, n, false);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+
+/* --Methode-- */
+void PIGraphic3D::DrawFPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n];  }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawFPolygon(pxc, pyc, n, false);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+/* --Methode-- */
+void PIGraphic3D::DrawMarker3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  Proj3DC2GrC(x0, y0, z0, xf, yf);
+  mGrC->DrawMarker(xf, yf);
+  return;
+}
+
+/* --Methode-- */
+void PIGraphic3D::DrawMarkers3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawMarkers(pxc, pyc, n);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+
+//  Methode pour debugger 
+/* --Methode-- */
+void PIGraphic3D::PrintCS()
+{
+if (sO)  printf("PIGraphic3D::PrintCS() : Set3DCS_Obs(...) \n");
+else  printf("PIGraphic3D::PrintCS() : Set3DCS(...) \n");
+printf("C: %g %g %g ->O: %g %g %g - T,P= %g %g %g lCO= %g %g  |  %g %g - %g %g \n", 
+        xC,yC,zC, xO, yO, zO, tO, fO, pO, lCO, dlCO, xOrg, xScale, yOrg, yScale ); 
+printf("RE[3][3]=  %g %g %g | %g %g %g | %g %g %g\n", 
+        RE[0][0], RE[0][1], RE[0][2], RE[1][0], RE[1][1], RE[1][2], RE[2][0], RE[2][1], RE[2][2]); 
+double x,y,z,xp,yp,zp, xpix, ypix;
+x = xC, y = yC, z= zC;
+C3DC2ObsCS(x, y, z, xp, yp, zp);
+Proj3DC2GrC(x, y, z, xpix, ypix);
+printf("C -> %g %g %g -> %g %g \n", xp, yp, zp, xpix, ypix); 
+x = xC+1, y = yC, z= zC;
+C3DC2ObsCS(x, y, z, xp, yp, zp);
+Proj3DC2GrC(x, y, z, xpix, ypix);
+printf("C+(1,0,0) -> %g %g %g -> %g %g ", xp, yp, zp, xpix, ypix); 
+x = xC, y = yC+1, z= zC+1;
+C3DC2ObsCS(x, y, z, xp, yp, zp);
+Proj3DC2GrC(x, y, z, xpix, ypix);
+printf("C+(0,1,1) -> %g %g %g -> %g %g \n", xp, yp, zp, xpix, ypix); 
+}
Index: /tags/DPC_V0/Poubelle/PI/pigraph3d.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraph3d.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraph3d.h	(revision 1307)
@@ -0,0 +1,56 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIGraphic3D
+// Trace graphiques 3D               R. Ansari  06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIGRAPHIC3D_H_SEEN
+#define PIGRAPHIC3D_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphuc.h"
+
+
+class PIGraphic3D : public PIGraphicUC 
+{
+public:
+                     PIGraphic3D(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual           ~PIGraphic3D();
+
+  virtual int        kind();
+
+//  Definition du systeme de projection 3D-2D
+  virtual void       Set3DCS_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                                 double dax, double day, double co, double dco=0.2);
+  virtual void       Set3DCS(double xc, double yc, double zc, double xo, double yo, double zo, 
+                             double dax, double day, double dco=0.2, double psi=0.);
+  virtual bool       Get3DCS(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo,  
+                             double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco);
+
+  virtual void       PrintCS();  // Pour debugger
+  virtual void       RotateObserver(double teta, double phi, double psi=0., bool rel=true);
+  virtual void       RotateObject(double teta, double phi, bool rel=true);
+  virtual void       ZoomInOut(double fco, double fdax, double fday, bool rel=true);
+
+  virtual void       C3DC2ObsCS(double x, double y, double z, double& xp, double& yp, double& zp);
+  virtual void       Proj3DC2GrC(double x, double y, double z, double& xpix, double& ypix);
+  
+  virtual void       DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s);
+  virtual void       DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s);
+  virtual void       DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1, 
+                                PIGrCoord x2, PIGrCoord y2, PIGrCoord z2);
+  virtual void       DrawPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n);  
+  virtual void       DrawFPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n);  
+  virtual void       DrawMarker3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0);
+  virtual void       DrawMarkers3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n);
+  
+protected:
+  double xO, yO, zO;  // Position observateur = camera
+  double xC, yC, zC;  // Position centre du champ
+  double tO,fO,pO;    // Orientation observateur (Teta, Phi, Psi, Angles d Euler)
+  double daxO, dayO;  // Demi-ouverture de la camera suivant les deux axes de projection (xp/zp, yp/zp) 
+  double lCO, dlCO;   // Distance Camera-Centre du champ et profondeur de champ 
+  double RE[3][3];    // Matrice de rotation  
+  bool sO;            // Vrai si fait par Set3DCS_Obs()
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pigraphgen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphgen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphgen.cc	(revision 1307)
@@ -0,0 +1,353 @@
+// Module PI : Peida Interactive     PIGraphic 
+// Primitives de trace graphiques    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+// Classe generique de trace graphique de base (Ne peut etre instancie)
+
+#include "pigraphgen.h"
+
+//++
+// Class	PIGraphic
+// Lib		PI
+// include	pigraphgen.h
+//
+//   	Classe de base fournissant les services de tracé graphique.
+//   	La classe PIGraphicGen définit l'interface à travers des méthodes
+//   	virtuelles pures. Les objets instanciés doivent être de la classe
+//   	"PIGraphicWin" ou "PIGraphicUC" ou ...
+//   	La classe "PIGraphicWin" a une implementation dépendante du système 
+//   	utilisé (Mac, XWindow, ...). 
+//   	Un type particulier *PIGrCoord* est défini pour la spécification 
+//	des coordonnées graphiques. 
+//--
+//++
+// Links	Voir aussi
+// PIGrCoord
+// PIColorMap
+//--
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// PIGraphic()
+//	Constructeur utilisé par les classes dérivées.
+// PIGraphic(PIWdg* wdg)
+//	Constructeur pour les *PIGraphicWin*. Objet "PIGraphic" capable 
+//	de tracer dans un "PIWdg".
+// PIGraphic(PIScreenBuffer* grb)
+//	Constructeur pour objet "PIGraphic" capable de tracer dans un 
+//	buffer graphique.
+//--
+//++
+//--
+// Titre	Méthodes
+//++
+// int  kind()
+//	Renvoie le type de l'objet "PIGraphic" .
+//	* PI_UnknownGraphics : Objet PIGraphic de type inconnue.
+//	* PI_ScrBufferGraphics : Objet PIGraphic associé à un "GraphicBuffer"
+//	* PI_ScrWindowGraphics : Objet PIGraphic associé à une fenêtre sur l'écran (PIWdg)
+//	* PI_PSFileGraphics : Objet PIGraphic à un fichier PostScript (pour impression papier)
+//	* PI_UCGraphics : Objet PIGraphic travaillant dans un système de coordonnées utilisateur.
+//	* PI_3DGraphics : Objet PIGraphic fournissant des méthodes de tracé en coordonnées 3-D
+// void  GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax)
+//	Renvoie les limites de l'espace graphique - Coordonnées fenêtre pour un PIGraphicWin, 
+//	Limites définies par l'utilisateur pour un PIGraphicUC
+// void  Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) 
+//	Efface le rectangle défini par le coin "x0,y0", de longeur et de largeur "dx,dy"
+//	en utilisant la couleur d'arrière plan (Background)
+//--
+
+
+/* --Methode-- */
+PIGraphicGen::PIGraphicGen()
+{
+myWdg = NULL;
+myGrb = NULL;
+}
+
+/* --Methode-- */
+PIGraphicGen::PIGraphicGen(PIWdg* wdg)
+{
+myWdg = wdg;
+myGrb = NULL;
+}
+
+/* --Methode-- */
+PIGraphicGen::PIGraphicGen(PIScreenBuffer* grb)
+{
+myWdg = NULL;
+myGrb = grb;
+}
+
+/* --Methode-- */
+PIGraphicGen::~PIGraphicGen()
+{
+}
+/* --Methode-- */
+int PIGraphicGen::kind() 
+{
+return PI_UnknownGraphics ;
+}
+
+
+/* --Methode-- */
+void PIGraphicGen::GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax)
+{
+xmin = ymin = 0;  
+xmax = ymax = 0;
+if (myWdg) {
+  xmax = myWdg->XSize();
+  ymax = myWdg->YSize();
+  }
+}
+
+//++ 
+// Titre	Tracés de texte
+//--
+//++
+// void  DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)
+//	Trace la chaîne de caractères "s" à la position "x,y", 
+//	en utilisant la couleur d'avant-plan (Foreground)
+// void  DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0) 
+//	Trace la chaîne de caractères "s" à la position "x,y" . La couleur d'
+//	arrière-plan est utilisée pour remplir la zone rectangulaire occupée par
+//	le tracé de texte.
+//--
+
+//++ 
+// Titre	Tracés de lignes et de figures géometriques
+//--
+//++
+// void  DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
+//	Trace une ligne entre les points de coordonnées "(x1,y1)" et "(x2,y2)", 
+//	en utilisant la couleur d'avant-plan (Foreground)
+// void  DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Tracé du contour d'un rectangle défini par la position du coin "(x0,y0)"
+//	et de taille "dx,dy" avec la couleur d'avant-plan.
+// void  DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Tracé d'un rectangle plein, défini par la position du coin "(x0,y0)"
+//	et de taille "dx,dy" avec la couleur d'avant-plan.
+// void  DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)  
+//	Tracé du contour d'un cercle centré en "(x0,y0)", de rayon "r"
+// void  DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)  
+//	Tracé d'un cercle plein centré en "(x0,y0)", de rayon "r"
+// void  DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Tracé d'une ellipse incluse dans le rectangle "(x0,y0)" , "dx,dy"
+// void  DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Tracé d'une ellipse pleine incluse dans le rectangle "(x0,y0)" , "dx,dy"
+// void  DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)
+//	Tracé du contour d'un polygone défini par le tableau des "n" points "x,y".
+//	Si "cinc==true", les coordonnées seront considérées comme relatives
+//	à la position du point "(x[0], y[0])". Dans le cas contraire, chaque couple
+//	"(x[i], y[i])" représentera les coordonnées absolues d'un coin du polygone.
+// void  DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)
+//	Tracé d'un polygone plein de la couleur d'avant-plan.
+// void  DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, double degdeb, double degfin)
+//	Tracé d'un arc de cercle ou d'ellipse, inclu dans le "(x0,y0)" , "dx,dy" 
+//	entre les angles (en degré) "degdeb" - "degfin" 
+// void  DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, double degdeb, double degfin)
+//	Tracé d'un arc plein, inclu dans le "(x0,y0)" , "dx,dy" 
+//	entre les angles (en degré) "degdeb" - "degfin" 
+//--
+
+//++ 
+// Titre	Tracés de signes
+//--
+//++
+// void  DrawMarker(PIGrCoord x0, PIGrCoord y0)  
+//	Tracé d'un signe au point "(x0,y0)". Le choix du signe tracé s'effectue
+//	à travers la méthode "SelMarker()"
+// void  DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+//	Tracé de "n" signes aux points "(x[i],y[i])"
+//--
+
+//++
+// Titre	Tracé d'images (pixmap)
+//--
+//++
+// void  DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, int sx, int sy, PIColorMap* cmap)
+//	Tracé d'un pixmap dans un rectangle positionné en "(x,y)". Le tableau des pixels
+//	"pix", de taille "sx,sy" représente les index dans la table de couleur "cmap".
+//--
+
+//++
+// Titre	Modifications des attributs graphiques	
+//--
+//++
+// void  SelForeground(PIColors col=PI_Black)
+//	Choix de la couleur de tracé d'avant-plan
+//|	PI_Black , PI_White,  PI_Grey , PI_Red , PI_Blue , PI_Green ,  
+//|	PI_Yellow , PI_Magenta , PI_Cyan , PI_Turquoise , PI_NavyBlue , 
+//|	PI_Orange , PI_SiennaRed , PI_Purple , PI_LimeGreen , PI_Gold 
+// void  SelBackground(PIColors col=PI_White)
+//	Choix de la couleur d'arrière-plan
+// void  SelForeground(PIColorMap& cmap, int cid) 
+//	Choix de la couleur de tracé d'avant-plan: Couleur numéro "cid" de la table de couleur "cmap"
+// void  SelBackground(PIColorMap& cmap, int cid)
+//	Choix de la couleur d'arrière-plan: Couleur numéro "cid" de la table de couleur "cmap"
+// void  SelGOMode(PIGOMode mod=PI_GOCopy) 
+//	Choix du mode de tracé graphique: "PI_GOCopy" ou "PI_GOXOR"	
+// void  SelFont(PIFontSize sz=PI_NormalSizeFont, PIFontAtt att=PI_RomanFont)
+//	Choix de la fonte pour le tracé de texte
+//|	PI_SmallSizeFont , PI_NormalSizeFont , PI_BigSizeFont, PI_HugeSizeFont
+//|	PI_RomanFont , PI_BoldFont , PI_ItalicFont 
+// void  SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont)
+//	Choix de la fonte avec spécification de taille en points (pixels sur l'écran)
+// void  SelLine(PILineAtt att=PI_NormalLine)
+//	Choix du type de ligne pour le tracé des lignes et contours
+//|	PI_NormalLine, PI_ThinLine , PI_ThickLine
+//|	PI_DashedLine, PI_ThinDashedLine, PI_ThickDashedLine
+//|	PI_DottedLine, PI_ThinDottedLine, PI_ThickDottedLine
+// void  SelMarker(int msz=3, PIMarker mrk=PI_DotMarker) 
+//	Choix de la taille et du type de signe pour "DrawMarker() / DrawMarkers()"
+//|	PI_DotMarker , PI_PlusMarker , PI_CrossMarker
+//|	PI_CircleMarker , PI_FCircleMarker , PI_BoxMarker , PI_FBoxMarker
+//|	PI_TriangleMarker , PI_FTriangleMarker , PI_StarMarker , PI_FStarMarker
+//	(Les "StarMaker" ne sont pas encore implémentés  11/98) 
+//--
+
+//++
+// Titre	Sélection de la zone de tracé (clip)	
+//--
+//++
+// void  SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Limite la zone de tracé permise au rectangle "(x0,y0)", "dx,dy"
+// void  ClearClipRectangle() 
+//	Supprime si nécéssaire la limitation de la zone de tracé.	
+//--
+
+//++
+// Titre	Accès aux attributs graphiques
+//--
+//++
+// PIColors  GetForeground()
+//	Renvoie la couleur de tracé d'avant-plan courante. 
+//	("PI_ColorFromMap" si défini à partir d'une table de couleur
+// PIColors  GetBackground()
+//	Renvoie la couleur d'arrière-plan courante.
+// PIGOMode  GetGOMode()
+//	Renvoie le mode de tracé graphique courante.
+// PIFontAtt GetFontAtt()
+//	Renvoie les attributs de la fonte courante.
+// int GetFontSize() 
+//	Renvoie la taille de la fonte courante.
+// PILineAtt GetLineAtt() 
+//	Renvoie le type de ligne courant
+// PIMarker  GetMarker() 
+//	Renvoie le type de signe (Marker) courant
+// int GetMarkerSize()
+//	Renvoie la taille des signes (Marker) pour le marker courant
+// int GetFontHeight(int& asc, int& desc) 
+//	Renvoie la hauteur des caractères, ainsi que la taille au dessus
+//	et en-dessous de la ligne de base ("asc , desc") pour la fonte courante
+// PIGrCoord CalcStringWidth(char const* s)
+//	Renvoie la largeur occupé par un texte s'il était affiché dans le 
+//	système de coordonnées courant (Fenêtre ou UC).
+//--
+
+//++
+// Titre	Sauvegarde et rappel des attributs graphiques
+//--
+//++
+// void  SaveGraphicAtt()
+//	Sauvegarde des attributs graphiques courants
+// void  RestoreGraphicAtt()
+//	Utilisation de l'ensemble des attributs graphiques sauvegardés par un appel
+//	à "SaveGraphicAtt()"
+//--
+
+
+/* --Methode-- */
+void PIGraphicGen::SaveGraphicAtt()
+{
+  sFCol = GetForeground();
+  sBCol = GetBackground();
+  sGOm = GetGOMode();
+  sFAtt = GetFontAtt();   
+  sFSize = GetFontSize();
+  sLAtt = GetLineAtt();
+  sMrk = GetMarker();   
+  sMrkSz = GetMarkerSize();
+  return;
+}
+
+/* --Methode-- */
+void PIGraphicGen::RestoreGraphicAtt()
+{
+  SelForeground(sFCol);
+  SelBackground(sBCol);
+  SelGOMode(sGOm);
+  SelFontSzPt(sFSize, sFAtt);
+  SelLine(sLAtt);
+  SelMarker(sMrkSz, sMrk);
+  return;
+}
+
+
+
+
+//++
+// Class	PIGrCoord
+// Lib		PI
+// include	pigraphgen.h
+//
+//   	Classe utilisé pour la spécifiaction de coordonnées graphique.
+//	Des constructeurs et des méthodes de conversion à partir 
+//	et vers des "int", "float" et "double" sont définis.
+//	L'objet conserve le type effectif de l'argument lors de la 
+//	création ou de la dernière affectation.
+// 
+//|	PIGrCoord gco;
+//|	gco = 3.141596 ; 
+//|	int ic = gco;     // ic -> 3
+//|	float fc = gco;   // fc -> 3.141596
+//--
+//++
+// Links	Voir aussi
+// PIGraphic
+//--
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// 
+// PIGrCoord() 
+//	Constructeur par défaut ("intVal=floatVal=0")
+// PIGrCoord(int a)
+//	Constructeur à partir de l'entier "a"
+// PIGrCoord(float a) 
+//	Constructeur à partir de la valeur flottante "a"
+// PIGrCoord(double a) 
+//	Constructeur à partir de la valeur flottante double précision "a"
+//--
+//++
+// Titre	Opérateurs de conversion
+//--
+//++
+// operator int() 
+//	Conversion en entier "int"
+// operator short() 
+//	Conversion en entier "short"
+// operator unsigned int() 
+//	Conversion en entier non signé "unsigned int"
+// operator unsigned short() 
+//	Conversion en entier non signé "unsigned short"
+// operator float() 
+//	Conversion en réél "float"
+// operator double() 
+//	Conversion en réél "double"
+//--
+//++
+// Titre	Opérateurs d'affectation
+//--
+//++
+// PIGrCoord& operator= (int a) 
+//	Affectation à partir de valeur entière "int"
+// PIGrCoord& operator= (float a) 
+//	Affectation à partir de valeur réélle "float"
+// PIGrCoord& operator= (double a) 
+//	Affectation à partir de valeur réélle double précision "double"
+//--
Index: /tags/DPC_V0/Poubelle/PI/pigraphgen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphgen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphgen.h	(revision 1307)
@@ -0,0 +1,162 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIGraphic 
+// Primitives de trace graphiques    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIGRAPHICGEN_H_SEEN
+#define PIGRAPHICGEN_H_SEEN
+
+#include "pisysdep.h"
+
+#include PIWDG_H
+#include PICMAP_H
+
+
+enum PIColors  { PI_ColorFromMap = -2, PI_NotDefColor = -1, 
+                 PI_Black = 0, PI_White = 1,  PI_Grey = 2,
+                 PI_Red = 3, PI_Blue = 4, PI_Green = 5,  
+                 PI_Yellow = 6, PI_Magenta = 7, 
+                 PI_Cyan = 8, PI_Turquoise = 9, PI_NavyBlue = 10, 
+                 PI_Orange = 11, PI_SiennaRed = 12, PI_Purple = 13,  
+                 PI_LimeGreen = 14, PI_Gold = 15 };
+
+enum PIFontSize { PI_NotDefFontSize = -1, 
+                  PI_SmallSizeFont = 1, PI_NormalSizeFont = 2, 
+                  PI_BigSizeFont = 3, PI_HugeSizeFont = 4 };
+
+enum PIFontAtt { PI_NotDefFontAtt = -1,
+                 PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 };
+
+enum PILineAtt { PI_NotDefLineAtt = -1,
+                 PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 ,
+                 PI_DashedLine = 64, PI_ThinDashedLine = 65, PI_ThickDashedLine = 66 ,
+                 PI_DottedLine = 128, PI_ThinDottedLine = 129, PI_ThickDottedLine = 130 };
+
+enum PIMarker  { PI_NotDefMarker = -1,
+                 PI_DotMarker = 0, PI_PlusMarker=1, PI_CrossMarker=2,  
+                 PI_CircleMarker=3, PI_FCircleMarker=4,
+                 PI_BoxMarker=5, PI_FBoxMarker=6,
+                 PI_TriangleMarker=7, PI_FTriangleMarker=8,
+                 PI_StarMarker=9, PI_FStarMarker=10 };
+
+enum PIGOMode { PI_GOCopy = 0, PI_GOXOR = 1 }; 
+
+
+//  Classe pour gerer indifferement des coordonnees double ou int 
+class PIGrCoord {
+public:
+  inline PIGrCoord() { iv = 0; dv = 0.;}
+  inline PIGrCoord(int a) { iv = a; dv = (double)a;}
+  inline PIGrCoord(float a) { iv = (int)a; dv = (double)a;}
+  inline PIGrCoord(double a) { iv = (int)a; dv = a;}
+  inline operator int() { return(iv); }
+  inline operator short() { return((short)iv); }
+  inline operator unsigned int() { return((unsigned int)iv); }
+  inline operator unsigned short() { return((unsigned short)iv); }
+  inline operator float() { return((float)dv); }
+  inline operator double() { return(dv); }
+  inline PIGrCoord& operator= (int a) { iv = a; dv = (double)a; return(*this); }
+  inline PIGrCoord& operator= (float a) { iv = (int)a; dv = (double)a; return(*this); }
+  inline PIGrCoord& operator= (double a) { iv = (int)a; dv = a; return(*this); }
+  int iv;
+  double dv;
+};
+
+enum PIGraphicsType { PI_UnknownGraphics = 0, 
+                      PI_ScrWindowGraphics = 2, PI_ScrBufferGraphics = 3, 
+                      PI_PSFileGraphics = 8, 
+                      PI_UCGraphics = 32, PI_3DGraphics = 36 };
+
+// Classe generique de trace graphique de base :
+
+class PIGraphicGen
+{
+public:
+                     PIGraphicGen();
+                     PIGraphicGen(PIWdg* wdg);
+                     PIGraphicGen(PIScreenBuffer* grb);
+  virtual           ~PIGraphicGen();
+
+  virtual int        kind();
+
+//  Espace des coordonnees
+  virtual void       GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax); 
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)     = 0;
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)        = 0;
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)  = 0;
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)  = 0;
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)   = 0;
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)  = 0;
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)               = 0;
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)              = 0;
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)  = 0;
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0;
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)    = 0;  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)   = 0;  
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin)                             = 0;
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin)                            = 0;
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0)                            = 0;
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)                    = 0;
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap)              = 0;
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black)                      = 0;
+  virtual void       SelBackground(PIColors col=PI_White)                      = 0;
+  virtual void       SelForeground(PIColorMap& cmap, int cid)                  = 0;
+  virtual void       SelBackground(PIColorMap& cmap, int cid)                  = 0;
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy)                         = 0;
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont)                       = 0;
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont)       = 0; 
+  virtual void       SelLine(PILineAtt att=PI_NormalLine)                      = 0;
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker)           = 0;
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)  = 0;
+  virtual void       ClearClipRectangle()                                      = 0;
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground()    = 0;
+  virtual PIColors   GetBackground()    = 0;
+  virtual PIGOMode   GetGOMode()        = 0;
+  virtual PIFontAtt  GetFontAtt()       = 0;
+  virtual int        GetFontSize()      = 0;
+  virtual PILineAtt  GetLineAtt()       = 0;
+  virtual PIMarker   GetMarker()        = 0;
+  virtual int        GetMarkerSize()    = 0;
+
+  virtual int        GetFontHeight(int& asc, int& desc)      = 0;
+  virtual PIGrCoord  CalcStringWidth(char const* s)          = 0;
+
+// Sauvegarde des attributs graphiques 
+  virtual void       SaveGraphicAtt();
+  virtual void       RestoreGraphicAtt();
+
+protected:
+// Pour Save/Restore des attributs graphiques 
+  PIWdg* myWdg;
+  PIScreenBuffer* myGrb;
+
+  PIColors  sFCol, sBCol;
+  PIGOMode sGOm;
+  PIFontAtt sFAtt;
+  PILineAtt sLAtt;
+  int sFSize;
+  PIMarker sMrk;
+  int sMrkSz;
+};
+
+#endif
+
+typedef PIGraphicGen PIGraphic;
+
+// hierarchie apparente
+//   PIGraphic               ( == Gen, mais pas visible de l'utilisateur).
+//     PIGraphicWin   ( == X ou Mac)
+//     PIGraphicPS
+//     PIGraphicUC
Index: /tags/DPC_V0/Poubelle/PI/pigraphics.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphics.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphics.h	(revision 1307)
@@ -0,0 +1,16 @@
+PIGraphics : = 0 sauf save et restore a reprendre de pibwdggen.cc
+
+Toutes methodes de trace et de selection.
+kind : retourne window, ps ou autre
+
+constructeur sans argument.
+
+->  PIGraphicsWinGen     rien de plus  sauf kind = window
+           constructeur prend un PIWdg
+     -> PIGraphicsWinMac 
+     -> PIGraphicsWinX
+
+->  PIGraphicsPS -> constructeur accepte un PSFile.
+
+
+=> toutes coords en float dans les draw
Index: /tags/DPC_V0/Poubelle/PI/pigraphmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphmac.cc	(revision 1307)
@@ -0,0 +1,535 @@
+#include <stdio.h>
+
+#include "pigraphmac.h"
+
+
+
+// #define DEBUG_PIBWDGX     Flag pour impression de debug etc ...
+
+/* --Methode-- */
+PIGraphicMac::PIGraphicMac(PIWdg* wdg)
+: PIGraphicGen(wdg)
+{
+  mPane = wdg->mPane;
+}
+
+/* --Methode-- */
+PIGraphicMac::~PIGraphicMac()
+{
+}
+
+/* --Methode-- */
+void PIGraphicMac::Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect theRect = {(int)y0, (int)x0, (int)y0+(int)dy, (int)x0+(int)dx};
+    ::EraseRect(&theRect);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
+{
+  if (!mPane->FocusDraw()) {
+    ::MoveTo(x, y);
+    LStr255 ps = s;
+    ::TextFont(applFont);
+    ::DrawString(ps);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
+{
+  if (mPane->FocusDraw()) {
+    ::MoveTo(x, y);
+    LStr255 ps = s;
+    ::TextFont(applFont);
+	Rect box;
+	box.left = x;
+	box.bottom = y;
+	int iWidth = TextWidth(s,0,strlen(s));
+	box.right = box.left + iWidth;
+	int z;
+	box.top = box.bottom + GetFontHeight(z,z);
+    ::TETextBox(s,strlen(s),&box,teForceLeft);
+  }
+}
+
+ 
+/* --Methode-- */
+void PIGraphicMac::DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
+{
+  if (mPane->FocusDraw()) {
+    ::MoveTo(x1,y1);
+    ::LineTo(x2,y2);
+  }
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect r = {y0, x0, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (r.top  > r.bottom) swap(r.top,  r.bottom);
+    if (r.left > r.right)  swap(r.left, r.right);
+    r.right++; r.bottom++;
+    ::FrameRect(&r);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect r = {y0, x0, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (r.top  > r.bottom) swap(r.top,  r.bottom);
+    if (r.left > r.right)  swap(r.left, r.right);
+    r.right++; r.bottom++;
+    ::PaintRect(&r);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)r, (int)x0-(int)r, (int)y0+(int)r, (int)x0+(int)r};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::FrameOval(&rr);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)r, (int)x0-(int)r, (int)y0+(int)r, (int)x0+(int)r};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::PaintOval(&rr);
+  }
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n)
+{
+  PolyHandle h = MakePoly(x,y,n);
+  if (h) {
+    ::FramePoly(h);
+    ::KillPoly(h);
+  }
+  
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n)
+{
+  PolyHandle h = MakePoly(x,y,n);
+  if (h) {
+    ::PaintPoly(h);
+    ::KillPoly(h);
+  }
+}
+
+/* --Methode-- */
+PolyHandle PIGraphicMac::MakePoly(PIGrCoord *x, PIGrCoord *y, int n)
+{
+  if (mPane->FocusDraw()) {
+    PolyHandle h = ::OpenPoly();
+    ::MoveTo(x[0], y[0]);
+    for (int i=1; i<n; i++) {
+      ::LineTo(x[i], y[i]);
+    }
+    ::MoveTo(x[0], y[0]);
+    ClosePoly();
+    return h;
+  }
+  return NULL;
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawMarker(PIGrCoord x0, PIGrCoord y0)
+{
+int hmsz = mMrkSz/2;
+int dmsz = mMrkSz-hmsz;
+PIGrCoord x[4],y[4];
+PILineAtt clatt;
+
+if (mMrk == PI_DotMarker) {
+  ::MoveTo( x0, y0);
+  ::Line(0,0);
+}
+
+else
+  {
+  clatt = mLAtt;
+  SelLine(PI_ThinLine);
+  switch (mMrk)
+    {
+    case  PI_PlusMarker :
+      DrawLine((int)x0-hmsz, y0, (int)x0+dmsz, y0);
+      DrawLine(x0, (int)y0-hmsz, x0, (int)y0+dmsz);
+      break;
+    case  PI_CrossMarker :
+      DrawLine((int)x0-hmsz, (int)y0-hmsz, (int)x0+dmsz, (int)y0+dmsz);
+      DrawLine((int)x0-hmsz, (int)y0+dmsz, (int)x0+dmsz, (int)y0-hmsz);
+      break;  
+    case PI_CircleMarker :
+      DrawCircle(x0, y0, hmsz);
+      break;
+    case PI_FCircleMarker :
+      DrawFCircle(x0, y0, hmsz);
+      break;
+    case PI_BoxMarker :
+      DrawBox((int)x0-hmsz, (int)y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case PI_FBoxMarker :
+      DrawFBox((int)x0-hmsz, (int)y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case  PI_TriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (int)x0-hmsz; y[0] = (int)y0+hmsz;  
+      DrawPolygon(x, y, 4);
+      break;
+    case  PI_FTriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (int)x0-hmsz; y[0] = (int)y0+hmsz;  
+      DrawFPolygon(x, y, 4);
+      break;
+    default :
+      ::MoveTo( x0, y0);
+      ::Line(0,0);
+      break;
+    }
+  SelLine(clatt);
+  }
+return;
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+{
+int i;
+
+if (n <= 0)  return;
+for(i=0; i<n; i++) DrawMarker(x[i], y[i]);
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                            int sx, int sy, PIColorMap* cmap)
+{
+  Rect	frame;
+  SetRect(&frame, 0, 0, sx, sy);
+  Rect dstFrame;
+  SetRect(&dstFrame, x, y, sx, sy);
+  GWorldPtr gWorld;
+  ThrowIfOSErr_(NewGWorld(&gWorld, 8, &frame, cmap->GetCTab(), nil, 0));
+  PixMapHandle pmh = GetGWorldPixMap(gWorld);
+  ::LockPixels (pmh);
+  Ptr pmap = GetPixBaseAddr(pmh);
+  memcpy(pmap, pix, sx*sy);
+  ::ForeColor (blackColor);
+  ::BackColor (whiteColor);
+  ::CopyBits((BitMap *) (*pmh),
+				&mPane->GetMacPort()->portBits,
+				&frame, &dstFrame, srcCopy, nil);
+  ::UnlockPixels (pmh);
+  DisposeGWorld(gWorld);
+}
+
+
+
+/* --Methode-- */
+void PIGraphicMac::SelForeground(PIColors col)
+{
+  if (mPane->FocusDraw()) {
+    long color;
+    switch (col) {
+      case PI_Black:
+        color = blackColor;
+        break;
+      case PI_White:
+        color = whiteColor;
+        break;
+      case PI_Red:
+        color = redColor;
+        break;
+      case PI_Blue:
+        color = blueColor;
+        break;
+      case PI_Green:
+        color = greenColor;
+        break;
+      case PI_Yellow:
+        color = yellowColor;
+        break;
+      default:
+        color = blackColor;
+    }
+    ::ForeColor(color);
+    mFCol = col;
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelBackground(PIColors col)
+{
+  if (mPane->FocusDraw()) {
+    long color;
+    switch (col) {
+      case PI_Black:
+        color = blackColor;
+        break;
+      case PI_White:
+        color = whiteColor;
+        break;
+      case PI_Red:
+        color = redColor;
+        break;
+      case PI_Blue:
+        color = blueColor;
+        break;
+      case PI_Green:
+        color = greenColor;
+        break;
+      case PI_Yellow:
+        color = yellowColor;
+        break;
+      default:
+        color = blackColor;
+    }
+    mBCol = col;
+    ::BackColor(color);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelForeground(PIColorMap& cmap, int cid)
+{
+  if (mPane->FocusDraw()) {
+    PIColor picol = cmap.GetColor(cid);
+    RGBColor qdCol;
+ 
+    qdCol.red   = picol.red;
+    qdCol.green = picol.green;
+    qdCol.blue  = picol.blue;
+
+    ::RGBForeColor(&qdCol);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelBackground(PIColorMap& cmap, int cid)
+{
+  if (mPane->FocusDraw()) {
+    PIColor picol = cmap.GetColor(cid);
+    RGBColor qdCol;
+ 
+    qdCol.red   = picol.red;
+    qdCol.green = picol.green;
+    qdCol.blue  = picol.blue;
+
+    ::RGBBackColor(&qdCol);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelGOMode(PIGOMode mod)
+{
+if (mod == mGOm)  return;
+  if (mPane->FocusDraw())
+    switch (mod)
+    {
+      case PI_GOCopy :
+        ::PenMode(patCopy);
+        mGOm = mod;
+        break;
+      case PI_GOXOR :
+        ::PenMode(patXor);
+        mGOm = mod;
+        break;
+    }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::SelFontSzPt(int npt, PIFontAtt att)
+{
+  if (mPane->FocusDraw()) {
+    ::TextFont(applFont);
+    ::TextSize(npt);
+    switch(att) {
+      case PI_RomanFont:
+        ::TextFace(0);
+        break;
+      case PI_BoldFont:
+        ::TextFace(bold);
+        break;
+      case PI_ItalicFont:
+        ::TextFace(italic);
+        break;
+    }
+  }
+  mFSize = npt;
+  mFAtt  = att;
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelFont(PIFontSize sz, PIFontAtt att)
+{
+  switch(sz) {
+      case PI_SmallSizeFont:
+        SelFontSzPt(9, att);
+        break;
+      case PI_NormalSizeFont:
+        SelFontSzPt(12, att);
+        break;
+      case PI_BigSizeFont:
+        SelFontSzPt(14, att);
+        break;
+  }
+}
+
+
+
+/* --Methode-- */
+void PIGraphicMac::SelLine(PILineAtt att)
+{
+  if (mPane->FocusDraw()) {
+    switch(att) {
+      case PI_NormalLine:
+        ::PenSize(1,1);
+        break;
+      case PI_ThinLine:
+        ::PenSize(1,1);  // Mettre en pointille, ou bien commentaire pour Laser ?
+        break;
+      case PI_ThickLine:
+        ::PenSize(2,2);
+        break;
+    }
+  }
+  mLAtt = att;
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::SelMarker(int msz, PIMarker mrk)
+{
+if (msz > 1)  { mMrk = mrk;  mMrkSz = msz; }
+else  { mMrk = PI_DotMarker;  mMrkSz = 1; }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+//$CHECK
+}
+
+/* --Methode-- */
+void PIGraphicMac::ClearClipRectangle()
+{ 
+//$CHECK
+}
+
+/* --Methode-- */
+PIColors  PIGraphicMac::GetForeground() 
+{
+return (mFCol);
+}
+
+/* --Methode-- */
+PIColors  PIGraphicMac::GetBackground() 
+{
+return (mBCol);
+}
+
+
+/* --Methode-- */
+PIGOMode   PIGraphicMac::GetGOMode()
+{
+return (mGOm);
+}
+
+/* --Methode-- */
+PIFontAtt  PIGraphicMac::GetFontAtt()
+{
+return (mFAtt);
+}
+
+/* --Methode-- */
+int        PIGraphicMac::GetFontSize()
+{
+return (mFSize);
+}
+
+/* --Methode-- */
+PILineAtt  PIGraphicMac::GetLineAtt()
+{
+return (mLAtt);
+}
+
+/* --Methode-- */
+PIMarker   PIGraphicMac::GetMarker()
+{
+return (mMrk);
+}
+
+/* --Methode-- */
+int        PIGraphicMac::GetMarkerSize()
+{
+return (mMrkSz);
+}
+
+/* --Methode-- */
+int        PIGraphicMac::GetFontHeight(int& asc, int& desc)   
+{
+  if (mPane->FocusDraw()) {
+    FontInfo info;
+    GetFontInfo(&info);
+    asc = info.ascent;
+    desc = info.descent;
+    return (asc + desc);
+  } else {
+    return 0;
+  }
+}
+
+/* --Methode-- */
+PIGrCoord PIGraphicMac::CalcStringWidth(char const* s)
+{
+//  if (mPane->FocusDraw())
+//    ::TextFont(applFont);
+  return ::TextWidth(s,0,strlen(s));
+}
+
+/* --Methode-- */
+void PIGraphicMac::SaveGraphicAtt()
+{  
+// Pour optimier l'implementation de PIBaseWdgGen
+
+// $CHECK$ faut faire quoi en plus de Gen ?
+PIGraphicGen::SaveGraphicAtt(); 
+return;
+}
+
+/* --Methode-- */
+void PIGraphicMac::RestoreGraphicAtt()
+{
+PIGraphicGen::RestoreGraphicAtt();
+}
+
+
+
+
+
+
Index: /tags/DPC_V0/Poubelle/PI/pigraphmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphmac.h	(revision 1307)
@@ -0,0 +1,79 @@
+#ifndef PIGRAPHICMAC_H_SEEN
+#define PIGRAPHICMAC_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphgen.h"
+
+class PIGraphicMac : public PIGraphicGen
+{
+public:
+                     PIGraphicMac(PIWdg* wdg);
+  virtual           ~PIGraphicMac();
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n);  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n);  
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap);
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black);
+  virtual void       SelBackground(PIColors col=PI_White);
+  virtual void       SelForeground(PIColorMap& cmap, int cid);
+  virtual void       SelBackground(PIColorMap& cmap, int cid);
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont);
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont);
+  virtual void       SelLine(PILineAtt att=PI_NormalLine);
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       ClearClipRectangle();
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PIFontAtt  GetFontAtt();
+  virtual int        GetFontSize();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+  virtual int        GetFontHeight(int& asc, int& desc);
+  virtual PIGrCoord  CalcStringWidth(char const* s);
+
+// Sauvegarde des attributs graphiques 
+  virtual void       SaveGraphicAtt();
+  virtual void       RestoreGraphicAtt();
+
+protected:
+  LPane* mPane;
+  
+  PolyHandle         MakePoly(PIGrCoord *x, PIGrCoord *y, int n);
+
+  PIColors  mFCol, mBCol;
+  PIGOMode  mGOm;
+  PIFontAtt mFAtt;
+  PILineAtt mLAtt;
+  int       mFSize;
+  PIMarker  mMrk;
+  int       mMrkSz;
+
+};
+
+typedef PIGraphicMac PIGraphicWin;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pigraphps.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphps.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphps.cc	(revision 1307)
@@ -0,0 +1,489 @@
+// Module PI : Peida Interactive     PIGraphicPS
+// Trace graphiques en PostScript    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+
+#include "pigraphps.h"
+
+//++
+// Class	PIGraphicPS
+// Lib		PI
+// include	pigraphps.h
+//
+//   	Classe les services de tracé graphique avec sortie PostScript
+//	Toutes les méthodes de tracé de "PIGraphic" sont redéfinies pour
+//	produire du PostScript 
+//--
+//++
+// Links	Parent
+// PIGraphic
+//--
+//++
+// Links	Voir aussi
+// PSFile
+//--
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIGraphicPS(PSFile * psf, double x0, double y0, double dx, double dy)
+//	Création d'un objet "PIGraphicPS" à partir d'un objet "PSFIle* psf".
+//	"(x0, y0)" détermine l'origine du nouveau bloc rectangulaire sur 
+//	la page et "dx, dy" l'extension du bloc. 
+// PIGraphicPS(PSFile * psf, PIWdg* wdg, double ofx, double ofy)
+//	Création d'un objet "PIGraphicPS" à partir d'un objet "PSFIle* psf"
+//|	x0 = wdg->XPos()+ofx    y0 = wdg->YPos()+ofy
+//|	dx = wdg->XSize()       dy = wdg->YSize()
+//
+// int kind()
+//	 Renvoie le type ("= PI_PSFileGraphics")
+//--
+
+/* --Methode-- */
+PIGraphicPS::PIGraphicPS(PSFile * psf, PIWdg* wdg, double ofx, double ofy)
+: PIGraphicGen()
+{
+BuildFromPSFile(psf, (double)wdg->XPos()+ofx, (double)wdg->YPos()+ofy, 
+                     (double)wdg->XSize(), (double)wdg->YSize() );  
+}
+
+/* --Methode-- */
+PIGraphicPS::PIGraphicPS(PSFile * psf, double x0, double y0, double dx, double dy)
+: PIGraphicGen()
+{
+BuildFromPSFile(psf, x0, y0, dx, dy);
+}
+
+/* --Methode-- */
+PIGraphicPS::~PIGraphicPS()
+{
+mPSOut->EndBloc();
+}
+
+/* --Methode-- */
+int PIGraphicPS::kind()
+{
+return PI_PSFileGraphics; 
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::BuildFromPSFile(PSFile * psf, double x0, double y0, double dx, double dy)
+{
+mPSOut = psf;
+
+mGOm = PI_GOCopy;
+
+mFCol = mBCol = PI_Grey;
+SelForeground(PI_Black);
+SelBackground(PI_White);
+mLAtt = PI_ThinLine;
+SelLine();
+mFAtt = PI_BoldFont;  mFSize = 0;
+SelFont();
+SelMarker(1, PI_DotMarker);
+
+if (psf) psf->NewBloc(x0, y0, dx, dy, dx, dy);
+mXmin = mYmin = 0.;
+mXmax = dx;  mYmax = dy;
+mFCfMap.red = mFCfMap.blue = mFCfMap.blue = 0;
+mBCfMap = mFCfMap; 
+}
+
+/* --Methode-- */
+void PIGraphicPS::GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax)
+{
+xmin = ymin = 0;  
+xmax = mXmax; ymax = mYmax;
+}
+
+/* --Methode-- */
+void PIGraphicPS::Erase(PIGrCoord, PIGrCoord, PIGrCoord, PIGrCoord)
+{
+// A Faire ??? $CHECK$ 
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+{
+if(mPSOut)
+  mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+{
+if(mPSOut)
+  mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
+return;
+}
+
+ 
+/* --Methode-- */
+void PIGraphicPS::DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
+{
+if(mPSOut)
+  mPSOut->DrawLine((double)x1,(double)y1,(double)x2,(double)y2,mFCol,mLAtt);
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+if(mPSOut)
+  mPSOut->DrawBox((double)x0,(double)y0,(double)dx,(double)dy,mFCol,mLAtt);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+if(mPSOut)
+  mPSOut->DrawFBox((double)x0,(double)y0,(double)dx,(double)dy, mFCol, mFCol, mLAtt);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+if(mPSOut)
+  mPSOut->DrawCircle((double)x0,(double)y0,(double)r,mFCol,mLAtt);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+if(mPSOut)
+  mPSOut->DrawFCircle((double)x0,(double)y0,(double)r,mFCol,mFCol,mLAtt);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+int i;
+double *xtmp;
+double *ytmp;
+
+if(! mPSOut) return;
+
+xtmp = new double[n];
+ytmp = new double[n];
+for(i = 0 ; i < n ; i++) {xtmp[i] = (double)x[i] ; ytmp[i] = (double)y[i] ; }
+//double xoff,yoff;
+//if (cinc) { xoff=yoff=0.; }   // Coord en mode incremental
+//else { xoff = (double)x[0];  yoff = (double)y[0]; }   //   Coord en mode absolu
+//xtmp[0] = (double)x[0];
+//ytmp[0] = (double)y[0];
+//for(i=1;i<n;i++) {
+//  xtmp[i] = (double)x[i]-xoff;
+//  ytmp[i] = (double)y[i]-yoff;
+//}
+mPSOut->DrawPolygon(xtmp,ytmp,n,mFCol,mLAtt,cinc);
+delete[] xtmp;
+delete[] ytmp;
+
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+int i;
+double *xtmp;
+double *ytmp;
+
+if(! mPSOut) return;
+
+xtmp = new double[n];
+ytmp = new double[n];
+for(i = 0 ; i < n ; i++) {xtmp[i] = (double)x[i] ; ytmp[i] = (double)y[i] ; }
+//double xoff,yoff;
+//if (cinc) { xoff=yoff=0.; }   // Coord en mode incremental
+//else { xoff = (double)x[0];  yoff = (double)y[0]; }   //   Coord en mode absolu
+//xtmp[0] = (double)x[0];
+//ytmp[0] = (double)y[0];
+//for(i=1;i<n;i++) {
+//  xtmp[i] = (double)x[i]-xoff;
+//  ytmp[i] = (double)y[i]-yoff;
+//}
+mPSOut->DrawFPolygon(xtmp,ytmp,n,mFCol,mFCol,mLAtt,cinc);
+delete[] xtmp;
+delete[] ytmp;
+
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double degfin)
+{
+// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double degfin)
+{
+// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawMarker(PIGrCoord x0, PIGrCoord y0)
+{
+if(mPSOut)
+  mPSOut->DrawMarker((double)x0,(double)y0,mMrk,mFCol,mMrkSz);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+{
+int i;
+double *xtmp;
+double *ytmp;
+
+if( !mPSOut)  return;
+
+xtmp = new double[n];
+ytmp = new double[n];
+for(i=0;i<n;i++){
+  xtmp[i] = (double)x[i];
+  ytmp[i] = (double)y[i];
+}
+mPSOut->DrawMarkers(xtmp,ytmp,n,mMrk,mFCol, mMrkSz);
+delete[] xtmp;
+delete[] ytmp;
+
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                            int sx, int sy, PIColorMap* cmap)
+{
+if ( (sx < 1) || (sy < 1) )  return;
+if ((pix == NULL) || (cmap == NULL)) return;
+if(mPSOut) 
+  mPSOut->Image((double)x, (double)y, (double)sx, (double)sy, sx, sy, pix, cmap);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelForeground(PIColors col)
+{
+mFCol = col;
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelBackground(PIColors col)
+{
+mBCol = col;
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelForeground(PIColorMap& cmap, int cid)
+{
+// A Faire Voir Nicolas  
+mFCfMap = cmap.GetColor(cid);
+mFCol = PI_ColorFromMap;
+mPSOut->SelForeground(cmap, cid) ; 
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelBackground(PIColorMap& cmap, int cid)
+{
+// A Faire Voir Nicolas  
+mBCfMap = cmap.GetColor(cid);
+mBCol = PI_ColorFromMap;
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelGOMode(PIGOMode mod)
+{
+mGOm = mod;
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelFontSzPt(int npt, PIFontAtt att)
+{
+mFSize = npt;
+mFAtt = att;
+return;
+}
+
+static int fntsz[5] = {8,10,12,14,16};
+
+/* --Methode-- */
+void PIGraphicPS::SelFont(PIFontSize sz, PIFontAtt att)
+{
+int i;
+switch (sz) {
+  case PI_SmallSizeFont:
+    i = 0;
+    break;
+  case PI_NormalSizeFont:
+    i = 2;
+    break;
+  case PI_BigSizeFont:
+    i = 4;
+    break;
+  default:
+    i=2;
+    break;
+  }
+mFSize = fntsz[i];
+mFAtt = att;
+return;
+}
+
+
+
+/* --Methode-- */
+void PIGraphicPS::SelLine(PILineAtt att)
+{
+mLAtt = att;
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::SelMarker(int msz, PIMarker mrk)
+{
+if (msz > 1)  { mMrk = mrk;  mMrkSz = msz; }
+else  { mMrk = PI_DotMarker;  mMrkSz = 1; }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::SetClipRectangle(PIGrCoord /*x0*/, PIGrCoord /*y0*/, PIGrCoord /*dx*/, PIGrCoord /*dy*/)
+{
+/*  $CHECK$  A FAIRE , voir Nicolas  */
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::ClearClipRectangle()
+{ 
+/*  $CHECK$  A FAIRE , voir Nicolas  */
+return;
+}
+
+/* --Methode-- */
+PIColors  PIGraphicPS::GetForeground() 
+{
+return (mFCol);
+}
+
+/* --Methode-- */
+PIColors  PIGraphicPS::GetBackground() 
+{
+return (mBCol);
+}
+
+
+/* --Methode-- */
+PIGOMode   PIGraphicPS::GetGOMode()
+{
+return (mGOm);
+}
+
+/* --Methode-- */
+PIFontAtt  PIGraphicPS::GetFontAtt()
+{
+return (mFAtt);
+}
+
+/* --Methode-- */
+int        PIGraphicPS::GetFontSize()
+{
+return (mFSize);
+}
+
+/* --Methode-- */
+PILineAtt  PIGraphicPS::GetLineAtt()
+{
+return (mLAtt);
+}
+
+/* --Methode-- */
+PIMarker   PIGraphicPS::GetMarker()
+{
+return (mMrk);
+}
+
+/* --Methode-- */
+int        PIGraphicPS::GetMarkerSize()
+{
+return (mMrkSz);
+}
+
+/* --Methode-- */
+int        PIGraphicPS::GetFontHeight(int& asc, int& desc)   
+{
+/*  $CHECK$  A refaire , voir Nicolas  */
+asc = mFSize; desc = 0; 
+return(asc+desc);
+}
+
+
+/* --Methode-- */
+PIGrCoord PIGraphicPS::CalcStringWidth(char const* s)
+{
+return((double)(mFSize*strlen(s)*0.5));   /*  facteur 0.5 ad'hoc $CHECK$  Voir Nicolas ! */
+}
+
+/* --Methode-- */
+void PIGraphicPS::SaveGraphicAtt()
+{  
+// Pour optimier l'implementation de PIBaseWdgGen
+sFCol = mFCol;    sBCol = mBCol;
+sGOm = mGOm;
+sFAtt = mFAtt;   sFSize = mFSize;
+sMrk = mMrk;   sMrkSz = mMrkSz;
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::RestoreGraphicAtt()
+{
+  if (sFCol != PI_ColorFromMap) SelForeground(sFCol);  
+// else    A faire Nicolas  
+  if (sBCol != PI_ColorFromMap) SelBackground(sBCol);
+// else    A faire Nicolas  
+  SelGOMode(sGOm);
+  SelFontSzPt(sFSize, sFAtt);
+  SelLine(sLAtt);
+  SelMarker(sMrkSz, sMrk);
+  return;
+}
+
+
+
+
+
Index: /tags/DPC_V0/Poubelle/PI/pigraphps.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphps.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphps.h	(revision 1307)
@@ -0,0 +1,93 @@
+#ifndef PIGRAPHICPS_H_SEEN
+#define PIGRAPHICPS_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphgen.h"
+#include "psfile.h"
+
+class PIGraphicPS : public PIGraphicGen
+{
+public:
+                     PIGraphicPS(PSFile * psf, PIWdg* wdg, double ofx=0., double ofy=0.);
+                     PIGraphicPS(PSFile * psf, double x0, double y0, double dx, double dy);
+  virtual           ~PIGraphicPS();
+
+  virtual int        kind();
+
+//  Espace des coordonnees
+  virtual void       GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax); 
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin);
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin);
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap);
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black);
+  virtual void       SelBackground(PIColors col=PI_White);
+  virtual void       SelForeground(PIColorMap& cmap, int cid);
+  virtual void       SelBackground(PIColorMap& cmap, int cid);
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont);
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont);
+  virtual void       SelLine(PILineAtt att=PI_NormalLine);
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       ClearClipRectangle();
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PIFontAtt  GetFontAtt();
+  virtual int        GetFontSize();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+  virtual int        GetFontHeight(int& asc, int& desc);
+  virtual PIGrCoord  CalcStringWidth(char const* s);
+
+// Sauvegarde des attributs graphiques 
+  virtual void       SaveGraphicAtt();
+  virtual void       RestoreGraphicAtt();
+
+protected:
+  void           BuildFromPSFile(PSFile * psf, double x0, double y0, double dx, double dy);
+
+  PSFile * mPSOut;  /* Fichier PostScript */
+  double mXmin, mYmin;
+  double mXmax, mYmax;
+
+  PIColors  mFCol, mBCol;
+  PIColor  mFCfMap, mBCfMap;
+  PIGOMode mGOm;
+  PIFontAtt mFAtt;
+  PILineAtt mLAtt;
+  int mFSize;
+  PIMarker mMrk;
+  int mMrkSz;
+};
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pigraphuc.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphuc.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphuc.cc	(revision 1307)
@@ -0,0 +1,754 @@
+// Module PI : Peida Interactive     PIGraphicUC 
+// Trace graphiques User-Coordinates    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pigraphuc.h"
+
+//++
+// Class	PIGraphicUC
+// Lib		PI
+// include	pigraphuc.h
+//
+//   	Classe fournissant les services de tracé graphique 
+//	en coordonnées utilisateur.
+//	Toutes les méthodes de tracé de "PIGraphic" sont redéfinies pour 
+//	accepter les arguments en système de coordonnées utilisateur.
+//--
+//++
+// Links	Parent
+// PIGraphic
+//--
+
+// Pour echanger deux valeurs PIGrCoord
+static inline void dbl_swap(double& a, double& b) { double tmp = a; a = b; b = tmp; }
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIGraphicUC(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Constructeur d'un objet "PIGraphUC" à partir d'un "PIGraphicGen* g". L'espace
+//	de travail du nouvel objet "PIGraphic" correspond au rectangle défini par
+//	"(x0,y0)" , "dx,dy" du "PIGraphic" de départ.
+// 
+// int  kind()
+//	Renvoie le type ("= PI_UCGraphics")
+// void SetBaseGraphic(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Permet de modifier l'objet "PIGraphic" de départ et l'espace graphique correspondant.
+//
+// void  SelFontSz(PIGrCoord sz, PIFontAtt att=PI_RomanFont)
+//	Sélection de fonte avec la taille exprimée en coordonnées utilisateur
+// void  SelMarkerSz(PIGrCoord msz, PIMarker mrk=PI_DotMarker)
+//	Sélection de marker avec la taille exprimée en coordonnées utilisateur
+//--
+
+/* --Methode-- */
+PIGraphicUC::PIGraphicUC(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+  : PIGraphicGen()
+{
+  mGrC = g;
+  xW0 = x0;  yW0 = y0; 
+  xWd = dx;  yWd = dy; 
+  aXdir = false;  // Vrai si Axe X de Droite vers Gauche 
+  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
+  SetUCS(0., 1., 0., 1., kAxeDirLtoR, kAxeDirDownUp);
+  clip = true;  
+}
+
+/* --Methode-- */
+PIGraphicUC::~PIGraphicUC()
+{
+}
+
+/* --Methode-- */
+int PIGraphicUC::kind() 
+{
+return PI_UCGraphics; 
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SetBaseGraphic(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  mGrC = g;
+  xW0 = x0;  yW0 = y0; 
+  xWd = dx;  yWd = dy; 
+  SetUCS(xMin, xMax, yMin, yMax, kAxeDirSame, kAxeDirSame);
+}
+
+/* --Methode-- */
+void PIGraphicUC::GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax)
+{
+xmin = xMin;  ymin = yMin;  
+xmax = xMax;  ymax = yMax;
+}
+
+//++
+// Titre	Système de coordonnées utilisateur
+//--
+//++
+// void       SetUCS(double xmin, double xmax, double ymin, double ymax, -
+// int axrl=kAxeDirSame, int ayud=kAxeDirSame)
+//	Définit le système de coordonnées utilisateur. Axe X de "xmin" à "xmax" , 
+//	Axe Y de "ymin" à "ymax". "axrl", "ayud" définit le sens des axes 
+//	sur la fenêtre :
+//|	kAxeDirSame : Pas de changement de sens
+//|	kAxeDirLtoR : Axe X croissant de gauche à droite   
+//|	kAxeDirRtoL : Axe X croissant de droite à gauche 
+//|	kAxeDirDownUp : Axe Y croissant de Bas vers Haut
+//|	kAxeDirUpDown : Axe Y croissant de Haut vers Bas
+//|	kAxeDirAuto : Sens determine a partir de la valeur relative de xmin, xmax, ymin, ymax
+//|	              xmin < xmax : kAxeDirLtoR   -  xmax < xmin : kAxeDirRtoL
+//|	              ymin < ymax : kAxeDirDownUp -  ymax < ymin : kAxeDirUpDown
+//	Par défaut : "xmin=ymin=0." , "ymin=ymax=0." , "kAxeDirLtoR" , "kAxeDirDownUp"
+// 
+// void  UC2GrC(double x, double y, double& xpix, double& ypix)
+//	Transformation de coordonnées utilisateur "(x,y)" en coordoonnées 
+//	de l'espace graphic de départ "(xpix, ypix)"
+// void  GrC2UC(double xpix, double ypix, double& x, double& y)
+//	Transformation de coordonnées de l'espace graphic de départ. en coordonnées utilisateur.
+// void  DUC2GrC(double dx, double dy, double& dxpix, double& dypix)
+//	Transformation de distances selon X,Y en coordonnées utilisateur "dx, dy" en distance
+//	dans l'espace graphique de départ "dxpix , dypix".
+// void  DGrC2UC(double dxpix, double dypix, double& dx, double& dy)
+//	Transformation de distances selon X,Y dans l'espace graphique de départ en distance
+//	dans l'espace de  coordonnées utilisateur.
+//--
+
+/* --Methode-- */
+void PIGraphicUC::SetUCS(double xmin, double xmax, double ymin, double ymax,
+                         int axrl, int ayud)
+{
+
+  if (axrl == kAxeDirAuto) {
+    double ff;
+    if (xmax < xmin)  { axrl = kAxeDirRtoL;   ff=xmin;  xmin=xmax;  xmax=ff; }
+    else  axrl = kAxeDirLtoR;
+  }
+  if (ayud == kAxeDirAuto) {
+    double ff;
+    if (ymax < ymin)  { ayud = kAxeDirUpDown;   ff=ymin;  ymin=ymax;  ymax=ff; }
+    else  ayud = kAxeDirDownUp;
+  }
+
+  if (xmax <= xmin  || ymax <= ymin)
+    return; // $CHECK$ exception ?
+  if (axrl == kAxeDirLtoR)  aXdir = false;
+  else if (axrl == kAxeDirRtoL)  aXdir = true;
+  if (ayud == kAxeDirDownUp)  aYdir = false;
+  else if (ayud == kAxeDirUpDown)  aYdir = true;
+  xMin = xmin;
+  xMax = xmax;
+  yMin = ymin;
+  yMax = ymax;
+
+  xScale = xWd/(xMax-xMin);
+  if (xScale < 1.e-19)  xScale = 1.e-19;  // Protection 
+  if (aXdir)  { 
+    xScale = -xScale;
+    xOrg   = -xMax * xScale;
+  }
+  else xOrg   = -xMin * xScale;
+  xOrg += xW0;
+
+  yScale = yWd/(yMax-yMin);
+  if (yScale < 1.e-19)  yScale = 1.e-19;  // Protection 
+  if (!aYdir) {
+    yScale = -yScale;
+    yOrg   = -yMax  * yScale;
+    }
+  else yOrg   = -yMin * yScale;
+  yOrg += yW0;
+  return;
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::UC2GrC(double x, double y, double& xpix, double& ypix)
+{
+  xpix = (double)(xOrg + x*xScale);  
+  ypix = (double)(yOrg + y*yScale);  
+}
+
+/* --Methode-- */
+void PIGraphicUC::GrC2UC(double xpix, double ypix, double& x, double& y)
+{
+  x = (xpix-xOrg)/xScale;
+  y = (ypix-yOrg)/yScale;
+}
+
+/* --Methode-- */
+void PIGraphicUC::DUC2GrC(double dx, double dy, double& dxpix, double& dypix)
+{
+  dxpix = dx*xScale;
+  if (dxpix < 0)  dxpix = -dxpix;
+  dypix = dy*yScale;
+  if (dypix < 0)  dypix = -dypix;
+}
+
+/* --Methode-- */
+void PIGraphicUC::DGrC2UC(double dxpix, double dypix, double& dx, double& dy)
+{
+  dx = dxpix/xScale;
+  dy = dypix/yScale;
+  if (dx < 0.) dx = -dx;
+  if (dy < 0.) dy = -dy;
+}
+
+/* --Methode-- */
+void PIGraphicUC::Erase(PIGrCoord xc, PIGrCoord yc, PIGrCoord dxc, PIGrCoord dyc)
+{
+  if (!mGrC) return;
+  double x, y, dx, dy;
+  x = xc;  dx = dxc;
+  y = yc;  dy = dyc;
+  if (clip) {
+    if (dx < 0) {
+      x = x+dx;
+      dx = -dx;
+    }
+    if (dy < 0) {
+      y = y+dy;
+      dy = -dy;
+    }
+    if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
+    if (x < xMin) {
+      dx -= (xMin-x);
+      x = xMin;
+    }
+    if (y < yMin) {
+      dy -= (yMin-y);
+      y = yMin;
+    }
+    if (x+dx > xMax)
+      dx = (xMax-x);
+    if (y+dy > yMax)
+      dy = (yMax-y);
+  }
+
+  double xf, yf, xf2, yf2;
+  UC2GrC(x, y, xf, yf);
+  UC2GrC(x+dx, y+dy, xf2, yf2);
+  if (xf2 < xf)  dbl_swap(xf, xf2);
+  if (yf2 < yf)  dbl_swap(yf, yf2);
+  mGrC->Erase(xf, yf, xf2-xf, yf2-yf);
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  UC2GrC(x, y, xf, yf);
+  mGrC->DrawString(xf, yf, s, pos);  
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  UC2GrC(x, y, xf, yf);
+  mGrC->DrawOpaqueString(xf, yf, s, pos);  
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawLine(PIGrCoord xc1, PIGrCoord yc1, PIGrCoord xc2, PIGrCoord yc2)
+{
+  
+  if (!mGrC) return;
+  double x1, y1, x2, y2;
+  x1 = xc1;  y1 = yc1;
+  x2 = xc2;  y2 = yc2;
+  if (clip) {
+    if (x2 < xMin && x1 < xMin) return;
+    if (x2 > xMax && x1 > xMax) return;
+    if (y1 < yMin && y2 < yMin) return;
+    if (y1 > yMax && y2 > yMax) return;
+    if (x2 < x1) {
+      dbl_swap(x1,x2);
+      dbl_swap(y1,y2);
+    }
+    if (x2>xMax) {
+      y2 = y1 + (y2-y1)/(x2-x1)*(xMax-x1);
+      x2 = xMax;
+    }
+    if (x1<xMin) {
+      y1 = y2 + (y1-y2)/(x1-x2)*(xMin-x2);
+      x1 = xMin;
+    }
+    if (y2 < y1) {
+      dbl_swap(x1,x2);
+      dbl_swap(y1,y2);
+    }
+    if (y2>yMax) {
+      x2 = x1 + (x2-x1)/(y2-y1)*(yMax-y1);
+      y2 = yMax;
+    }
+    if (y1<yMin) {
+      x1 = x2 + (x1-x2)/(y1-y2)*(yMin-y2);
+      y1 = yMin;
+    }
+  }
+
+  double xf1, yf1, xf2, yf2;
+  UC2GrC(x1, y1, xf1, yf1);
+  UC2GrC(x2, y2, xf2, yf2);
+  mGrC->DrawLine(xf1, yf1, xf2, yf2);
+
+}  
+
+
+/* --Methode-- */
+void PIGraphicUC::DrawBox(PIGrCoord xc, PIGrCoord yc, PIGrCoord dxc, PIGrCoord dyc)
+{
+  if (!mGrC) return;
+  double x, y, dx, dy;
+  x = xc;  dx = dxc;
+  y = yc;  dy = dyc;
+  if (clip) {
+    if (dx < 0) {
+      x = x+dx;
+      dx = -dx;
+    }
+    if (dy < 0) {
+      y = y+dy;
+      dy = -dy;
+    }
+    if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
+    if (x < xMin) {
+      dx -= (xMin-x);
+      x = xMin;
+    }
+    if (y < yMin) {
+      dy -= (yMin-y);
+      y = yMin;
+    }
+    if (x+dx > xMax)
+      dx = (xMax-x);
+    if (y+dy > yMax)
+      dy = (yMax-y);
+  }
+
+  double xf, yf, xf2, yf2;
+  UC2GrC(x, y, xf, yf);
+  UC2GrC(x+dx, y+dy, xf2, yf2);
+  if (xf2 < xf)  dbl_swap(xf, xf2);
+  if (yf2 < yf)  dbl_swap(yf, yf2);
+  mGrC->DrawBox(xf, yf, xf2-xf, yf2-yf);
+}  
+
+/* --Methode-- */
+void PIGraphicUC::DrawFBox(PIGrCoord xc, PIGrCoord yc, PIGrCoord dxc, PIGrCoord dyc)
+{
+  if (!mGrC) return;
+  double x, y, dx, dy;
+  x = xc;  dx = dxc;
+  y = yc;  dy = dyc;
+  if (clip) {
+    if (dx < 0) {
+      x = x+dx;
+      dx = -dx;
+    }
+    if (dy < 0) {
+      y = y+dy;
+      dy = -dy;
+    }
+    if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
+    if (x < xMin) {
+      dx -= (xMin-x);
+      x = xMin;
+    }
+    if (y < yMin) {
+      dy -= (yMin-y);
+      y = yMin;
+    }
+    if (x+dx > xMax)
+      dx = (xMax-x);
+    if (y+dy > yMax)
+      dy = (yMax-y);
+  }
+
+  double xf, yf, xf2, yf2;
+  UC2GrC(x, y, xf, yf);
+  UC2GrC(x+dx, y+dy, xf2, yf2);
+  if (xf2 < xf)  dbl_swap(xf, xf2);
+  if (yf2 < yf)  dbl_swap(yf, yf2);
+  mGrC->DrawFBox(xf, yf, xf2-xf, yf2-yf);
+}  
+
+/* --Methode-- */
+void PIGraphicUC::DrawCircle(PIGrCoord x, PIGrCoord y, PIGrCoord r)
+{
+  if (!mGrC) return;
+
+  double xf, yf, rf,rfy;
+  UC2GrC(x, y, xf, yf);
+  DUC2GrC(r,r,rf,rfy);
+  rf = 0.5*(rf+rfy);
+  mGrC->DrawCircle(xf, yf, rf);
+}  
+
+/* --Methode-- */
+void PIGraphicUC::DrawFCircle(PIGrCoord x, PIGrCoord y, PIGrCoord r)
+{
+  if (!mGrC) return;
+
+  double xf, yf, rf, rfy;
+  UC2GrC(x, y, xf, yf);
+  DUC2GrC(r,r,rf,rfy);
+  rf = 0.5*(rf+rfy);
+  mGrC->DrawFCircle(xf, yf, rf);
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (!mGrC) return;
+
+  double xf, yf, dxf, dyf;
+  UC2GrC(x0, y0, xf, yf);
+  DUC2GrC(dx, dy, dxf, dyf);
+  mGrC->DrawOval(xf, yf, dxf, dyf);
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (!mGrC) return;
+
+  double xf, yf, dxf, dyf;
+  UC2GrC(x0, y0, xf, yf);
+  DUC2GrC(dx, dy, dxf, dyf);
+  mGrC->DrawFOval(xf, yf, dxf, dyf);
+}
+
+#define NMXMULTP  30   // Pour multipoint sans new
+
+/* --Methode-- */
+void PIGraphicUC::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    UC2GrC(x[i], y[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawPolygon(pxc, pyc, n, cinc);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+  
+/* --Methode-- */
+void PIGraphicUC::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    UC2GrC(x[i], y[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawFPolygon(pxc, pyc, n, cinc);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                          double degdeb, double degfin)
+{
+  if (!mGrC) return;
+
+  double xf, yf, dxf, dyf;
+  UC2GrC(x0, y0, xf, yf);
+  DUC2GrC(dx, dy, dxf, dyf);
+  mGrC->DrawArc(xf, yf, dxf, dyf, degdeb, degfin);
+}
+/* --Methode-- */
+void PIGraphicUC::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                           double degdeb, double degfin)
+{
+  if (!mGrC) return;
+
+  double xf, yf, dxf, dyf;
+  UC2GrC(x0, y0, xf, yf);
+  DUC2GrC(dx, dy, dxf, dyf);
+  mGrC->DrawFArc(xf, yf, dxf, dyf, degdeb, degfin);
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawMarker(PIGrCoord x0, PIGrCoord y0)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  UC2GrC(x0, y0, xf, yf);
+  mGrC->DrawMarker(xf, yf);
+  return;
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    UC2GrC(x[i], y[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawMarkers(pxc, pyc, n);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
+                        int sx, int sy, PIColorMap* cmap)
+{
+  if (!mGrC) return;
+  if ( (sx < 1) || (sy < 1) )  return;
+  if ((pix == NULL) || (cmap == NULL)) return; 
+  double xf,yf;
+  UC2GrC(x, y, xf, yf);
+  mGrC->DrawPixmap(xf, yf, pix, sx, sy, cmap);
+}
+
+
+
+/* --Methode-- */
+void PIGraphicUC::SelForeground(PIColors col)
+{
+  if (!mGrC) return;
+  mGrC->SelForeground(col);
+  return;  
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SelBackground(PIColors col)
+{
+  if (!mGrC) return;
+  mGrC->SelBackground(col);
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelForeground(PIColorMap& cmap, int cid)
+{
+  if (!mGrC) return;
+  mGrC->SelForeground(cmap, cid);
+  return;  
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SelBackground(PIColorMap& cmap, int cid)
+{
+  if (!mGrC) return;
+  mGrC->SelBackground(cmap, cid);
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelGOMode(PIGOMode mod)
+{
+  if (!mGrC) return;
+  mGrC->SelGOMode(mod);
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelFont(PIFontSize sz, PIFontAtt att)
+{
+  if (!mGrC) return;
+  mGrC->SelFont(sz, att);
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelFontSzPt(int npt, PIFontAtt att)
+{
+  if (!mGrC) return;
+  mGrC->SelFontSzPt(npt, att);
+  return;  
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SelLine(PILineAtt att)
+{
+  if (!mGrC) return;
+  mGrC->SelLine(att);
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelMarker(int msz, PIMarker mrk)
+{
+  if (!mGrC) return;
+  mGrC->SelMarker( msz, mrk);
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelFontSz(PIGrCoord sz, PIFontAtt att)
+{
+  if (!mGrC) return;
+  double fx, fy;
+  DUC2GrC((double)sz, (double)sz, fx, fy);
+  int npt = (int)fy;
+  if (npt < 8) npt = 8;
+  if (npt > 127) npt = 127;
+  mGrC->SelFontSzPt(npt, att);
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SelMarkerSz(PIGrCoord sz, PIMarker mrk)
+{
+  if (!mGrC) return;
+  double fx, fy;
+  DUC2GrC((double)sz, (double)sz, fx, fy);
+  int isz = int(0.5*(fx+fy+1));
+  mGrC->SelMarker( isz, mrk);
+}
+
+/* --Methode-- */
+void PIGraphicUC::SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  /* $CHECK$  A faire Reza 08/02/97  */
+return;
+}
+/* --Methode-- */
+void PIGraphicUC::ClearClipRectangle()
+{
+  /* $CHECK$  A faire Reza 08/02/97  */
+return;
+}
+
+/* --Methode-- */
+PIColors PIGraphicUC::GetForeground()
+{
+  if (!mGrC) return(PI_NotDefColor);
+  return(mGrC->GetForeground());
+}
+
+/* --Methode-- */
+PIColors PIGraphicUC::GetBackground()
+{
+  if (!mGrC) return(PI_NotDefColor);
+  return(mGrC->GetBackground());
+}
+
+/* --Methode-- */
+PIGOMode PIGraphicUC::GetGOMode()
+{
+  if (!mGrC) return(PI_GOCopy);
+  return(mGrC->GetGOMode());
+}
+
+/* --Methode-- */
+PIFontAtt PIGraphicUC::GetFontAtt()
+{
+  if (!mGrC) return(PI_NotDefFontAtt);
+  return(mGrC->GetFontAtt());
+}
+
+/* --Methode-- */
+int PIGraphicUC::GetFontSize()
+{
+  if (!mGrC) return(0);
+  return(mGrC->GetFontSize());
+}
+
+/* --Methode-- */
+PILineAtt PIGraphicUC::GetLineAtt()
+{
+  if (!mGrC) return(PI_NotDefLineAtt);
+  return(mGrC->GetLineAtt());
+}
+
+/* --Methode-- */
+PIMarker PIGraphicUC::GetMarker()
+{
+  if (!mGrC) return(PI_NotDefMarker);
+  return(mGrC->GetMarker());
+}
+
+/* --Methode-- */
+int PIGraphicUC::GetMarkerSize()
+{
+  if (!mGrC) return(0);
+  return(mGrC->GetMarkerSize());
+}
+/* --Methode-- */
+PIGrCoord PIGraphicUC::GetFontHeightUC(PIGrCoord& asc, PIGrCoord& desc)
+{
+  asc = desc = 0;
+  if (!mGrC) return(0);
+  int h,a,d;
+  double fh, fa, fd, x;
+  h = mGrC->GetFontHeight(a, d) ;
+  DGrC2UC(0., h, x, fh);
+  DGrC2UC(0., a, x, fa);
+  DGrC2UC(0., d, x, fd);
+  asc = a;  desc = d;
+  return(fh);
+}
+
+/* --Methode-- */
+int PIGraphicUC::GetFontHeight(int& asc, int& desc)
+{
+  asc = desc = 0;
+  if (!mGrC) return(0);
+  return( mGrC->GetFontHeight(asc, desc) );
+}
+
+/* --Methode-- */
+PIGrCoord PIGraphicUC::CalcStringWidth(char const* s)
+{
+  if (!mGrC) return(0.);
+  double dx = mGrC->CalcStringWidth(s);
+  double dxx, dxy;
+  DGrC2UC(dx, dx, dxx, dxy);
+  return(dxx);
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SaveGraphicAtt()
+{
+  if (!mGrC) return;
+  mGrC->SaveGraphicAtt();
+}
+
+/* --Methode-- */
+void PIGraphicUC::RestoreGraphicAtt()
+{
+  if (!mGrC) return;
+  mGrC->RestoreGraphicAtt();
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pigraphuc.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphuc.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphuc.h	(revision 1307)
@@ -0,0 +1,121 @@
+// Module PI : Peida Interactive     PIGraphicUC 
+// Trace graphiques User-Coordinates    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIGRAPHICUC_H_SEEN
+#define PIGRAPHICUC_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphgen.h"
+
+enum {
+  kAxeDirSame     = 0,
+  kAxeDirLtoR     = 1,
+  kAxeDirRtoL     = 2,
+  kAxeDirDownUp   = 4,
+  kAxeDirUpDown   = 8,
+  kAxeDirAuto     = 255
+};
+
+class PIGraphicUC : public PIGraphicGen
+{
+public:
+                     PIGraphicUC(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual           ~PIGraphicUC();
+
+  virtual int        kind();
+
+  virtual void       SetBaseGraphic(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+
+//  Espace des coordonnees
+  virtual void       GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax);
+
+//  Definition des coordonnees utilisateur
+  virtual void       SetUCS(double xmin, double xmax, double ymin, double ymax,
+                            int axrl=kAxeDirSame, int ayud=kAxeDirSame);     
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin);
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin);
+ 
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap);
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black);
+  virtual void       SelBackground(PIColors col=PI_White);
+  virtual void       SelForeground(PIColorMap& cmap, int cid);
+  virtual void       SelBackground(PIColorMap& cmap, int cid);
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont);
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont);
+  virtual void       SelLine(PILineAtt att=PI_NormalLine);
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);
+
+//  Fonctions specifiques a PIGraphicUC :
+  virtual void       SelFontSz(PIGrCoord sz, PIFontAtt att=PI_RomanFont);
+  virtual void       SelMarkerSz(PIGrCoord msz, PIMarker mrk=PI_DotMarker);
+  virtual PIGrCoord  GetFontHeightUC(PIGrCoord& asc, PIGrCoord& desc);
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       ClearClipRectangle();
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PIFontAtt  GetFontAtt();
+  virtual int        GetFontSize();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+  virtual int	     GetFontHeight(int& asc, int& desc);
+  virtual PIGrCoord  CalcStringWidth(char const* s);
+
+// Sauvegarde des attributs graphiques 
+  virtual void       SaveGraphicAtt();
+  virtual void       RestoreGraphicAtt();
+
+//  Transformation des ccordonnees
+  virtual void       UC2GrC(double x, double y, double& xpix, double& ypix);
+  virtual void       GrC2UC(double xpix, double ypix, double& x, double& y);
+  virtual void       DUC2GrC(double dx, double dy, double& dxpix, double& dypix);
+  virtual void       DGrC2UC(double dxpix, double dypix, double& dx, double& dy);
+
+  void   NoClip() {clip = false; }
+  void   Clip() {clip = true; }
+  inline PIGraphicGen*  BaseGraphic() { return(mGrC); }
+
+protected:
+
+  PIGraphicGen* mGrC;
+
+  double xMin, xMax, yMin, yMax; // Valeurs en unites user
+  double xOrg, yOrg;             // Position en pixels de (0.0, 0.0)
+  double xScale, yScale;         // Pixels par unites graphiques
+  double xW0, yW0, xWd, yWd;        // Origine/largeur ds la fenetre de trace
+  bool   aXdir, aYdir;           // Sens des axes horiz, vertical 
+  bool   clip;
+};
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pigraphx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphx.cc	(revision 1307)
@@ -0,0 +1,875 @@
+// Module PI : Peida Interactive     PIGraphicX
+// Trace graphiques- Implementation X11  R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include "pigraphx.h"
+
+
+/*  Variables globales pour modifier les GC  */
+#define NMAXFONTSZ  7
+static XFontStruct * fntst[NMAXFONTSZ][3];
+static int fntsz[NMAXFONTSZ] = {8,10,12,14,18,24,36};
+static int SmallFontIndex = 1; 
+static int NormalFontIndex = 3;
+static int BigFontIndex = 5;
+static int HugeFontIndex = 6;
+static  PIFontAtt fntatt[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont }; 
+#define NMAXCOL  16
+static  PIXColor colpix[NMAXCOL];
+
+/*  GC pour DrawPixmap   */
+static GC dpxgc;
+
+// #define DEBUG_PIBWDGX     Flag pour impression de debug etc ...
+
+/* --Methode-- */
+PIGraphicX::PIGraphicX(PIWdg* wdg)
+: PIGraphicGen(wdg)
+{
+
+GlInit();
+
+if (MyWdg()) {
+  mDisp = XtDisplay(MyWdg());       // Structure Display X associe
+  mWId = XtWindow(MyWdg());   // Le drawable X
+  }
+else mDisp = PIXDisplay();       // Structure Display X associe
+
+XGCValues  xgv;
+xgv.function = GXcopy;
+xgv.plane_mask = ~0;
+mDefGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), GCFunction | GCPlaneMask, &xgv);
+
+Init();
+}
+
+/* --Methode-- */
+PIGraphicX::PIGraphicX(PIScreenBuffer* grb)
+: PIGraphicGen(grb)
+{
+GlInit();
+
+mDisp = PIXDisplay();       // Structure Display X associe
+mWId = grb->XScrBuffer();
+
+XGCValues  xgv;
+xgv.function = GXcopy;
+xgv.plane_mask = ~0;
+mDefGC = XCreateGC (mDisp, mWId, GCFunction | GCPlaneMask, &xgv);
+Init();
+}
+
+
+/* --Methode-- */
+void PIGraphicX::Init()
+{
+mGOm = PI_GOCopy;
+mFCol = mBCol = PI_Grey;
+SelForeground(PI_Black);
+SelBackground(PI_White);
+mLAtt = PI_ThinLine;
+SelLine();
+mFAtt = PI_BoldFont;  mFSize = 0;
+SelFont();
+SelMarker(1, PI_DotMarker);  
+mFCfMap = colpix[PI_Black];  mBCfMap = colpix[PI_White];
+}
+
+/* --Methode-- */
+PIGraphicX::~PIGraphicX()
+{
+XFreeGC(mDisp, mDefGC);
+}
+
+/* --Methode-- */
+int PIGraphicX::kind()
+{
+if (myWdg != NULL) return (PI_ScrWindowGraphics);
+else if (myGrb != NULL) return (PI_ScrBufferGraphics);
+else return(PI_UnknownGraphics);
+}
+
+/* --Methode-- */
+void PIGraphicX::TerminateInit()
+{
+if (MyWdg() == NULL)  { fprintf(stderr, "BUG/PIGraphicX::TerminateInit() for NULL Wdg \n"); return; }
+mDisp = XtDisplay(MyWdg());       // Structure Display X associe
+mWId = XtWindow(MyWdg());   // Le drawable X
+}
+
+/* --Methode-- */
+void PIGraphicX::Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+XClearArea (mDisp,mWId, (int)x0, (int)y0, (int)dx, (int)dy, False );
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+{
+XDrawString (XtDisplay (MyWdg()),mWId, 
+                  DefGC(), (int)x, (int)y, s, strlen(s));
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+{
+XDrawImageString (XtDisplay (MyWdg()),mWId, 
+                  DefGC(), (int)x, (int)y, s, strlen(s));
+return;
+}
+
+ 
+/* --Methode-- */
+void PIGraphicX::DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
+{
+XDrawLine(XtDisplay (MyWdg()), mWId, DefGC(), (int)x1, (int)y1, (int)x2, (int)y2);
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+int ix0 = x0;
+int iy0 = y0;
+int idx = dx;
+int idy = dy;
+if (idx < 0)  { ix0 += idx;  idx = -idx; }
+if (idy < 0)  { iy0 += idy;  idy = -idy; }
+XDrawRectangle(XtDisplay (MyWdg()), mWId, 
+               DefGC(), ix0, iy0, idx, idy);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+int ix0 = x0;
+int iy0 = y0;
+int idx = dx;
+int idy = dy;
+if (idx < 0)  { ix0 += idx;  idx = -idx; }
+if (idy < 0)  { iy0 += idy;  idy = -idy; }
+XFillRectangle(XtDisplay (MyWdg()), mWId, 
+               DefGC(), ix0, iy0, idx, idy);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+XDrawArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0-(int)r, (int)y0-(int)r, 2*(int)r, 2*(int)r, 0, 360*64);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+XFillArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0-(int)r, (int)y0-(int)r, 2*(int)r, 2*(int)r, 0, 360*64);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+XDrawArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0, (int)y0, (int)dx, (int)dy, 0, 360*64);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+XFillArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0, (int)y0, (int)dx, (int)dy, 0, 360*64);
+return;
+}
+
+// Pour les fonctions de trace avec un plusieurs coordonnees
+#define NMXXPOINTS  30 
+
+/* --Methode-- */
+void PIGraphicX::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+XPoint multipoint[NMXXPOINTS];
+XPoint *pxp;
+int i;
+
+if (n <= 0)  return;
+if (n > NMXXPOINTS)  pxp = new XPoint[n];
+else pxp = multipoint;
+for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; } 
+int mode = CoordModeOrigin;
+if (cinc) mode =  CoordModePrevious;
+XDrawLines(mDisp, mWId, DefGC(), pxp, n, mode);
+if (n > NMXXPOINTS)  delete[] pxp;
+
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+XPoint multipoint[NMXXPOINTS];
+XPoint *pxp;
+int i;
+
+if (n <= 0)  return;
+if (n > NMXXPOINTS)  pxp = new XPoint[n];
+else pxp = multipoint;
+for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; } 
+int mode = CoordModeOrigin;
+if (cinc) mode =  CoordModePrevious;
+XFillPolygon(XtDisplay (MyWdg()), mWId, DefGC(), pxp, n, 
+                        Complex, mode);
+if (n > NMXXPOINTS)  delete[] pxp;
+
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                         double degdeb, double degfin)
+{
+XDrawArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(degfin*64.));
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                         double degdeb, double degfin)
+{
+XFillArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(degfin*64.));
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawMarker(PIGrCoord x0, PIGrCoord y0)
+{
+float hmsz = mMrkSz/2;
+float dmsz = mMrkSz-hmsz;
+PIGrCoord x[4],y[4];
+PILineAtt clatt;
+
+if (mMrk == PI_DotMarker)
+  XDrawPoint(mDisp, mWId, DefGC(), (int)x0, (int)y0);
+
+else  {
+  clatt = mLAtt;
+  SelLine(PI_ThinLine);
+  switch (mMrk) {
+    case  PI_PlusMarker :
+      DrawLine((float)x0-hmsz, y0, (float)x0+dmsz, y0);
+      DrawLine(x0, (float)y0-hmsz, x0, (float)y0+dmsz);
+      break;
+    case  PI_CrossMarker :
+      DrawLine((float)x0-hmsz, (float)y0-hmsz, (float)x0+dmsz, (float)y0+dmsz);
+      DrawLine((float)x0-hmsz, (float)y0+dmsz, (float)x0+dmsz, (float)y0-hmsz);
+      break;  
+    case PI_CircleMarker :
+      DrawCircle(x0, y0, hmsz);
+      break;
+    case PI_FCircleMarker :
+      DrawFCircle(x0, y0, hmsz);
+      break;
+    case PI_BoxMarker :
+      DrawBox((float)x0-hmsz, (float)y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case PI_FBoxMarker :
+      DrawFBox((float)x0-hmsz, (float)y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case  PI_TriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (float)x0-hmsz; y[0] = (float)y0+hmsz;  
+      DrawPolygon(x, y, 4);
+      break;
+    case  PI_FTriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (float)x0-hmsz; y[0] = (float)y0+hmsz;  
+      DrawFPolygon(x, y, 4);
+      break;
+    default :
+      XDrawPoint(mDisp, mWId, DefGC(), x0, y0);
+      break;
+    }
+  SelLine(clatt);
+  }
+
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+{
+int i;
+if (n <= 0)  return;
+if (mMrk == PI_DotMarker)
+  {
+  XPoint multipoint[NMXXPOINTS];
+  XPoint *pxp;
+  if (n > NMXXPOINTS)  pxp = new XPoint[n];
+  else pxp = multipoint;
+  for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; } 
+  XDrawPoints(mDisp, mWId, DefGC(), pxp, n, CoordModeOrigin);
+  if (n > NMXXPOINTS)  delete[] pxp;  
+  }
+else for(i=0; i<n; i++) DrawMarker(x[i], y[i]);
+
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                            int sx, int sy, PIColorMap* cmap)
+{
+Window xw;
+Display * mdsp;
+int scr;
+int depth;
+int pad;
+int i,j;
+XImage * ximg;
+
+if ( (sx < 1) || (sy < 1) )  return;
+if ((pix == NULL) || (cmap == NULL)) return; 
+
+  
+xw = mWId;
+mdsp = PIXDisplay();
+scr = PIXScreen();
+
+depth = DefaultDepth(mdsp,scr);
+pad = (depth > 8) ? 32 : 8;
+ximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr),
+                     depth,ZPixmap,0,NULL, sx, sy, pad,0);
+if (ximg == NULL)  return;
+ximg->data = new char [sy*ximg->bytes_per_line];
+if (ximg->data == NULL)  
+  { XFree(ximg); return; }
+
+for(j=0; j<sy; j++)
+  for(i=0; i<sx; i++)
+    { XPutPixel(ximg, i, j, cmap->Color(*pix) );  pix++; }
+
+XPutImage(mdsp, xw, dpxgc, ximg, 0, 0, (int)x, (int)y, sx, sy);
+
+delete[] ximg->data;
+XFree(ximg); 
+return;
+}
+
+
+
+/* --Methode-- */
+void PIGraphicX::SelForeground(PIColors col)
+{
+if (col == mFCol)  return;
+if ( (col < 0) || (col >= NMAXCOL))  return;
+XSetForeground(mDisp, DefGC(), colpix[col]); 
+mFCol = col;  
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::SelBackground(PIColors col)
+{
+if (col == mBCol)  return;
+if ( (col < 0) || (col >= NMAXCOL))  return;
+XSetBackground(mDisp, DefGC(), colpix[col]); 
+mBCol = col;  
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::SelForeground(PIColorMap& cmap, int cid)
+{
+SelectFCol(cmap.Color(cid));
+}
+
+/* --Methode-- */
+void PIGraphicX::SelBackground(PIColorMap& cmap, int cid)
+{
+SelectBCol(cmap.Color(cid));
+}
+
+/* --Methode-- */
+void PIGraphicX::SelGOMode(PIGOMode mod)
+{
+if (mod == mGOm)  return;
+switch (mod)
+  {
+  case PI_GOCopy :
+    XSetFunction(mDisp, DefGC(), GXcopy);
+    mGOm = mod;
+    break;
+  case PI_GOXOR :
+    XSetFunction(mDisp, DefGC(), GXxor);
+    mGOm = mod;
+    break;
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::SelFontSzPt(int npt, PIFontAtt att)
+{
+int dsz,i,isel, j;
+
+if ((npt == mFSize) && (att == mFAtt))  return;
+isel = 0;
+dsz = 9999;
+for(i=0; i<NMAXFONTSZ; i++)
+  {
+  j = npt - fntsz[i];   if (j < 0)  j = -j;
+  if (j < dsz)  {  isel = i; dsz = j; }
+  }
+
+j = 0;
+if (att & PI_RomanFont) j = 0;
+if (att & PI_BoldFont) j = 1;
+if (att & PI_ItalicFont) j = 2;
+SelectFont(isel, j);
+
+}
+
+/* --Methode-- */
+void PIGraphicX::SelFont(PIFontSize sz, PIFontAtt att)
+{
+int i,j;
+switch (sz)
+  {
+  case PI_SmallSizeFont:
+    i = SmallFontIndex;
+    break;
+  case PI_NormalSizeFont:
+    i = NormalFontIndex;
+    break;
+  case PI_BigSizeFont:
+    i = BigFontIndex;
+    break;
+  case PI_HugeSizeFont:
+    i = HugeFontIndex;
+    break;
+  default:
+    i = NormalFontIndex;
+    break;
+  }
+
+j = 0;
+if (att & PI_RomanFont) j = 0;
+if (att & PI_BoldFont) j = 1;
+if (att & PI_ItalicFont) j = 2;
+
+SelectFont(i, j);
+}
+
+
+
+/* --Methode-- */
+void PIGraphicX::SelLine(PILineAtt att)
+{
+unsigned int lt=0;
+int lstyle=LineSolid;
+char dash[2]= {3,3};   
+
+if (att == mLAtt)  return;
+
+switch (att)
+  {
+  case PI_NormalLine :
+    lt = 2;
+    lstyle = LineSolid;
+    break;
+  case PI_ThickLine :
+    lt = 4;
+    lstyle = LineSolid;
+    break;
+  case  PI_ThinLine :
+    lt = 0;
+    lstyle = LineSolid;
+    break;
+
+  case PI_DashedLine :
+    lt = 2;
+    lstyle = LineOnOffDash;
+    dash[0] = dash[1] = 6;  
+    break;
+  case PI_ThickDashedLine :
+    lt = 4;
+    lstyle = LineOnOffDash;
+    dash[0] = dash[1] = 6;  
+    break;
+  case  PI_ThinDashedLine :
+    lt = 0;
+    lstyle = LineOnOffDash;
+    dash[0] = dash[1] = 6;  
+    break;
+
+  case PI_DottedLine :
+    lt = 2;
+    lstyle = LineOnOffDash;
+    dash[0] = 2; dash[1] = 6;  
+    break;
+  case PI_ThickDottedLine :
+    lt = 4;
+    lstyle = LineOnOffDash;
+    dash[0] = 2; dash[1] = 6;  
+    break;
+  case  PI_ThinDottedLine :
+    lt = 0;
+    lstyle = LineOnOffDash;
+    dash[0] = 2; dash[1] = 6;  
+    break;
+
+  default:
+    lt = 0;
+    lstyle=LineSolid;
+    break;
+  }
+
+if (lstyle != LineSolid) 
+  XSetDashes( mDisp, DefGC(), 0, dash, 2);
+  
+XSetLineAttributes(mDisp, DefGC(), lt, lstyle, CapButt, JoinMiter);
+mLAtt = att;
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::SelMarker(int msz, PIMarker mrk)
+{
+if (msz > 1)  { mMrk = mrk;  mMrkSz = msz; }
+else  { mMrk = PI_DotMarker;  mMrkSz = 1; }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+XRectangle xr;
+xr.x = x0;  xr.y = y0;
+xr.width = dx;  xr.height = dy;
+XSetClipRectangles(mDisp, DefGC(), 0, 0, &xr, 1, Unsorted);
+XSetClipRectangles(mDisp, dpxgc, 0, 0, &xr, 1, Unsorted);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::ClearClipRectangle()
+{ 
+XSetClipMask(mDisp, DefGC(), None);
+XSetClipMask(mDisp, dpxgc, None);
+return;
+}
+
+/* --Methode-- */
+PIColors  PIGraphicX::GetForeground() 
+{
+return (mFCol);
+}
+
+/* --Methode-- */
+PIColors  PIGraphicX::GetBackground() 
+{
+return (mBCol);
+}
+
+
+/* --Methode-- */
+PIGOMode   PIGraphicX::GetGOMode()
+{
+return (mGOm);
+}
+
+/* --Methode-- */
+PIFontAtt  PIGraphicX::GetFontAtt()
+{
+return (mFAtt);
+}
+
+/* --Methode-- */
+int        PIGraphicX::GetFontSize()
+{
+return (mFSize);
+}
+
+/* --Methode-- */
+PILineAtt  PIGraphicX::GetLineAtt()
+{
+return (mLAtt);
+}
+
+/* --Methode-- */
+PIMarker   PIGraphicX::GetMarker()
+{
+return (mMrk);
+}
+
+/* --Methode-- */
+int        PIGraphicX::GetMarkerSize()
+{
+return (mMrkSz);
+}
+
+/* --Methode-- */
+int        PIGraphicX::GetFontHeight(int& asc, int& desc)   
+{
+char a[2];
+XCharStruct  ovr;
+int hd, fa, fd;
+XTextExtents(mFSt, a, 0, &hd, &fa, &fd, &ovr);
+asc = fa; desc = fd; 
+return(fa+fd);
+}
+
+/* --Methode-- */
+PIGrCoord PIGraphicX::CalcStringWidth(char const* s)
+{
+return(XTextWidth(mFSt, s, strlen(s)));
+}
+
+/* --Methode-- */
+void PIGraphicX::SaveGraphicAtt()
+{  
+// Pour optimier l'implementation de PIBaseWdgGen
+sFCol = mFCol;    sBCol = mBCol;
+sGOm = mGOm;
+sFAtt = mFAtt;   sFSize = mFSize;
+sMrk = mMrk;   sMrkSz = mMrkSz;
+sFCfMap = mFCfMap; sBCfMap = mBCfMap; 
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::RestoreGraphicAtt()
+{
+  if (sFCol != PI_ColorFromMap) SelForeground(sFCol);
+  else SelectFCol(sFCfMap);
+  if (sBCol != PI_ColorFromMap) SelBackground(sBCol);
+  else SelectBCol(sBCfMap);
+  SelGOMode(sGOm);
+  SelFontSzPt(sFSize, sFAtt);
+  SelLine(sLAtt);
+  SelMarker(sMrkSz, sMrk);
+  return;
+}
+
+
+/* --Methode-- */
+unsigned long PIGraphicX::GetPixelValueforColor(PIColors col)
+{
+if ( (col < 0) || (col >= NMAXCOL))  return(0);
+return(colpix[col]); 
+}
+
+
+static bool fggrcx = false ;
+
+// Le bazar pour recuperer des resources de .Xdefault et autres 
+typedef struct 
+  {
+  String fntFam;
+  } myAppData;
+static myAppData  apd;
+
+static XtResource resources[] = {
+  { "fontFamilyName", "FontFamilyName", XtRString, sizeof(String),
+    /*XtOffset(apdp, fntFam)*/ 0, XtRString, "*-courier" }
+};
+ 
+static char * fnbi_b[4] = { "medium-r-normal", "bold-r-normal", 
+                          "medium-o-normal", "medium-i-normal" };
+
+static XFontStruct * defnt = NULL;
+static char * fnbi[3];
+
+
+/* --Methode-- */
+void PIGraphicX::GlInit()
+{
+char buff[256];
+int i,j,count;
+char **list;
+
+if (fggrcx)  return;
+fggrcx = true;
+
+Display *mdsp;
+int scr;
+XColor exact,mycol;
+Colormap  cmap;
+
+mdsp = PIXDisplay();
+scr = XDefaultScreen(mdsp);
+
+XtGetApplicationResources(PIXtTopWdg(), &apd, resources, 
+                          XtNumber(resources), NULL, 0);
+sprintf(buff,"-%s-*-*-*-*-*-*-*-*-*-*-*-*", apd.fntFam);
+list = XListFonts(mdsp, buff, 15, &count);
+XFreeFontNames(list);
+if (count < 5)
+  { 
+  printf("PIGraphicX::Init %d fonts found for %s , switching to courier\n",
+         count, apd.fntFam);
+  apd.fntFam = "*-courier";
+  }
+sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[0]);
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+if (count < 2) fnbi[0] = "*-*-*";
+else  fnbi[0] = fnbi_b[0];
+sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[1]);
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+if (count < 2) fnbi[1] = "*-*-*";
+else  fnbi[1] = fnbi_b[1];
+sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[2]);
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+fnbi[2] = fnbi_b[2];
+if (count < 2) 
+  {
+  sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[3]);
+  list = XListFonts(mdsp, buff, 10, &count);
+  XFreeFontNames(list);
+  fnbi[2] = fnbi_b[3];
+  }
+if (count < 2) fnbi[2] = "*-*-*";
+
+sprintf(buff,"-*-fixed-*-*-*-*-14-*-*-*-*-*-*-*");
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+if (count < 1) 
+  {  
+  sprintf(buff,"fixed");
+  list = XListFonts(mdsp, buff, 10, &count);
+  XFreeFontNames(list);
+  }
+if (count < 1) 
+  {  
+  strcpy(buff,"");
+  list = XListFonts(mdsp, buff, 10, &count);
+  XFreeFontNames(list);
+  printf("PIGraphicX::Init/ Erreur, no font found ... \n");
+  defnt = NULL;
+  }
+else defnt = XLoadQueryFont(mdsp, buff);
+
+for (i=0; i<NMAXFONTSZ; i++)
+  for (j=0; j<3; j++)  fntst[i][j] = NULL;
+
+// Choix des trois tailles de fontes standard en fonction de 
+// la taille de fonte par defaut des composantes standard
+int szx, szy, szf;
+PIXtAppCtx(szx, szy, szf);
+int kkk, kkj, kksel, kkdsz = 9999;  
+kksel = NMAXFONTSZ/2;
+for(kkk=NMAXFONTSZ-1; kkk>=0; kkk--) {
+  kkj = szf - fntsz[kkk];   if (kkj < 0)  kkj = -kkj;
+  if (kkj < kkdsz)  {  kksel = kkk;  kkdsz = kkj; }
+  }
+if (kksel == NMAXFONTSZ-1)  kksel = NMAXFONTSZ-2;
+NormalFontIndex = kksel;
+SmallFontIndex = (kksel > 1) ? kksel-2 : 0 ;
+BigFontIndex =  NMAXFONTSZ-2 ;
+if (BigFontIndex < NormalFontIndex)  BigFontIndex = NormalFontIndex;
+HugeFontIndex = NMAXFONTSZ-1;
+
+//printf("PIGraphicX::Init()-DBG- FontIndex= %d %d %d (%d) \n", 
+//       SmallFontIndex, NormalFontIndex, BigFontIndex, szf);
+
+/*  Les couleurs  */
+cmap = XDefaultColormap (mdsp, scr);
+
+for(i=0; i<NMAXCOL; i++)  colpix[i] = XWhitePixel(mdsp, scr);
+colpix[PI_Black] = XBlackPixel(mdsp, scr);
+colpix[PI_White] = XWhitePixel(mdsp, scr);
+if ( XAllocNamedColor (mdsp, cmap, "LightGray", &mycol, &exact) )
+  colpix[PI_Grey] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "red", &mycol, &exact) )
+  colpix[PI_Red] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "blue", &mycol, &exact) )
+  colpix[PI_Blue] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "green", &mycol, &exact) )
+  colpix[PI_Green] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "yellow", &mycol, &exact) )
+  colpix[PI_Yellow] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "magenta", &mycol, &exact) )
+  colpix[PI_Magenta] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "cyan", &mycol, &exact) )
+  colpix[PI_Cyan] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "turquoise", &mycol, &exact) )
+  colpix[PI_Turquoise] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "NavyBlue", &mycol, &exact) )
+  colpix[PI_NavyBlue] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "orange", &mycol, &exact) )
+  colpix[PI_Orange] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "sienna", &mycol, &exact) )
+  colpix[PI_SiennaRed] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "purple", &mycol, &exact) )
+  colpix[PI_Purple] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "LimeGreen", &mycol, &exact) )
+  colpix[PI_LimeGreen] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "gold", &mycol, &exact) )
+  colpix[PI_Gold] = mycol.pixel;
+
+
+/*  le GC pour DrawPixmap  */
+XGCValues  xgv;
+xgv.function = GXcopy;
+xgv.plane_mask = ~0;
+dpxgc = XCreateGC(mdsp, DefaultRootWindow(mdsp), GCFunction | GCPlaneMask, &xgv);
+
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::SelectFont(int isz, int jat)
+{
+
+if (!fntst[isz][jat])  // Il faut charger la fonte
+  {
+  char buff[256];
+  int count,k;
+  Display * mdsp = PIXDisplay();
+  char **list;
+
+  for (k=0; k<5; k++)    // Recherche de la fonte pour tailles croissantes
+    {
+    sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam, fnbi[jat], fntsz[isz]+k);
+    list = XListFonts(mdsp, buff, 10, &count);
+    XFreeFontNames(list);
+    if (count > 0)  break;
+    }
+  if (count > 0) 
+    fntst[isz][jat] = XLoadQueryFont(mdsp, buff);
+  else
+    { printf("PIGraphicX::SelectFont/ Pb font %s - Using default \n", buff);    
+    fntst[isz][jat] = defnt; }
+  }
+
+mFAtt = fntatt[jat];
+mFSize = fntsz[isz];
+mFSt = fntst[isz][jat];
+XSetFont(mDisp, DefGC(), fntst[isz][jat]->fid);
+return;
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/pigraphx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pigraphx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pigraphx.h	(revision 1307)
@@ -0,0 +1,111 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIGraphicX
+// Trace graphiques- Implementation X11  R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIGRAPHICX_H_SEEN
+#define PIGRAPHICX_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphgen.h"
+
+class PIGraphicX : public PIGraphicGen
+{
+public:
+                     PIGraphicX(PIWdg* wdg);
+                     PIGraphicX(PIScreenBuffer* grb);
+  virtual           ~PIGraphicX();
+
+  virtual int        kind();
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin);
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin);
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap);
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black);
+  virtual void       SelBackground(PIColors col=PI_White);
+  virtual void       SelForeground(PIColorMap& cmap, int cid);
+  virtual void       SelBackground(PIColorMap& cmap, int cid);
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont);
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont);
+  virtual void       SelLine(PILineAtt att=PI_NormalLine);
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       ClearClipRectangle();
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PIFontAtt  GetFontAtt();
+  virtual int        GetFontSize();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+  virtual int        GetFontHeight(int& asc, int& desc);
+  virtual PIGrCoord  CalcStringWidth(char const* s);
+
+// Sauvegarde des attributs graphiques 
+  virtual void       SaveGraphicAtt();
+  virtual void       RestoreGraphicAtt();
+
+//  Pour recuperer le pixcol d une couleur  (pour X) 
+  PIXColor           GetPixelValueforColor(PIColors col);
+//  Pour initialiser mWId apres creation de fenetre
+  virtual void	     TerminateInit();
+
+protected:
+  static void    GlInit();
+  void           Init();
+  void           SelectFont(int isz, int jat);
+  inline  GC     DefGC() { return mDefGC; }
+  inline SysDWdg MyWdg()  {return(myWdg->XtWdg()); }
+  inline void    SelectBCol(PIXColor col) 
+    {XSetBackground(mDisp, DefGC(), col);  mBCol = PI_ColorFromMap; mBCfMap = col; }
+  inline void    SelectFCol(PIXColor col) 
+    {XSetForeground(mDisp, DefGC(), col);  mFCol = PI_ColorFromMap; mFCfMap = col; }
+
+//  Structure et identificateur XWindow  associe
+  GC mDefGC;
+  Display* mDisp;  // Display X associe
+  Drawable mWId;   // Identificateur Window/Drawable X
+
+  PIColors  mFCol, mBCol;
+  PIGOMode mGOm;
+  PIFontAtt mFAtt;
+  PILineAtt mLAtt;
+  int mFSize;
+  XFontStruct *mFSt;
+  PIMarker mMrk;
+  int mMrkSz;
+  PIXColor mFCfMap, mBCfMap;
+  PIXColor sFCfMap, sBCfMap;
+};
+
+typedef PIGraphicX PIGraphicWin;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piimage.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piimage.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piimage.cc	(revision 1307)
@@ -0,0 +1,1056 @@
+// Module PI : Peida Interactive     PIImage
+// Affichage d'image            R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+//                        Refonte   Reza   10/95
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "piimage.h"
+#include "piimgtools.h"
+#include "pidrwtools.h"
+#include PIAPP_H
+
+//++
+// Class	PIImage
+// Lib		PI
+// include	piimage.h
+//
+//   	Classe pour la l'affichage et la manipulation d'images.
+//	Peut contrôler un PIPixmap pour l'affichage d'une zone
+//	agrandie (zoom) et un PIPixmap pour l'affichage de toute
+//	l'image (réduite).
+//	Utilise les adaptateur de tableaux 2D manipuler le
+//	contenu des images ("P2DArrayAdapter").
+//
+//	* Bouton-1 : Envoie le message "PIMsg_Active" et affiche
+//	les coordonnées courantes et la valeur du pixel, 
+//	et positionne le pavé.
+//	* Bouton-2 : Permet de définir une zone de l'image et repositionne le pavé.
+//	* Bouton-3 : Permet de déplacer l'image dans la fenêtre
+//
+//	Gestion du clavier :
+//	* <Alt>O : Affichage de la fenêtre de contrôle des paramètres de visualisation.
+//	* <Alt>G : Affichage de la fenêtre de changement des attributs graphiques
+//	* <Alt>R : Rafraîchit l'affichage.
+//	* <Alt>V : Copier/*Coller* Ajout du texte du buffer copier/coller
+//	sur l'objet à la position courante.
+//	* <Alt>C : *Copier*/Coller Permet de copier le contenu de la zone sélectionnée
+//	de l'image sous forme texte.
+//	* <Alt>Z : Supprime les textes et signes ajoutés au dessin.
+//	* Touches Curseurs : déplace la pavé.
+//--
+//++
+// Links	Parents
+// PIPixmap
+//--
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+//  PIImage(PIContainerGen *par, char *nom=NULL, int sx=0, int sy=0, int px=0, int py=0)
+//	Créateur
+//  
+//--
+
+// --------------------------------------------------------------------------------
+// ----------------------------- Classe PIImage -----------------------------------
+// --------------------------------------------------------------------------------
+// Variable globale pour la gestion de l'image courante 
+PIImage* PIImage::cur_piimage = NULL;
+/* --Methode-- */
+PIImage* PIImage::CurrentPIImage() 
+{ 
+return(cur_piimage); 
+}
+
+/* --Methode-- */
+void PIImage::SetCurrentPIImage(PIImage* curimg) 
+{ 
+cur_piimage = curimg;
+}
+
+/* --Methode-- */
+PIImage::PIImage(PIContainerGen *par, char *nom,
+   int sx, int sy, int px, int py) :
+  PIPixmap(par, nom, sx, sy, px, py)
+{
+
+img = NULL;
+aisup = false;
+curshow = true;
+winovis = true;     // $CHECK$ Reza A enlever si possible 17/6/96
+
+
+zow = NULL;   // Widget zoom
+gvw = NULL;   // widget vue globale
+cmvw = NULL;  // widget ColorMapView
+// Fenetre transient et Label pour affichage de l'info (texte PixVal)
+int tx, ty;
+PIApplicationPrefCompSize(tx, ty);
+tx *= 5;    ty = (int)(ty*0.8);
+trtw = new PIWindow(this, "PixVal", PIWK_transient, tx, ty, 0, 0);
+trtw->SetAutoDelChilds(true);
+trtlb = new PILabel(trtw, "PixVal", tx, ty, 0, 0);
+trtlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
+ustrtw = atrtw = false;
+if ((sx < 300) || (sy < 150) ) atrtw = true;
+showinfo = false;
+
+gpixm = zpixm = pixm = NULL;
+xsgpxm = xszpxm = xspxm = 0;
+ysgpxm = yszpxm = yspxm = 0;
+lut = NULL; 
+offx = offy = 0;
+xpav = ypav = 0;
+xpv0 = ypv0 = 0;
+xszpav = yszpav = 1;
+xmv0 = ymv0 = -1;
+dxmv = dymv = 0;
+xcurs = ycurs = -1;
+zoom = 1;
+zmgv = 1;
+
+mdrw = new PIElDrawer();
+gvdrw = new PIElDrawer();
+AddDrawer(mdrw, true, false, false);
+
+SetLut(0., 32000., kLutType_Lin, 0, false);
+SetColMapId(CMAP_COLRJ32);
+// pour le copier-coller
+cpbuffer = NULL;
+cpbuflen = 0;
+
+SetBackgroundColor(PI_Black);
+
+ActivateKeyboard();
+ActivateButton(1);
+ActivateMove(1);
+ActivateButton(2);
+ActivateMove(2);
+ActivateButton(3);
+ActivateMove(3);
+
+cur_piimage = this;
+}
+
+/* --Methode-- */
+PIImage::~PIImage()
+{
+if (pixm) delete pixm;
+if (zpixm) delete zpixm;
+if (zow) 
+  {
+  zow->SetPixmap(NULL,0,0);
+  zow->EraseWindow();
+  }
+if (gpixm) delete gpixm;
+if (gvw) 
+  {
+  gvw->SetPixmap(NULL,0,0);
+  gvw->EraseWindow();
+  gvw->SetMsg(0); gvw->SetMsgParent(NULL); 
+  gvw->SetUserData(NULL, 0); 
+  }
+if (cmvw)  cmvw->SetColMap(NULL, 1., -1., true);
+if (lut) delete lut;
+delete mdrw;
+delete gvdrw;
+if (aisup && img)  delete img;   // Suppression automatique d'image
+delete trtw;
+if (cpbuffer)  delete[] cpbuffer;
+if (this == cur_piimage)  cur_piimage = NULL;
+}
+
+/* --Methode-- */
+void PIImage::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+if (UserMsg(msg) == (Msg()+626))
+  {
+  if (ModMsg(msg) == PIMsg_Click) 
+    { int* pxy=(int *)data;   SetPave(pxy[0]*zmgv, pxy[1]*zmgv); }
+  if (ModMsg(msg) == PIMsg_Resize)
+    { ComputeGloVPixmap();   SetGloVPixmap(); }
+  }
+else ReSend(msg, sender, data);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetImage(P2DArrayAdapter *pim, bool ad, bool refr)
+{
+
+offx = offy = 0;
+xpav = ypav = 0;
+xszpav = yszpav = 1;
+img = pim;
+if (gpixm) delete gpixm;
+gpixm = NULL;
+xsgpxm = ysgpxm = 0;
+zmgv = 1;
+
+if (img)  {
+//  SetSize(img->XSize(), img->YSize());
+  CenterPave();
+  double min=1., max=-1., moy, sig;
+  int nbnul, nbsat;
+  img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
+  SetLut(min, max, kLutType_Lin, 1, refr);
+  aisup = ad;
+  }
+else aisup = false;
+return;
+}
+
+/* --Methode-- */
+void PIImage::ChangeAxesConfiguration(bool ix, bool iy, bool xy, bool refr)
+{
+if (!img) return;
+bool invx, invy, exy;
+img->GetAxesConfiguration(invx, invy, exy);
+if (ix)  invx = !invx;
+if (iy)  invy = !invy;
+if (xy)  exy = !exy;
+img->ConfigureAxes(invx, invy, exy);
+ComputeGloVPixmap();
+if (refr) Apply();
+}
+
+/* --Methode-- */
+void PIImage::SetZoomWin(PIPixmap * zw, bool refr) 
+{
+zow = zw;
+if (zow && refr && img)
+  ComputeZoomPixmap();
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetGloVWin(PIPixmap * zw, bool refr) 
+{
+gvw = zw;
+if (gvw && img)  
+  { ComputeGloVPixmap();
+  if (refr) SetGloVPixmap(); } 
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetCMapWin(PICMapView * cw, bool refr)
+{
+cmvw = cw;
+if (cmvw && refr) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), true);
+}
+
+
+/* --Methode-- */
+void PIImage::UseInfoWin(bool trw)
+{
+ustrtw = trw;
+}
+
+/* --Methode-- */
+void PIImage::ShowInfo(bool si)
+{
+if (showinfo == si) return;
+showinfo = si;
+if (showinfo && img)  { 
+  char buff[256];
+  double x,y;
+  img->XYCoord(xpav, ypav, x, y);
+  sprintf(buff," X= %g , Y= %g  Pix= %g (%d,%d)      ", 
+          x, y , (*img)(xpav, ypav), xpav, ypav );
+  DrawInfo(mWGrC, buff);
+  }
+else DrawInfo(mWGrC, NULL);
+}
+
+/* --Methode-- */
+void PIImage::ShowCursor(bool sc)
+{
+if (curshow == sc) return;
+curshow = sc;
+if (curshow)  DrawCursor(mWGrC);
+else DrawCursor(mWGrC, -1, -1);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetLut(double min, double max, int typlut, int lauto, bool refr)
+{
+if (lut) delete(lut);
+if (lauto && img) 
+  {
+  int nbsig = lauto;  
+  double fracmax = 1. - 0.05*nbsig;
+  img->ComputeLut_PicHisto(min, max, nbsig, fracmax);
+  }
+
+lut = new LUT(min, max, NbCol(), typlut);
+
+ComputeGloVPixmap();
+if (refr) Apply();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::SetLut(LUT *clut, bool refr)
+{
+LUT * olut = lut;
+lut = new LUT(clut->Min(), clut->Max(), NbCol(), clut->Type());
+if (olut) delete olut;
+
+ComputeGloVPixmap();
+if (refr) Apply();
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetZoomF(float fzm, bool refr)
+{
+int zm;
+
+if (fzm < 0.01) return;
+if (fzm < 1.)  zm = (int)(-(1./fzm));
+else zm = (int)(fzm+0.25);
+SetZoom(zm, refr);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetZoom(int zm, bool refr)
+{
+if ((zm == 0) || (zm == -1) )  zoom = 1;
+else if (zm > 20)  zoom = 20;
+else if (zm < -20) zoom = -20;
+else zoom = zm;
+if (img)
+  { SetOffsetFromPave();
+  if (refr) Apply(); }
+return;
+}
+
+/* --Methode-- */
+float PIImage::GetZoomF()
+{
+if (zoom >= 1)  return((float)zoom);
+else return(-1./(float)zoom);
+}
+
+
+/* --Methode-- */
+void PIImage::SetOffset(int ox, int oy, bool refr)
+{
+if (img == NULL)  {offx = offy = 0;  return; }
+if (ox < 0)  ox = 0;
+if (ox >= (img->XSize()-1))  ox = img->XSize()-2;
+if (oy < 0)  oy = 0;
+if (oy >= (img->YSize()-1))  oy = img->YSize()-2;
+offx = ox;  offy = oy;
+CenterPave();
+if (refr) Apply();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::SetPave(int x, int y, bool refr, bool cent)
+{
+int xc, yc;
+
+if (img == NULL)  
+  { offx = offy = 0; 
+  xpav = ypav = 0; 
+  return; }
+
+if ( (x >= (img->XSize()-1)) || ( x < 0)  ||
+     (y >= (img->YSize()-1)) || ( y < 0)  ) return;
+
+if ( (x == xpav) && (y == ypav) )  return;
+xpav = x;  ypav = y;
+
+if ( PosImg2W(xpav,ypav,&xc, &yc) || cent)  // Il faut recenter l'image
+  { SetOffsetFromPave();  
+  if (refr) Apply(true);  }
+else if (refr)
+  { Apply(false);  if (curshow)  DrawCursor(mWGrC);  }
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetColMap(PIColorMap* cmp, bool refr)
+{
+if (!cmp)  return;
+int cmapid = cmp->Type();
+if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  mdrw->SetColAtt(PI_Red);
+else mdrw->SetColAtt(PI_White);
+PIPixmap::SetColMap(cmp, refr);
+if (zow)  zow->SetColMap(cmp, refr);
+if (gvw)  gvw->SetColMap(cmp, refr);
+if (cmvw) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), refr);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetColMapId(CMapId cmapid, bool refr)
+{
+if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  mdrw->SetColAtt(PI_Red);
+else mdrw->SetColAtt(PI_White);
+PIPixmap::SetColMapId(cmapid, refr);
+if (zow)  zow->SetColMapId(cmapid, refr);
+if (gvw)  gvw->SetColMapId(cmapid, refr);
+if (cmvw) cmvw->SetColMapId(cmapid, Lut()->Min(), Lut()->Max(), refr);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Apply(bool mw)
+{
+if (img == NULL)  return;
+if (mw)  {  
+  ComputePixmap();
+  Send(Msg(), PIMsg_Active);
+  cur_piimage = this;
+  PIDrwTools::SetCurrentBaseWdg(this);
+  }
+else {
+  char buff[256];
+  double x,y;
+  img->XYCoord(xpav, ypav, x, y);
+  sprintf(buff," X= %g , Y= %g  Pix= %g (%d,%d)      ", 
+          x, y , (*img)(xpav, ypav), xpav, ypav );
+  if (ustrtw || atrtw)  trtlb->SetLabel((string)buff);
+  else DrawInfo(mWGrC, buff);
+  }
+if (zow != NULL)   ComputeZoomPixmap();
+if (gvw != NULL)
+  if ( (gvw->UserData() != this) || (mw) )  SetGloVPixmap();
+if (cmvw) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), true);
+  
+return;
+}
+
+/* --Methode-- */
+void PIImage::Resize()
+{
+// printf("PIImage::Resize\n");
+// On bascule sur la fenetre transient pour l'affichage des valeurs si fenetre trop petite
+if ((XSize() < 300) || (YSize() < 150) ) atrtw = true;  
+else atrtw = false;
+PIPixmap::Resize();
+CenterPave();
+Apply();
+return;
+}
+
+/* --Methode-- */
+void PIImage::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+{
+PIPixmap::Draw(g, x0, y0, dx, dy);
+winovis = false;    // $CHECK$ Reza A enlever si possible 17/6/96
+if (curshow) {
+  int xc,yc;
+  PosImg2W(xpav, ypav, &xc, &yc);
+  if ((xc >= x0) && (xc < x0+dx) && 
+      (yc >= y0) && (yc < y0+dy) )  DrawCursor(g, xc, yc);
+  }
+
+if (showinfo && img) {
+  char buff[256];
+  double x,y;
+  img->XYCoord(xpav, ypav, x, y);
+  sprintf(buff," X= %g , Y= %g  Pix= %g (%d,%d)      ", 
+        x, y , (*img)(xpav, ypav), xpav, ypav );
+  DrawInfo(mWGrC, buff); 
+  }
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::Keyboard(int key, PIKeyModifier kmod)
+{
+cur_piimage = this;
+if (kmod == PIKM_Alt) {
+  if      (key == 'R' || key == 'r') Apply(true);  // Pour tout rafraichir  
+  else if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller)  
+  else if (key == 'Z' || key == 'z') { mdrw->ElDelAll();  Refresh(); } // Pour supprimer tous les signes 
+  else if (key == 'O' || key == 'o') PIImgTools::ShowPIImgTools();   // Fentre LUT et options 
+  else if (key == 'G' || key == 'g') {   // Fentre attributs graphiques 
+    PIDrwTools::SetCurrentBaseWdg(this);
+    PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
+    }
+// ----  Le copier ---- 
+  else if ((key == 'C' || key == 'c') && img) { 
+    // On limite la taille a 48x48
+    int i1 = XPave();  
+    int i2 = ( XSzPave() < 48 ) ? i1+XSzPave() : i1+48;
+    int j1 = YPave();  
+    int j2 = ( YSzPave() < 48 ) ? j1+YSzPave() : i1+48;
+    if ( ( (i2-i1) < 1 ) || ((j2-j1) < 1) ) return;
+    if (!ClaimSelection())  return;  // On n'a pas pu prendre possession de la zone d'echange
+    if (cpbuffer)  delete[] cpbuffer;
+    cpbuflen = (j2-j1)*(i2-i1+2)*12+(j2-j1)+128;
+    cpbuffer = new char[cpbuflen];
+    sprintf(cpbuffer,"PIImage: Pave(%dx%d) en (%d, %d) MaxCopie= 48x48 \n", 
+            XSzPave(), YSzPave(), i1, j1);
+    int i,j;
+    int l = strlen(cpbuffer);
+    for(j=j1; j<j2; j++) {
+      sprintf(cpbuffer+l,"L %3d:",j);
+      l += 6;
+      for(i=i1; i<i2; i++) { sprintf(cpbuffer+l," %10g", (*img)(i, j));  l += 11; }
+      cpbuffer[l] = '\n';  l++;
+      }
+    cpbuffer[l] = '\0';
+    cpbuflen = l+1;
+    }
+  }
+
+
+else if (kmod == PIKM_Blank) {
+  switch (key) {
+    case PIK_Up :
+      SetPave(xpav, ypav-1, true, false);
+      break;
+    case PIK_Down :
+      SetPave(xpav, ypav+1, true, false);
+      break;
+    case PIK_Left :
+      SetPave(xpav-1, ypav, true, false);
+      break;
+    case PIK_Right :
+      SetPave(xpav+1, ypav, true, false);
+      break;
+    default :
+      break;
+  }
+}
+
+}
+
+
+/* --Methode-- */
+void PIImage::But1Press(int x, int y)
+{
+int xp, yp;
+
+Send(Msg(), PIMsg_Active);
+cur_piimage = this;
+PIDrwTools::SetCurrentBaseWdg(this);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+SelPointerShape(PI_CrossPointer);
+xpav = xp;  ypav = yp;
+if (ustrtw || atrtw) ShowTrTxW();
+Apply(false);
+if (curshow)  DrawCursor(mWGrC, -1,-1);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Ptr1Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+xpav = xp;  ypav = yp;
+Apply(false);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But1Release(int /*x*/,  int /*y*/)
+{
+SelPointerShape(PI_ArrowPointer);
+if (curshow)  DrawCursor(mWGrC);
+if (ustrtw || atrtw) trtw->Hide();
+else if (!showinfo) DrawInfo(mWGrC, NULL);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But2Press(int x, int y)
+{
+
+Send(Msg(), PIMsg_Active);
+cur_piimage = this;
+PIDrwTools::SetCurrentBaseWdg(this);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xpv0, &ypv0) )  {  xmv0 = -1;  return; }
+xmv0 = x;  ymv0 = y;  dxmv = dymv = 0;
+if (curshow)  DrawCursor(mWGrC,-1,-1);
+mWGrC->SelGOMode(PI_GOXOR);
+if (GetColMapId() == CMAP_COLRJ32)
+mWGrC->SelForeground(PI_Yellow);
+else mWGrC->SelForeground(PI_Magenta);
+mWGrC->SelLine(PI_NormalLine);
+if (ustrtw || atrtw) ShowTrTxW();
+return;
+}
+
+/* --Methode-- */
+void PIImage::Ptr2Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv);
+dxmv = x-xmv0;  dymv = y-ymv0;
+mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv);
+
+ {
+ char buff[256];  
+ double x,y;
+ img->XYCoord(xp, yp, x, y);
+ sprintf(buff," X= %g , Y= %g  Pix= %g  (C= %d,%d)   ", 
+         x, y , (*img)(xp, yp),  (xp+xpv0)/2, (yp+ypv0)/2 );
+ if (ustrtw || atrtw) trtlb->SetLabel((string)buff);
+ else DrawInfo(mWGrC, buff);
+ }
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::But2Release(int x, int y)
+{
+int xp2, yp2;
+
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv);
+mWGrC->SelGOMode(PI_GOCopy);
+mWGrC->SelForeground(PI_White);
+if ( PosW2Img(x, y, &xp2, &yp2) )  
+  PosW2Img(xmv0+dxmv, ymv0+dymv, &xp2, &yp2);
+xpav = (xpv0+xp2)/2;
+ypav = (ypv0+yp2)/2;
+xszpav = ((xp2-xpv0) > 0) ? (xp2-xpv0) : 1;
+yszpav = ((yp2-ypv0) > 0) ? (yp2-ypv0) : 1;
+
+Apply(false);
+if (curshow)  DrawCursor(mWGrC);
+if (ustrtw || atrtw) trtw->Hide();
+else if (!showinfo) DrawInfo(mWGrC, NULL);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But3Press(int x, int y)
+{
+int xp, yp;
+
+Send(Msg(), PIMsg_Active);
+cur_piimage = this;
+PIDrwTools::SetCurrentBaseWdg(this);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  { xmv0 = -1;  return; }
+if (curshow)  DrawCursor(mWGrC,-1,-1);
+if (ustrtw || atrtw) ShowTrTxW();
+SelPointerShape(PI_TDLRArrowPointer);
+xmv0 = xp;
+ymv0 = yp;
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Ptr3Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+
+char buff[256];
+sprintf(buff," DelX= %d , DelY= %d    ", xp-xmv0, yp-ymv0);
+if (ustrtw || atrtw) trtlb->SetLabel((string)buff);
+else DrawInfo(mWGrC, buff);
+}
+
+/* --Methode-- */
+void PIImage::But3Release(int x, int y)
+{
+int xp, yp;
+
+SelPointerShape(PI_ArrowPointer);
+if (ustrtw || atrtw) trtw->Hide();
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+
+offx -= (xp-xmv0);
+offy -= (yp-ymv0);
+
+if (offx < 0)  offx = 0;
+if (offy < 0)  offy = 0;
+if (offx >= img->XSize())  offx = img->XSize();
+if (offy >= img->YSize())  offy = img->YSize();
+xpav = xmv0;  ypav = ymv0;
+xmv0 = ymv0 = -1;
+Apply();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
+{
+if (!img) return;
+if (typ != PICP_string) return;
+int ll = (l<256) ? l+1 : 256;
+char pc[256];
+strncpy(pc, (char*)pdata, ll-1);  pc[ll-1] = '\0';
+double fx, fy;
+img->Coord(xpav, ypav, fx, fy); 
+mdrw->ElAddText(fx, fy, pc );
+mdrw->Refresh();
+}
+
+/* --Methode-- */
+void * PIImage::ProvideSelection(unsigned int& typ, unsigned int& len)
+{
+typ = PICP_string;
+len = cpbuflen;
+return(cpbuffer);
+}
+
+/* --Methode-- */
+void PIImage::SelectionLost()
+{
+if (cpbuffer)  delete[] cpbuffer;
+cpbuffer = NULL;
+cpbuflen = 0;
+return;
+}
+
+
+
+/* --Methode-- */
+void PIImage::ComputePixmap()
+{
+unsigned int xwsz, ywsz;
+
+if (img == NULL)  return;
+xwsz = XSize();
+ywsz = YSize();
+
+pixm = img->ComputePixmap(lut, offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
+int xw1, yw1, xw2, yw2;
+xw1 = (xwsz-xspxm)/2;
+if (xw1 < 0) xw1 = 0;
+yw1 = (ywsz-yspxm)/2;
+if (yw1 < 0) yw1 = 0;
+xw2 = xspxm+xw1;
+yw2 = yspxm+yw1;
+SetDefaultDrawRectangle(xw1, yw1, xw2, yw2, false);
+// printf("--DBG-- ComputePixmap() %d %d $ %d %d :: %d %d , %d %d \n", xwsz, ywsz, xspxm, yspxm, xw1, yw1, xw2, yw2);
+int x1,y1, x2,y2;
+ofx = xw1;  ofy = yw1;
+PosW2Img(xw1, yw1, &x1, &y1);
+PosW2Img(xw2, yw2, &x2, &y2);
+double fx1,fy1, fx2, fy2; 
+img->Coord(x1,y1, fx1, fy2);  // fy1 et fy2 echange expres pour utiliser kAxeDirAuto  
+img->Coord(x2,y2, fx2, fy1);  // En effet Image de haut vers bas, Axes de bas vers haut par defaut 
+SetDefaultDrawerLimits(fx1, fx2, fy1, fy2, kAxeDirAuto, kAxeDirAuto);
+// printf("--DBG2-- ComputePixmap() %g %g  %g %g  \n", fx1, fx2, fy1, fy2);
+xcurs = ycurs = -1;
+SetPixmap(pixm, xspxm, yspxm, true, xw1, yw1); 
+// Refresh();
+return; 
+}
+
+
+/* --Methode-- */
+void PIImage::ComputeZoomPixmap()
+{
+unsigned int xwsz, ywsz;
+int lofx, lofy;
+int zm;
+
+if (zow == NULL)  return;
+if (img == NULL)  return;
+
+xwsz = zow->XSize();
+ywsz = zow->YSize();
+
+zm = zoom+4;
+if ( (zm==-1) || (zm == 0) ) zm = 1;
+if (zm > 0)
+  {
+  lofx = xpav-(xwsz/2/zm);
+  lofy = ypav-(ywsz/2/zm);
+  }
+else 
+  {
+  lofx = xpav+(xwsz*zm/2);
+  lofy = ypav+(ywsz*zm/2);
+  }
+if (lofx < 0)  lofx = 0;
+if (lofy < 0)  lofy = 0;
+
+zpixm = img->ComputePixmap(lut, lofx, lofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
+zow->SetColMap(cmap, false);
+zow->SetPixmap(zpixm, xszpxm, yszpxm); 
+zow->SetUserData((void *)this, 0);
+// zow->Refresh();
+return; 
+
+}
+
+
+/* --Methode-- */
+void PIImage::ComputeGloVPixmap()
+{
+unsigned int xwsz, ywsz;
+int zmx,zmy;
+
+if (gvw == NULL)  return;
+if (img == NULL)  return;
+
+xwsz = gvw->XSize();
+ywsz = gvw->YSize();
+
+zmx = img->XSize()/xwsz;
+zmy = img->YSize()/ywsz;
+
+if (zmx < zmy)   zmx = zmy;
+if (zmx < 1)  zmx = 1;
+zmgv = zmx;
+if (zmx > 1)  zmx = -zmx;
+gpixm = img->ComputePixmap(lut, 0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);
+// printf("DEBUG-ComputeGloVPixmap()  %d-%d , (%d,%d) , %d-%d \n", xwsz, ywsz, zmx, zmy, xsgpxm, ysgpxm);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetGloVPixmap()
+{
+float zm;
+int x,y, dx,dy;
+
+int xw1, yw1, xw2, yw2;
+xw1 = (gvw->XSize()-xsgpxm)/2;
+if (xw1 < 0) xw1 = 0;
+yw1 = (gvw->YSize()-ysgpxm)/2;
+if (yw1 < 0) yw1 = 0;
+xw2 = xsgpxm+xw1;
+yw2 = ysgpxm+yw1;
+
+if (zoom > 0) zm = zmgv*zoom;
+else zm = (float)zmgv/(float)(-zoom);
+x = offx/zmgv+1+xw1;
+y = offy/zmgv+1+yw1;
+dx =  (int) ( (float)XSize()/zm-1. );  
+dy =  (int) ( (float)YSize()/zm-1. );  
+
+gvw->DeleteDrawers();
+gvdrw->ElDelAll();
+gvdrw->SetLimits(xw1, xw2, yw1, yw2, kAxeDirLtoR, kAxeDirUpDown);
+int cmapid = cmap->Type();
+if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128)) gvdrw->SetColAtt(PI_Red); 
+else gvdrw->SetColAtt(PI_Yellow);
+gvdrw->SetLineAtt(PI_NormalLine);
+gvdrw->ElAddRect(x,y,dx,dy);
+gvw->AddDrawer(gvdrw, xw1, yw1, xw2, yw2, false); 
+gvw->SetColMap(cmap, false);
+gvw->SetPixmap(gpixm, xsgpxm, ysgpxm, true, xw1, yw1); 
+gvw->SetUserData((void *)this, 0);
+gvw->SetMsg(Msg()+626);
+gvw->SetMsgParent(this);
+
+return; 
+}
+
+/* --Methode-- */
+void PIImage::DrawCursor(PIGraphic* g) 
+{
+int xc, yc;
+if (PosImg2W(xpav, ypav, &xc, &yc)) DrawCursor(g, -1, -1);
+else DrawCursor(g, xc, yc);
+return;
+}
+
+#define CURSHSIZE  25
+ 
+/* --Methode-- */
+void PIImage::DrawCursor(PIGraphic* g, int xc, int yc)
+{
+
+if (winovis)  return;      // $CHECK$ Reza A enlever si possible 17/6/96
+
+g->SelGOMode(PI_GOCopy);
+if ( (GetColMapId() == CMAP_GREY32) || (GetColMapId() == CMAP_GREYINV32) ||
+     (GetColMapId() == CMAP_GREY128) || (GetColMapId() == CMAP_GREYINV128) )  g->SelForeground(PI_Red);
+else  g->SelForeground(PI_White);
+
+if (zoom < 3)  g->SelLine(PI_NormalLine);
+else g->SelLine(PI_ThickLine);
+
+if ((xcurs>=0) && (ycurs>=0) && (g->kind() != PI_PSFileGraphics ) ) {
+  PIPixmap::Draw(g, xcurs-3, ycurs-CURSHSIZE, 6, CURSHSIZE*2); 
+  PIPixmap::Draw(g, xcurs-CURSHSIZE, ycurs-3, CURSHSIZE*2, 6); 
+}
+if ((xc >= 0) && (yc >= 0)) 
+  {
+  xcurs = xc;   ycurs = yc;
+  g->DrawLine(xcurs-CURSHSIZE, ycurs, xcurs-4, ycurs);
+  g->DrawLine(xcurs+4, ycurs, xcurs+CURSHSIZE, ycurs);
+  g->DrawLine(xcurs, ycurs-CURSHSIZE, xcurs, ycurs-4);
+  g->DrawLine(xcurs, ycurs+4, xcurs, ycurs+CURSHSIZE);
+  }
+else { xcurs = ycurs = -1; }
+
+g->SelGOMode(PI_GOCopy);
+g->SelLine(PI_NormalLine);
+g->SelForeground(PI_White);
+return;
+}
+
+ 
+/* --Methode-- */
+void PIImage::DrawInfo(PIGraphic* g, char* txt)
+{
+g->SelFont(PI_NormalSizeFont, PI_RomanFont);
+if (txt) { 
+  PIColors fgc = g->GetForeground();
+  PIGOMode gm = g->GetGOMode();
+  g->SelGOMode(PI_GOCopy);
+  g->SelForeground(PI_White);
+  g->SelBackground(PI_Black);
+  g->DrawOpaqueString(20, YSize()-5, txt);
+  g->SelGOMode(gm);
+  g->SelForeground(fgc);
+  }
+else {
+  int a,d,h;
+  h = g->GetFontHeight(a, d);
+  if (g->kind() != PI_PSFileGraphics )   PIPixmap::Draw(g, 0, YSize()-10-h, XSize(), h+10); 
+  }
+return;
+}
+
+/* --Methode-- */
+void PIImage::ShowTrTxW()
+{
+if (trtw) 
+  {
+  int tpx, tpy;
+  GetScreenPos(tpx, tpy);
+  tpy -= (trtw->YSize()+5);
+  if (tpy < 0)  tpy = 0;
+  trtw->SetPos(tpx, tpy);
+  trtw->Show();  
+  }
+
+return;
+}
+
+/* --Methode-- */
+int PIImage::PosW2Img(int xiw, int yiw, int * xp, int * yp)
+{
+if (!img) { *xp = *yp = 0;  return(1); }
+xiw -= ofx;  yiw -= ofy;   // Offset d'affichage du pixmap
+if (zoom > 0)
+  {
+  *xp = xiw/zoom+offx;
+  *yp = yiw/zoom+offy;
+  }
+else
+  {
+  *xp = offx-xiw*zoom;
+  *yp = offy-yiw*zoom;
+  }
+
+if ( (*xp >= 0) && (*xp < img->XSize() ) &&
+     (*yp >= 0) && (*yp < img->YSize() )  )   return(0);
+else return(1);
+}
+
+
+/* --Methode-- */
+int PIImage::PosImg2W(int xp, int yp, int * xiw, int * yiw)
+{
+if (!img) { *xiw = *yiw = -1;  return(1); }
+if (zoom > 0)
+  {
+  *xiw = (xp-offx)*zoom+(zoom/2);
+  *yiw = (yp-offy)*zoom+(zoom/2);
+  }
+else
+  {
+  *xiw = (offx-xp)/zoom;
+  *yiw = (offy-yp)/zoom;
+  }
+
+*xiw += ofx;  *yiw += ofy;    // Offset d'affichage du pixmap
+if (*xiw > XSize())  *xiw = -1;
+if (*yiw > YSize())  *yiw = -1;
+
+if ((*xiw < 0) || (*yiw < 0))  return(1);
+else return(0);
+}
+
+
+/* --Methode-- */
+void PIImage::SetOffsetFromPave()
+{
+if (!img) { offx = offy = 0; return; }
+if (zoom > 0)
+  {
+  offx = xpav-XSize()/2/zoom;
+  offy = ypav-YSize()/2/zoom;
+  }
+else
+  {
+  offx = xpav+XSize()/2*zoom;
+  offy = ypav+YSize()/2*zoom;
+  }
+
+if (offx < 0)  offx = 0;
+if (offx >= (img->XSize()-1))  offx = img->XSize()-2;
+if (offy < 0)  offy = 0;
+if (offy >= (img->YSize()-1))  offy = img->YSize()-2;
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::CenterPave()
+{
+int xwsz, ywsz;
+
+if (zoom > 0)
+  { xwsz = XSize()/zoom;  
+  ywsz = YSize()/zoom;  }
+else
+  { xwsz = -(XSize()*zoom); 
+  ywsz = -(YSize()*zoom); }
+
+if (img) {   
+  if (xwsz > (img->XSize()-offx)) xwsz = (img->XSize()-offx);
+  if (ywsz > (img->YSize()-offy)) ywsz = (img->YSize()-offy);
+  }
+xpav = offx+xwsz/2; 
+ypav = offx+ywsz/2;
+xszpav = ((xwsz+ywsz)/20) ;
+if (xszpav < 1) xszpav = 1;
+yszpav = xszpav; 
+
+return;
+}
Index: /tags/DPC_V0/Poubelle/PI/piimage.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piimage.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piimage.h	(revision 1307)
@@ -0,0 +1,166 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIImage
+// Affichage d image            R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIIMAGE_H_SEEN
+#define PIIMAGE_H_SEEN
+
+#include "parradapter.h"
+
+#include "pisysdep.h"
+
+#include "pidrawer.h"
+#include PIPIXMAP_H
+#include PISTDWDG_H
+#include PIWIN_H
+#include "picmapview.h"
+
+class PIImage : public PIPixmap
+{
+
+public:
+  enum {ClassId = 5150};
+
+//  Les methodes 
+
+  PIImage(PIContainerGen *par, char *nom=NULL, 
+           int sx=0, int sy=0, int px=0, int py=0);
+  ~PIImage();
+
+  virtual long    kind() {return ClassId; }
+
+//  Tableau des pixels et changement de configuration des axes 
+  void SetImage(P2DArrayAdapter* pim, bool ad = true, bool refr=true);
+  void ChangeAxesConfiguration(bool ix, bool iy, bool xy, bool refr=true);
+  inline void   SetDrawAxesFlags(unsigned int flags=kBoxAxes | kExtTicks | kLabels)
+                       { mdrw->SetAxesFlags(flags); mdrw->Refresh(); }
+
+// Fenetre de Zoom, Vue globale, ColorMap, text, ...
+  void SetZoomWin(PIPixmap * zw, bool refr=false);
+  void SetGloVWin(PIPixmap * zw, bool refr=false);
+  void SetCMapWin(PICMapView * cw, bool refr=false);
+
+  void UseInfoWin(bool trw=false);
+  void ShowInfo(bool si=true); 
+  void ShowCursor(bool sc=true); 
+
+//  Gestion du choix de LUT, facteur d agrandissement, table de couleur
+  void SetLut(double min, double max, int typlut=kLutType_Lin,
+              int lauto=0, bool refr=true);
+  void SetLut(LUT *clut, bool refr=true);
+
+  void SetZoom(int zm, bool refr=true);
+  void SetZoomF(float fzm, bool refr=true);
+  float GetZoomF();
+
+// Changement de table de couleur
+  virtual void SetColMap(PIColorMap* cmp, bool refr=true);
+  virtual void SetColMapId(CMapId cmapid, bool refr=true);
+
+// Positionnement image - pave
+  void SetOffset(int ox, int oy, bool refr=true);
+  void SetPave(int x, int y, bool refr=true, bool cent=true);
+
+// Acces aux informations
+  inline P2DArrayAdapter * Image() { return(img); }
+  inline LUT *     Lut() { return(lut); }
+  inline int XPave() { return(xpav); } ;
+  inline int YPave() { return(ypav); } ;
+
+  inline int XSzPave() { return(xszpav); }
+  inline int YSzPave() { return(yszpav); }
+
+  inline PIElDrawer* MyElDrawer() { return (mdrw); }
+
+// Rafraichissement des widgets auxiliaires (zoom, ...)
+  void Apply(bool mw=true);
+
+// Gestion du trace et des evenements 
+  virtual void Resize();
+  virtual void Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+
+  virtual void Keyboard(int key, PIKeyModifier kmod);
+  virtual void But1Press(int x, int y);
+  virtual void But1Release(int x, int y);
+  virtual void Ptr1Move(int x, int y);
+  virtual void But2Press(int x, int y);
+  virtual void But2Release(int x, int y);
+  virtual void Ptr2Move(int x, int y);
+  virtual void But3Press(int x, int y);
+  virtual void But3Release(int x, int y);
+  virtual void Ptr3Move(int x, int y);
+
+// Gestion du copier-coller
+  virtual void   PasteSelection(unsigned int typ, void *pdata, unsigned int l);
+  virtual void*  ProvideSelection(unsigned int& typ, unsigned int& len);
+  virtual void   SelectionLost();
+
+//  Pour acces par les ImgTools (LutWind, ...)
+  static PIImage* CurrentPIImage();
+  static void SetCurrentPIImage(PIImage* curimg);
+
+protected:
+  virtual void    Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  void ComputePixmap();
+  void ComputeZoomPixmap();
+  void ComputeGloVPixmap();
+  void SetGloVPixmap();
+
+  void DrawCursor(PIGraphic* g);
+  void DrawCursor(PIGraphic* g, int xc, int yc);
+  void DrawInfo(PIGraphic* g, char* txt);
+
+  void ShowTrTxW();
+
+  int PosW2Img(int xiw, int yiw, int * xp, int * yp);
+  int PosImg2W(int xp, int yp, int * xiw, int * yiw);
+
+  void SetOffsetFromPave();
+  void CenterPave();
+
+// Les donnees 
+  P2DArrayAdapter * img;
+  bool aisup;     // Flag de suppression automatique de img
+  bool curshow;
+  bool winovis;   // $CHECK$ Reza A enlever si possible 17/6/96
+// Tableau des pixels principal  
+  unsigned char * pixm;
+  int xspxm, yspxm;
+  LUT * lut;
+  int offx, offy;
+  PIElDrawer* mdrw;
+// Fenetre de zoom
+  int zoom;
+  PIPixmap * zow;
+  unsigned char * zpixm;
+  int xszpxm, yszpxm;
+// Fenetre pour l'image entiere  
+  int zmgv;
+  PIPixmap * gvw;
+  unsigned char * gpixm;
+  int xsgpxm, ysgpxm;
+  PIElDrawer* gvdrw;
+// Fenetre d'affichage du ColMap
+  PICMapView* cmvw;
+// Fenetre/champ de texte
+  PILabel * trtlb;
+  PIWindow * trtw;
+  bool ustrtw, atrtw;
+  bool showinfo;
+// Le pave et le curseur
+  int xpav, ypav;
+  int xpv0, ypv0;
+  int xmv0, ymv0;
+  int dxmv, dymv;
+  int xcurs, ycurs;
+  int xszpav, yszpav;
+// buffer pour copier-coller
+  char* cpbuffer;
+  int cpbuflen;
+
+//  PIImage courante 
+  static PIImage* cur_piimage;
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piimgtools.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piimgtools.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piimgtools.cc	(revision 1307)
@@ -0,0 +1,383 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Outils de manipulation des PIImage  R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+
+#include "piimgtools.h"
+#include "piimage.h"
+
+// ------ Menu des options et fenetre de dialogue pour changement de LUT --------
+
+PIImgTools* PIImgTools::curlutw = NULL;
+/* --Methode-- */
+void PIImgTools::ShowPIImgTools() 
+{
+if (curlutw == NULL)  curlutw = new PIImgTools(PIApplicationGetApp());
+curlutw->Show();
+}
+
+/* --Methode-- */
+PIImgTools::PIImgTools(PIApplication* par)
+: PIWindow((PIMsgHandler*)par, "PIImageTools", PIWK_dialog, 240, 240, 150, 150)
+{
+int bsx, bsy, spx, spy;
+
+// On definit la taille a partir de la taille par defaut des composantes 
+// PIApplicationPrefCompSize(bsx, bsy);
+par->PrefCompSz(bsx, bsy);
+spx = bsx/10;
+spy = bsy/4;
+
+int wszx = 8*spx+3*bsx+2*bsy; 
+int wszy = 9*spy+9*bsy;
+SetSize(wszx, wszy);
+
+int cpx = spx*2;
+int cpy = spy*2;
+int csx = cpx;
+int csy = cpy;
+mLab[0] = new PILabel(this, "MinPixel", bsx, bsy, cpx, cpy);
+cpy += spy+bsy; 
+mLab[1] = new PILabel(this, "MaxPixel", bsx, bsy, cpx, cpy);
+mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpy = spy*2;
+cpx += spx+bsx; 
+mText[0] = new PIText(this, "MinVal", 1.75*bsx, bsy, cpx, cpy);
+mText[0]->SetText("1");
+cpy += spy+bsy; 
+mText[1] = new PIText(this, "MaxVal", 1.75*bsx, bsy, cpx, cpy);
+mText[1]->SetText("32000");
+mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpy += spy+bsy; 
+cpx = spx*2;
+mOlb[0] = new PILabel(this, "LutType", bsx, bsy, cpx, cpy);
+mOlb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += spx+bsx; 
+mOpt[0] = new PIOptMenu(this, "imglut-opt-1", 1.75*bsx, bsy, cpx, cpy);
+mOpt[0]->AppendItem("Linear", 1100);
+mOpt[0]->AppendItem("Log.", 1101);
+mOpt[0]->SetValue(1100);
+mOpt[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpy += spy+bsy; 
+cpx = spx*2;
+mOlb[1] = new PILabel(this, "AutoLut", bsx, bsy, cpx, cpy);
+mOlb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += spx+bsx; 
+mOpt[1] = new PIOptMenu(this, "imglut-opt-2", 1.75*bsx, bsy, cpx, cpy);
+mOpt[1]->AppendItem("+3 Sig", 1203);
+mOpt[1]->AppendItem("+2 Sig", 1202);
+mOpt[1]->AppendItem("+1 Sig", 1201);
+mOpt[1]->AppendItem("NoAuto", 1200);
+mOpt[1]->AppendItem("-1 Sig", 1199);
+mOpt[1]->AppendItem("-2 Sig", 1198);
+mOpt[1]->AppendItem("-3 Sig", 1197);
+mOpt[1]->SetValue(1202);
+mOpt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpy += 2*spy+bsy; 
+cpx = bsx/2;
+mBut[0] = new PIButton(this, "Apply", 2500, bsx*1.75, bsy, cpx, cpy);
+cpx += bsx*2;
+mBut[1] = new PIButton(this, "Dismiss", 2600,  bsx*1.75, bsy, cpx, cpy);
+mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+int offy = cpy+bsy+spy*2;
+// printf("-DBG- PIImgTools()  SzX,Y= %d %d , ButPos= %d %d (off=%d)\n", wszx, wszy, cpx, cpy, offy);
+
+cpx = 4*spx+2.75*bsx;
+cpy = 2*spy;
+mSc[0] = new PIScale(this, "sc-offset-lut", 2700, kSDirDownUp, 1.25*bsy, 4.5*bsy, cpx, cpy); 
+cpx += 1.50*bsy;
+mSc[1] = new PIScale(this, "sc-dyn-lut", 2800, kSDirDownUp, 1.25*bsy, 4.5*bsy, cpx, cpy); 
+mSc[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mSc[0]->SetMinMax(-50, 50);
+mSc[0]->SetValue(0);
+mSc[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mSc[1]->SetMinMax(-50, 50);
+mSc[1]->SetValue(0);
+
+//  Option-Menu  Couleur/Zoom
+cpx = bsx/2;
+cpy = offy;
+mOptzc[0] = new PIOptMenu(this, "imglut-opt-3", bsx*1.75, bsy, cpx, cpy);
+mOptzc[0]->AppendItem("Grey32", 201);
+mOptzc[0]->AppendItem("GreyInv32", 202);
+mOptzc[0]->AppendItem("ColRJ32", 203);
+mOptzc[0]->AppendItem("ColBR32", 204);
+mOptzc[0]->AppendItem("ColRV32", 205);
+mOptzc[0]->AppendItem("Grey128", 206);
+mOptzc[0]->AppendItem("GreyInv128", 207);
+mOptzc[0]->AppendItem("ColRJ128", 208);
+mOptzc[0]->AppendItem("ColBR128", 209);
+mOptzc[0]->AppendItem("Col16", 210);
+mOptzc[0]->SetValue(203);
+mOptzc[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpx += bsx*2;
+mOptzc[1] = new PIOptMenu(this, "imglut-opt-4", bsx*1.75, bsy, cpx, cpy);
+mOptzc[1]->AppendItem("Agr. x10", 110);
+mOptzc[1]->AppendItem("Agr. x 8", 108);
+mOptzc[1]->AppendItem("Agr. x 6", 106);
+mOptzc[1]->AppendItem("Agr. x 5", 105);
+mOptzc[1]->AppendItem("Agr. x 4", 104);
+mOptzc[1]->AppendItem("Agr. x 3", 103);
+mOptzc[1]->AppendItem("Agr. x 2", 102);
+mOptzc[1]->AppendItem("Zoom x 1", 101);
+mOptzc[1]->AppendItem("Red. / 2", 98);
+mOptzc[1]->AppendItem("Red. / 3", 97);
+mOptzc[1]->AppendItem("Red. / 4", 96);
+mOptzc[1]->AppendItem("Red. / 5", 95);
+mOptzc[1]->AppendItem("Red. / 6", 94);
+mOptzc[1]->AppendItem("Red. / 8", 92);
+mOptzc[1]->AppendItem("Red. /10", 90);
+mOptzc[1]->SetValue(101);
+mOptzc[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+int pbsx = bsy;
+int pbsy = bsy;
+int pspx = spy/2;
+int pspy = spy;
+
+cpx = 2*pspx;
+cpy += pbsy+2*spy;
+mButsz[0] = new PIButton(this, "1x1", 3201,  pbsx, pbsy, cpx, cpy);
+mButsz[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButsz[1] = new PIButton(this, "1x2", 3202,  pbsx, pbsy, cpx, cpy);
+mButsz[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButsz[2] = new PIButton(this, "1x4", 3204,  pbsx, pbsy, cpx, cpy);
+mButsz[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButsz[3] = new PIButton(this, "1/2", 3198,  pbsx, pbsy, cpx, cpy);
+mButsz[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButsz[4] = new PIButton(this, "1/4", 3196,  pbsx, pbsy, cpx, cpy);
+mButsz[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpx += pbsx+10*pspx;
+mButoa[0] = new PIButton(this, "+Info", 5311,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += 1.5*pbsx+pspx;
+mButoa[1] = new PIButton(this, "-Info", 5312,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+
+cpx = 2*pspx;
+cpy += pbsy+pspy;
+mButcax[0] = new PIButton(this, "-X", 5201,  pbsx, pbsy, cpx, cpy);
+mButcax[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButcax[1] = new PIButton(this, "-Y", 5202,  pbsx, pbsy, cpx, cpy);
+mButcax[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButcax[2] = new PIButton(this, "X-Y", 5203, pbsx, pbsy, cpx, cpy);
+mButcax[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpx += 1.5*pbsx+pspx+10*pspx;
+mButoa[2] = new PIButton(this, "-All", 5300,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += 1.5*pbsx+pspx;
+mButoa[3] = new PIButton(this, "+Curs", 5321,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += 1.5*pbsx+pspx;
+mButoa[4] = new PIButton(this, "+Axe", 5331,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+curlutw = this;
+
+}
+
+/* --Methode-- */
+PIImgTools::~PIImgTools()
+{
+if (curlutw == this)  curlutw = NULL;
+int i;
+for(i=0; i<2; i++)
+  {
+  delete mLab[i];
+  delete mBut[i];
+  delete mText[i];
+  delete mOpt[i];
+  delete mOlb[i];
+  delete mSc[i];
+  delete mOptzc[i];
+  }
+for(i=0; i<5; i++)  delete mButsz[i];
+for(i=0; i<3; i++)  delete mButcax[i];
+for(i=0; i<5; i++)  delete mButoa[i];
+
+}
+
+/* --Methode-- */
+void PIImgTools::Show()
+{
+char buff[32];
+PIImage *mpii;
+PIWindow::Show();
+mpii = PIImage::CurrentPIImage();
+if (mpii == NULL)  return;
+min_lut = mpii->Lut()->Min();
+max_lut = mpii->Lut()->Max();
+sprintf(buff,"%g", min_lut);
+mText[0]->SetText(buff);
+sprintf(buff,"%g", max_lut);
+mText[1]->SetText(buff);
+if ( (mpii->Lut())->Type() == kLutType_Lin ) 
+  mOpt[0]->SetValue(1100);
+else mOpt[0]->SetValue(1101);
+string s("NoAuto");
+mOpt[1]->SetValueStr(s);
+mSc[0]->SetValue(0);
+mSc[1]->SetValue(0);
+mOptzc[0]->SetValue(203);
+mOptzc[1]->SetValue(101);
+return;
+}
+
+
+/* --Methode-- */
+void PIImgTools::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+double min, max, del;
+int lauto, typ;
+int typlut[2] = {kLutType_Lin, kLutType_Log} ; 
+
+msg = UserMsg(msg);
+
+if (msg == 2600)  { this->Hide();  return; }
+PIImage* mpii = PIImage::CurrentPIImage();
+if (mpii == NULL)  return;
+
+switch (msg)
+  {
+  case 2500:
+  case 2700 :
+  case 2800 :
+    {
+    min = atof(mText[0]->GetText().c_str());
+    max = atof(mText[1]->GetText().c_str());
+    if (msg == 2700) {
+      del = max_lut-min_lut;
+      min = min_lut+(double)mSc[0]->GetValue()/100*del;
+      max = max_lut+(double)mSc[0]->GetValue()/100*del;
+    }
+    if (msg == 2800) {
+      del = max_lut-min_lut;
+      min = min_lut-(double)mSc[1]->GetValue()/100.*del*0.5;
+      max = max_lut+(double)mSc[1]->GetValue()/100.*del*0.5;
+    }
+    if ( (msg == 2700) || (msg == 2800) ) {
+      char buff[92];
+      sprintf(buff,"%g", min);
+      mText[0]->SetText(buff);
+      sprintf(buff,"%g", max);
+      mText[1]->SetText(buff);
+      lauto = 0;
+    }
+    else lauto = mOpt[1]->GetValue() - 1200;
+    typ = mOpt[0]->GetValue() - 1100;
+    if ( (typ < 0) || (typ > 1) )  typ = 0;
+    (PIImage::CurrentPIImage())->SetLut(min, max, typlut[typ], lauto);
+    if (msg == 2500) { 
+      min_lut = min;   max_lut = max;
+      mSc[0]->SetValue(0);
+      mSc[1]->SetValue(0);
+      }
+//    ((PIImage::CurrentPIImage())->Lut())->Print();
+    }
+    break;
+
+  case 3201 :
+  case 3202 :
+  case 3204 :
+  case 3198 :
+  case 3196 :
+    {
+    PIImage* pimg = PIImage::CurrentPIImage();
+    int zm = msg-3200;
+    pimg->SetZoom(zm, false);
+    int sx, sy, snx, sny;
+    sx = pimg->XSize();
+    sy = pimg->YSize();
+    if (zm > 0)
+      {
+      snx = pimg->Image()->XSize()*zm;
+      sny = pimg->Image()->YSize()*zm;
+      }
+    else 
+      {
+      snx = pimg->Image()->XSize()/(-zm);
+      sny = pimg->Image()->YSize()/(-zm);
+      }
+    if ((snx != sx) || (sny != sy))
+      {
+      int szinc[2];
+      pimg->SetOffset(0, 0, false);
+      szinc[0] = snx-sx;   szinc[1] = sny-sy;
+      pimg->Send(pimg->Msg(), PIMsg_ResizeRequest, szinc);  
+      }
+    else   pimg->SetOffset(0, 0);
+    
+    }
+    break;
+
+  case 5201 :
+    mpii->ChangeAxesConfiguration(true, false, false);
+    break;
+  case 5202 :
+    mpii->ChangeAxesConfiguration(false, true, false);
+    break;
+  case 5203 :
+    mpii->ChangeAxesConfiguration(false, false, true);
+    break;
+
+
+  case 5300 :
+    mpii->SetDrawAxesFlags(kAxesNone);
+    mpii->ShowCursor(false);
+    mpii->MyElDrawer()->ElDelAll();
+    mpii->Refresh();
+    break;
+
+  case 5311 :
+    mpii->ShowInfo(true);
+    break;
+
+  case 5312 :
+    mpii->ShowInfo(false);
+    break;
+
+  case 5321 :
+    mpii->ShowCursor(true);
+    break;
+
+  case 5331 :
+    mpii->SetDrawAxesFlags();
+    break;
+
+  default:
+//    printf("PIImgTools::Process Msg %d received \n", (int)msg);
+    break;
+  }
+
+
+CMapId cmap[10] =  { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32,
+                      CMAP_COLBR32, CMAP_COLRV32, CMAP_GREY128,
+                      CMAP_GREYINV128, CMAP_COLRJ128, CMAP_COLBR128,
+                      CMAP_COL16 };
+
+if ((msg <= 110) && (msg >= 90))  // Zoom
+  PIImage::CurrentPIImage()->SetZoom((int)(msg-100), true);
+else if ((msg > 200) && (msg < 211)) // Changement de couleur 
+  PIImage::CurrentPIImage()->SetColMapId(cmap[msg-201], true);
+
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/piimgtools.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piimgtools.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piimgtools.h	(revision 1307)
@@ -0,0 +1,49 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Outils de manipulation des PIImage  R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIIMGTOOLS_H_SEEN
+#define PIIMGTOOLS_H_SEEN
+
+#include "pisysdep.h"
+#include PISTDWDG_H
+#include PIOPTMENU_H
+#include PIWIN_H
+#include PIAPP_H
+
+// ------ fenetre de dialogue pour changement de LUT et options de PIImage --------
+// --------------------------------------------------------------------------------
+
+class PIImgTools : public PIWindow {
+public :
+  PIImgTools(PIApplication* par);
+  ~PIImgTools();
+  virtual void  Show();
+
+  static PIImgTools* curlutw;
+  static void ShowPIImgTools();
+protected:
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+// Pour changer la LUT
+  PILabel* mLab[2];
+  PIButton* mBut[2];
+  PIText* mText[2];
+  PIOptMenu* mOpt[2];
+  PILabel* mOlb[2];
+  PIScale* mSc[2];
+  float min_lut,max_lut;
+// Pour la couleur et le zoom
+  PIOptMenu* mOptzc[2];
+// Pour expand et compress
+  PIButton* mButsz[5];
+// Config axes 
+  PIButton* mButcax[3];
+// Options show/hide
+  PIButton* mButoa[5];
+};
+
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pilistgen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pilistgen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pilistgen.cc	(revision 1307)
@@ -0,0 +1,74 @@
+// Module PI : Peida Interactive     PIList
+// Liste                                     96-97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pilistgen.h"
+
+//++
+// Class	PIList
+// Lib		PI
+// include	pilistgen.h
+//
+//	Composant graphique de type liste, permettant d'afficher une liste 
+//	d'éléments, qui peuvent être sélectionnés à l'aide du pointeur (souris). 
+//	"PIListGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIList" déclarée dans le fichier
+//	entête "PILIST_H". Lors de la sélection d'un des éléments, 
+//	le message correspondant complété par "PIMsg_Select" est envoyé.
+//	Le modifier "PIMsg_ClearSel" est appliqué lorsque d'une dé-sélection.
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur
+//--
+//++
+// PIListGen(PIContainerGen* par, char* nom, int sx=100, int sy=100, int px=0, int py=0)
+//	Création d'un objet liste (PIList). 
+//--
+
+//++
+// Titre	Ajout et suppression d'éléments
+//--
+//++
+// void  AppendItem(char* nom, PIMessage msg)
+//	Ajoute un élément à la liste.
+// void  DeleteItem(const char *item)
+//	Supprime l'élément "item" de la liste.
+// void  DeleteItemMsg(PIMessage msg)
+//	Supprime l'élément identifié par le message "msg" de la liste.
+//--
+//++
+// Titre	Gestion des sélections
+//--
+//++
+// void  SetMultipleSelect(bool ms=false)
+//	Active ("ms=true") ou désactive la possibilité de sélection multiple.
+// int   GetNbSelection()
+//	Renvoie le nombre d'éléments sélectionnés.
+// PIMessage  GetSelection(int num=0)
+//	Renvoie le message correspondant à la sélection numéro "n". L'ordre 
+//	dans lequel les sélections sont retournées est indéfini.
+// string   GetSelectionStr(int num=0)
+//	Renvoie la chaîne de caractères correspondant à l'élément sélectionné 
+//	numéro "n".
+// void  SelectItem(const char* item)
+//	Permet de sélectionner l'élément "item".
+// void  SelectItemMsg(PIMessage msg)
+//	Permet de sélectionner l'élément identifié par le message "msg".
+// void  ClearSelItem(const char* item)
+//	Efface la sélection pour l'élément "item".
+// void  ClearSelItemMsg(PIMessage msg)
+//	Efface la sélection pour l'élément identifié par le message "msg".
+//--
+
+PIListGen::PIListGen(PIContainerGen *par, char *nom,
+                     int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PIListGen::~PIListGen()
+{}
Index: /tags/DPC_V0/Poubelle/PI/pilistgen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pilistgen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pilistgen.h	(revision 1307)
@@ -0,0 +1,37 @@
+#ifndef PILISTGEN_H_SEEN
+#define PILISTGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+
+class PIListGen : public PIWdg {
+public:
+  enum {ClassId = 1110};
+
+	             PIListGen(PIContainerGen* par, char* nom,
+                               int sx=100, int sy=100, int px=0, int py=0);
+	             ~PIListGen();
+				   
+  virtual void	     AppendItem(const char * item, PIMessage msg)=0;
+  virtual void       DeleteItem(const char *item)=0;
+  virtual void       DeleteItemMsg(PIMessage msg)=0;
+  
+  virtual void       SetMultipleSelect(bool ms=false)=0;
+
+  virtual int        GetNbSelection()=0;
+  virtual PIMessage  GetSelection(int num=0)=0;
+  virtual string     GetSelectionStr(int num=0)=0;
+
+  virtual void       SelectItem(const char * item)=0;
+  virtual void       SelectItemMsg(PIMessage msg)=0;
+  virtual void       ClearSelItem(const char * item)=0;
+  virtual void       ClearSelItemMsg(PIMessage msg)=0;
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+}; 
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pilistmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pilistmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pilistmac.cc	(revision 1307)
@@ -0,0 +1,92 @@
+#include<stdio.h>
+
+#include "pilistmac.h"
+
+
+
+
+/* --Methode-- */
+PIListMac::PIListMac(PIContainerGen* par, char* nom,
+                 int sx, int sy, int px, int py)
+: PIListGen(par, nom, sx, sy, px, py)
+{
+  delete mPane;
+  mPane = mPIPPList = new PIPPList(mPaneInfo, mViewInfo, this);
+  Manage();
+}
+
+/* --Methode-- */
+PIListMac::~PIListMac()
+{
+}
+
+
+/* --Methode-- */
+void PIListMac::AppendItem(const char * item, PIMessage msg)
+{
+  mPIPPList->AppendItem(item, msg);
+}
+
+/* --Methode-- */
+void PIListMac::DeleteItem(const char * item)
+{
+  mPIPPList->DeleteItem(item);
+}
+
+/* --Methode-- */
+void PIListMac::DeleteItem(PIMessage msg)
+{
+  mPIPPList->DeleteItem(msg);
+}
+
+
+/* --Methode-- */
+void PIListMac::SetMultipleSelect(bool ms)
+{
+  mPIPPList->SetMultipleSelect(ms);
+}
+
+/* --Methode-- */
+int PIListMac::GetNbSelection()
+{
+  return mPIPPList->GetNbSel();
+}
+
+/* --Methode-- */
+PIMessage PIListMac::GetSelection(int num)
+{
+  return mPIPPList->GetSelMsg(num);
+}
+
+/* --Methode-- */
+string PIListMac::GetSelectionStr(int num)
+{
+  return mPIPPList->GetSelStr(num);
+}
+
+/* --Methode-- */
+void PIListMac::SelectItem(const char * item)
+{
+  mPIPPList->SelectItem(item);
+}
+
+/* --Methode-- */
+void PIListMac::SelectItem(PIMessage msg)
+{
+  mPIPPList->SelectItem(msg);
+}
+
+
+/* --Methode-- */
+void PIListMac::ClearSelItem(const char * item)
+{
+  mPIPPList->ClearSelItem(item);
+}
+
+/* --Methode-- */
+void PIListMac::ClearSelItem(PIMessage msg)
+{
+  mPIPPList->ClearSelItem(msg);
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/pilistmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pilistmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pilistmac.h	(revision 1307)
@@ -0,0 +1,35 @@
+#ifndef PILISTMAC_H_SEEN
+#define PILISTMAC_H_SEEN
+
+#include "pilistgen.h"
+#include "pipplist.h"
+
+class PIListMac : public PIListGen {
+public:
+	             PIListMac(PIContainerGen* par, char* nom,
+                             int sx=100, int sy=100, int px=0, int py=0);
+	             ~PIListMac();
+				   
+  virtual void	     AppendItem(const char * item, PIMessage msg);
+  virtual void       DeleteItem(const char *item);
+  virtual void       DeleteItem(PIMessage msg);
+
+  virtual void       SetMultipleSelect(bool ms=false);
+
+  virtual int        GetNbSelection();
+  virtual PIMessage  GetSelection(int num=0);
+  virtual string     GetSelectionStr(int num=0);
+
+  virtual void       SelectItem(const char * item);
+  virtual void       SelectItem(PIMessage msg);
+  virtual void       ClearSelItem(const char * item);
+  virtual void       ClearSelItem(PIMessage msg);
+
+
+protected:
+  PIPPList* mPIPPList;
+};
+
+typedef PIListMac        PIList;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pilistx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pilistx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pilistx.cc	(revision 1307)
@@ -0,0 +1,387 @@
+#include<stdio.h>
+
+#include "pilistx.h"
+#include "picontainerx.h"
+
+#include <Xm/Xm.h>
+#include <Xm/List.h>
+
+
+/************* PIListX ************/
+
+// Pour ces sal... de XmString  (ds piwdgx.cc)
+int CStrFrXmStr(XmString xms, char* buff, int nmx);
+
+// Fonction prive (CallBack)
+static void list_action(Widget w, XtPointer *usd, XmListCallbackStruct *isel);
+
+/* Nouvelle-Fonction */
+void  list_action(Widget /*w*/, XtPointer *usd, XmListCallbackStruct *isel)
+{
+PIListX *pil;
+
+pil = (PIListX *)usd ;
+//  printf("list_action/Debug: reason=%d itemPos= %d \n", 
+//          isel->reason, isel->item_position);
+pil->ToggleSel(isel->item_position-1, true);
+return;
+}
+
+
+#define NBITEMB  20
+#define NBISELB  5
+
+
+/* --Methode-- */
+PIListX::PIListX(PIContainerGen* par, char* nom,
+                 int sx, int sy, int px, int py)
+: PIListGen(par, nom, sx, sy, px, py)
+{
+
+mNItem = mNItemMax = 0;
+mMess = NULL;  mSel = NULL;
+mNbSel = mNSelMax = 0;
+mSelNum = NULL;
+ 
+Arg  warg[3];
+int n = 0;
+XtSetArg(warg[n], XmNlistSizePolicy, XmCONSTANT);  n++;
+XtSetArg(warg[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED);  n++;
+mlist = XmCreateScrolledList(((PIWdgX *)par)->XtWdg(), nom, warg, n);
+XtManageChild(mlist);
+XtWdg() = XtParent(mlist);
+SetSize(sx, sy);
+SetPos(px, py);
+wmis = k_wmi_normal ;
+stmng = 0;
+
+//XtAddCallback(mlist, XmNdefaultActionCallback,
+//              list_action, (XtPointer)this);
+XtAddCallback(mlist, XmNmultipleSelectionCallback,
+              (XtCallbackProc)list_action, (XtPointer)this);
+XtAddCallback(mlist, XmNsingleSelectionCallback,
+              (XtCallbackProc)list_action, (XtPointer)this);
+
+SetMultipleSelect(false);
+Manage();
+}
+
+/* --Methode-- */
+PIListX::~PIListX()
+{
+
+if (mNItemMax > 0)  
+  {
+    //  XtFree((char *)mItems);
+  delete[] mMess;
+  delete[] mSel;
+  }  
+if (mNSelMax > 0)  delete[] mSelNum;
+}
+
+
+/* --Methode-- */
+void PIListX::AppendItem(const char * item, PIMessage msg)
+{
+
+if (mNItem >= mNItemMax)
+  {
+  PIMessage *mso;
+  bool *slo;
+  int i;
+
+  mso = mMess;
+  slo = mSel;
+  mNItemMax += NBITEMB;
+  mMess = new PIMessage[mNItemMax];
+  mSel = new bool[mNItemMax];
+  for(i=0; i<mNItem; i++)   
+    {  mMess[i] = mso[i];  mSel[i] = slo[i]; }
+
+  delete[] mso;
+  delete[] slo;
+  }
+
+mMess[mNItem] = msg;
+mSel[mNItem] = false;
+mNItem++;
+
+#if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
+XmString xms = XmStringCreate(const_cast<char *>(item), XmSTRING_DEFAULT_CHARSET);
+#else
+XmString xms = XmStringCreate((char *)(item), XmSTRING_DEFAULT_CHARSET);
+#endif
+XmListAddItem(mlist, xms, 0);
+XmStringFree(xms);
+return;
+}
+
+/* --Methode-- */
+void PIListX::DeleteItem(const char * item)
+{
+int n;
+if ((n=GetNumItem(item)) < 0)  return;
+DelItem(n);
+return;
+}
+
+/* --Methode-- */
+void PIListX::DeleteItemMsg(PIMessage msg)
+{
+int n;
+if ((n=GetNumItemMsg(msg)) < 0)  return;
+DelItem(n);
+return;
+}
+
+
+/* --Methode-- */
+void PIListX::SetMultipleSelect(bool ms)
+{
+Arg  warg[2];
+
+mMultSel = ms;
+if (ms)
+  XtSetArg(warg[0], XmNselectionPolicy, XmMULTIPLE_SELECT);  
+else
+  XtSetArg(warg[0], XmNselectionPolicy, XmSINGLE_SELECT);  
+
+XtSetValues(mlist, warg, 1);
+}
+
+/* --Methode-- */
+int PIListX::GetNbSelection()
+{
+return(mNbSel);
+}
+
+/* --Methode-- */
+PIMessage PIListX::GetSelection(int num)
+{
+if ( (num < 0) || (num >= mNbSel) ) return(0); 
+return(ItemMsg(mSelNum[num]));
+}
+
+/* --Methode-- */
+string PIListX::GetSelectionStr(int num)
+{
+if ( (num < 0) || (num >= mNbSel) ) return(""); 
+string s(ItemStr(mSelNum[num]));
+return(s);
+}
+
+/* --Methode-- */
+void PIListX::SelectItem(const char * item)
+{
+int n;
+if ((n=GetNumItem(item)) < 0)  return;
+if ((!mMultSel) && (mNbSel > 0))
+  if  (mSelNum[0] != n)  ClrSItem(mSelNum[0], false, true);  
+SelItem(n, false, true);
+return;
+}
+
+/* --Methode-- */
+void PIListX::SelectItemMsg(PIMessage msg)
+{
+int n;
+if ((n=GetNumItemMsg(msg)) < 0)  return;
+if ((!mMultSel) && (mNbSel > 0))
+  if  (mSelNum[0] != n)  ClrSItem(mSelNum[0], false, true);  
+SelItem(n, false, true);
+return;
+}
+
+
+/* --Methode-- */
+void PIListX::ClearSelItem(const char * item)
+{
+int n;
+if ((n=GetNumItem(item)) < 0)  return;
+ClrSItem(n, false, true);
+return;
+}
+
+/* --Methode-- */
+void PIListX::ClearSelItemMsg(PIMessage msg)
+{
+int n;
+if ((n=GetNumItemMsg(msg)) < 0)  return;
+ClrSItem(n, false, true);
+return;
+}
+
+
+/* --Methode-- */
+void PIListX::ToggleSel(int n, bool smg)
+{
+if ( (n < 0) || (n >= mNItem))  return;
+if (mSel[n])  ClrSItem(n,smg); 
+else
+  {
+  if ((!mMultSel) && (mNbSel > 0))  ClrSItem(mSelNum[0], smg);
+  SelItem(n, smg);
+  }
+}
+
+
+/* --Methode-- */
+PIMessage PIListX::ItemMsg(int n)
+{
+if ( (n < 0) || (n >= mNItem))  return(0);
+else return(mMess[n]);
+}
+
+/* --Methode-- */
+char * PIListX::ItemStr(int n)
+{
+Arg  warg[2];
+XmString *xmst=NULL;
+
+if ( (n < 0) || (n >= mNItem))  { mSItem[0] = '\0'; return(mSItem); }
+mSItem[0] = '\0';
+XtSetArg(warg[0], XmNitems, &xmst);  
+XtGetValues(mlist, warg, 1);
+CStrFrXmStr(xmst[n], mSItem, 320);
+return(mSItem);
+}
+
+/* --Methode-- */
+int PIListX::GetNumItem(const char *it)
+{
+for(int i=0; i<mNItem; i++)
+  if (strcmp(ItemStr(i), it) == 0)  return(i);
+return(-1);
+}
+
+/* --Methode-- */
+int PIListX::GetNumItemMsg(PIMessage msg)
+{
+for(int i=0; i<mNItem; i++)
+  if (mMess[i] == msg)   return(i);  
+return(-1);
+}
+
+
+
+/* --Methode-- */
+void PIListX::DelItem(int n)
+{
+int i;
+
+if ((n < 0) || (n > mNItem))  return;
+
+ClrSItem(n);
+for(i=n; i<mNItem-1; i++)
+  { mMess[i] = mMess[i+1];  mSel[i] = mSel[i+1]; }
+mNItem--;
+
+if (mNItem < (mNItemMax-NBITEMB-1))
+  {
+    //  XmString *ito;
+  PIMessage *mso;
+  bool *slo;
+
+  //  ito = mItems;
+  mso = mMess;
+  slo = mSel;
+  mNItemMax -= NBITEMB;
+  mMess = new PIMessage[mNItemMax];
+  mSel = new bool[mNItemMax];
+  //  mItems = (XmString *) XtMalloc(sizeof(XmString)*mNItemMax);
+  for(i=0; i<mNItem; i++)   
+    { // mItems[i] = ito[i];
+    mMess[i] = mso[i];  mSel[i] = slo[i]; }
+
+  //  XtFree((char *)mItems);
+  delete[] mso;
+  delete[] slo;
+  }
+
+XmListDeletePos(mlist, n+1);
+return;
+}
+
+
+/* --Methode-- */
+bool PIListX::SelItem(int n, bool smg, bool cxw)
+{
+int i;
+
+if ((n < 0) || (n > mNItem))  return(false);
+if (mSel[n])  return(false);
+
+mSel[n] = true;
+if (mNbSel >= mNSelMax)
+  {
+  int * osel;
+  osel = mSelNum;
+  mNSelMax += NBISELB;
+  mSelNum = new int[mNSelMax];
+  for(i=0; i<mNbSel; i++)  mSelNum[i] = osel[i];
+  if (osel)  delete[] osel;
+  }
+
+mSelNum[mNbSel] = n; 
+mNbSel++;
+if (smg)  
+  Send(mMess[n], PIMsg_Select); 
+if (cxw)
+  XmListSelectPos(mlist, n+1, FALSE);
+return(true);
+}
+
+
+
+
+/* --Methode-- */
+bool PIListX::ClrSItem(int n, bool smg, bool cxw)
+{
+int i;
+if ((n < 0) || (n > mNItem))  return(false);
+if (!mSel[n])  return(false);
+mSel[n] = false;
+
+mNbSel --;
+if (smg)  
+  Send(mMess[n], PIMsg_ClearSel); 
+if (cxw)
+  XmListDeselectPos(mlist, n+1);
+
+if (mSelNum) delete[] mSelNum;
+if (mNbSel <= 0)
+  { mNSelMax = mNbSel = 0;  mSelNum = NULL; }
+else
+  {
+  mNSelMax = (mNbSel+NBISELB)/NBISELB;
+  mSelNum = new int[mNSelMax];
+  mNbSel =  0;
+  for(i=0; i<mNItem; i++)
+    if (mSel[i]) { mSelNum[mNbSel] = i; mNbSel++; }
+  }
+
+return(true);
+} 
+
+
+/* --Methode-- 
+    A Supprimer .....
+void PIListX::ChangeSel()
+{
+XmString *xmst;
+int n;
+
+n=0;
+XtSetArg(warg[n], XmNselectedItems, &xmst);  n++;
+XtGetValues(mlist, warg, n);
+if (xmst)  XtFree(xmst);
+xmst =  (XmString *) XtMalloc(sizeof(XmString)*mNbSel);
+for(i=0; i<mNbSel; i++)
+  xmst[i] = mItems[mSelNum[i]];
+n=0;
+XtSetArg(warg[n], XmNselectedItems, xmst);  n++;
+XtSetArg(warg[n], XmNselectedItemCount, mNbSel);  n++;
+XtSetValues(mlist, warg, n);
+return;
+}
+   .....  */
Index: /tags/DPC_V0/Poubelle/PI/pilistx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pilistx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pilistx.h	(revision 1307)
@@ -0,0 +1,52 @@
+#ifndef PILISTX_H_SEEN
+#define PILISTX_H_SEEN
+
+#include "pilistgen.h"
+
+class PIListX : public PIListGen {
+public:
+	             PIListX(PIContainerGen* par, char* nom,
+                             int sx=100, int sy=100, int px=0, int py=0);
+	             ~PIListX();
+				   
+  virtual void	     AppendItem(const char * item, PIMessage msg);
+  virtual void       DeleteItem(const char *item);
+  virtual void       DeleteItemMsg(PIMessage msg);
+
+  virtual void       SetMultipleSelect(bool ms=false);
+
+  virtual int        GetNbSelection();
+  virtual PIMessage  GetSelection(int num=0);
+  virtual string     GetSelectionStr(int num=0);
+
+  virtual void       SelectItem(const char * item);
+  virtual void       SelectItemMsg(PIMessage msg);
+  virtual void       ClearSelItem(const char * item);
+  virtual void       ClearSelItemMsg(PIMessage msg);
+
+// Mis en public pour Callback Xt
+  virtual void       ToggleSel(int n, bool smg=false);
+
+protected:
+  PIMessage          ItemMsg(int n);
+  char *             ItemStr(int n);
+  int                GetNumItem(const char * nom);
+  int                GetNumItemMsg(PIMessage msg);
+  void               DelItem(int n);
+  bool               SelItem(int n, bool smg=false, bool cxw=false);
+  bool               ClrSItem(int n, bool smg=false, bool cxw=false);
+
+int mNItem, mNItemMax;
+PIMessage * mMess;
+bool * mSel;
+int mNbSel, mNSelMax;
+int * mSelNum;
+bool mMultSel;
+char mSItem[320];
+
+SysDWdg mlist;
+};
+
+typedef PIListX        PIList;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pimak
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimak	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimak	(revision 1307)
@@ -0,0 +1,143 @@
+CC := gcc
+CXX := g++
+# General setup GNU Makefile for EROS. To be included in all makefiles.  
+# Define  makefile variables according to CPU
+# MACHEROSD = `uname | sed 's/-//'`   i.e. { AIX HPUX OSF1 ULTRIX }
+# 
+# Makefile variables set are:
+# - Path to Exec, Include, Libs, Objs directories (from EROSBASEREP env. var.)
+#     i.e. variables LIB, OBJ, EXE, INC 
+#---------------------------------------------------------------------------
+
+# define MACHEROS from uname
+MACHEROS := $(shell echo `uname`)
+# define the -D option
+MACHEROSD := $(shell echo `uname | sed 's/-//'`)
+
+#-
+#-     Optimization option different for HP...
+ifeq (${MACHEROS},HP-UX)
+  O := +O
+else
+  O := -O
+endif
+#-
+#-   Define Makefile paths
+#-  
+ PP  := ${EROSBASEREP}/${MACHEROS}/
+ LIB := ${PP}/Libs/
+ SLB := ${PP}/ShLibs/
+ OBJ := ${PP}/Objs/
+ EXE := ${PP}/Exec/
+ INC := ${EROSBASEREP}/Include/
+ CCI := ${INC}/CInc/
+ CXI := ${INC}/CxxInc/
+#--
+
+#-
+#-    Define default compilation flags
+#--
+ifeq (${MACHEROS},HP-UX)                                    
+  CFLAGS   :=  -Aa
+  FFLAGS   :=  -Aa -I${INC} -D${MACHEROSD}  
+  CPPFLAGS :=  -I${INC} -D${MACHEROSD} \
+               -D_INCLUDE_POSIX_SOURCE -D_INCLUDE_XOPEN_SOURCE
+else
+  FFLAGS   :=  -I${INC} -D${MACHEROSD}  
+  CPPFLAGS :=  -I${INC} -D${MACHEROSD}
+endif
+AR       := ar
+ARFLAGS  := -rcs
+
+ifeq ($(CC), gcc)
+CFLAGS       := -g -O -Wall -Wpointer-arith \
+                -Wmissing-prototypes -Wsynth -I$(INC)
+//CXXFLAGS     := $(CFLAGS) -fno-implicit-templates -I$(CXI)
+CXXFLAGS     := $(CFLAGS) -I$(CXI)
+endif
+
+#- redefine implicit rule. Les .o sont dans $(OBJ).
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -o $@ $<
+
+$(OBJ)%.o:%.cc
+	$(COMPILE.cc) -o $@ $<
+
+$(OBJ)%.o:%.f
+	$(COMPILE.f) -o $@ $< 
+
+#OSF1
+#LDFC est f77
+#LDFCFLAGS est rien
+
+#parfois
+#LDFC est cc
+#LDFCFLAGS est -ltruc
+
+#------------------------------------------------- End of Makefile.h ------- 
+all : piapp piapp_nosh
+
+piapp : $(EXE)piapp $(SLB)piup.so 
+ 
+piapp_nosh : $(EXE)piapp_nosh
+ 
+
+$(EXE)piapp  : $(OBJ)pidemo.o $(SLB)libPI.so $(SLB)libOuIm.so \
+               $(SLB)liberosc.so $(SLB)libStarReco.so 
+	cc -call_shared -o $(EXE)piapp $(OBJ)pidemo.o \
+              -L$(SLB) -lPI -lOuIm -lerosc -lStarReco \
+              -lgcxx -lXm -lXt -lX11 -lm  
+
+$(EXE)piapp_nosh  : $(OBJ)pidemo_nosh.o $(LIB)libPI.a $(LIB)libStarReco.a  \
+               $(LIB)libOutils.a $(LIB)libImages.a $(LIB)libmath.a $(LIB)libdiv.a 
+	g++ -o $(EXE)piapp_nosh $(OBJ)pidemo_nosh.o \
+              -L$(LIB) -lPI -lStarReco -lImages -lOutils -lmath -ldiv \
+              -lXm -lXt -lX11 -lm 
+ 
+$(SLB)piup.so : $(OBJ)piup_def.o \
+                $(SLB)libOuIm.so $(SLB)liberosc.so 
+	ld -shared -o $(SLB)piup.so -all $(OBJ)piup_def.o \
+        -none -L$(SLB) -lOuIm -lerosc -lgcxx -lm -lc
+
+$(OBJ)pidemo_nosh.o: pidemo.cc pidemo.h
+	g++ -g -O -c -Wall -Wpointer-arith \
+            -Wmissing-prototypes -Wsynth -I$(INC) -I$(CXI) \
+            -D C_NO_SHLIBS -o $(OBJ)pidemo_nosh.o pidemo.cc
+
+$(OBJ)pidemo.o: ./pidemo.cc \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)fitsimage.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)datatypes.h \
+ $(INC)fitsheader.h \
+ $(INC)fitskeys.h pidemo.h \
+ pisysdep.h piapplx.h piapplgen.h pimsghandler.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimenubarx.h pimenubargen.h \
+ pimenux.h pimenugen.h piwindowx.h piwindowgen.h pioptmenux.h \
+ pioptmenugen.h pistdwdgx.h pistdwdggen.h pifilechox.h pifilechogen.h \
+ piimage.h $(INC)lut.h \
+ pipixmapx.h pipixmapgen.h pibwdgx.h pibwdggen.h picmap.h picmapx.h \
+ picmapgen.h pihisto.h piscdrawwdg.h \
+ $(INC)histos.h \
+ $(INC)peida.h \
+ $(INC)utils.h pidrawwin.h \
+ $(INC)piup.h
+$(OBJ)piup_def.o: piup_def.cc  piup.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)fitsimage.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)datatypes.h \
+ $(INC)fitsheader.h \
+ $(INC)fitskeys.h \
+ $(INC)utils.h $(INC)peida.h 
+
Index: /tags/DPC_V0/Poubelle/PI/pimenubargen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenubargen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenubargen.cc	(revision 1307)
@@ -0,0 +1,54 @@
+// Module PI : Peida Interactive     PIMenubar
+// Barre de menu                        96-97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pimenubargen.h"
+
+#include PIAPP_H
+
+//++
+// Class	PIMenubar
+// Lib		PI
+// include	pimenubargen.h
+//
+//	Composant graphique de type Barre des menus . 
+//	"PIMenubarGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIMenubar" déclarée dans le fichier
+//	entête "PIMENUBAR_H". 
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Links	Voir aussi
+// PIMenu
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIMenubar(PIApplicationGen* par, char* nom)
+//	Création d'un objet Menubar.
+// void  AppendMenu(PIMenu* pdm)
+//	Rajoute un menu à la barre de menu. Le menu sera affiché avec un titre identique à son nom.
+// void  RemoveMenu(PIMenu* pdm)
+//	Supprime le menu "pdm" de la barre de menu, sans le détruire (delete).
+// void  SetSensitivity(PIMenu* pdm, bool sens=true)
+//	Permet de rendre sensible ("sens=true") ou insensible un menu. Le titre d'un menu
+//	insensible est affiché, mais ne peut être séléctionné.
+// bool  IsSensitive(PIMenu* pdm)
+//	Indique si le menu "pdm" est sensible ou pas.
+//--
+
+PIMenubarGen::PIMenubarGen(PIApplicationGen* par, char* nom)
+: PIWdg(NULL, nom)
+{
+SetMsgParent(par);
+}
+
+PIMenubarGen::~PIMenubarGen()
+{}
+
+
Index: /tags/DPC_V0/Poubelle/PI/pimenubargen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenubargen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenubargen.h	(revision 1307)
@@ -0,0 +1,24 @@
+#ifndef PIMBARGEN_H_SEEN
+#define PIMBARGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIMENU_H
+
+class PIApplicationGen;
+
+class PIMenubarGen : public PIWdg {
+public:
+  enum {ClassId = 2600};
+
+	            PIMenubarGen(PIApplicationGen* par, char* nom);
+	            ~PIMenubarGen();
+				   
+  virtual void      AppendMenu(PIMenu *pdm)=0;
+  virtual void      RemoveMenu(PIMenu *pdm)=0;
+  virtual void      SetSensitivity(PIMenu *pdm, bool sens=true)=0;
+  virtual bool      IsSensitive(PIMenu *pdm)=0;
+
+  virtual long      kind() {return ClassId; }
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pimenubarmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenubarmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenubarmac.cc	(revision 1307)
@@ -0,0 +1,18 @@
+#include "pimenubarmac.h"
+#include "pippmenubar.h"
+#include <LMenuBar.h>
+
+PIMenubarMac::PIMenubarMac(PIApplicationGen* par, char* nom)
+:PIMenubarGen(par, nom)
+{
+	new PIPPMenuBar();
+}
+
+PIMenubarMac::~PIMenubarMac()
+{}
+
+void
+PIMenubarMac::AppendMenu(PIPDMenu *pdm)
+{
+  LMenuBar::GetCurrentMenuBar()->InstallMenu(pdm->macMenu, InstallMenu_AtEnd);
+}
Index: /tags/DPC_V0/Poubelle/PI/pimenubarmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenubarmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenubarmac.h	(revision 1307)
@@ -0,0 +1,16 @@
+#ifndef PIMBARMAC_H_SEEN
+#define PIMBARMAC_H_SEEN
+
+#include "pimenubargen.h"
+
+class PIMenubarMac : public PIMenubarGen {
+ public:
+	            PIMenubarMac(PIApplicationGen* par, char* nom);
+	           ~PIMenubarMac();
+ virtual void	AppendMenu(PIPDMenu *pdm);
+
+};
+
+typedef PIMenubarMac   PIMenubar;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pimenubarx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenubarx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenubarx.cc	(revision 1307)
@@ -0,0 +1,105 @@
+#include<stdio.h>
+
+#include "pimenubarx.h"
+#include PIAPP_H
+
+#include <Xm/Xm.h>
+#include <Xm/RowColumn.h>
+#include <Xm/PushB.h>
+#include <Xm/ToggleB.h>
+#include <Xm/CascadeB.h>
+
+/************* PIMenubarX ************/
+
+#define NBITEMB  10
+
+/* --Methode-- */
+PIMenubarX::PIMenubarX(PIApplicationGen* par, char* nom)
+: PIMenubarGen(par, nom)
+{
+mNItem = 0;  mNItemMax = NBITEMB; 
+mMbb = new _pimbxit_[mNItemMax];
+
+XtWdg() = XmCreateMenuBar( ((PIApplicationX *)par)->MBCont()->XtWdg(), 
+                            nom, NULL, 0); 
+
+wmis = k_wmi_normal ;
+stmng = 0;
+
+SetPos(0,0);
+SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_free);
+
+Manage();
+}
+
+
+/* --Methode-- */
+PIMenubarX::~PIMenubarX()
+{
+for(int i=0; i<mNItem; i++)
+  XtDestroyWidget(mMbb[i].itb);
+delete[] mMbb ;
+}
+
+/* --Methode-- */
+void PIMenubarX::AppendMenu(PIMenu *pdm)
+{
+_pimbxit_ *buto;
+Arg  wargs[2];
+
+if (mNItem >= mNItemMax)
+  {
+  buto = mMbb;
+  mNItemMax += NBITEMB;
+  mMbb = new _pimbxit_[mNItemMax];
+  for(int i=0; i<mNItem; i++)   mMbb[i] = buto[i];
+  delete[] buto;
+  }
+XtSetArg(wargs[0], XmNsubMenuId, pdm->XtWdg());
+mMbb[mNItem].itb = XtCreateManagedWidget(pdm->Nom().c_str(), xmCascadeButtonWidgetClass, 
+                                         this->XtWdg(), wargs, 1) ;
+mMbb[mNItem].pdm = pdm;
+mNItem++;
+
+pdm->SetMsgParent(this);
+return;
+}
+
+/* --Methode-- */
+void PIMenubarX::RemoveMenu(PIMenu *pdm)
+{
+int i,j;
+for(i=0; i<mNItem; i++) 
+  if ( mMbb[i].pdm == pdm ) { 
+    XtDestroyWidget(mMbb[i].itb);
+    for(j=i; j<mNItem-1; j++) mMbb[j] = mMbb[j+1]; 
+    mNItem--;  break;  
+    }
+return;
+}
+
+/* --Methode-- */
+void PIMenubarX::SetSensitivity(PIMenu *pdm, bool sens)
+{
+int i;
+for(i=0; i<mNItem; i++) 
+  if ( mMbb[i].pdm == pdm ) { 
+    if (sens) XtSetSensitive(mMbb[i].itb, TRUE);
+    else XtSetSensitive(mMbb[i].itb, FALSE);
+    break;  
+    }
+return;
+}
+
+/* --Methode-- */
+bool PIMenubarX::IsSensitive(PIMenu *pdm)
+{
+int i;
+for(i=0; i<mNItem; i++) 
+  if ( mMbb[i].pdm == pdm ) { 
+    if (XtIsSensitive(mMbb[i].itb) == TRUE)  return(true);
+    else return(false);
+    break; 
+    }
+return(false);
+}
Index: /tags/DPC_V0/Poubelle/PI/pimenubarx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenubarx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenubarx.h	(revision 1307)
@@ -0,0 +1,32 @@
+#ifndef PIMBARX_H_SEEN
+#define PIMBARX_H_SEEN
+
+#include "pimenubargen.h"
+
+struct _pimbxit_ 
+{
+SysDWdg itb;
+PIMenu *pdm;
+};
+
+class PIMenubarX : public PIMenubarGen {
+ public:
+	            PIMenubarX(PIApplicationGen* par, char* nom);
+	            ~PIMenubarX();
+
+  virtual void	    AppendMenu(PIMenu *pdm);
+  virtual void      RemoveMenu(PIMenu *pdm);
+  virtual void      SetSensitivity(PIMenu *pdm, bool sens=true);
+  virtual bool      IsSensitive(PIMenu *pdm);
+
+ protected:
+
+int mNItem, mNItemMax;
+_pimbxit_ *mMbb;
+};
+
+
+typedef PIMenubarX     PIMenubar;
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pimenugen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenugen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenugen.cc	(revision 1307)
@@ -0,0 +1,123 @@
+// Module PI : Peida Interactive     PIMenu
+// Menu                                     96-97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pimenugen.h"
+
+//++
+// Class	PIMenu
+// Lib		PI
+// include	pimenugen.h
+//
+//	Composant graphique de type menu. 
+//	"PIMenuGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIMenu" déclarée dans le fichier
+//	entête "PIMENUBAR_H". Lors de la séléction d'une des options du menu
+//	Le message correspondant complété par "PIMsg_Click" est envoyé à l'objet
+//	par "SendSelf()".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Links	Voir aussi
+// PIMenubar
+//--
+
+
+
+//++
+// Titre	Constructeur
+//--
+//++
+// PIMenu(PIWdg* par, char* nom, PIMenuType pdpu=k_UTMenu)
+//	Création d'un objet Menubar. "pdpu" peut prendre les valeurs
+//	"k_UTMenu", "k_PopupMenu", "k_PulldownMenu". Un menu de type
+//	"PulldownMenu" est destiné à être accroché à un Menubar ou
+//	comme sous-menu d'un autre menu. Si l'objet parent est de type
+//	"PIMenu" ou "PIMenubar", un PulldownMenu est créé par défaut. Un 
+//	menu de type PopupMenu est créé dans les autres cas.
+// PIMenuType MType() 
+//	Renvoie le type du menu : "k_PopupMenu" ou  "k_PulldownMenu".
+//--
+
+//++
+// Titre	Ajout et suppression des options du menu
+//--
+//
+//++
+// void  AppendItem(char* nom, PIMessage msg, char* sc=NULL)
+//	Permet d'ajouter une option au menu. Un raccourci clavier peut être spécifié
+//	par "sc".
+// void  AppendCheckItem(char* nom, PIMessage msg, char* sc=NULL)
+//	Permet d'ajouter une option avec état ON/OFF au menu.
+// void	 AppendPDMenu(PIMenu* pdm, char* sc=NULL)
+//	Ajoute un menu déroulant comme sous-menu.
+// void  DeleteItem(char* nom)
+//	Permet de supprimer une option du menu identifiée par le titre ("nom").
+//	Si le nom désigne un menu déroulant, celui-ci n'est pas détruit (par "delete").
+// void  DeleteItemMsg(PIMessage msg)
+//	Permet de supprimer une option du menu identifiée par le message ("msg").
+// void  DeleteItemNum(int n)
+//	Suppression de l'option numéro "n".
+//--
+//++
+// Titre	Gestion des options 
+//--
+//++
+// void  SetSensitivity(char* nom, bool sens=true)
+//	Rend sensible ("sens=true") ou insensible l'option du menu identifiée par "nom".
+//	Une option insensible est affichée, mais ne peut être sélectionnée.
+// void  SetSensitivityMsg(PIMessage msg, bool sens=true)
+//	Rend sensible ("sens=true") ou insensible l'option du menu identifiée par le message "msg".
+// void  SetSensitivityNum(int n, bool sens=true)
+//	Rend sensible ("sens=true") ou insensible l'option numéro "n".
+// bool  IsSensitive(char* nom)
+//	Indique si l'option "nom" est sensible ou pas.
+// bool  IsSensitiveMsg(PIMessage msg)
+//	Indique si l'option identifiée par le message "msg" est sensible ou pas.
+// bool  IsSensitiveNum(int n)
+//	Indique si l'option numéro "n" est sensible ou pas.
+//--
+//++
+// Titre	Options à état (CheckItem)
+//	Le champ "data" de "Send()/SendSelf()" contient un pointeur sur une variable
+//	de type bool, indiquant l'état (On/Off) de l'option, lors de la séléction des
+//	options à état ("CheckItem"). Les méthodes suivantes ne s'appliquent qu'aux 
+//	options de type CheckItem.
+//--
+//++
+// void  SetState(char* nom, bool st=false)
+//	Change l'état de l'option "nom".
+// void  SetStateMsg(PIMessage msg, bool st=false)
+//	Change l'état de l'option identifiée par le message "msg".
+// void  SetStateNum(int n, bool st=false)
+//	Change l'état de l'option numéro "n".
+// bool GetState(char* nom)
+//	Renvoie l'état de l'option "nom".
+// bool GetStateMsg(PIMessage msg)
+//	Renvoie l'état de l'option identifiée par le message "msg".
+// bool GetStateNum(int n)
+//	Renvoie l'état de l'option numéro "n".
+//--
+
+//++
+// Titre	Affichage des PopupMenu
+//--
+//++
+// void  Show()
+//	Affiche le menu (de type "k_PopupMenu" uniquement) à la position courante du pointeur.
+// void  Show(PIWdg* w, int px, int py)
+//	Affiche le menu (de type "k_PopupMenu" uniquement) à la position "px,py" de l'objet "w". 
+//--
+
+PIMenuGen::PIMenuGen(PIWdg* par, char* nom, PIMenuType pdpu)
+: PIWdg(NULL, nom) , mMTyp(pdpu)
+{
+SetMsgParent(par);
+}
+
+PIMenuGen::~PIMenuGen()
+{}
+
Index: /tags/DPC_V0/Poubelle/PI/pimenugen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenugen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenugen.h	(revision 1307)
@@ -0,0 +1,52 @@
+#ifndef PIMENUGEN_H_SEEN
+#define PIMENUGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+enum PIMenuType { k_UTMenu = 0, k_PopupMenu = 1, k_PulldownMenu = 2 };
+
+
+class PIMenuGen : public PIWdg {
+public:
+  enum {ClassId = 2500};
+
+	          PIMenuGen(PIWdg* par, char* nom, PIMenuType pdpu=k_UTMenu);
+	          ~PIMenuGen();
+				   
+  virtual void	  AppendItem(char* nom, PIMessage msg, char* sc=NULL)=0;
+  virtual void	  AppendCheckItem(char* nom, PIMessage msg, char* sc=NULL)=0;
+  virtual void	  AppendPDMenu(PIMenuGen *pdm, char* sc=NULL)=0;
+
+  virtual void    DeleteItem(char *nom)=0;
+  virtual void    DeleteItemMsg(PIMessage msg)=0;
+  virtual void    DeleteItemNum(int n)=0;
+
+  virtual void    SetSensitivity(char *nom, bool sens=true)=0; 
+  virtual void    SetSensitivityMsg(PIMessage msg, bool sens=true)=0; 
+  virtual void    SetSensitivityNum(int n, bool sens=true)=0;
+
+  virtual bool    IsSensitive(char *nom)=0;
+  virtual bool    IsSensitiveMsg(PIMessage msg)=0;
+  virtual bool    IsSensitiveNum(int n)=0;
+
+  virtual void    SetState(char *nom, bool st=false)=0; 
+  virtual void    SetStateMsg(PIMessage msg, bool st=false)=0; 
+  virtual void    SetStateNum(int n, bool st=false)=0;
+ 
+  virtual bool    GetState(char *nom)=0; 
+  virtual bool    GetStateMsg(PIMessage msg)=0; 
+  virtual bool    GetStateNum(int n)=0; 
+
+  virtual void    Show()=0;
+  virtual void    Show(PIWdg *w, int px, int py)=0;
+
+  virtual long    kind() {return ClassId; }
+  virtual PIMenuType MType() { return  mMTyp; }
+
+protected:
+  PIMenuType mMTyp;
+}; 
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pimenumac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenumac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenumac.cc	(revision 1307)
@@ -0,0 +1,210 @@
+#include <LString.h>
+#include "pimenumac.h"
+#include <algorithm>
+
+int PIMenuMac::lastId = 1024;
+list<PIMenuMac*> PIMenuMac::sMenus;
+
+PIMenuMac::PIMenuMac(PIMsgHandler *par, char *nom, PIMenuType pdpu) 
+: PIMenuGen(par, nom, pdpu)
+{
+   macMenu = new LMenu(lastId, LStr255(nom));
+   mMenuId = lastId;
+   sMenus.push_back(this);
+   lastId++;
+}
+
+
+PIMenuMac::~PIMenuMac()
+{
+  LMenuBar::GetCurrentMenuBar()->RemoveMenu(macMenu);
+  sMenus.remove(this);
+  delete macMenu;
+}
+
+int
+PIMenuMac::FindItemByMsg(PIMessage msg)
+{
+  if (mMsgs.size() == 0) return -1;
+  int i = find(mMsgs.begin(), mMsgs.end(), msg) - mMsgs.begin();
+  return (i>=mMsgs.size()) ? -1 : i;
+}
+
+int
+PIMenuMac::FindItemByName(string const& s)
+{
+  int n = ::CountMItems(GetMacMenuHandle());
+  for (int i=0; i<n; i++)
+    if (GetMenuItemText(i) == s)
+      return i;
+  return -1;
+}
+
+
+void
+PIMenuMac::AppendItem(char* nom, PIMessage msg, char* sc)  // sc = short-cut , raccourci clavier
+{
+  LStr255 titre(nom);
+  if (titre.BeginsWith("-",1))
+    titre.Insert(" ", 1, 0);
+  if (sc) {
+    titre.Append('/');
+    titre.Append(*sc);
+  }
+  macMenu->InsertCommand(titre, -2000, 1000); // ou cmd_UseMenuItem ???
+  mMsgs.push_back(msg);
+}
+
+void
+PIMenuMac::CheckItemNum(int n, bool st)
+{
+  if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ?
+  ::CheckItem(macMenu->GetMacMenuH(), n, st);
+}
+
+void
+PIMenuMac::CheckItemMsg(PIMessage msg, bool st)
+{
+  int i = FindItemByMsg(msg);
+  if (i>=0)
+    CheckItemNum(i, st);
+}
+
+void
+PIMenuMac::CheckItem(char* nom, bool st)
+{
+  int i = FindItemByName(nom);
+  if (i>=0)
+    CheckItemNum(i, st);
+}
+
+void
+PIMenuMac::DeleteItemNum(int n)
+{
+  if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ?
+  macMenu->RemoveItem(n+1);
+  mMsgs.erase(mMsgs.begin()+n);
+}
+
+void
+PIMenuMac::DeleteItemMsg(PIMessage msg)
+{
+  int i = FindItemByMsg(msg);
+  if (i>=0)
+    DeleteItemNum(i);
+}
+
+void
+PIMenuMac::DeleteItem(char* nom)
+{
+  int i = FindItemByName(nom);
+  if (i>=0)
+    DeleteItemNum(i);
+}
+
+
+
+void
+PIMenuMac::ItemSelected(int item)
+{
+  if (item<0 || item >= mMsgs.size()) return; // $CHECK$ exception ?
+  Send(mMsgs[item], PIMsg_Click, (void*) GetMenuItemText(item).c_str());
+}
+
+
+void
+PIMenuMac::Show()
+{}
+
+void
+PIMenuMac::Show(PIWdg *w, int px, int py)
+{}
+
+void
+PIMenuMac::Hide()
+{}
+
+PIMenuMac*
+PIMenuMac::findMenu(int id)
+{
+  list<PIMenuMac*>::iterator i = sMenus.begin();
+  
+  while (i != sMenus.end()) {
+    if ((*i)->MenuId()==id) return *i;
+    i++;
+  }
+  
+  return NULL;
+}
+
+MenuHandle
+PIMenuMac::GetMacMenuHandle()
+{
+  return macMenu->GetMacMenuH();
+}
+
+ResIDT
+PIMenuMac::GetMacMenuID()
+{
+  return macMenu->GetMenuID();
+}
+
+
+string
+PIMenuMac::GetMenuItemText(int item)
+{
+  if (item<0 || item >= mMsgs.size()) return ""; // $CHECK$ exception ?
+  MenuHandle h = GetMacMenuHandle();
+  Str255 txt;
+  ::GetMenuItemText(h, item+1, txt);
+  p2cstr(txt);
+  return (char*) txt;
+}
+
+PIMenuMac::GetMenuItemMsg(int item)
+{
+  if (item<0 || item >= mMsgs.size()) return -1; // $CHECK$ exception ?
+  return mMsgs[item];
+}
+
+
+
+/* --Methode-- */
+PIPUMenuMac::PIPUMenuMac(PIMsgHandler* par, char* nom)
+: PIMenuMac(par, nom, k_PopupMenu)
+{
+}
+
+/* --Methode-- */
+PIPUMenuMac::~PIPUMenuMac()
+{
+}
+
+void
+PIPUMenuMac::Show()
+{
+  Point pt;
+  ::GetMouse(&pt);
+  ::LocalToGlobal(&pt);
+  int item = ::PopUpMenuSelect(macMenu->GetMacMenuH(),pt.v,pt.h,1);
+  ItemSelected(item);
+}
+
+void
+PIPUMenuMac::Show(PIWdg *w, int px, int py)
+{
+  int item = ::PopUpMenuSelect(macMenu->GetMacMenuH(),py,px,1);
+  ItemSelected(item);
+}
+
+/* --Methode-- */
+PIPDMenuMac::PIPDMenuMac(PIMsgHandler* par, char* nom)
+: PIMenuMac(par, nom, k_PulldownMenu)
+{
+}
+
+/* --Methode-- */
+PIPDMenuMac::~PIPDMenuMac()
+{
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pimenumac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenumac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenumac.h	(revision 1307)
@@ -0,0 +1,79 @@
+#ifndef PIMENUMAC_H_SEEN
+#define PIMENUMAC_H_SEEN
+
+#include "pimenugen.h"
+#include <LMenu.h>
+#include <vector>
+#include <list>
+
+// Menu general
+class PIMenuMac : public PIMenuGen {
+public:
+					PIMenuMac(PIMsgHandler* par, char* nom, PIMenuType pdpu);
+				   ~PIMenuMac();
+				   
+    virtual void    AppendItem(char* nom, PIMessage msg, char* sc=NULL);
+
+    virtual void    DeleteItem(char *nom);
+    virtual void    DeleteItemMsg(PIMessage msg);
+    virtual void    DeleteItemNum(int n);
+
+    virtual void    CheckItem(char *nom, bool st=false); 
+    virtual void    CheckItemMsg(PIMessage msg, bool st=false); 
+    virtual void    CheckItemNum(int n, bool st=false); 
+	
+    virtual void    Show();
+    virtual void    Show(PIWdg *w, int px, int py);
+
+    virtual void    Hide();
+    
+    int             MenuId() {return mMenuId;}
+    void            ItemSelected(int item);
+    
+	string          GetMenuItemText(int item);
+	int             GetMenuItemMsg(int item);
+	int             FindItemByMsg(PIMessage msg);
+	int             FindItemByName(string const& nom);
+	
+protected:
+	static PIMenuMac* findMenu(int id);
+	LMenu*          macMenu;
+	int             mMenuId;
+	vector<PIMessage>    mMsgs;
+	static int      lastId;
+	static list<PIMenuMac*> sMenus;
+	
+	friend class    PIMenubarMac;
+	friend class    PIOptMenuMac;
+	friend class    PIPPOptMenu;
+	friend class    PIPPMenuBar;
+	MenuHandle      GetMacMenuHandle();
+	ResIDT          GetMacMenuID();
+	
+   
+};
+
+// Menu popup
+class PIPUMenuMac : public PIMenuMac
+{
+public:
+               PIPUMenuMac(PIMsgHandler* par, char* nom);
+               ~PIPUMenuMac();
+virtual void   Show();
+virtual void   Show(PIWdg *w, int px, int py);
+};
+
+// Menu pull-down
+class PIPDMenuMac : public PIMenuMac
+{
+public:
+               PIPDMenuMac(PIMsgHandler* par, char* nom);
+               ~PIPDMenuMac();
+};
+
+
+typedef PIMenuMac      PIMenu;
+typedef PIPUMenuMac    PIPUMenu;
+typedef PIPDMenuMac    PIPDMenu;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pimenux.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenux.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenux.cc	(revision 1307)
@@ -0,0 +1,477 @@
+#include<stdio.h>
+#include<iostream.h>
+
+#include "pisysdep.h"
+#include PIMENUBAR_H
+
+#include <Xm/Xm.h>
+#include <Xm/RowColumn.h>
+#include <Xm/PushB.h>
+#include <Xm/ToggleB.h>
+#include <Xm/CascadeB.h>
+
+/************* PIMenuX ************/
+
+// Quand on cree les menus comme fils du Top-Widget, ca rentre en 
+// conflit avec certaains Window-Manager ...
+// La fonction suivante permet de bypasser ce probleme- Le createur d'application
+// X doit donc appeler la fonction ci-dessous pour initialiser menuXTopWdg
+//                                               Reza 4/11/97
+static SysDWdg menuXTopWdg = NULL;
+void SetTopWdgForMenuX(SysDWdg mtw) {
+  menuXTopWdg = mtw;
+}
+
+// Pour ces sal... de XmString  (ds piwdgx.cc)
+int CStrFrXmStr(XmString xms, char* buff, int nmx);
+
+
+// Fonction prive (CallBack)
+static void menu_action(Widget w, XtPointer usd, XtPointer calld);
+static void menu_toggle_action(Widget w, XtPointer usd, XmToggleButtonCallbackStruct* calld);
+
+/* Nouvelle-Fonction */
+void  menu_action(Widget /*w*/, XtPointer usd, XtPointer /*calld*/)
+{
+PIMenuX *pim;
+_pimxit_ *cusd;
+
+cusd = ( _pimxit_ *)usd ;
+pim = (PIMenuX *) (cusd->pmen);
+// pim->Hide();
+pim->SendSelf(cusd->msg, PIMsg_Click );
+#ifdef DEBUG_PIMenuX
+printf("%%%Debug_menu_action: Msg= %d  %lx\n", (int)cusd->msg, (long)pim);
+#endif
+return;
+}
+
+// Variable globale pour Toggle Item's  Send(..., ..., data); 
+static bool toggmenbut = false;
+
+/* Nouvelle-Fonction */
+void  menu_toggle_action(Widget /*w*/, XtPointer usd, XmToggleButtonCallbackStruct* calld)
+{
+PIMenuX *pim;
+_pimxit_ *cusd;
+
+cusd = ( _pimxit_ *)usd ;
+pim = (PIMenuX *) (cusd->pmen);
+if (calld->set == True)  cusd->togstate = toggmenbut = true;
+else  cusd->togstate = toggmenbut = false;
+pim->SendSelf(cusd->msg, PIMsg_DataChanged, (void *)(&toggmenbut));
+return;
+}
+
+
+
+#define NBITEMB  10
+
+/* --Methode-- */
+PIMenuX::PIMenuX(PIWdg* par, char *nom, PIMenuType pdpu) 
+: PIMenuGen(par, nom, pdpu)
+{
+mNItem = 0;  mNItemMax = NBITEMB; 
+mBut = new _pimxit_[mNItemMax];
+
+SysDWdg tw;
+if (par == NULL) { 
+  tw = menuXTopWdg;
+  if (tw == NULL) tw = PIXtTopWdg(); 
+}
+else  tw = par->XtWdg();
+// Si le type de menu pdpu n'est pas specifie, on le decide 
+// en fonction du type de l'objet parent 
+if (pdpu == k_UTMenu) {
+  if  ( (par->kind() == PIMenu::ClassId) || (par->kind() == PIMenubar::ClassId) )  pdpu = k_PulldownMenu ;
+  else pdpu = k_PopupMenu ;
+}
+if (pdpu == k_PopupMenu)
+  XtWdg() = XmCreatePopupMenu( tw, nom, NULL, 0); 
+else 
+  XtWdg() = XmCreatePulldownMenu( tw, nom, NULL, 0); 
+
+mMTyp = pdpu;
+wmis = k_wmi_normal ;
+stmng = 0;
+}
+
+/* --Methode-- */
+PIMenuX::~PIMenuX()
+{
+// for(int i=0; i<mNItem; i++)
+//  XtDestroyWidget(mBut[i].itb); Le destroy est fait par le widget menu lui-meme
+delete[] mBut ;
+}
+
+
+/* --Methode-- */
+void PIMenuX::AppendItem(char* nom, PIMessage msg, char* sc)
+{
+AddItem(nom, msg, 0, sc, NULL);
+}
+
+/* --Methode-- */
+void PIMenuX::AppendCheckItem(char* nom, PIMessage msg, char* sc)
+{
+AddItem(nom, msg, 1, sc, NULL);
+}
+
+/* --Methode-- */
+void PIMenuX::AppendPDMenu(PIMenuGen *pdm, char* sc)
+{
+if (pdm->MType() !=  k_PulldownMenu) {
+  cerr << "PIMenuX::AppendPDMenu()/Erreur: PullDownMenu seulement ... " << endl;
+  return;
+  }
+AddItem(NULL, pdm->Msg(), 2, sc, (PIMenuX*)pdm);
+}
+
+/* --Methode-- */
+void PIMenuX::DeleteItem(char *nom)
+{
+DeleteItemNum(GetNumItem(nom));
+}
+
+/* --Methode-- */
+void PIMenuX::DeleteItemMsg(PIMessage msg)
+{
+DeleteItemNum(GetNumItemMsg(msg));
+}
+
+/* --Methode-- */
+void PIMenuX::SetSensitivity(char *nom, bool sens)
+{
+SetSensitivityNum(GetNumItem(nom), sens);
+}
+
+/* --Methode-- */
+void PIMenuX::SetSensitivityMsg(PIMessage msg, bool sens)
+{
+SetSensitivityNum(GetNumItemMsg(msg), sens);
+}
+
+/* --Methode-- */
+bool PIMenuX::IsSensitive(char *nom)
+{
+return(IsSensitiveNum(GetNumItem(nom)) );
+}
+
+/* --Methode-- */
+bool PIMenuX::IsSensitiveMsg(PIMessage msg)
+{
+return(IsSensitiveNum(GetNumItemMsg(msg)) ); 
+}
+
+/* --Methode-- */
+bool PIMenuX::IsSensitiveNum(int n)
+{
+if ((n < 0) || (n >= mNItem))  return(false);
+if (XtIsSensitive(mBut[n].itb) == TRUE)  return(true);
+else return(false);
+}
+
+/* --Methode-- */
+void PIMenuX::SetSensitivityNum(int n, bool sens)
+{
+if ((n < 0) || (n >= mNItem))  return;
+if (sens) XtSetSensitive(mBut[n].itb, TRUE);
+else XtSetSensitive(mBut[n].itb, FALSE);
+}
+
+/* --Methode-- */
+void PIMenuX::DeleteItemNum(int n)
+{
+if ((n < 0) || (n >= mNItem))  return;
+XtDestroyWidget(mBut[n].itb);
+for(int i=n; i<mNItem-1; i++)
+  {
+  String cbckn;
+  XtCallbackProc cbproc;
+  if (mBut[i+1].toggpdm < 2) {
+    if (mBut[i+1].toggpdm == 1)    // ToggleItem 
+      { cbckn = XmNvalueChangedCallback;  cbproc = (XtCallbackProc)menu_toggle_action; }
+    else { cbckn = XmNactivateCallback;  cbproc = menu_action; }
+
+    XtRemoveCallback(mBut[i+1].itb, cbckn, cbproc, (XtPointer)(mBut+i+1));
+    mBut[i] = mBut[i+1];
+    XtAddCallback(mBut[i].itb, cbckn, cbproc, (XtPointer)(mBut+i));
+    }
+  else mBut[i] = mBut[i+1]; 
+  }
+mNItem--;
+}
+
+
+/* --Methode-- */
+void PIMenuX::SetState(char *nom, bool st)
+{
+SetStateNum(GetNumItem(nom), st);
+}
+
+/* --Methode-- */
+void PIMenuX::SetStateMsg(PIMessage msg, bool st)
+{
+SetStateNum(GetNumItemMsg(msg), st);
+}
+
+/* --Methode-- */
+void PIMenuX::SetStateNum(int n, bool st)
+{
+if ((n < 0) || (n >= mNItem))  return;
+if (mBut[n].toggpdm != 1 ) return;  // Pas un toggle-item
+Arg warg[2];
+if (st) XtSetArg(warg[0],XmNset, True);
+else XtSetArg(warg[0],XmNset, False);
+XtSetValues(mBut[n].itb, warg, 1);
+mBut[n].togstate = st;
+return;
+}
+
+/* --Methode-- */
+bool PIMenuX::GetState(char *nom)
+{
+return( GetStateNum(GetNumItem(nom)) );
+}
+
+/* --Methode-- */
+bool PIMenuX::GetStateMsg(PIMessage msg)
+{
+return( GetStateNum(GetNumItemMsg(msg)) );
+}
+
+/* --Methode-- */
+bool PIMenuX::GetStateNum(int n) 
+{
+if ((n < 0) || (n >= mNItem))  return(false);
+if (mBut[n].toggpdm != 1 ) return(false); 
+return(mBut[n].togstate); 
+}
+
+
+
+
+/* --Methode-- */
+char* PIMenuX::ItemName(int n)
+{
+if ( (n < 0) || (n >= mNItem))  { mSItem[0] = '\0'; return(mSItem); }
+else return (ItemNameWdg(mBut[n].itb));
+}
+
+
+/* --Methode-- */
+char* PIMenuX::ItemNameWdg(SysDWdg itw)
+{
+XmString xmstr;
+Arg warg[2];
+
+XtSetArg(warg[0], XmNlabelString, &xmstr);
+XtGetValues(itw, warg, 1);
+if (xmstr)
+  {
+  CStrFrXmStr(xmstr, mSItem, 96);
+  XmStringFree(xmstr);
+  }
+else mSItem[0] = '\0';
+
+return(mSItem);
+}
+
+
+/* --Methode-- */
+PIMessage PIMenuX::ItemMsg(int n)
+{
+if ( (n < 0) || (n >= mNItem))  return(0);
+else return(mBut[n].msg);
+}
+
+
+
+/* --Methode-- */
+int PIMenuX::GetNumItem(char *nom)
+{
+
+for(int i=0; i<mNItem; i++)
+  if (strcmp(ItemName(i),nom) == 0)  return(i);
+return(-1);
+}
+
+/* --Methode-- */
+int PIMenuX::GetNumItemMsg(PIMessage msg)
+{
+for(int i=0; i<mNItem; i++)
+  if (mBut[i].msg == msg)   return(i);  
+return(-1);
+}
+
+/* --Methode-- */
+SysDWdg PIMenuX::GetItemWdg(int n)
+{
+if ((n<0) || (n>=mNItem))  return(NULL);
+else return(mBut[n].itb);
+}
+
+
+/* --Methode-- */
+void PIMenuX::AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuX *pdm)
+{
+_pimxit_ *buto;
+SysDWdgClass wdgcl;
+String cbckn;
+XtCallbackProc cbproc;
+Arg  warg[2];
+int n=0;
+
+
+if (mNItem >= mNItemMax)  {
+  buto = mBut;
+  mNItemMax += NBITEMB;
+  mBut = new _pimxit_[mNItemMax];
+  for(int i=0; i<mNItem; i++)    {
+    if (buto[i].toggpdm < 2) {  // Pas de Cascade Menu
+      if (buto[i].toggpdm == 1)  // ToggleItem
+        { cbckn = XmNvalueChangedCallback;  cbproc = (XtCallbackProc)menu_toggle_action; }
+      else { cbckn = XmNactivateCallback;  cbproc = menu_action; }
+      XtRemoveCallback(buto[i].itb, cbckn, cbproc, (XtPointer)(buto+i));
+      mBut[i] = buto[i];
+      XtAddCallback(mBut[i].itb, cbckn, cbproc, (XtPointer)(mBut+i));
+      }
+    else mBut[i] = buto[i]; 
+    }
+  delete[] buto;
+  }
+
+if (tog < 2) {  // Pas de Cascade Menu
+  if (tog == 1) {   // Toggle-Item 
+    cbckn = XmNvalueChangedCallback;  cbproc = (XtCallbackProc)menu_toggle_action;
+    wdgcl = xmToggleButtonWidgetClass;  
+    XtSetArg(warg[0],XmNset, False); n = 1; }
+  else {
+    cbckn = XmNactivateCallback;  cbproc = menu_action;
+    wdgcl = xmPushButtonWidgetClass;  n = 0; }
+
+  mBut[mNItem].itb = XtCreateManagedWidget(nom, wdgcl, this->XtWdg(), warg, n) ; 
+  XtAddCallback(mBut[mNItem].itb, cbckn, cbproc, (XtPointer)(mBut+mNItem));
+  }
+else {    // Creation Cascade-Menu
+  XtSetArg(warg[0], XmNsubMenuId, pdm->XtWdg());
+  mBut[mNItem].itb = XtCreateManagedWidget(pdm->Nom().c_str(), xmCascadeButtonWidgetClass, 
+                                           XtWdg(), warg, 1) ;
+  pdm->SetMsgParent(this);
+  }
+
+if (sc)  // Raccourci clavier 
+  {
+  char acc[16];
+  XmString xmstr;
+  n=0;
+  sprintf(acc,"Ctrl/%c", sc[0]);
+  xmstr = XmStringLtoRCreate(acc, XmSTRING_DEFAULT_CHARSET);
+  XtSetArg(warg[n], XmNacceleratorText, xmstr); n++;
+  sprintf(acc,"Ctrl<Key>%c", sc[0]);
+  XtSetArg(warg[n], XmNaccelerator, acc); n++;
+  XtSetValues(mBut[mNItem].itb, warg, n);  
+  XmStringFree(xmstr);
+  }
+
+#ifdef DEBUG_PIMenuX
+printf("DBG>> %d (%d) %lx \n", mNItem, mNItemMax, (long)(mBut+mNItem));
+#endif
+mBut[mNItem].pmen = this;
+mBut[mNItem].msg = msg;
+mBut[mNItem].toggpdm = tog;
+mBut[mNItem].togstate = false;
+mNItem++;
+return;
+}
+
+
+
+/* --Methode-- 
+void PIMenuX::Check()
+{
+printf("#Debug_CHECK: %d %d %d %d \n",XSize(), YSize(), XPos(), YPos() );  
+for(int i=0; i<mNItem; i++)
+  printf("##Debug_CHECK: %d %d %ld %lx %lx %lx \n", i, (int)mBut[i].toggpdm, 
+         (long) mBut[i].msg, (long) mBut[i].itb, 
+         (long) mBut[i].pmen, long (mBut+i));
+return;
+}
+*/
+
+
+
+
+void PIMenuX::Show()
+{
+if (MType() !=  k_PopupMenu) {
+  cerr << "PIMenuX::Show()/Erreur: PopupMenu seulement ... " << endl;
+  return;
+  }
+
+// XEvent  mevt;
+XButtonEvent evt;
+
+// XPeekEvent(PIXDisplay(), &mevt);
+// evt = mevt.xbutton; 
+evt.type = ButtonPress;
+evt.display = PIXDisplay();
+evt.window = XtWindow(PIXtTopWdg());
+evt.root = DefaultRootWindow(evt.display);
+evt.serial = PIXGetLastEventSerial(); 
+evt.time = PIXGetLastEventTime();
+evt.send_event = False;
+evt.same_screen = XQueryPointer(evt.display, evt.window, &(evt.root), 
+                    &(evt.subwindow), &(evt.x_root), &(evt.y_root), 
+                    &(evt.x), &(evt.y), &(evt.state));
+ 
+#ifdef DEBUG_PIMenuX
+printf("XXDbg_Show : %d %d %d - %d %d \n", (int)evt.same_screen, 
+       (int)evt.x_root, (int)evt.y_root, (int)evt.x, (int)evt.y);
+#endif
+
+if (evt.same_screen) XmMenuPosition(XtWdg(), &evt);
+Manage();     
+}
+
+/* --Methode-- */
+void PIMenuX::Show(PIWdg *w, int px, int py)
+{
+if (MType() !=  k_PopupMenu) {
+  cerr << "PIMenuX::Show(w, px, py)/Erreur: PopupMenu seulement ... " << endl;
+  return;
+  }
+// This method should only be used by a button press ...
+int xr, yr;
+Window cw, sw, rw;
+SysDWdg xtw;
+Display *dsp;
+XButtonEvent evt;
+
+xtw =  w->XtWdg();
+dsp = XtDisplay(xtw);
+sw = XtWindow(xtw);
+rw = DefaultRootWindow(dsp);
+XTranslateCoordinates(dsp, sw, rw, px, py, &xr, &yr, &cw);
+
+evt.type = ButtonPress;
+evt.display = dsp;
+evt.window = sw;
+evt.root = rw;
+evt.x_root = xr;
+evt.y_root = yr; 
+evt.x = px;
+evt.y = py;
+evt.serial = PIXGetLastEventSerial(); 
+evt.time = PIXGetLastEventTime();
+evt.send_event = False;
+evt.same_screen = True;
+XmMenuPosition(XtWdg(), &evt);
+// SetPos(xr, yr);
+Manage();
+return;    
+}
+
+
+
+
Index: /tags/DPC_V0/Poubelle/PI/pimenux.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimenux.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimenux.h	(revision 1307)
@@ -0,0 +1,73 @@
+#ifndef PIMENUX_H_SEEN
+#define PIMENUX_H_SEEN
+
+#include "pimenugen.h"
+
+
+class PIMenuX ;
+
+struct _pimxit_ 
+{
+SysDWdg itb;
+PIMenuX *pmen;
+PIMessage msg;
+int toggpdm;      // 0= Normal Item, 1, Toggle Item,  2= PDMenu
+bool togstate;    // true , false pour toggle items  
+};
+
+
+
+class PIMenuX : public PIMenuGen {
+public:
+	          PIMenuX(PIWdg* par, char* nom, PIMenuType pdpu=k_UTMenu);
+	          ~PIMenuX();
+				   
+  virtual void	  AppendItem(char* nom, PIMessage msg, char* sc=NULL);
+  virtual void	  AppendCheckItem(char* nom, PIMessage msg, char* sc=NULL);
+  virtual void	  AppendPDMenu(PIMenuGen *pdm, char* sc=NULL);
+
+  virtual void    DeleteItem(char *nom);
+  virtual void    DeleteItemMsg(PIMessage msg);
+  virtual void    DeleteItemNum(int n);
+
+  virtual void    SetSensitivity(char *nom, bool sens=true); 
+  virtual void    SetSensitivityMsg(PIMessage msg, bool sens=true); 
+  virtual void    SetSensitivityNum(int n, bool sens=true);
+
+  virtual bool    IsSensitive(char *nom);
+  virtual bool    IsSensitiveMsg(PIMessage msg);
+  virtual bool    IsSensitiveNum(int n);
+
+  virtual void    SetState(char *nom, bool st=false); 
+  virtual void    SetStateMsg(PIMessage msg, bool st=false); 
+  virtual void    SetStateNum(int n, bool st=false);
+ 
+  virtual bool    GetState(char *nom); 
+  virtual bool    GetStateMsg(PIMessage msg); 
+  virtual bool    GetStateNum(int n); 
+
+  virtual void    Show();
+  virtual void    Show(PIWdg *w, int px, int py);
+
+
+// Pour usage prive et par OptionMenu, ...
+  PIMessage       ItemMsg(int n);
+  int             GetNumItem(char *nom);
+  int             GetNumItemMsg(PIMessage msg);
+  SysDWdg         GetItemWdg(int n);
+  char*           ItemName(int n);
+  char*           ItemNameWdg(SysDWdg itw);
+
+protected:
+        void      AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuX *pdm);
+
+int mNItem, mNItemMax;
+_pimxit_  * mBut;
+char mSItem[96];
+};
+
+
+typedef PIMenuX        PIMenu;
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pimsghandler.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimsghandler.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimsghandler.cc	(revision 1307)
@@ -0,0 +1,101 @@
+//  Classe de gestionnaire de message pour programme graphique interactive
+//
+//                  E.Aubourg , R. Ansari  01-06/96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pimsghandler.h"
+
+//++
+// Class	PIMsgHandler
+// Lib		PI
+// include	pimsghandler.h
+//
+//   	Classe de gestionnaire de message de Peida Interactive (PI)
+//	Les message ("PIMessage") sont des entiers non signés
+//	("unsigned long"). 
+//	Chaque PIMsgHandler se trouve dans une organisation 
+//	hiérarchique où il dépend d'un
+//	PIMsgHandler père à qui il reporte les messages, et peut
+//	avoir lui-même un ou plusieurs PIMsgHandler qui sont sous sa 
+//	dépendance. Un message ("PIMessage") est constitué de deux 
+//	parties, une partie à la disposition de l'utilisateur ("UserMsg()")
+//	et une partie sous contrôle du code PI ("ModMsg()"), 
+//	qui peut spécifie si nécéssaire la raison de déclenchement 
+//	d'envoi du message. 
+//--
+
+//++
+// Titre	Constructeur
+//--
+//++
+// PIMsgHandler(PIMsgHandler* par=NULL)
+//	Création d'un PIMsgHandler dépendant hiérarchiquement du parent "par"
+//--
+
+PIMsgHandler::PIMsgHandler(PIMsgHandler* par)
+: msgParent(par)
+{}
+
+PIMsgHandler::~PIMsgHandler()
+{}
+
+
+//++
+// Titre	Traitement des messages
+//--
+
+//++
+// PIMessage  UserMsg(PIMessage msg)
+//	Décode et renvoie la partie utilisateur d'un PIMessage
+// PIMessage  ModMsg(PIMessage msg)
+//	Décode et renvoie la partie *modifier* d'un PIMessage
+// PIMessage  BuildMsg(PIMessage um, PIMsgMod mm) 
+//	Code les deux parties (user "um", modifier "mm") d'un message
+//	dans un PIMessage.
+// void  SetMsgParent(PIMsgHandler* par)
+//	Modifie l'organisation hiérarchique, en assignant un nouveau père.
+// void	 Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL)
+//	Cette méthode virtuelle est appelée quand un message "msg"
+//	est reçue par l'objet gestionnaire. "sender" est l'expéditeur
+//	du message, et "data" est un argument optionnel supplémentaire.
+//	La signification et contenu de "data" dépend de l'expéditeur
+//	et du contexte. Par défaut, la méthode "Process(...)" renvoie
+//	le message au PIMsgHandler père, sans altérer l'identité
+//	de l'expéditeur. (méthode "ReSend(...)"). C'est une méthode 
+//	non public (protected) destinée être redéfinie par les classes
+//	héritières.
+// void  Send(PIMessage msg, PIMsgMod mm=0, void* data=NULL)
+//	Envoie le message "msg" avec le modifier "mm", et l'argument 
+//	optionnel "data" au parent, déclenchant ainsi l'execution
+//	de la méthode "Process(...)" du père.
+// void  SendSelf(PIMessage msg, PIMsgMod mm=0, void* data=NULL)
+//	Envoie le message "msg" avec le modifier "mm", et l'argument 
+//	optionnel "data" à l'objet lui-même, déclenchant ainsi l'execution
+//	de la méthode "Process(...)" de l'objet.
+//--
+
+void
+PIMsgHandler::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+	ReSend(msg, sender, data);
+}
+
+void
+PIMsgHandler::Send(PIMessage msg, PIMsgMod mm,  void* data)
+{
+//	Process(msg, this, data);  $CHECK$  Reza 12/06/96
+// Send par defaut appelle le process du parent $CHECK$
+if (msgParent)
+  msgParent->Process(BuildMsg(msg, mm), this, data);
+
+}
+
+void
+PIMsgHandler::ReSend(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+  if (msgParent)
+    msgParent->Process(msg, sender, data);
+}
+
+
+
Index: /tags/DPC_V0/Poubelle/PI/pimsghandler.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimsghandler.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimsghandler.h	(revision 1307)
@@ -0,0 +1,67 @@
+#ifndef PIMSGHANDLER_H_SEEN
+#define PIMSGHANDLER_H_SEEN
+
+/* Classe de gestion de messages */
+
+#include <stdlib.h>
+
+#include "defs.h"
+
+enum {
+ // Les messages reserves systeme (PI)   les 8 premiers bits
+ // Messages user, les bits restants
+	PIMsg_Active        = 1,
+        PIMsg_Close         = 2,
+        PIMsg_Resize        = 3,
+        PIMsg_ResizeRequest = 4,
+
+	PIMsg_Click         = 21,
+        PIMsg_Press         = 22,
+        PIMsg_Release       = 23,
+        PIMsg_Drag          = 24,
+        PIMsg_Drop          = 25,
+        PIMsg_Copy          = 26,
+        PIMsg_Paste         = 27,
+        PIMsg_Cut           = 28,
+
+	PIMsg_OK            = 21,
+	PIMsg_Cancel        = 22,
+	PIMsg_Help          = 23,
+
+	PIMsg_DataChanged   = 31,
+        PIMsg_Select        = 32,
+        PIMsg_ClearSel      = 33
+
+};
+
+
+// Definition de type pour les messages - Il est peu probable que le typedef change ...
+//                                      Reza 17/10/96
+typedef unsigned long PIMessage;
+typedef unsigned char PIMsgMod;
+
+class PIMsgHandler {
+public:
+			     PIMsgHandler(PIMsgHandler* par=NULL);
+	virtual 	     ~PIMsgHandler();
+	
+	virtual void	     SetMsgParent(PIMsgHandler* par) {msgParent = par;}
+
+	virtual void         Send(PIMessage msg, PIMsgMod mm=0, void* data=NULL);
+	inline  void         SendSelf(PIMessage msg, PIMsgMod mm=0, void* data=NULL)
+                                  { Process(BuildMsg(msg, mm), this, data); }
+
+        inline  PIMessage    UserMsg(PIMessage msg) { return (msg >> 8); }
+        inline  PIMessage    ModMsg(PIMessage msg) { return (msg & 0xFF); }
+	inline  PIMessage    BuildMsg(PIMessage um, PIMsgMod mm) 
+                        	  { return ((um << 8) | mm); }
+
+protected:
+	virtual void	ReSend(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+	virtual void	Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+	PIMsgHandler*     msgParent;
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pimsgmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pimsgmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pimsgmac.h	(revision 1307)
@@ -0,0 +1,8 @@
+#include <PP_Types.h>
+
+const MessageT msg_Btn1    msg_Click;
+const MessageT msg_Btn2    10001;
+const MessageT msg_Btn3    10002;
+const MessageT msg_Move1   10003;
+const MessageT msg_Move2   10004;
+const MessageT msg_Move3   10005;
Index: /tags/DPC_V0/Poubelle/PI/pioptmenugen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pioptmenugen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pioptmenugen.cc	(revision 1307)
@@ -0,0 +1,12 @@
+#include "pioptmenugen.h"
+
+
+PIOptMenuGen::PIOptMenuGen(PIContainerGen* par, char* nom, int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py) // Attention au const !
+{
+}
+
+PIOptMenuGen::~PIOptMenuGen()
+{}
+
+
Index: /tags/DPC_V0/Poubelle/PI/pioptmenugen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pioptmenugen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pioptmenugen.h	(revision 1307)
@@ -0,0 +1,30 @@
+#ifndef PIOPTMENGEN_H_SEEN
+#define PIOPTMENGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIMENU_H
+
+class PIOptMenuGen : public PIWdg {
+public:
+  enum {ClassId = 1100};
+
+	             PIOptMenuGen(PIContainerGen* par, char* nom, int sx=50, int sy=15, int px=0, int py=0);
+	             ~PIOptMenuGen();
+				   
+  virtual long       kind() {return ClassId; }
+
+  inline  PIMenu*    Menu() {return mMen; }     // Renvoie un pointeur sur le menu associe 
+  inline  void       AppendItem(char* nom, PIMessage msg) 
+                                   { mMen->AppendItem(nom, msg); }
+
+  virtual string     GetValueStr() = 0;         // Option choisie
+  virtual PIMessage  GetValue() = 0;            // Message correspondant a l option choisie
+  virtual void       SetValueStr(string & s) = 0;
+  virtual void       SetValue(PIMessage msg) = 0;
+
+protected:
+  PIMenu* mMen;
+
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pioptmenumac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pioptmenumac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pioptmenumac.cc	(revision 1307)
@@ -0,0 +1,90 @@
+#include "pioptmenumac.h"
+#include "pippoptmenu.h"
+
+/* --Methode-- */
+PIOptMenuMac::PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm,
+                     int sx, int sy, int px, int py)
+: PIOptMenuGen(par, pdm, sx, sy, px, py), mPUMenu(pdm)
+{
+  delete mPane;
+  //LStr255 titre(Nom().c_str());
+  LStr255 titre("");
+  
+  StTextState textState;
+  ::TextFont(systemFont);
+  ::TextSize(12);
+  ::TextFace(0);
+  int titleWidth = ::StringWidth(titre);
+  
+  //mPane = new LStdPopupMenu(mPaneInfo, msg_Click, 0, 200, titleWidth+5, popupMenuProc/*+popupVariableWidth*/, 130, titre, 0, 1);
+  mPane = new PIPPOptMenu(mPaneInfo, msg_Click, 0, 200, titleWidth+5, popupMenuProc/*+popupVariableWidth*/, 130, titre, 0, 1);
+  //macMenu = ((LStdPopupMenu*)mPane)->GetMacMenuH();
+  
+  // On va changer la resource de menu au passage...
+//  InsertMenu(pdm->GetMacMenuHandle(), hierMenu);
+//  PopupPrivateDataHandle	dataH =
+////		(PopupPrivateDataHandle) (**((LStdPopupMenu*)mPane)->GetMacControl()).contrlData;
+//  (**dataH).mHandle = pdm->GetMacMenuHandle();
+//  (**dataH).mID = pdm->GetMacMenuID();
+  
+  ((PIPPOptMenu*)mPane)->SetMenu(pdm);
+  ((LStdPopupMenu*)mPane)->AddListener(this);
+  
+  Manage();
+}
+
+/* --Methode-- */
+PIOptMenuMac::~PIOptMenuMac()
+{
+}
+
+/* --Methode-- */
+void PIOptMenuMac::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+Select((char *)data, UserMsg(msg));  //  Reza 17/10/96 $CHECK$ ???
+ReSend(msg, sender, data);
+}
+
+void
+PIOptMenuMac::ListenToMessage(MessageT /*inMessage*/, void *)
+{
+//  if (inMessage == msg_Click)
+    mPUMenu->ItemSelected(((LStdPopupMenu*)mPane)->GetValue()-1);
+}
+
+void
+PIOptMenuMac::Select(char *txt, PIMessage msg)
+{ // Ca doit faire quoi ????
+mStext = txt;  mSmsg = msg;
+}
+
+/* --Methode-- */
+void PIOptMenuMac::SetValueStr(string & s)
+{
+int n;
+n=mPUMenu->FindItemByName((char *)s.c_str());
+if (n < 0)  return;  
+
+((LStdPopupMenu*)mPane)->SetValue(n+1);
+mStext = s;
+mSmsg  = mPUMenu->GetMenuItemMsg(n);
+
+return;
+}
+
+/* --Methode-- */
+void PIOptMenuMac::SetValue(PIMessage msg)
+{
+int n;
+n=mPUMenu->FindItemByMsg(msg);
+if (n < 0)  return;
+  
+StopListening();
+((LStdPopupMenu*)mPane)->SetValue(n+1);
+StartListening();
+mStext = mPUMenu->GetMenuItemText(n);
+mSmsg  = msg;
+
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pioptmenumac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pioptmenumac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pioptmenumac.h	(revision 1307)
@@ -0,0 +1,33 @@
+#ifndef PIOPTMENMAC_H_SEEN
+#define PIOPTMENMAC_H_SEEN
+
+#include "pioptmenugen.h"
+
+class PIOptMenuMac : public PIOptMenuGen {
+public:
+	                PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm,  
+                               int sx=10, int sy=10, int px=0, int py=0);
+	               ~PIOptMenuMac();
+
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+				   
+  virtual void	    ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual string    GetValueStr() { return(mStext); }
+  virtual PIMessage GetValue()    { return(mSmsg); } 
+  virtual void      SetValueStr(string & s);
+  virtual void      SetValue(PIMessage msg);
+  
+  inline void       Select(char *txt, PIMessage msg); // public ou protege ???
+
+
+protected:
+  string    mStext;
+  PIMessage mSmsg;
+  //MenuHandle macMenu;
+  PIPUMenu* mPUMenu;
+};
+
+
+typedef PIOptMenuMac  PIOptMenu ;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pioptmenux.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pioptmenux.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pioptmenux.cc	(revision 1307)
@@ -0,0 +1,135 @@
+#include<stdio.h>
+
+#include <Xm/Xm.h>
+#include <Xm/PushB.h>
+
+#include "pisysdep.h"
+#include "pioptmenux.h"
+#include "piapplx.h"
+
+
+/************* PIOptionMenuX ************/
+static int rsx=0, rsy=0;
+
+/* Nouvelle-Fonction */
+static void mouse_handler_optmenux (Widget wdgp, XtPointer ud, 
+                                    XEvent* evt, Boolean* cont){
+*cont = FALSE ; 
+// printf("---  mouse_handler_optmenux ud = %lx ----- EvtType=%d (%d) \n", (long)ud, evt->type, Expose );
+if ( evt->type == Expose ) {
+  PIOptMenuX* opm = (PIOptMenuX*) ud;
+  Display* dis = PIXDisplay();
+  Window w = XtWindow(opm->XtWdg()) ;
+  XFillRectangle(dis, w, opm->myGC(), rsy, (opm->YSize()-rsy)/2, rsy, rsy); 
+  }
+else if ( (evt->type == ButtonPress) && (evt->xbutton.button == 1))  { 
+  PIXSetLastEventTimeSerial(evt->xbutton.time,  evt->xbutton.serial);
+  PIOptMenuX* opm = (PIOptMenuX*) ud;
+  opm->Menu()->Show(opm, rsy/2, opm->YSize());
+  }
+}
+
+
+/* --Methode-- */
+PIOptMenuX::PIOptMenuX(PIContainerGen* par, char* nom, int sx, int sy, int px, int py)
+: PIOptMenuGen(par, nom, sx, sy, px, py)
+{
+mSmsg = 0;
+mStext = "";
+
+if (rsx == 0) { 
+  PIApplicationPrefCompSize(rsx, rsy);
+  rsy = rsy/3-2; 
+  }
+Arg warg[10];
+int n = 0;
+CreateXtWdg(nom, xmPushButtonWidgetClass, NULL, sx, sy, px, py);
+XtSetArg(warg[n],XmNhighlightThickness, 0);  n++;
+XtSetArg(warg[n], XmNrecomputeSize, FALSE); n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+XtSetArg(warg[n],XmNmarginLeft,rsy*3);  n++;
+XtSetValues(XtWdg(), warg, n);
+XtTranslations trans = XtParseTranslationTable( 
+      "<Btn1Down>: \n <Btn1Up>: \n <Btn2Down>: \n <Btn2Up>: \n <Btn3Down>: \n <Btn3Up>:");
+XtOverrideTranslations(XtWdg(), trans);
+XtAddEventHandler( XtWdg(), ButtonPressMask|ExposureMask, FALSE, mouse_handler_optmenux, this);
+mgc = 0;
+char buff[128];
+strncpy(buff, nom, 64);
+strcat(buff,"_Menu");
+mMen = new PIMenu((PIWdg*)par, buff, k_PopupMenu);
+mMen->SetMsgParent(this);
+Manage();
+}
+
+
+/* --Methode-- */
+PIOptMenuX::~PIOptMenuX()
+{
+delete mMen;
+}
+
+/* --Methode-- */
+void PIOptMenuX::FinishCreate()
+{
+// printf("PIOptMenuX::FinishCreate()/DBG  %s \n", Nom().c_str());
+if (mSmsg == 0)  SetValue(mMen->ItemMsg(0)); 
+}
+
+/* --Methode-- */
+void PIOptMenuX::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+// printf("PIOptMenuX::Process Msg= %d Sender= %lx \n", (int)msg, (long)sender);
+if (sender == mMen)   {
+  SetValue(UserMsg(msg));
+  ReSend(msg, this, NULL);
+}
+return;
+}
+
+
+/* --Methode-- */
+void PIOptMenuX::SetValueStr(string & s)
+{
+int n;
+Arg warg[2];
+n=mMen->GetNumItem((char *)s.c_str());
+if (n < 0)  return;  
+
+XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
+XtSetValues(XtWdg(), warg, 1);
+mStext = s;
+mSmsg  = mMen->ItemMsg(n);
+
+SetLabel(mStext);
+
+return;
+}
+
+/* --Methode-- */
+void PIOptMenuX::SetValue(PIMessage msg)
+{
+int n;
+Arg warg[2];
+n=mMen->GetNumItemMsg(msg);
+if (n < 0)  return;
+  
+XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
+XtSetValues(XtWdg(), warg, 1);
+mStext = mMen->ItemName(n);
+mSmsg  = msg;
+SetLabel(mStext);
+return;
+}
+
+/* --Methode-- */
+void PIOptMenuX::createmygc()
+{
+unsigned long fgc = 0;
+Arg warg[2];
+XtSetArg(warg[0], XmNforeground, &fgc);
+XtGetValues(XtWdg(), warg, 1);
+mgc = XCreateGC(PIXDisplay(), XtWindow(XtWdg()), 0, NULL); 
+XSetForeground(PIXDisplay(), mgc, fgc);
+}
Index: /tags/DPC_V0/Poubelle/PI/pioptmenux.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pioptmenux.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pioptmenux.h	(revision 1307)
@@ -0,0 +1,36 @@
+#ifndef PIOPTMENX_H_SEEN
+#define PIOPTMENX_H_SEEN
+
+#include "pisysdep.h"
+#include "pioptmenugen.h"
+#include PISTDWDG_H
+
+class PIOptMenuX : public PIOptMenuGen {
+public:
+	            PIOptMenuX(PIContainerGen* par, char* nom, int sx=50, int sy=15, int px=0, int py=0);
+	            ~PIOptMenuX();
+
+  virtual void	    FinishCreate(); 
+
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+				   
+  virtual string    GetValueStr() { return(mStext); }
+  virtual PIMessage GetValue()    { return(mSmsg); } 
+  virtual void      SetValueStr(string & s);
+  virtual void      SetValue(PIMessage msg);
+
+//  Pour utilisation privee dans call-back   
+  inline  GC        myGC() {if (mgc == 0) createmygc();  return(mgc); }  
+
+protected:
+  string   mStext;
+  PIMessage mSmsg;
+//  SysDWdg mLabel;
+  GC mgc;
+  void              createmygc();
+};
+
+
+typedef PIOptMenuX  PIOptMenu ;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piperiodx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piperiodx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piperiodx.cc	(revision 1307)
@@ -0,0 +1,52 @@
+#include "piwdgx.h"
+#include "piperiodx.h"
+
+/* Nouvelle-Fonction */
+static void xttimer_action(XtPointer usd, XtIntervalId * /*tid*/)
+{
+PIPeriodX * pip;
+XtIntervalId id;
+pip = (PIPeriodX *)usd;
+pip->DoPeriodic();
+int szx, szy, szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+id = XtAppAddTimeOut(*appctx, pip->Intervalms(), xttimer_action, pip);
+pip->SetTimerId(id);
+return;
+}
+
+
+/* --Methode-- */
+PIPeriodX::PIPeriodX(int dt, UsPeriodicAction act, void * usp)
+: Periodic(dt, act, usp)
+{
+}
+
+/* --Methode-- */
+PIPeriodX::~PIPeriodX()
+{
+if (mFgact) Stop();
+}
+
+/* --Methode-- */
+void PIPeriodX::Start(int dt)
+{
+if (mFgact) return;
+if (dt > 0)  { mDt = dt;  mDtms = dt*1000; }
+
+int szx,szy,szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+mTId = XtAppAddTimeOut(*appctx, Intervalms(), xttimer_action, this);
+mFgact = true;
+return;
+}
+
+void
+PIPeriodX::Stop()
+{
+if(mFgact)
+  XtRemoveTimeOut(mTId);
+mFgact = false;
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/piperiodx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piperiodx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piperiodx.h	(revision 1307)
@@ -0,0 +1,24 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef PIPERIODX_H
+#define PIPERIODX_H
+
+#include <X11/Intrinsic.h>
+#include "periodic.h"
+
+class PIPeriodX : public Periodic {
+public:
+  PIPeriodX(int dt, UsPeriodicAction act=NULL, void * usp=NULL);
+  ~PIPeriodX();
+
+  virtual void Start(int dt=-1);
+  virtual void Stop();
+
+  inline void SetTimerId(XtIntervalId id) {mTId=id; }
+
+protected:
+XtIntervalId mTId;
+};
+
+typedef PIPeriodX PIPeriodic;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pipixmapgen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pipixmapgen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pipixmapgen.cc	(revision 1307)
@@ -0,0 +1,152 @@
+// Module PI : Peida Interactive     PIPixmap
+// Classe de base pour affichage de pixmap  Reza 96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "pipixmapgen.h"
+
+// --------- Methodes de la classe PIPixMap  ----------
+//++
+// Class	PIPixmap
+// Lib		PI
+// include	pipixmapgen.h
+//
+//   	Classe pour la gestion optimisée des pixmap.
+//	Un pixmap est un tableau d'index dans une table de couleurs.
+//	Cette classe gére actuellement des pixmaps avec des index
+//	codés sur 8 bits (256 couleurs).
+//	Pour des raisons d'optimisation, cette classe a une 
+//	implémentation spécifique pour chaque plateforme.
+//	La classe "PIPixmapGen" définit l'interface, et ne doit pas 
+//	être instanciée directement.  Les objets instanciés sont de la 
+//	classes "PIPixmap" et le fichier entête correspondant est "PIPIXMAP_H"
+//	défini dans "pisysdep.h".
+//--
+//++
+// Links	Parents
+// PIBaseWdg
+//--
+//++
+// Links	Voir aussi
+// PIColorMap
+//--
+
+//++
+// Titre	Constructeur, Pixmap
+//--
+//++
+// PIPixmapGen(PIContainerGen *par, char *nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Constructeur - Création d'un "PIPIxmap".
+// long  kind() 
+//	Retourne le type ("=PIPixmap::ClassId")
+// void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true, int ox=0, int oy=0)
+//	Associe un tableau d'index "pix" de taille "sx * sy".
+//	(ox,oy)" définissent  l'offset d'affichage.
+//	Si "refr=true", la méthode "Refresh()" est appelée.
+//--
+//++
+// Titre	Gestion de la table de couleur
+//--
+//++
+// void  SetColMap(PIColorMap* cmp, bool refr=true)
+//	Change la table de couleur associée.
+//	Si "refr=true", la méthode "Refresh()" est appelée.
+// void  SetColMapId(CMapId cmapid, bool refr=true)
+//	Change la table de couleur associée, à l'aide d'un identificateur
+//	de table de couleur standard. ("CMapId cmapid").
+//	Si "refr=true", la méthode "Refresh()" est appelée.
+// PIColorMap* GetColMap()
+//	Retourne la table de couleur associée.
+// CMapId GetColMapId() 
+//	Retourne l'identificateur de la table de couleur associée.
+// int NbCol()
+//	Retourne le nombre de couleurs de la table de couleur associée.
+//--
+
+//++
+// Titre	Actions
+//--
+//++
+// void  But1Press(int x, int y)
+//	L'action sur le bouton 1 déclenche l'envoi d'un message
+//	avec le modifier PIMsg_Click. La position du bouton-press
+//	est stocké.
+// int  XPPos() 
+//	Position X du click
+// int  YPPos() 
+//	Position Y du click
+//--
+
+/* --Methode-- */
+PIPixmapGen::PIPixmapGen(PIContainerGen  *par, char *nom,
+                     int sx, int sy, int px, int py) :
+PIBaseWdg(par, nom, sx, sy, px, py)
+{
+pixmap = NULL;
+nx = ny = 0;
+ofx = ofy = 0;
+mPpos[0] = mPpos[0] = 0;
+cmap = new PIColorMap(CMAP_GREY32);
+ActivateButton(1);
+}
+
+
+/* --Methode-- */
+PIPixmapGen::~PIPixmapGen()
+{
+delete cmap;
+}
+
+/* --Methode-- */
+void PIPixmapGen::SetPixmap(unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)
+{
+pixmap = pix; 
+if (pixmap)
+  {
+  if (sx < 0)  sx = 0;
+  if (sy < 0)  sy = 0;
+  if (ox < 0)  ox = 0;
+  if (oy < 0)  oy = 0;
+  nx = sx; ny = sy;
+  ofx = ox;  ofy = oy;
+  }
+else { ofx = ofy = nx = ny = 0; }
+if (refr) Refresh();   
+}
+
+/* --Methode-- */
+void PIPixmapGen::SetColMap(PIColorMap* cmp, bool refr)
+{
+if (!cmp)  return;
+if ( (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER) ) return;
+if (cmap) delete cmap;
+cmap = new PIColorMap(*cmp);
+if (refr)  Refresh();  
+}
+
+/* --Methode-- */
+void PIPixmapGen::SetColMapId(CMapId cmapid, bool refr)
+{
+if (!cmap || (cmap->Type() != cmapid) || (cmapid == CMAP_OTHER) ) {  
+  if (cmap) delete cmap;
+  cmap = new PIColorMap(cmapid);
+  }
+if (refr)  Refresh();  
+}
+
+
+/* --Methode-- */
+void  PIPixmapGen::But1Press(int x, int y)
+{
+mPpos[0] = x;  mPpos[1] = y;  
+if (Msg())  Send(Msg(), PIMsg_Click, mPpos);
+return;
+}
+
+
+
+// Fin des methodes de la classe 
+
+
Index: /tags/DPC_V0/Poubelle/PI/pipixmapgen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pipixmapgen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pipixmapgen.h	(revision 1307)
@@ -0,0 +1,55 @@
+/* Fonctions interface XWindow pour affichage d'images */
+
+#ifndef PIPIXMAP_H_SEEN
+#define PIPIXMAP_H_SEEN
+
+#include "pisysdep.h"
+
+#include PIBWDG_H
+#include PICMAP_H
+
+#include <list>
+#if defined(__KCC__)
+#include <list.h>
+#endif
+
+class PIPixmapGen : public PIBaseWdg
+{
+public:
+  enum {ClassId = 5100};
+
+                PIPixmapGen(PIContainerGen *par, char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual       ~PIPixmapGen();
+
+  virtual long  kind() {return ClassId; }
+
+  virtual void  SetPixmap(unsigned char *pix, int sx, int sy, 
+                          bool refr=true, int ox=0, int oy=0);
+
+  virtual void  SetColMap(PIColorMap* cmp, bool refr=true);
+  virtual void  SetColMapId(CMapId cmapid, bool refr=true);
+
+  inline PIColorMap* GetColMap() { return cmap; }
+  inline CMapId GetColMapId() { return ((CMapId)cmap->Type()); }; 
+  inline int    NbCol() { return(cmap->NCol()); };
+
+  virtual void  But1Press(int x, int y);
+  inline  int   XPPos() { return mPpos[0]; }
+  inline  int   YPPos() { return mPpos[1]; }
+
+protected:
+  unsigned char *pixmap;
+  int nx, ny;
+  int ofx, ofy;
+  PIColorMap* cmap;
+
+  int mPpos[2];
+};  
+  
+
+
+
+#endif   /* PIPIXMAP_H_SEEN */
+
+
Index: /tags/DPC_V0/Poubelle/PI/pipixmapmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pipixmapmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pipixmapmac.cc	(revision 1307)
@@ -0,0 +1,102 @@
+#include "pipixmapmac.h"
+
+PIPixmapMac::PIPixmapMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIPixmapGen(par,nom,sx,sy,px,py), mGWorld(NULL)
+{}
+
+
+PIPixmapMac::~PIPixmapMac()
+{}
+
+
+/* --Methode-- */
+void PIPixmapMac::SetPixmap(unsigned char *pix, int sx, int sy, bool refr)
+{
+  if (nx != sx || ny != sy)
+    if (mGWorld) {
+      DisposeGWorld(mGWorld);
+      mGWorld = NULL;
+    }
+  PIPixmapGen::SetPixmap(pix, sx, sy, refr);
+}
+
+void
+PIPixmapMac::Resize()
+{
+  Refresh();
+}
+
+void
+PIPixmapMac::Refresh()
+{
+	PIPixmapGen::Refresh();
+}
+
+void
+PIPixmapMac::DrawOff()
+{
+  if (mGWorld) {
+    DisposeGWorld(mGWorld);
+    mGWorld = NULL;
+  }
+  
+  if (!cmap) return;
+  if (!pixmap) return;
+  if (nx == 0 || ny == 0) return;
+  
+  Rect	frame;
+  SetRect(&frame, 0, 0, XSize(), YSize());
+
+  
+  ThrowIfOSErr_(NewGWorld(&mGWorld, 8, &frame, cmap->mCTab, nil, 0));
+
+    // Lock down Pixels that we are drawing to so that memory will not
+	// move
+	::LockPixels (mGWorld->portPixMap);
+
+ 	// Draw
+	PixMapHandle	pMap;
+	unsigned char	*pixP;
+	
+	pMap = GetGWorldPixMap(mGWorld);
+	for (int y=frame.top; y<frame.bottom; y++) {
+		pixP = (unsigned char *) GetPixBaseAddr(pMap) + y * ((**pMap).rowBytes & 0x7FFF);
+		for(int x = frame.left ; x < frame.right ; x++)
+			pixP[x] = (x<nx && y<ny) ? pixmap[x + y*nx]+2 : 0;
+	}
+			
+	// Now unlock Pixels.
+	::UnlockPixels (mGWorld->portPixMap);
+	
+	mPane->FocusDraw();
+//	SetPalette(mPane->GetMacPort(),cmap->mPalette, true);
+//	PIPixmapGen::Refresh();
+}
+
+void
+PIPixmapMac::Draw(PIGraphic* g,int,int,int,int)
+{
+  Draw(g);
+}
+
+void
+PIPixmapMac::Draw(PIGraphic* g)
+{
+  DrawOff();
+  if (!mGWorld) return;
+  mPane->FocusDraw();
+  Rect	paneFrame;
+  mPane-> CalcLocalFrameRect(paneFrame);
+  Rect	offsFrame;
+  SetRect(&offsFrame, 0, 0, paneFrame.right-paneFrame.left, paneFrame.bottom-paneFrame.top);
+  ::LockPixels (mGWorld->portPixMap);
+  ::ForeColor (blackColor);
+  ::BackColor (whiteColor);
+  ::CopyBits((BitMap *) (*(GetGWorldPixMap(mGWorld))),
+				&mPane->GetMacPort()->portBits,
+				&offsFrame, &paneFrame, srcCopy, nil);
+  ::UnlockPixels (mGWorld->portPixMap);
+  DisposeGWorld(mGWorld);
+  mGWorld = 0;
+}
Index: /tags/DPC_V0/Poubelle/PI/pipixmapmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pipixmapmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pipixmapmac.h	(revision 1307)
@@ -0,0 +1,26 @@
+#ifndef PIPIXMAPMAC_H_SEEN
+#define PIPIXMAPMAC_H_SEEN
+
+#include "pipixmapgen.h"
+
+class PIPixmapMac : public PIPixmapGen {
+
+public:
+                PIPixmapMac(PIContainerGen *par, char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual      ~PIPixmapMac();
+
+  virtual void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true);
+  virtual void  Draw(PIGraphic* g);
+  virtual void  Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  virtual void	Refresh();
+  virtual void	DrawOff();
+  virtual void  Resize();
+protected:
+  GWorldPtr 	mGWorld;
+};
+
+typedef PIPixmapMac PIPixmap;
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pipixmapx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pipixmapx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pipixmapx.cc	(revision 1307)
@@ -0,0 +1,174 @@
+#include <stdio.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+#include "pipixmapx.h"
+
+static  GC    mygc;
+
+/* --Methode-- */
+PIPixmapX::PIPixmapX(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIPixmapGen(par,nom,sx,sy,px,py) 
+{
+Init();
+AllocXImg();
+}
+
+
+/* --Methode-- */
+PIPixmapX::~PIPixmapX()
+{
+delete[] myximg->data;
+XFree(myximg); 
+}
+
+/* --Methode-- */
+void PIPixmapX::Refresh()
+{
+int i,j;
+unsigned char *pp;
+
+if (pixmap)
+  {
+  for(j=0; j<ny; j++)
+    {
+    pp = pixmap+j*nx;
+    for(i=0; i<nx; i++)
+      { XPutPixel(myximg, i, j, cmap->Color(*pp) );  pp++; }
+    }
+  }
+
+for(j=ny; j<YSize(); j++)
+  for(i=nx; i<XSize(); i++)
+     XPutPixel(myximg, i, j, 0 );
+
+PIBaseWdgX::Refresh();
+}
+
+
+/* --Methode-- */
+void PIPixmapX::Resize()
+{
+delete[] myximg->data;
+XFree(myximg); 
+AllocXImg();
+if (Msg())  Send(Msg(), PIMsg_Resize, mPpos);
+}
+
+/*DEL07 --Methode-- 
+void PIPixmapX::Draw(PIGraphicGen* g)
+{
+if (!pixmap)  return;
+if (!g) return; 
+if (g->kind() == PI_PSFileGraphics ) {
+    g->DrawPixmap(ofx, ofy, pixmap, nx, ny, cmap);
+    //  Il faut faire quelque chose Sinon ??! 
+  }
+else  Draw(g, 0, 0, XSize(), YSize());
+}
+*/
+
+/* --Methode-- */
+void PIPixmapX::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+{
+
+if (!g) return; 
+if ((myximg == NULL) || (cmap == NULL)) return;
+
+if (g->kind() == PI_PSFileGraphics ) {
+  if (pixmap) g->DrawPixmap(ofx, ofy, pixmap, nx, ny, cmap);
+  return;
+  }
+
+Window xw = XtWindow(XtWdg());
+Display * mdsp = PIXDisplay();
+
+int mx, my, ox, oy;
+
+if (x0 < 0)  x0 = 0;
+if (y0 < 0)  y0 = 0;
+mx = nx+ofx;   my = ny+ofy;
+if (dx > (XSize()-x0)) dx = XSize()-x0;
+if (dy > (YSize()-y0)) dy = YSize()-y0;
+if ((dx <= 0) || (dy <= 0))  return;
+
+if ( (mx < x0 ) || (my < y0) )
+  { XClearArea(mdsp, xw, x0, y0, dx, dy, False);  return; }
+
+ox = oy = 0;  
+
+if (ofx > x0)
+  { XClearArea(mdsp, xw, x0, y0, ofx-x0, dy, False);   
+  dx -= (ofx-x0);  x0 = ofx;  ox = 0; }
+else  ox = x0-ofx;
+if (ofy > y0)
+  { XClearArea(mdsp, xw, x0, y0, dx, ofy-y0, False);  
+  dy -= (ofy-y0);  y0 = ofy;  oy = 0; }
+else  oy = y0-ofy;
+ 
+if (mx < (x0+dx))
+  { XClearArea(mdsp, xw, mx, y0, x0+dx-mx, dy, False);  dx = mx-x0; }
+if (my < (y0+dy))
+  { XClearArea(mdsp, xw, x0, my, dx, y0+dy-my, False);  dy = my-y0; }
+ 
+XPutImage(mdsp, xw, mygc, myximg, ox, oy, x0, y0, dx, dy);
+XFlush(mdsp);
+return;
+ 
+}
+
+static bool fgxpxm = false;
+
+
+/* --Methode-- */
+void PIPixmapX::Init()
+{
+XGCValues       values;
+XtGCMask        mask;
+
+if (fgxpxm)  return; 
+fgxpxm = true;
+
+
+mask = GCFunction | GCPlaneMask;
+// mask = GCForeground | GCBackground;
+values.function = GXcopy;
+values.plane_mask = ~0;
+// values.foreground = WhitePixel(mdsp, scr);
+// values.background = BlackPixel(mdsp, scr);
+mygc = XtGetGC(XtWdg(), mask, &values);
+
+return;
+}
+
+
+/* --Methode-- */
+void PIPixmapX::AllocXImg()
+{
+Display * mdsp;
+int scr;
+int depth;
+int pad;
+int i,j;
+
+mdsp = PIXDisplay();
+scr = PIXScreen();
+
+depth = DefaultDepth(mdsp,scr);
+pad = (depth > 8) ? 32 : 8;
+myximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr),
+           depth,ZPixmap,0,NULL, XSize(), YSize(), pad,0);
+if (myximg == NULL)  return;
+myximg->data = new char [YSize()*myximg->bytes_per_line];
+if (myximg->data == NULL)  
+  { XFree(myximg); myximg = NULL;  return; } 
+
+for(j=0; j<YSize(); j++)
+  for(i=0; i<XSize(); i++)
+    XPutPixel(myximg, i, j, 0 );
+
+return;
+}
Index: /tags/DPC_V0/Poubelle/PI/pipixmapx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pipixmapx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pipixmapx.h	(revision 1307)
@@ -0,0 +1,27 @@
+#ifndef PIPIXMAPX_H_SEEN
+#define PIPIXMAPX_H_SEEN
+
+#include "pipixmapgen.h"
+
+class PIPixmapX : public PIPixmapGen {
+
+public:
+                PIPixmapX(PIContainerGen *par, char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual      ~PIPixmapX();
+
+  virtual void  Refresh();
+  virtual void  Resize();
+  virtual void  Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+
+
+protected:
+  void          Init();
+  void          AllocXImg();
+  XImage * myximg;  
+};
+
+typedef PIPixmapX PIPixmap;
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pippapplmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippapplmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippapplmac.cc	(revision 1307)
@@ -0,0 +1,41 @@
+#include "pippapplmac.h"
+#include "piupdattachment.h"
+#include "pippmenubar.h"
+#include "pippwindowmac.h"
+#include <LClipboard.h>
+
+PIPPApplMac::PIPPApplMac()
+:LApplication()
+{
+  RegisterClass_(PIPPWindowMac);
+  AddAttachment(new LClipboard);
+}
+
+
+PIPPApplMac::~PIPPApplMac()
+{}
+
+void
+PIPPApplMac::AdjustCursor(const EventRecord &inMacEvent)
+{
+  PIUpdAttachment::hit = false;
+  LApplication::AdjustCursor(inMacEvent);
+  if (!PIUpdAttachment::hit) {
+    if (PIUpdAttachment::lastCursPane)
+       PIUpdAttachment::lastCursPane->myWdg->Leave();
+    PIUpdAttachment::lastCursPane = NULL;
+  }   
+}
+
+void
+PIPPApplMac::MakeMenuBar()
+{
+	//new PIPPMenuBar();
+}
+
+
+
+// $CHECK$
+// Gerer AllowSubRemoval, qui envoie un evenement a l'application PI.
+// Eventuellement avoir des fenetres qui se cachent lors d'un close et d'autres
+// qui se detruisent ??
Index: /tags/DPC_V0/Poubelle/PI/pippapplmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippapplmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippapplmac.h	(revision 1307)
@@ -0,0 +1,11 @@
+#include <LApplication.h>
+
+class PIPPApplMac : public LApplication {
+public:
+						PIPPApplMac();
+	virtual				~PIPPApplMac();
+
+	void MakeMenuBar();
+	virtual void			AdjustCursor	(const EventRecord &inMacEvent);
+};
+
Index: /tags/DPC_V0/Poubelle/PI/pipplist.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pipplist.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pipplist.cc	(revision 1307)
@@ -0,0 +1,198 @@
+#include "pipplist.h"
+#include <LTableMonoGeometry.h>
+#include <LTableSingleSelector.h>
+#include <LTableMultiSelector.h>
+#include <LTableArrayStorage.h>
+#include <LComparator.h>
+
+class CellMsgComparator : public LComparator {
+public:
+	virtual Int32		Compare(
+								const void*			inItemOne,
+								const void* 		inItemTwo,
+								Uint32				/*inSizeOne*/,
+								Uint32				/*inSizeTwo*/) const
+	{return ((PIPPListCell*)inItemOne)->msg == ((PIPPListCell*)inItemTwo)->msg;}
+};
+
+static CellMsgComparator cellMsgComparator;
+
+class CellStrComparator : public LComparator {
+public:
+	virtual Int32		Compare(
+								const void*			inItemOne,
+								const void* 		inItemTwo,
+								Uint32				/*inSizeOne*/,
+								Uint32				/*inSizeTwo*/) const
+	{return ((PIPPListCell*)inItemOne)->str == ((PIPPListCell*)inItemTwo)->str;}
+};
+
+static CellStrComparator cellStrComparator;
+
+
+PIPPList::PIPPList(PIMsgHandler* h)
+: mHndl(h)
+{
+  InitPPList();
+}
+
+PIPPList::PIPPList(
+    const SPaneInfo& inPaneInfo,
+    const SViewInfo& inViewInfo,
+    PIMsgHandler* h)
+: LTableView(inPaneInfo, inViewInfo), mHndl(h)
+{
+  InitPPList();
+}
+
+void PIPPList::InitPPList()
+{
+  SetTableGeometry(new LTableMonoGeometry(this, 10, 16));
+  SetTableSelector(tss=new LTableSingleSelector(this)); 
+  mArray = new LArray(sizeof(PIPPListCell)),
+  SetTableStorage(new LTableArrayStorage(this, mArray));
+  tms = new LTableMultiSelector(this);
+  LTableView::InsertCols(1, 0, nil, 0, Refresh_No);
+}
+
+PIPPList::~PIPPList()
+{
+  SetTableSelector(nil);
+  delete tss;
+  delete tms;
+}
+
+
+void PIPPList::AppendItem(string const& str, PIMessage msg)
+{
+  PIPPListCell cell;
+  cell.str=str;
+  cell.msg=msg;
+  InsertRows(1, -1, &cell, sizeof(cell), Refresh_Yes);
+}
+
+STableCell PIPPList::FindStr(string const& str)
+{
+  PIPPListCell cell;
+  cell.str = str;
+  cell.msg = 0;
+  mArray->SetComparator(&cellStrComparator);
+  STableCell tcell;
+  FindCellData(tcell, &cell, sizeof(cell));
+  return tcell;
+}
+
+STableCell PIPPList::FindMsg(PIMessage msg)
+{
+  PIPPListCell cell;
+  cell.str = "";
+  cell.msg = msg;
+  mArray->SetComparator(&cellMsgComparator);
+  STableCell tcell;
+  FindCellData(tcell, &cell, sizeof(cell));
+  return tcell;
+}
+
+void PIPPList::DeleteItem(string const& str)
+{
+  STableCell tcell = FindStr(str);
+  RemoveRows(1, tcell.row, Refresh_Yes);
+}
+
+void PIPPList::DeleteItem(PIMessage msg)
+{
+  STableCell tcell = FindMsg(msg);
+  RemoveRows(1, tcell.row, Refresh_Yes);
+}
+
+
+void PIPPList::SetMultipleSelect(bool ms);
+  
+int PIPPList::GetNbSel()
+{
+  int n = 0;
+  for (TableIndexT j=1; j<=mRows; j++) {
+    STableCell cell;
+    cell.row = j;
+    cell.col = 1;
+    if (CellIsSelected(cell)) n++;
+  }
+  return n; 
+}
+
+PIMessage PIPPList::GetSelMsg(int i)
+{
+  int n = 0;
+  for (TableIndexT j=1; j<=mRows; j++) {
+    STableCell cell;
+    cell.row = j;
+    cell.col = 1;
+    if (CellIsSelected(cell)) n++;
+    if (n == i) {
+       PIPPListCell ppcell;
+       UInt32 sz = sizeof(ppcell);
+       GetCellData(cell, &ppcell, sz);
+       return ppcell.msg;
+    }
+  }
+  return 0; 
+}
+
+string PIPPList::GetSelStr(int i)
+{
+  int n = 0;
+  for (TableIndexT j=1; j<=mRows; j++) {
+    STableCell cell;
+    cell.row = j;
+    cell.col = 1;
+    if (CellIsSelected(cell)) n++;
+    if (n == i) {
+       PIPPListCell ppcell;
+       UInt32 sz = sizeof(ppcell);
+       GetCellData(cell, &ppcell, sz);
+       return ppcell.str;
+    }
+  }
+  return ""; 
+}
+void PIPPList::SelectItem(string const& str)
+{
+  STableCell cell = FindStr(str);
+  SelectCell(cell);
+}
+
+void PIPPList::SelectItem(PIMessage msg)
+{
+  STableCell cell = FindMsg(msg);
+  SelectCell(cell);
+}
+
+void PIPPList::ClearSelItem(string const& str)
+{
+  STableCell cell = FindStr(str);
+  UnselectCell(cell);
+}
+
+void PIPPList::ClearSelItem(PIMessage msg)
+{
+  STableCell cell = FindMsg(msg);
+  UnselectCell(cell);
+}
+
+void PIPPList::SetMultipleSelect(bool ms)
+{
+  if (ms)
+    SetTableSelector(tms);
+  else
+    SetTableSelector(tss); 
+}
+
+void
+PIPPList::ClickCell(
+	const STableCell&		inCell,
+	const SMouseDownEvent&	inMouseDown)
+{
+  if (GetClickCount() == 2) {
+	
+  }
+}
Index: /tags/DPC_V0/Poubelle/PI/pipplist.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pipplist.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pipplist.h	(revision 1307)
@@ -0,0 +1,52 @@
+#pragma once
+
+#include <string>
+#include <LTableView.h>
+#include "pimsghandler.h"
+
+class LArray;
+
+struct PIPPListCell {
+   string 	   str;
+   PIMessage   msg;
+};
+
+class PIPPList : public LTableView {
+public:
+
+  PIPPList(PIMsgHandler* hndl);
+  PIPPList(
+    const SPaneInfo& inPaneInfo,
+    const SViewInfo& inViewInfo,
+    PIMsgHandler* hndl);
+  virtual ~PIPPList();
+
+  void       AppendItem(string const& str, PIMessage msg);
+  void       DeleteItem(string const& str);
+  void       DeleteItem(PIMessage msg);  
+
+  void       SetMultipleSelect(bool ms);
+  
+  int        GetNbSel();
+  PIMessage  GetSelMsg(int i);
+  string     GetSelStr(int i);
+  
+  void       SelectItem(string const& str);
+  void       SelectItem(PIMessage msg);
+  void       ClearSelItem(string const& str);
+  void       ClearSelItem(PIMessage msg);
+  
+protected:
+  LTableSelector* tss;
+  LTableSelector* tms;
+  LArray*         mArray;
+  PIMsgHandler*   mHndl;
+
+  virtual void    ClickCell(
+                       const STableCell        &inCell,
+                       const SMouseDownEvent   &inMouseDown);
+
+  void InitPPList();
+  STableCell  FindMsg(PIMessage msg);
+  STableCell  FindStr(string const& str);
+};
Index: /tags/DPC_V0/Poubelle/PI/pippmenubar.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippmenubar.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippmenubar.cc	(revision 1307)
@@ -0,0 +1,44 @@
+#include "pippmenubar.h"
+
+PIPPMenuBar::PIPPMenuBar()
+: LMenuBar(MBAR_Initial)
+{
+
+}
+
+PIPPMenuBar::~PIPPMenuBar()
+{}
+
+CommandT
+PIPPMenuBar::MenuCommandSelection(
+	const EventRecord	&inMouseEvent,
+	Int32				&outMenuChoice) const
+{
+	outMenuChoice = ::MenuSelect(inMouseEvent.where);
+	
+	int menuId = HiWord(outMenuChoice);
+	int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
+	
+	PIMenuMac* menu = PIMenuMac::findMenu(menuId);
+	if (menu)
+	  menu->ItemSelected(menuItem);
+	
+	return cmd_Nothing;
+}
+
+CommandT
+PIPPMenuBar::FindKeyCommand(
+	const EventRecord	&inKeyEvent,
+	Int32				&outMenuChoice) const
+{
+	char	theChar = inKeyEvent.message & charCodeMask;
+	outMenuChoice = ::MenuKey(theChar);
+	int menuId = HiWord(outMenuChoice);
+	int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
+	
+	PIMenuMac* menu = PIMenuMac::findMenu(menuId);
+	if (menu)
+	  menu->ItemSelected(menuItem);
+	
+	return cmd_Nothing;
+}
Index: /tags/DPC_V0/Poubelle/PI/pippmenubar.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippmenubar.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippmenubar.h	(revision 1307)
@@ -0,0 +1,21 @@
+#ifndef PIPPMENUBAR_H_SEEN
+#define PIPPMENUBAR_H_SEEN
+
+#include <LMenuBar.h>
+#include "pimenumac.h"
+
+class PIPPMenuBar : public LMenuBar {
+public:
+                           PIPPMenuBar();
+                          ~PIPPMenuBar();
+
+	virtual CommandT	   MenuCommandSelection(const EventRecord &inMouseEvent,
+								Int32 &outMenuChoice) const;
+
+	virtual CommandT	FindKeyCommand(
+								const EventRecord	&inKeyEvent,
+								Int32				&outMenuChoice) const;
+};
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pippoptmenu.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippoptmenu.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippoptmenu.cc	(revision 1307)
@@ -0,0 +1,67 @@
+#include "pippoptmenu.h"
+
+PIPPOptMenu::PIPPOptMenu(
+	const SPaneInfo	&inPaneInfo,
+	MessageT		inValueMessage,
+	Int16			inTitleOptions,
+	ResIDT			inMENUid,
+	Int16			inTitleWidth,
+	Int16			inPopupVariation,
+	ResIDT			inTextTraitsID,
+	Str255			inTitle,
+	OSType			inResTypeMENU,
+	Int16			inInitialMenuItem)
+		: LStdPopupMenu(inPaneInfo, inValueMessage, inTitleOptions,
+				inMENUid, inTitleWidth, inPopupVariation, inTextTraitsID,
+				inTitle, inResTypeMENU, inInitialMenuItem)
+{
+}
+
+
+
+PIPPOptMenu::PIPPOptMenu(
+	const SPaneInfo	&inPaneInfo,
+	MessageT		inValueMessage,
+	Int32			inMaxValue,
+	ResIDT			inTextTraitsID,
+	ControlHandle	inMacControlH)
+		: LStdPopupMenu(inPaneInfo, inValueMessage, inMaxValue,
+						inTextTraitsID, inMacControlH)
+{
+}
+
+
+
+PIPPOptMenu::PIPPOptMenu(
+	LStream	*inStream)
+		: LStdPopupMenu(inStream)
+{	
+}
+
+void
+PIPPOptMenu::HotSpotResult(
+	Int16	inHotSpot)
+{
+		BroadcastMessage(msg_ThumbDragged, (void*) this);
+}
+
+void
+PIPPOptMenu::SetMenu(PIPUMenu* pdm)
+{
+  // On va changer la resource de menu au passage...
+  InsertMenu(pdm->GetMacMenuHandle(), hierMenu);
+  PopupPrivateDataHandle	dataH =
+		(PopupPrivateDataHandle) (**GetMacControl()).contrlData;
+  (**dataH).mHandle = pdm->GetMacMenuHandle();
+  (**dataH).mID = pdm->GetMacMenuID();
+  
+  //InitStdPopupMenu(1);
+  
+  mValue = 1;
+  mMinValue = 1;
+  mMaxValue = ::CountMItems(pdm->GetMacMenuHandle());
+
+  ::SetControlValue(mMacControlH, mValue);
+  ::SetControlMinimum(mMacControlH, mMinValue);
+  ::SetControlMaximum(mMacControlH, mMaxValue);
+}
Index: /tags/DPC_V0/Poubelle/PI/pippoptmenu.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippoptmenu.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippoptmenu.h	(revision 1307)
@@ -0,0 +1,36 @@
+#include "LStdControl.h"
+#include "pisysdep.h"
+#include PIMENU_H
+
+// Redefinir HotSpotResult pour envoyer un message au PIOptMenuMac (qui est un listener)
+// qui va envoyer une action.
+
+class PIPPOptMenu : public LStdPopupMenu {
+public:
+	enum { class_ID = 'PPop' };
+					PIPPOptMenu(
+							const SPaneInfo		&inPaneInfo,
+							MessageT			inValueMessage,
+							Int16				inTitleOptions,
+							ResIDT				inMENUid,
+							Int16				inTitleWidth,
+							Int16				inPopupVariation,
+							ResIDT				inTextTraitsID,
+							Str255				inTitle,
+							OSType				inResTypeMENU,
+							Int16				inInitialMenuItem);
+					PIPPOptMenu(
+							const SPaneInfo		&inPaneInfo,
+							MessageT			inValueMessage,
+							Int32				inMaxValue,
+							ResIDT				inTextTraitsID,
+							ControlHandle		inMacControlH);
+					PIPPOptMenu(
+							LStream				*inStream);
+							
+					void SetMenu(PIPUMenu* pdm);
+protected:
+	virtual void		HotSpotResult(
+								Int16			inHotSpot);
+
+};
Index: /tags/DPC_V0/Poubelle/PI/pippviewadapter.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippviewadapter.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippviewadapter.cc	(revision 1307)
@@ -0,0 +1,116 @@
+#include "pippviewadapter.h"
+#include "piupdattachment.h"
+
+
+PIPPViewAdapter::PIPPViewAdapter()	
+:LView()
+{
+	::SetRect(&piBindings, 0, 0, 0, 0);
+}
+
+PIPPViewAdapter::PIPPViewAdapter(	
+	const PIPPViewAdapter& inOriginal)
+:LView(inOriginal)
+{
+	::SetRect(&piBindings, 0, 0, 0, 0);
+}
+PIPPViewAdapter::PIPPViewAdapter(
+	const SPaneInfo		&inPaneInfo,
+	const SViewInfo		&inViewInfo)
+:LView(inPaneInfo, inViewInfo)
+{
+	::SetRect(&piBindings, 0, 0, 0, 0);
+}
+
+void PIPPViewAdapter::SetBinding(PIBindingKind left, PIBindingKind top, 
+                                  PIBindingKind right, PIBindingKind bottom)
+{
+  piBindings.left = left;
+  piBindings.right = right;
+  piBindings.top = top;
+  piBindings.bottom = bottom;
+}
+
+void PIPPViewAdapter::AdaptToSuperFrameSize(
+	Int32				inSurrWidthDelta,
+	Int32				inSurrHeightDelta,
+	Boolean				inRefresh)
+{
+  SDimension16 parSize;
+  GetSuperView()->GetFrameSize(parSize);
+  
+  SDimension16 oldParSize = parSize;
+  oldParSize.width -= inSurrWidthDelta;
+  oldParSize.height -= inSurrHeightDelta;
+  
+  SPoint32 myLoc;
+  GetFrameLocation(myLoc);
+  SPoint32	superImageLoc = {0, 0};
+	
+  if (mSuperView != nil) {
+    mSuperView->GetImageLocation(superImageLoc);
+  }
+  myLoc.h -= superImageLoc.h;
+  myLoc.v -= superImageLoc.v;
+  
+  SDimension16 mySize;
+  GetFrameSize(mySize);
+    
+  SPoint32 myXLoc = myLoc;
+  myXLoc.h += mySize.width;
+  myXLoc.v += mySize.height;
+  
+  if (piBindings.left == PIBK_elastic) {
+     myLoc.h = parSize.width * ((float)myLoc.h / (float)oldParSize.width);
+  }
+ 
+  if (piBindings.top == PIBK_elastic) {
+     myLoc.v = parSize.height * ((float)myLoc.v / (float)oldParSize.height);
+  }
+  
+  if (piBindings.right == PIBK_fixed) {
+     myXLoc.h += inSurrWidthDelta;
+  } else
+  if (piBindings.right == PIBK_elastic) {
+     myXLoc.h = parSize.width * ((float)myXLoc.h / (float)oldParSize.width);
+  }  
+ 
+  if (piBindings.bottom == PIBK_fixed) {
+     myXLoc.v += inSurrHeightDelta;
+  } else
+  if (piBindings.bottom == PIBK_elastic) {
+     myXLoc.v = parSize.height * ((float)myXLoc.v / (float)oldParSize.height);
+  }
+  
+  
+  if (piBindings.left == PIBK_free) {
+    myLoc.h = myXLoc.h - mySize.width;
+  }   
+  if (piBindings.top == PIBK_free) {
+    myLoc.v = myXLoc.v - mySize.height;
+  }   
+  if (piBindings.right == PIBK_free) {
+    myXLoc.h = myLoc.h + mySize.width;
+  }   
+  if (piBindings.bottom == PIBK_free) {
+    myXLoc.v = myLoc.v + mySize.height;
+  }
+  
+  mySize.width = myXLoc.h - myLoc.h;
+  mySize.height = myXLoc.v - myLoc.v;
+  
+  ResizeFrameTo(mySize.width, mySize.height, inRefresh);
+  ResizeFrameTo(mySize.width, mySize.height, inRefresh);
+  PlaceInSuperImageAt(myLoc.h, myLoc.v, inRefresh);
+}
+
+void
+PIPPViewAdapter::ResizeFrameBy(
+	Int16		inWidthDelta,
+	Int16		inHeightDelta,
+	Boolean		inRefresh)
+{
+  LView::ResizeFrameBy(inWidthDelta,inHeightDelta,inRefresh);
+  ExecuteAttachments(msg_Resize, NULL);
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pippviewadapter.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippviewadapter.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippviewadapter.h	(revision 1307)
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <LView.h>
+#include "piwdggen.h"
+
+class PIPPViewAdapter : public LView {
+public:
+						PIPPViewAdapter();
+						PIPPViewAdapter(	
+								const PIPPViewAdapter	&inOriginal);
+						PIPPViewAdapter(
+								const SPaneInfo		&inPaneInfo,
+								const SViewInfo		&inViewInfo);
+
+	virtual void        SetBinding(PIBindingKind left, PIBindingKind top, 
+                                   PIBindingKind right, PIBindingKind bottom);
+	virtual void		AdaptToSuperFrameSize(
+								Int32				inSurrWidthDelta,
+								Int32				inSurrHeightDelta,
+								Boolean				inRefresh);
+	virtual void		ResizeFrameBy(
+								Int16				inWidthDelta,
+								Int16				inHeightDelta,
+								Boolean				inRefresh);
+								
+protected:
+	Rect				piBindings;
+};
Index: /tags/DPC_V0/Poubelle/PI/pippwindowmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippwindowmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippwindowmac.cc	(revision 1307)
@@ -0,0 +1,107 @@
+#include "pippwindowmac.h"
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac
+// ---------------------------------------------------------------------------
+//	Default Constructor
+
+PIPPWindowMac::PIPPWindowMac()
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac(SWindowInfo&)
+// ---------------------------------------------------------------------------
+//	Construct Window from the data in a struct
+
+PIPPWindowMac::PIPPWindowMac(
+	const SWindowInfo	&inWindowInfo)
+:LWindow(inWindowInfo)
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac(ResIDT, Uint32, LCommander*)
+// ---------------------------------------------------------------------------
+//	Construct a Window from a WIND Resource with the specified attributes
+//	and SuperCommander
+
+PIPPWindowMac::PIPPWindowMac(
+	ResIDT		inWINDid,
+	Uint32		inAttributes,
+	LCommander	*inSuperCommander)
+:LWindow(inWINDid, inAttributes, inSuperCommander)
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac
+// ---------------------------------------------------------------------------
+//	Construct a Window from input parameters
+
+PIPPWindowMac::PIPPWindowMac(
+	LCommander		*inSuperCommander,
+	const Rect		&inGlobalBounds,
+	ConstStringPtr	inTitle,
+	Int16			inProcID,
+	Uint32			inAttributes,
+	WindowPtr		inBehind,
+	void			*inStorage)
+:LWindow(inSuperCommander, inGlobalBounds, inTitle,
+inProcID, inAttributes, inBehind, inStorage)
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac(LStream*)
+// ---------------------------------------------------------------------------
+//	Construct Window from the data in a stream
+
+PIPPWindowMac::PIPPWindowMac(
+	LStream	*inStream)
+:LWindow(inStream)
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ ~PIPPWindowMac
+// ---------------------------------------------------------------------------
+//	Destructor
+
+PIPPWindowMac::~PIPPWindowMac()
+{
+}
+
+void
+PIPPWindowMac::AttemptClose()
+{
+  myPIWindow->Process(myPIWindow->BuildMsg(myPIWindow->Msg(),PIMsg_Close), myPIWindow, NULL) ;
+}
+
+
+const MessageT	msg_Resize			= 817;
+const MessageT	msg_Move			= 818;
+
+void PIPPWindowMac::DoSetPosition(Point inPosition)
+{
+    ExecuteAttachments(msg_Move, NULL);
+    LWindow::DoSetPosition(inPosition);
+}
+
+void PIPPWindowMac::DoSetBounds(const Rect &inBounds)
+{
+    ExecuteAttachments(msg_Resize, NULL);
+    LWindow::DoSetBounds(inBounds);
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pippwindowmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pippwindowmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pippwindowmac.h	(revision 1307)
@@ -0,0 +1,37 @@
+#include <LWindow.h>
+#include "piwindowmac.h"
+
+class PIPPWindowMac : public LWindow {
+public:
+	enum { class_ID = 'pwin' };
+	
+						PIPPWindowMac();
+						PIPPWindowMac(
+								const SWindowInfo	&inWindowInfo);
+						PIPPWindowMac(
+								ResIDT				inWINDid,
+								Uint32				inAttributes,
+								LCommander			*inSuperCommander);
+								
+						PIPPWindowMac(
+								LCommander			*inSuperCommander,
+								const Rect			&inGlobalBounds,
+								ConstStringPtr		inTitle,
+								Int16				inProcID,
+								Uint32				inAttributes,
+								WindowPtr			inBehind,
+								void				*inStorage = nil);
+								
+						PIPPWindowMac(
+								LStream				*inStream);
+	virtual				~PIPPWindowMac();
+
+	virtual void		DoSetPosition(
+								Point				inPosition);
+	virtual void		DoSetBounds(
+								const Rect			&inBounds);
+								
+	virtual void		AttemptClose();
+								
+	PIWindow* myPIWindow;
+};
Index: /tags/DPC_V0/Poubelle/PI/piscdrawwdg.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piscdrawwdg.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piscdrawwdg.cc	(revision 1307)
@@ -0,0 +1,490 @@
+// Module PI : Peida Interactive     PIScDrawWdg
+// Gestionnaire Drawer-2D  E.Aubourg, R. Ansari  96-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "piscdrawwdg.h"
+#include "pidrwtools.h"
+#include "parradapter.h"
+
+//++
+// Class	PIScDrawWdg
+// Lib		PI
+// include	piscdrawwdg.h
+//
+//   	Classe pour la l'affichage et la manipulation d'un ensemble
+//	de *Drawer* avec la gestion de zoom (agrandissement).
+//	* Bouton-1 : Envoie le message "PIMsg_Active" et affiche
+//	les coordonnées courantes (User-Coordinates)
+//	* Bouton-2 : Permet de définir un rectangle pour le zoom.
+//
+//	Gestion du clavier :
+//	* <Alt>O : Active/Affiche les  contrôles de paramètres spécifiques 
+//	(Par défaut, action identique à <Alt>G)
+//	* <Alt>G : Affichage de la fenêtre de changement des attributs graphiques
+//	* <Alt>R : Rafraîchit l'affichage.
+//	* <Alt>M : Active/Désactive l'affichage d'une réticule de mesure (Bouton-1)
+//	* <Alt>V : Copier/*Coller* Ajout du texte du buffer copier/coller
+//	sur l'objet à la position courante.
+//	* <Alt>Z : Supprime les textes et signes ajoutés au dessin.
+//--
+//++
+// Links	Parents
+// PIBaseWdg
+//--
+//++
+// Links	Voir aussi
+// PIDrawer
+//--
+
+static inline void dbl_swap(double& a, double& b) { double tmp = a; a = b; b = tmp;  } 
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+//  PIScDrawWdg(PIContainerGen *par, char *nom, int sx=100, int sy=100, int px=0, int py=0)
+//	Constructeur. Contient uniquement le traceur de base, responsable du tracé
+//	des axes et des éléments ajoutés (textes, ...)
+// long  kind()
+//	Renvoie le type ("=PIScDrawWdg::ClassId")
+// void SetLimits(double xmin, double xmax, double ymin, double ymax, -
+//           int axrl=kAxeDirSame, int ayud=kAxeDirSame, bool tmp=false)
+//	Définit les limites de coordonnées.
+// void	 UpdateLimits()
+//	Recalcule les limites de coordonnées à partir du premier Drawer.
+// void  SetAxesFlags(unsigned int flags=kAxesDflt)
+//	Définit les attributs des axes.
+// int  AddScDrawer(PIDrawer*, bool ad=false)
+//	Ajoute un Drawer.
+//--
+
+
+PIScDrawWdg::PIScDrawWdg(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+:PIBaseWdg(par, nom, sx, sy, px, py)
+{
+  mFgReticule = false;
+  mCPosX = mCPosY = 0;
+  mPPos[0] = mPPos[1] = 0.;
+
+  mBDrw = new PIElDrawer;
+  SetLimits(-1.,1.,-1.,1.,kAxeDirLtoR,kAxeDirDownUp);
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);  
+  FreeLimits();
+  xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
+  SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true);
+//  SetDefaultDrawRectangle(0.12, 0.08, 0.88, 0.92, true);
+  AddDrawer(mBDrw, true, false, false);
+  
+  mTrlb = mTxw = NULL;
+  mTrW = NULL;
+  SetTextWin(NULL);
+
+  ActivateKeyboard();
+  ActivateButton(1);    // Pour pouvoir activer la fenetre et coordonnees
+  ActivateMove(1);      //    "         "         "        "
+  ActivateButton(2);
+  ActivateMove(2);
+
+}
+
+PIScDrawWdg::~PIScDrawWdg()
+{
+  delete mBDrw;
+  if (mTrW)  delete mTrW;
+}
+
+void 
+PIScDrawWdg::Keyboard(int key, PIKeyModifier kmod)
+{
+if (kmod == PIKM_Alt) {
+  if      (key == 'R' || key == 'r')  Refresh(); // rafraichir l'affichage
+  else if (key == 'M' || key == 'm') mFgReticule = !mFgReticule; // reticule de mesure 
+  else if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller)  
+  else if (key == 'Z' || key == 'z') { mBDrw->ElDelAll();  Refresh(); } // Pour supprimer tous les signes 
+  else if (key == 'O' || key == 'o') ActivateSpecializedControls();
+  else if (key == 'G' || key == 'g') { 
+    PIDrwTools::SetCurrentBaseWdg(this);
+    PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
+    }
+  }
+}
+void 
+PIScDrawWdg::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
+{
+if (typ != PICP_string) return;
+int ll = (l<256) ? l+1 : 256;
+char pc[256];
+strncpy(pc, (char*)pdata, ll-1);  pc[ll-1] = '\0';
+mBDrw->ElAddText(mPPos[0], mPPos[1], pc );
+mBDrw->Refresh();
+}
+
+void
+PIScDrawWdg::SetLimits(double xmin, double xmax, double ymin, double ymax,
+                       int axrl, int ayud, bool tmp)
+{
+  if (xmax <= xmin || ymax <= ymin)
+    return; // $CHECK$ exception ?
+  SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);
+  mBDrw->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud);
+  mPPos[0] = 0.5*(XMin()+XMax());
+  mPPos[1] = 0.5*(YMin()+YMax());
+  if (!tmp) {
+    xMinS = xmin;
+    xMaxS = xmax;
+    yMinS = ymin;
+    yMaxS = ymax;
+  }
+}
+  
+void
+PIScDrawWdg::UpdateLimits()
+{
+  if (NbDrawers() < 2)  return;
+  PIDrawer* d = GetDrawer(1);
+  if (d == NULL) return;
+  d->UpdateLimits();
+  SetLimits(d->XMin(), d->XMax(), d->YMin(), d->YMax()); 
+  Refresh();
+  return;  
+}
+
+int 
+PIScDrawWdg::AddScDrawer(PIDrawer* d, bool ad)
+{
+  if (d == NULL)  return(-1);
+  if (! LimitsFixed() ) {  //  On met a jour les limites 
+    d->UpdateLimits();
+    SetLimits(d->XMin(), d->XMax(), d->YMin(), d->YMax());
+  }
+  return(AddDrawer(d, true, ad));
+}
+
+
+void
+PIScDrawWdg::SetTextWin(PILabel * tw, bool trw, int tx, int ty)
+{
+mTxw = tw;
+if (trw)
+  {
+  if (mTrW)  mTrW->SetSize(tx, ty);
+  else
+    {
+    mTrW = new PIWindow(this, "Point", PIWK_transient, tx, ty, 0, 0);
+    mTrW->SetAutoDelChilds(true);
+    mTrlb = new PILabel(mTrW, "PointCoord", tx, ty, 0, 0);
+    mTrlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
+    }
+  }
+else
+  if (mTrW) { delete mTrW; mTrW = NULL;  mTrlb = NULL; }
+
+return;
+}
+
+
+
+// Gestion affichage coordonnees du point 
+
+string   
+PIScDrawWdg::GetClickText(double x, double y) 
+// Donne le texte a afficher pour position x,y  
+{
+  char buff[128];
+  sprintf(buff, "X= %g  Y= %g",  x, y);
+  //  sprintf(buff, "%.3f,%.3f ",  x, y);
+  return((string)buff);
+}
+
+void
+PIScDrawWdg::ActivateSpecializedControls()
+// Par défaut affiche la fenetres des attributs graphiques et axes
+{
+  PIDrwTools::SetCurrentBaseWdg(this);
+  PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
+}
+
+void
+PIScDrawWdg::But1Press(int x, int y)
+{
+  UpdateText(x, y);
+  if (mTrW)
+    { 
+    int tpx, tpy;
+    GetScreenPos(tpx, tpy);       
+    tpy -= (mTrW->YSize()+5);
+    if (tpy < 0)  tpy = 0;
+    mTrW->SetPos(tpx, tpy);
+    mTrW->Show();
+    }
+  if (mFgReticule) { // On trace une reticule
+    cForCol = mWGrC->GetForeground();
+    cGOmod  = mWGrC->GetGOMode();
+    cLatt = mWGrC->GetLineAtt();
+    mWGrC->SelForeground(PI_Magenta);
+    mWGrC->SelGOMode(PI_GOXOR);
+    mWGrC->SelLine(PI_ThinLine);
+    mWGrC->DrawLine(x, 0, x, YSize());
+    mWGrC->DrawLine(0, y, XSize(), y);
+    mCPosX = x;   mCPosY = y;
+    char buff[64];
+    sprintf(buff,"%g , %g", mPPos[0], mPPos[1]);
+    mWGrC->DrawString(x+10, y-10, buff); 
+    }
+  else SelPointerShape(PI_CrossPointer);
+
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+}
+
+void
+PIScDrawWdg::Ptr1Move(int x, int y)
+{
+  char buff[64];
+  if (mFgReticule) { // On trace une reticule
+    mWGrC->DrawLine(mCPosX, 0, mCPosX, YSize());
+    mWGrC->DrawLine(0, mCPosY, XSize(), mCPosY);
+    sprintf(buff,"%g , %g", mPPos[0], mPPos[1]);
+    mWGrC->DrawString(mCPosX+10, mCPosY-10, buff); 
+    mWGrC->DrawLine(x, 0, x, YSize());
+    mWGrC->DrawLine(0, y, XSize(), y);
+    mCPosX = x;   mCPosY = y;
+    }  
+  UpdateText(x, y);  // Met a jour mPPos
+  if (mFgReticule) {
+    sprintf(buff,"%g , %g", mPPos[0], mPPos[1]);
+    mWGrC->DrawString(x+10, y-10, buff); 
+    }
+}
+
+void
+PIScDrawWdg::But1Release(int x, int y)
+{
+  UpdateText(x, y);
+  if (mFgReticule) { // On efface la reticule
+    mWGrC->DrawLine(mCPosX, 0, mCPosX, YSize());
+    mWGrC->DrawLine(0, mCPosY, XSize(), mCPosY);
+    char buff[64];
+    sprintf(buff,"%g , %g", mPPos[0], mPPos[1]);
+    mWGrC->DrawString(mCPosX+10, mCPosY-10, buff); 
+    mWGrC->SelForeground(cForCol);
+    mWGrC->SelGOMode(cGOmod);
+    mWGrC->SelLine(cLatt); 
+    mCPosX = mCPosY = 0;
+    }
+  else SelPointerShape(PI_ArrowPointer);
+  if (mTrW)  mTrW->Hide();
+}
+
+void
+PIScDrawWdg::UpdateText(int xp, int yp)
+{
+
+  double dx, dy;
+  mBDrw->GetGraphicUC()->GrC2UC(xp, yp, dx, dy); 
+  mPPos[0] = dx;  mPPos[1] = dy; 
+  
+  string ctxt =  GetClickText(dx, dy);
+//DEBUG  char buff[32];    sprintf(buff, " %d:%d",xp,yp); ctxt += buff;
+  if (mTxw)
+    mTxw->SetLabel(ctxt);
+  if (mTrlb)
+    mTrlb->SetLabel(ctxt);
+  return;
+
+}
+
+// Gestion du zoom
+void
+PIScDrawWdg::But2Press(int x, int y)
+{
+  xEndDrag = xBegDrag = x;
+  yEndDrag = yBegDrag = y;
+  cForCol = mWGrC->GetForeground();
+  cGOmod  = mWGrC->GetGOMode();
+  cPointer = GetPointerShape();
+  cLatt = mWGrC->GetLineAtt();
+  SelPointerShape(PI_CrossPointer);
+  mWGrC->SelForeground(PI_Magenta);
+  mWGrC->SelGOMode(PI_GOXOR);
+  mWGrC->SelLine(PI_ThinLine);
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+}
+
+void
+PIScDrawWdg::But2Release(int /*x*/, int /*y*/)
+{
+
+  mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+
+  mWGrC->SelForeground(cForCol);
+  mWGrC->SelGOMode(cGOmod);
+  SelPointerShape(cPointer); 
+  mWGrC->SelLine(cLatt); 
+  
+  if (xBegDrag == xEndDrag || yBegDrag == yEndDrag)
+    SetLimits(xMinS, xMaxS, yMinS, yMaxS, kAxeDirSame, kAxeDirSame );
+  else {
+    double xl,yl,xh,yh;
+    mBDrw->GetGraphicUC()->GrC2UC(xBegDrag, yBegDrag, xl, yl);
+    mBDrw->GetGraphicUC()->GrC2UC(xEndDrag, yEndDrag, xh, yh);
+    if (xl > xh) dbl_swap(xl, xh);
+    if (yl > yh) dbl_swap(yl, yh);
+    SetLimits(xl,xh,yl,yh, kAxeDirSame, kAxeDirSame, true);
+  }
+  
+  Refresh();
+}
+
+void
+PIScDrawWdg::Ptr2Move(int x, int y)
+{
+  mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+  xEndDrag = x;
+  yEndDrag = y;
+  mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+}
+
+
+// ----------------------------------------------------------
+//  Classe de trace de points/fonctions Y=f(X)
+//  Trace Y=ay->Value() = f(X= ax->Value()) si ax et ay != NULL
+//  Trace Y=ax->Value() = f(X= ax->X())  si ay == NULL
+// ----------------------------------------------------------
+
+/* --Methode-- */
+PIYfXDrawer::PIYfXDrawer(P1DArrayAdapter* ax, P1DArrayAdapter* ay, bool ad)
+    : PIDrawer()
+{
+  mAdDO = ad;
+  mAx = ax;
+  mAy = ay;
+  if ((mAx == NULL))  mSz = 0;
+  else {
+    if (!mAy)  mSz = mAx->Size();
+    else   mSz = (mAx->Size() < mAy->Size()) ? mAx->Size() :  mAy->Size();
+    }
+} 
+
+/* --Methode-- */
+PIYfXDrawer::~PIYfXDrawer()
+{
+  if (mAdDO && mAx)  delete mAx;
+  if (mAdDO && mAy)  delete mAy;
+}
+
+/* --Methode-- */
+void PIYfXDrawer::UpdateLimits()
+{
+  if (mSz <= 0)  return;
+  double xmin, xmax, ymin, ymax;
+  int i=0;
+  double cv;
+  if (mAy) {
+    xmin = xmax = mAx->Value(0);
+    ymin = ymax = mAy->Value(0);
+    for(i=1; i<mSz; i++) {
+      cv = mAx->Value(i); 
+      if (cv < xmin)  xmin = cv;
+      if (cv > xmax)  xmax = cv;
+      cv = mAy->Value(i); 
+      if (cv < ymin)  ymin = cv;
+      if (cv > ymax)  ymax = cv;
+      }
+    }
+  else {
+    xmin = xmax = mAx->X(0);
+    ymin = ymax = mAx->Value(0);
+    for(i=1; i<mSz; i++) {
+      cv = mAx->X(i); 
+      if (cv < xmin)  xmin = cv;
+      if (cv > xmax)  xmax = cv;
+      cv = mAx->Value(i); 
+      if (cv < ymin)  ymin = cv;
+      if (cv > ymax)  ymax = cv;
+      }
+    }
+
+  double dx, dy;
+  dx = 0.02*(xmax-xmin);
+  dy = 0.02*(ymax-ymin);
+
+  SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy);
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+
+/* --Methode-- */
+void PIYfXDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+  double xp,yp;
+  int i;
+
+  if (mSz <= 0)  return;
+
+//  Trace des markers 
+  if ( (mMrk != PI_NotDefMarker) ||  (mLAtt == PI_NotDefLineAtt) ) {
+    for(i=0; i<mSz; i++) {
+      if (mAy) { xp = mAx->Value(i); yp = mAy->Value(i); }
+      else { xp = mAx->X(i);  yp = mAx->Value(i); }
+      if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+      g->DrawMarker(xp, yp);
+    }
+  }
+
+  if (mLAtt == PI_NotDefLineAtt)    return;
+
+// Trace des lignes 
+  double xp2, yp2;
+  if (mAy) { xp2 = mAx->Value(0); yp2 = mAy->Value(0); }
+  else { xp2 = mAx->X(0);  yp2 = mAx->Value(0); }
+  for(i=1; i<mSz; i++) {
+    xp = xp2; yp = yp2;
+    if (mAy) { xp2 = mAx->Value(i); yp2 = mAy->Value(i); }
+    else { xp2 = mAx->X(i);  yp2 = mAx->Value(i); }
+    if ( ((xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax)) &&
+         ((xp2 < xmin) || (xp2 > xmax) || (yp2 < ymin) || (yp2 > ymax)) )  continue;
+    g->DrawLine(xp, yp, xp2, yp2);
+  }
+}
+
+
+//================================================================
+// PIFuncDrawer
+// Classe de traceur de fonction  double = f(fouble)
+//================================================================
+
+/* --Methode-- */
+PIFuncDrawer::PIFuncDrawer(PIFuncDrawer::FUNC f)
+: mFunc(f)
+{}
+
+/* --Methode-- */
+PIFuncDrawer::~PIFuncDrawer()
+{
+}
+
+/* --Methode-- */
+void
+PIFuncDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/)
+{
+  PIGrCoord x1, x2, y1, y2;
+  g->GetGrSpace(x1, x2, y1, y2);
+  double xMax = x2;
+  double xMin = x1;
+  double yMax = y2;
+  double yMin = y1;
+  double xStep = (xMax - xMin)/100;
+  double xOld = xMin;
+  double yOld = mFunc(xMin);
+  for (double x = xMin+xStep; x<xMax; x+=xStep) {
+    double y = mFunc(x);
+    if (y>yMin && yOld>yMin && 
+        y<yMax && yOld<yMax) 
+           g->DrawLine(xOld, yOld, x, y);
+    xOld = x;
+    yOld = y;
+  }
+}
Index: /tags/DPC_V0/Poubelle/PI/piscdrawwdg.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piscdrawwdg.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piscdrawwdg.h	(revision 1307)
@@ -0,0 +1,134 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive  PIScDrawWdg PIYfXDrawer
+// Gestionnaire Drawer-2D  E.Aubourg, R. Ansari  96-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PISCDRAWWDG_H
+#define PISCDRAWWDG_H
+
+#include "pisysdep.h"
+#include PIBWDG_H
+#include PISTDWDG_H
+#include PIWIN_H
+#include "pidrawer.h"
+
+
+// PIScDrawWdg, Gestionnaire de traceur 2D 
+
+class PIScDrawWdg : public PIBaseWdg {
+public:
+  enum {ClassId = 5300};
+
+                     PIScDrawWdg(PIContainerGen *par, char *nom,
+                                   int sx=100, int sy=100, int px=0, int py=0);
+  virtual            ~PIScDrawWdg();
+
+  virtual long       kind() {return ClassId; }
+  
+  virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax, 
+                               int axrl=kAxeDirSame, int ayud=kAxeDirSame, bool tmp=false);
+  virtual void	     UpdateLimits();  // Calcule et change les limites a partir de Drawer-No-1 
+
+  inline void        SetAxesFlags(unsigned int flags=kBoxAxes | kExtTicks | kLabels) 
+                                  { mBDrw->SetAxesFlags(flags); }
+  inline void	     SetTitles(const char* tt=NULL, const char* tb=NULL)
+                            { mBDrw->SetTitles(tt, tb); }
+  inline void	     SetTitles(string const & tt, string const & tb)
+                            { mBDrw->SetTitles(tt, tb); }
+
+  int                AddScDrawer(PIDrawer*, bool ad=false);   // Ajoute un Drawer en auto 
+  inline PIElDrawer* BaseDrawer() { return mBDrw; };
+
+// Configuration et limites des axes 
+  inline unsigned int GetAxesFlags() { return(mBDrw->GetAxesFlags()); }
+  inline void         GetAxesConfig(int& xa, int& ya) { mBDrw->GetAxesConfig(xa, ya); }
+
+  inline double XMin() const {return mBDrw->XMin();}
+  inline double XMax() const {return mBDrw->XMax();}
+  inline double YMin() const {return mBDrw->YMin();}
+  inline double YMax() const {return mBDrw->YMax();}
+
+  inline double XPPos() const { return mPPos[0]; }
+  inline double YPPos() const { return mPPos[1]; }
+
+  int    LimitsFixed() const {return mBDrw->LimitsFixed();}
+  void   FreeLimits() { mBDrw->FreeLimits(); }
+    
+
+  virtual string     GetClickText(double x, double y); // Donne le texte a afficher pour position x,y
+  virtual void	     ActivateSpecializedControls();   // Pour activer des controles specifiques
+
+  void               SetTextWin(PILabel * tw, bool trw=true, int tx=300, int ty=30);
+
+  virtual void       But1Press(int x, int y);
+  virtual void       But1Release(int x, int y);
+  virtual void       Ptr1Move(int x, int y);
+
+  virtual void       But2Press(int x, int y);
+  virtual void       But2Release(int x, int y);
+  virtual void       Ptr2Move(int x, int y);
+  
+  virtual void       Keyboard(int key, PIKeyModifier kmod);
+  virtual void       PasteSelection(unsigned int typ, void *pdata, unsigned int l);
+  
+protected:
+  double xMinS, xMaxS, yMinS, yMaxS; // Sauvegarde pour zoom
+  double mPPos[2];               // Position courante (user coordinates)
+  int mCPosX, mCPosY;              // Position click souris X,Y
+  bool mFgReticule;                // Controle l'affiche d'une réticule (Bouton-1)
+
+  PIElDrawer* mBDrw;
+  
+  int xBegDrag, yBegDrag;
+  int xEndDrag, yEndDrag;
+  PIColors cForCol;
+  PIGOMode cGOmod;  
+  PIPointer cPointer;
+  PILineAtt cLatt;
+  PILabel * mTxw;  
+  PILabel * mTrlb;
+  PIWindow * mTrW;
+
+private:
+  void  UpdateText(int xp, int yp);
+};
+
+
+// ----------------------------------------------------------
+// Classe de traceur de points/fonction Y=F(x)
+// Trace Y=ay->Value() = f(X= ax->Value()) si ax et ay != NULL
+// Trace Y=ax->Value() = f(X= ax->X())  si ay == NULL
+ 
+class P1DArrayAdapter;
+class PIYfXDrawer : public PIDrawer {
+public:
+                     PIYfXDrawer(P1DArrayAdapter* ax, P1DArrayAdapter* ay, bool ad);
+  virtual           ~PIYfXDrawer();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+       
+protected:
+  P1DArrayAdapter* mAx;
+  P1DArrayAdapter* mAy;
+  int mSz;
+  bool mAdDO;
+};
+
+// ----------------------------------------------------------
+// Classe de traceur de fonction  double = f(fouble)
+// ----------------------------------------------------------
+
+class PIFuncDrawer : public PIDrawer {
+public:
+  typedef double(*FUNC)(double);
+                     PIFuncDrawer(FUNC);
+  virtual           ~PIFuncDrawer();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+protected:
+  FUNC               mFunc;
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pistdwdggen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pistdwdggen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pistdwdggen.cc	(revision 1307)
@@ -0,0 +1,279 @@
+#include "pistdwdggen.h"
+
+/************* PILabelGen ************/
+
+//++
+// Class	PILabel
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique simple permettant d'afficher une étiquette (texte).
+//	"PILabelGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PILabel" déclarée dans le fichier
+//	entête "PISTDWDG_H".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PILabel(PIContainerGen* par, char* nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet PILabel ayant un contenu (étiquette) identique à "nom".
+// void SetLabel(string const& lab)
+//	Modifie l'étiquette affichée par l'objet 
+//--
+
+
+
+
+PILabelGen::PILabelGen(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PILabelGen::~PILabelGen()
+{}
+
+/************* PIButtonGen ************/
+//++
+// Class	PIButton
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type bouton .
+//	"PIButtonGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIButton" déclarée dans le fichier
+//	entête "PISTDWDG_H". Lors de l'activation, le message de l'objet complété
+//	par le modifier "PIMsg_Click" est envoyé ("Send()"). Le champ "data" 
+//	contient le pointeur "NULL".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIButton(PIContainerGen* par, char* nom, PIMessage msg, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet PIButton avec une étiquette identique à "nom".
+// void SetLabel(string const& lab)
+//	Modifie l'étiquette affichée par l'objet bouton.
+//--
+
+
+
+PIButtonGen::PIButtonGen(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py, PIBtnSign bsgn)
+: PIWdg(par, nom, sx, sy, px, py)
+{
+SetMsg(msg);
+mSgn = bsgn;
+}
+
+PIButtonGen::~PIButtonGen()
+{}
+
+
+
+/************* PITextGen ************/
+//++
+// Class	PIText
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type champ texte.
+//	"PITextGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIText" déclarée dans le fichier
+//	entête "PISTDWDG_H". Si un message non nul a été associé a l'objet 
+//	par "PIWdg::SetMsg(PIMessage msg)", le message correspondant complété
+//	par le modifier "PIMsg_DataChanged" est envoyé ("Send()") lors de 
+//	de la validation du champ texte (touche Retour-Chariot). Le champ "data" 
+//	contient le pointeur "NULL".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+//  PIText(PIContainerGen* par, char* nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet PIText.
+// void SetText(string const& txt)
+//	Modifie  le contenu du champ texte.
+// string  GetText() const
+//	Renvoie le contenu du champ texte.
+// void  SetMutiLineMode(bool mlm=false)
+//	Active ("mlm=true") ou désactive ("mlm=false") la possibilité d'édition multiligne.
+// void  SetTextEditable(bool te=true)
+//	Permet de rendre le contenu du champ texte non-éditable ("te=false")
+//--
+
+PITextGen::PITextGen(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PITextGen::~PITextGen()
+{}
+
+
+
+
+/************* PICheckBoxGen ************/
+
+PICheckBoxGen::PICheckBoxGen(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{
+SetMsg(msg);
+}
+
+PICheckBoxGen::~PICheckBoxGen()
+{}
+
+//++
+// Class	PICheckBox
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type CheckBox.
+//	"PICheckBoxGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PICheckBox" déclarée dans le fichier
+//	entête "PISTDWDG_H". Lors du changement d'état, le message de l'objet  
+//	complété par le modifier "PIMsg_DataChanged" est envoyé ("Send()").
+//	Le champ "data" contient un pointeur sur une variable de type "bool"
+//	qui contient l'état de l'objet lors de l'appel à "Send()".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PICheckBox(PIContainerGen* par, char* nom,  PIMessage msg, int sx=10, int sy=10, int px=0, int py=0);
+//	Création d'un objet PICheckBox.
+// void SetState(bool st=false)
+//	Modifie l'état de l'objet.
+// bool GetState()
+//	Renvoie l'état de l'objet.
+//--
+
+
+/************* PIScaleGen ************/
+//++
+// Class	PIScale
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type échelle ou curseur. (La valeur représentée 
+//	par l'objet peut être modifiée à l'aide d'un curseur).
+//	"PIScaleGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIScale" déclarée dans le fichier
+//	entête "PISTDWDG_H". Lors du changement de valeur, le message de l'objet  
+//	complété par le modifier "PIMsg_DataChanged" est envoyé ("Send()").
+//	Le champ "data" contient un pointeur sur une variable de type "int"
+//	qui contient la valeur associée  à l'objet lors de l'appel à "Send()".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIScale(PIContainerGen* par, char* nom, PIMessage msg, int dir=kSDirLtoR, int sx=100, int sy=10, int px=0, int py=0)
+//	Création d'un objet PIScale. "dir" indique la direction et le sens d'affichage et peut
+//	prendre les valeurs "kSDirLtoR" (gauche à droite), "kSDirRtoL" (droite à gauche),
+//	"kSDirDownUp" (bas vers haut) et "kSDirUpDown" (de haut en bas).
+// void  SetMinMax(int min, int max)
+//	Modifie les valeurs extrêmes de l'échelle. L'objet est créé avec des bornes par défaut de 1 à 100.
+// void GetMinMax(int& min, int& max)
+//	Renvoie les valeurs extrêmes de l'échelle.
+// void SetValue(int v)
+//	Modifie la valeur courante de l'échelle.
+// int GetValue()
+//	Renvoie la valeur courante de l'échelle.
+//--
+
+
+PIScaleGen::PIScaleGen(PIContainerGen *par, char *nom, PIMessage msg, 
+                       int /*dir*/, int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py) 
+{
+SetMsg(msg);
+}
+
+PIScaleGen::~PIScaleGen()
+{}
+
+/************* PIScrollBarGen ************/
+//++
+// Class	PIScrollBar
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type ascenseur. 
+//	"PIScrollBarGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIScrollBar" déclarée dans le fichier
+//	entête "PISTDWDG_H". Lors du changement de valeur, le message de l'objet  
+//	complété par le modifier "PIMsg_DataChanged" est envoyé ("Send()").
+//	La méthode "ActivateDrag()" permet d'activer l'envoi de message en 
+//	cours de déplacement du curseur. Dans ce cas, le modifier 
+//	"PIMsg_Drag" est appliqué.
+//	Le champ "data" contient un pointeur sur une variable de type "int"
+//	qui contient la position courante du curseur.
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIScrollBar(PIContainerGen* par, char* nom, PIMessage msg, int dir=kSDirUpDown, int sx=10, int sy=100, int px=0, int py=0)
+//	Création d'un objet PIScrollBar. "dir" indique la direction et le sens d'affichage et peut
+//	prendre les valeurs "kSDirLtoR" (gauche à droite), "kSDirRtoL" (droite à gauche),
+//	"kSDirDownUp" (bas vers haut) et "kSDirUpDown" (de haut en bas).
+// void  ActivateDrag(bool acd=false)
+//	Active ("acd=true") ou désactive ("mlm=false") l'envoi de messages lors du mouvement du curseur.
+// void SetMinMax(int min, int max)
+//	Modifie les valeurs extrêmes de l'ascenseur. L'objet est créé avec des bornes par défaut de 1 à 100.
+//	La valeur "max" correspond à la position extrême taille du curseur comprise ("max=posmax+taille").
+// void GetMinMax(int& min, int& max)
+//	Renvoie les valeurs extrêmes de l'ascenseur. 
+// void SetValue(int v)
+//	Modifie la position courante de l'ascenseur.
+// int GetValue()
+//	Renvoie la position courante de l'ascenseur.
+// void  SetSlSize(int sz)
+//	Modifie la taille de l'ascenseur.
+// int  GetSlSize()
+//	Renvoie la taille de l'ascenseur.
+//--
+
+PIScrollBarGen::PIScrollBarGen(PIContainerGen *par, char *nom, PIMessage msg, 
+                       int /*dir*/, int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py) 
+{
+SetMsg(msg);
+}
+
+PIScrollBarGen::~PIScrollBarGen()
+{}
+
Index: /tags/DPC_V0/Poubelle/PI/pistdwdggen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pistdwdggen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pistdwdggen.h	(revision 1307)
@@ -0,0 +1,134 @@
+#ifndef PISTDWDGGEN_H_SEEN
+#define PISTDWDGGEN_H_SEEN
+
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+class PILabelGen : public PIWdg {
+public:
+  enum {ClassId = 1001};
+
+                     PILabelGen(PIContainerGen* par, char* nom,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PILabelGen();
+
+  virtual long       kind() {return ClassId; }
+};
+
+//  Les differents types de boutons avec un signe dessus ... 
+enum PIBtnSign {  PIBtn_Label=0, PIBtn_ArrowUp=1, PIBtn_ArrowDown=2,  
+                                 PIBtn_ArrowLeft=3, PIBtn_ArrowRight=4 };
+
+class PIButtonGen : public PIWdg
+{
+public:
+  enum {ClassId = 1010};
+
+                     PIButtonGen(PIContainerGen* par, char* nom, 
+                                 PIMessage msg = PIMsg_Click,
+                                 int sx=10, int sy=10, int px=0, int py=0,
+                                 PIBtnSign bsgn = PIBtn_Label);
+  virtual            ~PIButtonGen();
+
+  virtual long       kind() {return ClassId; }
+  virtual void       ActivatePress(bool acp=false)=0;
+
+protected:
+  PIBtnSign mSgn;
+};
+
+
+class PITextGen : public PIWdg
+{
+public:
+
+  enum {ClassId = 1020};
+
+  		     PITextGen(PIContainerGen* par, char* nom,
+         		       int sx=10, int sy=10, int px=0, int py=0);
+  virtual	     ~PITextGen();
+  virtual void       SetText(string const&) = 0;
+  virtual string     GetText() const = 0;
+
+  virtual void       SetMutiLineMode(bool mlm=false) = 0;
+  virtual void       SetTextEditable(bool te=true) = 0;
+
+  virtual long       kind() {return ClassId; }
+};
+
+
+
+class PICheckBoxGen : public PIWdg
+{
+public:
+
+  enum {ClassId = 1030};
+
+                     PICheckBoxGen(PIContainerGen* par, char* nom, 
+                                  PIMessage msg = PIMsg_Click,
+                                  int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PICheckBoxGen()=0;
+  virtual void       SetState(bool st=false)=0;
+  virtual bool       GetState()=0;
+  
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+// Definition choix de la direction et sens pour Scale et Scroll-bar
+enum {
+  kSDirLtoR     = 1,
+  kSDirRtoL     = 2,
+  kSDirDownUp   = 4,
+  kSDirUpDown   = 8
+};
+
+class PIScaleGen : public PIWdg
+{
+public:
+  enum {ClassId = 1040};
+
+                     PIScaleGen(PIContainerGen* par, char* nom, 
+                                PIMessage msg = PIMsg_DataChanged, int dir=kSDirLtoR, 
+                                int sx=100, int sy=10, int px=0, int py=0);
+  virtual            ~PIScaleGen();
+
+  virtual void       SetMinMax(int min, int max) = 0;
+  virtual void       GetMinMax(int& min, int& max) = 0;
+  virtual void       SetValue(int val) = 0;
+  virtual int        GetValue() = 0; 
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+class PIScrollBarGen : public PIWdg
+{
+public:
+  enum {ClassId = 1050};
+
+                     PIScrollBarGen(PIContainerGen* par, char* nom, 
+                                    PIMessage msg=PIMsg_DataChanged, int dir=kSDirUpDown,
+                                    int sx=10, int sy=100, int px=0, int py=0);
+  virtual            ~PIScrollBarGen();
+
+  virtual void       ActivateDrag(bool acd=false) = 0;
+  virtual void       SetMinMax(int min, int max) = 0;
+  virtual void       GetMinMax(int& min, int& max) = 0;
+  virtual void       SetValue(int val) = 0;
+  virtual int        GetValue() = 0; 
+  virtual void       SetSlSize(int sz) = 0;
+  virtual int        GetSlSize() = 0;
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pistdwdgmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pistdwdgmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pistdwdgmac.cc	(revision 1307)
@@ -0,0 +1,310 @@
+#include "pistdwdgmac.h"
+#include <LString.h>
+#include <PP_Messages.h>
+
+/************* PILabelMac ************/
+#include <LCaption.h>
+
+PILabelMac::PILabelMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PILabelGen(par, nom, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LCaption(mPaneInfo, titre, 130);
+}
+
+PILabelMac::~PILabelMac()
+{}
+
+
+/************* PIButtonMac ************/
+#include <LStdControl.h>
+
+PIButtonMac::PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py, PIBtnSign bsgn)
+: PIButtonGen(par, nom, msg, sx, sy, px, py, bsgn)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdButton(mPaneInfo, msg_Click, 130, titre);
+  ((LStdButton*)mPane)->AddListener(this);
+}
+
+PIButtonMac::~PIButtonMac()
+{}
+
+void
+PIButtonMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_Click)
+    Send(myMsg, PIMsg_Press);
+}
+
+
+/************* PITextMac ************/
+#include <LEditField.h>
+
+PITextMac::PITextMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PITextGen(par, nom, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LEditField(mPaneInfo, titre, 130, 255, true, true, NULL, LCommander::GetTopCommander());
+}
+
+PITextMac::~PITextMac()
+{}
+
+void
+PITextMac::SetText(string const& s)
+{
+  SetLabel(s);
+}
+
+string
+PITextMac::GetText() const
+{
+  Str255 desc;
+  mPane->GetDescriptor(desc);
+  p2cstr(desc);
+  return (char*) desc;
+}
+
+/* --Methode-- */
+void PITextMac::SetMutiLineMode(bool /*mlm*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PITextMac::SetTextEditable(bool te)
+{
+if (te)
+  { mPane->Enable(); }
+else
+  { mPane->Disable(); }
+return;
+}
+
+/************* PIScaleMac ************/
+static ControlActionUPP	sSBarAction = nil;
+
+
+PIScaleMac::PIScaleMac(PIContainerGen* par, char* nom, PIMessage msg,
+                       bool horiz, int sx, int sy, int px, int py)
+: PIScaleGen(par, nom, msg, horiz, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdControl(mPaneInfo, msg_Click, 1, 1, 10,
+						  scrollBarProc, 130, titre, (Int32) this);
+  ((LStdControl*)mPane)->AddListener(this);
+  
+  if (sSBarAction == nil) {	// Allocate UPP if necessary
+	sSBarAction = NewControlActionProc((ProcPtr) SBarAction);
+  }
+  ((LStdControl*)mPane)->SetActionProc(sSBarAction);
+}
+
+PIScaleMac::~PIScaleMac()
+{}
+
+void
+PIScaleMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_ThumbDragged)
+    Send(myMsg, PIMsg_DataChanged);
+}
+
+void
+PIScaleMac::SetMinMax(int min, int max)
+{
+  ((LStdControl*)mPane)->SetMinValue(min);
+  ((LStdControl*)mPane)->SetMaxValue(max);
+}
+
+void
+PIScaleMac::SetValue(int val)
+{
+  StopListening();
+  ((LStdControl*)mPane)->SetValue(val);
+  StartListening();
+}
+
+int
+PIScaleMac::GetValue()
+{
+  return ((LStdControl*)mPane)->GetValue();
+}
+
+pascal void
+PIScaleMac::SBarAction(
+	ControlHandle	inMacControl,
+	Int16			inPart)
+{
+	PIScaleMac		*theScroller =
+							(PIScaleMac *) GetControlReference(inMacControl);
+	theScroller->HandleScroll(inPart);
+}
+
+void
+PIScaleMac::HandleScroll(
+	const Int16		inPart)
+{
+    int delta;
+	switch (inPart) {				// Determine how much to scroll
+	
+		case kControlUpButtonPart:	// Scroll left one unit
+			delta = -1;
+			break;
+			
+		case kControlDownButtonPart:	// Scroll right one unit
+			delta = 1;
+			break;
+			
+		case kControlPageUpPart:		// Scroll left by Frame width
+										//   less one unit of overlap
+			delta = -10;
+			break;
+			
+		case kControlPageDownPart:		// Scroll right by Frame width
+										//   less one unit of overlap
+			delta = 10;
+			break;
+	}
+	
+	if (delta != 0) {
+	    SetValue(GetValue()+delta);
+	}
+}
+
+/************* PIScrollBarMac ************/
+static ControlActionUPP	sSBarAction2 = nil;
+
+
+PIScrollBarMac::PIScrollBarMac(PIContainerGen* par, char* nom, PIMessage msg,
+                       bool vert, int sx, int sy, int px, int py)
+: PIScrollBarGen(par, nom, msg, vert, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdControl(mPaneInfo, msg_Click, 1, 1, 10,
+						  scrollBarProc, 130, titre, (Int32) this);
+  ((LStdControl*)mPane)->AddListener(this);
+  
+  if (sSBarAction2 == nil) {	// Allocate UPP if necessary
+	sSBarAction2 = NewControlActionProc((ProcPtr) SBarAction);
+  }
+  ((LStdControl*)mPane)->SetActionProc(sSBarAction2);
+}
+
+PIScrollBarMac::~PIScrollBarMac()
+{}
+
+void
+PIScrollBarMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_ThumbDragged)
+    Send(myMsg, PIMsg_DataChanged);
+}
+
+void
+PIScrollBarMac::SetMinMax(int min, int max)
+{
+  ((LStdControl*)mPane)->SetMinValue(min);
+  ((LStdControl*)mPane)->SetMaxValue(max);
+}
+
+void
+PIScrollBarMac::SetValue(int val)
+{
+  StopListening();
+  ((LStdControl*)mPane)->SetValue(val);
+  StartListening();
+}
+
+int
+PIScrollBarMac::GetValue()
+{
+  return ((LStdControl*)mPane)->GetValue();
+}
+
+pascal void
+PIScrollBarMac::SBarAction(
+	ControlHandle	inMacControl,
+	Int16			inPart)
+{
+	PIScrollBarMac		*theScroller =
+							(PIScrollBarMac *) GetControlReference(inMacControl);
+	theScroller->HandleScroll(inPart);
+}
+
+void
+PIScrollBarMac::HandleScroll(
+	const Int16		inPart)
+{
+    int delta;
+	switch (inPart) {				// Determine how much to scroll
+	
+		case kControlUpButtonPart:	// Scroll left one unit
+			delta = -1;
+			break;
+			
+		case kControlDownButtonPart:	// Scroll right one unit
+			delta = 1;
+			break;
+			
+		case kControlPageUpPart:		// Scroll left by Frame width
+										//   less one unit of overlap
+			delta = -10;
+			break;
+			
+		case kControlPageDownPart:		// Scroll right by Frame width
+										//   less one unit of overlap
+			delta = 10;
+			break;
+	}
+	
+	if (delta != 0) {
+	    SetValue(GetValue()+delta);
+	}
+}
+
+/************* PICheckBoxMac ************/
+#include <LStdControl.h>
+
+PICheckBoxMac::PICheckBoxMac(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PICheckBoxGen(par, nom, msg, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdCheckBox(mPaneInfo, msg_Click, 0, 130, titre);
+  ((LStdCheckBox*)mPane)->AddListener(this);
+}
+
+PICheckBoxMac::~PICheckBoxMac()
+{}
+
+void
+PICheckBoxMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_Click)
+    Send(myMsg, PIMsg_DataChanged);
+}
+
+void
+PICheckBoxMac::SetState(bool st)
+{
+  StopListening();
+  ((LStdCheckBox*)mPane)->SetValue(st ? 1 : 0);
+  StartListening();
+}
+ 
+bool
+PICheckBoxMac::GetState()
+{
+  return ((LStdCheckBox*)mPane)->GetValue();
+}
Index: /tags/DPC_V0/Poubelle/PI/pistdwdgmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pistdwdgmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pistdwdgmac.h	(revision 1307)
@@ -0,0 +1,103 @@
+#ifndef PISTDWDGMAC_H_SEEN
+#define PISTDWDGMAC_H_SEEN
+
+#include "pistdwdggen.h"
+
+
+class PILabelMac : public PILabelGen
+{
+public:
+                     PILabelMac(PIContainerGen *par, char *nom,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PILabelMac();
+};
+
+class PIButtonMac : public PIButtonGen
+{
+public:
+                     PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg = PIMsg_Click,
+                                 int sx=10, int sy=10, int px=0, int py=0,
+                                 PIBtnSign bsgn = PIBtn_Label);
+  virtual           ~PIButtonMac();
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void       ActivatePress(bool=false) {}
+};
+
+class PITextMac : public PITextGen
+{
+public:
+                     PITextMac(PIContainerGen *par, char *nom,
+                               int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PITextMac();
+
+  virtual void       SetMutiLineMode(bool mlm=false);
+  virtual void       SetTextEditable(bool te=true);
+
+  virtual void       SetText(string const&);
+  virtual string     GetText() const;
+};
+
+class PIScaleMac : public PIScaleGen
+{
+public:
+                     PIScaleMac(PIContainerGen* par, char* nom, 
+                                PIMessage msg=PIMsg_DataChanged, bool horiz=true,
+                                int sx=100, int sy=10, int px=0, int py=0);
+                    ~PIScaleMac();
+
+  virtual void       SetMinMax(int min, int max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void	     HandleScroll(const Int16 inPart);
+  
+protected:
+  static pascal void SBarAction(ControlHandle inMacControl,
+								Int16 inPart);
+};
+
+class PIScrollBarMac : public PIScrollBarGen
+{
+public:
+                     PIScrollBarMac(PIContainerGen* par, char* nom, 
+                                PIMessage msg=PIMsg_DataChanged, bool vert=true,
+                                int sx=100, int sy=10, int px=0, int py=0);
+                    ~PIScrollBarMac();
+
+  virtual void       ActivateDrag(bool /*acd*/=false) {};
+  virtual void       SetMinMax(int min, int max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void	     HandleScroll(const Int16 inPart);
+  virtual void       SetSlSize(int sz) {msz = sz;}
+  virtual int        GetSlSize() {return msz;}
+protected:
+  static pascal void SBarAction(ControlHandle inMacControl,
+								Int16 inPart);
+  int msz;
+};
+
+
+class PICheckBoxMac : public PICheckBoxGen
+{
+public:
+                     PICheckBoxMac(PIContainerGen* par, char* nom, 
+                                   PIMessage msg = PIMsg_Click,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PICheckBoxMac();
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void       SetState(bool st=false);
+  virtual bool       GetState();
+};
+
+
+ 
+typedef PILabelMac   PILabel;
+typedef PIButtonMac  PIButton;
+typedef PITextMac    PIText;
+typedef PIScaleMac   PIScale;
+typedef PIScrollBarMac PIScrollBar;
+typedef PICheckBoxMac PICheckBox;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pistdwdgx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pistdwdgx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pistdwdgx.cc	(revision 1307)
@@ -0,0 +1,628 @@
+#include<stdlib.h>
+#include<string.h>
+
+#include "pisysdep.h"
+#include PISTDWDG_H
+
+// ------- Pb de gestion du focus-keyboard  Motif-PIBaseWdg -------
+// ** Note du 26/02/98 - Reza 
+// Je desactive pour le moment XmNnavigationType et XmNtraversalOn
+// afin d'ameliorer la gestion du focus-keyboard entre Widget Motif
+// et objet Peida - Cela semble avoir un effet secondaire - 
+// Il faut que la souris reste dans le widget Text pour taper dedans
+// ** Note du 30/04/98 - Reza
+// J'ai modifie le mecanisme de gestion des evenements pour PIBaseWdg
+// en passant par un EventHandler - Le probleme de gestion du 
+// focus-keyboard n'a pour autant pas ete resolu
+// Je reactive XmNtraversalOn pour les PIText - Le probleme 
+// d'attribution du focus-keyboard au PIBaseWdg reste si on 
+// met PIText et un PIBaseWdg ds un meme conteneur
+
+
+/************* PILabelX ************/
+#include <Xm/Label.h>
+
+
+/* --Methode-- */
+PILabelX::PILabelX(PIContainerGen *par, char *nom,
+                   int sx, int sy, int px, int py)
+: PILabelGen(par, nom, sx, sy, px, py)
+{
+Arg warg[3];
+int n = 0;
+CreateXtWdg(nom, xmLabelWidgetClass, NULL, sx, sy, px, py);
+SetBorderWidth(0);
+XtSetArg(warg[n], XmNrecomputeSize, FALSE); n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+XtSetValues(XtWdg(), warg, n);
+Manage();
+}
+
+/* --Methode-- */
+PILabelX::~PILabelX()
+{}
+
+
+/************* PIButtonX ************/
+#include <Xm/PushB.h>
+#include <Xm/ArrowB.h>
+
+// Fonctions privees (CallBack)
+static void button_action(Widget w, XtPointer *usd, XtPointer *calld);
+static void button_press(Widget w, XtPointer *usd, XmAnyCallbackStruct *calld);
+
+/* Nouvelle-Fonction */
+void  button_action(Widget , XtPointer *usd, XtPointer *)
+{
+PIButtonX *pib;
+pib = (PIButtonX *) usd ;
+pib->Send(pib->Msg(),PIMsg_Click,NULL);
+return;
+}
+
+/* Nouvelle-Fonction */
+void  button_press(Widget, XtPointer *usd, XmAnyCallbackStruct *calld)
+{
+PIButtonX *pib;
+pib = (PIButtonX *) usd ;
+pib->Send(pib->Msg(),PIMsg_Press,NULL);
+pib->myevt = *(calld->event);
+pib->myevt.type = pib->myevt.xbutton.type = ButtonRelease;
+pib->myevt.xbutton.serial += 10;
+PIXSetLastEventTimeSerial(calld->event->xbutton.time,  calld->event->xbutton.serial);
+
+return;
+}
+
+
+/* --Methode-- */
+PIButtonX::PIButtonX(PIContainerGen *par, char *nom, PIMessage msg, 
+                     int sx, int sy, int px, int py, PIBtnSign bsgn)
+: PIButtonGen(par, nom, msg, sx, sy, px, py, bsgn)
+{
+
+Arg  warg[6];
+int n = 0;
+
+XtSetArg(warg[n],XmNhighlightThickness, 0);  n++;
+XtSetArg(warg[n], XmNrecomputeSize, FALSE);  n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+
+if (bsgn == PIBtn_Label)
+  CreateXtWdg(nom, xmPushButtonWidgetClass, NULL, sx, sy, px, py);
+else
+  {
+  CreateXtWdg(nom, xmArrowButtonWidgetClass, NULL, sx, sy, px, py);
+  switch (bsgn)
+    {
+    case PIBtn_ArrowUp :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_UP);  n++;
+      break;
+    case PIBtn_ArrowDown :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_DOWN);  n++;
+      break;
+    case PIBtn_ArrowLeft :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_LEFT);  n++;
+      break;
+    case PIBtn_ArrowRight :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_RIGHT);  n++;
+      break;
+    }
+  }
+
+XtSetValues(XtWdg(), warg, n);
+XtAddCallback(XtWdg(), XmNactivateCallback, 
+              (XtCallbackProc)button_action, (XtPointer)this);
+
+mAcP = false;
+SetBorderWidth(0);
+Manage();
+}
+
+/* --Methode-- */
+PIButtonX::~PIButtonX()
+{}
+
+/* --Methode-- */
+void PIButtonX::ActivatePress(bool acp)
+{
+if (mAcP == acp)  return; 
+    
+if (mAcP)
+  XtRemoveCallback(XtWdg(), XmNarmCallback, 
+                   (XtCallbackProc)button_press, (XtPointer)this);
+else 
+  XtAddCallback(XtWdg(), XmNarmCallback, 
+                (XtCallbackProc)button_press, (XtPointer)this);
+mAcP = acp;
+return;
+}       
+
+/* --Methode-- */
+void PIButtonX::ReleaseButton()
+{
+XPutBackEvent(myevt.xbutton.display, &myevt);
+return;
+}
+
+
+/************* PITextX ************/
+#include <Xm/Text.h>
+
+/* --Methode-- */
+PITextX::PITextX(PIContainerGen *par, char *nom,
+                 int sx, int sy, int px, int py)
+: PITextGen(par, nom, sx, sy, px, py)
+{
+Arg warg[3];
+int n = 0;
+CreateXtWdg(nom, xmTextWidgetClass, NULL, sx, sy, px, py);
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+// XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+XtSetValues(XtWdg(), warg, n);
+SetMutiLineMode(false);
+SetTextEditable(true);
+Manage();
+}
+
+/* --Methode-- */
+PITextX::~PITextX()
+{}
+
+/* --Methode-- */
+void PITextX::SetText(string const& s)
+{
+XmTextSetString(XtWdg(), (char *)s.c_str());
+return;
+}
+
+/* --Methode-- */
+string PITextX::GetText() const
+{
+char *txtb;
+txtb = XmTextGetString(XtWdg());
+string s(txtb);
+XtFree(txtb);
+return(s);
+}
+
+/* --Methode-- */
+void PITextX::SetMutiLineMode(bool mlm)
+{
+Arg  warg[2];
+int n = 0;
+
+if (mlm)
+  { XtSetArg(warg[n],XmNeditMode, XmMULTI_LINE_EDIT);  n++; }
+else
+  { XtSetArg(warg[n],XmNeditMode, XmSINGLE_LINE_EDIT);  n++; }
+
+XtSetValues(XtWdg(), warg, n);
+return;
+}
+
+/* --Methode-- */
+void PITextX::SetTextEditable(bool te)
+{
+Arg  warg[2];
+int n = 0;
+
+if (te)
+  { XtSetArg(warg[n],XmNeditable, TRUE);  n++; }
+else
+  { XtSetArg(warg[n],XmNeditable, FALSE);  n++; }
+
+XtSetValues(XtWdg(), warg, n);
+return;
+}
+
+// Fonction privee (CallBack)
+static void text_action(Widget w, XtPointer *usd, XtPointer *calld);
+
+void  text_action(Widget, XtPointer *usd, XtPointer *)
+{
+PIText *pit;
+
+pit = (PIText *) usd ;
+pit->Send(pit->Msg(), PIMsg_DataChanged, NULL);
+}
+
+
+/* --Methode-- */
+void PITextX::SetMsg(PIMessage msg)
+{
+
+if (Msg() && !msg)
+  XtRemoveCallback(XtWdg(), XmNactivateCallback, 
+                   (XtCallbackProc)text_action, (XtPointer)this);
+if (!Msg() && msg)
+  XtAddCallback(XtWdg(), XmNactivateCallback, 
+                (XtCallbackProc)text_action, (XtPointer)this);
+
+PIWdg::SetMsg(msg);
+}
+
+
+/************* PICheckBoxX ************/
+#include <Xm/ToggleB.h>
+
+// Fonction prive (CallBack)
+static void toggb_action(Widget w, XtPointer *usd, XmToggleButtonCallbackStruct* calld);
+
+//  Variable globale d'etat de checkbox pour Send(...)
+static bool toggb_state = false;
+
+/* Nouvelle-Fonction */
+void  toggb_action(Widget , XtPointer *usd, XmToggleButtonCallbackStruct* calld)
+{
+PICheckBoxX *picb;
+picb = (PICheckBoxX *) usd ;
+if (calld->set == True)   picb->mSt = true;
+else picb->mSt = false;
+toggb_state = picb->mSt;
+picb->Send(picb->Msg(), PIMsg_DataChanged, (void *)(&toggb_state));
+return;
+}
+
+/* --Methode-- */
+PICheckBoxX::PICheckBoxX(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PICheckBoxGen(par, nom, msg, sx, sy, px, py)
+{
+CreateXtWdg(nom, xmToggleButtonWidgetClass, NULL, sx, sy, px, py);
+XtAddCallback(XtWdg(), XmNvalueChangedCallback,
+             (XtCallbackProc) toggb_action, (XtPointer)this);
+Arg warg[4];
+int n = 0;
+XtSetArg(warg[n],XmNhighlightThickness, 0); n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+XtSetValues(XtWdg(), warg, n);
+SetState(false);
+Manage();
+}
+
+
+/* --Methode-- */
+PICheckBoxX::~PICheckBoxX()
+{}
+
+
+/* --Methode-- */
+void PICheckBoxX::SetState(bool st)
+{
+Arg warg[2];
+mSt = st;
+if (st) XtSetArg(warg[0],XmNset, True);
+else XtSetArg(warg[0],XmNset, False);
+XtSetValues(XtWdg(), warg, 1);
+return;
+}
+
+/* --Methode-- */
+bool PICheckBoxX::GetState()
+{
+return(mSt);
+}
+
+
+/************* PIScaleX ************/
+#include <Xm/Scale.h>
+
+// Fonction prive (CallBack)
+static void scale_action(Widget w, XtPointer *usd, 
+                         XmScaleCallbackStruct *calld);
+// Variable globale pour contenir valeur de Scale a l'appel de Send;
+static int scale_value=0;
+ 
+void  scale_action(Widget, XtPointer *usd, 
+                         XmScaleCallbackStruct *calld)
+{
+PIScale *pis;
+
+pis = (PIScale *) usd ;
+pis->CBSetVal(calld->value);
+scale_value = calld->value;
+pis->Send(pis->Msg(), PIMsg_DataChanged, (void *)(&scale_value));
+return;
+}
+
+/* --Methode-- */
+PIScaleX::PIScaleX(PIContainerGen *par, char *nom, PIMessage msg,
+                   int dir, int sx, int sy, int px, int py)
+: PIScaleGen(par, nom, msg, dir, sx, sy, px, py)
+{
+int n=0;
+Arg warg[8];
+XtSetArg(warg[n], XmNshowValue, TRUE); n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+if (dir == kSDirLtoR) {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
+  }
+else if (dir == kSDirRtoL) {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_LEFT); n++;
+  }
+else if (dir == kSDirDownUp) {
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_TOP); n++;
+  }
+else { // kSDirUpDown
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_BOTTOM); n++;
+  }
+// Il ne faut pas attribuer une valeur a XmNscaleWidth et XmNscaleHeight
+// Elles sont calculees automatiquement et repondent alors correctement aux resize
+// (Il faut laisser donc leur valeur par defaut=0)   Reza 28/10/98 
+// XtSetArg(warg[n], XmNscaleWidth, sx); n++;
+// XtSetArg(warg[n], XmNscaleHeight, sy); n++;
+// XtSetArg(warg[n], XmNstringDirection, XmSTRING_DIRECTION_R_TO_L); n++;
+CreateXtWdg(nom, xmScaleWidgetClass, NULL, sx, sy, px, py, warg, n);
+
+SetMinMax(1, 100);
+SetValue(1);
+
+XtAddCallback(XtWdg(), XmNvalueChangedCallback, 
+             (XtCallbackProc) scale_action, (XtPointer)this);
+Manage();
+}
+
+/* --Methode-- */
+PIScaleX::~PIScaleX()
+{}
+
+/* --Methode-- */
+void PIScaleX::SetMinMax(int min, int max)
+{
+if (min >= max)  max = min+10;
+if (mVal < min)  mVal = min;
+if (mVal > max)  mVal = max;
+int n=0;
+Arg warg[3];
+XtSetArg(warg[n], XmNminimum, min); n++;
+XtSetArg(warg[n], XmNmaximum, max); n++;
+XtSetArg(warg[n], XmNvalue, mVal); n++;
+XtSetValues(XtWdg(), warg, n);
+mMin = min;   mMax = max;
+return;
+}
+
+/* --Methode-- */
+void PIScaleX::GetMinMax(int& min, int& max)
+{
+min = mMin;   max = mMax;
+return;
+}
+
+/* --Methode-- */
+void PIScaleX::SetValue(int val)
+{
+int n=0;
+if (val < mMin)  val = mMin;
+if (val > mMax)  val = mMax;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, val); n++;
+XtSetValues(this->sdw, warg, n);
+return;
+}
+
+/* --Methode-- */
+int  PIScaleX::GetValue()
+{
+int val;
+int n=0;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, &val); n++;
+XtGetValues(this->sdw, warg, n);
+mVal = val;
+return(mVal);
+}
+
+/* --Methode-- */
+void  PIScaleX::CBSetVal(int val)
+{
+mVal = val;
+return;
+}
+
+
+
+/************* PIScrollBarX ************/
+
+#include <Xm/ScrollBar.h>
+
+// Fonction prive (CallBack)
+static void scrollbar_action(Widget w, XtPointer *usd, 
+                             XmScrollBarCallbackStruct *calld);
+static void scrollbar_drag(Widget w, XtPointer *usd, 
+                           XmScrollBarCallbackStruct *calld);
+// Variable globale pour contenir valeur de Scale a l'appel de Send;
+static int scroll_value=0;
+
+void  scrollbar_action(Widget, XtPointer *usd, 
+                       XmScrollBarCallbackStruct *calld)
+{
+PIScrollBar *pis;
+
+pis = (PIScrollBar *) usd ;
+pis->CBSetVal(calld->value);
+pis->Send(pis->Msg(), PIMsg_DataChanged, (void *)(&scroll_value));
+return;
+}
+
+void  scrollbar_drag(Widget, XtPointer *usd, 
+                       XmScrollBarCallbackStruct *calld)
+{
+PIScrollBar *pis;
+
+pis = (PIScrollBar *) usd ;
+pis->CBSetVal(calld->value);
+pis->Send(pis->Msg(), PIMsg_Drag, (void *)(&scroll_value));
+return;
+}
+
+/* --Methode-- */
+PIScrollBarX::PIScrollBarX(PIContainerGen *par, char *nom, PIMessage msg,
+                           int dir, int sx, int sy, int px, int py)
+: PIScrollBarGen(par, nom, msg, dir, sx, sy, px, py)
+{
+int n=0;
+Arg warg[6];
+
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+if (dir == kSDirLtoR) {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
+  }
+else if (dir == kSDirRtoL) {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_LEFT); n++;
+  }
+else if (dir == kSDirDownUp) {
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_TOP); n++;
+  }
+else { // kSDirUpDown
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_BOTTOM); n++;
+  }
+CreateXtWdg(nom, xmScrollBarWidgetClass, NULL, sx, sy, px, py, warg, n);
+mAcD = false;
+mVal = -1;
+mMin = mMax = 0;
+mSz = 10;
+mDir = dir;
+SetMinMax(1, 100);
+SetSlSize(10);
+SetValue(1);
+XtAddCallback(XtWdg(), XmNvalueChangedCallback, 
+             (XtCallbackProc) scrollbar_action, (XtPointer)this);
+Manage();
+}
+
+/* --Methode-- */
+PIScrollBarX::~PIScrollBarX()
+{}
+
+
+/* --Methode-- */
+void PIScrollBarX::ActivateDrag(bool acd)
+{
+if (mAcD == acd)  return; 
+    
+if (mAcD)
+  XtRemoveCallback(XtWdg(), XmNdragCallback, 
+                   (XtCallbackProc)scrollbar_drag, (XtPointer)this);
+else 
+  XtAddCallback(XtWdg(), XmNdragCallback, 
+                (XtCallbackProc)scrollbar_drag, (XtPointer)this);
+mAcD = acd;
+return;
+}       
+
+/* --Methode-- */
+void PIScrollBarX::SetMinMax(int min, int max)
+{
+if (min >= max)  max = min+100;
+if (mVal < min)  mVal = min;
+if (mVal > max-mSz)  mVal = max-mSz;
+//DBG printf("PIScrollBarX::SetMinMax(%d %d )  %d  Sz=%d \n", min, max, mVal, mSz);
+int n=0;
+Arg warg[3];
+XtSetArg(warg[n], XmNminimum, min); n++;
+XtSetArg(warg[n], XmNmaximum, max); n++;
+XtSetArg(warg[n], XmNvalue, mVal); n++;
+XtSetValues(XtWdg(), warg, n);
+mMin = min;   mMax = max;
+//DBG printf("--OUT-OF-- PIScrollBarX::SetMinMax(%d %d )  %d  Sz=%d \n", min, max, mVal, mSz);
+return;
+}
+
+/* --Methode-- */
+void PIScrollBarX::GetMinMax(int& min, int& max)
+{
+min = mMin;   max = mMax;
+return;
+}
+
+/* --Methode-- */
+void PIScrollBarX::SetValue(int val)
+{
+int n=0;
+if (val < mMin)  val = mMin;
+if (val > mMax-mSz)  val = mMax-mSz;
+Arg warg[2];
+//DBG printf("PIScrollBarX::SetValue(%d -> %d) \n", val, val0);
+XtSetArg(warg[n], XmNvalue, val); n++;
+XtSetValues(this->sdw, warg, n);
+mVal = val;
+//DBG printf("--OUT-OF---PIScrollBarX::SetValue(%d -> %d) \n", val, val0);
+return;
+}
+
+/* --Methode-- */
+int  PIScrollBarX::GetValue()
+{
+int val;
+int n=0;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, &val); n++;
+XtGetValues(this->sdw, warg, n);
+mVal = val;
+return(mVal);
+}
+
+/* --Methode-- */
+void PIScrollBarX::SetSlSize(int sz)
+{
+int n=0;
+Arg warg[4];
+int szl;
+
+szl = mMax-mMin;
+if (sz > szl)  sz = szl;
+szl /= 100;
+if (szl < 1)  szl = 1;
+if (sz < szl)  sz = szl;
+szl = sz/10;
+if (szl < 1)  szl = 1;
+//DBG printf("PIScrollBarX::SetSlSize(%d ) \n", sz);
+XtSetArg(warg[n], XmNsliderSize, sz); n++;
+XtSetArg(warg[n], XmNpageIncrement, sz); n++;
+XtSetArg(warg[n], XmNincrement, szl); n++;
+if (mVal < mMin)  mVal = mMin;
+if (mVal > mMax-sz)  mVal = mMax-sz;
+XtSetArg(warg[n], XmNvalue, mVal); n++;
+XtSetValues(this->sdw, warg, n);
+//DBG printf("---OUT-OF---PIScrollBarX::SetSlSize(%d ) -> mVal= %d (cv1,2=%d %d)\n", sz,mVal, cv1, cv2);
+mSz = sz;
+return;
+}
+
+/* --Methode-- */
+int  PIScrollBarX::GetSlSize()
+{
+int sz;
+int n=0;
+Arg warg[2];
+XtSetArg(warg[n], XmNsliderSize, &sz); n++;
+XtGetValues(this->sdw, warg, n);
+mSz = sz;
+return(mSz);
+}
+
+
+/* --Methode-- */
+void  PIScrollBarX::CBSetVal(int val)
+{
+mVal = val;
+scroll_value = mVal;
+//DBG printf("PIScrollBarX::CBSetVal(%d) %d -> %d \n", mDir, val, mVal);
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pistdwdgx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pistdwdgx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pistdwdgx.h	(revision 1307)
@@ -0,0 +1,120 @@
+#ifndef PISTDWDGX_H_SEEN
+#define PISTDWDGX_H_SEEN
+
+#include "pistdwdggen.h"
+
+
+class PILabelX : public PILabelGen
+{
+public:
+                     PILabelX(PIContainerGen *par, char *nom,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PILabelX();
+  
+};
+
+class PIButtonX : public PIButtonGen
+{
+public:
+                     PIButtonX(PIContainerGen *par, char *nom, 
+                               PIMessage msg = PIMsg_Click,
+                               int sx=10, int sy=10, int px=0, int py=0,
+                               PIBtnSign bsgn = PIBtn_Label);
+  virtual            ~PIButtonX();
+
+  virtual void       ActivatePress(bool acp=false);
+
+  void               ReleaseButton();   // Fonction a utiliser avec attention
+
+  XEvent myevt;   // Attention - Pour usage interne 
+
+protected :
+  bool mAcP;
+};
+
+
+class PITextX : public PITextGen
+{
+public:
+                     PITextX(PIContainerGen *par, char *nom, 
+                                  int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PITextX();
+  virtual void       SetText(string const&);
+  virtual string     GetText() const;
+
+  virtual void       SetMutiLineMode(bool mlm=false);
+  virtual void       SetTextEditable(bool te=true);
+
+  virtual void       SetMsg(PIMessage msg=0);
+};
+
+
+class PICheckBoxX : public PICheckBoxGen
+{
+public:
+                     PICheckBoxX(PIContainerGen *par, char *nom, 
+                                 PIMessage msg=PIMsg_Click,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PICheckBoxX();
+
+  virtual void       SetState(bool st=false);
+  virtual bool       GetState();
+
+  bool mSt;          // Etat du bouton, en public a cause du Callback
+};
+
+
+
+class PIScaleX : public PIScaleGen
+{
+public:
+                     PIScaleX(PIContainerGen* par, char* nom, 
+                              PIMessage msg=PIMsg_DataChanged, int dir=kSDirLtoR, 
+                              int sx=100, int sy=10, int px=0, int py=0);
+  virtual            ~PIScaleX();
+
+  virtual void       SetMinMax(int min, int max);
+  virtual void       GetMinMax(int& min, int& max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+
+  virtual void       CBSetVal(int val);   // A ne pas utiliser (pour Callback Xt)
+protected: 
+  int mVal, mMin, mMax;
+};
+
+
+
+class PIScrollBarX : public PIScrollBarGen
+{
+public:
+                     PIScrollBarX(PIContainerGen* par, char* nom, 
+                                  PIMessage msg = PIMsg_DataChanged, int dir=kSDirUpDown,
+                                  int sx=10, int sy=100, int px=0, int py=0);
+                     ~PIScrollBarX();
+
+  virtual void       ActivateDrag(bool acd=false);
+  virtual void       SetMinMax(int min, int max);
+  virtual void       GetMinMax(int& min, int& max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+  virtual void       SetSlSize(int sz);
+  virtual int        GetSlSize();
+
+  virtual void       CBSetVal(int val);   // A ne pas utiliser (pour Callback Xt)
+
+protected: 
+  int mVal, mMin, mMax, mSz, mDir;
+  bool mAcD;
+};
+
+
+typedef PILabelX       PILabel;
+typedef PIButtonX      PIButton;
+typedef PITextX        PIText;
+typedef PICheckBoxX    PICheckBox;
+typedef PIScaleX       PIScale;
+typedef PIScrollBarX   PIScrollBar;
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pistzwin.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pistzwin.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pistzwin.cc	(revision 1307)
@@ -0,0 +1,373 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive  - Zone/Stack Layout
+// PIStackLayout , PIZone Layout , PIStackWindow , PIZoneWindow
+//                             R. Ansari  08/98
+
+#include <stdio.h>
+
+#include "pistzwin.h"
+#include "psfile.h"
+
+// -------------- Classe PIStackLayout --------------
+
+//++
+// Class	PIStackLayout
+// Lib		PI
+// include	pistzwin.h
+//
+//	Classe de gestionnaire de "PIWdg" dans un conteneur avec un seul 
+//	"PIWdg" visible à un moment donné. Permet d'empiler plusieurs
+//	objet dans une fenêtre, et passer de l'un à l'autre.
+//--
+//++
+// Links	Parent
+// PILayoutMgr
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIStackLayout()
+// 	Constructeur
+// PIWdg*  CurrentWdg() 
+//	Retourne l'objet "PIWdg" visible au moment de l'appel.
+// int NumCurrentWdg()
+//	Retourne le numéro de l'objet "PIWdg" visible au moment de l'appel.
+// void  DispNext()
+//	Affiche l'objet "PIWdg" suivant.
+// void  DispWdgNum(int n)
+//	Affiche l'objet "PIWdg" numéro "n".
+//--
+
+/* --Methode-- */
+PIStackLayout::PIStackLayout()
+	: PILayoutMgr()
+{
+mCurdisp = -1;
+}
+
+/* --Methode-- */
+PIStackLayout::~PIStackLayout()
+{
+}
+
+/* --Methode-- */
+void PIStackLayout::ChildAdd(PIWdg* child)
+{
+int k;
+for(k=0; k<NbChilds(); k++) GetChild(k)->UnManage();
+PILayoutMgr::ChildAdd(child);
+child->Manage();
+mCurdisp = NbChilds()-1;
+return;
+}
+
+/* --Methode-- */
+void PIStackLayout::ChildDel(PIWdg* child)
+{
+int k;
+for(k=0; k<NbChilds(); k++) GetChild(k)->UnManage();
+PILayoutMgr::ChildDel(child);
+if (NbChilds() > 0) {
+  mCurdisp--;
+  if (mCurdisp < 0)  mCurdisp = 0;
+  if (mCurdisp > NbChilds()) mCurdisp = NbChilds()-1; 
+  GetChild(mCurdisp)->Manage();
+  }
+else mCurdisp = -1;
+return;
+}
+
+/* --Methode-- */
+void PIStackLayout::DispNext()
+{
+if (NbChilds() < 1) return;
+int n = (mCurdisp+1)%NbChilds();
+DispWdgNum(n);
+}
+
+/* --Methode-- */
+void PIStackLayout::DispWdgNum(int n)
+{
+if ( (n < 0) || (n >= NbChilds()) )  return;
+for(int k=0; k<NbChilds(); k++) GetChild(k)->UnManage();
+mCurdisp = n;
+GetChild(mCurdisp)->Manage();
+return;
+}
+
+
+// -------------- Classe PIStackWindow --------------
+
+// Fonction de l'objet PIPeriodic de PIStackWindow
+static void myadperpact(void* a);
+
+void myadperpact(void* a)
+{
+((PIStackWindow*)a)->DispNext();
+}
+
+//++
+// Class	PIStackWindow
+// Lib		PI
+// include	pistzwin.h
+//
+//	Classe de fenêtre ("PIWindow") avec le "PIStackLayout".
+//	Le "PILayoutMgr" ne peut être changé.
+//--
+//++
+// Links	Parent
+// PIWindow
+//--
+//++
+// Links	Voir aussi
+// PIStackLayout
+//--
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIStackWindow(PIMsgHandler* par, char* nom, PIWindowKind k=PIWK_normal, int sx=100, int sy=100, int px=0, int py=0)
+// 	Constructeur - identique à celui de "PIWindow"
+// void  DispNext()
+//	Affichage du "PIWdg" suivant.
+// PIWdg* CurrentWdg()
+//	Retourne l'objet "PIWdg" courant.
+// void  StartAutoDisp(int dtms=1000)
+//	Démarre  l'affichage cyclique automatique avec l'intervalle en temps 
+//	"dtms" spécifié en millisecondes.
+// void  StopAutoDisp()
+//	Arrête l'affichage cyclique automatique.
+// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
+//	Rajoute tous les "PIWdg" associés à la fenêtre à l'objet
+//	"PSFile" (fichier PostScript), un objet par page.
+//--
+
+/* --Methode-- */
+PIStackWindow::PIStackWindow(PIMsgHandler* par, char* nom, PIWindowKind k,
+                             int sx, int sy, int px, int py)
+        : PIWindow(par, nom, k, sx, sy, px, py) , mPerad(1)
+{
+mPerad.SetAction(myadperpact, this);
+delete layout;
+layout = new PIStackLayout;
+layout->SetContainer(this); 
+} 
+
+
+/* --Methode-- */
+PIStackWindow::~PIStackWindow()
+{
+mPerad.Stop();
+Hide();
+}
+
+/* --Methode-- */
+void PIStackWindow::SetLayoutMgr(PILayoutMgr*)
+{
+fprintf(stderr, "PIStackWindow::SetLayoutMgr() - LayoutMgr cannot be changed \n");
+return;
+}
+
+/* --Methode-- */
+void PIStackWindow::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+if (!psf) return;
+int k;
+for(k=0; k<NbChilds(); k++) { 
+  psf->NewPage((double)XSize(), (double)YSize(),PI_Auto);
+  GetChild(k)->PSPrint(psf, ofx, ofy);
+  }
+}
+
+
+/* --Methode-- */
+void PIStackWindow::StartAutoDisp(int dtms)
+{
+mPerad.SetIntervalms(dtms);
+mPerad.Start();
+}
+
+/* --Methode-- */
+void PIStackWindow::StopAutoDisp()
+{
+mPerad.Stop();
+}
+
+//-------------------- Classe PIZoneLayout ------------------------------
+//++
+// Class	PIZoneLayout
+// Lib		PI
+// include	pistzwin.h
+//
+//	Classe de gestionnaire de "PIWdg" dans un conteneur, 
+//	divisé en cellule horizotale-verticale.
+//	En cas d'ajout d'un objet dans une cellule déjà occupée,
+//	l'objet est supprimé si "SetAutoDelChilds(true)", 
+//	sinon "UnManage()" est appelé pour cet objet.
+//--
+//++
+// Links	Parent
+// PILayoutMgr
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIZoneLayout(int nzx, int nzy)
+// 	Constructeur. Subdivision en "nzx" cellules horizontales,
+//	"nzy" cellules verticales.
+// void SetZone(int nzx, int nzy)
+//	Modification du découpage en cellules.
+// void  NbZone(int& nzx, int& nzy)
+//	Retourne le nombre de cellules verticale-horizontale.
+// PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy)
+//	Retourne la position et la taille d'un eventuel objet "PIWdg"
+//	ajouté. Retourne le "PIWdg" actuellement dans cette cellule.
+//-- 
+
+/* --Methode-- */
+PIZoneLayout::PIZoneLayout(int nzx, int nzy)
+	: PILayoutMgr()
+{
+mZWdg = NULL;
+SetZone(nzx, nzy);
+}
+
+/* --Methode-- */
+PIZoneLayout::~PIZoneLayout()
+{
+delete[] mZWdg;
+}
+
+
+/* --Methode-- */
+void PIZoneLayout::SetZone(int nzx, int nzy)
+{
+int i;
+if (mZWdg) {
+  for(i=0; i<mZx*mZy; i++) 
+    if (mZWdg[i]) delete mZWdg[i];  
+  delete[]  mZWdg;
+  }
+
+if (nzx < 1) nzx = 1;
+if (nzy < 1) nzy = 1;
+if (nzx > 50) nzx = 50;
+if (nzx > 50) nzx = 50;
+mZx = nzx;  mZy = nzy;   mZc = 0;
+
+mZWdg = new PIWdg*[nzx*nzy];
+for(i=0; i<mZx*mZy; i++) mZWdg[i] = NULL; 
+}
+
+
+/* --Methode-- */
+void PIZoneLayout::ChildAdd(PIWdg * child)
+{
+if (!child) return;
+int nx = mZc%mZx;
+int ny = mZc/mZx;
+PILayoutMgr::ChildAdd(child);
+child->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free);
+int sx = mCont->XSize()/mZx;
+int sy = mCont->YSize()/mZy;
+child->SetPos(nx*sx, ny*sy);
+child->SetSize(sx, sy);
+child->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic, PIBK_elastic);
+child->LockBinding();
+//  Il faut faire le delete a cet endroit, sinon probleme avec widget motif XmForm  Reza 18/08/98
+if (mZWdg[mZc])  { 
+  if (mACSup) delete mZWdg[mZc]; 
+  else mZWdg[mZc]->UnManage();
+  }
+mZWdg[mZc] = child;
+mZc = (mZc+1)%(mZx*mZy);
+}
+
+/* --Methode-- */
+void PIZoneLayout::ChildDel(PIWdg * child)
+{
+if (!child)  return;
+int k;
+for(k=0; k<mZx*mZy; k++) 
+  if (mZWdg[k] == child) mZWdg[k] = NULL;  
+PILayoutMgr::ChildDel(child);
+return;
+}
+
+/* --Methode-- */
+void PIZoneLayout::NbZone(int& nzx, int& nzy)
+{
+nzx = mZx;   nzy = mZy;
+}
+
+/* --Methode-- */
+PIWdg* PIZoneLayout::NextChildPosSize(int& px, int& py, int& sx, int& sy)
+{
+sx = mCont->XSize()/mZx;
+sy = mCont->YSize()/mZy;
+int nx = mZc%mZx;
+int ny = mZc/mZx;
+px = nx*sx;  py = ny*sy;
+return ((PIWdg*)mZWdg[mZc]);
+}
+
+
+//-------------------- Classe PIZoneWindow ------------------------------
+//++
+// Class	PIZoneWindow
+// Lib		PI
+// include	pistzwin.h
+//
+//	Classe de fenêtre ("PIWindow") avec le "PIZoneLayout".
+//	Le "PILayoutMgr" ne peut être changé.
+//--
+//++
+// Links	Parent
+// PIWindow
+//--
+//++
+// Links	Voir aussi
+// PIZoneLayout
+//--
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIZoneWindow(PIMsgHandler* par, char* nom, PIWindowKind k=PIWK_normal, -
+//              int nzx=1, int nzy=1, int sx=100, int sy=100, int px=0, int py=0)
+// 	Constructeur avec spécification de nombre de cellules horizontal "nzx", vertical "nzy".
+// void  SetZone(int nzx, int nzy)
+//	Modification du découpage en cellules.
+// void NbZone(int& nzx, int& nzy)
+//	Retourne le nombre de cellules verticale-horizontale.
+// PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy)
+//	Appel à " PIZoneLayout::NextChildPosSize(...) "
+//--
+
+/* --Methode-- */
+PIZoneWindow::PIZoneWindow(PIMsgHandler* par, char* nom, PIWindowKind k,
+                           int nzx, int nzy, int sx, int sy, int px, int py)
+        : PIWindow(par, nom, k, sx, sy, px, py)
+{
+delete layout;
+layout = new PIZoneLayout(nzx, nzy);
+layout->SetContainer(this); 
+}
+
+/* --Methode-- */
+PIZoneWindow::~PIZoneWindow()
+{
+Hide();
+}
+
+/* --Methode-- */
+void PIZoneWindow::SetLayoutMgr(PILayoutMgr*)
+{
+fprintf(stderr, "PIZoneWindow::SetLayoutMgr() - LayoutMgr cannot be changed \n");
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/pistzwin.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pistzwin.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pistzwin.h	(revision 1307)
@@ -0,0 +1,95 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive  PIStackWindow  PIZoneWindow
+//                             R. Ansari  08/98
+
+#ifndef PISTZWIN_H_SEEN
+#define PISTZWIN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWIN_H
+#include PIPERIODIC_H
+
+// ----------------------- Classe PIStackLayout ----------------------------
+// Pour Fenetre de type empilement , tout widget occupe la totalite 
+// de la fenetre - Un seul des widget visible (active) a chaque moment
+
+class PIStackLayout : public PILayoutMgr {
+public:
+		PIStackLayout();
+  virtual 	~PIStackLayout();
+
+  virtual void  ChildAdd(PIWdg* child);
+  virtual void  ChildDel(PIWdg* child);
+
+  inline PIWdg*  CurrentWdg() { return(GetChild(mCurdisp)); }
+  inline int    NumCurrentWdg() { return(mCurdisp); } 
+  virtual void  DispNext();
+  virtual void  DispWdgNum(int n);
+
+protected:
+  int mCurdisp;
+};
+		
+// ----------------------- Classe PIStackWindow ----------------------------
+//                    Fenetre avec un PIStackLayout
+
+class PIStackWindow : public PIWindow {
+public:
+		PIStackWindow(PIMsgHandler* par, char* nom, PIWindowKind k=PIWK_normal,
+                              int sx=100, int sy=100, int px=0, int py=0);
+  virtual	~PIStackWindow();
+
+  virtual void  SetLayoutMgr(PILayoutMgr* nlay);
+  virtual void  PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+  inline  void  DispNext() { ((PIStackLayout*)layout)->DispNext(); }
+  inline  PIWdg* CurrentWdg() { return( ((PIStackLayout*)layout)->CurrentWdg() ); }
+
+  virtual void  StartAutoDisp(int dtms=1000);
+  virtual void  StopAutoDisp();
+
+protected:
+  PIPeriodic mPerad;
+};
+
+// ----------------------- Classe PIZoneLayout ----------------------------
+// Pour fenetre avec nzx*nzy zone d affichage - Les nouveaux widgets dans chaque
+// zone viennent remplacer les anciennes - Ceux-ci sont detruits automatiquement
+
+
+class PIZoneLayout : public PILayoutMgr {
+public:
+		PIZoneLayout(int nzx=1, int nzy=1);
+  virtual 	~PIZoneLayout();
+
+  virtual void  ChildAdd(PIWdg* child);
+  virtual void  ChildDel(PIWdg* child);
+  virtual void  SetZone(int nzx, int nzy);
+  virtual void  NbZone(int& nzx, int& nzy);
+  virtual PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy);
+
+protected:
+  int mZx, mZy, mZc;
+  PIWdg** mZWdg;
+};
+
+// ----------------------- Classe PIZoneWindow ----------------------------
+//                    Fenetre avec un PIZoneLayout 
+ 
+class PIZoneWindow : public PIWindow {
+public:
+		PIZoneWindow(PIMsgHandler* par, char* nom, PIWindowKind k=PIWK_normal,
+                             int nzx=1, int nzy=1, int sx=100, int sy=100, int px=0, int py=0);
+  virtual	~PIZoneWindow();
+
+  virtual void  SetLayoutMgr(PILayoutMgr* nlay);
+
+  inline  void  SetZone(int nzx, int nzy) { ((PIZoneLayout*)layout)->SetZone(nzx, nzy); }
+  inline  void  NbZone(int& nzx, int& nzy)  { ((PIZoneLayout*)layout)->NbZone(nzx, nzy); }
+  inline PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy)
+                { return ( ((PIZoneLayout*)layout)->NextChildPosSize(px, py, sx, sy) ); }
+
+protected:
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pisurfdr.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pisurfdr.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pisurfdr.cc	(revision 1307)
@@ -0,0 +1,251 @@
+#include <math.h>
+#include "pisurfdr.h"
+
+/* --Methode-- */
+PISurfaceDrawer::PISurfaceDrawer(P2DArrayAdapter* arr, bool asxy, bool asz, bool ad)
+{
+  mArr = arr;  mAda = ad;
+  mScx = mScy = mScz = 1.;
+  mZmin = 0.; mZmax = 1.;
+  mLut = NULL;
+  if (arr == NULL)  return;
+  arr->XYfromxy(0,0,mXmin, mYmin);
+  arr->XYfromxy(arr->XSize(),arr->YSize(),mXmax, mYmax);
+  if (asxy)  mScy = (mXmax-mXmin)/(mYmax-mYmin);
+  double scm =  ((mXmax-mXmin) > (mYmax-mYmin)) ? (mXmax-mXmin)  : (mYmax-mYmin);
+  int i,j;   double cv;
+  mZmin = mZmax = arr->Value(0,0);
+  for(i=0; i<arr->XSize(); i++) 
+    for(j=0; j<arr->YSize(); j++) {
+      cv  = arr->Value(i,j);
+      if (cv < mZmin) mZmin = cv;
+      if (cv > mZmax) mZmax = cv;
+    }
+  if ((mZmax-mZmin) <= 1.e-19)  mZmax = mZmin + 1.e-19;
+  if (asz) mScz = scm/(mZmax-mZmin);
+//  printf("PISurfaceDrawer::PISurfaceDrawer Min/Max: %g,%g  %g,%g  %g,%g  Sc: %g %g %g \n",
+//          mXmin, mXmax, mYmin, mYmax, mZmin, mZmax, mScx, mScy, mScz);
+  double zmin = mZmin; 
+  double zmax = mZmax;
+  double dzz = (mZmax-mZmin)*0.05;
+  mLut = new LUT(zmin-dzz*2, zmax-dzz, 256);
+}
+
+/* --Methode-- */
+PISurfaceDrawer::~PISurfaceDrawer()
+{
+  if (mAda) delete mArr;
+  if (mLut) delete mLut;
+}
+
+/* --Methode-- */
+void PISurfaceDrawer::UpdateLimits()
+{
+  if (mArr == NULL)  return;
+  double xmin, xmax, ymin, ymax, zmin, zmax;
+  xmin = mXmin*mScx;  xmax = mXmax*mScx;
+  ymin = mYmin*mScy;  ymax = mYmax*mScy;
+  zmin = mZmin*mScz;  zmax = mZmax*mScz;
+// Centre du champ en C = (xmin+xmax)/2., (ymin+ymax)/2  (zmin+zmax)*0.5
+// Distance D = Max(xmax-xmin,ymin-ymax)*2
+// Observateur en O = X+D, Yc+2*D 
+  double D = xmax-xmin;
+  if (D < (ymax-ymin))  D = ymax-ymin;
+  D *= 1.4;
+  
+  Set3DView((xmin+xmax)/2., (ymin+ymax)/2, zmin+(zmax-zmin)*0.40, 
+            (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25);  
+  
+  x3Min = xmin;   x3Max = xmax;
+  y3Min = ymin;   y3Max = ymax;
+  z3Min = zmin-0.05*(zmax-zmin);   z3Max = zmax+0.05*(zmax-zmin);
+
+//  printf("PISurfaceDrawer::UpdateLimits() : %g-%g  %g-%g  %g-%g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
+//  printf("PISurfaceDrawer::UpdateLimits() :  %g %g %g <<- %g %g %g \n", 
+//         (xmin+xmax)/2., (ymin+ymax)/2, zmin+(zmax-zmin)*0.40, 
+//         (xmin+xmax)/2.+D , (ymin+ymax)/2.+2.*D , zmin+(zmax-zmin)*0.60 );
+
+}
+
+
+typedef struct   /*  structures pour trier en ZP les facettes */
+  { double dp;  double zh;  int ij;  } ZPSORT;
+/* Nouvelle-Fonction */
+static int ijzpsort(const void * sp1, const void * sp2)
+/*  Fonctions de tri des etoiles en flux ds un starlist */
+{
+  ZPSORT* p1 = (ZPSORT*)sp1;   
+  ZPSORT* p2 = (ZPSORT*)sp2;  
+  if (p1->dp > p2->dp)  return(-1);
+  else if (p1->dp < p2->dp)  return(1);
+  return(0);
+}
+
+/* --Methode-- */
+void PISurfaceDrawer::DrawAxes(PIGraphicUC* g)
+{
+  if (axesFlags == kAxesNone) return;
+#if defined(__DECCXX) || defined(__KCC__)
+  PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+  PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+  Draw3DBoxe(g3, XMin3(), XMax3(), YMin3(), YMax3(), ZMin3(), ZMax3(),
+                 mXmin, mXmax, mYmin, mYmax, mZmin-0.05*(mZmax-mZmin), mZmax+0.05*(mZmax-mZmin));
+}
+
+/* --Methode-- */
+void PISurfaceDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+// On trace les axes - En attendant de faire mieux - Reza 8/12/98
+  if (axesFlags != kAxesNone)  DrawAxes(g);
+
+  if (mArr == NULL)  return;
+
+#if defined(__DECCXX) || defined(__KCC__)
+  PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+  PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+
+  g3->SelBackground(PI_White);
+//  g3->Erase(xmin, ymin, xmax-xmin, ymax-ymin);
+
+  int xsz = mArr->XSize();
+  int ysz = mArr->YSize();
+
+  ZPSORT* ijzp = new ZPSORT[xsz*ysz];
+  double* xw = new double[(xsz+1)*(ysz+1)];
+  double* yw = new double[(xsz+1)*(ysz+1)];
+  double* zw = new double[(xsz+1)*(ysz+1)];
+
+  double dx,dy;   // taille du bin 
+  dx = (mXmax-mXmin)*mScx/xsz; 
+  dy = (mYmax-mYmin)*mScy/ysz;
+ 
+  int i1,j1;
+  int i,j,k,l;
+  double x,y,z,xp,yp,zp;
+
+  k = 0;
+  for(i=0; i<xsz; i++) 
+    for(j=0; j<ysz; j++) { 
+      ijzp[k].ij = j*xsz+i; 
+      mArr->XYfromxy(i,j,x,y);
+      x *= mScx; x += dx/2.;
+      y *= mScy; y += dy/2.;
+      ijzp[k].zh = mArr->Value(i,j);
+      z = ijzp[k].zh * mScz;
+      g3->C3DC2ObsCS(x,y,z,xp,yp,zp);
+      ijzp[k].dp = zp; 
+      k++;
+
+// Calcul de la projection du coin de la facette
+      x -= dx/2.;   y -= dy/2.;
+      i1 = (i>0) ? i-1 : 0;
+      j1 = (j>0) ? j-1 : 0;
+      z = mArr->Value(i,j) + mArr->Value(i1,j) + mArr->Value(i1,j1) +  mArr->Value(i,j1);
+      z = z/4.*mScz;        
+//      g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);
+      xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;    zw[j*(xsz+1)+i] = z;    
+    }
+
+  j = ysz;
+  for(i=0; i<xsz; i++) {
+     mArr->XYfromxy(i,j-1,x,y);
+     x *= mScx; 
+     y *= mScy; y += dy;
+     i1 = (i>0) ? i-1 : 0;
+     j1 = j-1;
+     z = mArr->Value(i,j-1) + mArr->Value(i1,j-1) + mArr->Value(i1,j1) +  mArr->Value(i,j1);
+     z = z/4.*mScz;
+//     g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);     
+     xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;   zw[j*(xsz+1)+i] = z;   
+  }
+  i = xsz;
+  for(j=0; j<ysz; j++) {
+     mArr->XYfromxy(i-1,j,x,y);
+     x *= mScx; x += dx;
+     y *= mScy; 
+     i1 = i-1;
+     j1 = (j>0) ? j-1 : 0;
+     z = mArr->Value(i-1,j) + mArr->Value(i1,j) + mArr->Value(i1,j1) +  mArr->Value(i-1,j1);
+     z = z/4.*mScz;
+//     g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);     
+     xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;   zw[j*(xsz+1)+i] = z;   
+  }
+  i = xsz;  j = ysz;
+  mArr->XYfromxy(i-1,j-1,x,y);
+  i1 = i-1;   j1 = j-1;
+  x *= mScx; x += dx;
+  y *= mScy; y += dy;
+  z = mArr->Value(i-1,j-1) + mArr->Value(i1,j-1) + mArr->Value(i1,j1) +  mArr->Value(i-1,j1);
+  z = z/4.*mScz;
+//  g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);     
+  xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;    zw[j*(xsz+1)+i] = z;   
+
+// On trie par ordre de distance zp de projection / observateur, du plus loin au plus proche
+  qsort(ijzp,(size_t) k,sizeof(ZPSORT),ijzpsort);
+
+  PIGrCoord xg[5],yg[5],zg[5];
+  PIColors fgc; 
+
+
+  if (mCmapid == CMAP_OTHER) {   // Trace avec des lignes
+    if (mLAtt == PI_NotDefLineAtt)    g3->SelLine(PI_ThinLine);
+    fgc = ( mFCol == PI_NotDefColor ) ? PI_Black : mFCol;
+    for(l=0;l<k;l++) {
+      i =  ijzp[l].ij%xsz;
+      j =  ijzp[l].ij/xsz;
+      xg[4] = xg[0] = xw[i+j*(xsz+1)];    yg[4] = yg[0] = yw[i+j*(xsz+1)];  
+      zg[4] = zg[0] =   zw[i+j*(xsz+1)];
+      xg[1] = xw[i+1+j*(xsz+1)];          yg[1] = yw[i+1+j*(xsz+1)];   
+      zg[1] = zw[i+1+j*(xsz+1)];   
+      xg[2] = xw[i+1+(j+1)*(xsz+1)];      yg[2] = yw[i+1+(j+1)*(xsz+1)];
+      zg[2] = zw[i+1+(j+1)*(xsz+1)];
+      xg[3] = xw[i+(j+1)*(xsz+1)];        yg[3] = yw[i+(j+1)*(xsz+1)];  
+      zg[3] = zw[i+(j+1)*(xsz+1)]; 
+// On efface derriere 
+      g3->SelForeground(PI_White);
+//      g3->BaseGraphic()->DrawFPolygon(xg,yg,5);
+      g3->DrawFPolygon3D(xg,yg,zg,5);
+// On trace 
+      g3->SelForeground(fgc);
+//      g3->BaseGraphic()->DrawPolygon(xg,yg,5);
+      g3->DrawPolygon3D(xg,yg,zg,5);
+    }
+  }
+  else {   // Trace avec niveaux de couleur
+    PIColorMap* cmap = new PIColorMap(mCmapid);
+    PIColors fgc; 
+    if ( (mCmapid == CMAP_GREY32) || (mCmapid == CMAP_GREYINV32) || 
+         (mCmapid == CMAP_GREY128)  || (mCmapid == CMAP_GREYINV128) )
+      fgc = ( mFCol == PI_NotDefColor ) ? PI_Red : mFCol;
+    else  fgc = ( mFCol == PI_NotDefColor ) ? PI_Black : mFCol;
+    for(l=0;l<k;l++) {
+      i =  ijzp[l].ij%xsz;
+      j =  ijzp[l].ij/xsz;
+      xg[4] = xg[0] = xw[i+j*(xsz+1)];    yg[4] = yg[0] = yw[i+j*(xsz+1)];  
+      zg[4] = zg[0] =   zw[i+j*(xsz+1)];
+      xg[1] = xw[i+1+j*(xsz+1)];          yg[1] = yw[i+1+j*(xsz+1)];   
+      zg[1] = zw[i+1+j*(xsz+1)];   
+      xg[2] = xw[i+1+(j+1)*(xsz+1)];      yg[2] = yw[i+1+(j+1)*(xsz+1)];
+      zg[2] = zw[i+1+(j+1)*(xsz+1)];
+      xg[3] = xw[i+(j+1)*(xsz+1)];        yg[3] = yw[i+(j+1)*(xsz+1)];  
+      zg[3] = zw[i+(j+1)*(xsz+1)]; 
+// On efface derriere 
+      g3->SelForeground(*cmap, mLut->ApplyFast(ijzp[l].zh));
+      g3->DrawFPolygon3D(xg,yg,zg,5);
+// On trace 
+      if (mLAtt == PI_NotDefLineAtt)   continue;
+      g3->SelForeground(fgc);
+      g3->DrawPolygon3D(xg,yg,zg,5);
+    }
+      
+  }
+
+  delete[] ijzp;
+  delete[] xw; 
+  delete[] yw;
+  delete[] zw;
+}
Index: /tags/DPC_V0/Poubelle/PI/pisurfdr.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pisurfdr.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pisurfdr.h	(revision 1307)
@@ -0,0 +1,32 @@
+// Module PI : Peida Interactive PISurfaceDrawer
+// Drawer et DrawWidget 3D       R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PISURFDRW_H_SEEN
+#define PISURFDRW_H_SEEN
+
+#include "parradapter.h"
+#include "pi3ddrw.h"
+
+// Trace d une surface defini par Z=f(x,y)  travers un tableau 
+class PISurfaceDrawer : public PIDrawer3D {
+public :
+  			PISurfaceDrawer(P2DArrayAdapter* arr, bool asxy=false, bool asz=true, bool ad = true);
+  			~PISurfaceDrawer();
+
+  virtual void 		UpdateLimits();   // Calcule et change la vue-3D
+
+  virtual void 		Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 
+  virtual void       	DrawAxes(PIGraphicUC* g);
+
+protected :
+  P2DArrayAdapter* mArr;
+  bool mAda;
+  double mScz, mScx, mScy;
+  double mXmin, mXmax;
+  double mYmin, mYmax;
+  double mZmin, mZmax;
+  LUT* mLut;
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/pisysdep.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pisysdep.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pisysdep.h	(revision 1307)
@@ -0,0 +1,50 @@
+#ifndef PISYSDEP_SEEN
+#define PISYSDEP_SEEN
+
+#ifdef __MWERKS__         // Macintosh
+
+  #define PIWDG_H  "piwdgmac.h"
+  #define PICONT_H "picontainermac.h"
+  #define PIWIN_H  "piwindowmac.h"
+  #define PISTDWDG_H "pistdwdgmac.h"
+  #define PIMENU_H "pimenumac.h"
+  #define PIMENUBAR_H "pimenubarmac.h"
+  #define PIOPTMENU_H "pioptmenumac.h"
+  #define PIFILECHO_H "pifilechomac.h"
+  #define PILIST_H "pilistmac.h"
+
+  #define PIAPP_H "piapplmac.h"
+  
+  #define PIBWDG_H "pibwdgmac.h"
+  #define PIGRAPHIC_H "pigraphmac.h"
+
+  #define PICMAPNTV_H "picmapmac.h"
+  #define PICMAP_H "picmap.h"
+  #define PIPIXMAP_H "pipixmapmac.h"
+
+
+#else                  // XWindow
+  #define PIWDG_H  "piwdgx.h"
+  #define PICONT_H "picontainerx.h"
+  #define PIWIN_H  "piwindowx.h"
+  #define PISTDWDG_H "pistdwdgx.h"
+  #define PIMENU_H "pimenux.h"
+  #define PIMENUBAR_H "pimenubarx.h"
+  #define PIOPTMENU_H "pioptmenux.h"
+  #define PIFILECHO_H "pifilechox.h"
+  #define PILIST_H "pilistx.h"
+
+  #define PIAPP_H "piapplx.h"
+
+  #define PIBWDG_H "pibwdgx.h"
+  #define PIGRAPHIC_H "pigraphx.h"
+
+  #define PICMAPNTV_H "picmapx.h"
+  #define PICMAP_H "picmap.h"
+  #define PIPIXMAP_H "pipixmapx.h"
+
+  #define PIPERIODIC_H "piperiodx.h"
+
+#endif
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piup.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piup.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piup.cc	(revision 1307)
@@ -0,0 +1,61 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "ctimer.h"
+#include "imageop.h"
+
+#include "piup.h"
+
+RzImage * PIUserProc_1(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("**** PIUserProc_1 Pave[%d*%d] en (%d,%d) %s %s  Filtrage passe-bas 3*3 \n",
+       dx, dy, xp, yp, arg1, arg2);
+ImageR4 filt(3,3);
+ImageR4 * out;
+
+// Definition du filtre passe-bas
+int i,j;
+for(i=0; i<3; i++)
+  for(j=0; j<3; j++)  filt(i,j) = 0.1;
+filt(1,1) = 0.2;
+
+filt.PrintImage();
+out = new ImageR4(myimg.XSize(), myimg.YSize());
+TIMEF ;
+FilterImage(&myimg, out, &filt); 
+return((RzImage*)out);
+}
+ 
+RzImage * PIUserProc_2(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("**** PIUserProc_2 Pave[%d*%d] en (%d,%d) %s %s  Ombre 3*3 \n",
+       dx, dy, xp, yp, arg1, arg2);
+printf(" PIUserProc_2(%d %d %s %s)  Ombre 3*3 \n", xp, yp, arg1, arg2);
+ImageR4 filt(3,3);
+ImageR4 * out;
+
+// Definition du filtre ombre
+int i,j;
+filt(0,0) = filt(1,1) = filt(2,2) = 0.;
+filt(0,1) = filt(1,2) = -1.;
+filt(1,0) = filt(2,1) = 1.;
+filt(0,2) = -2.;
+filt(2,0) = 2.;
+filt.PrintImage();
+out = new ImageR4(myimg.XSize(), myimg.YSize());
+TIMEF ;
+FilterImage(&myimg, out, &filt); 
+return((RzImage*)out);
+}
+
+ 
+RzImage * PIUserProc_3(ImageR4& , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_3 Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
Index: /tags/DPC_V0/Poubelle/PI/piup.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piup.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piup.h	(revision 1307)
@@ -0,0 +1,10 @@
+#include "cimage.h"
+extern "C" {
+RzImage * PIUserProc_1(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2);
+RzImage * PIUserProc_2(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2);
+RzImage * PIUserProc_3(ImageR4& myimg, int xp, int yp, int dx, int dy, 
+                       char * arg1, char * arg2);
+}
+
Index: /tags/DPC_V0/Poubelle/PI/piup_def.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piup_def.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piup_def.cc	(revision 1307)
@@ -0,0 +1,33 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "ctimer.h"
+#include "imageop.h"
+
+#include "piup.h"
+
+RzImage * PIUserProc_1(ImageR4 & , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_1/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
+RzImage * PIUserProc_2(ImageR4 & , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_2/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
+RzImage * PIUserProc_3(ImageR4 & , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_3/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
Index: /tags/DPC_V0/Poubelle/PI/piupdattachment.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piupdattachment.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piupdattachment.cc	(revision 1307)
@@ -0,0 +1,104 @@
+#include "piupdattachment.h"
+//const MessageT	msg_MouseUp			= 819;
+
+PIUpdAttachment* PIUpdAttachment::lastCursPane = NULL;
+bool PIUpdAttachment::hit = false;
+int PIUpdAttachment::down = 0;
+
+PIUpdAttachment::PIUpdAttachment(PIBaseWdgMac* wdg)
+: LAttachment(), myWdg(wdg)
+{
+  myGraphic = (PIGraphicMac*) wdg->WindowGraphic();
+}
+
+PIUpdAttachment::~PIUpdAttachment()
+{
+  if (lastCursPane == this) lastCursPane = NULL;
+  delete myGraphic;
+}
+
+void PIUpdAttachment::ExecuteSelf(MessageT msg, void* data)
+{
+  if (myWdg)
+    switch(msg) {
+      case msg_DrawOrPrint:
+        myWdg->Draw(myGraphic);
+ 		break;
+      case msg_Resize:
+        myWdg->Resize();
+ 		break;
+      case msg_Move:
+//        myWdg->Move();
+        break;
+//      case cmd_Close: {
+//        delete myWdg;
+//        break;
+//      }
+      case msg_Click: {
+        SMouseDownEvent* evt = (SMouseDownEvent*) data;
+        EventModifiers mod = evt->macEvent.modifiers;
+        if ((mod & cmdKey) && (mod & optionKey))
+          { myWdg->But3Press(evt->whereLocal.h,evt->whereLocal.v); down = 3;}
+        else if (mod & cmdKey)
+          { myWdg->But2Press(evt->whereLocal.h,evt->whereLocal.v); down = 2;}
+        else
+          { myWdg->But1Press(evt->whereLocal.h,evt->whereLocal.v); down = 1;}
+ 		break;
+ 		}
+ 	  case msg_KeyPress: {
+ 	    EventRecord* evt = (EventRecord*) data;
+ 	    PIKeyModifier kmod = PIKM_Blank;
+ 	    if (evt->modifiers & shiftKey)
+ 	      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+ 	      //kmod |= PIKM_Shift;  // Ca devrait passer !!!
+ 	    if (evt->modifiers & optionKey)
+ 	      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+ 	    if (evt->modifiers & controlKey)
+ 	      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+ 	    myWdg->Keyboard(evt->message & charCodeMask, kmod);
+ 	    break;
+ 	    }
+ 	  case msg_AdjustCursor: {
+ 	    EventRecord* evt = (EventRecord*) data;
+ 	    if (lastCursPane != this) {
+ 	      if (lastCursPane)
+ 	        lastCursPane->myWdg->Leave();
+ 	      myWdg->Enter();
+ 	      lastCursPane = this;
+ 	    }
+ 	    hit = true;
+ 	    SetExecuteHost(!myWdg->AdjustCursor());
+ 	    // Est-ce un move, i.e. le bouton est-il toujours appuye depuis le dernier MouseDown ?
+ 	    if (::StillDown() && down) {
+ 	      Point pt = evt->where;
+ 	      myWdg->mPane->GlobalToPortPoint(pt);
+ 	      myWdg->mPane->PortToLocalPoint(pt);
+ 	      if (lastPt.h != pt.h || lastPt.v != pt.v) {
+ 	        lastPt = pt;
+            EventModifiers mod = evt->modifiers;
+            if ((mod & cmdKey) && (mod & optionKey))
+              myWdg->Ptr3Move(pt.h,pt.v);
+            else if (mod & cmdKey)
+              myWdg->Ptr2Move(pt.h,pt.v);
+            else
+              myWdg->Ptr1Move(pt.h,pt.v);
+          }
+ 	    } else if (down) {  // A changer le jour ou les attachements recoivent les mouseup.
+ 	      Point pt = evt->where;
+ 	      myWdg->mPane->GlobalToPortPoint(pt);
+ 	      myWdg->mPane->PortToLocalPoint(pt);
+          EventModifiers mod = evt->modifiers;
+          //if ((mod & cmdKey) && (mod & optionKey))
+          if (down == 3)
+            myWdg->But3Release(pt.h,pt.v);
+          //else if (mod & cmdKey)
+          else if (down == 2)
+            myWdg->But2Release(pt.h,pt.v);
+          else
+            myWdg->But1Release(pt.h,pt.v);
+ 	      down = 0;
+        }
+ 	    break;
+ 	    }
+    }
+}
Index: /tags/DPC_V0/Poubelle/PI/piupdattachment.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piupdattachment.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piupdattachment.h	(revision 1307)
@@ -0,0 +1,28 @@
+
+#include <LAttachment.h>
+
+#include "pibwdgmac.h"
+
+const MessageT	msg_Resize			= 817;
+const MessageT	msg_Move			= 818;
+
+class PIUpdAttachment : public LAttachment {
+public:
+  PIUpdAttachment(PIBaseWdgMac* wdg);
+  ~PIUpdAttachment();
+  
+protected:
+ virtual void	ExecuteSelf(
+							MessageT		inMessage,
+							void			*ioParam);
+
+ PIBaseWdgMac* myWdg;
+ PIGraphicMac* myGraphic;
+ 
+ friend class PIPPApplMac;
+ static PIUpdAttachment* lastCursPane;
+ static bool hit;
+ static int down;
+ Point lastPt;
+};
+
Index: /tags/DPC_V0/Poubelle/PI/piusmak
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piusmak	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piusmak	(revision 1307)
@@ -0,0 +1,39 @@
+include  $(EROSBASEREP)/Include/MakefileUser.h
+
+%.o:%.cc
+	$(COMPILE.cc) -o $@ $<
+LIBF =  $(SLB)libpeida.so $(SLB)liberosc.so
+LIBS = -L$(SLB) -lpeida -lerosc
+
+#-------------------------------------------------------- 
+all : piup.so
+
+clean:
+	rm -f user.o user.so piup.so
+
+piup.so : user.so
+	cp -p user.so piup.so
+
+user.so : user.o $(LIBF)
+ifeq (${MACHEROS},Linux)
+	$(LINK.cc) -shared -o user.so --whole-archive user.o --nowhole-archive $(LIBS) -lm -lc
+endif
+ifeq (${MACHEROS},OSF1)
+ifeq ($(CXX), cxx)
+	$(LINK.cc) -shared -o user.so -all user.o -none $(LIBS) -lm -lc
+endif
+ifeq ($(CXX), g++)
+	ld -shared -o user.so -all user.o -none $(LIBS) -L$(GLB) -lg++ -lstdc++ -lm -lc
+endif
+endif
+
+user.o: user.cc  $(INC)piup.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)datatypes.h \
+ $(INC)utils.h $(INC)peida.h 
Index: /tags/DPC_V0/Poubelle/PI/piwdggen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwdggen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwdggen.cc	(revision 1307)
@@ -0,0 +1,388 @@
+//  Classe de base pour les objets correspondant a une fenetre 
+//  dans les programmes graphiques interactives
+//
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "piwdggen.h"
+#include "picontainergen.h"
+#include "pievthandler.h"
+#include "psfile.h"
+
+//++
+// Class	PIWdg
+// Lib		PI
+// include	piwdggen.h
+//
+//   	Classe de base pour tout objets correspondant à une fenêtre
+//	à l'écran, ayant donc une représentation graphique et 
+//	pouvant jouer un rôle dans la hiérarchie des objets interactif. 
+//	*PIWdg* hérite de *PIMsgHandler*, avec une hiérarchie correspondant
+//	par défaut à celles des PIWdg. La classe "PIWdg" est une des 
+//	classes de PI qui ont une implementation dépendante du systeme utilisé
+//	(Mac, XWindow, ...). La classe "PIWdgGen" est la classe qui
+//	définit l'interface, et ne doit pas être instanciée directement
+//	(Méthodes virtuelles pures). Les objets instanciés sont de la 
+//	classes "PIWdg" et le fichier entête correspondant est "PIWDG_H"
+//	défini dans "pisysdep.h"
+//--
+//++
+// Links	Parents
+// PIMsgHandler
+//--
+//++
+// Links	Voir aussi
+// PIEventHandler
+//--
+
+//++
+// Titre	Constructeur
+//--
+//++
+// PIWdg(PIContainerGen *par, char *nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet contenu dans l'objet *PIContainer* "par", de
+//	taille "sx,sy", se trouvant à la position "px,py" avec le nom "nom"
+// long kind()
+//	Renvoie le type de la classe de l'objet ("=PIWdgGen::ClassId") pour cette classe
+//	de base. Doit être redéfinie par les classes dérivées.
+//--  
+
+
+//++
+// Titre	Taille, position
+//--
+//++
+// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
+//	Méthode virtuelle qui doit être redéfinie pour chacune des classes filles.
+//	produit une représentation graphique de l'objet en Postscript.
+// SetSize(int sx, int sy)
+//	Modifie la taille de l'objet.
+// SetPos(int px, int py)
+//	Modifie la position de l'objet.
+// int  XSize()  YSize()
+//	Renvoient la taille (X,Y) de l'objet.
+// int  XPos()  YPos()
+//	Renvoient la position (X,Y) de l'objet.
+// void  GetScreenPos(int & spx, int & spy)
+//	Renvoie la position de l'objet sur l'écran.
+//--
+//++
+// Titre	Gestion des accrochages (Binding)
+//--
+//++
+// void  SetBinding(PIBindingKind left, PIBindingKind top, PIBindingKind right, PIBindingKind bottom)
+//	Permet de contrôler le comportement de l'objet en cas de changement de taille 
+//	du conteneur parent. La position de chaque bord peut être sans contrainte ("PIBK_free")
+//	attachée à une distance fixe par rapport au bord opposé du conteneur ("PIBK_fixed"), 
+//	ou à une position proportionnelle à la taille du conteneur parent. ("PIBK_elastic") 
+// bool  GetBinding((PIBindingKind& left, PIBindingKind& top, PIBindingKind& right, PIBindingKind& bottom)
+//	Permet de connaitre l'état des accrochages. Retourne "true" si les accrochages ont été
+//	verrouillé (appel à "LockBinding()"), "false" sinon.
+// void  LockBinding()
+//	Verrouille l'état des accrochages. Appel à "SetBinding()" sera alors sans effet.
+//	Permet à certains *LayouMgr* d'imposer une contrôle strict.
+// void  UnLockBinding()
+//	Deverrouille les accrochages.
+//--
+
+//++
+// Titre	Etat de l'objet
+//	L'objet peut se trouver dans l'état actif ou inactif. Cet état est contrôlé par les 
+//	méthodes "Manage(), UnManage()". L'objet ne se trouve effectivement dans l'état 
+//	actif que si son conteneur parent est lui même actif.
+//	L'objet peut aussi être affichés, mais insensible aux actions utilisateur
+//	(clavier, souris, ...). Cette sensibilité est controlée par les 
+//	méthodes  "SetSensitive(), SetUnSensitive()".
+//--
+//++
+// void  Manage()  UnManage()
+//	Change l'état de l'objet (actif, inactif)
+// bool  IfManaged()  IfVisible()
+//	indique si l'objet est actif , visible	
+// void  SetSensitive() SetUnSensitive()
+//	Rend l'objet sensible/ insensible aux actions utilisateurs (clavier, souris, ...)
+//	L'état visuel de l'objet peut être modifié en conséquence.
+// bool  IfSensitive() 
+//	indique si l'objet est répond aux sollicitations utilisateur.
+//--
+
+//++
+// Titre	Rafraîchissement de la fenêtre
+//--
+//++
+// void  Refresh()
+//	L'appel à cette méthode permet de retracer le contenu de la 
+//	fenêtre et des "Drawer" associés.
+//--
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+// void SetMsg(PIMessage msg = 0)
+//	Modifie la valeur du message associé à l'objet.
+// PIMessage  Msg()
+//	Renvoie le message associé à l'objet.
+// string  Nom()
+//	Renvoie le nom associé à l'objet.
+// PIWdg*  Parent()
+//	Renvoie le conteneur parent de l'objet.
+// void  SetUserData( void * p, int fg = 0)
+//	Associe un pointeur de données à la disposition de l'utilisateur 
+//	("void* p") à l'objet, ainsi qu'une valeur ("int fg")
+// void* UserData()
+//	Renvoie le pointeur de données user de l'objet. (NULL par défaut)
+// int  UserFlag()
+//	Renvoie la valeur "int" user de l'objet.
+//--
+
+//++
+// Titre	Gestion du copier/coller
+//	L'ensemble des méthodes de gestion de copier/coller sont décrites ici. Les méthodes
+//	"SelectionLost()", "ProvideSelection()", et "PasteSelection()" doivent être 
+//	redéfinies par les classes héritières de *PIWdg* implémentant la fonctionalité
+//	copier/coller. Le mécanisme copier/coller entre objets d'une même application,
+//	ainsi qu'entre différentes applications. Dans les opérations de copier/coller,
+//	il existe un PIWdg ou une application source des données et un PIWdg ou 
+//	une application destinatire.
+//--
+
+//++
+// bool  ClaimSelection(int typ=PICP_string)
+//	Cette méthode doit être appelée par l'objet "PIWdg" source quand celui-ci veut 
+//	s'approprier la zone d'échange de données (Selection) pour le copier/coller. "typ" indique 
+//	le type de données que peut fournir l'objet. Le type "PICP_string" (suite de caractères)
+//	est le seul type supporté actuellement. La valeur de retour est "true" si 
+//	la zone d'échange est attribué a l'objet. Cette méthode ne doit en principe pas 
+//	être redéfinie par les classes héritières de *PIWdg*.
+// void  SelectionLost()
+//	Cette méthode est appelée quand l'objet "PIWdg" source qui possede la zone d'échange 
+//	(Selection) perd celle-ci, suite par exemple à la demande d'un autre objet. Cette méthode 
+//	doit être redéfinies par les classes qui implémentent la fonctionalité et ne doit 
+//	doit pas être appelée directement.
+// int  RequestSelection(int typ=PICP_string)
+//	Cette méthode doit être appelée par l'objet "PIWdg" destinatire quand celui-ci souhaite 
+//	obtenir les données de la zone d'échange (Selection). "typ" indique les types de données 
+//	acceptables par l'objet. La valeur de retour indique le type qui sera fourni
+//	(à l'appel de "PasteSelection()"). Cette méthode ne doit en principe pas 
+//	être redéfinie par les classes héritières de *PIWdg*.
+// void* ProvideSelection(int& typ, int& len)  
+//	Cette méthode est appelée quand l'objet "PIWdg" source, qui possede la zone d'échange 
+//	(Selection) doit  fournir les données correspondantes à la sélection. Renvoie le pointeur 
+//	de la zone mémoire correspondante, sa longueur ("len") et le type ("typ") des données.
+//	cette zone mémoire appartient à l'objet, et ne doit être modifié tant que 
+//	la méthode "SelectionTransferEnd()" n'a été appelé.
+// void  SelectionTransferEnd()
+//	Cette méthode est appelé une fois que l'objet ou l'application destinataire 
+//	des données de sélection a fini de traiter l'opération de copie. l'objet PIWdg 
+//	source peut alors détruire ou modifier les données correspondantes à l'échange.
+// void  PasteSelection(int typ, void *pdata, int l)
+//	Cette méthode est appelée après l'appel à "RequestSelection()" pour l'objet 
+//	destinataire. "typ" indique le type des données dans "pdata", et "l" la longeur. 
+//	La zone mémoire "pdata" n'appartient pas à l'objet destinataire et ne doit pas 
+//	être modifié par celui-ci. Une copie doit être effectué si cesCette méthode  données devaient
+//	être utilisées après la sortie de "PasteSelection()".
+//--
+
+/* --Methode-- */
+PIWdgGen::PIWdgGen(PIContainerGen *par, char*, int, int, int, int)
+: PIMsgHandler(par)
+{
+parent = par;
+bindingLock = false;
+SetMsg(0);
+SetUserData(NULL, 0);
+//  ChildAdd() doit etre appele par la classe qui implemente le widget
+// if (par)  par->ChildAdd(this);   //  On previent le container parent  
+return;
+}
+
+
+/* --Methode-- */
+PIWdgGen::~PIWdgGen()
+{
+//  ChildDel() doit etre appele par la classe qui implemente le widget
+// if (parent)  parent->ChildDel(this);   //  On previent le container parent 
+list<EvHand>::iterator it;
+for(it= mDHlist.begin(); it != mDHlist.end(); it++) 
+  if ((*it).ad) delete (*it).evh;
+for(it= mEHlist.begin(); it != mEHlist.end(); it++) 
+  if ((*it).ad) delete (*it).evh;
+}
+
+/* --Methode-- */
+void PIWdgGen::SetMsg(PIMessage msg)
+{
+myMsg = msg;
+}
+
+/* --Methode-- */
+void PIWdgGen::GetScreenPos(int & spx, int & spy)
+/*  Renvoie la position de la fenetre par rapport a l'ecran */
+{
+PIWdgGen * wc;
+spx = 0;  spy = 0;
+wc = this;
+
+while (wc) 
+  { spx += wc->XPos();  
+  spy += wc->YPos();  wc = wc->Parent();
+  }
+return;
+}
+
+/* --Methode-- */
+void PIWdgGen::LockBinding()
+{
+bindingLock = true;
+}
+
+/* --Methode-- */
+void PIWdgGen::UnLockBinding()
+{
+bindingLock = false;
+}
+
+/* --Methode-- */
+void PIWdgGen::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+char str[256];
+
+if (!psf) return;
+psf->NewBloc((double)ofx+XPos(), (double)ofy+YPos(), (double)XSize(), (double)YSize(),
+             (double)XSize(), (double)YSize());
+psf->DrawBox(0., 0., (double)XSize(), (double)YSize());
+sprintf(str,"PIWdgGen::PSPrint() Kind=%ld Name= %s", kind(), Nom().c_str());
+psf->DrawString(12., 12., str, PI_Black, PI_RomanFont, 10);
+psf->EndBloc();
+
+return;
+}
+
+//++
+// Titre	Gestion des Draw/Event Handler
+//	Les objets de la classe "PIWdg" peuvent gérer des objets "PIEventHandler" 
+//	qui peuvent prendre en charge une partie du traitement des événements
+//	clavier-souris-écran.
+//--
+
+//++
+// void AddDrawHandler(PIEventHandler* drwh, bool ad=false)
+//	Ajout d'un objet gestionnaire d'événements, responsable du tracé du contenu de la fenêtre.
+//	La méthode "Draw(PIGraphic* g, ...)" sera appelé pour rafraîchir le contenu de la fenêtre.
+// void RemoveDrawHandler(PIEventHandler* drwh)
+//	Suppression d'un objet gestionnaire de tracé. Toutes les réferences sonnt supprimées en cas 
+//	d' enregistrement multiple.
+// void AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false)
+//	Ajout d'un objet gestionnaire d'événements. La variable "evtmask" détermine pour
+//	quels types d'événements, la méthode "Process()" du gestionnaire est appelée.
+//|	PIEvent_Resize   (Non implementé en version X11 , 12/98)
+//|	PIEvent_Enter , PIEvent_Leave
+//|	PIEvent_ButxPress, PIEvent_ButxRelease (x=1,2,3)
+//|	PIEvent_PtrMove , PIEvent_PtrxMove (x=1,2,3)
+//|	PIEvent_Keyboard
+//
+// void RemoveEventHandler(PIEventHandler* evh)
+//	Suppression d'un gestionnaire d'événements. Toutes les réferences sonnt supprimées en cas
+//	d' enregistrement multiple, même avec différents masques d'événements.
+//--
+
+/* --Methode-- */
+void PIWdgGen::AddDrawHandler(PIEventHandler* drwh, bool ad)
+{
+EvHand eh;
+eh.evh = drwh; eh.mask = PIEvent_Draw;  eh.ad = ad;
+mDHlist.push_back(eh);
+}
+
+/* --Methode-- */
+void PIWdgGen::RemoveDrawHandler(PIEventHandler* drwh)
+{
+list<EvHand>::iterator it;
+bool found = true;
+while (found) {
+  found = false;
+  for(it= mDHlist.begin(); it != mDHlist.end(); it++) 
+    if ((*it).evh == drwh) { mDHlist.erase(it); found = true; break; }
+  }
+}
+
+/* --Methode-- */
+void PIWdgGen::AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad)
+{
+EvHand eh;
+eh.evh = evh; eh.mask = evtmask;  eh.ad = ad;
+mEHlist.push_back(eh);
+}
+
+/* --Methode-- */
+void PIWdgGen::RemoveEventHandler(PIEventHandler* evh)
+{
+list<EvHand>::iterator it;
+bool found = true;
+while (found) {
+  found = false;
+  for(it= mEHlist.begin(); it != mEHlist.end(); it++) 
+    if ((*it).evh == evh) { mEHlist.erase(it); found = true; break; }
+  }
+}
+
+
+/* --Methode-- 
+string PIWdgGen::kindstr()
+{
+char b[5];
+string s;
+
+b[0] = (char) (kind()&0x000000FF);
+b[1] = (char) ((kind()&0x0000FF00) / 0x100);
+b[2] = (char) ((kind()&0x00FF0000) / 0x10000);
+b[3] = (char) ((kind()&0xFF000000) / 0x1000000);
+b[4] = '\0';
+s = b;
+return(s);
+}
+*/
+
+//++
+// Class	PIScreenBuffer
+// Lib		PI
+// include	piwdggen.h
+//
+//	Classe de tampon de dessin hors écran. Permet la copie du contenu des pixels
+//	depuis et vers des objets "PIWdg", ainsi que depuis et vers d'autres tampon
+//	d'écran. Un objet "PIGraphic" peut-être instancié pour fournir les services
+//	de dessin dans un "PIScreenBuffer"
+//--
+//++
+// Links	Voir aussi
+// PIWdg
+// PIGraphic
+//--
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIScreenBuffer(int sx, int sy)
+//	Constructeur, création d'un tampon de taille "sx * sy" pixels.
+// int  XSize()
+//	Renvoie la taille en X.
+// int  YSize()
+//	Renvoie la taille en Y.
+//
+//	Pour les opérations de copie, le rectangle source est défini par
+//	la position du coin haut-gauche "(ox,oy)" et la taille "dx * dy" en pixels.
+//	La copie s'effectue sur l'objet destination à partir de l'offset "(x,y)".
+//
+// void CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+//	Copie depuis l'objet "PIWdg* wdg".
+// void CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+//	Copie vers l'objet "PIWdg* wdg".
+// void CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y)
+//	Copie depuis l'objet "PIScreenBuffer* grb"
+//--
Index: /tags/DPC_V0/Poubelle/PI/piwdggen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwdggen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwdggen.h	(revision 1307)
@@ -0,0 +1,143 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIWdgGen
+//                                    Reza 10/95            
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIWDG_H_SEEN
+#define PIWDG_H_SEEN
+
+#include "pimsghandler.h"
+
+#include <string>
+#include <list>
+#if defined(__KCC__)
+using std::string ;
+#include <list.h>
+#endif
+
+
+void PIBeep();
+
+// Les differents types d accrochage aux containers  
+
+enum PIBindingKind {    
+  PIBK_free = 0,
+  PIBK_fixed = 1,
+  PIBK_elastic = 2
+};
+
+enum PICopyPasteKind {    // Pour gerer les types d objets echange en copier/coller
+  PICP_string = 1
+};
+
+class PSFile;
+class PIContainerGen;
+class PIEventHandler;
+
+//  -------------------- Classe PIWdgGen -----------------------
+class PIWdgGen : public PIMsgHandler
+{
+public:
+  enum {ClassId = 100};
+
+                         PIWdgGen(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual               ~PIWdgGen();
+  virtual void		 FinishCreate()=0; // apres avoir installe les sous-vues
+
+  virtual long           kind() {return ClassId; }
+//  string               kindstr();
+
+  inline PIContainerGen* Parent() { return( parent ); }
+
+  inline void         	 SetUserData( void * p, int fg = 0) {pdata=p; flag=fg; }
+  inline void*       	 UserData() { return (pdata); };
+  inline void const* 	 UserData() const { return (pdata); };
+  inline int         	 UserFlag() { return(flag); };
+
+
+  virtual void           SetMsg(PIMessage msg = 0);
+  inline  PIMessage      Msg() { return (myMsg); }
+
+  virtual void           SetSize(int sx, int sy)=0;
+  virtual void           SetPos(int px, int py)=0;
+  virtual void           SetBorderWidth(int bw)=0;
+  virtual void           SetLabel(string const&) {}
+
+//  Gestion des accrochages (binding) aux containers
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom)      =0;
+  virtual bool           GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                                    PIBindingKind& right, PIBindingKind& bottom)    =0;
+  virtual void		 LockBinding();
+  virtual void		 UnLockBinding();
+
+  virtual int            XSize()=0;
+  virtual int            YSize()=0;
+  virtual int            XPos()=0;
+  virtual int            YPos()=0;
+
+  virtual string         Nom()=0;
+  virtual void           GetScreenPos(int & spx, int & spy);
+
+// Pour activer, desactiver un composant graphique (PIWdg)
+  virtual void           Manage()=0;
+  virtual void           UnManage()=0;
+  virtual bool           IfManaged()=0;
+  virtual bool           IsVisible()=0;
+
+//  Fonction qui doit etre appelee pour rafraichir la fenetre 
+  virtual void       	 Refresh()=0;
+
+//  Pour rendre un composant graphique (PIWdg) sensible/insensible 
+//  aux actions utilisateur (souris, clavier, ...)
+  virtual void           SetSensitive()=0;
+  virtual void           SetUnSensitive()=0;
+  virtual bool           IfSensitive()=0;
+
+  virtual void           PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+//  Gestion de copier-coller
+  virtual bool           ClaimSelection(unsigned int typ=PICP_string)                     = 0;
+  virtual void           SelectionLost()                                                  = 0;
+  virtual unsigned int   RequestSelection(unsigned int typ=PICP_string)                   = 0;
+  virtual void*          ProvideSelection(unsigned int& typ, unsigned int& len)           = 0;
+  virtual void           SelectionTransferEnd()                                           = 0;
+  virtual void           PasteSelection(unsigned int typ, void *pdata, unsigned int l)    = 0;
+
+//  Copie depuis un PIWdgGen
+  virtual void		 CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y) = 0;
+
+//  Gestion des EventHandler
+  virtual void		 AddDrawHandler(PIEventHandler* drwh, bool ad=false);
+  virtual void		 RemoveDrawHandler(PIEventHandler* drwh);
+  virtual void		 AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
+  virtual void		 RemoveEventHandler(PIEventHandler* evh);
+
+// !! Devrait etre protected - mis ici a cause de cxx  Reza 12/98
+  struct EvHand { PIEventHandler* evh; unsigned long mask;  bool ad; };
+protected:
+  PIContainerGen*        parent;
+  PIMessage              myMsg;
+  list<EvHand>		 mDHlist;
+  list<EvHand>		 mEHlist;
+  bool			 bindingLock;
+private:
+  int flag;
+  void * pdata;
+};
+
+// ---- La classe PIScreenBuffer doit se conformer a l'interface suivante
+// class PIScreenBuffer {
+// public :
+//  			PIScreenBuffer(int sx, int sy);
+//  virtual		~PIScreenBuffer();
+//  virtual int         XSize();
+//  virtual int         YSize();
+//  virtual  void 	CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+//  virtual  void 	CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+//  virtual  void 	CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
+// };
+  
+
+#endif/* PIWDG_H_SEEN */
Index: /tags/DPC_V0/Poubelle/PI/piwdgmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwdgmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwdgmac.cc	(revision 1307)
@@ -0,0 +1,251 @@
+#include "piwdgmac.h"
+#include "pisysdep.h"
+
+#include PICONT_H
+
+#include <LView.h>
+#include <LString.h>
+
+void PIBeep()
+{
+  ::SysBeep(1);
+}
+
+
+PIWdgMac::PIWdgMac(PIContainerGen *par, char *nom,
+                   int sx, int sy, int px, int py)
+:PIWdgGen(par, nom, sx, sy, px, py), mNom(nom)
+{
+  mAdapterPaneInfo.paneID    = 0;
+  mAdapterPaneInfo.width     = sx;
+  mAdapterPaneInfo.height    = sy;
+  mAdapterPaneInfo.visible   = true;
+  mAdapterPaneInfo.enabled   = true;
+  mAdapterPaneInfo.bindings.left =
+    mAdapterPaneInfo.bindings.top =
+    mAdapterPaneInfo.bindings.right =
+    mAdapterPaneInfo.bindings.bottom = false;
+  mAdapterPaneInfo.left      = px;
+  mAdapterPaneInfo.top       = py;
+  mAdapterPaneInfo.userCon   = 0;
+  mAdapterPaneInfo.superView = par ? (LView*) (((PIContainerMac*)(par))->mPane) : NULL;
+
+  mAdapterViewInfo.imageSize.width = sx;
+  mAdapterViewInfo.imageSize.height = sy;
+  mAdapterViewInfo.scrollPos.h = 
+    mAdapterViewInfo.scrollPos.v = 
+    mAdapterViewInfo.scrollUnit.h = 
+    mAdapterViewInfo.scrollUnit.v = 0;
+  mAdapterViewInfo.reconcileOverhang = 0;
+
+  mAdapter = new PIPPViewAdapter(mAdapterPaneInfo, mAdapterViewInfo);
+
+  mPaneInfo.paneID    = 'PIWD';
+  mPaneInfo.width     = sx;
+  mPaneInfo.height    = sy;
+  mPaneInfo.visible   = true;
+  mPaneInfo.enabled   = true;
+  mPaneInfo.bindings.left =
+    mPaneInfo.bindings.top =
+    mPaneInfo.bindings.right =
+    mPaneInfo.bindings.bottom = true;
+  mPaneInfo.left      = 0;
+  mPaneInfo.top       = 0;
+  mPaneInfo.userCon   = 'PIWD';
+  mPaneInfo.superView = mAdapter;
+
+  mViewInfo.imageSize.width = sx;
+  mViewInfo.imageSize.height = sy;
+  mViewInfo.scrollPos.h = 
+    mViewInfo.scrollPos.v = 
+    mViewInfo.scrollUnit.h = 
+    mViewInfo.scrollUnit.v = 0;
+  mViewInfo.reconcileOverhang = 0;
+  
+  mPane = new LView(mPaneInfo, mViewInfo);
+  ((LView*)mAdapter)->CalcPortOrigin();
+  ((LView*)mPane)->CalcPortOrigin();
+}
+
+
+PIWdgMac::~PIWdgMac()
+{
+  delete mPane;
+  delete mAdapter;
+}
+
+void
+PIWdgMac::FinishCreate()
+{
+  mPane->FinishCreate();
+}
+
+void
+PIWdgMac::ListenToMessage(MessageT /*inMessage*/, void */*ioParam*/)
+{
+
+}
+
+void
+PIWdgMac::SetLabel(string const& lab)
+{
+  LStr255 titre(lab.c_str());
+  mPane->SetDescriptor(titre);
+}
+
+void
+PIWdgMac::SetSize(int sx, int sy)
+{
+  if (mAdapter)
+   mAdapter->ResizeFrameTo(sx, sy, true);
+  else
+   mPane->ResizeFrameTo(sx, sy, true);
+}
+
+void
+PIWdgMac::SetPos(int px, int py)
+{
+  if (mAdapter)
+   mAdapter->MoveBy(px-XPos(), py-YPos(), false);
+  else
+   mPane->MoveBy(px-XPos(), py-YPos(), false);
+}
+
+void
+PIWdgMac::SetBinding(PIBindingKind left, PIBindingKind top, 
+                     PIBindingKind right, PIBindingKind bottom)
+{
+  if (mAdapter)  
+    mAdapter->SetBinding(left, top, right, bottom);
+  //else
+  //  mPane->SetBinding(left, top, right, bottom);
+}
+
+int
+PIWdgMac::XSize()
+{ 
+  SDimension16 outSize;
+  mPane->GetFrameSize(outSize);
+  return outSize.width;
+}
+
+int
+PIWdgMac::YSize()
+{ 
+  SDimension16 outSize;
+  mPane->GetFrameSize(outSize);
+  return outSize.height;
+}
+
+int
+PIWdgMac::XPos()
+{
+  SPoint32 p;
+  mPane->GetFrameLocation(p);
+  return p.h;
+}
+
+int
+PIWdgMac::YPos()
+{
+  SPoint32 p;
+  mPane->GetFrameLocation(p);
+  return p.v;
+}
+
+
+bool 
+PIWdgMac::IsVisible()    // $CHECK$  REZA a verifier  01/12/97
+{
+if (mPane->IsVisible())  return(true);
+else return(false);
+}
+
+
+// Gestion de Copier/Coller
+#include <LClipboard.h>
+/* --Methode-- */
+// COPY
+bool PIWdgMac::ClaimSelection(unsigned int)
+{
+  int l;
+  char* txt = SelectionString(l);
+  LClipboard::GetClipboard()->SetData('TEXT',txt,l,true);
+  delete[] txt;
+  return (true);
+}
+
+/* --Methode-- */
+void PIWdgMac::SelectionLost()
+{
+}
+
+/* --Methode-- */
+// PASTE
+unsigned int PIWdgMac::RequestSelection(unsigned int)
+{
+  Handle h = NewHandle(0);
+  Int32 l = LClipboard::GetClipboard()->GetData('TEXT', h);
+  if (l) {
+    CopyFromSelection(*h, l);
+  }
+  return 1;
+}
+
+/* --Methode-- */
+void PIWdgMac::CopyFromSelection(char * sv, int l)
+{
+char* buff = new char[l+2];
+strncpy(buff, sv, l);
+buff[l] = '\0';
+printf("PIWdgMac::RequestSelection() L=%d [%s] \n", l, buff);
+delete buff;
+return;
+}
+
+/* --Methode-- */
+void PIWdgMac::PasteSelection(unsigned int, void *buff, unsigned int l)
+{
+  CopyFromSelection((char*) buff, l);
+}
+
+/* --Methode-- */
+char* PIWdgMac::SelectionString(int& len)
+{
+char *rs = new char[60];
+strcpy(rs, "Test-of-PIWdgMac::SelectionString()");
+len = strlen(rs);
+return(rs);
+}
+
+
+/* --Methode-- */
+void* PIWdgMac::ProvideSelection(unsigned int&, unsigned int& len)
+{
+  return SelectionString(len);
+}
+
+/* --Methode-- */
+void PIWdgMac::SelectionTransferEnd()
+{
+}
+
+/* --Methode-- */
+void PIWdgMac::Manage()
+{
+  if (mAdapter) mAdapter->Show();
+  mPane->Show();
+}
+
+/* --Methode-- */
+void PIWdgMac::UnManage()
+{
+  mPane->Hide();
+  if (mAdapter) mAdapter->Hide();
+}
+
+/* --Methode-- */
+bool PIWdgMac::IfManaged()
+{
+  return(mPane->IsVisible());
+}
Index: /tags/DPC_V0/Poubelle/PI/piwdgmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwdgmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwdgmac.h	(revision 1307)
@@ -0,0 +1,64 @@
+#ifndef PIWDG_MAC_SEEN
+#define PIWDG_MAC_SEEN
+
+#include "piwdggen.h"
+#include "pippviewadapter.h"
+#include <LPane.h>
+#include <LListener.h>
+
+class PIWdgMac : public PIWdgGen, public LListener {
+public:
+  
+                         PIWdgMac(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIWdgMac();
+  virtual void			 FinishCreate(); // apres avoir installe les sous-vues
+                                       
+  virtual void	         ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void           SetLabel(string const&);
+
+  virtual void           SetSize(int sx, int sy);
+  virtual void           SetPos(int px, int py);
+  virtual void           SetBorderWidth(int /*bw*/) {}
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom);
+  virtual int            XSize();
+  virtual int            YSize();
+  virtual int            XPos();
+  virtual int            YPos();
+  virtual string         Nom()  { return mNom; }
+
+  virtual void           Manage();
+  virtual void           UnManage();
+  virtual bool           IfManaged();
+  virtual bool           IsVisible();
+  
+//  Gestion de copier-coller
+// $$CHECK$$ Pourquoi les noms ont-ils change ???
+// En plus, pour des trucs tout aussi obscurs...
+// Et c'est quoi, typ, qui en plus n'est pas utilise sous X ???
+  virtual bool           ClaimSelection(unsigned int typ=PICP_string);
+  virtual void           SelectionLost();
+  virtual unsigned int   RequestSelection(unsigned int typ=PICP_string);
+  virtual void*          ProvideSelection(unsigned int& typ, unsigned int& len);
+  virtual void           PasteSelection(unsigned int typ, void *, unsigned int l);
+  virtual void           CopyFromSelection(char *, int l);
+  virtual char*          SelectionString(int& len);
+  virtual void           SelectionTransferEnd();
+
+protected:
+  LPane*				 mPane;
+  PIPPViewAdapter*       mAdapter;
+  SPaneInfo				 mAdapterPaneInfo;
+  SViewInfo				 mAdapterViewInfo;
+  SPaneInfo				 mPaneInfo;
+  SViewInfo				 mViewInfo;
+  string                 mNom;
+  
+  friend class PIGraphicMac;
+};
+
+typedef PIWdgMac PIWdg;
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piwdgx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwdgx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwdgx.cc	(revision 1307)
@@ -0,0 +1,1095 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Shell.h>
+#include <X11/Core.h>
+#include <X11/CoreP.h>
+
+#include <X11/keysym.h>
+
+#include <Xm/Xm.h>       // A cause des container XmForm 
+#include <Xm/Form.h>     // Idem 
+
+#include "piwdgx.h"
+#include "picontainerx.h"
+#include "pievthandler.h"
+
+
+// #define DEBUG_PIWdgX
+
+// Quelques variables statiques globales, Connection Display, Top Widget Xt, AppContext Xt ...
+// et leurs fonctions d'acces 
+static SysDWdg  top = NULL;
+static Display * dpy = NULL;
+static GC defgc;
+// static char appname[64];
+static char appclass[64];
+static XtAppContext appctx;
+static int appSzX = 10;
+static int appSzY = 10;
+static int appSzFont = 10;
+static XFontStruct * stdfnt = NULL;
+
+// Variable globale Widget qui possede la selection pour le copier-coller
+static PIWdgX* curselwdg = NULL;    // Le PIWdg qui possede la selection
+
+/* Nouvelle-Fonction */
+XtAppContext* PIXtAppCtx(int& szx, int& szy, int& szf)
+{
+szx = appSzX;  szy = appSzY;
+szf = appSzFont;
+return(&appctx);
+}
+
+/* Nouvelle-Fonction */
+SysDWdg   PIXtTopWdg()
+{
+return (top);
+}
+
+/* Nouvelle-Fonction */
+Display * PIXDisplay()
+{
+return(dpy);
+}
+
+/* Nouvelle-Fonction */
+void PIBeep()
+{
+XBell(dpy, 0);
+return;
+}
+
+/* Nouvelle-Fonction */
+int CStrFrXmStr(XmString xms, char* buff, int nmx)
+/*  Pour recuperer le contenu d'un string Motif  */
+{
+int n,l,m;
+XmStringContext cntx;
+char *txs;
+XmStringDirection dir;
+XmStringCharSet cset;
+Boolean sep;
+
+if (nmx < 2)  return(0);
+n = 0;  m = nmx-1;  buff[0] = buff[m] = '\0';
+XmStringInitContext (&cntx, xms);
+while (m > 0)
+  {
+  if (XmStringGetNextSegment( cntx, &txs, &cset, &dir, &sep) )
+    {
+    l = strlen(txs);
+    if (m < l)  txs[m] = '\0';
+    strcpy(buff+n, txs);
+    n += l;   m -= l;
+    if (sep)  m = -2;
+    XtFree(txs);
+    }
+  else m = -1;
+  }
+
+return(n);
+} 
+
+
+/* --Methode-- */
+PIWdgX::PIWdgX(int narg, char *arg[])
+:PIWdgGen(NULL, "PITopLevel")  
+{
+if (top == NULL)  InitXt(narg, arg);
+sdw = top;
+wmis =  k_wmi_appshell;
+stmng = false;
+mBKleft =  mBKright =  mBKtop =  mBKbottom = PIBK_free;
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::PIWdgX(int , char * [])  this=%lx  top=%lx \n", (long)this, (long)sdw);
+#endif
+}
+
+
+
+/* --Methode-- */
+PIWdgX::PIWdgX(PIContainerGen *par, char *nom, 
+               int sx, int sy, int px, int py)
+:PIWdgGen(par, nom, sx, sy, px, py) 
+{
+sdw = NULL;
+wmis = k_wmi_unknown;
+mBKleft =  mBKright =  mBKtop =  mBKbottom = PIBK_free;
+}
+
+/* --Methode-- */
+int PIWdgX::CreateXtWdg(char *nom, SysDWdgClass wdgcl, SysDWdg pwdg,
+                        int sx, int sy, int px, int py, Arg* oarg, int na)
+{
+Arg  wargs[20];
+int n=0;
+
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::CreateXtWdg(%s) Getting in \n");
+#endif
+
+if (pwdg == NULL)
+  {
+  if (parent == NULL)
+    {
+    if (top == NULL)  InitXt();
+    pwdg = top;
+    }
+  // else pwdg = ((PIContainerX *)parent)->sdw;
+  else pwdg = ((PIWdgX *)parent)->sdw;
+  }
+
+n=0;
+if ((sx >= 0) && (sy >= 0))
+  {
+  XtSetArg(wargs[n],XtNwidth,sx);  n++;
+  XtSetArg(wargs[n],XtNheight,sy);  n++;
+  }
+XtSetArg(wargs[n],XtNx,px);  n++;
+XtSetArg(wargs[n],XtNy,py);  n++;
+
+if (na > 16) { printf("PIWdgX::CreateXtWdg()/Warning: na=%d > Max=16 \n", na);  na = 16; }
+for(int kk=0; kk<na; kk++) { wargs[n] = oarg[kk]; n++; }
+
+if (wdgcl == NULL)  wdgcl = coreWidgetClass;
+
+if ( (wdgcl == topLevelShellWidgetClass) || 
+     (wdgcl == transientShellWidgetClass) ||
+     (wdgcl == overrideShellWidgetClass) )
+  {
+  sdw = XtCreatePopupShell(nom, wdgcl, pwdg, wargs, n);
+  }
+else
+  {
+  sdw = XtCreateWidget(nom, wdgcl, pwdg, wargs, n);
+  }
+
+if (wdgcl == topLevelShellWidgetClass)  wmis = k_wmi_toplevel;
+else if (wdgcl == transientShellWidgetClass)  wmis = k_wmi_transient;
+else if (wdgcl == overrideShellWidgetClass)  wmis = k_wmi_override;
+else wmis = k_wmi_normal ;
+
+stmng = false;
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::CreateXtWdg(%s) this=%lx sdw=%lx pere=%lx wmis=%d\n", nom, 
+       (long)this, (long)sdw, (long)pwdg, wmis);
+#endif
+
+SetBinding(PIBK_free, PIBK_free, PIBK_free, PIBK_free);
+if (parent) parent->ChildAdd(this);
+return(0);
+}
+
+
+/* --Methode-- */
+PIWdgX::~PIWdgX()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::~PIWdgX()  %lx %lx \n", (long)this, (long)sdw);
+#endif
+if (parent) parent->ChildDel(this);
+UnManage();
+if (curselwdg == this)  { SelectionLost(); curselwdg = NULL; }
+if (sdw)  { 
+// Pour gerer la double structure en Widget des PIWindowX
+  if (wmis == k_wmi_normal) XtDestroyWidget(sdw);
+  else if (wmis == k_wmi_cascade) { 
+    SysDWdg pwdg = XtParent(sdw);
+    XtDestroyWidget(sdw);
+    if (pwdg) XtDestroyWidget(pwdg);
+    }
+  }
+}
+
+
+/* --Methode-- */
+void PIWdgX::FinishCreate()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::FinishCreate() ne fait rien ! \n");
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIWdgX::Manage()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::Manage  this=%lx  sdw=%lx \n", (long)this, (long)sdw);
+#endif
+if (!sdw)  return;
+if (wmis != k_wmi_appshell)  XtManageChild(sdw);
+else if (!XtIsRealized(sdw))  XtRealizeWidget(sdw);  
+stmng = true;
+return;
+}
+
+/* --Methode-- */
+void PIWdgX::UnManage()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::UnManage  this=%lx sdw=%lx \n", (long)this, (long)sdw);
+#endif
+if (!sdw)  return;
+if (wmis != k_wmi_appshell) 
+  XtUnmanageChild(sdw);
+stmng = false;
+return;
+}
+
+/* --Methode-- */
+bool PIWdgX::IfManaged()
+{
+return(stmng);
+}
+
+/* --Methode-- */
+bool PIWdgX::IsVisible()
+{
+if ( (XtIsRealized(XtWdg())) &&  
+   ( (this->XtWdg())->core.visible) )  return(true);
+else return(false);       
+}
+
+/* --Methode-- */
+void PIWdgX::Refresh()
+{
+if (XtIsRealized(XtWdg()))
+  XClearArea(XtDisplay(XtWdg()), XtWindow(XtWdg()), 0, 0, 0, 0, True);
+}
+
+/* --Methode-- */
+void PIWdgX::SetSensitive()
+{
+XtSetSensitive(XtWdg(), TRUE);
+}
+
+/* --Methode-- */
+void PIWdgX::SetUnSensitive()
+{
+XtSetSensitive(XtWdg(), FALSE);
+}
+
+/* --Methode-- */
+bool PIWdgX::IfSensitive()
+{
+if (XtIsSensitive(XtWdg()) == TRUE)  return(true);
+else return(false);
+}
+
+/* --Methode-- */
+void PIWdgX::SetSize(int sx, int sy)
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::SetSize  this=%lx  sdw=%lx \n", (long)this, (long)sdw);
+#endif
+
+if (!sdw)  return;
+/*
+Arg  wargs[2];
+XtSetArg(wargs[0],XtNwidth,sx); 
+XtSetArg(wargs[1],XtNheight,sy); 
+XtSetValues(this->sdw, wargs, 2);
+*/
+XtResizeWidget(sdw, sx, sy, BorderWidth());
+
+return;
+} 
+
+/* --Methode-- */
+void PIWdgX::SetPos(int px, int py)
+{
+if (!sdw)  return;
+/*
+Arg  wargs[2];
+XtSetArg(wargs[0],XtNx,px);  
+XtSetArg(wargs[1],XtNy,py);  
+XtSetValues(this->sdw, wargs, 2);
+*/
+XtMoveWidget(sdw, px, py);
+
+return;
+} 
+
+/* --Methode-- */
+void PIWdgX::SetBinding(PIBindingKind left, PIBindingKind top, 
+                        PIBindingKind right, PIBindingKind bottom)
+{
+Arg  wargs[9];
+int n=0;
+if (bindingLock) return;
+if (!sdw)  return;
+if (!parent)  return;
+
+int fbase = 1000 ;  // Valeur de XmNfractionBase des XmForm ds PIContainerX
+int frpos = 0;
+float frac;
+
+n = 0;
+XtSetArg(wargs[n],XmNfractionBase, fbase);  n++;
+XtSetValues(parent->XtWdg(), wargs, n);
+
+// printf(" DEBUG_SetBinding: C-Sz= %d %d - Sz=%d %d , Pos= %d %d \n",  parent->XSize(),
+// parent->YSize(), XSize(), YSize(), XPos(), YPos());
+switch (left)
+  {
+  case PIBK_free : 
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_NONE);  n++;
+    break;
+  case PIBK_fixed :
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNleftOffset, XPos() );  n++;
+    break;
+  case PIBK_elastic :
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_POSITION);  n++;
+    frac = (float)(XPos())/(float)parent->XSize() ;
+    frpos = frac*fbase;
+    XtSetArg(wargs[n],XmNleftPosition, frpos );  n++;
+    break;
+  default :
+    left = PIBK_free;
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_NONE);  n++;
+    break;    
+  }
+ 
+switch (top)
+  {
+  case PIBK_free : 
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_NONE);  n++;
+    break;
+  case PIBK_fixed :
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNtopOffset, YPos() );  n++;
+    break;
+  case PIBK_elastic :
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_POSITION);  n++;
+    frac = (float)(YPos())/(float)parent->YSize() ;
+    frpos = frac*fbase;
+    XtSetArg(wargs[n],XmNtopPosition, frpos );  n++;
+    break;
+  default :
+    top = PIBK_free;
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_NONE);  n++;
+    break;
+  }
+  
+switch (right) 
+  {
+  case PIBK_free : 
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_NONE);  n++;
+    break;
+  case PIBK_fixed :
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNrightOffset, parent->XSize()-(XSize()+XPos()) );  n++;
+    break;
+  case PIBK_elastic :
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_POSITION);  n++;
+    frac = (float)(XPos()+XSize())/(float)parent->XSize() ;
+    frpos = frac*fbase;
+    XtSetArg(wargs[n],XmNrightPosition, frpos );  n++;
+    break;
+  default : 
+    right = PIBK_free;
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_NONE);  n++;
+    break;
+
+  }
+
+switch (bottom) 
+  {
+  case PIBK_free : 
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_NONE);  n++;
+    break;
+  case PIBK_fixed :
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNbottomOffset, parent->YSize()-(YSize()+YPos()) );  n++;
+    break;
+  case PIBK_elastic :
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_POSITION);  n++;
+    frac = (float)(YPos()+YSize())/(float)parent->YSize() ;
+    frpos = frac*fbase;
+    XtSetArg(wargs[n],XmNbottomPosition, frpos );  n++;
+    break;
+  default :
+    bottom =  PIBK_free;
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_NONE);  n++;
+    break;
+  }
+
+XtSetValues(this->sdw, wargs, n);
+mBKleft = left;  mBKright = right;
+mBKtop = top;  mBKbottom = bottom;
+// printf(" Out_SetBinding: C-Sz= %d %d - Sz=%d %d , Pos= %d %d \n",  parent->XSize(),
+// parent->YSize(), XSize(), YSize(), XPos(), YPos());
+
+return;
+}
+
+/* --Methode-- */
+bool PIWdgX::GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                        PIBindingKind& right, PIBindingKind& bottom)
+{
+left = mBKleft;  right = mBKright;
+top = mBKtop;  bottom = mBKbottom;
+return(bindingLock);
+}
+
+/* --Methode-- */
+void PIWdgX::SetBorderWidth(int bw)
+{
+if (!sdw)  return;
+
+Arg  wargs[2];
+int n=0;
+
+XtSetArg(wargs[n],XtNborderWidth,bw);  n++;
+XtSetValues(this->sdw, wargs, n);
+return;
+}
+
+/* --Methode-- */
+void PIWdgX::SetLabel(string const& lab)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)lab.c_str(), XmSTRING_DEFAULT_CHARSET);
+int n=0;
+Arg warg[2];
+
+XtSetArg(warg[n], XmNlabelString, xmstr); n++;
+XtSetValues(XtWdg(), warg, n);
+XmStringFree(xmstr);
+return;
+}
+
+
+
+/* --Methode-- */
+int PIWdgX::XSize()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.width);
+}
+
+/* --Methode-- */
+int PIWdgX::YSize()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.height);
+}
+
+/* --Methode-- */
+int PIWdgX::XPos()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.x);
+}
+
+/* --Methode-- */
+int PIWdgX::YPos()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.y);
+}
+
+
+/* --Methode-- */
+int PIWdgX::BorderWidth()
+{
+if (!sdw)  return(-1);
+Arg  wargs[2];
+int bw;
+XtSetArg(wargs[0],XtNborderWidth, &bw);  
+XtGetValues(this->sdw, wargs, 1);
+return(bw);
+}
+
+/* --Methode-- */
+string PIWdgX::Nom()
+{
+return(XtName(this->sdw));
+}
+
+/* --Methode-- */
+void PIWdgX::GetScreenPos(int & spx, int & spy)
+{
+PIWdgX * wc;
+Display *mdsp;
+Window w, rw, pw, *cw;
+unsigned int ncw;
+Status st;
+int x,y;
+unsigned int bw, l, h, d;
+
+spx = 0;  spy = 0;
+wc = this;
+
+while (wc)
+  { spx += wc->XPos();
+  spy += wc->YPos();  wc = (PIWdgX *)wc->Parent();
+  }
+
+mdsp = XtDisplay(XtWdg());
+w = XtWindow(XtWdg());
+ncw = 0;
+st = XQueryTree(mdsp, w, &rw, &pw, &cw, &ncw);
+if (st) 
+  { XFree(cw);
+  if (pw == rw)  return; }
+
+while (st && (pw != rw))  
+  {
+  w = pw;
+  st = XQueryTree(mdsp, w, &rw, &pw, &cw, &ncw); 
+  if (st)   XFree(cw);
+  XGetGeometry(mdsp, w, &rw, &x, &y, &l, &h, &bw, &d);  
+  spy += y;  spx += x;
+  }  
+return;
+}
+
+
+// Ressources X si non definis 
+static const String fallback_res[22] = {
+"PeidaInt*default*background:                 LightGrey" ,
+"PeidaInt*background:                         LightGrey" ,
+"PeidaInt*bottomShadowColor:                  Black" ,
+"PeidaInt*default*bottomShadowColor:          Black" , 
+"PeidaInt*Foreground:                         Black",
+"PeidaInt*default*Foreground:                 Black",
+"PeidaInt*topShadowColor:                     White",
+"PeidaInt*default*topShadowColor:             White",
+"PeidaInt*borderColor:                        Black",
+"PeidaInt*XmLabel.borderWidth:                0",
+"PeidaInt*XmScrollBar*background:             LightGrey",
+"PeidaInt*XmDrawingArea*background:           Black",
+"PeidaInt*XmPushButton*borderWidth:           0",
+"PeidaInt*XmText*shadowThickness:             2",
+"PeidaInt*XmText*highlightThickness:          0",
+"PeidaInt*XmText*marginHeigt:                 0",
+"PeidaInt*XmText*marginWidth:                 3",
+// "PeidaInt*DefMenubar*XtNwidth:                250",
+// "PeidaInt*DefMenubar*XtNheight:               30",
+"PeidaInt*fontList:           -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1",
+"PeidaInt*default*fontList:   -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1"
+"PeidaInt*fontFamilyName:                     *-courier",   // Pas de blanc apres le nom de font
+"PeidaInt*XmToggleButton*selectColor:         Red",
+""
+};
+
+
+/* --Methode-- */
+int PIWdgX::InitXt(int narg, char *arg[])
+{
+if (top != NULL)  return(0);
+// Initialisation ...  
+int n;
+const char *pc = (const char *)"PIWdgX";
+char **ppc;
+if (narg > 0)  { n = narg, ppc = arg; }
+#if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
+else { ppc = const_cast<char **>(&pc); n = 1; }
+#else
+else { ppc = (char **)(&pc); n = 1; }
+#endif
+//  strncpy(appname, ppc[0], 63); appname[63] = '\0';
+strncpy(appclass,"PeidaInt",63);  appclass[63] = '\0';     
+//  top = XtAppInitialize(&appctx, appclass, NULL, 0, &n, ppc);
+#if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
+top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, const_cast<String*>(fallback_res), NULL);
+#else
+top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, (String*)(fallback_res), NULL);
+#endif
+if (top == NULL) {
+  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize() -> Exit \n");
+  exit(9);
+  }
+dpy = XtDisplay(top);
+if (dpy == NULL)  {
+  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize()/DisplayConnection -> Exit \n");
+  exit(9);
+  }
+
+/*  le GC pour les XCopyArea */
+XGCValues  xgv;
+xgv.function = GXcopy;
+xgv.plane_mask = ~0;
+defgc = XCreateGC (dpy, DefaultRootWindow(dpy), GCFunction | GCPlaneMask, &xgv); 
+
+// On va recuperer la fonte par defaut des composantes Motif
+XtResource res[] = {
+  { (char *)"fontList", (char *)"FontList", XtRString, sizeof(String),
+    0, XtRString, "-*-courier-bold-*-*-*-*-*-*-*-*-*-*-*" }
+};
+
+String fntname;
+XtGetApplicationResources(top, &fntname, res, XtNumber(res), NULL, 0);
+// scr = XDefaultScreen(dpy);
+int count;
+char **list;
+char buff[256];
+strcpy(buff, fntname);
+list = XListFonts(dpy, buff, 15, &count);
+XFreeFontNames(list);
+if (count < 1)  strcpy(buff,"-*-*-*-*-*-*-*-*-*-*-*-*-*-*" );
+stdfnt = XLoadQueryFont(dpy, buff);
+
+// On calcule la taille de la chaine CANCEL (6 caracteres)
+char a[2];
+XCharStruct  ovr;
+int hd, fa, fd, len;  // direction, font-ascent, font-descent len("CANCEL")
+XTextExtents(stdfnt, a, 0, &hd, &fa, &fd, &ovr);
+len = XTextWidth(stdfnt, "CANCEL", 6);
+appSzY = (float)(fa+fd)*1.4+10;  // pour les shadow
+appSzX = (float)len*1.5;
+appSzFont = fa+fd;
+// Taille multiple de 5 pixels 
+if ( (appSzX % 5) != 0 )   appSzX = 5*(appSzX/5 + 1);
+if ( (appSzY % 5) != 0 )   appSzY = 5*(appSzY/5 + 1);
+if(appSzY < 10) appSzY = 10;
+if(appSzX < 30) appSzX = 30;
+
+// printf("PIWdgX::InitXt(Font=%s- %d %d , %d ) SzX,Y= %d %d \n", buff, fa,fd,len,appSzX, appSzY);
+return(0);
+}
+
+/* .................................................................*/
+/* ................... Gestion de Copier/Coller ....................*/
+/* .................................................................*/
+
+// Les Call-Backs Xt
+
+static Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ,
+                                   XtPointer* value, unsigned long* len, int* format);
+
+static void forXt_LoseSelection(Widget w, Atom* sel);
+static void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ);
+static void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ, 
+                                 XtPointer value, unsigned long* len, int* format );
+
+static unsigned int curseltype = PICP_string; // Type de selcetion qu'il peut fournir
+static unsigned int reqseltype = PICP_string; // Type de selection demande
+static unsigned int provseltype = PICP_string; // Type de selection fourni
+
+/* Nouvelle-Fonction */
+Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ,
+                                   XtPointer* value, unsigned long* len, int* format)
+{
+if (*targ != XA_STRING)  return(FALSE);
+if (!curselwdg)  return(FALSE);
+unsigned int ll = 0;
+unsigned int styp = reqseltype;
+*value = curselwdg->ProvideSelection(styp, ll);
+*len=ll;
+*typ = XA_STRING;
+*format = 8;
+provseltype = (styp != 0) ? styp : PICP_string;
+return(TRUE);
+}
+
+/* Nouvelle-Fonction */
+void forXt_LoseSelection(Widget w, Atom* sel)
+{
+if (curselwdg)  curselwdg->SelectionLost();
+curselwdg = NULL; curseltype = PICP_string; 
+}
+
+/* Nouvelle-Fonction */
+void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ)
+{
+if (curselwdg)  curselwdg->SelectionTransferEnd();
+}
+
+/* Nouvelle-Fonction */
+void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ, 
+                                 XtPointer value, unsigned long* len, int* format )
+{
+if ( (value != NULL) && (*len > 0) ) 
+  ((PIWdgX*)usd)->PasteSelection(provseltype, (void*)value, (*len)) ;
+}
+
+
+
+// Gestion de Copier/Coller
+/* --Methode-- */
+bool PIWdgX::ClaimSelection(unsigned int typ)
+// Pour prendre possession du buffer copier/coller
+{
+if (XtOwnSelection(XtWdg(), XA_PRIMARY, PIXGetLastEventTime(), forXt_ConvertSelection, 
+                   forXt_LoseSelection, forXt_DoneSelection) ) {
+#ifdef DEBUG_PIWdgX
+  printf("PIWdgX::ClaimSelection(%d) - OK  (Wdg= %lx)\n", typ, (unsigned long)this);
+#endif
+  curselwdg = this;
+  curseltype = (typ != 0) ? typ : PICP_string;
+  return (true);
+}
+else {
+#ifdef DEBUG_PIWdgX
+  printf("PIWdgX::ClaimSelection() - Probleme (Wdg= %lx)\n", (unsigned long)this);
+#endif
+  curselwdg = NULL;
+  curseltype = PICP_string;
+  return (false);
+}
+}
+
+/* --Methode-- */
+void PIWdgX::SelectionLost()
+// Appele quand le PIWdg perd la possession du buffer copier/coller
+{
+return;
+}
+
+/* --Methode-- */
+unsigned int PIWdgX::RequestSelection(unsigned int typ)
+{
+// Pour demander le contenu du buffer de copier/coller
+#ifdef DEBUG_PIWdgX
+printf("PIWdgX::RequestSelection(%d) (Wdg= %lx - %lx) \n", typ,  
+        (unsigned long)this, (unsigned long)curselwdg);
+#endif
+reqseltype = (typ != 0) ? typ : PICP_string;
+XtGetSelectionValue(XtWdg(), XA_PRIMARY, XA_STRING, forXt_SelectionValue, 
+                    (XtPointer)this, PIXGetLastEventTime());
+return(reqseltype);
+}
+
+static char* rs = NULL;
+
+/* --Methode-- */
+void* PIWdgX::ProvideSelection(unsigned int& typ, unsigned int& len)
+// Le widget doit fournier une l zone memoire contenant la selection
+// en un type donne
+// Renvoie le pointeur de cette zone, sa taille et son typ
+{
+rs = new char[128];
+sprintf(rs, "Test-of-PIWdgX::ProvideSelection(%d)- %lx", typ,(long)rs);
+len = strlen(rs);
+return(rs);
+}
+
+/* --Methode-- */
+void PIWdgX::SelectionTransferEnd()
+{
+delete[] rs;
+}
+
+
+/* --Methode-- */
+void PIWdgX::PasteSelection(unsigned int typ, void *buff, unsigned int l)
+{
+// Methode appele apres que le widget ait fait RequestSelection
+// Le typ de donnees fourni ainsi que les donnees et leur taille 
+// sont en argument 
+#ifdef DEBUG_PIWdgX
+char* mbuff = new char[l+1];
+strncpy(mbuff, (char *)buff, l);
+mbuff[l] = '\0';
+printf("PIWdgX::PasteSelection(%d, %lx, %d) [%s] \n", typ, (long)buff, l, mbuff);
+delete[] mbuff;
+#endif
+return;
+}
+
+//  Copie depuis un PIWdgGen
+void PIWdgX::CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+PIWdgX* wx = (PIWdgX*)wdg;
+XCopyArea(XtDisplay(XtWdg()), XtWindow(wx->XtWdg()), XtWindow(XtWdg()), defgc, ox, oy, 
+          (unsigned int)dx, (unsigned int)dy, x, y);
+}
+
+
+// Declaration de l' EventHandler Xt
+static void evthandler_piwdgx (Widget wdgp, XtPointer, XEvent* evt, Boolean* cont);
+
+
+/* --Methode-- */
+void PIWdgX::AddDrawHandler(PIEventHandler* drwh, bool ad)
+{
+PIWdgGen::AddDrawHandler(drwh, ad);
+XtInsertEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this, XtListTail);
+}
+
+/* --Methode-- */
+void PIWdgX::RemoveDrawHandler(PIEventHandler* drwh)
+{
+PIWdgGen::RemoveDrawHandler(drwh);
+if (mEHlist.size() <= 0) XtRemoveEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this);
+}
+
+/* --Methode-- */
+void PIWdgX::AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad)
+{
+PIWdgGen::AddEventHandler(evh, evtmask, ad);
+EventMask mask = 0;
+// if (evtmask & PIEvent_Resize)  pas traite pour le moment
+if (evtmask & PIEvent_Enter)  mask |= EnterNotify;
+if (evtmask & PIEvent_Leave)  mask |= LeaveNotify;
+if (evtmask & PIEvent_But1Press)  mask |= ButtonPressMask;
+if (evtmask & PIEvent_But1Release)  mask |= ButtonReleaseMask;
+if (evtmask & PIEvent_But2Press)  mask |= ButtonPressMask;
+if (evtmask & PIEvent_But2Release)  mask |= ButtonReleaseMask;
+if (evtmask & PIEvent_But3Press)  mask |= ButtonPressMask;
+if (evtmask & PIEvent_But3Release)  mask |= ButtonReleaseMask;
+if (evtmask & PIEvent_PtrMove)  mask |= PointerMotionHintMask;
+if (evtmask & PIEvent_Ptr1Move)  mask |= (PointerMotionHintMask | Button1MotionMask);
+if (evtmask & PIEvent_Ptr2Move)  mask |= (PointerMotionHintMask | Button2MotionMask);
+if (evtmask & PIEvent_Ptr3Move)  mask |= (PointerMotionHintMask | Button3MotionMask);
+if (evtmask & PIEvent_Keyboard)  mask |= KeyPressMask;
+printf("PIWdgX::AddEventHandler() Mask = %lx \n", (long)mask);
+XtInsertEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this, XtListTail);
+}
+
+/* --Methode-- */
+void PIWdgX::RemoveEventHandler(PIEventHandler* evh)
+{
+PIWdgGen::RemoveEventHandler(evh);
+if (mEHlist.size() > 0) return; 
+EventMask mask = EnterNotify;
+mask |= LeaveNotify;
+mask |= ButtonPressMask;
+mask |= ButtonRelease;
+mask |= ButtonPressMask;
+mask |= ButtonRelease;
+mask |= ButtonPressMask;
+mask |= ButtonRelease;
+mask |= PointerMotionHintMask;
+mask |= (PointerMotionHintMask | Button1MotionMask);
+mask |= (PointerMotionHintMask | Button2MotionMask);
+mask |= (PointerMotionHintMask | Button3MotionMask);
+mask |= KeyPressMask;
+XtRemoveEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this);
+}
+
+/* --Methode-- */
+void PIWdgX::CallDrawHandlers(int x0, int y0, int dx, int dy)
+{
+PIGraphicWin* g = new PIGraphicWin(this);
+PIEventHandler* eh;
+list<EvHand>::iterator it;
+for(it= mDHlist.begin(); it != mDHlist.end(); it++) { 
+  eh = (*it).evh;
+  eh->SetCurrentWdg(this);
+  eh->SetEventInfo(PIEvent_Draw, x0, y0, 0, PIKM_Blank, 0);
+  g->SaveGraphicAtt();
+  eh->Draw(g, x0, y0, dx, dy);
+  g->RestoreGraphicAtt();
+  }
+delete g;
+}
+
+/* --Methode-- */
+void PIWdgX::CallEventHandlers(unsigned long evt, int px, int py,
+                               int k, int km, unsigned long tm)
+{
+PIEventHandler* eh;
+list<EvHand>::iterator it;
+for(it= mEHlist.begin(); it != mEHlist.end(); it++) {
+  if (!((*it).mask & evt))  continue; 
+  eh = (*it).evh;
+  eh->SetCurrentWdg(this);
+  eh->SetEventInfo((PIEventMask)evt, px, py, k, (PIKeyModifier)km, tm);
+  eh->ProcessEvent();
+  }
+}
+
+
+// -------   Event Handler Xt ----------
+/* Nouvelle-Fonction */
+void evthandler_piwdgx (Widget wdgp, XtPointer usd, 
+                             XEvent* evt, Boolean* cont)
+{
+
+*cont = true ; 
+PIWdgX* wx = (PIWdgX*)usd;
+PIEventMask evm = PIEvent_None;
+PIKeyModifier kmod = PIKM_Blank;
+
+switch (evt->type) {
+  case Expose :
+    wx->CallDrawHandlers(evt->xexpose.x , evt->xexpose.y , evt->xexpose.width , evt->xexpose.height);
+    break;
+  case EnterNotify : 
+    wx->CallEventHandlers(PIEvent_Enter, evt->xcrossing.x, evt->xcrossing.y, 0, 
+                          PIKM_Blank, evt->xcrossing.time);
+    PIXSetLastEventTimeSerial(evt->xcrossing.time, evt->xcrossing.serial);
+    break;
+
+  case LeaveNotify : 
+    wx->CallEventHandlers(PIEvent_Leave, evt->xcrossing.x, evt->xcrossing.y, 0, 
+                          PIKM_Blank, evt->xcrossing.time);
+    PIXSetLastEventTimeSerial(evt->xcrossing.time, evt->xcrossing.serial);
+  break;
+
+  case ButtonPress :
+    if  (evt->xbutton.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xbutton.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xbutton.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    if (evt->xbutton.button == 1) evm = PIEvent_But1Press;
+    else if (evt->xbutton.button == 2) evm = PIEvent_But2Press;
+    else if (evt->xbutton.button == 3) evm = PIEvent_But3Press;
+    wx->CallEventHandlers(evm, evt->xbutton.x, evt->xbutton.y, 0, 
+                          kmod, evt->xbutton.time);
+    PIXSetLastEventTimeSerial(evt->xbutton.time, evt->xbutton.serial);
+  break;
+
+  case ButtonRelease :
+    if  (evt->xbutton.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xbutton.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xbutton.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    if (evt->xbutton.button == 1) evm = PIEvent_But1Release;
+    else if (evt->xbutton.button == 2) evm = PIEvent_But2Release;
+    else if (evt->xbutton.button == 3) evm = PIEvent_But3Release;
+
+    wx->CallEventHandlers(evm, evt->xbutton.x, evt->xbutton.y, 0, 
+                          kmod, evt->xbutton.time);
+    PIXSetLastEventTimeSerial(evt->xbutton.time, evt->xbutton.serial);
+  break;
+
+  case MotionNotify :
+    {
+    int xw, yw, xr, yr;
+    unsigned int key_but;
+    Window rw, cw;
+    if ( evt->xmotion.is_hint == NotifyHint ) { 
+      if (!XQueryPointer( XtDisplay(wdgp), evt->xmotion.window, &rw, &cw,
+                  &xr, &yr, &xw, &yw, &key_but) ) break ;
+      }
+    else { key_but =  evt->xmotion.state ; xw = evt->xmotion.x;  yw = evt->xmotion.y; }
+    if  (key_but & Button1Mask ) evm = PIEvent_Ptr1Move;
+    else  if (key_but & Button2Mask ) evm = PIEvent_Ptr2Move;
+    else  if (key_but & Button3Mask ) evm = PIEvent_Ptr3Move;
+    else if ( !(key_but & (Button4Mask|Button5Mask)) )  evm = PIEvent_PtrMove;
+
+    if  (key_but & ShiftMask)   kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (key_but & ControlMask) kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (key_but & Mod1Mask)    kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+
+    wx->CallEventHandlers(evm, xw, yw, 0, kmod, evt->xbutton.time);
+    PIXSetLastEventTimeSerial(evt->xmotion.time, evt->xmotion.serial);    
+    }
+  break;
+
+  case KeyPress :
+    {
+    XComposeStatus cs;
+    KeySym key;
+    char buf[10];
+    int i,nc,rkey;
+
+  
+    kmod = PIKM_Blank;
+    nc = XLookupString(&(evt->xkey), buf, 10, &key, &cs);
+
+    if  (evt->xkey.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xkey.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xkey.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    switch (key) {
+      case XK_Return :
+        rkey = PIK_Return;
+      break;
+      case XK_KP_Enter :
+        rkey = PIK_Enter;
+      break;
+      case XK_Up :
+        rkey = PIK_Up;
+      break;
+      case XK_Down :
+        rkey = PIK_Down;
+      break;
+      case XK_Left :
+        rkey = PIK_Left;
+      break;
+      case XK_Right :
+        rkey = PIK_Right;
+      break;
+      case XK_Prior :
+        rkey = PIK_Previous;
+      break;
+      case XK_Next :
+        rkey = PIK_Next;
+      break;
+      default :
+        rkey = 0;
+      break;
+    }
+    if (rkey > 0)  wx->CallEventHandlers(PIEvent_Keyboard, evt->xkey.y, evt->xkey.x, 
+                                         rkey, kmod, evt->xkey.time);
+    else for(i=0; i<nc; i++)  
+            wx->CallEventHandlers(PIEvent_Keyboard, evt->xkey.y, evt->xkey.x, 
+                                 (int)(buf[i]), kmod, evt->xkey.time);
+    PIXSetLastEventTimeSerial(evt->xkey.time, evt->xkey.serial);    
+
+  }
+  break;
+}
+
+return;
+}
+
+
+// -------- La classe PIScreenBuffer ----------
+/* --Methode-- */
+PIScreenBuffer::PIScreenBuffer(int sx, int sy)
+{
+if (sx < 1) sx = 1;
+if (sy < 1) sy = 1;
+mSx = sx;  mSy = sy;
+Display * dsx = PIXDisplay();
+Window rw = DefaultRootWindow(dsx);
+xScrbuff = XCreatePixmap(dsx, rw, sx, sy, DefaultDepth(dsx, DefaultScreen(dsx)) );
+}
+/* --Methode-- */
+PIScreenBuffer::~PIScreenBuffer()
+{
+XFreePixmap(PIXDisplay(),xScrbuff); 
+}
+
+/* --Methode-- */
+int PIScreenBuffer::XSize()
+{
+return(mSx);
+}
+
+/* --Methode-- */
+int PIScreenBuffer::YSize()
+{
+return(mSx);
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+XCopyArea(XtDisplay(wdg->XtWdg()), XtWindow(wdg->XtWdg()), XScrBuffer(), defgc, ox, oy, 
+          (unsigned int)dx, (unsigned int)dy, x, y);
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+XCopyArea(XtDisplay(wdg->XtWdg()), XScrBuffer(), XtWindow(wdg->XtWdg()), defgc, ox, oy, 
+          (unsigned int)dx, (unsigned int)dy, x, y);
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y)
+{
+
+XCopyArea(PIXDisplay(), grb->XScrBuffer(), XScrBuffer(), defgc, ox, oy, 
+          (unsigned int)dx, (unsigned int)dy, x, y);
+}
Index: /tags/DPC_V0/Poubelle/PI/piwdgx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwdgx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwdgx.h	(revision 1307)
@@ -0,0 +1,143 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIWdgX
+//                                    Reza 10/95            
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIWDG_X_SEEN
+#define PIWDG_X_SEEN
+
+#include <X11/Xlib.h>
+#include <X11/Intrinsic.h>
+
+#include "piwdggen.h"
+
+typedef Widget SysDWdg;
+typedef WidgetClass SysDWdgClass;
+
+
+class PIWdgX : public PIWdgGen 
+{
+public:
+// Les methodes ...
+  		  PIWdgX(int narg=0, char *arg[]=NULL);
+  		  PIWdgX(PIContainerGen *par, char *nom, 
+         		 int sx=10, int sy=10, int px=0, int py=0);
+
+  virtual 	 ~PIWdgX();
+
+  virtual void	 FinishCreate(); // apres avoir installe les sous-vues
+
+  virtual void   SetSize(int sx, int sy);
+  virtual void   SetPos(int px, int py);
+  virtual void   SetLabel(string const & lab);
+
+
+  virtual void   SetBinding(PIBindingKind left, PIBindingKind top, 
+                            PIBindingKind right, PIBindingKind bottom);
+  virtual bool   GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                            PIBindingKind& right, PIBindingKind& bottom);
+
+  virtual int    XSize();
+  virtual int    YSize();
+  virtual int    XPos();
+  virtual int    YPos();
+
+  virtual string Nom();  
+  virtual void   GetScreenPos(int & spx, int & spy);
+
+  virtual void   Manage();
+  virtual void   UnManage();
+  virtual bool   IfManaged();
+  virtual bool   IsVisible();
+
+//  Fonction qui doit etre appelee pour rafraichir la fenetre 
+  virtual void       	 Refresh();
+
+//  Pour rendre un composant graphique (PIWdg) sensible/insensible 
+  virtual void           SetSensitive();
+  virtual void           SetUnSensitive();
+  virtual bool           IfSensitive();
+
+//  Gestion de copier-coller
+  virtual bool           ClaimSelection(unsigned int typ=PICP_string);
+  virtual void           SelectionLost();
+  virtual unsigned int   RequestSelection(unsigned int typ=PICP_string);
+  virtual void*          ProvideSelection(unsigned int& typ, unsigned int& len);
+  virtual void           SelectionTransferEnd();
+  virtual void           PasteSelection(unsigned int typ, void *, unsigned int l);
+
+//  Copie depuis un PIWdgGen
+  virtual void		 CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y);
+
+//  Gestion des EventHandler
+  virtual void		 AddDrawHandler(PIEventHandler* drwh, bool ad=false);
+  virtual void		 RemoveDrawHandler(PIEventHandler* drwh);
+  virtual void		 AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
+  virtual void		 RemoveEventHandler(PIEventHandler* evh);
+
+// En public, pour permettre l'acces depuis call-back Xt
+  virtual void		 CallDrawHandlers(int x0, int y0, int dx, int dy); 
+  virtual void		 CallEventHandlers(unsigned long evt, int px, int py,
+                                           int k, int km, unsigned long tm);
+
+//  Usage limite a a la version X11
+  inline SysDWdg XtWdg() const {return(sdw); }; 
+  inline SysDWdg& XtWdg() {return(sdw); }; 
+  int 		CreateXtWdg(char *nom, SysDWdgClass wdgcl=NULL, SysDWdg pwdg=NULL,
+                  int sx=10, int sy=10, int px=0, int py=0, Arg* oarg=NULL, int na=0);
+  int   	BorderWidth();
+  void  	SetBorderWidth(int bw);
+
+protected:
+// Definit le type de Widget, en particulier pour la gestion des feneteres de haut niveau
+// k_wmi_cascade : Widget cree en cascade d'un autre (Exemple pour PIWIndowX)
+  enum WmIntState { k_wmi_unknown=0,
+                    k_wmi_normal=1, k_wmi_toplevel=2, 
+                    k_wmi_transient=3, k_wmi_override=4,
+                    k_wmi_appshell=5, k_wmi_cascade=6 };
+
+  int 		InitXt(int narg=0, char *arg[]=NULL); 
+
+  SysDWdg sdw;
+  WmIntState wmis;
+  bool stmng;
+  PIBindingKind mBKleft, mBKright, mBKtop, mBKbottom;
+};
+
+typedef PIWdgX PIWdg;
+
+// -------- La classe PIScreenBuffer ----------
+class PIScreenBuffer {
+public :
+  			PIScreenBuffer(int sx, int sy);
+  virtual		~PIScreenBuffer();
+
+  virtual int         	XSize();
+  virtual int         	YSize();
+  virtual  void 	CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+  virtual  void 	CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+  virtual  void 	CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
+
+//  Acces au Drawable X 
+  inline Pixmap		XScrBuffer() { return(xScrbuff); }
+protected :
+  Pixmap xScrbuff;
+  int mSx, mSy;
+};
+
+
+// Utile pour avoir acces au Display et Screen X ...
+SysDWdg   PIXtTopWdg();
+XtAppContext* PIXtAppCtx(int& szx, int& szy, int& szf);
+Display * PIXDisplay();
+#define  PIXScreen()  DefaultScreen(PIXDisplay()) 
+Time PIXGetLastEventTime();
+unsigned long PIXGetLastEventSerial();
+void PIXSetLastEventTimeSerial(Time t, unsigned long ser);
+void PIXGetLastEventInfo(unsigned int& st, Time& t);
+
+
+#endif/* PIWDGX_SEEN */
+
+
+
Index: /tags/DPC_V0/Poubelle/PI/piwindowgen.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwindowgen.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwindowgen.cc	(revision 1307)
@@ -0,0 +1,106 @@
+//  Classe de base pour les fenêtre de premier niveau
+//  dans les programmes graphiques interactives
+//
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "piwindowgen.h"
+#include "psfile.h"
+
+//++
+// Class	PIWindow
+// Lib		PI
+// include	piwindowgen.h
+//
+//	Classe de conteneur (dérivant de *PIContainer") spécialisée pour 
+//	la création des fenêtres de premier niveau, gérée par l'application
+//	"WindowManager". La classe "PIWindow" a  implementation dépendante 
+//	du systeme utilisé (Mac, XWindow, ...). La classe "PIWindowGen" est 
+//	la classe qui définit l'interface, et ne pas doit être instanciée 
+//	directement (Méthodes virtuelles pures). Les objets instanciés sont 
+//	de la classes "PIWindow" et le fichier entête correspondant est 
+//	"PIWIN_H" défini dans "pisysdep.h"
+//--
+//++
+// Links	Parents
+// PIContainer
+//--
+//++
+// Titre	Constructeur
+//--
+//++
+// PIWindowGen(PIMsgHandler* par, char *nom, PIWindowKind k=PIWK_normal, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'une fenêtre de haut niveau. La variable "PIWindowKind k"  contrôle
+//	le comportement de l'objet vis à vis de l'application WindowManager. Le comportement
+//	exacte, ainsi que l'apparence graphique dépend de la plateforme et du WindowManager
+//	utilisés. "par" est le l'objet "PIMsgHandler" dont dépend la fenêtre, en général un objet
+//	de la classe "PIApplication". "nom" désigne le nom, "sx,sy" la taille et 
+//	"px,py" la position de l'objet.
+//	- "PIWK_normal" : fenêtre ordinaire
+//	- "PIWK_floating" : fenêtre qui reste en avant plan 
+//	- "PIWK_dialog" : fenêtre de dialogue 
+//	- "PIWK_transient" : fenêtre apparaissant an avant plan, sans barre de contrôle 
+// long kind()
+//	Renvoie le type de la classe de l'objet ("=PIWindowGen::ClassId") pour cette classe.
+//--
+
+//++
+// Titre	Méthodes
+//--
+//++
+// void  AutoHideOnClose(bool ahc=true)
+//	Contrôle le comportement par défaut de l'objet quand la fenêtre est fermée
+//	à travers le WindowManager. si "ahc=true", "Hide()" est appelé. 
+//	Le message de l'objet avec le qualificatif "PIMsg_Closë est transmis
+//	au "PIMsgHandler" parent.
+// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
+//	Définit une nouvelle page et appelle la méthode "PSPrint()" pour tous les
+//	objets "PIWdg" contenus dans la fenêtre.
+//--
+
+
+/* --Methode-- */
+PIWindowGen::PIWindowGen(PIMsgHandler *par, char *nom, PIWindowKind k, 
+                         int sx, int sy, int px, int py)
+: PIContainer(NULL, nom, sx, sy, px, py), mWtyp(k)
+{
+  SetMsgParent(par);
+  AutoHideOnClose();
+}
+
+
+/* --Methode-- */
+PIWindowGen::~PIWindowGen()
+{}
+
+/* --Methode-- */
+void PIWindowGen::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+if (!psf) return;
+//int ori;
+//ori = (XSize() > YSize()) ? LANDSCAPE : PORTRAIT ;
+psf->NewPage((float)XSize(), (float)YSize(),PI_Auto);
+PIContainerGen::PSPrint(psf, ofx, ofy);
+}
+
+
+/* --Methode-- */
+void PIWindowGen::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+/*  On intercepte le message Active, et Close avant de les renvoyer */
+/*  avec un message ActiveWdg de la part de la fenetre              */
+{
+if (ModMsg(msg) == PIMsg_ResizeRequest) { 
+  // On change la taille de la fenetre - data est un pointeur sur entier
+  // data[0] represente l'increment (positif ou negatif) en X, data[1] en Y
+  int* nsz = (int*) data;
+  SetSize(XSize()+nsz[0], YSize()+nsz[1]);
+  return;
+  }
+else if ((msg == BuildMsg(Msg(), PIMsg_Close)) && (sender == this) && mAHC) 
+  Hide();   // Action par defaut en cas de MsgClose.
+else if (ModMsg(msg) == PIMsg_Active)
+  Send(Msg(),PIMsg_Active);
+
+ReSend(msg, sender, data);
+return;  
+}
Index: /tags/DPC_V0/Poubelle/PI/piwindowgen.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwindowgen.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwindowgen.h	(revision 1307)
@@ -0,0 +1,36 @@
+#ifndef PIWINDOWGEN_H_SEEN
+#define PIWINDOWGEN_H_SEEN
+
+#include "pisysdep.h"
+
+#include PICONT_H
+
+enum PIWindowKind {
+  PIWK_normal = 0,
+  PIWK_dialog = 1,
+  PIWK_transient = 2,
+  PIWK_floating = 3
+};
+
+class PIWindowGen : public PIContainer {
+public:
+  enum {ClassId = 1550};
+		    PIWindowGen(PIMsgHandler* par, char *nom, PIWindowKind k=PIWK_normal,
+                                int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PIWindowGen();
+
+  virtual long      kind() {return ClassId; }
+
+  virtual void      PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+  inline  void      AutoHideOnClose(bool ahc=true) { mAHC = ahc; }
+
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  
+protected:  
+  PIWindowKind	       mWtyp;
+  bool                 mAHC;
+};
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piwindowmac.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwindowmac.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwindowmac.cc	(revision 1307)
@@ -0,0 +1,91 @@
+#include "piwindowmac.h"
+#include "pippwindowmac.h"
+
+PIWindowMac::PIWindowMac(PIMsgHandler *par, char *nom, PIWindowKind k, int sx, int sy, int px, int py)
+: PIWindowGen(par, nom, k, sx, sy, px, py), finalized(false)
+{
+	delete mPane;
+	delete mAdapter;
+	mAdapter = NULL;
+	mWindowInfo.WINDid = 1000+k;
+	mWindowInfo.attributes = windAttr_EraseOnUpdate |
+	                         windAttr_Targetable |
+	                         windAttr_Enabled;
+	switch (k) {
+	 case PIWK_normal:
+	  mWindowInfo.attributes |= windAttr_Regular | 
+	                            windAttr_TitleBar |
+	                            windAttr_SizeBox |
+	                            windAttr_CloseBox |
+	                            windAttr_Resizable;
+	  mWindowInfo.layer = windLayer_Regular;
+	  break;
+	 case PIWK_dialog:
+	  mWindowInfo.attributes |= windAttr_Modal;
+	  mWindowInfo.layer = windLayer_Modal;
+	  break;
+	 case PIWK_floating:
+	  mWindowInfo.attributes |= windAttr_Floating |
+	                            windAttr_HideOnSuspend;
+	  mWindowInfo.layer = windLayer_Floating;
+	  break;
+	}
+	mWindowInfo.minimumWidth = 30;
+	mWindowInfo.minimumHeight = 30;
+	mWindowInfo.maximumWidth = 32000;
+	mWindowInfo.maximumHeight = 32000;
+	mWindowInfo.standardSize.width = sx;
+	mWindowInfo.standardSize.height = sy;
+	mWindowInfo.userCon = 0;
+	
+	//mPane = new LWindow(mWindowInfo);
+	mPane = LWindow::CreateWindow(1000+k,LCommander::GetTopCommander());
+    ((PIPPWindowMac*)mPane)->myPIWindow = this; 
+	Rect r = {py, px, py+sy, px+sx};
+    ((LWindow*) mPane)->DoSetBounds(r);
+    SetLabel(nom);
+    //((LWindow*) mPane)->SetSuperCommander(LCommander::GetTopCommander());
+}
+
+
+PIWindowMac::~PIWindowMac()
+{}
+
+
+void PIWindowMac::Show()
+{
+  if (!finalized) {
+    FinishCreate();
+    finalized = true;
+  }
+  PIWindowGen::Show();
+}
+
+void
+PIWindowMac::SetSize(int sx, int sy)
+{
+   ((LWindow*) mPane)->ResizeWindowTo(sx, sy);
+}
+
+void
+PIWindowMac::SetPos(int px, int py)
+{
+   ((LWindow*) mPane)->MoveWindowBy(px-XPos(), py-YPos());
+}
+
+int
+PIWindowMac::XPos()
+{
+	Rect	theBounds;
+	((LWindow*) mPane)->GetGlobalBounds(theBounds);
+    return theBounds.left;
+}
+
+int
+PIWindowMac::YPos()
+{
+	Rect	theBounds;
+	((LWindow*) mPane)->GetGlobalBounds(theBounds);
+    return theBounds.top;
+}
+
Index: /tags/DPC_V0/Poubelle/PI/piwindowmac.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwindowmac.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwindowmac.h	(revision 1307)
@@ -0,0 +1,26 @@
+#ifndef PIWINDOWMAC_H_SEEN
+#define PIWINDOWMAC_H_SEEN
+
+#include "piwindowgen.h"
+#include "pisysdep.h"
+#include <LWindow.h>
+
+class PIWindowMac : public PIWindowGen {
+public:
+                         PIWindowMac(PIMsgHandler *par, char *nom, PIWindowKind k=PIWK_normal,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIWindowMac();
+  virtual void           Show();
+  virtual void           SetSize(int sx, int sy);
+  virtual void           SetPos(int px, int py);
+  virtual int            XPos();
+  virtual int            YPos();
+
+protected:
+  SWindowInfo			  mWindowInfo;
+  Boolean				  finalized;
+};
+
+typedef PIWindowMac PIWindow;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PI/piwindowx.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwindowx.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwindowx.cc	(revision 1307)
@@ -0,0 +1,170 @@
+#include <stdio.h>
+
+#include "piwindowx.h"
+
+#include <X11/Xlib.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Shell.h>
+#include <Xm/Form.h>
+
+/* Fonctions (Callback et action) pour traiter le message Close de WM  */
+
+/* Nouvelle-Fonction */
+static void popdwn_cb(Widget /*w*/, XtPointer *usd,  XtPointer * )
+{
+PIWindowX * dw = (PIWindowX *) usd;
+dw->Process(dw->BuildMsg(dw->Msg(),PIMsg_Close), dw, NULL) ;
+}
+
+
+/* Nouvelle-Fonction */
+static int fgactl = 0;
+
+static void CloseWindow (Widget w, XEvent*, String*,Cardinal*)
+{
+XtCallCallbacks(w,  XtNpopdownCallback, NULL);
+}
+
+
+
+/* --Methode-- */
+PIWindowX::PIWindowX(PIMsgHandler *par, char *nom, PIWindowKind k, 
+                     int sx, int sy, int px, int py)
+: PIWindowGen(par, nom, k, -1, -1, 0, 0)
+{
+XtTranslations trans;
+
+pwm = new PIWdgX(NULL, nom, sx, sy, px, py);
+
+switch (k)
+  {
+  case PIWK_normal :
+  case PIWK_floating :
+    pwm->CreateXtWdg(nom, topLevelShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  case PIWK_dialog :
+    pwm->CreateXtWdg(nom, transientShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  case PIWK_transient :
+    pwm->CreateXtWdg(nom, overrideShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  }
+
+
+/*  Il faut "attraper" l'action close, genere par le window-manager       */
+/*  2 actions sont necessaires, installation d'une action (CloseWindow()) */
+/*  et j'utilise ensuite un callback ds CloseWindow()                     */
+/*  Il faut aussi desactiver l'action de destruction du widget par defaut */
+/*  (XtSetArg(warg, XmNdeleteResponse, ...                                */
+/*  Attention, voir la fonction Show(), pour l'appel a XSetWMProptocols() */
+/*  Pour une fenetre donnee, on peut recuperer les Map, UnMap, Destroy,   */
+/*  etc... il faut appeler XtAddEventHandler( w, Mask, ...)               */
+/*    Mask =  StructureNotifyMask | SubstructureNotifyMask                */
+
+
+
+if ((k == PIWK_normal) || (k == PIWK_floating) || (k == PIWK_dialog))
+  { 
+  if (k == PIWK_dialog)  AutoHideOnClose(false);
+  /* XtAddEventHandler(pwm->XtWdg(), StructureNotifyMask | SubstructureNotifyMask, 
+                  FALSE, wmaction_evthandler, this);*/
+
+  XtAddCallback(pwm->XtWdg(), XtNpopdownCallback,
+                (XtCallbackProc)popdwn_cb, (XtPointer)this);
+
+  if (fgactl == 0) 
+    { 
+    XtActionsRec desact = {(char *)"CloseWindow" ,CloseWindow};
+    int szx, szy, szf;
+    XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+    XtAppAddActions(*appctx, &desact, 1);  fgactl = 1; 
+    }
+
+  trans = XtParseTranslationTable("<Message>WM_PROTOCOLS:CloseWindow()");
+  XtOverrideTranslations(pwm->XtWdg() , trans);
+  Arg warg[2];
+  XtSetArg(warg[0], XmNdeleteResponse, XmDO_NOTHING);
+  XtSetValues(pwm->XtWdg(), warg, 1);
+  }
+
+CreateXtWdg(nom, xmFormWidgetClass, pwm->XtWdg(), sx, sy, 0, 0);
+wmis = k_wmi_cascade;
+}
+
+/* --Methode-- */
+PIWindowX::~PIWindowX()
+{
+Hide();
+delete pwm;
+}
+
+/* --Methode-- */
+void PIWindowX::SetBinding(PIBindingKind /*left*/, PIBindingKind /*top*/, 
+                           PIBindingKind /*right*/, PIBindingKind /*bottom*/)
+{
+// On ne doit rien faire pour les fenetres 
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::SetSize(int sx, int sy)
+{
+pwm->SetSize(sx, sy);
+PIWdgX::SetSize(sx, sy);
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::SetPos(int px, int py)
+{
+pwm->SetPos(px, py);
+PIWdgX::SetPos(px, py);
+return;
+}
+
+
+/* --Methode-- */
+void PIWindowX::Show()
+{
+int fgr = 0;
+Display *mdsp;
+
+mdsp = XtDisplay(pwm->XtWdg());
+
+PIContainerGen::Show();
+// Manage();  $CHECK$ Ca ne doit plus etre necessaire Reza 9/7/97
+if (!XtIsRealized(pwm->XtWdg()))  fgr = 1;
+pwm->Manage();
+if (fgr) 
+  {
+  Atom wmd;
+  if ((mWtyp == PIWK_normal) || (mWtyp == PIWK_floating) || (mWtyp == PIWK_dialog))
+    { 
+    wmd = XInternAtom(mdsp, "WM_DELETE_WINDOW",False);
+    XSetWMProtocols(mdsp, XtWindow(pwm->XtWdg()), &wmd, 1);
+    }
+  else 
+    XSetTransientForHint(mdsp, XtWindow(PIXtTopWdg()), XtWindow(pwm->XtWdg()));
+  //  Pour faire les actions sur les fenetres X, sinon fenetre pas cree 
+  PIContainerGen::FinishCreate();
+  }
+
+// XRaiseWindow est necessaire, sinon la fenetre passe des fois derriere ...
+if (mWtyp == PIWK_transient)  
+  XRaiseWindow(mdsp, XtWindow(pwm->XtWdg()));
+ 
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::Hide()
+{
+PIWindowGen::Hide();
+// UnManage();  $CHECK$ Ca ne doit plus etre necessaire Reza 9/7/97
+pwm->UnManage();
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/piwindowx.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/piwindowx.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/piwindowx.h	(revision 1307)
@@ -0,0 +1,29 @@
+#ifndef PIWINDOWX_H_SEEN
+#define PIWINDOWX_H_SEEN
+
+#include "piwindowgen.h"
+#include "pisysdep.h"
+
+
+class PIWindowX : public PIWindowGen {
+public:
+                         PIWindowX(PIMsgHandler *par, char *nom, PIWindowKind k=PIWK_normal,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIWindowX();
+  
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom);
+  virtual void           SetSize(int sx, int sy);
+  virtual void           SetPos(int px, int py);  
+
+  virtual void           Show();
+  virtual void           Hide();
+
+protected:
+  PIWdgX   *pwm;
+
+};
+
+typedef PIWindowX PIWindow;
+
+#endif   /* PIWINDOWX_H_SEEN  */
Index: /tags/DPC_V0/Poubelle/PI/pixtbase.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pixtbase.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pixtbase.cc	(revision 1307)
@@ -0,0 +1,331 @@
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/CoreP.h>
+
+#include <X11/keysym.h>
+
+#include "pixtbaseP.h"
+#include "pixtbase.h"
+
+// #define DEBUG_PIXTB
+
+ 
+//  ------- Pb de gestion du focus-keyboard  Motif-PIBaseWdg -------
+// ** Note 30/04/98  Reza
+// Il y un probleme d'attribution du focus-keyboard entre Widget Motif et
+// PIBaseWdg (Widget PIXtBase) les Attributs XmNnavigationType et XmNtraversalOn
+// ont ete desactives pour les StdWdgX - Le probleme n'a pas pu etre resolu
+// meme en attribuant les attributs  XmNnavigationType XmNtraversalOn 
+// (et XmNsensitive) a PIXtBase, ni en utilisant 
+// XSetInputFocus(XtDisplay (wdgp), XtWindow(wdgp), RevertToParent, evt->xbutton.time)
+// Solution pour le moment :
+//  XmNnavigationType =XmNONE et XmNtraversalOn=FALSE pour les PIStdWdgX 
+// sauf pour PIText ou XmNtraversalOn=TRUE
+
+
+/*  Construction du widget Xt PIXtBase   */
+
+static void     init_class_pixtbase(void);
+
+static void     init_pixtbase    (Widget, Widget, ArgList, Cardinal*);
+static void     destroy_pixtbase (Widget);
+static void     resize_pixtbase  (Widget);
+static void     expose_pixtbase  (Widget, XEvent*, Region);
+
+
+// Si on ne veut pas utiliser XtInheritAcceptFocus
+// static Boolean  acceptfocus_pixtbase   (Widget, Time* ); 
+
+
+static XtResource resources[] ={
+  {PIXNobject ,(char *)"Object", XtRPointer, sizeof(XtRPointer),
+   XtOffset(PIXtBaseWidget,  pixtbase.objet), XtRImmediate, (XtPointer)0},
+};
+
+
+PIXtBaseClassRec  piXtBaseClassRec = {
+/* Core Class Part */
+{
+
+(WidgetClass) &coreClassRec,    /* pointer to superclass ClassRec   */
+(char*)"PIXtBase",         	/* widget resource class name       */
+sizeof(PIXtBaseRec),	        /* size in bytes of widget record   */
+init_class_pixtbase,            /* class_initialize                 */
+NULL, 			        /* dynamic initialization           */
+FALSE,       		        /* has class been initialized?      */
+init_pixtbase,                  /* initialize                       */
+NULL,			        /* notify that initialize called    */
+XtInheritRealize,               /* XCreateWindow for widget         */
+// actions,     		/* widget semantics name to proc map*/
+// XtNumber(actions),           /* number of entries in actions     */
+NULL,                           /* widget semantics name to proc map*/
+0,                              /* number of entries in actions     */
+resources,                      /* resources             */
+XtNumber(resources),            /* resources             */
+NULLQUARK,		        /* resource class quarkified        */
+TRUE,			        /* compress MotionNotify for widget */
+TRUE,			        /* compress Expose events for widget*/
+TRUE,			        /* compress enter and leave events  */
+TRUE,			        /* select for VisibilityNotify      */
+destroy_pixtbase,	        /* free data for subclass pointers  */
+resize_pixtbase,                /* geom manager changed widget size */
+expose_pixtbase,       	        /* rediplay window                  */
+NULL,		                /* set subclass resource values     */
+NULL,			        /* notify that set_values called    */
+XtInheritSetValuesAlmost,       /* set_values got "Almost" geo reply*/
+NULL,		                /* notify that get_values called    */
+XtInheritAcceptFocus,           /* assign input focus to widget     */
+// acceptfocus_pixtbase,           /* assign input focus to widget     */
+XtVersion,	                /* version of intrinsics used       */
+NULL,		                /* list of callback offsets         */
+// translations,	        /* state machine                    */
+NULL,                           /* state machine                    */
+XtInheritQueryGeometry,         /* return preferred geometry        */
+XtInheritDisplayAccelerator,    /* display your accelerator         */
+NULL		                /* pointer to extension record      */
+}
+/* PIXtBase */
+,{   NULL }
+
+};
+
+WidgetClass piXtBaseWidgetClass = (WidgetClass) &piXtBaseClassRec;
+
+
+/*  Last XEvent Serial Number and Time-Stamp , and Key-state */
+static Time last_time_xevt = 0;
+static unsigned long last_serial_xevt = 0;
+static unsigned int  last_state_xevt = 0;
+
+
+Time PIXGetLastEventTime() { return(last_time_xevt); }
+unsigned long PIXGetLastEventSerial() { return(last_serial_xevt); }
+void PIXSetLastEventTimeSerial(Time t, unsigned long ser) 
+{ last_time_xevt = t;  last_serial_xevt = ser; }
+void PIXGetLastEventInfo(unsigned int& st, Time& t)
+{ st = last_state_xevt;  t = last_time_xevt; }
+
+/* Nouvelle-Fonction */
+static void init_class_pixtbase()
+{
+#ifdef DEBUG_PIXTB
+puts("Debug_init_class_pixtbase() ");
+#endif
+return;
+}
+
+/* Nouvelle-Fonction */
+static void init_pixtbase (Widget request, Widget wdg,
+                          ArgList /*args*/, Cardinal* /*narg*/)
+{
+PIXtBaseWidget wdgp;
+wdgp = (PIXtBaseWidget)wdg;
+
+if(request->core.width<=0)  wdgp->core.width  = 10;
+if(request->core.height<=0) wdgp->core.height = 10;
+// get_GCs (wdgp);
+#ifdef DEBUG_PIXTB
+printf("Debug_init_pixtbase: Wdg=%lx Object= %lx  narg=%d \n", 
+(long)wdgp, (long)(wdgp->pixtbase.objet), (int)(*narg));
+#endif
+return;
+}
+
+/* Nouvelle-Fonction */
+static void destroy_pixtbase (Widget /*wdgp*/)
+{
+#ifdef DEBUG_PIXTB
+printf("Debug_destroy_pixtbase: Wdg= %lx Object= %lx \n", (long)wdgp, 
+(long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+// free_GCs((PIXtBaseWidget)wdgp);
+//    $CHECK$ Reza  21/11/97
+// J'ai l'impression que cette fonction n'est pas appellee au moment 
+// de destruction du Widget - Par contre la fonction leave est appelee
+// si l'action correspondante a ete enregistree ?!
+}
+
+
+/* Nouvelle-Fonction */
+static void resize_pixtbase (Widget wdgp)
+{
+#ifdef DEBUG_PIXTB
+printf("Debug_resize_pixtbase: Wdg=%lx Object= %lx \n", (long)wdgp, 
+(long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Resize();
+return;
+}
+
+/* Nouvelle-Fonction */
+static void expose_pixtbase (Widget  wdgp, XEvent* /*event*/, Region region)
+{
+#ifdef DEBUG_PIXTB
+printf("Debug_expose_pixtbase: Wdg=%lx Object= %lx \n", (long)wdgp, 
+(long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+if (!(wdgp->core.visible))  return;
+if ( ((PIXtBaseWidget)wdgp)->pixtbase.objet ) 
+  {
+  XRectangle  xrec;
+  int x0, y0, dx, dy;
+  XClipBox(region, &xrec);
+  x0 = xrec.x;  y0 = xrec.y;
+  dx = xrec.width;  dy = xrec.height;
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->eXposeProcess(x0, y0, dx, dy);
+  }
+return;
+}
+
+/* Nouvelle-Fonction 
+static Boolean  acceptfocus_pixtbase   (Widget wdgp , Time* )
+{
+// printf("acceptfocus_pixtbase() %lx %x \n",  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask, ShiftMask );
+if (  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & ShiftMask  )  return TRUE;
+else return FALSE;
+}
+*/
+
+/* -------- Fonction de traitement des evenements --------- */
+/* Nouvelle-Fonction */
+void event_handler_pixtbase (Widget wdgp, XtPointer /*closure*/, 
+                             XEvent* evt, Boolean* cont)
+{
+
+*cont = true ; 
+switch (evt->type) {
+  case EnterNotify : 
+#ifdef DEBUG_PIXTB
+    printf("Debug_enter_pixtbase: Wdg=%lx Object= %lx \n", (long)wdgp, 
+           (long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+    last_time_xevt = evt->xcrossing.time;
+    last_serial_xevt = evt->xcrossing.serial;
+    last_state_xevt = evt->xcrossing.state;
+//    if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+    (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Enter();
+  break;
+
+  case LeaveNotify : 
+#ifdef DEBUG_PIXTB
+    printf("Debug_leave_pixtbase: Wdg=%lx Object= %lx \n", (long)wdgp, 
+           (long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+    last_time_xevt = evt->xcrossing.time;
+    last_serial_xevt = evt->xcrossing.serial;
+    last_state_xevt = evt->xcrossing.state;
+//    if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+       (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Leave();
+  break;
+
+  case ButtonPress :
+    last_time_xevt = evt->xbutton.time;
+    last_serial_xevt = evt->xbutton.serial;
+    last_state_xevt = evt->xbutton.state;
+    if ( (evt->xbutton.button == 1) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button1Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But1Press(evt->xbutton.x, evt->xbutton.y);
+    else  if ( (evt->xbutton.button == 2) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button2Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But2Press(evt->xbutton.x, evt->xbutton.y);
+    else  if ( (evt->xbutton.button == 3)  && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button3Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But3Press(evt->xbutton.x, evt->xbutton.y);
+  break;
+
+  case ButtonRelease :
+    last_time_xevt = evt->xbutton.time;
+    last_serial_xevt = evt->xbutton.serial;
+    last_state_xevt = evt->xbutton.state;
+    if ( (evt->xbutton.button == 1) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button1Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But1Release(evt->xbutton.x, evt->xbutton.y);
+    else  if ( (evt->xbutton.button == 2) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button2Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But2Release(evt->xbutton.x, evt->xbutton.y);
+    else  if ( (evt->xbutton.button == 3)  && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button3Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But3Release(evt->xbutton.x, evt->xbutton.y);
+  break;
+
+  case MotionNotify :
+    {
+    int xw, yw, xr, yr;
+    unsigned int key_but;
+    Window rw, cw;
+    if ( evt->xmotion.is_hint == NotifyHint ) { 
+      if (!XQueryPointer( XtDisplay(wdgp), evt->xmotion.window, &rw, &cw,
+                  &xr, &yr, &xw, &yw, &key_but) ) break ;
+      }
+    else { key_but =  evt->xmotion.state ; xw = evt->xmotion.x;  yw = evt->xmotion.y; }
+//    if  ( !(key_but & ( Button1Mask | Button2Mask | Button3Mask ) ) ) break;
+      last_time_xevt = evt->xmotion.time;
+      last_serial_xevt = evt->xmotion.serial;
+      last_state_xevt = evt->xmotion.state;
+      if  (key_but & Button1Mask ) 
+        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr1Move(xw, yw);
+      else  if (key_but & Button2Mask ) 
+        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr2Move(xw, yw);
+      else  if (key_but & Button3Mask ) 
+        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr3Move(xw, yw);
+      else if ( !(key_but & (Button4Mask|Button5Mask)) ) 
+        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->PtrMove(xw, yw);
+    }
+  break;
+
+  case KeyPress :
+    {
+    XComposeStatus cs;
+    KeySym key;
+    char buf[10];
+    int i,nc,rkey;
+    PIKeyModifier kmod;
+  
+    kmod = PIKM_Blank;
+    nc = XLookupString(&(evt->xkey), buf, 10, &key, &cs);
+
+    if  (evt->xkey.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xkey.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xkey.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    switch (key) {
+      case XK_Return :
+        rkey = PIK_Return;
+      break;
+      case XK_KP_Enter :
+        rkey = PIK_Enter;
+      break;
+      case XK_Up :
+        rkey = PIK_Up;
+      break;
+      case XK_Down :
+        rkey = PIK_Down;
+      break;
+      case XK_Left :
+        rkey = PIK_Left;
+      break;
+      case XK_Right :
+        rkey = PIK_Right;
+      break;
+      case XK_Prior :
+        rkey = PIK_Previous;
+      break;
+      case XK_Next :
+        rkey = PIK_Next;
+      break;
+      default :
+        rkey = 0;
+      break;
+    }
+    if (rkey > 0)  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Keyboard(rkey, kmod);
+    else for(i=0; i<nc; i++)  
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Keyboard((int)(buf[i]), kmod);
+  }
+  break;
+}
+
+return;
+}
+
+
Index: /tags/DPC_V0/Poubelle/PI/pixtbase.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pixtbase.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pixtbase.h	(revision 1307)
@@ -0,0 +1,19 @@
+/* Widget Xt pour construction Widget C++  Interface Public  */
+/*                                    Reza 10/95             */
+
+#ifndef PIXTBASE_H_SEEN
+#define PIXTBASE_H_SEEN
+
+#include <X11/Intrinsic.h>
+ 
+typedef struct _PIXtBaseClassRec * PIXtBaseWidgetClass;
+typedef struct _PIXtBaseRec      * PIXtBaseWidget;
+
+#define PIXNobject      "mypiobject"
+
+extern WidgetClass piXtBaseWidgetClass;
+
+void event_handler_pixtbase (Widget wdgp, XtPointer closure, 
+                             XEvent* evt, Boolean* cont);
+
+#endif /* PIXTBASE_H_SEEN */
Index: /tags/DPC_V0/Poubelle/PI/pixtbaseP.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/pixtbaseP.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/pixtbaseP.h	(revision 1307)
@@ -0,0 +1,41 @@
+/* Widget Xt pour affichage d'image   Declaration privee  */
+/*                                      Reza 10/95        */
+
+
+#ifndef PIXTBASEP_H_SEEN
+#define PIXTBASEP_H_SEEN
+
+#include "pibwdgx.h"
+
+typedef struct
+{
+   void * mumble;   /* No new procedures */
+} PIXtBaseClassPart;
+
+
+typedef struct _RzXBaseClassRec
+{
+CoreClassPart		core_class;
+PIXtBaseClassPart	pixtbase_class;
+} PIXtBaseClassRec;
+
+typedef struct
+{
+PIBaseWdgX  * objet; 
+unsigned long myeventmask;
+} PIXtBasePart;
+
+
+typedef struct _PIXtBaseRec
+{
+CorePart		core;
+PIXtBasePart		pixtbase;
+} PIXtBaseRec;
+
+extern PIXtBaseClassRec piXtBaseClassRec;
+
+
+#endif /* PIXTBASEP_H_SEEN */
+
+
+
Index: /tags/DPC_V0/Poubelle/PI/psfile.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PI/psfile.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/psfile.cc	(revision 1307)
@@ -0,0 +1,1039 @@
+/*
+ *   PSFile.cc
+ *   
+ *   19/06/96
+ *
+ *   Modification le 01/03/96
+ *    - fusion psfile.cc - psdict.cc
+ *
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <time.h>
+
+#include "psfile.h"
+
+//++
+// Class	PSFile
+// Lib		PI
+// include	psfile.h
+//
+//   	Classe encapsulant un fichier PostScript, fournissant des primitives
+//	graphiques produisant du code PostScript.
+//--
+//++
+// Links	Voir aussi
+// PIGraphicPS
+//--
+
+
+
+/* En cm */
+#define  MIN_SIZE_IN_PAGE  2.
+
+/*
+ *  Dictionnaire PIDict
+ *
+ *  Contient les fonctions suivantes : 
+ *
+ *
+ */
+#define PIDICT_PAR   \
+  \
+  PI_Landscape, PI_Portrait,\
+  \
+  PI_ColorFromMap, PI_Black, PI_White, PI_Grey, PI_Red, PI_Blue,\
+  PI_Green, PI_Yellow, PI_Magenta, PI_NotDefColor,\
+  PI_Cyan, PI_Turquoise, PI_NavyBlue,\
+  PI_Orange, PI_SiennaRed, PI_Purple,\
+  PI_LimeGreen, PI_Gold,\
+  \
+  PI_RomanFont, PI_BoldFont, PI_ItalicFont, PI_NotDefFontAtt,\
+  PI_SmallSizeFont, PI_NormalSizeFont, PI_BigSizeFont, PI_NotDefFontSize, \
+  \
+  PI_NormalLine, PI_ThinLine, PI_ThickLine, PI_NotDefLineAtt
+
+#define PIDICT       "\
+/$PIDict 50 dict def\n\
+$PIDict begin $PIDict /mtrx matrix put /Landscape %d def /Portrait %d def\n\
+%% Couleurs et fontes courantes\n\
+/C%-2d  {ur    ug    ub    setrgbcolor} bind def %% PI_ColorFromMap\n\
+/C%-2d  {0.0   0.0   0.0   setrgbcolor} bind def %% PI_Black\n\
+/C%-2d  {0.996 0.996 0.996 setrgbcolor} bind def %% PI_White\n\
+/C%-2d  {0.824 0.824 0.824 setrgbcolor} bind def %% PI_Grey\n\
+/C%-2d  {0.996 0.0   0.0   setrgbcolor} bind def %% PI_Red\n\
+/C%-2d  {0.0   0.0   0.996 setrgbcolor} bind def %% PI_Blue\n\
+/C%-2d  {0.0   0.996 0.0   setrgbcolor} bind def %% PI_Green\n\
+/C%-2d  {0.996 0.996 0.0   setrgbcolor} bind def %% PI_Yellow\n\
+/C%-2d  {0.996 0.0   0.996 setrgbcolor} bind def %% PI_Magenta\n\
+/C%-2d  {}                              bind def %% PI_NotDefColor\n\
+/C%-2d  {0.0   0.996 0.996 setrgbcolor} bind def %% PI_Cyan\n\
+/C%-2d  {0.250 0.875 0.813 setrgbcolor} bind def %% PI_Turquoise\n\
+/C%-2d  {0.0   0.0   0.500 setrgbcolor} bind def %% PI_NavyBlue\n\
+/C%-2d  {0.996 0.644 0.0   setrgbcolor} bind def %% PI_Orange\n\
+/C%-2d  {0.625 0.320 0.176 setrgbcolor} bind def %% PI_SiennaRed\n\
+/C%-2d  {0.625 0.125 0.937 setrgbcolor} bind def %% PI_Purple\n\
+/C%-2d  {0.195 0.800 0.195 setrgbcolor} bind def %% PI_LimeGreen\n\
+/C%-2d  {0.996 0.840 0.0   setrgbcolor} bind def %% PI_Gold\n\
+/F%-2d  {/Courier   findfont} bind def       %% PI_RomanFont\n\
+/F%-2d  {/Courier-Bold    findfont} bind def       %% PI_BoldFont\n\
+/F%-2d  {/Courier-Italic  findfont} bind def       %% PI_ItalicFont\n\
+/F%-2d  {}\
+                        bind def       %% PI_NotDefFontAtt\n\
+/FS {scalefont setfont} bind def\n\
+%%/FS%-2d {8  scalefont setfont} bind def          %% PI_SmallSizeFont\n\
+%%/FS%-2d {12 scalefont setfont} bind def          %% PI_NormalSizeFont\n\
+%%/FS%-2d {16 scalefont setfont} bind def          %% PI_BigSizeFont\n\
+/FS%-2d {}                     bind def          %% PI_NotDefFontSize\n\
+/L%-2d  {1    slw} bind def                      %% PI_NormalLine\n\
+/L%-2d  {0.5  slw} bind def                      %% PI_ThinLine\n\
+/L%-2d  {3    slw} bind def                      %% PI_ThickLine\n\
+/L%-2d  {}         bind def                      %% PI_NotDefLineAtt\n\
+\
+%% Conversion\n\
+/cm   {28.3 mul}   bind def  %% cm --> points\n\
+/Ux   {$Cvrtx mul} bind def  %% Unites utilisateur /x --> points\n\
+/Uy   {$Cvrty mul} bind def  %% Unites utilisateur /y --> points\n\
+\
+%% Pages et Blocs\n\
+/newref  {%% Dx Dy Tx Ty X0 Y0 newref\n\
+translate 3 -1 roll cm div 28.3 mul /$Cvrty exch def\n\
+exch cm div 28.3 mul /$Cvrtx exch def} bind def\n\
+/NewPage {%% Dx Dy orientation NewPage\n\
+/$PageEnteredState save def 1 -1 scale Portrait eq {w cm h cm 0 h cm neg\n\
+newref} { -90 rotate h cm w cm 0 0 newref} ifelse} bind def\n\
+/EndPage { %% EndPage\n\
+$PageEnteredState restore} bind def\n\
+/NewBloc { %% Dx Dy Tx Ty X0 Y0 NewBloc\n\
+/$BlocEnteredState save def newref} bind def\n\
+/EndBloc { %% EndBloc\n\
+$BlocEnteredState restore} bind def\n\
+\
+%% Trace\n\
+/n  {newpath} bind def    /c  {closepath} bind def\n\
+/gs {gsave}  bind def     /gr {grestore} bind def\n\
+/m  {moveto} bind def     /l  {lineto} bind def\n\
+/s  {stroke} bind def     /f  {fill}   bind def\n\
+/sc {scale}  bind def     /S  {gs 1 -1 sc show gr} bind def \n\
+/slw {setlinewidth} bind def\n\
+/ff {findfont} bind def   /sf {setfont} bind def /scf {scalefont} bind def\n\
+/rl {rlineto} bind def    /tr {translate} bind def\n\
+%% Tx Ty X0 Y0 box\n\
+/box {tr 0 3 1 roll neg exch 0 0 3 index neg 0 0 m rl rl rl c} bind def\n\
+%% R X0 Y0 circle\n\
+/circle {tr dup 0 m 0 0 3 -1 roll 0 380 arc} bind def\n\
+%% DrawEllipse pompee sur transfig\n\
+/ellipse {/endangle exch def /startangle exch def /yrad exch def\n\
+/xrad exch def /y exch def /x exch def /savematrix mtrx currentmatrix def\n\
+x y tr xrad yrad sc 0 0 1 startangle endangle arc\n\
+closepath savematrix setmatrix } def\n\
+\
+%% Gestion des images\n\
+%% ColorImage, pompee sur xv (qui les avait pompees sur xgrab)\n\
+/colorimage where   %% do we know about 'colorimage'?\n\
+  { pop }           %% yes: pop off the 'dict' returned\n\
+  {                 %% no:  define one\n\
+    /colortogray {  %% define an RGB->I function\n\
+      /rgbdata exch store    %% call input 'rgbdata'\n\
+      rgbdata length 3 idiv\n\
+      /npixls exch store\n\
+      /rgbindx 0 store\n\
+      0 1 npixls 1 sub {\n\
+        grays exch\n\
+        rgbdata rgbindx       get 20 mul    %% Red\n\
+        rgbdata rgbindx 1 add get 32 mul    %% Green\n\
+        rgbdata rgbindx 2 add get 12 mul    %% Blue\n\
+        add add 64 idiv      %% I = .5G + .31R + .18B\n\
+        put\n\
+        /rgbindx rgbindx 3 add store\n\
+      } for\n\
+      grays 0 npixls getinterval\n\
+    } bind def\n\
+    /mergeprocs { %% def\n\
+      dup length 3 -1 roll dup length dup 5 1 roll 3 -1 roll add\n\
+      array cvx dup 3 -1 roll 0 exch putinterval dup 4 2 roll\n\
+      putinterval } bind def\n\
+    /colorimage {\n\
+      pop pop     %% remove 'false 3' operands\n\
+      {colortogray} mergeprocs image} bind def\n\
+  } ifelse          %% end of 'false' case\n\
+\
+%% GetRGB\n\
+/GetRGB { %% ImageStr --> RGBStr\n\
+  /ImageData exch store\n\
+  %% Pour chaque element de ImageData,\n\
+  %% On va chercher les valeurs RGB correspondantes\n\
+  0 1 Taille 1 sub {\n\
+    /i      exch store  %% On met a jour l'indice de parcours\n\
+    ImageData i get     %% Recupere la Indice e val dans la chaine ImData\n\
+    ColorMap exch get   %% On recupere la valeur RGB Correspondante\n\
+    aload pop           %% On met tout ca dans la pile\n\
+    %% Maintenant, on va mettre tout ca dans la chaine RGBStr\n\
+    RGBStr i 3 mul 2 add 3 -1 roll put\n\
+    RGBStr i 3 mul 1 add 3 -1 roll put\n\
+    RGBStr i 3 mul       3 -1 roll put\n\
+    } for\n\
+  RGBStr 0 Taille 3 mul getinterval %% On renvoie la chaine RGB\n\
+} bind def\n\
+end\n\
+"
+
+
+
+/* 
+ *  Les PIMarkers sont definis et geres commes des fontes
+ *
+ *
+ */
+#define PIMARKERS_PAR  PI_DotMarker, PI_PlusMarker, PI_CrossMarker,\
+  PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,\
+  PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker
+
+#define PIMARKERS  "\
+%% Definition de la fonte $PIMarkers\n\
+/$PIMarkers 26 dict def\n\
+$PIMarkers begin\n\
+/FontType 3 def\n\
+/FontMatrix [0.001 0 0 0.001 -0.375 -0.375] def\n\
+/FontBBox   [0 0 1000 1000] def\n\
+/Encoding 256 array def\n\
+0 1 255 {Encoding exch /.notdef put} for\n\
+Encoding  %d /PIDot       put %% PI_DotMarker\n\
+Encoding  %d /PIPlus      put %% PI_PlusMarker\n\
+Encoding  %d /PICross     put %% PI_CrossMarker\n\
+Encoding  %d /PICircle    put %% PI_CircleMarker\n\
+Encoding  %d /PIFCircle   put %% PI_FCircleMarker\n\
+Encoding  %d /PIBox       put %% PI_BoxMarker\n\
+Encoding  %d /PIFBox      put %% PI_FBoxMarker\n\
+Encoding  %d /PITriangle  put %% PI_TriangleMarker\n\
+Encoding  %d /PIFTriangle put %% PI_FTriangleMarker\n\
+Encoding  %d /PIStar      put %% PI_StarMarker\n\
+Encoding  %d /PIFStar     put %% PI_FStarMarker\n\
+/CharProcs 26 dict def\n\
+$PIDict begin\n\
+CharProcs begin\n\
+/.notdef     {} def\n\
+/PIDot       {100 375 375 circle f} bind def\n\
+/PIPlus      {0 375 m 750 375 l 375 0 m 375 750 l s} bind def\n\
+/PICross     {0 0 m 750 750 l 750 0 m 0 750 l s} bind def\n\
+/PICircle    {375 375 375 circle s} bind def\n\
+/PIFCircle   {375 375 375 circle f} bind def\n\
+/PIBox       {0 0 m 750 0 l 750 750 l 0 750 l c s} bind def\n\
+/PIFBox      {0 0 m 750 0 l 750 750 l 0 750 l c f} bind def\n\
+/PITriangle  {0 750 m 375 0 l 750 750 l c s} bind def\n\
+/PIFTriangle {0 750 m 375 0 l 750 750 l c f} bind def\n\
+/PIStar      {} def\n\
+/PIFStar     {} def\n\
+end %%$PIDict\n\
+end %%$CharProcs\n\
+/BuildChar {\n\
+1000 0      %% Largeur \n\
+0 0 750 750 %% Bounding Box\n\
+setcachedevice \n\
+exch begin\n\
+Encoding exch get\n\
+CharProcs exch get\n\
+end exec} def\n\
+end\n\
+/PIMarkers $PIMarkers definefont pop\n\
+save\n\
+"
+
+/* Dimensions des divers formats */
+  struct PaperSize {
+      double width ;
+      double height ;
+  };
+struct PaperSize PaperSizeTable[] = {
+    { 0.0,  0.0},    /* PI_NotDefFormat */
+    {21.0, 29.7},    /* PI_A4 */
+    {29.7, 42.0},    /* PI_A3 */
+    {14.8, 21.0}     /* PI_A5 ? */
+} ;
+
+
+double cm2pt(double x);
+
+
+/* Fonction WriteHeader */
+#define END_PROLOG_PAR  PAGE_WIDTH, PAGE_HEIGHT
+#define END_PROLOG  "/NewFile { %%%% w h NewFile (--> h et w en cm <--)\n\
+$PIDict begin /PIMarkers ff 14 scf sf /h exch def /w exch def \n\
+/$PIEnteredState save def} bind def\n\
+/EndFile {$PIEnteredState restore end} bind def\n\
+%%%%EndProlog\n\n\
+"
+
+#define HEADER     "\
+%%%%Title: %s\n\
+%%%%Creator: PSFile\n\
+%%%%CreationDate: %s\
+%%%%Pages: (atend)\n\
+%%%%EndComments\n\n\
+"
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// PSFile (const char * FileName, double sc = 1.0)
+//	Créateur pour fichier Encapsulated Postscript
+// PSFile (const char * FileName, PIOrientation orientation, -
+//         PIPaperSize paperSize= PI_A4, -
+//         double marginX = 5.0, double marginY = 5.0 )
+//	Créateur pour fichier Postscript
+//--
+
+/* 
+ *   PostScript encapsule...
+ * 
+ *   Attention la bounding Box ne sera specifiee 
+ *     qu'au premier NewPage() --> definie dans 
+ *     le champ "Trailer" 
+ *
+ */
+PSFile::PSFile(const char * FileName, double sc) 
+#if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
+    : mPSFileName(FileName==NULL? "unnamed.eps" : const_cast<char *>(FileName)),
+#else
+    : mPSFileName(FileName==NULL? "unnamed.eps" : (char *)(FileName)),
+#endif
+      Tw (-1.), Th(-1.),         /* Non specifies pour du eps  */
+      WMargin (-1), HMargin(-1), /* Non specifiees en eps  */ 
+      isEPS(1),
+      scale(sc),                 /* Defaut : 1. */
+      mPaperSize(PI_NotDefPaperSize), /* Non specifiee en eps */
+      PageCounter(0),            /* Fichier vide */
+      FileEmpty(1),              /* Fichier vide */
+      currentPage(NULL),
+      currentBloc(NULL),
+      mDrawColor(PI_Black),
+      mFillColor(PI_Black),
+      mFontAtt(PI_RomanFont),
+      mFontSize(PI_NormalSizeFont),
+      mLineAtt(PI_NormalLine),
+      mMarker(PI_DotMarker),
+      setFontDone(true)
+{
+    char*  date = new (char[64] ) ; 
+    time_t timer ; 
+
+    /* Ouverture du fichier en mode w+ */
+    if ( (mPSFile = fopen(FileName, "w+")) == NULL){
+	  perror (FileName);
+	  return;
+    }
+
+    /* Ecriture du Header  */
+    fprintf(mPSFile, "%%!PS-Adobe-2.0 EPSF-2.0\n");
+    fprintf(mPSFile, "%%%%BoundingBox: ");
+    /* 
+     * Les dimensions de la BB seront notees ici lors du 
+     * premier appel a NewPage
+     *
+     * C'est laid... si qqn a une meilleure idee...
+     */
+    boundingBox = ftell(mPSFile) ; 
+    fprintf(mPSFile, "                       \n");
+
+    time(&timer) ; 
+    date = ctime(&timer) ; 
+    fprintf(mPSFile, HEADER, mPSFileName, date) ; /* titre, date etc... */
+    fprintf(mPSFile, PIDICT, PIDICT_PAR) ;        /* Dictionnaire */
+    fprintf(mPSFile, PIMARKERS, PIMARKERS_PAR) ;  /* Fonte "PIMARKERS" */
+    //    fprintf(mPSFile, END_PROLOG) ;
+    /* Aucun format n'est specifie ici ... */
+    fprintf(mPSFile, "$PIDict begin /PIMarkers ff 14 scf sf\n") ;
+    fprintf(mPSFile, "/FState save def\n%%%%EndProlog\n\n") ;
+}
+
+
+
+/*
+ *  PostScript simple...
+ *
+ *
+ */
+PSFile::PSFile(const char *FileName,
+	       PIOrientation orientation,
+	       PIPaperSize   paperSize,
+	       double marginX, double marginY)
+#if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
+ :  mPSFileName (FileName == NULL ? "unnamed.ps" : const_cast<char *>(FileName)),
+#else
+ :  mPSFileName (FileName == NULL ? "unnamed.ps" : (char *)(FileName)),
+#endif
+    Tw(PaperSizeTable[paperSize].width),  /* Format papier utilise */
+    Th(PaperSizeTable[paperSize].height), /*                       */
+    WMargin(marginX),
+    HMargin(marginY),
+    isEPS(0),
+    scale(0.),
+    PageCounter(0),  /* Fichier vide */
+    FileEmpty(1),    /*              */
+    currentPage(NULL),
+    currentBloc(NULL),
+    mDrawColor(PI_Black),
+    mFillColor(PI_Black),
+    mFontAtt(PI_RomanFont),
+    mFontSize(PI_NormalSizeFont),
+    mLineAtt(PI_NormalLine),
+    mMarker(PI_DotMarker), 
+    setFontDone(true)
+{
+    char * date = new(char[64]) ; 
+    time_t timer ; 
+
+    /* Ouverture du fichier, en mode w+ (tout est ecrase) */
+    if ( (mPSFile = fopen(FileName, "w+")) == NULL){
+	  perror (FileName);
+	  return;
+    }
+
+    /* Format et orientation */
+
+    /* Ecriture du Header  */
+    fprintf(mPSFile, "%%!PS-Adobe-2.0\n") ;
+    time(&timer) ; 
+    date = ctime(&timer) ; 
+    fprintf(mPSFile, HEADER, mPSFileName, date) ; /* titre, date etc... */
+    fprintf(mPSFile, PIDICT, PIDICT_PAR) ;        /* Dictionnaire */
+    fprintf(mPSFile, PIMARKERS, PIMARKERS_PAR) ;  /* Fonte "PIMARKERS" */
+    fprintf(mPSFile, "$PIDict begin /PIMarkers ff 14 scf sf\n") ;
+    fprintf(mPSFile, "/FState save def\n%%%%EndProlog\n\n") ;
+}
+
+
+/* 
+ * Destructeur
+ *
+ */
+PSFile::~PSFile () {
+
+    /* On ferme tout ce qui ne l'est pas */
+    if (currentBloc) PSFile::EndBloc();
+    if (currentPage) PSFile::EndPage();
+
+    /* Si le fichier est vide, on le detruit */
+    if (FileEmpty) remove(mPSFileName);
+
+    /* On ecrit le "Trailer" et on ferme */
+    else {
+	/* On restore l'etat initial */
+	fprintf(mPSFile,"FState restore\n") ;
+	fprintf(mPSFile, "%%%%Trailer\n%%%%Pages: %d\n%%%%EOF\n", 
+		PageCounter) ;
+	fclose (mPSFile);
+    }
+}
+
+
+int   PSFile::IsEPS(){
+
+    return(isEPS);
+}
+
+
+const char* PSFile::GetFileName() {
+
+    return(mPSFileName);
+}
+
+PIColors PSFile::GetDrawColor() {
+
+    return(mDrawColor);
+}
+
+PIColors PSFile::GetFillColor() {
+
+    return(mFillColor);
+}
+
+PIFontAtt PSFile::GetFontAtt() {
+
+    return(mFontAtt);
+}
+
+PIFontSize PSFile::GetFontSize() {
+
+    return(mFontSize);
+}
+
+PILineAtt PSFile::GetLineAtt() {
+
+    return(mLineAtt);
+}
+
+PIMarker PSFile::GetMarker() {
+
+    return(mMarker);
+}
+
+void  PSFile::NewPage(double Dx, double Dy, PIOrientation orientation) {
+
+double  tw, th; /* largeur & hauteur corrigees des marges */
+
+    /* On ferme ce qui doit l'etre ... */
+    if (currentPage) PSFile::EndPage();
+
+    currentPage = new (Page) ; 
+
+    /* Initialisations */
+    currentPage->num = ++PageCounter;
+    currentPage->BlocCounter = 0;
+    currentPage->Dx = Dx;
+    currentPage->Dy = Dy;
+    currentPage->orientation = orientation ;
+
+    /* Position du debut AVANT D'ECRIRE! */
+    currentPage->begin  = ftell(mPSFile);
+
+    /* On ecrit dans le fichier */
+    fprintf(mPSFile, "%%%%Page: %d %d\n", PageCounter, PageCounter) ;
+    fprintf(mPSFile, "/PState save def 1 -1 scale\n");
+
+    /* 
+     *  Si eps : Portrait || Auto == on laisse tel que
+     *           Landscape == on tourne de -90 degres
+     */
+    if(isEPS) {
+	if( (orientation == PI_Portrait) || (orientation == PI_Auto) )
+	    fprintf(mPSFile,
+		    "%.2f %.2f %.2f %.2f %.2f %.2f newref\n",
+		    Dx, Dy, Dx*scale, Dy*scale, 0., -Dy*scale);
+	else
+	    if(orientation==PI_Landscape)
+		fprintf(mPSFile, 
+			"-90 rotate %.2f %.2f %.2f %.2f %.2f %.2f newref\n",
+			Dx, Dy, Dx*scale, Dy*scale, 0., 0.);
+	    else
+		fprintf(stderr, "Orientation Error ; Page : %d\n",
+			currentPage->num) ; 
+    /* 
+     * On specifie la bb 
+     * (Si non encore fait par un appel precedent a NewPage() ) 
+     */
+	if(boundingBox) {
+	    currentPage->tmp = ftell(mPSFile) ;
+	    fseek(mPSFile,boundingBox,SEEK_SET) ;
+	    if( (orientation == PI_Portrait) || (orientation == PI_Auto) )
+		fprintf(mPSFile, "%d %d %d %d", 0, 0, 
+			(int)(Dx*scale), (int)(Dy*scale) ) ; 
+	    else
+		fprintf(mPSFile, "%d %d %d %d", 0, 0, 
+			(int)(Dy*scale), (int)(Dx*scale) ) ;
+	    fseek(mPSFile,currentPage->tmp,SEEK_SET) ;
+	    boundingBox = 0 ; 
+	} /* BB */
+    } /* EPS */
+    /*
+     * Si ps : 
+     *   - soustraction marges --> rectangle utile.
+     *   - Si PI_Auto : On fait au mieux pour minimiser le 
+     *      redimensionnement...
+     *   - Si PI_Portrait, on ne fait rien, sauf 
+     *      peut-etre un redimensionnement pour rentrer dans les marges
+     *   - Si PI_Landscape, on tourne de -90 degres.
+     */
+    else {
+        // Si marges <= 0 on les met a 2cm
+        if(WMargin<=0) WMargin = 2. ; 
+        if(HMargin<=0) HMargin = 2. ; 
+	/* Eviter image reduite a un point...ou moins... */
+	if((tw = Tw - 2*WMargin) < (Tw/10)) {
+	    WMargin = (0.45)*Tw ;
+	    tw = Tw/10;
+	}
+	if((th = Th - 2*HMargin)< (Th/10)) {
+	    HMargin = (0.45)*Th ;
+	    th = Th/10;
+	}
+	/* Portrait ou Landscape ? */
+	if(orientation == PI_Auto) 
+	    if( ((tw < th) && (Dx < 1.2*Dy)) ||
+		((tw > th) && (Dx > Dy) )) 
+		currentPage->orientation = PI_Portrait ;
+	    else 
+		currentPage->orientation = PI_Landscape ;
+
+	if(currentPage->orientation == PI_Portrait) {
+//	    if( (tw/Dx) < (th/Dy) ) 
+//		scale = tw/Dx ;
+//                scale = tw/Tw ; 
+//	    else 
+//		scale = th/Dy;
+//                scale = th/Th;
+//	    fprintf(mPSFile, 
+//		    "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+//		    Dx, Dy, 
+//		    Dx*scale, Dy*scale, 
+//		    Tw*scale, Th*scale, 
+//		    0.5*(Tw-tw), -0.5*(Th+th)) ;
+            scale = (tw/Dx)<(th/Dy) ? tw/Dx : th/Dy ; 
+            tw = scale*Dx ; th = scale*Dy ; 
+	    fprintf(mPSFile, 
+		    "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+		    Dx, Dy, 
+		    tw, th, 
+		    0.5*(Tw-tw), -0.5*(Th+th)) ;
+	}
+	if(currentPage->orientation == PI_Landscape) {
+	    /* Idem avec X<->Y */
+//	    if( (th/Dx) < (th/Dy) ) 
+//		scale = th/Dx;
+//                scale = th/Tw;
+//	    else
+//		scale = tw/Dy ;
+//                scale = tw/Th;
+//	    fprintf(mPSFile,
+//	       "-90 rotate %.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+//	       Dx, Dy,
+//	       Dx*scale, Dy*scale, 
+//	       Th*scale, Tw*scale, 
+//	       0.5*(Th-th), 0.5*(Tw-tw));
+
+            scale = (th/Dx)<(tw/Dy) ? th/Dx : tw/Dy ; 
+            th = scale*Dx ; tw = scale*Dy ; 
+	    fprintf(mPSFile,
+	       "-90 rotate %.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+	       Dx, Dy,
+	       th, tw,
+	       0.5*(Th-th), 0.5*(Tw-tw));
+	}
+    } /* End if .ps */
+currentPage->tmp = ftell(mPSFile);
+}
+
+
+
+void  PSFile::EndPage() {
+
+    /* Si rien a fermer, on s'en va */
+    if ( ! currentPage ) return;
+
+    /* Si un bloc non ferme, on appelle EndBloc */
+    if ( currentBloc ) PSFile::EndBloc();
+    
+    /* Si la page est vide, on la detruit */
+    if (currentPage->tmp == ftell(mPSFile)) {
+	fseek(mPSFile, currentPage->begin, SEEK_SET);
+	delete(currentPage) ;
+	PageCounter--;
+    }
+    /* Sinon, fin page + empilage */
+    else {
+	//	it = mPageList.end(); it--;
+	fprintf(mPSFile,"PState restore  showpage\n");
+	fprintf(mPSFile,"%%>EndPage %d\n\n\n", currentPage->num);
+	currentPage->end = ftell(mPSFile);
+	mPageList.push_back(*currentPage); /* Pourquoi PageList ? */
+	FileEmpty = 0;
+    }
+    currentPage = NULL;
+}
+
+
+void  PSFile::NewBloc(double x0, double y0, double Tx, double Ty,
+			      double Dx, double Dy){
+
+    /* Si pas de page, on s'en va */
+    if ( ! currentPage ) return;
+
+    /* On ferme le bloc precedent (Pas de Bloc-gigognes ! ) */
+    if (currentBloc) PSFile::EndBloc();
+
+    currentBloc = new (Bloc) ; 
+    /* On remplit currentBloc */
+    currentBloc->num = ++(currentPage->BlocCounter);
+    currentBloc->X0 = x0;
+    currentBloc->Y0 = y0;
+    currentBloc->Tx = Tx;
+    currentBloc->Ty = Ty;
+    currentBloc->Dx = Dx;
+    currentBloc->Dy = Dy;
+    currentBloc->begin = ftell(mPSFile);
+
+    /* On met a jour le fichier */
+    fprintf(mPSFile, "%%>BeginBloc %d\n", currentBloc->num);
+    fprintf(mPSFile, "%.2f %.2f %.2f Ux %.2f Uy %.2f Ux %.2f Uy NewBloc\n",
+	    currentBloc->Dx, currentBloc->Dy,
+	    currentBloc->Tx, currentBloc->Ty,
+	    currentBloc->X0, currentBloc->Y0);
+    currentBloc->tmp = ftell(mPSFile) ;
+}
+
+
+void  PSFile::EndBloc() {
+
+    /* On verifie qu'un bloc ouvert existe bien */
+    if ( ! currentBloc ) return;
+
+    /* Si le bloc est vide, on le detruit */
+    if (currentBloc->tmp == ftell(mPSFile)) {
+	fseek(mPSFile, currentBloc->begin, SEEK_SET) ; 
+	currentPage->BlocCounter-- ; 
+    }
+    /* Sinon, Ok met a jour le fichier */
+    else { 
+	fprintf(mPSFile, "EndBloc\n"); 
+	fprintf(mPSFile, "%%>EndBloc %d\n", currentBloc->num); 
+	currentBloc->end = ftell(mPSFile) ; 
+	currentPage->mBlocList.push_back(*currentBloc) ; 
+	//	PageEmpty = 0; 
+    } 
+    /* Flags */
+    currentBloc = NULL ; 
+}
+
+void PSFile::SelForeground(PIColorMap& cmap, int cid)
+{
+  mDrawColor = PI_ColorFromMap ; 
+  PIColor tmp = cmap.GetColor(cid) ; 
+  fprintf(mPSFile, "/ur %.3f def /ug %.3f def /ub %.3f def \n", 
+          (double)(tmp.red)/65535., 
+          (double)(tmp.green)/65535., 
+          (double)(tmp.blue)/65535.) ; 
+}
+
+
+void PSFile::SelBackground(PIColorMap& cmap, int cid)
+{
+  mDrawColor = PI_ColorFromMap ; 
+}
+
+
+void  PSFile::DrawString  (double x,  double y, const char *s, 
+			   PIColors DrawColor, 
+			   PIFontAtt FontAtt, 
+			   int FontSize) {
+    int change = 0;
+
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
+    /* Choix des fontes */
+    if ( (FontAtt != PI_NotDefFontAtt) || (FontAtt != mFontAtt) ) {
+	mFontAtt = FontAtt;
+	change = 1;}
+    if ( (FontSize != PI_NotDefFontSize) || (FontSize != mFontSize) ) {
+	mFontSize = (PIFontSize) FontSize;  // $CHECK$ EA ajoute le cast un peu au pif
+	change = 1;}
+    if (change)
+	fprintf(mPSFile, "F%d %d FS ", mFontAtt, FontSize) ; 
+
+    fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 
+    setFontDone = true ; 
+}
+
+
+void  PSFile::DrawLine    (double x1, double y1, double x2, double y2, 
+		   PIColors DrawColor,
+		   PILineAtt LineAtt) {
+
+  int lw = 0 ; 
+
+  switch(LineAtt) {
+    case PI_NotDefLineAtt:
+      break ; 
+    case PI_NormalLine:
+      lw = 2. ; 
+      break ; 
+    case PI_ThinLine:
+      lw = 1 ; 
+      break ; 
+    case PI_ThickLine:
+      lw = 4 ;
+      break ; 
+  } 
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", lw) ; 
+    }
+
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor);
+    }
+
+    /* Dessin */
+    fprintf(mPSFile, "n %.2f Ux %.2f Uy m %.2f Ux %.2f Uy l s\n",
+	    x1, y1, x2, y2) ;
+}
+
+
+
+void  PSFile::DrawBox(double x0, double y0, double Tx, double Ty, 
+		      PIColors  DrawColor,
+		      PILineAtt LineAtt) {
+
+    /* Changement couleurs ? */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* On dessine */
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box s gr\n",
+	    Tx, Ty, x0, y0) ; 
+}
+
+
+void  PSFile::DrawFBox(double x0, double y0, double Tx, double Ty, 
+		   PIColors DrawColor,
+		   PIColors FillColor, 
+		   PILineAtt LineAtt) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Dessin du fond */
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) )
+	mFillColor = FillColor;
+    fprintf(mPSFile, "C%d ", mFillColor) ; 
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box f gr\n",
+	    Tx, Ty, x0, y0) ; 
+    
+    /* Dessin du contour (s'il y a lieu) */
+    if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) )
+	mDrawColor = DrawColor;
+    fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box s gr\n",
+	    Tx, Ty, x0, y0) ;
+}
+
+
+void  PSFile::DrawCircle  (double x0, double y0, double r, 
+			   PIColors DrawColor,
+			   PILineAtt LineAtt) {
+
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor); 
+    }
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt); 
+    }
+
+    /* Dessin */
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy 0 360 ellipse s gr\n",
+	    x0, y0, r, r) ;
+}
+
+
+void  PSFile::DrawFCircle (double x0, double y0, double r,
+		   PIColors DrawColor,
+		   PIColors FillColor, 
+		   PILineAtt LineAtt) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Dessin du fond */
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) ){
+	mFillColor = FillColor;
+	fprintf(mPSFile, "C%d ", mFillColor) ;
+    }
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy \
+                      0 360 ellipse f gr\n",
+	    x0, y0, r, r);
+    fprintf(mPSFile, "C%d ", mDrawColor) ;
+
+    /* Dessin du contour (s'il y a lieu) */
+    if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor); 
+	fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy 0 360 ellipse s gr\n",
+		x0, y0, r, r) ;
+    }
+}
+
+
+// Les coordonnees sont supposees etre en mode incremental .
+void  PSFile::DrawPolygon (double *x, double *y, int n,
+		   PIColors DrawColor, 
+		   PILineAtt LineAtt, bool cinc) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Couleur */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ;
+    }
+    
+    /* On dessine ; ici*/
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+
+    const char* cmd ; 
+    if(cinc == true) cmd = "%.2f Ux %.2f Uy rl\n" ; 
+    else             cmd = "%.2f Ux %.2f Uy l\n" ; 
+
+    for(int i = 1; i<n; i++) 
+      fprintf(mPSFile, cmd, x[i], y[i]);
+    fprintf(mPSFile, "c s\n");
+}
+
+
+void  PSFile::DrawFPolygon(double *x, double *y, int n,
+		   PIColors DrawColor,
+		   PIColors FillColor,
+		   PILineAtt LineAtt, bool cinc) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    const char* cmd ; 
+    if(cinc == true) cmd = "%.2f Ux %.2f Uy rl\n" ; 
+    else             cmd = "%.2f Ux %.2f Uy l\n" ; 
+
+    /* Dessin du fond... */
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) ) 
+	mFillColor = FillColor;
+    fprintf(mPSFile, "C%d ", mFillColor) ;
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    int i;
+    for(i = 1; i<n; i++) 
+	fprintf(mPSFile, cmd, x[i], y[i]);
+    fprintf(mPSFile, "c f\n");
+
+    /* ...puis du contour (s'il y a lieu) */
+    if ( (DrawColor != PI_NotDefColor) && (DrawColor != FillColor) )
+	mDrawColor = DrawColor;
+    fprintf(mPSFile, "C%d ", mDrawColor) ;
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    for(i = 1; i<n; i++) 
+      fprintf(mPSFile, cmd, x[i], y[i]);
+    fprintf(mPSFile, "c s\n");
+}
+
+
+
+void  PSFile::DrawMarker  (double x0, double y0,
+			   PIMarker MrkType,   
+			   PIColors DrawColor,
+			   int MarkerSize) {
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
+
+    /* Marker */
+    if (MrkType != PI_NotDefMarker)
+	mMarker = MrkType;
+
+    if(MarkerSize != mMarkerSize || setFontDone) {
+	mMarkerSize = MarkerSize ;
+	fprintf(mPSFile, "/PIMarkers ff %d scf sf\n", mMarkerSize) ; 
+        setFontDone = false ; 
+    }
+    /* Dessin */
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", x0, y0, mMarker) ;
+}
+
+/*
+ * Pas d'options pour specifier la taille des Markers ?
+ *
+ */
+void  PSFile::DrawMarkers (double *x0, double *y0, int n,
+			   PIMarker MrkType,
+			   PIColors DrawColor,
+			   int MarkerSize) {
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }    
+
+    /* Marker */
+    if (MrkType != PI_NotDefMarker)
+	mMarker = MrkType;
+
+    if(MarkerSize != mMarkerSize || setFontDone) {
+	mMarkerSize = MarkerSize ;
+	fprintf(mPSFile, "/PIMarkers ff %d scf sf\n", mMarkerSize) ; 
+        setFontDone = false ; 
+    }
+    /* Dessin */
+    for(int i = 0; i<n; i++)
+	fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", x0[i], y0[i], mMarker) ; 
+}
+
+void PSFile::Image(double x0, double y0, double Tx, double Ty,
+		   int Nx, int Ny,
+		   unsigned char *Pict, 
+		   PIColorMap *mMap) {
+
+    int i, j;
+
+    /* Buffers PostScript */
+    fprintf(mPSFile, "/Taille %d def\n", Nx);
+    fprintf(mPSFile, "/ImStr Taille string def\n");
+    fprintf(mPSFile, "/RGBStr Taille 3  mul string def\n");
+
+    /* Ecriture ColorMap */
+    fprintf(mPSFile, "/ColorMap %02d array def\n", mMap->NCol() );
+    for(i = 0; i < mMap->NCol(); i++) {
+	fprintf(mPSFile, "ColorMap %d [16#%02X 16#%02X 16#%02X] put\n",
+		i,
+		(int)(mMap->GetColor(i).red/256),
+		(int)(mMap->GetColor(i).green/256),
+		(int)(mMap->GetColor(i).blue/256));
+    }
+    /* Emplacement de l'image */
+    fprintf(mPSFile, "gs %.2f Ux %.2f Uy tr %.2f Ux %.2f Uy sc\n", x0, y0, Tx, Ty);
+    /* Nbr pix-X, Nbr pix-Y bits/pixels */
+    fprintf(mPSFile, "%d %d 8\n", Nx, Ny);
+    /* Matrice de passage */
+    fprintf(mPSFile, "[%d 0 0 %d 0 0]", Nx, Ny);
+    /* Fonction colorimage */
+    fprintf(mPSFile, "{currentfile ImStr readhexstring pop GetRGB}\
+false 3 colorimage\n\n");
+    /* Data */
+    for(i = 0; i < Ny; i++) {
+	for(j = 0; j<Nx-1; j++ )
+	    fprintf(mPSFile, "%02X", Pict[i*Nx+j]);
+    fprintf(mPSFile, "%02X\n", Pict[i*Nx+j]);
+    }
+    /* Un petit grestore ...*/
+    fprintf(mPSFile, "gr\n");
+}
+
+/* 
+ *  Conversion
+ *
+ */
+
+double cm2pt(double x) {
+    return (x*28.35);
+}
+
Index: /tags/DPC_V0/Poubelle/PI/psfile.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/psfile.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/psfile.h	(revision 1307)
@@ -0,0 +1,206 @@
+#ifndef PSFILE_H_SEEN
+#define PSFILE_H_SEEN
+
+/*
+ *  PSFile.h
+ * 
+ *  14/06/96, 19/06/96
+ *
+ *  Gestion des fichier .ps et .eps
+ *
+ *     - L'unite de mesure est lUnite Courante (UC)
+ *        Au depart, 1UC == 1cm 
+ *     - Les reperes sont orientes a la maniere XWindow
+ * 
+ *  17/02/97 : modification des constructeurs(1-->eps,2-->ps)
+ *             ajout du type enum orientation
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "defs.h"
+#ifdef __mac__
+#include <stat.h>
+#endif
+#include "pisysdep.h"
+
+
+#include "pigraphgen.h"      // Types enumeres repris de Peida:PIFontSize...
+#include PICMAP_H
+
+#include <list>
+#if defined(__KCC__)
+#include <list.h>
+#endif
+
+enum PIPaperSize { PI_A4 = 1, PI_A3 = 2, PI_A5 = 3, PI_NotDefPaperSize = 0};
+
+enum PIOrientation { PI_Landscape = 0, PI_Portrait = 1, PI_Auto = 2 } ;
+
+
+/*
+ *#define PAGE_WIDTH   21.0    == 595 points 
+ *#define PAGE_HEIGHT  29.7    == 842 points 
+ *#define PORTRAIT  1
+ *#define LANDSCAPE 0
+ */
+
+
+
+/* Valable pour une page, ou un bloc */
+/*typedef struct {
+ *  double X0;          Coordonnes sommet NO  
+ *  double Y0;           en unites courantes  
+ *  double Tx;          Format                
+ *  double Ty;           en unites courantes  
+ *  double Dx;          Coord sommet SE       
+ *  double Dy;           en unites courantes  
+ *  int orientation;   LANDSCAPE OU PORTRAIT 
+ *} Format;
+ */
+
+/*
+ *typedef struct{
+ *    char *Name;
+ *    int  Tx;     En 1/72e de pouce  !! 
+ *    int  Ty;     unite naturelle de ps 
+ *} PIMedia;
+ */
+
+
+
+class PSFile{
+
+public:
+    /* Production fichier eps */
+    PSFile (const char * FileName, double sc = 1.0);
+    /* Production fichier ps  */
+    PSFile (const char * FileName, PIOrientation orientation, 
+	    PIPaperSize paperSize= PI_A4, 
+	    double marginX = 5.0, double marginY = 5.0 ) ;
+
+    virtual      ~PSFile();
+
+    virtual int     IsEPS();
+    virtual const char*   GetFileName();
+
+
+    /*    virtual Format* GetFormat(); */
+    /* Attributs graphiques */
+    virtual PIColors    GetDrawColor();
+    virtual PIColors    GetFillColor();
+    virtual PIFontAtt   GetFontAtt();
+    virtual PIFontSize  GetFontSize();
+    virtual PILineAtt   GetLineAtt();
+    virtual PIMarker    GetMarker();
+
+    virtual void  NewPage(double Dx, double Dy, PIOrientation orientation);
+    virtual void  EndPage();
+    virtual void  NewBloc(double x0, double y0, double Tx, double Ty,
+			  double Dx, double Dy);
+    virtual void  EndBloc();
+
+    virtual void SelForeground(PIColorMap& cmap, int cid) ; 
+    virtual void SelBackground(PIColorMap& cmap, int cid) ; 
+
+    /* Trace */
+    virtual void  DrawString  (double x,  double y, const char *s, 
+			       PIColors DrawColor  = PI_NotDefColor, 
+			       PIFontAtt FontAtt   = PI_NotDefFontAtt, 
+			       int FontSize        = 8);
+    virtual void  DrawLine    (double x1, double y1, double x2, double y2, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawBox     (double x0, double y0, double Tx, double Ty, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawFBox    (double x0, double y0, double Tx, double Ty, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PIColors FillColor  = PI_NotDefColor, 
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawCircle  (double x0, double y0, double r, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawFCircle (double x0, double y0, double r,
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PIColors FillColor  = PI_NotDefColor, 
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawPolygon (double *x, double *y, int n,
+			       PIColors DrawColor  = PI_NotDefColor, 
+			       PILineAtt LineAtt   = PI_NotDefLineAtt, 
+                               bool cinc = true);
+    virtual void  DrawFPolygon(double *x, double *y, int n,
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PIColors FillColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt, 
+                               bool cinc = true);
+    virtual void  DrawMarker  (double x0, double y0, 
+			       PIMarker MrkType    = PI_NotDefMarker, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       int MarkerSize=14);
+    virtual void  DrawMarkers (double *x0, double *y0, int n,
+			       PIMarker MrkType    = PI_NotDefMarker,
+			       PIColors DrawColor  = PI_NotDefColor,
+			       int MarkerSize=14); 
+
+    virtual void  Image(double x0, double y0, double Tx, double Ty,
+			int Nx, int Ny,
+			unsigned char *pict,
+			PIColorMap *mColorMap);
+
+// Declarations en public - sinon certains compilateurs cxx , aCC, xlC ont des problemes
+    /* Blocs */
+    typedef struct {
+	int    num;
+	char*  label;
+	double  X0, Y0;            /* coordonnees sommet NO */
+	double  Tx, Ty;            /* Format */
+	double  Dx, Dy;            /* Repere utilisateur */
+	long  begin,end,tmp;   /* offsets dans le fichier */
+    } Bloc ;
+    typedef list<Bloc> BlocList;  /* STL */
+
+
+    /* Pages */
+    typedef struct {
+	int num;
+	int BlocCounter;
+	double Dx,Dy;              /* Sommet SE (unites utilisateur) */ 
+	PIOrientation orientation;
+	long  begin, end, tmp;    /* Offsets dans le fichier */
+	BlocList mBlocList;       /* Page == Liste de blocs  */
+    } Page ;
+    typedef list<Page> PageList;  /* STL */
+
+private:
+
+    /* Fichier ps/eps */
+    FILE *   mPSFile;
+    const char *   mPSFileName;
+    double    Tw,Th ;              /* Format, en cm */
+    double    WMargin,HMargin ;    /* Marges minimales */
+    int      isEPS;               /* Vrai si PostScript Encapsule */
+    long     boundingBox;         /* Endroit ou est specifiee la bb */
+    double    scale;              /* boundingbox = Dx*scale ; Dy*scale */
+    PIPaperSize mPaperSize ; 
+    int      PageCounter;         /* nbr pages */
+    int      FileEmpty;
+    Page*    currentPage;        /* Avant empilage */
+    Bloc*    currentBloc;        /* Avant empilage */
+    PageList mPageList;          /* Fichier == Liste de pages */
+
+
+    /* Attributs graphiques, initialises par constructeur */
+    enum PIColors    mDrawColor;  /* Couleur de trace courante */
+    enum PIColors    mFillColor;  /* Couleur de remplissage courante */
+    enum PIFontAtt   mFontAtt; 
+    enum PIFontSize  mFontSize; 
+    enum PILineAtt   mLineAtt;    /* Epaisseur d une ligne */
+    enum PIMarker    mMarker;     /* Marker courant */
+    int              mMarkerSize; /* Taille (en points) du marker courant */
+    bool setFontDone ; /* Pour forcer la selection de Marker apres DrawString() */
+} ;
+
+
+#endif/* PSFILE_H_SEEN */
Index: /tags/DPC_V0/Poubelle/PI/xdispim.c
===================================================================
--- /tags/DPC_V0/Poubelle/PI/xdispim.c	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/xdispim.c	(revision 1307)
@@ -0,0 +1,383 @@
+#if 0
+/* Fonctions interface XWindow pour affichage d'images */
+/*                  Reza   05/95                       */
+
+/*                  LAL (Orsay) / IN2P3-CNRS           */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+#include "xdispim.h"
+
+/*  Variables globales pour  */
+
+static int RzXwDispImg = 0;
+static Display * display;
+static int screen;
+static GC defgc;
+static RzXCMap rzxcmap[5];
+static int rzxgcok = 0;
+static Font fonts[5];
+
+static int NbRzXw = 0;
+
+
+/*  Fin des variables globales   */
+
+
+/* Nouvelle-Fonction */
+int RzXInitDisplay(int prtl)
+
+/*   Connection avec un serveur X, et allocation des couleurs    */
+
+{
+Visual* vis;
+
+
+struct rzvisu_struc
+  {
+  int MMsize_x;
+  int MMsize_y;
+  int Pixsize_x;
+  int Pixsize_y;
+  float resol_x;
+  float resol_y;
+  } rzvisu;
+
+
+display = XOpenDisplay ("");
+
+if (display == 0)
+  { printf("RzXInitDisplay_Error: Cannot connect to X-Server \n");
+    return(1); }
+screen = XDefaultScreen(display);
+
+rzvisu.Pixsize_x = DisplayWidth  (display, screen);
+rzvisu.Pixsize_y = DisplayHeight (display, screen);
+rzvisu.MMsize_x = DisplayWidthMM  (display, screen);
+rzvisu.MMsize_y = DisplayHeightMM (display, screen);
+
+rzvisu.resol_x = (float)rzvisu.Pixsize_x*10./(float)rzvisu.MMsize_x;
+rzvisu.resol_y = (float)rzvisu.Pixsize_y*10./(float)rzvisu.MMsize_y;
+
+vis = DefaultVisual(display,screen);
+
+if (prtl > 0)
+  {
+  printf("RzXInitDisplay_Info: Screen size (X,Y) : %d * %d Pix (%d * %d  mm)\n",
+         rzvisu.Pixsize_x,rzvisu.Pixsize_y,
+         rzvisu.MMsize_x,rzvisu.MMsize_y);
+  printf ("... Planes= %d  Cells= %d  depth= %d ", XDisplayPlanes(display, screen) ,
+          XDisplayCells(display, screen), XDefaultDepth(display, screen));
+
+  switch (vis->class)
+    {
+    case PseudoColor :
+      printf (".... Class = %d (PseudoColor) \n",vis->class);
+      break;
+    case DirectColor : 
+      printf (".... Class = %d (DirectColor) \n",vis->class);
+      break;
+    case GrayScale :
+      printf (".... Class = %d (GreyScale) \n",vis->class);
+      break;
+    case StaticColor :
+      printf (".... Class = %d (StaticColor) \n",vis->class);
+      break;
+    case StaticGray :
+      printf (".... Class = %d (StaticGray) \n",vis->class);
+      break;
+    case TrueColor :   
+      printf (".... Class = %d (TrueColor) \n",vis->class);
+      break;
+    default :
+      printf (".... Class = %d (Unknown !) \n",vis->class);
+      break;
+    }
+
+  }
+
+/*  Allocating default CMap */
+RzXAllocCMap(rzxcmap, CMAP_GREY32, prtl);
+RzXAllocCMap(rzxcmap+1, CMAP_COL16, prtl);
+RzXAllocCMap(rzxcmap+2, CMAP_GREYINV32, prtl);
+RzXAllocCMap(rzxcmap+3, CMAP_COLRJ32, prtl);
+rzxcmap[4].typ = -1;  rzxcmap[4].nCol = 0;
+
+if (prtl > 1)
+  printf("...Loading fonts Adobe-Courier Normal/Bold/Ital : \n");
+fonts[0] = XLoadFont(display,
+       "-adobe-courier-medium-r-normal--*-140-*-iso8859-1");
+fonts[1] = XLoadFont(display,
+       "-adobe-courier-bold-r-normal--*-140-*-iso8859-1");
+fonts[2] = XLoadFont(display,
+       "-adobe-courier-medium-o-normal--*-140-*-iso8859-1");
+
+RzXwDispImg = 1;    /*  Variable de controle d'initialisation */
+
+return(0);
+}
+
+/* Nouvelle-Fonction */
+int RzXCheckInitDisp()
+{
+return (RzXwDispImg);
+}
+
+
+/* Nouvelle-Fonction */
+int RzXGetPixDSize()
+/*  Retourne la taille correspondant a depth en Byte ( 8->1) */
+{
+int depth;
+depth = DefaultDepth(display,screen);
+if (depth <= 8)  return(1);
+else if (depth <= 16)  return(2);
+else return(4);
+}
+
+/* Nouvelle-Fonction */
+int RzXDispPixMap(Window xw, unsigned char *pix,  int sizx, int sizy, RzXCMap *cmap)
+{
+int depth;
+XImage * ximg;
+int i,j;
+unsigned char *pp;
+
+depth = DefaultDepth(display,screen);
+ximg = XCreateImage (display,DefaultVisual(display,screen),
+       depth,ZPixmap,0,pix,sizx,sizy,8,0);
+pp = pix;
+for(j=0; j<sizy; j++)
+  for(i=0; i<sizx; i++) 
+    { XPutPixel(ximg, i, j, cmap->colpix[*pp]);  pp++; }
+XRaiseWindow(display, xw);
+XPutImage(display,xw,defgc,ximg,0,0,0,0,sizx, sizy);
+XSync(display,1);
+XFree(ximg);
+
+return(0);
+
+}
+
+
+/* Nouvelle-Fonction */
+RzXCMap * RzXGetCMap(int cmapid)
+{
+int i;
+for(i=0; i<5; i++)
+  if (rzxcmap[i].typ == cmapid)  return(rzxcmap+i);
+if (rzxcmap[4].typ >= 0)  RzXFreeCMap(rzxcmap+4);
+RzXAllocCMap(rzxcmap+4, cmapid, 0);
+return(rzxcmap+4);
+}
+
+
+/*  Definition d' une table de couleurs  R G B   */
+
+static float R_RGB1[16] =
+{0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};
+static float G_RGB1[16] =
+{0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};
+static float B_RGB1[16] =
+{0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};
+
+
+
+/* Nouvelle-Fonction */
+int RzXAllocCMap(RzXCMap *rcmap, int cmapid, int prtl)
+/*  Allocation des tables de couleurs  */
+
+{
+Colormap cmap;
+XColor mycol;
+int nok,i;
+
+cmap = XDefaultColormap (display, screen);
+
+nok = 0;
+
+rcmap->typ = -1;
+
+switch (cmapid)
+  {
+  case CMAP_GREY32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_GREY32;
+    break;
+
+  case CMAP_GREYINV32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      mycol.red = mycol.green = mycol.blue = 65535-(i*62000/32);
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_GREYINV32;
+    break;
+
+  case CMAP_COL16 :
+    rcmap->nCol = 16;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      mycol.red = (int)(R_RGB1[i]*65535.);
+      mycol.green = (int)(G_RGB1[i]*65535.);
+      mycol.blue =(int)(B_RGB1[i]*65535.) ;
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_COL16;
+    break;
+
+  case CMAP_COLRJ32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      if (i < 12) 
+        { mycol.green = mycol.blue = 0;  
+          mycol.red = 21535+(i*4000); }
+      else if (i < 24)
+        { mycol.blue = 0;   mycol.red = 65535;
+          mycol.green = 21535+(i-12)*4000;  }
+      else 
+        { mycol.green = mycol.red = 65535;
+          mycol.blue = 17535+(i-23)*6000; }
+
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_COLRJ32;
+    break;
+
+  case CMAP_COLBR32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      if (i < 5) 
+        { mycol.green = mycol.red = 0;  
+          mycol.blue = 5535+i*15000; }
+      else if (i < 10)
+        { mycol.blue = 65535;
+          mycol.green = 5535+(i-5)*9000;
+          mycol.red = 0;  }
+      else if (i < 15)
+        { mycol.blue = 60000-(i-10)*15000;
+          mycol.green = 41535+(i-10)*6000;
+          mycol.red = 0;  }
+      else if (i < 21)
+        { mycol.blue = 0;
+          mycol.green = 65535;
+          mycol.red = 5535+(i-15)*12000;  }
+      else if (i < 27)
+        { mycol.blue = 0;
+          mycol.green = 60000-(i-21)*12000;
+          mycol.red = 65535-(i-21)*2000;  }
+      else 
+        { mycol.blue = 0;
+          mycol.green = 0;
+          mycol.red = 57535+(i-27)*2000; }
+
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_COLBR32;
+    break;
+
+  case CMAP_COLRV32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      if (i < 8) 
+        { mycol.green = 15000+(i*5000); mycol.blue = 0;  
+          mycol.red = 15000+(i*5000); }
+      else if (i < 21)
+        { mycol.green = 50000-(i-7)*5000;   
+          if (mycol.green < 0)  mycol.green = 0;
+          mycol.blue = 0;
+          mycol.red = 53535+(i-8)*1000;  }
+      else 
+        { mycol.green = 0;  mycol.red = 65535;
+          mycol.blue = 15535+(i-21)*5000; }
+
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_COLRV32;
+    break;
+
+  default :
+    printf("RzXAllocCMap_Info: Erreur specification CMapType (%d) \n", cmapid);
+    break;
+  }
+
+for(i=rcmap->nCol; i<256; i++)  rcmap->colpix[i] = 0;
+
+if (prtl)
+  printf("RzXAllocCMap_Info: %d colors allocated for CMap Type %d \n", nok, cmapid);
+
+return(0);
+
+}
+
+/* Nouvelle-Fonction */
+int RzXFreeCMap(RzXCMap *rcmap)
+{
+Colormap cmap;
+int i;
+
+cmap = XDefaultColormap (display, screen);
+XFreeColors(display, cmap, rcmap->colpix,  rcmap->nCol, 0);
+for(i=0; i<rcmap->nCol; i++)  rcmap->colpix[i] = 0;
+rcmap->nCol = 0;
+return(0);
+}
+
+
+/* Nouvelle-Fonction */
+Window RzXNewWin(int sx, int sy, char *title, int posx, int posy)
+
+/*  Creation de fenetre X simple pour mettre une image  */
+{
+XSizeHints hint;
+Window   win;
+
+hint.x = posx;   hint.y = posy;
+hint.width  = sx;  hint.height = sy;
+hint.flags  = PPosition | PSize;
+
+
+win =  XCreateSimpleWindow (display, DefaultRootWindow (display),
+       hint.x, hint.y, hint.width, hint.height, 3,
+       WhitePixel(display, screen), BlackPixel(display, screen) );                        
+
+XSetStandardProperties (display, win, title, title, None, NULL, 0, &hint);
+
+if (!rzxgcok)
+  {
+  defgc = XCreateGC (display, win, 0, 0);
+  rzxgcok = 1;
+  }
+XMapRaised(display,win);
+XSync(display,1);
+
+return(win);
+}
+#endif
+
Index: /tags/DPC_V0/Poubelle/PI/xdispim.h
===================================================================
--- /tags/DPC_V0/Poubelle/PI/xdispim.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PI/xdispim.h	(revision 1307)
@@ -0,0 +1,36 @@
+/* Fonctions interface XWindow pour affichage d'images */
+
+#ifndef XDISPIM_SEEN
+#define XDISPIM_SEEN
+
+
+#include <X11/Xlib.h>
+
+#define CMAP_GREY32         0
+#define CMAP_COL16          1
+#define CMAP_COLRJ32        2
+#define CMAP_GREYINV32      3
+#define CMAP_COLBR32        4
+#define CMAP_COLRV32        5
+
+struct _RzXCMap_
+  {
+  int typ;
+  int nCol;
+  unsigned long colpix[256];
+  };
+typedef struct _RzXCMap_  RzXCMap;
+
+int RzXInitDisplay(int prtl);
+int RzXCheckInitDisp(void);
+
+int RzXGetPixDSize(void);
+int RzXDispPixMap(Window xw, unsigned char *pix,  int sizx, int sizy, RzXCMap *cmap);
+
+RzXCMap * RzXGetCMap(int cmpaid);
+int RzXAllocCMap(RzXCMap *rcmap, int cmapid, int prtl);
+int RzXFreeCMap(RzXCMap *rcmap);
+
+Window RzXNewWin(int sx, int sy, char *title, int posx, int posy);
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/Makefile
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/Makefile	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/Makefile	(revision 1307)
@@ -0,0 +1,487 @@
+MODULECXXREPNAME := PI
+MODULEDECCXXFLAGS := -msg_quiet
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libPIext.a
+$(LIB)libPIext.a : $(OBJ)nobjmgr.o $(OBJ)piacmd.o $(OBJ)pigfd1.o $(OBJ)pigfd2.o $(OBJ)pihisto.o $(OBJ)pihisto2d.o $(OBJ)piinit.o $(OBJ)pintup3d.o $(OBJ)pintuple.o $(OBJ)pipodrw.o $(OBJ)pisiadw.o $(OBJ)pistdimgapp.o $(OBJ)servnobjm.o
+	$(AR) $(ARFLAGS)  $@ $? 
+ifeq ($(CXX),cxx)
+	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS) -L$(LIB) -lPIext -lSysTools -lNTools -lPI -o $(OBJ)xx.x -Hf
+endif 
+ 
+clean:
+	rm -f $(OBJ)nobjmgr.o $(OBJ)piacmd.o $(OBJ)pigfd1.o $(OBJ)pigfd2.o $(OBJ)pihisto.o $(OBJ)pihisto2d.o $(OBJ)piinit.o $(OBJ)pintup3d.o $(OBJ)pintuple.o $(OBJ)pipodrw.o $(OBJ)pisiadw.o $(OBJ)pistdimgapp.o $(OBJ)servnobjm.o
+ifeq ($(CXX),cxx)
+	cd $(REPM); rm -f *.o
+endif 
+ 
+$(OBJ)nobjmgr.o: nobjmgr.cc /home/ansari/DPC/Include/strutil.h \
+ /home/ansari/DPC/Include/datatypes.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/defs.h \
+ nobjmgr.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/pclassids.h dlftypes.h servnobjm.h \
+ /home/ansari/DPC/Include/ctimer.h /home/ansari/DPC/Include/peida.h \
+ /home/ansari/DPC/Include/utils.h /home/ansari/DPC/Include/fmath.h \
+ /home/ansari/DPC/Include/pdlmgr.h pistdimgapp.h \
+ /home/ansari/DPC/Include/pisysdep.h \
+ /home/ansari/DPC/Include/piapplx.h \
+ /home/ansari/DPC/Include/piapplgen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picontainerx.h \
+ /home/ansari/DPC/Include/picontainergen.h \
+ /home/ansari/DPC/Include/piwdgx.h /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimenubarx.h \
+ /home/ansari/DPC/Include/pimenubargen.h \
+ /home/ansari/DPC/Include/pimenux.h \
+ /home/ansari/DPC/Include/pimenugen.h \
+ /home/ansari/DPC/Include/picons.h \
+ /home/ansari/DPC/Include/pistdwdgx.h \
+ /home/ansari/DPC/Include/pistdwdggen.h \
+ /home/ansari/DPC/Include/pibwdgx.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h \
+ /home/ansari/DPC/Include/pigraphps.h \
+ /home/ansari/DPC/Include/piwindowx.h \
+ /home/ansari/DPC/Include/piwindowgen.h \
+ /home/ansari/DPC/Include/pioptmenux.h \
+ /home/ansari/DPC/Include/pioptmenugen.h \
+ /home/ansari/DPC/Include/pifilechox.h \
+ /home/ansari/DPC/Include/pifilechogen.h \
+ /home/ansari/DPC/Include/piimage.h \
+ /home/ansari/DPC/Include/parradapter.h /home/ansari/DPC/Include/lut.h \
+ /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pipixmapx.h \
+ /home/ansari/DPC/Include/pipixmapgen.h \
+ /home/ansari/DPC/Include/picmapview.h \
+ /home/ansari/DPC/Include/pi3ddrw.h \
+ /home/ansari/DPC/Include/pigraph3d.h piacmd.h pisiadw.h \
+ /home/ansari/DPC/Include/pilistx.h \
+ /home/ansari/DPC/Include/pilistgen.h \
+ /home/ansari/DPC/Include/pistzwin.h \
+ /home/ansari/DPC/Include/piperiodx.h \
+ /home/ansari/DPC/Include/periodic.h /home/ansari/DPC/Include/poly.h \
+ /home/ansari/DPC/Include/cvector.h /home/ansari/DPC/Include/matrix.h \
+ /home/ansari/DPC/Include/dvlist.h /home/ansari/DPC/Include/fct1dfit.h \
+ /home/ansari/DPC/Include/generalfit.h \
+ /home/ansari/DPC/Include/generaldata.h \
+ /home/ansari/DPC/Include/fct2dfit.h pimgadapter.h \
+ /home/ansari/DPC/Include/cimage.h /home/ansari/DPC/Include/rzimage.h \
+ /home/ansari/DPC/Include/rzvect.h pipodrw.h \
+ /home/ansari/DPC/Include/histos2.h /home/ansari/DPC/Include/histos.h \
+ pihisto.h /home/ansari/DPC/Include/hisprof.h pihisto2d.h \
+ /home/ansari/DPC/Include/piscdrawwdg.h pintuple.h \
+ /home/ansari/DPC/Include/ntuple.h /home/ansari/DPC/Include/pisurfdr.h \
+ pintup3d.h pigfd1.h pigfd2.h
+$(OBJ)piacmd.o: piacmd.cc /home/ansari/DPC/Include/ctimer.h \
+ /home/ansari/DPC/Include/peida.h /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h /home/ansari/DPC/Include/fmath.h \
+ nobjmgr.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h dlftypes.h piacmd.h \
+ /home/ansari/DPC/Include/pdlmgr.h pistdimgapp.h \
+ /home/ansari/DPC/Include/pisysdep.h \
+ /home/ansari/DPC/Include/piapplx.h \
+ /home/ansari/DPC/Include/piapplgen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picontainerx.h \
+ /home/ansari/DPC/Include/picontainergen.h \
+ /home/ansari/DPC/Include/piwdgx.h /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimenubarx.h \
+ /home/ansari/DPC/Include/pimenubargen.h \
+ /home/ansari/DPC/Include/pimenux.h \
+ /home/ansari/DPC/Include/pimenugen.h \
+ /home/ansari/DPC/Include/picons.h \
+ /home/ansari/DPC/Include/pistdwdgx.h \
+ /home/ansari/DPC/Include/pistdwdggen.h \
+ /home/ansari/DPC/Include/pibwdgx.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h \
+ /home/ansari/DPC/Include/pigraphps.h \
+ /home/ansari/DPC/Include/piwindowx.h \
+ /home/ansari/DPC/Include/piwindowgen.h \
+ /home/ansari/DPC/Include/pioptmenux.h \
+ /home/ansari/DPC/Include/pioptmenugen.h \
+ /home/ansari/DPC/Include/pifilechox.h \
+ /home/ansari/DPC/Include/pifilechogen.h \
+ /home/ansari/DPC/Include/piimage.h \
+ /home/ansari/DPC/Include/parradapter.h /home/ansari/DPC/Include/lut.h \
+ /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pipixmapx.h \
+ /home/ansari/DPC/Include/pipixmapgen.h \
+ /home/ansari/DPC/Include/picmapview.h \
+ /home/ansari/DPC/Include/pi3ddrw.h \
+ /home/ansari/DPC/Include/pigraph3d.h pisiadw.h \
+ /home/ansari/DPC/Include/pilistx.h \
+ /home/ansari/DPC/Include/pilistgen.h \
+ /home/ansari/DPC/Include/pistzwin.h \
+ /home/ansari/DPC/Include/piperiodx.h \
+ /home/ansari/DPC/Include/periodic.h /home/ansari/DPC/Include/histos.h \
+ /home/ansari/DPC/Include/cvector.h /home/ansari/DPC/Include/matrix.h \
+ /home/ansari/DPC/Include/histos2.h /home/ansari/DPC/Include/hisprof.h \
+ /home/ansari/DPC/Include/ntuple.h /home/ansari/DPC/Include/dvlist.h \
+ /home/ansari/DPC/Include/generaldata.h \
+ /home/ansari/DPC/Include/poly.h
+$(OBJ)pigfd1.o: pigfd1.cc pigfd1.h /home/ansari/DPC/Include/generaldata.h \
+ /home/ansari/DPC/Include/exceptions.h /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/pclassids.h /home/ansari/DPC/Include/poly.h \
+ /home/ansari/DPC/Include/peida.h /home/ansari/DPC/Include/utils.h \
+ /home/ansari/DPC/Include/fmath.h /home/ansari/DPC/Include/cvector.h \
+ /home/ansari/DPC/Include/matrix.h /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/pisysdep.h /home/ansari/DPC/Include/piwdgx.h \
+ /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h
+$(OBJ)pigfd2.o: pigfd2.cc pigfd2.h /home/ansari/DPC/Include/generaldata.h \
+ /home/ansari/DPC/Include/exceptions.h /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/pclassids.h /home/ansari/DPC/Include/poly.h \
+ /home/ansari/DPC/Include/peida.h /home/ansari/DPC/Include/utils.h \
+ /home/ansari/DPC/Include/fmath.h /home/ansari/DPC/Include/cvector.h \
+ /home/ansari/DPC/Include/matrix.h /home/ansari/DPC/Include/pi3ddrw.h \
+ /home/ansari/DPC/Include/pisysdep.h \
+ /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/piwdgx.h /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h \
+ /home/ansari/DPC/Include/pigraph3d.h \
+ /home/ansari/DPC/Include/pibwdgx.h \
+ /home/ansari/DPC/Include/pigraphps.h
+$(OBJ)pihisto.o: pihisto.cc pihisto.h /home/ansari/DPC/Include/histos.h \
+ /home/ansari/DPC/Include/peida.h /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h /home/ansari/DPC/Include/fmath.h \
+ /home/ansari/DPC/Include/cvector.h /home/ansari/DPC/Include/matrix.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/pisysdep.h /home/ansari/DPC/Include/piwdgx.h \
+ /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h /home/ansari/DPC/Include/hisprof.h
+$(OBJ)pihisto2d.o: pihisto2d.cc /home/ansari/DPC/Include/piapplgen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h /home/ansari/DPC/Include/pisysdep.h \
+ /home/ansari/DPC/Include/picontainerx.h \
+ /home/ansari/DPC/Include/picontainergen.h \
+ /home/ansari/DPC/Include/piwdgx.h /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimenubarx.h \
+ /home/ansari/DPC/Include/pimenubargen.h \
+ /home/ansari/DPC/Include/pimenux.h \
+ /home/ansari/DPC/Include/pimenugen.h \
+ /home/ansari/DPC/Include/picons.h \
+ /home/ansari/DPC/Include/pistdwdgx.h \
+ /home/ansari/DPC/Include/pistdwdggen.h \
+ /home/ansari/DPC/Include/pibwdgx.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h \
+ /home/ansari/DPC/Include/pigraphps.h pihisto2d.h \
+ /home/ansari/DPC/Include/pioptmenux.h \
+ /home/ansari/DPC/Include/pioptmenugen.h \
+ /home/ansari/DPC/Include/histos2.h /home/ansari/DPC/Include/peida.h \
+ /home/ansari/DPC/Include/utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h /home/ansari/DPC/Include/fmath.h \
+ /home/ansari/DPC/Include/histos.h /home/ansari/DPC/Include/cvector.h \
+ /home/ansari/DPC/Include/matrix.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/piscdrawwdg.h \
+ /home/ansari/DPC/Include/piwindowx.h \
+ /home/ansari/DPC/Include/piwindowgen.h \
+ /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/nbrandom.h
+$(OBJ)piinit.o: piinit.cc /home/ansari/DPC/Include/defs.h piinit.h \
+ /home/ansari/DPC/Include/outilsinit.h \
+ /home/ansari/DPC/Include/peidainit.h
+$(OBJ)pintup3d.o: pintup3d.cc pintup3d.h /home/ansari/DPC/Include/ntuple.h \
+ /home/ansari/DPC/Include/ppersist.h /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/dvlist.h /home/ansari/DPC/Include/pi3ddrw.h \
+ /home/ansari/DPC/Include/pisysdep.h \
+ /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/piwdgx.h /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h \
+ /home/ansari/DPC/Include/pigraph3d.h \
+ /home/ansari/DPC/Include/pibwdgx.h \
+ /home/ansari/DPC/Include/pigraphps.h
+$(OBJ)pintuple.o: pintuple.cc pintuple.h /home/ansari/DPC/Include/ntuple.h \
+ /home/ansari/DPC/Include/ppersist.h /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/dvlist.h /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/pisysdep.h /home/ansari/DPC/Include/piwdgx.h \
+ /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h
+$(OBJ)pipodrw.o: pipodrw.cc pipodrw.h /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/pisysdep.h /home/ansari/DPC/Include/piwdgx.h \
+ /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/defs.h /home/ansari/DPC/Include/picmap.h \
+ /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h \
+ /home/ansari/DPC/Include/parradapter.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/lut.h \
+ /home/ansari/DPC/Include/cvector.h /home/ansari/DPC/Include/matrix.h \
+ /home/ansari/DPC/Include/peida.h /home/ansari/DPC/Include/utils.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h /home/ansari/DPC/Include/fmath.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/histos2.h /home/ansari/DPC/Include/histos.h \
+ /home/ansari/DPC/Include/generalfit.h \
+ /home/ansari/DPC/Include/generaldata.h \
+ /home/ansari/DPC/Include/poly.h
+$(OBJ)pisiadw.o: pisiadw.cc /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/defs.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/ctimer.h /home/ansari/DPC/Include/peida.h \
+ /home/ansari/DPC/Include/utils.h /home/ansari/DPC/Include/fmath.h \
+ /home/ansari/DPC/Include/nbmath.h pistdimgapp.h \
+ /home/ansari/DPC/Include/pisysdep.h \
+ /home/ansari/DPC/Include/piapplx.h \
+ /home/ansari/DPC/Include/piapplgen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picontainerx.h \
+ /home/ansari/DPC/Include/picontainergen.h \
+ /home/ansari/DPC/Include/piwdgx.h /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimenubarx.h \
+ /home/ansari/DPC/Include/pimenubargen.h \
+ /home/ansari/DPC/Include/pimenux.h \
+ /home/ansari/DPC/Include/pimenugen.h \
+ /home/ansari/DPC/Include/picons.h \
+ /home/ansari/DPC/Include/pistdwdgx.h \
+ /home/ansari/DPC/Include/pistdwdggen.h \
+ /home/ansari/DPC/Include/pibwdgx.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h \
+ /home/ansari/DPC/Include/pigraphps.h \
+ /home/ansari/DPC/Include/piwindowx.h \
+ /home/ansari/DPC/Include/piwindowgen.h \
+ /home/ansari/DPC/Include/pioptmenux.h \
+ /home/ansari/DPC/Include/pioptmenugen.h \
+ /home/ansari/DPC/Include/pifilechox.h \
+ /home/ansari/DPC/Include/pifilechogen.h \
+ /home/ansari/DPC/Include/piimage.h \
+ /home/ansari/DPC/Include/parradapter.h /home/ansari/DPC/Include/lut.h \
+ /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pipixmapx.h \
+ /home/ansari/DPC/Include/pipixmapgen.h \
+ /home/ansari/DPC/Include/picmapview.h \
+ /home/ansari/DPC/Include/pi3ddrw.h \
+ /home/ansari/DPC/Include/pigraph3d.h nobjmgr.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h dlftypes.h piacmd.h \
+ /home/ansari/DPC/Include/pdlmgr.h pisiadw.h \
+ /home/ansari/DPC/Include/pilistx.h \
+ /home/ansari/DPC/Include/pilistgen.h \
+ /home/ansari/DPC/Include/pistzwin.h \
+ /home/ansari/DPC/Include/piperiodx.h \
+ /home/ansari/DPC/Include/periodic.h servnobjm.h
+$(OBJ)pistdimgapp.o: pistdimgapp.cc /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/defs.h /home/ansari/DPC/Include/strutil.h \
+ /home/ansari/DPC/Include/timing.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/ctimer.h /home/ansari/DPC/Include/peida.h \
+ /home/ansari/DPC/Include/utils.h /home/ansari/DPC/Include/fmath.h \
+ /home/ansari/DPC/Include/psighand.h /home/ansari/DPC/Include/cimage.h \
+ /home/ansari/DPC/Include/rzimage.h /home/ansari/DPC/Include/rzvect.h \
+ /home/ansari/DPC/Include/datatypes.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/dvlist.h pistdimgapp.h \
+ /home/ansari/DPC/Include/pisysdep.h \
+ /home/ansari/DPC/Include/piapplx.h \
+ /home/ansari/DPC/Include/piapplgen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picontainerx.h \
+ /home/ansari/DPC/Include/picontainergen.h \
+ /home/ansari/DPC/Include/piwdgx.h /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimenubarx.h \
+ /home/ansari/DPC/Include/pimenubargen.h \
+ /home/ansari/DPC/Include/pimenux.h \
+ /home/ansari/DPC/Include/pimenugen.h \
+ /home/ansari/DPC/Include/picons.h \
+ /home/ansari/DPC/Include/pistdwdgx.h \
+ /home/ansari/DPC/Include/pistdwdggen.h \
+ /home/ansari/DPC/Include/pibwdgx.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h \
+ /home/ansari/DPC/Include/pigraphps.h \
+ /home/ansari/DPC/Include/piwindowx.h \
+ /home/ansari/DPC/Include/piwindowgen.h \
+ /home/ansari/DPC/Include/pioptmenux.h \
+ /home/ansari/DPC/Include/pioptmenugen.h \
+ /home/ansari/DPC/Include/pifilechox.h \
+ /home/ansari/DPC/Include/pifilechogen.h \
+ /home/ansari/DPC/Include/piimage.h \
+ /home/ansari/DPC/Include/parradapter.h /home/ansari/DPC/Include/lut.h \
+ /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pipixmapx.h \
+ /home/ansari/DPC/Include/pipixmapgen.h \
+ /home/ansari/DPC/Include/picmapview.h \
+ /home/ansari/DPC/Include/pi3ddrw.h \
+ /home/ansari/DPC/Include/pigraph3d.h nobjmgr.h dlftypes.h piacmd.h \
+ /home/ansari/DPC/Include/pdlmgr.h pisiadw.h \
+ /home/ansari/DPC/Include/pilistx.h \
+ /home/ansari/DPC/Include/pilistgen.h \
+ /home/ansari/DPC/Include/pistzwin.h \
+ /home/ansari/DPC/Include/piperiodx.h \
+ /home/ansari/DPC/Include/periodic.h pihisto2d.h \
+ /home/ansari/DPC/Include/histos2.h /home/ansari/DPC/Include/histos.h \
+ /home/ansari/DPC/Include/cvector.h /home/ansari/DPC/Include/matrix.h \
+ /home/ansari/DPC/Include/piscdrawwdg.h \
+ /home/ansari/DPC/Include/piimgtools.h \
+ /home/ansari/DPC/Include/pidrwtools.h
+$(OBJ)servnobjm.o: servnobjm.cc /home/ansari/DPC/Include/strutil.h \
+ /home/ansari/DPC/Include/datatypes.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/defs.h \
+ nobjmgr.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/pclassids.h dlftypes.h servnobjm.h \
+ /home/ansari/DPC/Include/ctimer.h /home/ansari/DPC/Include/peida.h \
+ /home/ansari/DPC/Include/utils.h /home/ansari/DPC/Include/fmath.h \
+ /home/ansari/DPC/Include/pdlmgr.h pistdimgapp.h \
+ /home/ansari/DPC/Include/pisysdep.h \
+ /home/ansari/DPC/Include/piapplx.h \
+ /home/ansari/DPC/Include/piapplgen.h \
+ /home/ansari/DPC/Include/pimsghandler.h \
+ /home/ansari/DPC/Include/picontainerx.h \
+ /home/ansari/DPC/Include/picontainergen.h \
+ /home/ansari/DPC/Include/piwdgx.h /home/ansari/DPC/Include/piwdggen.h \
+ /home/ansari/DPC/Include/pimenubarx.h \
+ /home/ansari/DPC/Include/pimenubargen.h \
+ /home/ansari/DPC/Include/pimenux.h \
+ /home/ansari/DPC/Include/pimenugen.h \
+ /home/ansari/DPC/Include/picons.h \
+ /home/ansari/DPC/Include/pistdwdgx.h \
+ /home/ansari/DPC/Include/pistdwdggen.h \
+ /home/ansari/DPC/Include/pibwdgx.h \
+ /home/ansari/DPC/Include/pibwdggen.h \
+ /home/ansari/DPC/Include/picmap.h /home/ansari/DPC/Include/picmapx.h \
+ /home/ansari/DPC/Include/picmapgen.h \
+ /home/ansari/DPC/Include/pigraphx.h \
+ /home/ansari/DPC/Include/pigraphgen.h \
+ /home/ansari/DPC/Include/pigraphuc.h \
+ /home/ansari/DPC/Include/pievthandler.h \
+ /home/ansari/DPC/Include/psfile.h \
+ /home/ansari/DPC/Include/pigraphps.h \
+ /home/ansari/DPC/Include/piwindowx.h \
+ /home/ansari/DPC/Include/piwindowgen.h \
+ /home/ansari/DPC/Include/pioptmenux.h \
+ /home/ansari/DPC/Include/pioptmenugen.h \
+ /home/ansari/DPC/Include/pifilechox.h \
+ /home/ansari/DPC/Include/pifilechogen.h \
+ /home/ansari/DPC/Include/piimage.h \
+ /home/ansari/DPC/Include/parradapter.h /home/ansari/DPC/Include/lut.h \
+ /home/ansari/DPC/Include/pidrawer.h \
+ /home/ansari/DPC/Include/pipixmapx.h \
+ /home/ansari/DPC/Include/pipixmapgen.h \
+ /home/ansari/DPC/Include/picmapview.h \
+ /home/ansari/DPC/Include/pi3ddrw.h \
+ /home/ansari/DPC/Include/pigraph3d.h piacmd.h pisiadw.h \
+ /home/ansari/DPC/Include/pilistx.h \
+ /home/ansari/DPC/Include/pilistgen.h \
+ /home/ansari/DPC/Include/pistzwin.h \
+ /home/ansari/DPC/Include/piperiodx.h \
+ /home/ansari/DPC/Include/periodic.h /home/ansari/DPC/Include/histos.h \
+ /home/ansari/DPC/Include/cvector.h /home/ansari/DPC/Include/matrix.h \
+ /home/ansari/DPC/Include/histos2.h /home/ansari/DPC/Include/ntuple.h \
+ /home/ansari/DPC/Include/dvlist.h /home/ansari/DPC/Include/hisprof.h \
+ /home/ansari/DPC/Include/generaldata.h \
+ /home/ansari/DPC/Include/poly.h /home/ansari/DPC/Include/cimage.h \
+ /home/ansari/DPC/Include/rzimage.h /home/ansari/DPC/Include/rzvect.h
Index: /tags/DPC_V0/Poubelle/PIext/PIext.o.list
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/PIext.o.list	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/PIext.o.list	(revision 1307)
@@ -0,0 +1,13 @@
+nobjmgr.o
+piacmd.o
+pigfd1.o
+pigfd2.o
+pihisto.o
+pihisto2d.o
+piinit.o
+pintup3d.o
+pintuple.o
+pipodrw.o
+pisiadw.o
+pistdimgapp.o
+servnobjm.o
Index: /tags/DPC_V0/Poubelle/PIext/dlftypes.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/dlftypes.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/dlftypes.h	(revision 1307)
@@ -0,0 +1,22 @@
+// This may look like C code, but it is really -*- C++ -*-
+// typedef pour link dynamique de piapp  
+// Reza                     Juillet,Aout 98
+// LAL-IN2P3/CNRS
+
+#ifndef DLFTPES_H_SEEN
+#define DLFTYPES_H_SEEN
+
+#include <string>
+#include <vector>
+#if defined(__KCC__)
+using std::string ;
+#include <vector.h>
+#endif
+
+typedef double (* DlFunctionOfX) (double x);
+typedef double (* DlFunctionOfXY) (double x, double y);
+typedef int (* PlotExprFunc) (float* x, float* rx, float* ry, float* rz, float* wt);
+typedef void (* DlUserProcFunction) (vector<string>& args);
+
+#endif
+
Index: /tags/DPC_V0/Poubelle/PIext/exclude
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/exclude	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/exclude	(revision 1307)
@@ -0,0 +1,1 @@
+pistlist.cc
Index: /tags/DPC_V0/Poubelle/PIext/nobjmgr.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/nobjmgr.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/nobjmgr.cc	(revision 1307)
@@ -0,0 +1,2073 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <iostream.h>
+#include <string>
+#include <list>
+#include <map>
+#if defined(__KCC__)
+using std::string ;
+#include <list.h>
+#include <map.h>
+#endif
+
+#include "strutil.h"
+#include "datatypes.h"
+//EVOL-PLANCK #include "fitsimage.h"  
+
+#include "nobjmgr.h"
+#include "servnobjm.h"
+#include "pistdimgapp.h"
+
+#include "pclassids.h"
+#include "poly.h"
+#include "dvlist.h"
+#include "matrix.h"
+#include "cvector.h"
+//EVOL-PLANCK #include "zfidu.h"  
+//EVOL-PLANCK #include "fft.h"
+
+#include "fct1dfit.h"
+#include "fct2dfit.h"
+
+#include "pimgadapter.h"
+#include "pipodrw.h"
+
+#include "pihisto.h"
+#include "hisprof.h"
+#include "pihisto2d.h"
+#include "pintuple.h"
+#include "pisurfdr.h"  
+#include "pintup3d.h"
+#include "pigfd1.h"
+#include "pigfd2.h"
+
+//  Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
+#ifdef SANS_EVOLPLANCK 
+#include "pistlist.h"
+#include "transfo.h"
+#endif
+
+//++
+// Class	NamedObjMgr
+// Lib		PI
+// include	nobjmgr.h
+//
+//	Cette classe fournit les services nécéssaire àla gestion des objets
+//	(l'ensemble des objets PPersist de PEIDA++) au sein du programme
+//	d'analyse interactive *piapp* . Elle constitue en outre l'interface
+//	entre les fonctions utilisateur et l'application graphique.
+//--
+//++
+// Links	Voir aussi
+// PIStdImgApp
+// Services2NObjMgr
+// PIACmd
+//--
+
+
+// ..................................................................
+// ......  Gestion des objets nommes, variables globales ............
+struct nobj_item {
+  PPersist* obj;
+  int num;
+  list<int> wrsid;
+  bool operator==(nobj_item const& b) const
+    { return (this->obj ==  b.obj); }
+};
+
+typedef map<string, nobj_item, less<string> > NObjList;
+
+static NObjList* myObjs;
+static int fgOInit = 0;
+static int myNObj = 0;
+static string* lastobj = NULL;
+
+static PIStdImgApp* myImgApp=NULL;
+static Services2NObjMgr* servnobjm=NULL;
+
+static string* TmpDir;  // Repertoire pour les compilations / link dynamique
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// NamedObjMgr()
+//	Constructeur. Les différents instantiation de la classe "NamedObjMgr" 
+//	dans une même application créent des objets qui travaillent sur la même
+//	liste d'objets. Les objets de cette classe ne possedent en effet pas
+//	de variables membres. 
+//--
+
+/* --Methode-- */
+NamedObjMgr::NamedObjMgr()
+{
+if (fgOInit == 0) { 
+  myObjs = new NObjList;  
+  lastobj = new string(""); 
+  char* varenv;
+  TmpDir = new string("");
+  if ( (varenv=getenv("PEIDA_TMP")) != NULL )  (*TmpDir) = varenv; 
+  else if ( (varenv=getenv("TMPDIR")) != NULL )  (*TmpDir) = varenv; 
+  int l = (*TmpDir).length();
+  if ( (l>0) && ((*TmpDir)[l-1] != '/') )  (*TmpDir) += '/';
+  servnobjm = new Services2NObjMgr(NULL, (*TmpDir));
+  }
+fgOInit++;
+}
+
+  
+/* --Methode-- */
+NamedObjMgr::~NamedObjMgr()
+{
+fgOInit--;
+if (fgOInit == 0)  delete myObjs;
+}
+
+//++
+// Titre	Méthodes
+//--
+//++
+// void SetImgApp(PIStdImgApp* app)
+//	Spécifie l'objet "PIStdImgApp" associé.
+// PIStdImgApp* GetImgApp()
+//	Accès à l'objet "PIStdImgApp" associé.
+//--
+
+/* --Methode-- */
+void NamedObjMgr::SetImgApp(PIStdImgApp* app)
+{
+myImgApp = app;
+servnobjm->SetImgApp(app);
+}
+
+/* --Methode-- */
+PIStdImgApp* NamedObjMgr::GetImgApp()
+{
+return(myImgApp);
+}
+
+/* --Methode-- */
+Services2NObjMgr* NamedObjMgr::GetServiceObj()
+{
+return(servnobjm);
+}
+
+//++
+// Titre	Gestion de la liste des objets
+//--
+//++
+// void AddObj(PPersist* obj, string& nom)
+//	Ajoute l'objet "obj" à la liste, identifié par "nom".
+//	Si un objet de même nom existe, l'ancien objet est renommé en concaténant 
+//	un numéro à son nom.
+// void DelObj(string const& nom, bool fgd=true)
+//	Supprime l'objet "nom" de la liste. L'objet est détruit si "fgd==true"	("delete obj")
+// void DelObjects(string const& patt, bool fgd=true)
+//	Supprime l'ensemble des objets dont le nom correspond au patron "patt".
+//	Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
+// PPersist*  GetObj(string const& nom) 
+//	Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est 
+//	pas dans la liste.
+// void  RenameObj(string const& nom, string& nomnew)
+//	Change le nom d'un objet dans la liste.
+// string  LastObjName()
+//	Renvoie le nom du dernier objet ajouté à la liste
+//--
+
+
+/* --Methode-- */
+void NamedObjMgr::AddObj(PPersist* obj, string& nom)
+{
+
+if (obj == NULL)  return;
+// on supprime les blancs de debut et de fin 
+size_t p = nom.find_first_not_of(" ");
+if(p>nom.length()) {
+  nom = "";
+} else {
+  nom = nom.substr(p);
+  p = nom.find_first_of(" ");
+  if(p>nom.length()) p=nom.length();
+  nom = nom.substr(0, p);
+}
+
+myNObj++;
+if (nom.length() < 1) nom = servnobjm->PClassIdToShortClassName(obj->ClassId());
+NObjList::iterator it = myObjs->find(nom);
+if (it != myObjs->end()) { // l'objet existe deja
+  char strg[16];
+  sprintf(strg, "%d", myNObj);
+  string nomnew = nom + strg;
+  RenameObj(nom, nomnew);
+  }
+
+(*lastobj) = nom;
+nobj_item no;
+no.obj = obj;
+no.num =  myNObj;
+(*myObjs)[(*lastobj)] = no;
+if (myImgApp)  { 
+  string str = (*lastobj) + "    (T= " + servnobjm->PClassIdToClassName(obj->ClassId()) + ")" ;
+  (myImgApp->ObjMgrW())->AddObj(str.c_str(), myNObj+1000);
+}
+ 
+cout << "NamedObjMgr::AddObj()  Object " << (*lastobj) << " ( "  
+     << servnobjm->PClassIdToClassName(obj->ClassId()) << " ) added (Total= " << myObjs->size() << ")" << endl;  
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::DelObj(string const& nom, bool fgd)
+{
+NObjList::iterator it = myObjs->find(nom);
+if (it == myObjs->end()) return; 
+list<int>::iterator ii;
+if (myImgApp) {
+//DBG  cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl; 
+  for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++) 
+      myImgApp->DelWRsId((*ii));
+  (myImgApp->ObjMgrW())->DelObj((*it).second.num+1000);
+}
+if (fgd) delete (*it).second.obj;
+myObjs->erase(it);
+if (fgd) cout << "NamedObjMgr::DelObj()  Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
+else  cout << "NamedObjMgr::DelObj()  Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
+return;  
+}
+
+/* --Methode-- */
+void NamedObjMgr::DelObjects(string const& patt, bool fgd)
+{
+NObjList::iterator it;  
+list<string> odel;
+string cn;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) != 0)  odel.push_back(cn);
+  }
+list<string>::iterator ii;
+for(ii=odel.begin(); ii != odel.end(); ii++)  DelObj(*ii, fgd);
+}
+
+/* --Methode-- */
+PPersist* NamedObjMgr::GetObj(string const& nom)
+{
+NObjList::iterator it = myObjs->find(nom);
+if (it == myObjs->end()) return(NULL); 
+return((*it).second.obj);
+}
+
+/* --Methode-- */
+void NamedObjMgr::RenameObj(string const& nom, string& nomnew)
+{
+PPersist* obj = GetObj(nom);
+if (obj == NULL) return;
+DelObj(nom, false);
+AddObj(obj, nomnew);
+return;
+}
+
+/* --Methode-- */
+string NamedObjMgr::LastObjName()
+{
+return((*lastobj));
+}
+
+//++
+// Titre	Entrées-Sorties (I/O) sur les objets
+//--
+//++
+// void  ReadObj(PInPersist& s, int num=-1)
+//	Lit l'objet à partir avec le tag numéro "num" dans le flot "PInPersist s"
+//	et l'ajoute à la liste. Si "num" est négatif, tous les objets présents
+//	sur le flot "s" sont créés et ajoutés à la liste.
+// void  ReadObj(string const & nomppf, string nobj="")
+//	Lit le premier objet à partir du fichier PPF "nomppf". L'objet est ajouté
+//	à la liste avec le nom "nobj". Si "nobj" est une chaîne vide, un nom est 
+//	composé à partir du nom de fichier. 
+//--
+
+/* --Methode-- */
+void NamedObjMgr::ReadObj(string const & flnm, string nobj)
+{
+PPersist* obj=NULL;
+bool ok = true;
+
+TRY{
+  PInPersist pis(flnm);
+  obj = PPersistMgr::ReadObject(pis);
+  if (obj == NULL) ok = false;
+}  CATCH(merr) 
+  { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", 
+    (long)merr, PeidaExc(merr));  ok = false; } ENDTRY;
+
+if (!ok)  return;
+if (nobj.length()<1)  nobj = servnobjm->FileName2Name(flnm);
+AddObj(obj, nobj);
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::ReadObj(PInPersist& s, int num)
+{
+int i, cid, key, ln;
+int n0, n1;
+bool ok = true;
+PPersist* obj=NULL;
+string nom;
+
+if ( (s.NbTags() < 1) || (num >= s.NbTags()) ) {
+  if (num >= 0) { 
+    printf("NamedObjMgr::ReadObj(PInPersist, %d) Error! NbTags = %d \n", num, s.NbTags());
+    return;
+  }
+  TRY {
+    obj = PPersistMgr::ReadObject(s);
+    if (obj == NULL)  ok = false;
+  }  CATCH(merr) { 
+    printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr)); 
+    ok = false; 
+  } ENDTRY;
+  if (!ok)  return;
+  nom = "";
+  AddObj(obj, nom);
+}
+ 
+if (num < 0) { n0 = 0; n1 = s.NbTags(); } 
+else { n0 = num; n1 = num+1; }
+for(i=n0; i<n1; i++) {
+  key = s.TagKey(i, cid, ln); 
+  if (ln <= 0)  nom = "";
+  else nom = s.TagName(i);
+  s.GotoTag(i);
+  TRY {
+    obj = PPersistMgr::ReadObject(s);
+    if (obj == NULL)  ok = false;
+  }  CATCH(merr) { 
+    printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr)); 
+    ok = false; 
+  } ENDTRY;
+  if (ok)  AddObj(obj, nom);  
+}
+
+return;
+}
+/* --Methode-- */
+void NamedObjMgr::ReadAll(string const & flnm)
+{
+bool ok = true;
+PPersist* obj=NULL;
+
+PInPersist* ppin;
+TRY{
+  ppin = new PInPersist(flnm);
+  if (ppin->NbTags() < 1)  obj = PPersistMgr::ReadObject((*ppin));
+  else obj = NULL;
+}  CATCH(merr) 
+  { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n", 
+    (long)merr, PeidaExc(merr));  ok = false; } ENDTRY;
+
+if (!ok)  return;
+if (obj) {
+  string nom = servnobjm->FileName2Name(flnm);
+  AddObj(obj, nom);
+  }
+else ReadObj((*ppin), -1);
+delete ppin;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::ReadFits(string const & flnm, string nobj)
+{
+bool ok = true;
+RzImage* obj;
+
+TRY{
+//  obj = RzReadFits((char*)flnm.c_str(), ImgOffX, ImgOffY, ImgSizX, ImgSizY, ImgBitSgn);
+#ifdef SANS_EVOLPLANCK 
+  obj = RzReadFits((char*)flnm.c_str());
+#else
+  printf("NamedObjMgr::ReadFITS( NON-Disponible EVOL-PLANCK) \n"); 
+  obj = NULL;
+#endif
+  if (obj == NULL)   ok = false;
+}  CATCH(merr) { 
+  printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr)); 
+  ok = false; 
+} ENDTRY;
+if (ok) { 
+  if (nobj.length()<1)  nobj = servnobjm->FileName2Name(flnm);
+  AddObj((PPersist*)obj, nobj);
+}
+return;
+}
+
+
+static int key_for_write = 5000;
+/* --Methode-- */
+void NamedObjMgr::SaveObj(string const& nom, POutPersist& s)
+{
+PPersist* obj=NULL;
+obj = GetObj(nom);
+if (obj == NULL)  return;
+printf("NamedObjMgr::SaveObj(%s, )  (Type=%s) \n",  
+       nom.c_str(), servnobjm->PClassIdToClassName(obj->ClassId()));
+string nm = nom;  // A cause de const 
+obj->Write(s,  key_for_write, nm);
+key_for_write++;
+return; 
+}
+
+/* --Methode-- */
+void NamedObjMgr::SaveAll(string const& flnm)
+{
+bool ok = true;
+
+POutPersist* pout;
+TRY{
+  pout = new POutPersist(flnm);
+}  CATCH(merr) 
+  { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n", 
+    (long)merr, PeidaExc(merr));  ok = false; } ENDTRY;
+if (!ok)  return;
+NObjList::iterator it; 
+for(it = myObjs->begin(); it != myObjs->end(); it++) SaveObj((*it).first, (*pout));
+delete pout;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::SaveFits(string const& nom, string const & flnm)
+{
+
+#ifndef SANS_EVOLPLANCK 
+printf("NamedObjMgr::SaveFITS( NON-Disponible EVOL-PLANCK) \n"); 
+return;
+
+#else
+
+PPersist* obj=NULL;
+obj = GetObj(nom);
+if (obj == NULL)  return;
+int cid = obj->ClassId();
+if ( (cid < ClassId_Image) && ( cid > ClassId_Image+kr_8) ) {
+  printf("NamedObjMgr::SaveFits(%s, ) Error - Object is NOT an image (type=%s) \n",
+         nom.c_str(), servnobjm->PClassIdToClassName(obj->ClassId()) );
+  return;
+}
+
+RzImage* pim = (RzImage*)obj;
+TRY { 
+  switch (pim->PixelType()) {
+    case kuint_2:
+      {
+      FitsImageU2 imgfits(*pim);
+      imgfits.Save(flnm); 
+      }
+    break;
+    case kint_2:
+      {
+      FitsImageI2 imgfits(*pim);
+      imgfits.Save(flnm); 
+      }
+      break;
+    case kint_4:
+      {
+      FitsImageI4 imgfits(*pim);
+      imgfits.Save(flnm); 
+      }
+      break;
+    case kr_4:
+      {
+      FitsImageR4 imgfits(*pim);
+      imgfits.Save(flnm); 
+      }
+      break;
+    default :
+      printf("NamedObjMgr::SaveObj()/Error Type d'image (%d) NON supporte en FITS \n", 
+             (int)pim->PixelType());
+      break;
+  }
+}  CATCH(merr) { 
+  printf("NamedObjMgr::SaveObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
+} ENDTRY;
+
+#endif
+
+return;
+}
+
+
+/* --Methode-- */
+void NamedObjMgr::ListObjs()
+{
+int k;
+PPersist* obj=NULL;
+string ctyp;
+char strg[256];
+int cid;
+
+cout << "NamedObjMgr::ListObjs() NObjs= " << myObjs->size() << "\n" ;
+NObjList::iterator it;  k = 0;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  obj = (*it).second.obj;
+
+  cid = obj->ClassId();
+  ctyp = servnobjm->PClassIdToClassName(cid);
+  sprintf(strg, "%2d/ %16s : %s", k, servnobjm->PClassIdToClassName(obj->ClassId()), ((*it).first).c_str()); 
+  ctyp = strg;
+  cout << ctyp << "\n" ;
+  k++;
+}
+cout << endl;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::PrintObj(string const& nom)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::PrintObj() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+
+int cid = obj->ClassId();
+string ctyp = servnobjm->PClassIdToClassName(cid);
+
+cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp 
+     << "Cid= " << cid << ")" << endl;
+
+int i4dum;
+switch (cid) {
+  case ClassId_Poly1 : 
+    ((Poly*)obj)->Print(cout);
+    break;
+  case ClassId_Poly2 : 
+    ((Poly2*)obj)->Print(cout);
+    break;
+  case ClassId_Matrix : 
+  case ClassId_Vector : 
+    cout << *((Matrix*)obj);
+    break;
+
+  case ClassId_DVList : 
+    ((DVList*)obj)->Print();
+    break;
+
+  case ClassId_Histo1D : 
+    ((Histo*)obj)->Print(60);
+    break;
+  case ClassId_Histo2D : 
+    ((Histo2D*)obj)->Print();
+    break;
+  case ClassId_HProf : 
+    ((HProf*)obj)->Print(60);
+    break;
+  case ClassId_NTuple : 
+    cout << ((NTuple*)obj)->Info();
+    cout << *((NTuple*)obj);
+    break;
+  case ClassId_GeneralFitData : 
+    ((GeneralFitData*)obj)->PrintStatus();
+    i4dum = ((GeneralFitData*)obj)->NData();
+    if(i4dum>0) {
+      ((GeneralFitData*)obj)->PrintData(0);
+      ((GeneralFitData*)obj)->PrintData(i4dum-1);
+    }
+    break;
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kuint_4 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 : 
+  case ClassId_Image + kr_8 : 
+    ((RzImage*)obj)->Print();
+    break;
+
+#ifdef SANS_EVOLPLANCK 
+  case ClassId_ZFidu : 
+    ((ZFidu*)obj)->Print();
+    break;
+
+  case ClassId_StarList : 
+    ((StarList*)obj)->Print(10, 1, 50);
+    break;
+  case ClassId_Transfo : 
+    ((Transfo*)obj)->Print(cout);
+    break;
+  case ClassId_PSF : 
+    break;
+
+  case ClassId_Star + BStar_Type : 
+  case ClassId_Star + RzStar_Type : 
+  case ClassId_Star + PSFStar_Type : 
+  case ClassId_Star + MCStar_Type : 
+  case ClassId_Star + CircRFixStar_Type : 
+  case ClassId_Star + PSFDHStar_Type : 
+  case ClassId_Star + PSFSEStar_Type : 
+  case ClassId_Star + MCDHStar_Type : 
+    ((BStar*)obj)->Print(1);
+    break;
+#endif
+
+// - Ajout objet PPF
+  default:
+    break;
+  }
+cout << endl;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::DisplayObj(string const& nom, string dopt) 
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplayObj() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return;
+ 
+int cid = obj->ClassId();
+string ctyp = servnobjm->PClassIdToClassName(cid);
+
+int wrsid = 0;
+bool fgsr = true;
+// On veut tracer une ligne pour vecteur et histo1D par defaut
+if ( (cid == ClassId_Vector) || (cid == ClassId_Histo1D) )  dopt = "thinline," + dopt;
+else if(cid == ClassId_HProf)  dopt = "fcirclemarker5," + dopt;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+
+switch (cid) {
+  case ClassId_Poly1 : 
+  case ClassId_Poly2 : 
+  case ClassId_DVList : 
+    cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl; 
+    break;
+
+  case ClassId_Matrix : 
+    {
+    wrsid = myImgApp->DispImage(new POMatrixAdapter((Matrix*)obj, false), nom, opt);
+    break;
+    }
+  case ClassId_Vector : 
+    {
+    PIYfXDrawer* dr = new   PIYfXDrawer( new POVectorAdapter((Vector*)obj, false), NULL, true);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)dr, nom, opt);    
+    break;
+    }
+  case ClassId_Histo1D : 
+    {
+    PIHisto* pih = new PIHisto(((Histo*)obj), false);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pih, nom, opt);
+    break;
+    }
+  case ClassId_Histo2D : 
+    {
+    PIHisto2D* pih2 = new PIHisto2D(((Histo2D*)obj), false);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pih2, nom, opt, nom, true);
+    break;
+    }
+  case ClassId_HProf : 
+    {
+    PIHisto* pihp = new PIHisto(((Histo*)obj), false);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pihp, nom, opt);
+    break;
+    }
+  case ClassId_GeneralFitData : 
+    {
+    GeneralFitData* gfd = (GeneralFitData*)obj;
+    if(gfd->NVar()==1) {
+      PIGenFitDat* pigfd = new PIGenFitDat(gfd,false);
+      wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,nom,opt);
+    } else if(gfd->NVar()==2) {
+      PIGenFitDat3D* pigfd = new PIGenFitDat3D(gfd,false);
+      wrsid = myImgApp->Disp3DDrawer(pigfd,nom,opt);
+    } else {
+      cout<<"NamedObjMgr::DisplayObj() Error , Utilisez DisplayGFD pour GeneralFitData "
+          <<ctyp<<"\n de "<<gfd->NVar()<<" variables (!=1,2)"<<endl; 
+    }
+    break;
+    }
+
+  case ClassId_NTuple : 
+    cout << "NamedObjMgr::DisplayObj() Error , Utilisez DisplayNt pour NTuple " << ctyp << endl; 
+    break;
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kr_8 : 
+  case ClassId_Image + kuint_4 : 
+    wrsid = myImgApp->DispImage(new RzImageAdapter((RzImage*)obj, false), nom, opt);
+    break;
+  case ClassId_Image + kuint_2 : 
+    wrsid = myImgApp->DispImage(new ImageAdapter<uint_2>((ImageU2*)obj, false), nom, opt);
+    break;
+  case ClassId_Image + kint_2 : 
+    wrsid = myImgApp->DispImage(new ImageAdapter<int_2>((ImageI2*)obj, false), nom, opt);
+    break;
+  case ClassId_Image + kint_4 : 
+    wrsid = myImgApp->DispImage(new ImageAdapter<int_4>((ImageI4*)obj, false), nom, opt);
+    break;
+  case ClassId_Image + kr_4 : 
+    wrsid = myImgApp->DispImage(new ImageAdapter<r_4>((ImageR4*)obj, false), nom, opt);
+    break;
+
+#ifdef SANS_EVOLPLANCK 
+  case ClassId_ZFidu : 
+    {
+    int nx = ((ZFidu*)obj)->XMax() -  ((ZFidu*)obj)->XMin();
+    int ny = ((ZFidu*)obj)->YMax() -  ((ZFidu*)obj)->YMin();
+    if (nx > 1024)  nx = 1024;
+    if (ny > 1024)  ny = 1024;
+    if (nx < 128)  nx = 128;
+    if (ny < 128)  nx = 128;
+    ImageU2* msk = ((ZFidu*)obj)->MakeBadZoneMask(nx, ny);
+    myImgApp->DispImage(new ImageAdapter<uint_2>((ImageU2*)msk, true), nom, opt);
+    break;
+    }
+
+  case ClassId_StarList : 
+    {
+    PIStarList* pist = new PIStarList(((StarList*)obj), false);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pist, nom, opt);
+    break;
+    }
+
+  case ClassId_Transfo : 
+  case ClassId_PSF : 
+  case ClassId_Star + BStar_Type : 
+  case ClassId_Star + RzStar_Type : 
+  case ClassId_Star + PSFStar_Type : 
+  case ClassId_Star + MCStar_Type : 
+  case ClassId_Star + CircRFixStar_Type : 
+  case ClassId_Star + PSFDHStar_Type : 
+  case ClassId_Star + PSFSEStar_Type : 
+  case ClassId_Star + MCDHStar_Type : 
+    cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl; 
+    break;
+#endif
+
+// - Ajout objet PPF
+  default:
+    break;
+  }
+
+if(wrsid != 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+return;
+}
+
+
+/* --Methode-- */
+void NamedObjMgr::DisplayNT(string const& nom, string& nmx, string& nmy, string& nmz,
+                            string& erx, string& ery, string& erz, string dopt)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplayNT() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return; 
+
+int cid = obj->ClassId();
+if (cid != ClassId_NTuple) { 
+  string ctyp = servnobjm->PClassIdToClassName(cid);
+  cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl; 
+  return;
+  }
+
+int wrsid = 0;
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+
+if (nmz.length()>0)  { // Display 3D
+  PINTuple3D* pin = new PINTuple3D(((NTuple*)obj), false);
+  pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
+  pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
+  string titre = nmz + "%" + nmy + "%" + nmz;
+  wrsid = myImgApp->Disp3DDrawer(pin, nom, opt, titre);  
+}
+else {
+  PINTuple* pin = new PINTuple(((NTuple*)obj), false);
+  pin->SelectXY(nmx.c_str(), nmy.c_str());
+  pin->SelectErrBar(erx.c_str(), ery.c_str());
+  string titre = nmy + "%" + nmz;
+  wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, nom, opt, titre);
+  }
+
+if(wrsid >= 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+return;
+}
+
+/* --Methode-- cmv 13/10/98 */
+void NamedObjMgr::DisplayGFD(string const& nom, string& numvarx, string& numvary, string& err, string dopt)
+//	Pour le display 2D ou 3D d'un ``GeneralFitData''.
+//|  nom = nom de l'objet GeneralFitData a representer.
+//|  numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
+//|  numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
+//|            Pour le display 2D, numvary="" string vide.
+//|  err = qu'elles erreurs faut il representer ?
+//|      - 2D : x y xy   (display y=f(x))
+//|      - 3D : x y z xy xz yz xzy   (display z=f(x,y))
+//|      Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
+//|      les barres d'erreurs sont representees.
+//|  opt = options generales pour le display.
+{
+PPersist* obj=GetObj(nom);
+if(obj == NULL)
+  {cout << "NamedObjMgr::DisplayGFD() Error , Pas d'objet de nom " << nom << endl; 
+   return;}
+if(!myImgApp) return; 
+int cid = obj->ClassId();
+if(cid != ClassId_GeneralFitData)
+  {string ctyp = servnobjm->PClassIdToClassName(cid);
+   cout<<"NamedObjMgr::DisplayGFD() Error , Objet n'est pas un GeneralFitData "<<ctyp<<endl; 
+   return;}
+
+// Decodage des options classiques
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+// Decodage des erreurs a representer
+bool errx=false, erry=false, errz=false;
+if(err.length()>0) {
+  for(int i=0;i<err.length();i++)
+    if     (err[i]=='x' || err[i]=='X') errx = true;
+    else if(err[i]=='y' || err[i]=='Y') erry = true;
+    else if(err[i]=='z' || err[i]=='Z') errz = true;
+}
+// Decodage des numeros de variables en abscisse
+int numvx=-1, numvy=-1;
+if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
+if(numvary.length()>0) numvy = atoi(numvary.c_str());
+
+int wrsid = 0;
+if(numvy>=0) {              // Display 3D
+  PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
+  pigfd->SelectXY(numvx,numvy);
+  pigfd->SelectErrBar(errx,erry,errz);
+  wrsid = myImgApp->Disp3DDrawer(pigfd,nom,opt);  
+} else {                   // Display 2D
+  PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
+  pigfd->SelectX(numvx);
+  pigfd->SelectErrBar(errx,erry);
+  wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,nom,opt);
+}
+
+if(wrsid >= 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+}
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+return;
+}
+
+/* --Methode-- 
+void NamedObjMgr::DisplayImage(string const& nom, string dopt)
+{
+  cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
+}
+*/
+
+
+/* --Methode-- */
+void NamedObjMgr::DisplaySurf3D(string const& nom, string dopt)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplaySurf3D() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return; 
+
+int cid = obj->ClassId();
+
+
+P2DArrayAdapter* arr=NULL;
+switch (cid) {
+  case ClassId_Matrix : 
+    arr = new POMatrixAdapter((Matrix*)obj, false);
+    break;
+  case ClassId_Histo2D : 
+    arr = new POH2DAdapter((Histo2D*)obj, false);
+    break;
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kr_8 : 
+  case ClassId_Image + kuint_4 : 
+    arr = new RzImageAdapter((RzImage*)obj, false);
+    break;
+  case ClassId_Image + kuint_2 : 
+    arr = new ImageAdapter<uint_2>((ImageU2*)obj, false);
+    break;
+  case ClassId_Image + kint_2 : 
+    arr = new ImageAdapter<int_2>((ImageI2*)obj, false);
+    break;
+  case ClassId_Image + kint_4 : 
+    arr = new ImageAdapter<int_4>((ImageI4*)obj, false);
+    break;
+  case ClassId_Image + kr_4 : 
+    arr = new ImageAdapter<r_4>((ImageR4*)obj, false);
+    break;
+
+  default :
+    cout << "NamedObjMgr::DisplaySurf3D() Error , Pas de display pour " << servnobjm->PClassIdToClassName(cid) << endl; 
+    return;
+  }
+
+if (!arr) return;
+if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
+  cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" <<  arr->XSize() 
+       << "x" << arr->YSize() << ") trop grand (max=250x250)" << endl; 
+  delete arr;
+  return;
+  }
+
+int wrsid = 0;
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+if (cid == ClassId_Histo2D)  arr->DefineXYCoordinates(0., 0., 1., 1.);
+PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
+wrsid = myImgApp->Disp3DDrawer(sdr, nom, opt);
+if(wrsid >= 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+
+if (fgsr) myImgApp->RestoreGraphicAtt();  
+return; 
+}
+
+
+/* --Methode-- */
+void NamedObjMgr::SetGraphicAttributes(string gratt)
+{
+bool fg = false;
+servnobjm->DecodeDispOption(gratt, fg);
+}
+/* --Methode-- */
+void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
+{
+if (!myImgApp)  return; 
+if (fcr)  myImgApp->CreateGraphWin(nzx, nzy);
+else myImgApp->SetZone(nzx, nzy);
+}
+
+/* --Methode-- */
+void NamedObjMgr::DisplayPoints2D(string const& nom,  string& expx, string& expy,
+                                  string& experrx, string& experry,
+                                  string& expcut, string dopt)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return; 
+
+// Creation NTuple 
+char* ntn[4] = {"expx","expy","expex","expey",};
+NTuple* nt = NULL;
+bool haserr = false;
+
+if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) {  haserr = true;   nt = new NTuple(2, ntn); }
+else {  haserr = false;  experrx = experry = "0."; nt = new NTuple(2, ntn); }
+
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "NamedObjMgr::DisplayPoints2D() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+
+// nt->Show();
+// nt->Print(0,10);
+PINTuple* pin = new PINTuple(nt, true);
+pin->SelectXY(ntn[0], ntn[1]);
+if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
+
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+string titre =  nom + ":" + expy + "%" + expx;
+myImgApp->DispScDrawer( (PIDrawer*)pin, titre, opt);
+if (fgsr) myImgApp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::DisplayPoints3D(string const& nom,  string& expx, string& expy, string& expz,
+                                  string& expcut, string dopt)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+char* ntn[3] = {"expx","expy","expz"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple
+
+string expwt = "1.";
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "NamedObjMgr::DisplayPoints3D() Warning  Zero points satisfy cut !" << endl;
+  delete nt;
+  return;
+  }
+nt->Show();
+nt->Print(0,10);
+PINTuple3D* pin = new PINTuple3D(nt, true);
+pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+
+// Pour plot a partir de DispScDrawer
+// string nomdisp = "_NT3D_";
+// myImgApp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
+// Pour plot a partir de Disp3DDrawer
+string titre =  nom + ":" + expy + "%" + expx;
+myImgApp->Disp3DDrawer(pin, titre, opt);
+
+if (fgsr) myImgApp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::ProjectH1(string const& nom, string& expx, string& expwt, string& expcut, string& nomh1, string dopt)
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+Histo* h1 = NULL;
+NTuple* nt = NULL;
+PPersist* oh = NULL; 
+if (nomh1.length() > 0) oh=GetObj(nomh1);
+else nomh1 = "H1Proj";
+if ( (oh != NULL) && (oh->ClassId() == ClassId_Histo1D) )  h1 = (Histo*)oh;  // Pas de remise a zero ! h1->Zero();
+else {
+  char* ntn[2]= {"hxval", "hwt"};
+  nt = new NTuple(2,ntn);  // Creation NTuple 
+  }
+string expz = "0.";   
+servnobjm->Nobj_ComputeExpressions(obj, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
+
+if ((!h1) && (!nt)) return;
+if (!h1) {
+  if (nt->NEntry() < 1) {
+    cout << "NamedObjMgr::ProjectH1() Warning  Zero points satisfy cut !" << endl; 
+    delete nt;
+    return;
+    }
+  float xmin, xmax;
+  nt->GetMinMax(0, xmin, xmax);
+  h1 = new Histo(xmin, xmax, 100);
+  int k;
+  float* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetVec(k);
+    h1->Add(xn[0], xn[1]);    
+    }
+  delete nt;
+  AddObj(h1, nomh1);
+  }
+
+DisplayObj(nomh1, dopt);
+return;  
+}
+
+/* --Methode-- */
+void NamedObjMgr::ProjectH2(string const& nom, string& expx, string& expy, string& expwt, string& expcut, 
+                            string& nomh2, string dopt)
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+Histo2D* h2 = NULL;
+NTuple* nt = NULL;
+PPersist* oh = NULL;
+if (nomh2.length() > 0)  oh=GetObj(nomh2);
+else nomh2 = "H2Proj";
+if ( (oh != NULL) && (oh->ClassId() == ClassId_Histo2D) )  h2 = (Histo2D*)oh;  // Pas de remise a zero ! h2->Zero();
+else {
+  char* ntn[3]= {"hxval", "hyval", "hwt"};
+  nt = new NTuple(3,ntn);  // Creation NTuple 
+  }
+string expz = "0.";   
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
+
+if ((!h2) && (!nt)) return;
+if (!h2) {
+  if (nt->NEntry() < 1) {
+    cout << "NamedObjMgr::ProjectH2() Warning  Zero points satisfy cut !" << endl; 
+    delete nt;
+    return;
+    }
+  float xmin, xmax, ymin, ymax;
+  nt->GetMinMax(0, xmin, xmax);
+  nt->GetMinMax(0, ymin, ymax);
+  h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
+  int k;
+  float* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetVec(k);
+    h2->Add(xn[0], xn[1], xn[2]);    
+    }
+  delete nt;
+  AddObj(h2, nomh2);
+  }
+
+DisplayObj(nomh2, dopt);
+return;  
+
+}
+
+/* --Methode-- cmv 13/10/98 */
+void NamedObjMgr::ProjectHProf(string const& nom, string& expx, string& expy, string& expwt, string& expcut, 
+                              string& nomprof, string dopt)
+//	Pour remplir un ``GeneralFitData'' a partir de divers objets:
+//| nom = nom de l'objet a projeter dans un HProf.
+//| expx = expression X de definition du bin.
+//| expy = expression Y a additionner dans le bin.
+//| expwt = expression W du poids a additionner.
+//| expcut = expression du test de selection.
+//| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
+//|           les limites Xmin,Xmax sont calculees automatiquement.
+//|           sinon ce sont celles de l'objet preexistant.
+//| opt = options generales pour le display.
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+HProf* hprof = NULL;
+NTuple* nt = NULL;
+PPersist* oh = NULL;
+if (nomprof.length() > 0)  oh=GetObj(nomprof);
+else nomprof = "ProfProj";
+if( (oh!=NULL) && (oh->ClassId()== ClassId_HProf) )  hprof = (HProf*)oh;
+else {
+  char* ntn[3]= {"hxval", "hyval", "hwt"};
+  nt = new NTuple(3,ntn);  // Creation NTuple 
+}
+string expz = "0.";
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
+
+if((!hprof) && (!nt)) return;
+if(!hprof) {
+  if (nt->NEntry() < 1) {
+    cout << "NamedObjMgr::ProjectHProf() Warning  Zero points satisfy cut !" << endl;
+    delete nt;
+    return;
+  }
+  float xmin, xmax;
+  nt->GetMinMax(0, xmin, xmax);
+  hprof = new HProf(xmin, xmax, 100);
+  int k;
+  float* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetVec(k);
+    hprof->Add(xn[0], xn[1], xn[2]);
+    }
+  delete nt;
+  AddObj(hprof, nomprof);
+  }
+hprof->UpdateHisto();
+
+DisplayObj(nomprof, dopt);
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::FillVect(string const& nom, string& expx, string& expcut, string& nomvec, string dopt)
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+NTuple* nt = NULL;
+if (nomvec.length() < 1) nomvec = "VecFill";
+
+char* ntn[2]= {"vecval", "vecwt"};
+nt = new NTuple(1,ntn);  // Creation NTuple
+ 
+string expwt = "1.";
+string expz = "0.";   
+servnobjm->Nobj_ComputeExpressions(obj, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "NamedObjMgr::FillVect() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+  
+Vector* vec = new Vector(nt->NEntry());
+int k;
+float* xn;
+for(k=0; k<nt->NEntry(); k++)    {
+  xn = nt->GetVec(k);
+  (*vec)(k) = xn[0];
+  }
+delete nt;
+AddObj(vec, nomvec); 
+DisplayObj(nomvec, dopt);
+return;  
+}
+
+/* --Methode-- */
+void NamedObjMgr::FillNT(string const& nom, string& expx, string& expy, string& expz, string& expt, 
+                         string& expcut, string& nomnt)
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+bool fgnnt = false;
+NTuple* nt = NULL;
+PPersist* oh = NULL;
+if (nomnt.length() > 0)  oh=GetObj(nomnt);
+else nomnt = "NTFill";
+if ( (oh != NULL) && (oh->ClassId() == ClassId_NTuple) )  { 
+  nt = (NTuple*)oh;
+  if (nt->NVar() > 10) {
+    cout << "NamedObjMgr::FillNT() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
+    nt = NULL;
+    }
+  }  
+if (nt == NULL) {
+  char* ntn[4]= {"x", "y","z","t"};
+  nt = new NTuple(4,ntn);  // Creation NTuple 
+  fgnnt = true;
+  }
+
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, expt, expcut, nt, NULL, NULL);
+
+if (fgnnt) AddObj(nt, nomnt);
+return;  
+
+}
+
+/* --Methode-- cmv 13/10/98 */
+void NamedObjMgr::FillGFD(string const& nom, string& expx, string& expy, string& expz,
+                          string& experr, string& expcut, string& nomgfd)
+//	Pour remplir un ``GeneralFitData'' a partir de divers objets:
+//| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
+//|       Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
+//| expx = expression X du GeneralFitData (1er abscisse)
+//| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
+//| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
+//| experr = expression de l'erreur sur l'ordonnee Z
+//| expcut = expression du test de selection
+//| nomgfd = nom du GeneralFitData engendre (optionnel)
+{
+PPersist* obj=GetObj(nom);
+if(obj == NULL)
+  {cout<<"NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
+   return;}
+if(!myImgApp)  return;
+
+// 2D ou 3D?
+int nvar = 2;
+if(expy.length()<=0) {nvar = 1; expy = "0.";}
+
+// Que faut-il copier dans GeneralFitData
+int ndata=0;
+int cid = obj->ClassId();
+switch (cid) {
+  case ClassId_Vector :
+    ndata=((Vector*)obj)->NElts();
+    break;
+  case ClassId_Matrix :
+    ndata=((Matrix*)obj)->NCol()*((Matrix*)obj)->NRows();
+    break;
+  case ClassId_Histo1D :
+  case ClassId_HProf : 
+    ndata=((Histo*)obj)->NBins();
+    break;
+  case ClassId_Histo2D :
+    ndata=((Histo2D*)obj)->NBinX()*((Histo2D*)obj)->NBinY();
+    break;
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 :
+  case ClassId_Image + kint_1 :
+  case ClassId_Image + kr_8 :
+  case ClassId_Image + kuint_4 :
+  case ClassId_Image + kuint_2 :
+  case ClassId_Image + kint_2 :
+  case ClassId_Image + kint_4 :
+  case ClassId_Image + kr_4 :
+    ndata=((RzImage*)obj)->XSize()*((RzImage*)obj)->YSize();
+    break;
+#ifdef SANS_EVOLPLANCK 
+  case ClassId_StarList : 
+    ndata=((StarList*)obj)->NbStars();
+    break;
+#endif
+  case ClassId_NTuple :
+    ndata=((NTuple*)obj)->NEntry();
+    break;
+  case ClassId_GeneralFitData :
+    ndata=((GeneralFitData*)obj)->NData();
+    break;
+  default :
+    cout<<"FillGFD Erreur: N/A to  "<<servnobjm->PClassIdToClassName(cid)<<endl; 
+    return;
+}
+
+// Nom du GeneralFitData cree.
+if (nomgfd.length() <= 0) nomgfd = "GFDFill";
+// Consistence ndata.
+if(ndata<=0)
+  {cout<<"NamedObjMgr::FillGFD() Warning   ndata="<<ndata<<endl; 
+   return;}
+
+// Creation NTuple Buffer
+char* ntn[4]= {"x","y","f","e"};
+NTuple*nt = new NTuple(4,ntn);
+
+// Remplissage NTuple buffer
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, experr, expcut, nt, NULL, NULL);
+if(nt->NEntry() < 1)
+  {cout<<"NamedObjMgr::FillGFD() Warning  Zero points satisfy cut !"<<endl; 
+   delete nt; return;}
+
+//Remplissage de la structure GeneraFitData
+GeneralFitData* gfd = new GeneralFitData(nvar,ndata,0);
+int k;
+float* xn;
+for(k=0; k<nt->NEntry(); k++) {
+  xn = nt->GetVec(k);
+  gfd->AddData(xn,xn[2],xn[3]);
+}
+
+// Menage et table d'objets
+delete nt;
+AddObj(gfd, nomgfd);
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::PlotFunc(string& expfunc, float xmin, float xmax, int np, string dopt)
+{
+FILE *fip;
+string fname = (*TmpDir) + "func1_pia_dl.c";
+string fnamer = (*TmpDir) + "func1_pia_dl";
+string  cmd;
+int rc;
+
+if (!myImgApp)  return; 
+
+cmd = "rm " + fname;
+rc = system(cmd.c_str());
+printf("PlotFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "NamedObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl; 
+  return; 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("double func1_pia_dl_func(double x) \n{\n", fip);
+fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
+fclose(fip);
+
+DlFunctionOfX f = (DlFunctionOfX) servnobjm->LinkFunctionFromFile(fnamer, "func1_pia_dl_func");
+if (!f) return; 
+PlotFunc(f, xmin, xmax, np, dopt);
+servnobjm->CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::PlotFunc2D(string& expfunc, float xmin, float xmax, float ymin, float ymax, 
+                             int npx, int npy, string dopt)
+{
+FILE *fip;
+string fname = (*TmpDir) + "func2_pia_dl.c";
+string fnamer = (*TmpDir) + "func2_pia_dl";
+string cmd;
+int rc;
+
+if (!myImgApp)  return; 
+
+cmd = "rm " + fname;
+rc = system(cmd.c_str());
+printf("PlotFunc2D_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "NamedObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl; 
+  return; 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
+fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
+fclose(fip);
+
+DlFunctionOfXY f = (DlFunctionOfXY) servnobjm->LinkFunctionFromFile(fnamer, "func2_pia_dl_func");
+if (!f)  return;
+PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
+servnobjm->CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt)
+{
+if (!myImgApp)  return; 
+
+int k;
+if (np < 1) np = 1;
+if (xmax <= xmin) xmax = xmin+1.;
+Vector* vpy = new Vector(np);
+
+double xx;
+double dx = (xmax-xmin)/np;
+TRY {
+  for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "NamedObjMgr::PlotFunc()  Exception :" << merr << es;
+  delete vpy;
+  vpy = NULL;
+  } ENDTRY;
+
+
+if (vpy) {
+  string nom = "Func";
+  AddObj(vpy, nom);
+  P1DArrayAdapter* vya = new POVectorAdapter(vpy, false);
+  vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
+  PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ; 
+  bool fgsr = true;
+  dopt = "thinline," + dopt;
+  int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+  int wrsid = myImgApp->DispScDrawer(dr, nom, opt);
+  if(wrsid >= 0) {
+    NObjList::iterator it = myObjs->find(nom);
+    if (it == myObjs->end()) return; 
+    (*it).second.wrsid.push_back(wrsid);
+    }
+  if (fgsr) myImgApp->RestoreGraphicAtt(); 
+  }
+
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
+                             int npx, int npy, string dopt)
+{
+if (!myImgApp)  return; 
+
+if (npx < 1) npx = 1;
+if (npy < 1) npy = 1;
+if (xmax <= xmin) xmax = xmin+1.;
+if (ymax <= ymin) ymax = ymin+1.;
+
+Matrix* mtx = new Matrix(npy, npx);
+
+int i,j;
+double xx, yy;
+double dx = (xmax-xmin)/npx;
+double dy = (ymax-ymin)/npy;
+// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
+TRY {
+  for(j=0; j<npy; j++) {
+    yy = ymin+dy*j; 
+    for(i=0; i<npx; i++) {
+      xx = xmin+dx*i;
+      (*mtx)(j, i) = f(xx, yy);
+    }
+  }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "NamedObjMgr::PlotFunc2D()  Exception :" << merr << es;
+  delete mtx;  mtx = NULL;
+  } ENDTRY;
+
+if (mtx) {
+  string nom = "Func2";
+  AddObj(mtx, nom);
+  DisplaySurf3D(nom, dopt);
+  }
+
+return;
+}
+
+///////////////////// Fit 1D et 2D //////////////////////////
+/* --Function static propre aux routines de fit 1D et 2D-- cmv 13/10/98 */
+struct DFOptions {
+  int okres, okfun;
+  int polcx,polcy; double xc,yc;
+  double err_e, err_E;
+  double stc2;
+  int lp,lpg;
+  int i1,i2,j1,j2;
+};
+typedef struct DFOptions DFOPTIONS;
+static void DecodeFitsOptions(string par,string step,string min,string max,string opt
+                      ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O);
+void DecodeFitsOptions(string par,string step,string min,string max,string opt
+                      ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O)
+//| Pour decoder les "string" et remplir les vecteurs du fit (cf commentaires dans Fit1D)
+{
+// set des vecteurs et decodage des string correspondantes
+int NParMax = 100;
+Par.Realloc(NParMax); Step.Realloc(NParMax);
+Min.Realloc(NParMax); Max.Realloc(NParMax);
+{
+  Vector* v; string* s;
+  {for(int i=0;i<NParMax;i++) {Par(i)=0.; Step(i)=1.; Min(i)=1.; Max(i)=-1.;}}
+  for(int j=0;j<4;j++) {
+    if(j==0)      {v=&Par; s=&par;}
+    else if(j==1) {v=&Step; s=&step;}
+    else if(j==2) {v=&Min; s=&min;}
+    else if(j==3) {v=&Max; s=&max;}
+    if(s->length()>0) *s += ",";
+    for(int i=0;i<NParMax;i++) {
+      if(s->length()<=0) break;
+      sscanf(s->c_str(),"%lf",&(*v)(i));
+      size_t p = s->find_first_of(',') + 1;
+      if(p>=s->length()) *s = ""; else *s = s->substr(p);
+    }
+  }
+}
+
+// Decodage de options de opt
+O.okres = O.okfun = 0;
+O.polcx = O.polcy = 0;
+O.xc = O.yc = 0.;
+O.stc2 = 1.e-3;
+O.err_e = O.err_E = -1.;
+O.lp = 1; O.lpg = 0;
+O.i1 = O.j1 = O.i2 = O.j2 = -1;
+
+if(opt.length()<=0) return;
+opt = "," + opt + ",";
+
+if(strstr(opt.c_str(),",r,")) O.okres = 1;  // residus
+if(strstr(opt.c_str(),",f,")) O.okfun = 1;  // fonction fittee
+if(strstr(opt.c_str(),",x")) { // Demande de centrage (fit X=x-xc)
+  O.polcx = 2; // Le centrage est calcule automatiquement
+  size_t p = opt.find(",x");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) {
+    sscanf(dum.c_str(),",x%lf",&O.xc);
+    O.polcx = 1; // Le centrage est fixe par la valeur lue
+  }
+}
+if(strstr(opt.c_str(),",y")) { // Demande de centrage (fit Y=y-yc)
+  O.polcy = 2; // Le centrage est calcule automatiquement
+  size_t p = opt.find(",y");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) {
+    sscanf(dum.c_str(),",y%lf",&O.yc);
+    O.polcy = 1; // Le centrage est fixe par la valeur lue
+  }
+}
+if(strstr(opt.c_str(),",E")) { // Erreurs imposees a "sqrt(val)" ou "aa.b*sqrt(val)"
+  size_t p = opt.find(",E");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&O.err_E);
+  if(O.err_E<=0.) O.err_E = 1.;
+  O.err_e=-1.;
+}
+if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b"
+  size_t p = opt.find(",e");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&O.err_e);
+  if(O.err_e<=0.) O.err_e = 1.;
+  O.err_E=-1.;
+}
+if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2
+  size_t p = opt.find(",X");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",X%lf",&O.stc2);
+  if(O.stc2<=0.) O.stc2 = 1.e-3;
+}
+if(strstr(opt.c_str(),",l")) { // niveau de print
+  size_t p = opt.find(",l");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  float ab;
+  if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
+  if(ab<0) ab = 0.;
+  O.lp = (int) ab; O.lpg = (int) 10.*(ab-O.lp);
+}
+if(strstr(opt.c_str(),",I")) { // intervalle de fit selon X
+  size_t p = opt.find(",I");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",I%d/%d",&O.i1,&O.i2);
+}
+if(strstr(opt.c_str(),",J")) { // intervalle de fit selon Y
+  size_t p = opt.find(",J");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",J%d/%d",&O.j1,&O.j2);
+}
+return;
+}
+
+/* --Methode-- cmv 13/10/98 */
+void  NamedObjMgr:: Fit12D(string const& nom, string& func,
+                          string par,string step,string min,string max,
+                          string opt)
+//| --------------- Fit d'objets a 1 et 2 dimensions ---------------
+//| nom  : nom de l'objet qui peut etre:
+//|        fit-1D:  Vector,Histo1D,HProf ou GeneraFitData(1D)
+//|        fit-2D:  Matrix,Histo2D,Imagexx ou GeneraFitData(2D)
+//| func : pnn = fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D
+//|      : Pnn = fit polynome degre nn avec GeneralFit (non-lineaire) 1D ou 2D
+//|      : gnn = fit gaussienne (hauteur) + polynome de degre nn 1D
+//|      : g   = fit gaussienne (hauteur) 1D
+//|      : enn = fit exponentielle + polynome de degre nn 1D
+//|      : e   = fit exponentielle 1D
+//|      : Gnn = fit gaussienne (volume) + polynome de degre nn 1D
+//|      : G   = fit gaussienne (volume) 1D
+//|      :     = fit gaussienne+fond (volume) 2D
+//|      : Gi  = fit gaussienne+fond integree (volume) 2D
+//|      : d   = fit DL de gaussienne+fond (volume) 2D
+//|      : di  = fit DL de gaussienne+fond integree (volume) 2D
+//|      : D   = fit DL de gaussienne+fond avec coeff variable p6 (volume) 2D
+//|      : Di  = fit DL de gaussienne+fond integree avec coeff variable p6 (volume) 2D
+//|      : M   = fit Moffat+fond (expos=p6) (volume) 2D
+//|      : Mi  = fit Moffat+fond integree (expos=p6) (volume) 2D
+//| par  : p1,...,pn valeur d'initialisation des parametres (def=0)
+//| step : s1,...,sn valeur des steps de depart (def=1)
+//| min  : m1,...,mn valeur des minima (def=1)
+//| max  : M1,...,Mn valeur des maxima (def=-1) (max<=min : pas de limite)
+//| opt  : options "Eaa.b,eaa.b,f,r,caa.b,Xaa.b"
+//|       f = generation d'un Objet identique contenant la fonction fittee
+//|       r = generation d'un Objet identique contenant les residus
+//|       Xaa.b = aa.b valeur du DXi2 d'arret (def=1.e-3)
+//|       la.b = niveau "a.b" de print: a=niveau de print Fit1/2D
+//|                                     b=niveau de debug GeneralFit
+//|       Ii1/i2 numeros des bins X de l'histos utilises pour le fit [i1,i2]
+//|2D     Jj1/j2 numeros des bins Y de l'histos utilises pour le fit [j1,j2]
+//|       - L'erreur est celle associee a l'objet si existe, 1 sinon sauf si
+//|       E = erreur prise comme la racine de la valeur a fitter
+//|       Eaa.b = erreur prise aa.b*sqrt(val)
+//|       e = erreur prise egale a 1 pour toutes les valeurs
+//|       eaa.b = erreur prise egale a aa.b
+//|       xaa.b = demande de centrage: on fit x-aa.b au lieu de x)
+//|       x = demande de centrage: on fit x-xc au lieu de x
+//|           avec xc=abscisse du milieu de l'histogramme
+//|           Actif pour: exp+poly 1D, poly 1D
+//|                       gauss+poly 1D (mais xc est le centre de la gaussienne)
+//|2D     yaa.b et y = idem "xaa.b et x" mais pour y
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout<<"NamedObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
+  return;
+}
+if (!myImgApp)  return;
+if(func.length()<=0)
+  {cout<<"NamedObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
+   return;}
+int cid = obj->ClassId();
+string ctyp = servnobjm->PClassIdToClassName(cid);
+
+int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
+Vector* v = NULL; Histo* h = NULL;
+Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
+GeneralFitData* g = NULL;
+switch (cid) {
+  // 1D
+  case ClassId_Vector :
+    ndim = 1;
+    v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
+    break;
+  case ClassId_HProf :
+  case ClassId_Histo1D :
+    ndim = 1;
+    h = (Histo*)  obj; nbinx = h->NBins(); nbiny = 1;
+    break;
+  // 2D
+  case ClassId_Matrix :
+    ndim = 2;
+    m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
+    break;
+  case ClassId_Histo2D :
+    ndim = 2;
+    h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
+    break;
+  // 1D ou 2D selon
+  case ClassId_GeneralFitData :
+    g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
+    if(     g->NVar()==1) ndim = 1;
+    else if(g->NVar()==2) ndim = 2;
+    else {
+      cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
+          <<((GeneralFitData*) obj)->NVar()<<endl; return;}
+    break;
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 :
+  case ClassId_Image + kr_8 : 
+    ndim = 2;
+    im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
+    break;
+  default:
+    cout<<"NamedObjMgr::Fit12D() Error , Objet n'est pas un "
+        <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
+    return;
+    break;
+}
+ndata = nbinx*nbiny;
+if(ndata<=0)
+  {cout<<"L'objet a "<<nbinx<<","<<nbiny<<" bins ("<<ndata<<")"<<endl; return;}
+
+// Decodage des options et des parametres, mise en forme
+Vector Par(1); Vector Step(1); Vector Min(1); Vector Max(1); DFOPTIONS O;
+DecodeFitsOptions(par,step,min,max,opt,Par,Step,Min,Max,O);
+O.i1 = (O.i1<0||O.i1>=nbinx)? 0: O.i1;
+O.i2 = (O.i2<0||O.i2>=nbinx||O.i2<O.i1)? nbinx-1: O.i2;
+if(ndim>=2) {
+  O.j1 = (O.j1<0||O.j1>=nbiny)? 0: O.j1;
+  O.j2 = (O.j2<0||O.j2>=nbiny||O.j2<O.j1)? nbiny-1: O.j2;
+} else O.j2 = O.j1 = 0;
+if(O.polcx==2) {
+  if(v||m)    O.xc = (O.i2-O.i1+1)/2.;
+  else if(h)  O.xc = (h->XMin()+h->XMax())/2.;
+  else if(h2) O.xc = (h2->XMin()+h2->XMax())/2.;
+  else if(g)  {double mini,maxi; g->GetMinMax(2,mini,maxi); O.xc=(mini+maxi)/2.;}
+  else if(im) {O.xc = im->XOrg() * im->XPxSize()*(O.i2-O.i1+1)/2.;}
+}
+if(O.polcy==2 && ndim>=2) {
+  if(m)  O.yc = (O.j2-O.j1+1)/2.;
+  if(h2) O.yc = (h2->YMin()+h2->YMax())/2.;
+  if(g)  {double mini,maxi; g->GetMinMax(12,mini,maxi); O.yc=(mini+maxi)/2.;}
+  if(im) {O.yc = im->YOrg() * im->YPxSize()*(O.j2-O.j1+1)/2.;}
+}
+if(O.lp>0)
+  cout<<"Fit["<<nbinx<<","<<nbiny<<"] ("<<ndata<<") dim="<<ndim<<":"
+      <<" Int=["<<O.i1<<","<<O.i2<<"],["<<O.j1<<","<<O.j2<<"]"<<endl
+      <<" Cent="<<O.polcx<<","<<O.polcy<<","<<O.xc<<"+x"<<","<<O.yc<<"+y"
+      <<" TypE="<<O.err_e<<","<<O.err_E
+      <<" StpX2="<<O.stc2
+      <<" lp,lpg="<<O.lp<<","<<O.lpg<<endl;
+
+///////////////////////////////////
+// Remplissage de GeneralFitData //
+///////////////////////////////////
+GeneralFitData mydata(ndim,ndata,0);
+{for(int i=O.i1;i<=O.i2;i++) for(int j=O.j1;j<=O.j2;j++) {
+  double x,y,f,e;
+
+  if(v)
+    {x= (double) i; f=(*v)(i); e=1.;}
+  else if(h)
+    {x=h->BinCenter(i); f=(*h)(i); e=(h->HasErrors())?h->Error(i):1.;}
+  else if(m)
+    {x=(double) i; y=(double) j; f=(*m)(j,i); e=1.;}
+  else if(h2)
+    {float xf,yf; h2->BinCenter(i,j,xf,yf); x=(double)xf; y=(double)yf;
+     f=(*h2)(i,j); e=(h2->HasErrors())?h2->Error(i,j):1.;}
+  else if(im)
+    {x=im->XOrg()+(i+0.5)*im->XPxSize(); y=im->YOrg()+(j+0.5)*im->YPxSize();
+     f=im->DValue(i,j); e=1.;}
+  else if(g&&ndim==1) {x= g->X(i); f=g->Val(i); e=g->EVal(i);}
+  else if(g&&ndim==2) {x= g->X(i); y= g->Y(i); f=g->Val(i); e=g->EVal(i);}
+  else x=y=f=e=0.;
+
+  // Gestion des erreurs a utiliser
+  if(O.err_e>0.) e=O.err_e;
+  else if(O.err_E>0.) {e=(y<-1.||y>1.)?O.err_E*sqrt(fabs(y)):O.err_E;}
+
+  // Remplissage de generalfit
+  if(func[0]=='p') {x -= O.xc; if(ndim>=2) y -= O.yc;}
+  if(ndim==1)      mydata.AddData1(x,f,e);
+  else if(ndim==2) mydata.AddData2(x,y,f,e);
+}}
+if(mydata.NData()<=0)
+  {cout<<"Pas de donnees dans GeneralFitData: "<<mydata.NData()<<endl;
+   return;}
+if(O.lpg>1) {
+  mydata.PrintStatus();
+  mydata.PrintData(0);
+  mydata.PrintData(mydata.NData()-1);
+}
+
+////////////////////////////////////////////
+// Identification de la fonction a fitter //
+////////////////////////////////////////////
+GeneralFunction* myfunc = NULL;
+if(func[0]=='p' && ndim==1) {
+  // Fit de polynome sans passer par les GeneralFit
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl;
+  Poly p1(0);
+  double c2rl = mydata.PolFit(0,p1,degre);
+  cout<<"C2r_lineaire = "<<c2rl<<endl;
+  if(O.lp>0) cout<<p1<<endl;
+  return;
+
+} else if(func[0]=='P' && ndim==1) {
+  // Fit de polynome
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit polynome 1D de degre "<<degre<<endl;
+  Polyn1D* myf = new Polyn1D(degre,O.xc);
+  myfunc = myf;
+
+} else if(func[0]=='e' && ndim==1) {
+  // Fit d'exponentielle
+  int degre =-1;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit d'exponentielle+polynome 1D de degre "<<degre<<endl;
+  Exp1DPol* myf;
+  if(degre>=0) myf = new Exp1DPol((unsigned int)degre,O.xc);
+       else    myf = new Exp1DPol(O.xc);
+  myfunc = myf;
+
+} else if(func[0]=='g' && ndim==1) {
+  // Fit de gaussienne en hauteur
+  int degre =-1;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit de Gaussienne_en_hauteur+polynome 1D de degre "<<degre<<endl;
+  Gauss1DPol* myf;
+  if(degre>=0) myf = new Gauss1DPol((unsigned int)degre,((O.polcx)?true:false));
+  else { bool bfg = (O.polcx)?true:false;   myf = new Gauss1DPol(bfg); }
+  myfunc = myf;
+
+} else if(func[0]=='G' && ndim==1) {
+  // Fit de gaussienne en volume
+  int degre =-1;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit de Gaussienne_en_volume+polynome 1D de degre "<<degre<<endl;
+  GaussN1DPol* myf;
+  if(degre>=0) myf = new GaussN1DPol((unsigned int)degre,((O.polcx)?true:false));
+  else  { bool bfg = (O.polcx)?true:false;   myf = new GaussN1DPol(bfg); }
+  myfunc = myf;
+
+} else if(func[0]=='p' && ndim==2) {
+  // Fit de polynome 2D sans passer par les GeneralFit
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl;
+  Poly2 p2(0);
+  double c2rl = mydata.PolFit(0,1,p2,degre);
+  cout<<"C2r_lineaire = "<<c2rl<<endl;
+  if(O.lp>0) cout<<p2<<endl;
+  return;
+
+} else if(func[0]=='P' && ndim==2) {
+  // Fit de polynome 2D
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit polynome 2D de degre "<<degre<<endl;
+  Polyn2D* myf = new Polyn2D(degre,O.xc,O.yc);
+  myfunc = myf;
+
+} else if(func[0]=='G' && ndim==2) {
+  // Fit de gaussienne+fond en volume
+  int integ = 0;
+  if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de Gaussienne+Fond 2D integ="<<integ<<endl;
+  if(integ) {GauRhInt2D* myf = new GauRhInt2D; myfunc = myf;}
+    else    {GauRho2D* myf = new GauRho2D; myfunc = myf;}
+
+} else if(func[0]=='d' && ndim==2) {
+  // Fit de DL gaussienne+fond en volume
+  int integ = 0;
+  if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de DL de Gaussienne+Fond 2D integ="<<integ<<endl;
+  if(integ) {GdlRhInt2D* myf = new GdlRhInt2D; myfunc = myf;}
+    else    {GdlRho2D* myf = new GdlRho2D; myfunc = myf;}
+
+} else if(func[0]=='D' && ndim==2) {
+  // Fit de DL gaussienne+fond avec coeff variable p6 en volume
+  int integ = 0;
+  if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de DL de Gaussienne+Fond avec coeff variable (p6) 2D integ="<<integ<<endl;
+  if(integ) {Gdl1RhInt2D* myf = new Gdl1RhInt2D; myfunc = myf;}
+    else    {Gdl1Rho2D* myf = new Gdl1Rho2D; myfunc = myf;}
+
+} else if(func[0]=='M' && ndim==2) {
+  // Fit de Moffat+fond (volume)
+  int integ = 0;
+  if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de Moffat+Fond (expos=p6) 2D integ="<<integ<<endl;
+  if(integ) {MofRhInt2D* myf = new MofRhInt2D; myfunc = myf;}
+    else    {MofRho2D* myf = new MofRho2D; myfunc = myf;}
+
+} else {
+  cout<<"Fonction "<<func<<" inconnue pour la dim "<<ndim<<endl;
+  return;
+}
+
+/////////////////////////
+// Fit avec generalfit //
+/////////////////////////
+if(myfunc->NPar()>Par.NElts())
+  {cout<<"Trop de parametres: "<<myfunc->NPar()<<">"<<Par.NElts()<<endl;
+  if(myfunc) delete myfunc; return;}
+GeneralFit myfit(myfunc);
+myfit.SetDebug(O.lpg);
+myfit.SetData(&mydata);
+myfit.SetStopChi2(O.stc2);
+{for(int i=0;i<myfunc->NPar();i++) {
+  char str[10];
+  sprintf(str,"P%d",i);
+  myfit.SetParam(i,str,Par(i),Step(i),Min(i),Max(i));
+}}
+if(O.lp>1) myfit.PrintFit();
+double c2r = (double) myfit.Fit();
+if(O.lp>0) myfit.PrintFit();
+if(c2r>0.) {
+  c2r = myfit.GetChi2Red();
+  cout<<"C2r_Reduit = "<<c2r<<"  nstep="<<myfit.GetNStep()<<endl;
+  Vector ParFit(myfunc->NPar());
+  for(int i=0;i<myfunc->NPar();i++) ParFit(i)=myfit.GetParm(i);
+} else {
+  cout<<"echec Fit, rc = "<<c2r<<"  nstep="<<myfit.GetNStep()<<endl;
+}
+
+// Mise a disposition des resultats
+if(c2r>=0. && myfunc && (O.okres>0||O.okfun>0)) {
+  string nomres = nom + "res";
+  string nomfun = nom + "fun";
+  if(v) {
+    if(O.okres) {Vector* ob = v->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {Vector* ob = v->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(h) {
+    if(O.okres) {Histo* ob = h->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {Histo* ob = h->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(m) {
+    if(O.okres) {Matrix* ob = m->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {Matrix* ob = m->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(h2) {
+    if(O.okres) {Histo2D* ob = h2->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {Histo2D* ob = h2->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(im) {
+    if(O.okres) {RzImage* ob = im->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {RzImage* ob = im->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(g) {
+    if(O.okres) {GeneralFitData* ob = g->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {GeneralFitData* ob = g->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  }
+}
+
+// Nettoyage
+if(myfunc) delete myfunc;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::FFT(string const& nom, string dopt)
+{
+#ifndef SANS_EVOLPLANCK 
+  cout << cout << "NamedObjMgr::FFT() NON Disponible - Evol-Planck " << endl;
+#else
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::FFT() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return; 
+
+int cid = obj->ClassId();
+if (cid != ClassId_Vector) { 
+  string ctyp = servnobjm->PClassIdToClassName(cid);
+  cout << "NamedObjMgr::FFT() Error , Objet n'est pas un vecteur " << ctyp << endl; 
+  return;
+  }
+
+FFT1 fft( *((Vector*)obj) );
+
+if (fft.NData() < 1)  return;
+
+char* ntn[3] = {"refc", "imfc", "pfc"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple 
+Vector* vf = new Vector(fft.NData()/2);
+
+float xnt[3]; 
+double pf;
+for(int k=0; k<fft.NData()/2; k++) {
+  xnt[0] = fft.ReF(k);  xnt[1] = fft.ImF(k); 
+  pf = (xnt[0]*xnt[0]+xnt[1]*xnt[1]);
+  if (pf >= 0.)  pf = sqrt(pf);  
+  xnt[2] = pf;   (*vf)(k) = pf;
+  nt->Fill(xnt);  
+  }
+
+P1DArrayAdapter* vya = new POVectorAdapter(vf, true);
+// vya->DefineXCoordinate(xmin, xmax);   a determiner
+PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ; 
+bool fgsr = true;
+dopt = "thinline," + dopt;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+myImgApp->DispScDrawer(dr, nom, opt);
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+#endif
+return;
+}
Index: /tags/DPC_V0/Poubelle/PIext/nobjmgr.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/nobjmgr.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/nobjmgr.h	(revision 1307)
@@ -0,0 +1,98 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe de gestion d objets nommes pour piapp
+// Reza      Aout 97 , Juillet,Aout 98
+// CEA-DAPNIA      LAL-IN2P3/CNRS
+
+#ifndef NOBJMGR_H_SEEN
+#define NOBJMGR_H_SEEN
+
+#include "ppersist.h"
+#include "dlftypes.h"
+
+class PIStdImgApp;
+class Services2NObjMgr;
+
+class NamedObjMgr {
+public:
+			NamedObjMgr();
+  virtual		~NamedObjMgr();
+
+  virtual void 		SetImgApp(PIStdImgApp* app);
+
+
+//  Pour ajouter, supprimer et acceder aux objets PPersist
+  virtual void		AddObj(PPersist* obj, string& nom);
+  virtual void          DelObj(string const& nom, bool fgd=true);
+  virtual void		DelObjects(string const& patt, bool fgd=true); 
+  virtual PPersist*	GetObj(string const& nom);
+  virtual void		RenameObj(string const& nom, string& nomnew);
+  virtual string        LastObjName();  // Renvoie le nom du dernier objet ajoute
+
+//  Lecture et sauvegarde des objets sur fichier
+  virtual void		ReadObj(PInPersist& s, int num=-1);
+  virtual void		ReadObj(string const & nomppf, string nobj="");
+  virtual void		ReadAll(string const & nomppf);
+  virtual void		ReadFits(string const & flnm, string nobj="");
+  virtual void          SaveObj(string const& nom, POutPersist& s);
+  virtual void          SaveAll(string const& nomppf);
+  virtual void          SaveFits(string const& nom, string const & flnm);
+
+// Info sur les objets 
+  virtual void          ListObjs();  		
+  virtual void          PrintObj(string const& nom);
+
+//  Affichage des objets 
+  virtual void          DisplayObj(string const& nom, string dopt="");
+  virtual void          DisplaySurf3D(string const& nom, string dopt="");
+  virtual void          DisplayNT(string const& nom, string& nmx, string& nmy, string& nmz,  
+                                  string& erx, string& ery, string& erz, string dopt="");
+  virtual void          DisplayGFD(string const& nom, string& numvarx, string& numvary, string& err, string dopt="");
+// virtual void          DisplayImage(string const& nom, string dopt=""); C'est necessaire ??
+
+  virtual void		SetGraphicAttributes(string gratt="");
+  virtual void		SetGraphicWinZone(int nzx, int nzy, bool fcr=false);
+
+
+//  Trace d'expression de NTuple, et d'autres objets
+  virtual void          DisplayPoints2D(string const& nom, string& expx, string& expy,
+                                        string& experrx, string& experry, 
+                                        string& expcut, string dopt="");
+  virtual void          DisplayPoints3D(string const& nom, string& expx, string& expy, string& expz, 
+                                        string& expcut, string dopt="");
+//  Projection d'expressions dans histogramme (et trace) 
+  virtual void          ProjectH1(string const& nom, string& expx, string& expwt, string& expcut, 
+                                  string& nomh1, string dopt="");
+  virtual void          ProjectH2(string const& nom, string& expx, string& expy, string& expwt, 
+                                  string& expcut, string& nomh2, string dopt="");
+  virtual void          ProjectHProf(string const& nom, string& expx, string& expy, string& expwt, 
+                                  string& expcut, string& nomprof, string dopt="");
+//  Projection d'expression dans vecteurs et dans n-tuple
+  virtual void          FillVect(string const& nom, string& expx, string& expcut, 
+                                 string& nomvec, string dopt="");
+  virtual void          FillNT(string const& nom, string& expx, string& expy, string& expz,
+                               string& expt, string& expcut, string& nomnt); 
+  virtual void          FillGFD(string const& nom, string& expx, string& expy, string& expz,
+                               string& experr, string& expcut, string& nomgfd);
+
+// Trace de fonctions 1-D , 2-D
+  virtual void          PlotFunc(string& expfunc, float xmin, float xmax, int np=100, string dopt="");
+  virtual void          PlotFunc2D(string& expfunc, float xmin, float xmax, float ymin, float ymax, 
+                                   int npx=50, int npy=50, string dopt="");
+  virtual void          PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np=100, string dopt="");
+  virtual void          PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
+                                   int npx=50, int npy=50, string dopt="");
+
+//   Methodes de fit, a rajouter  (pour CMV , deux methodes H1 H2 ou 1 seule ??) ...
+  virtual void          Fit12D(string const& nom, string& func,
+                              string par,string step,string min,string max,string opt);
+
+//   Calcul de la transforme de Fourier - A titre d'exemple
+  virtual void          FFT(string const& nom, string dopt);   
+
+// Acces au PIApplication et a la classe de service 
+  virtual PIStdImgApp*		GetImgApp();
+  virtual Services2NObjMgr* 	GetServiceObj();
+};
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/nomapstr.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/nomapstr.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/nomapstr.h	(revision 1307)
@@ -0,0 +1,23 @@
+// Include file prive pour NamedObjMgr (nobmgr.cc)
+// LAL-IN2P3/CNRS         DAPNIA-CEA
+//      Reza    Aout 97
+
+#ifndef NOMAPSTR_H_SEEN
+#define NOMAPSTR_H_SEEN
+
+#include <string>
+#include <map>
+
+#include "ppersist.h"
+
+struct nobj_item {
+  PPersist* obj;
+  int num;
+  list<int> wrsid;
+  bool operator==(nobj_item const& b) const         
+    { return (this->obj ==  b.obj); } 
+};
+
+typedef map<string, nobj_item, less<string> > NObjList;
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/piacmd.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/piacmd.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/piacmd.cc	(revision 1307)
@@ -0,0 +1,1093 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <iostream.h>
+#include <string>
+#include <vector>
+#include <map>
+#if defined(__KCC__)
+using std::string ;
+#include <vector.h>
+#include <map.h>
+#endif
+
+#include "ctimer.h"
+
+#include "nobjmgr.h"
+#include "piacmd.h"
+#include "pistdimgapp.h"
+
+#include "histos.h"
+#include "histos2.h"
+#include "hisprof.h"
+#include "ntuple.h"
+#include "generaldata.h"
+
+
+//  Pour le decoupage des commandes en lignes 
+typedef vector<string> cmdtok;
+
+//  Fonction pour faire le Fit de PSF sur image   
+static int FitPSFImg(cmdtok& tokens);
+static int Photom_Ouv(cmdtok& tokens);
+
+
+/* --Methode-- */
+PIACmd::PIACmd(NamedObjMgr* omg, PIStdImgApp* app)
+{
+if (omg)  { mOmg= false; mObjMgr = omg; }
+else { mObjMgr = new NamedObjMgr;  mOmg = true; }
+mImgApp = app;
+system("cp history.pic hisold.pic");
+hist.open("history.pic");
+trace = false;   timing = false;
+gltimer = NULL;
+dynlink = NULL;
+}
+
+/* --Methode-- */
+PIACmd::~PIACmd()
+{
+if (mOmg)  delete mObjMgr;
+hist.close();
+if (gltimer) { delete gltimer;  gltimer = NULL; }
+}
+
+/* --Methode-- */
+int PIACmd::Exec(string& file)
+{
+char line_buff[512];
+FILE *fip;
+
+if ( (fip = fopen(file.c_str(),"r")) == NULL ) {
+  cerr << "PIACmd::Exec() Error opening file " << file << endl;
+  hist << "##! PIACmd::Exec() Error opening file " << file << endl;
+  return(0);
+  }
+ 
+hist << "### Executing commands from " << file << endl;
+if (trace) { 
+  mImgApp->GetConsole()->AddStr("### Executing commands from ", PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(file.c_str(), PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr("\n", PIVA_Magenta);
+  }
+
+while (fgets(line_buff,511,fip) != NULL)
+  {
+  if (trace) mImgApp->GetConsole()->AddStr(line_buff, PIVA_Magenta);
+  line_buff[strlen(line_buff)-1] = '\0';   /*  LF/CR de la fin */
+  string line(line_buff);
+  Do(line);
+  }
+hist << "### End of Exec( " << file << " ) " << endl;
+if (trace) { 
+  mImgApp->GetConsole()->AddStr("### End of Exec( ", PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(file.c_str(), PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(" ) \n", PIVA_Magenta);
+  }
+
+return(0);
+}
+
+/* --Methode-- */
+int PIACmd::Do(string& s)
+{
+
+cmdtok tokens;
+if (s.length() < 1)  return(0);
+
+hist << s << endl;   // On enregistre les commandes 
+
+if (s[0] == '#') {
+  cout << "PIACmd::Do() Comment-Line:" << s << endl;
+  return(0); 
+  } 
+string toks,kw;
+size_t p = s.find_first_not_of(" ");
+s = s.substr(p);
+p = 0;
+size_t q = s.find_first_of(" ");
+size_t l = s.length();
+
+if (q < l)
+  {  kw = s.substr(p,q-p);  toks = s.substr(q, l-q); }
+else { kw = s.substr(p,l-p);  toks = ""; }
+
+q = 0;
+while (q < l)  {
+  p = toks.find_first_not_of(" ",q+1); // au debut d'un token
+  if (p>=l) break;
+  q = toks.find_first_of(" ",p); // la fin du token;
+  string token = toks.substr(p,q-p);
+  tokens.push_back(token);
+  }
+
+for(int k=0; k<tokens.size(); k++) { // On remplace les $varname par la valeur de la variable
+ if ((tokens[k])[0] != '$')  continue; 
+ CmdVarList::iterator it = mVars.find(tokens[k].substr(1));
+ if (it != mVars.end())  tokens[k] = (*it).second;
+}
+
+// cout << "PIACmd::Do() DBG  KeyW= " << kw << " NbArgs= " << tokens.size() << endl;
+//  for(int ii=0; ii<tokens.size(); ii++)
+//  cout << "arg[ " << ii << " ] : " << tokens[ii] << endl;
+
+// >>>>>>>>>>> Commande d'interpreteur
+if (kw == "help") {
+  cout << "\n PIACmd::Do() ----- Help : Liste des commandes ------------ \n";
+  cout << "help  shelp  exec  set  listvars  traceon  traceoff \n"; 
+  cout << "timingon  timingoff  shell \n"; 
+  cout << "link  call    zone  grwin  gratt  stacknext \n" ;
+  cout << "openppf  saveall  listobjs openfits savefits \n"; 
+  cout << "print rename  del delobjs \n";
+  cout << "newh1d  newh2d  newprof newgfd func  func2d \n" ; 
+  cout << "disp  surf  nt2d  nt3d  gfd2d  gfd3d \n" ;
+  cout << "plot2d plot3d  projh1d  projh2d  projprof \n";  
+  cout << "fillvec  fillnt fillgd1 fillgd2  fft fit fitpsf aper\n";
+  cout << "*** Commande sans args -> liste d'arguments\n";
+  cout << "*** dopt: DisplayOption = next/same/win/stack,color,... \n";
+  cout << "*** $varname remplace par la valeur de la variable varname\n" << endl; 
+  }
+
+else if (kw == "shelp" )   {
+  cout << "\n PIACmd::Do() ------------- SHelp ------------ " << endl;
+  cout << "exec filename   --   set varname string  --  clr varname  --  listvars \n"; 
+  cout << "traceon/off  --  timingon/off  --  shell cmdline\n";
+  cout << "link fnameso f1 [f2 f3]  --   call userf [arg1 arg2 ...]\n";
+  cout << "zone nx ny -- newwin nx ny -- gratt attributes_list -- stacknext \n";
+  cout << "openppf file -- saveall file -- listobjs \n";
+  cout << "openfits file -- savefits nomobj file \n";
+  cout << "print nomobj -- rename nomobj nomnew -- del nomobj -- delobjs pattern (*,?) \n";
+  cout << "newh1d nomh xmin xmax nbin  --  newh2d nomh xmin xmax nbinx ymin ymax nbiny\n";
+  cout << "newprof nomh xmin xmax nbin [ymin ymax] \n";
+  cout << "newgfd nomgfd nvar nalloc [errx(0/1)]\n";
+  cout << "func expfunc xmin xmax npt opt\n";
+  cout << "func2d expfunc xmin xmax nptx ymin ymax npty opt\n";
+  cout << "disp nomobj opt  --  surf nomobj opt\n";
+  cout << "nt2d nomobj varx vary errx erry opt\n";
+  cout << "nt3d nomobj varx vary varz errx erry errz dopt\n";
+  cout << "gfd2d nomobj numvarx erreur=(x y xy) opt\n";
+  cout << "gfd3d nomobj numvarx numvary erreur=(x y z xy xz yz xyz) opt\n";
+  cout << "plot2d nomobj expx expy [experrx experry] expcut  dopt\n";
+  cout << "plot3d nomobj expx expy expz expcut dopt\n";
+  cout << "projh1d nomobj expx expwt expcut nomh1 dopt\n";
+  cout << "projh2d nomobj expx expy expwt expcut nomh2 dopt\n";
+  cout << "projprof nomobj expx expy expwt expcut nomprof dopt\n";
+  cout << "fillnt nomobj expx expy expz expt  expcut nomnt dopt\n";
+  cout << "fillvec nomobj expx expcut nomvec dopt\n";
+  cout << "fillgd1 nomobj expx expy experry expcut nomgfd\n";
+  cout << "fillgd2 nomobj expx expy expz experrz expcut nomgfd\n";
+  cout << "fft nomobj dopt\n";
+  cout << "fit nomobj func [p:p1,.,pn s:s1,.,sn m:m1,.,mn M:M1,.,Mn I:i1,i2 o:... o:...]\n";
+  cout << "fitpsf psf_typ [options_fit]\n";
+  cout << "aper fond_typ [options_calcul]\n";
+}
+
+else if (kw == "set") {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: set varname string" << endl;  return(0); }
+  mVars[tokens[0]] = tokens[1];
+  }
+else if (kw == "clr") {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: clr varname" << endl;  return(0); }
+  CmdVarList::iterator it = mVars.find(tokens[0]);
+  if (it != mVars.end())  mVars.erase(it);
+  else cerr << "PIACmd::Do() Pas de variable de nom " << tokens[0] << endl;
+  }
+else if (kw == "listvars") {
+  cout << "PIACmd::Do()  Variable List , VarName = Value \n";
+  CmdVarList::iterator it;
+  for(it = mVars.begin(); it != mVars.end(); it++)  
+    cout << (*it).first << " = " <<  (*it).second << "\n";
+  cout << endl;
+  }
+else if (kw == "traceon")  { cout << "PIACmd::Do()  -> Trace ON mode " << endl; trace = true; }
+else if (kw == "traceoff") { cout << "PIACmd::Do()  -> Trace OFF mode " << endl; trace = false; }
+else if (kw == "timingon") { 
+  cout << "PIACmd::Do()  -> Timing ON mode " << endl; 
+  if (gltimer)   delete gltimer;   gltimer = new Timer("PIA-CmdInterpreter ");   timing = true; }
+else if (kw == "timingoff") { 
+  cout << "PIACmd::Do()  -> Timing OFF mode " << endl; 
+  if (gltimer)  delete gltimer;  gltimer = NULL;  timing = false; }
+else if (kw == "exec") {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: exec filename" << endl;  return(0); }
+  Exec(tokens[0]);
+  }
+else if (kw == "shell") {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: shell cmdline" << endl;  return(0); }
+  system(toks.c_str());
+  }
+
+// >>>>>>>>>>> Fenetre graphique , changement d'attributs graphiques 
+else if (kw == "zone") {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: zone nx ny" << endl;  return(0); }
+  int nx, ny;
+  nx = ny = 1;
+  nx = atoi(tokens[0].c_str());    ny = atoi(tokens[1].c_str());
+  mObjMgr->SetGraphicWinZone(nx, ny, false);
+  }  
+else if (kw == "newwin") {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: newwin nx ny" << endl;  return(0); }
+  int nx, ny;
+  nx = ny = 1;
+  nx = atoi(tokens[0].c_str());    ny = atoi(tokens[1].c_str());
+  mObjMgr->SetGraphicWinZone(nx, ny, true);
+  }  
+else if (kw == "gratt") {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: gratt attributes_list (att=def->defaut)" << endl;  return(0); }
+  mObjMgr->SetGraphicAttributes(tokens[0]); 
+  }
+else if (kw == "stacknext") mImgApp->StackWinNext(); 
+
+// >>>>>>>>>>> Link dynamique de fonctions C++
+else if (kw == "link" ) {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: link fnameso f1 [f2 f3]" << endl;  return(0); }
+  string sph = "";
+  for(int gg=0; gg<5; gg++)   tokens.push_back(sph);
+  int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]);
+  if (rc == 0)  cout << "PIAcmd::Do(): Link from " << tokens[0] << " OK " << endl;
+}
+else if (kw == "call" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: call userf [arg1 arg2 ...]" << endl;  return(0); }
+  UsFmap::iterator it = usfmap.find(tokens[0]);
+  if (it == usfmap.end()) {
+    cerr << "PIAcmd::Do() No User Function " << tokens[0] << endl;
+    return(0);
+  }
+  cout << "PIAcmd::Do() Call " << tokens[0] << "( ... )" << endl;
+// on est oblige de faire un cast  etant donne qu'on 
+// utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++)
+  DlUserProcFunction fuf = (DlUserProcFunction)(*it).second;
+  TRY {
+    tokens.erase(tokens.begin());
+    fuf(tokens);
+  }  CATCH(merr) {
+    fflush(stdout); 
+    cout << endl; 
+    cerr << endl;
+    string es = PeidaExc(merr);
+    cerr << "PIACmd::Do() Call UserFunc  Exception :" << merr << es;
+    }
+}
+
+// >>>>>>>>>>> lecture/ecriture des objets, gestion des objets 
+else if (kw == "openfits" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: openfits file " << endl;  return(0); }
+  else mObjMgr->ReadFits(tokens[0]);
+}
+else if (kw == "savefits" ) {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: savefits nomobj filename " << endl;  return(0); }
+  else mObjMgr->SaveFits(tokens[0], tokens[1]);
+}
+else if (kw == "openppf" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: openppf file " << endl; return(0); }
+  mObjMgr->ReadAll(tokens[0]);  
+}
+else if (kw == "saveall" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: saveall file " << endl; return(0); }
+  mObjMgr->SaveAll(tokens[0]);  
+}
+else if (kw == "print" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: print nomobj " << endl; return(0); }
+  mObjMgr->PrintObj(tokens[0]);  
+}
+else if (kw == "rename" ) {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: rename nomobj nomnew" << endl; return(0); }
+  mObjMgr->RenameObj(tokens[0], tokens[1]);  
+}
+else if (kw == "del" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: del nomobj " << endl; return(0); }
+  mObjMgr->DelObj(tokens[0]);  
+}
+else if (kw == "delobjs" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
+  mObjMgr->DelObjects(tokens[0]);  
+}
+else if (kw == "listobjs")   mObjMgr->ListObjs();
+
+// >>>>>>>>>>> Creation d'histos 1D-2D
+else if (kw == "newh1d") {
+  if (tokens.size() < 4) { cout << "PIACmd::Do() Usage: newh1d nom xmin xmax nbin" << endl; return(0); }
+  int nbx;
+  float xmin, xmax;
+  nbx = 100;
+  xmin = 0.;  xmax = 1.;
+  nbx = atoi(tokens[3].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  Histo* h = new Histo(xmin, xmax, nbx);
+  mObjMgr->AddObj(h, tokens[0]);
+  }
+else if (kw == "newh2d") {
+  if (tokens.size() < 7) { 
+    cout << "PIACmd::Do() Usage:newh2d nomh xmin xmax nbinx ymin ymax nbiny" << endl; 
+    return(0); 
+    }
+  int nbx, nby;
+  float xmin, xmax;
+  float ymin, ymax;
+  nbx = nby = 50;
+  xmin = 0.;  xmax = 1.;
+  ymin = 0.;  ymax = 1.;
+  nbx = atoi(tokens[3].c_str());
+  nby = atoi(tokens[6].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());
+  Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby);
+  mObjMgr->AddObj(h, tokens[0]);
+  }
+else if (kw == "newprof") {
+  if (tokens.size() < 4)
+    { cout << "PIACmd::Do() Usage: newprof nom xmin xmax nbin [ymin ymax]" << endl; return(0); }
+  int nbx;
+  float xmin, xmax, ymin = 1., ymax = -1.;
+  if(tokens.size() > 5)
+    {ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());}
+  nbx = 100;
+  xmin = 0.;  xmax = 1.;
+  nbx = atoi(tokens[3].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax);
+  mObjMgr->AddObj(h, tokens[0]);
+  }
+else if (kw == "newgfd") {
+  if (tokens.size() < 3)
+    { cout << "PIACmd::Do() Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); }
+  int nvar, nalloc, errx=0;
+  if (tokens.size() > 3)
+    { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;}
+  nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str());
+  if(nvar>0 && nalloc>0) {
+    GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx);
+    mObjMgr->AddObj(gfd, tokens[0]);
+    }
+  }
+
+// >>>>>>>>>>>  Affichage des objets 
+else if ( (kw == "disp") || (kw == "surf") ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: disp nomobj opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 1)  opt = tokens[1];
+  if (kw == "disp") mObjMgr->DisplayObj(tokens[0], opt);
+  else if (kw == "surf")  mObjMgr->DisplaySurf3D(tokens[0], opt);
+  }
+
+else if (kw == "nt2d") {
+  if (tokens.size() < 5) { cout << "PIACmd::Do() Usage: nt2d nomobj varx vary errx erry opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  string ph = "";
+  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], ph, tokens[3], tokens[4], ph, opt);
+  }
+else if (kw == "nt3d") {
+  if (tokens.size() < 7) { cout << "PIACmd::Do() Usage: nt3d nomobj varx vary varz errx erry errz opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 7)  opt = tokens[7];
+  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt);
+  }
+
+else if (kw == "gfd2d") {
+  if(tokens.size()<2)
+    {cout<<"PIACmd::Do() Usage: gfd2d nomobj numvarx erreur=(x y xy) opt"<<endl;
+     return(0);}
+  string numvary = "";
+  string err = "";
+  string opt = "n";
+  if(tokens.size()>2) err = tokens[2];
+  if(tokens.size()>3) opt = tokens[3];
+  mObjMgr->DisplayGFD(tokens[0],tokens[1],numvary,err,opt);
+  }
+else if (kw == "gfd3d") {
+  if(tokens.size()<3)
+    {cout<<"PIACmd::Do() Usage: gfd3d nomobj numvarx numvary erreur=(x y z xy xz yz xyz) opt"<<endl;
+     return(0);}
+  string err = "";
+  string opt = "n";
+  if(tokens.size()>3) err = tokens[3];
+  if(tokens.size()>4) opt = tokens[4];
+  mObjMgr->DisplayGFD(tokens[0],tokens[1],tokens[2],err,opt);
+  }
+
+// >>>>>>>>>>>  Trace de fonctions 
+else if ( (kw == "func") ) {
+  if (tokens.size() < 4) { cout << "PIACmd::Do() Usage: func expr xmin xmax npt opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 4)  opt = tokens[4];
+  int np;
+  float xmin, xmax;
+  np = 100;
+  xmin = 0.;  xmax = 1.;
+  np = atoi(tokens[3].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  mObjMgr->PlotFunc(tokens[0], xmin, xmax, np, opt); 
+  }
+else if ( (kw == "func2d") ) {
+  if (tokens.size() < 7) {
+    cout << "PIACmd::Do() Usage: func2d expr xmin xmax nptx ymin ymax npty opt" << endl;
+    return(0);
+    }
+  int npx, npy;
+  float xmin, xmax;
+  float ymin, ymax;
+  npx = npy = 50;
+  xmin = 0.;  xmax = 1.;
+  ymin = 0.;  ymax = 1.;
+  npx = atoi(tokens[3].c_str());
+  npy = atoi(tokens[6].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());
+  string opt = "n";
+  if (tokens.size() > 7)  opt = tokens[7];
+  mObjMgr->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt);
+  }
+
+// >>>>>>>>>>>  Trace d'expressions de N_Tuple, StarList, etc ...
+else if (kw == "plot2d" ) {
+  if (tokens.size() < 4) {
+    cout << "PIACmd::Do() Usage: plot2d nomobj expx expy [experrx experry] expcut opt" << endl;
+    return(0); 
+    }
+  string errx = ""; string erry = ""; string ecut = "1";
+  string opt = "n";
+  if (tokens.size() < 6) { // Plot sans les erreurs
+    ecut = tokens[3];
+    if (tokens.size() > 4)  opt = tokens[4];
+    }
+  else {                 // Plot avec les erreurs
+    errx = tokens[3]; erry = tokens[4]; ecut = tokens[5];
+    if (tokens.size() > 6)  opt = tokens[6];
+    }
+  mObjMgr->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
+  }
+
+else if (kw == "plot3d" ) {
+  if (tokens.size() < 5) { 
+    cout << "PIACmd::Do() Usage: plot3d nomobj expx expy expz expcut opt" << endl;
+    return(0); 
+    }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  mObjMgr->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
+  }
+
+else if (kw == "projh1d" ) {
+  if (tokens.size() < 5) { 
+    cout << "PIACmd::Do() Usage: projh1d nomobj expx expwt expcut nomh1 opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  mObjMgr->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
+  }
+
+else if (kw == "projh2d" ) {
+  if (tokens.size() < 6) { 
+    cout << "PIACmd::Do() Usage: projh2 nomobj expx expy expwt expcut nomh2 opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 6)  opt = tokens[6];
+
+  mObjMgr->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
+  }
+
+else if (kw == "projprof" ) {
+  if (tokens.size() < 6) { 
+    cout << "PIACmd::Do() Usage: projprof nomobj expx expy expwt expcut nomprof opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 6)  opt = tokens[6];
+
+  mObjMgr->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
+  }
+
+else if (kw == "fillnt" ) {
+  if (tokens.size() < 7) { 
+    cout << "PIACmd::Do() Usage: fillnt nomobj expx expy expz expt expcut nomnt" << endl;
+    return(0);
+    }
+  mObjMgr->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
+  }
+
+else if (kw == "fillvec" ) {
+  if (tokens.size() < 4) { 
+    cout << "PIACmd::Do() Usage: fillvec nomobj expx expcut nomvec opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 4)  opt = tokens[4];
+  mObjMgr->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
+  }
+
+else if (kw == "fillgd1" ) {
+  if (tokens.size() < 5) {
+    cout << "PIACmd::Do() Usage: fillgd1 nomobj expx expy experry expcut nomgfd" << endl;
+    return(0);
+    }
+  string nomgfd = "";
+  if (tokens.size() > 5) nomgfd = tokens[5];
+  string expy = "";
+  mObjMgr->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
+  }
+
+else if (kw == "fillgd2" ) {
+  if (tokens.size() < 6) {
+    cout << "PIACmd::Do() Usage: fillgd2 nomobj expx expy expz experrz expcut nomgfd" << endl;
+    return(0);
+    }
+  string nomgfd = "";
+  if (tokens.size() > 6) nomgfd = tokens[6];
+  mObjMgr->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
+  }
+
+// Calcul TF 
+else if (kw == "fft" ) {
+  if (tokens.size() < 1) { 
+    cout << "PIACmd::Do() Usage: fft nomobj opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 1)  opt = tokens[1];
+  mObjMgr->FFT(tokens[0], opt);
+  }
+
+// Fit 1D sur objets 1D. Egalement Fit 2D sur objets 2D.
+else if (kw == "fit") {
+  if (tokens.size() < 2) {
+    cout <<"PIACmd::Do() Usage:fit nomobj func \n"
+         <<" [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]\n";
+    return(0);
+  }
+  string p=""; string s=""; string m=""; string M=""; string O="";
+  if (tokens.size()>2)
+    for(int ip=2;ip<tokens.size();ip++) {
+      if(tokens[ip].length()<=2) continue;
+      const char *c = tokens[ip].c_str();
+      if(c[1]!=':') continue;
+      if(c[0]=='p')      p=c+2;
+      else if(c[0]=='s') s=c+2;
+      else if(c[0]=='m') m=c+2;
+      else if(c[0]=='M') M=c+2;
+      else if(c[0]=='o') {O += ","; O += c+2;}
+    }
+  mObjMgr->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
+}
+
+#ifdef SANS_EVOLPLANCK 
+// FITPSF sur image
+else if (kw == "fitpsf" ) {
+  if (tokens.size() < 1) { 
+    cout << "PIACmd::Do() Usage: fitpsf psf_typ [options_fit]" << endl;
+    return(0);
+    }
+  FitPSFImg(tokens);
+  }
+
+// Photometrie d'ouvertue sur image 
+else if (kw == "aper" ) {
+  if (tokens.size() < 1) { 
+    cout << "PIACmd::Do() Usage: aper fond_typ [opt_calcul opt_disp]" << endl;
+    return(0);
+    }
+  Photom_Ouv(tokens);
+  }
+#endif
+
+else  { 
+  cerr << "PIACmd::Do() Erreur - Commande " << kw << " inconuue ! " << endl;    
+  return(-1);
+  }
+if (timing)  gltimer->Split();
+
+return(0);
+}
+
+
+
+/* --Methode-- */
+int PIACmd::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
+//                          string& func4, string& func5)
+{
+string cmd;
+int rc;
+
+if (dynlink) delete dynlink;    dynlink = NULL;
+usfmap.clear();
+
+dynlink = new PDynLinkMgr(fnameso, true);
+if (dynlink == NULL) { 
+  string sn = fnameso; 
+  cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl; 
+  return(2); 
+  }
+
+int nok=0;
+// on utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++)
+// DlUserProcFunction f = NULL;
+DlFunction f = NULL;
+if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func1.c_str());
+f = dynlink->GetFunction(func1);
+if (f) { nok++;  usfmap[func1] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
+
+if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func2.c_str());
+f = dynlink->GetFunction(func2);
+if (f) { nok++;  usfmap[func2] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
+
+if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func3.c_str());
+f = dynlink->GetFunction(func3);
+if (f) { nok++;  usfmap[func3] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
+
+/*  Pb compile g++ 2.7.2 
+if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func4.c_str());
+f = dynlink->GetFunction(func4);
+if (f) { nok++;  usfmap[func4] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
+
+if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func5.c_str());
+f = dynlink->GetFunction(func5);
+if (f) { nok++;  usfmap[func5] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
+*/
+fin:
+if (nok < 1) { if (dynlink) delete dynlink;    dynlink = NULL;  return(3); }
+else return(0);
+}
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////// Fonctions ///////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+#ifdef SANS_EVOLPLANCK 
+#include "psf.h"
+#include "dynccd.h"
+#include "pimgadapter.h"
+#include "nbmath.h"
+#include "nbtri.h"
+
+/* Nouvelle-Fonction    rz + cmv 15/10/98 */
+int FitPSFImg(cmdtok& tokens)
+//	Fit de PSF sur une Image.
+//| tokens[0] = Type de PSF ()
+//|      : G   = fit gaussienne+fond (volume)
+//|      : Gi  = fit gaussienne+fond integree (volume)
+//|      : d   = fit DL de gaussienne+fond (volume)
+//|      : di  = fit DL de gaussienne+fond integree (volume)
+//|      : D   = fit DL de gaussienne+fond avec coeff variable p6 (volume)
+//|      : Di  = fit DL de gaussienne+fond integree avec coeff variable p6 (volume)
+//|      : M   = fit Moffat+fond (expos=p6) (volume)
+//|      : Mi  = fit Moffat+fond integree (expos=p6) (volume)
+//| tokens[1] = options pour le fit ex: l1.0,G2.,R7.,m10.,M65000.,P3.,f,n,r,i,w10/450
+//|      : r = ecriture de l'image des residus (def=non)
+//|      : f = ecriture de l'image de de la PSF fitee (def=non)
+//|      : i = ecriture du pave initial selectionne pour le fit (def=non)
+//|      : n = ecriture de l'image du bruit (def=non)
+//|      : Gaa.bbb = gain en e-/ADU (def=1)
+//|      : Raa.bbb = readout noise en e- (def=0)
+//|      : maa.bbb = limite basse dynamique en ADU (def=-9.e19)
+//|      : Maa.bbb = limite haute dynamique en ADU (def=9.e19)
+//|      : Paa.bbb = valeur du parametre supplementaire pour 
+//|      : la.a = print a=FitPSFImg, b=PSF.Fit PSF.IniFit
+//|      : wa/b = "a" est le facteur de zoom de la fenetre de representation
+//|               des resultats (def=6) et b sa taille maximale (def=500).
+//| Return: 0 si Ok, <0 sinon.
+{
+// Decodage des arguments
+if(tokens.size()<1) return(-1);
+int typ_psf=PSF::psfGaussienne;
+bool wres=false, wpsf=false, wpav=false, wnois=false;
+float gain=1., readout=0., pixmin=-9.e19, pixmax=9.e19;
+int zoom=6, wmax=500;
+float par6=-1.;
+int lp=1, lpg=0;
+string dummy,dum;
+
+if(tokens.size()>=2) {
+  dummy = "," + tokens[1]+ ",";
+  if(strstr(dummy.c_str(),",r,")) wres=true;
+  if(strstr(dummy.c_str(),",f,")) wpsf=true;
+  if(strstr(dummy.c_str(),",i"))  wpav=true;
+  if(strstr(dummy.c_str(),",n"))  wnois=true;
+  if(strstr(dummy.c_str(),",G")) {
+    size_t p = dummy.find(",G"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",G%f",&gain);
+  }
+  if(strstr(dummy.c_str(),",P")) {
+    size_t p = dummy.find(",P"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",P%f",&par6);
+  }
+  if(strstr(dummy.c_str(),",R")) {
+    size_t p = dummy.find(",R"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",R%f",&readout);
+  }
+  if(strstr(dummy.c_str(),",m")) {
+    size_t p = dummy.find(",m"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",m%f",&pixmin);
+  }
+  if(strstr(dummy.c_str(),",M")) {
+    size_t p = dummy.find(",M"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",M%f",&pixmax);
+  }
+  if(strstr(dummy.c_str(),",l")) { // niveau de print
+    size_t p = dummy.find(",l"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    float ab;
+    if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
+    if(ab<0) ab = 0.;
+    lp = (int) ab; lpg = (int) 10.*(ab-lp);
+  }
+  if(strstr(dummy.c_str(),",w")) { // niveau de print
+    size_t p = dummy.find(",w"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",w%d/%d",&zoom,&wmax);
+  }
+}
+
+dummy = "," + tokens[0]+ ",";
+if(strstr(dummy.c_str(),",G,"))        typ_psf=PSF::psfGaussienne;
+else if(strstr(dummy.c_str(),",Gi,"))  typ_psf=PSF::psfGaussInteg;
+else if(strstr(dummy.c_str(),",d,") )  typ_psf=PSF::psfDelGaussienne;
+else if(strstr(dummy.c_str(),",di,"))  typ_psf=PSF::psfDelGaussinteg;
+else if(strstr(dummy.c_str(),",D,") ) {typ_psf=PSF::psfDel1Gaussienne; if(par6<=0.) par6=1.;}
+else if(strstr(dummy.c_str(),",Di,")) {typ_psf=PSF::psfDel1GaussInteg; if(par6<=0.) par6=1.;}
+else if(strstr(dummy.c_str(),",M,") ) {typ_psf=PSF::psfMoffat;         if(par6<=1.) par6=2.5;}
+else if(strstr(dummy.c_str(),",Mi,")) {typ_psf=PSF::psfMoffInteg;      if(par6<=1.) par6=2.5;}
+
+if(gain<=0.) gain=1.; if(readout<0.) readout=0.;
+if(zoom<1) zoom=1; if(zoom>10) zoom=10; // Il semble que le zoom soit limite a 10 !!!
+if(wmax>500) wmax=500;
+if(lp<0) lp=1; if(lpg<0) lpg=0;
+
+// Wigdet,piimage et image courants
+NamedObjMgr omg;
+PIStdImgApp* app = omg.GetImgApp();
+if(app == NULL)
+  {cout<<"Pas de PIStdImgApp*"<<endl; return(-2);}
+PIBaseWdg* curw= app->CurrentBaseWdg() ;
+if(curw == NULL)
+  {cout<<"Pas de PIBaseWdg*"<<endl; return(-3);}
+if(curw->kind() != PIImage::ClassId)
+  {cout<<"Current window not an Image"<<endl; return(-4);}
+PIImage* curpimg = (PIImage*)curw;
+if(curpimg == NULL)
+  {cout<<"Pas de PIImage*"<<endl; return(-5);}
+P2DArrayAdapter* img = curpimg->Image();
+if(img == NULL)
+  {cout<<"Pas de Image*"<<endl; return(-6);}
+string nom = "fitpsf_";
+
+// Definition du pave courant sur la piimage
+int dx = curpimg->XSzPave(), dy = curpimg->YSzPave();  
+int x0 = curpimg->XPave()-dx/2, y0 = curpimg->YPave()-dy/2;
+if(x0<0) x0 = 0; if(y0<0) y0 = 0;
+int x1 = x0+dx, y1 = y0+dy;
+if(x1>img->XSize()) x1=img->XSize(); if(y1>img->YSize()) y1=img->YSize();
+dx = x1-x0;  dy = y1-y0;
+int dxy = (dx>dy)?dx:dy;
+ImageR4* pav = new ImageR4(dx, dy); 
+{for(int j=0;j<dy;j++) for(int i=0;i<dx;i++) (*pav)(i,j)=(*img)(i+x0,j+y0);}
+
+// Bruit sur le pave
+DynCCD mdynccd(kPhotonNoise,pixmin,pixmax,gain,readout);
+ImageR4 *nois = NoiseImage(pav, &mdynccd);
+
+// Print
+int w=2*zoom*dxy+25; if(w>wmax){w=wmax;zoom=(wmax-25)/(2*dxy);if(zoom<1)zoom=1;}
+if(lp>1)
+  {cout<<"FitPSFImg: fun="<<tokens[0]<<","<<typ_psf
+       <<"  Write res="<<wres<<" psf="<<wpsf<<" pav="<<wpav<<" nois="<<wnois
+       <<"  Par6="<<par6<<"  lp="<<lp<<","<<lpg<<endl;
+   mdynccd.Print();
+   cout<<"... dx,y="<<dxy<<" zoom="<<zoom<<" w="<<w<<endl;}
+
+// PSF et Fit
+PSF mypsf(typ_psf,100.0);
+int npar = mypsf.NParm();
+PSFStar mypsfstar(&mypsf);
+if(npar>7) mypsfstar.Parm(6)=(double)par6; // Cas moffat et Dl gauss avec coeff var.
+int rc = mypsfstar.IniFit(*pav,*nois,lpg);
+if(rc != 0)
+  {cout<<"PIDemoApp::FitPSFImg(), Echec IniFit (rc="<<rc<<")"<<endl;
+   delete nois;  delete pav; return(-10); }
+rc = mypsfstar.Fit(*pav,*nois,lpg);
+if(rc != 0)
+  {cout<<"PIDemoApp::FitPSFImg(), Echec Fit (rc="<<rc<<")"<<endl;
+   delete nois;  delete pav; return(-11); }
+if(lp) mypsfstar.Print(2);
+float smax,axisrat,tiltdeg;
+rc = paramga((float) mypsfstar.SigX(),(float) mypsfstar.SigY()
+            ,(float) mypsfstar.Rho(),&smax,&axisrat,&tiltdeg);
+if(rc==0 && lp)
+  printf("...   sa=%g sb=%g (%g) teta=%g\n",smax,smax*axisrat,axisrat,tiltdeg);
+else printf("Erreur paramga \n");
+
+// Creation des pave resultats
+ImageR4* res = new ImageR4(dx, dy);
+ImageR4* psf = new ImageR4(dx, dy);
+CopieImage(*res,*pav); *res -= mypsfstar;
+*psf = 0.; *psf += mypsfstar;
+
+// Si on demande d'ecrire au moins un des resultats (pav,nois,res,psf) => menage!
+bool delobj = (wpav||wnois||wres||wpsf)?true:false;
+
+// Display des resultats, fenetre 2x2 {{pav,nois},{res,psf}}
+app->CreateGraphWin(2,2,w,w); app->SetZoomAtt(zoom);
+dummy = nom+"pav"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
+if(wpav) {
+  // Si on veut garder l'objet
+  omg.AddObj(pav,dummy);
+  omg.DisplayObj(omg.LastObjName());
+} else {
+  // "true" pour tuer (delete) de l'objet ImageR4 lors de la destruction de PIImage
+  app->DispImage(new ImageAdapter<r_4>(pav,true),dummy,Disp_Next);
+}
+dummy = nom+"nois"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
+if(wnois) {
+  omg.AddObj(nois,dummy);
+  omg.DisplayObj(omg.LastObjName());
+} else {
+  app->DispImage(new ImageAdapter<r_4>(nois,true),dummy,Disp_Next);
+}
+dummy = nom+"res"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
+if(wres) {
+  omg.AddObj(res,dummy);
+  omg.DisplayObj(omg.LastObjName());
+} else {
+  app->DispImage(new ImageAdapter<r_4>(res,true),dummy,Disp_Next);
+}
+dummy = nom+"psf"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
+if(wpsf) {
+  omg.AddObj(psf,dummy);
+  omg.DisplayObj(omg.LastObjName());
+} else {
+  app->DispImage(new ImageAdapter<r_4>(psf,true),dummy,Disp_Next);
+}
+
+return(0);
+}
+
+/* Nouvelle-Fonction    cmv 16/10/98 */
+int Photom_Ouv(cmdtok& tokens)
+//	Photometrie d'ouverture sur une Image.
+//| tokens[0] = Type de calcul du fond et du flux.
+//|   : b = fond calcule sur les pixels du bord du pave.
+//|   : a = fond sur les pixels autres que ceux servant au calcul du flux.
+//|   : faa.bbb = fond fixe a aa.bbb
+//|   defaut : "b"
+//| tokens[1] = options pour le fit ex: l1
+//|      : ra = "a" rayon minimal de scan (def=0)
+//|      : ga = "a" taille de la fenetre glissante pour les extrapolations (def=4)
+//|      : la = "a" niveau de print
+//|      : c  = la surface pour la photometrie est un carre (defaut=cercle)
+//|      : C  = recentrage du pave sur le pixel le + brillant  (defaut=non)
+//| tokens[2] = options graphiques
+//| Return: 0 si Ok, <0 sinon.
+{
+// Decodage des arguments
+if(tokens.size()<1) return(-1);
+int typ_fond=1, rmin=0, rmax, npt_gliss=4, lp=0;
+float fondimpos=0., fondbord=0., fondautre;
+bool cercle=true, centre=false;
+string opt="";
+string dummy; string dum;
+
+if(tokens.size()>=3) opt = tokens[2];
+if(tokens.size()>=2) {
+  dummy = "," + tokens[1]+ ",";
+  if(strstr(dummy.c_str(),",r")) {
+    size_t p = dummy.find(",r"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",r%d",&rmin);
+  }
+  if(strstr(dummy.c_str(),",g")) {
+    size_t p = dummy.find(",g"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",g%d",&npt_gliss);
+  }
+  if(strstr(dummy.c_str(),",l")) {
+    size_t p = dummy.find(",l"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",l%d",&lp);
+  }
+  if(strstr(dummy.c_str(),",c")) cercle = false;
+  if(strstr(dummy.c_str(),",C")) centre = true;
+}
+
+dummy = "," + tokens[0]+ ",";
+if(strstr(dummy.c_str(),",b,"))       typ_fond=1;
+else if(strstr(dummy.c_str(),",a,"))  typ_fond=2;
+else if(strstr(dummy.c_str(),",f"))  {
+  typ_fond=3;
+  size_t p = dummy.find(",f"); size_t q = dummy.find_first_of(',',p+1);
+  dum = dummy.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",f%f",&fondimpos);
+}
+
+if(rmin<0) rmin=0; if(npt_gliss<=0) npt_gliss=4; if(lp<0) lp=1;
+
+// Wigdet,piimage et image courants
+NamedObjMgr omg;
+PIStdImgApp* app = omg.GetImgApp();
+if(app == NULL)
+  {cout<<"Pas de PIStdImgApp*"<<endl; return(-2);}
+PIBaseWdg* curw= app->CurrentBaseWdg() ;
+if(curw == NULL)
+  {cout<<"Pas de PIBaseWdg*"<<endl; return(-3);}
+if(curw->kind() != PIImage::ClassId)
+  {cout<<"Current window not an Image"<<endl; return(-4);}
+PIImage* curpimg = (PIImage*)curw;
+if(curpimg == NULL)
+  {cout<<"Pas de PIImage*"<<endl; return(-5);}
+P2DArrayAdapter* img = curpimg->Image();
+if(img == NULL)
+  {cout<<"Pas de Image*"<<endl; return(-6);}
+string nom = "ouver_";
+
+// Definition du pave courant sur la piimage
+int xc = curpimg->XPave(), yc = curpimg->YPave();
+int dx = curpimg->XSzPave(), dy = curpimg->YSzPave();
+int dxym = (dx<dy)?dx:dy; if(dxym%2==0) dxym++; rmax = dxym/2;
+if(dxym<3||dxym>img->XSize()||dxym>img->YSize())
+  {cout<<"Pave trop petit/grand: "<<dxym<<endl; return(-10);}
+if(rmin>=rmax)
+  {cout<<"rayon mini="<<rmin<<">= rmax="<<rmax<<endl; return(-11);}
+if(centre) {  // Recentrage autour du pixel le + brillant?
+  int xcnew=-1, ycnew=-1; float pxnew=-1.e20,pxold=-1.e20,px;
+  for(int j=yc-rmax;j<=yc+rmax;j++) {
+    if(j<0 || j>=img->YSize()) continue;
+    for(int i=xc-rmax;i<=xc+rmax;i++) {
+      if(i<0 || i>=img->XSize()) continue;
+      px = (*img)(i,j);
+      if(i==xc && j==yc) pxold = px;
+      if((xcnew==-1 && ycnew==-1) || px>=pxnew) {xcnew=i; ycnew=j; pxnew=px;}
+      // cout<<"xcnew,ycnew,pxnew="<<xcnew<<" "<<ycnew<<" "<<pxnew<<endl;
+  } }
+  if(lp>1) cout<<"Re-centrage(x,y,px): old=("<<xc<<","<<yc<<","<<pxold<<")"
+               <<" -> new=("<<xcnew<<","<<ycnew<<","<<pxnew<<")"<<endl;
+  if(xcnew!=-1 && ycnew!=-1 && pxnew>pxold) {xc=xcnew; yc=ycnew;}
+}
+int x0=xc-rmax, y0=yc-rmax, x1=xc+rmax, y1=yc+rmax;
+if(x0<0||y0<0||x1>=img->XSize()||y1>=img->YSize())
+  {cout<<"Pave hors image"<<endl; return(-12);}
+int ic = rmax, jc = rmax;
+ImageR4* pav = new ImageR4(dxym, dxym);
+{for(int j=-rmax;j<=rmax;j++) for(int i=-rmax;i<=rmax;i++)
+    (*pav)(ic+i,jc+j)=(*img)(xc+i,yc+j);}
+
+// Print
+if(lp>1)
+  cout<<"photom_ouv[cercle="<<cercle<<",typ="<<typ_fond<<"]: pav["
+      <<dx<<","<<dy<<","<<dxym
+      <<"] xc,yc=["<<xc<<","<<yc<<"] ic,jc="<<ic<<","<<jc<<endl
+      <<"          (fond="<<fondimpos<<") pxmil="<<(*pav)(ic,ic)
+      <<" -> Rph de "<<rmin<<" a "<<rmax<<endl;
+
+// Ouverture des buffers et objets necessaires
+float *p = new float[dxym*dxym];
+r_4 xnt[4];
+NTuple *ntfl=NULL, *ntex=NULL;
+{char* name[4]={"npx","flux","fond","mag"}; ntfl = new NTuple(4,name);}
+{char* name[3]={"k","a","f0"};              ntex = new NTuple(3,name);}
+
+// Calcul du fond sur les pixels du bord du pave
+{
+int nf = 0;
+for(int i=0;i<dxym;i++)   {p[nf]=(*pav)(i,0); nf++; p[nf]=(*pav)(i,dxym-1); nf++;}
+for(int j=1;j<dxym-1;j++) {p[nf]=(*pav)(0,j); nf++; p[nf]=(*pav)(dxym-1,j); nf++;}
+qsort(p,(size_t) nf,sizeof(float),qSort_Float);
+fondbord = (p[nf/2]+p[(nf-1)/2])/2.;
+if(lp>0) cout<<"Fond_Bord: "<<fondbord<<" (avec 1 px au bord="<<nf<<")"<<endl;
+}
+
+// Photometrie d'ouverture variable.
+int rfin = -1;
+for(int r=rmin;r<=rmax;r++) {
+  double sum=0.; int ns=0, nf=0;
+  for(int i=0;i<dxym;i++) for(int j=0;j<dxym;j++) {
+    double ray2 = (i-ic)*(i-ic)+(j-jc)*(j-jc)-0.1;
+    if( (cercle && ray2<=r*r) ||
+        (!cercle && ic-r<=i && i<=ic+r && jc-r<=j && j<=jc+r) )
+          {sum += (*pav)(i,j); ns++;}
+    else {p[nf] = (*pav)(i,j); nf++;}
+  }
+  if(typ_fond==2) {
+    if(nf<2) continue;
+    qsort(p,(size_t) nf,sizeof(float),qSort_Float);
+    fondautre = (p[nf/2]+p[(nf-1)/2])/2.;
+  }
+  double fond=-1.e19;
+  if(typ_fond==3) fond=fondimpos; else if(typ_fond==2) fond=fondautre; else fond=fondbord;
+  rfin = r;
+  xnt[0] = ns;
+  xnt[1] = sum-fond*ns;
+  xnt[2] = fond;
+  xnt[3] = (xnt[1]>0.)? -2.5*log10((double)xnt[1]): -99.;
+  if(lp>0)
+    cout<<"Ouv[r="<<r<<",ns="<<xnt[0]<<",nf="<<nf<<"]: fd="<<xnt[2]
+        <<" fl="<<xnt[1]<<" mag="<<xnt[3]<<endl;
+  ntfl->Fill(xnt);
+}
+delete [] p;
+int nr = ntfl->NEntry();
+if(lp>1) cout<<"Nombre de calculs de flux: "<<nr<<endl;
+if(nr<=0)
+  {cout<<"Pas de flux calcules"<<endl; delete pav; delete ntfl; delete ntex; return(-13);}
+
+cout<<"Ouv[rouv="<<rfin<<",npix="<<xnt[0]<<"]: fond="<<xnt[2]
+    <<" flux="<<xnt[1]<<" mag="<<xnt[3]<<endl;
+
+// Extrapolation: F_mes = F_vrai + npxflux*(Fd_vrai-Fd_mes)
+// On fit F_mes=f(npxflux) sur une fenetre glissante de npt_gliss pts.
+bool ex = false;
+if(nr>=npt_gliss) {
+  ex = true;
+  double *npix = new double[nr], *flux = new double[nr], *err  = new double[nr];
+  for(int i=0;i<nr;i++) { ntfl->GetVec(i,xnt); npix[i]=xnt[0]; flux[i]=xnt[1]; err[i]=1.;}
+  double a,b; int n;
+  for(int k=0;k<=nr-npt_gliss;k++) {
+    n = npt_gliss; FitLin(&npix[k],&flux[k],&err[k],&n,&b,&a);
+    xnt[0]=k; xnt[1]=a; xnt[2]=b; ntex->Fill(xnt);
+    if(lp>1)
+      cout<<"Fit["<<k<<","<<k+npt_gliss-1<<"] f0="<<xnt[2]<<" pente="<<xnt[1]<<endl;
+  }
+  delete [] npix; delete [] flux; delete [] err;
+}
+
+// Display des resultats, fenetre 2x2 {{flux%ns,fond%ns},{f0,pente}}
+if(ex) app->CreateGraphWin(2,2); else app->CreateGraphWin(1,2);
+dummy = nom+"*"; omg.DelObjects(dummy);
+
+dummy=nom+"pav"; omg.AddObj(pav,dummy);
+
+string xd=""; string yd=""; string zd,exd,eyd,ezd;
+dummy=nom+"flux"; omg.AddObj(ntfl,dummy);
+xd="npx"; yd="flux";
+omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);
+if(typ_fond==2)
+  {xd="npx"; yd="fond"; omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);}
+if(ex) {
+  dummy=nom+"fit"; omg.AddObj(ntex,dummy);
+  if(typ_fond!=2)
+    {xd="a"; yd="f0"; omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);}
+  xd = "k"; yd = "f0";
+  omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);
+  xd = "k"; yd = "a";
+  omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);
+}
+
+return(0);
+}
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/piacmd.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/piacmd.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/piacmd.h	(revision 1307)
@@ -0,0 +1,59 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe interpreteur de commande pour piapp 
+// Reza      Aout 97 , Juillet,Aout 98
+// LAL-IN2P3/CNRS
+
+#ifndef PIACMD_H_SEEN
+#define PIACMD_H_SEEN
+
+#include "defs.h"
+
+#include <fstream.h>
+#include <string>
+#include <map>
+#if defined(__KCC__)
+using std::string ;
+#include <map.h>
+#endif
+
+#include "pdlmgr.h"
+
+#include "ctimer.h"
+#include "dlftypes.h"
+
+class NamedObjMgr;
+class PIStdImgApp;
+
+
+class PIACmd {
+public:
+		PIACmd(NamedObjMgr* omg=NULL, PIStdImgApp* app=NULL);
+		~PIACmd();
+  int		Exec(string& file);
+  int		Do(string& line);
+
+//  Link dynamique de fonction user
+  int 		LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3);
+//                            string& func4, string& func5);   compil avec g++ 2.7.2
+  NamedObjMgr* mObjMgr;
+  PIStdImgApp* mImgApp;
+  bool mOmg;
+
+//  Pour stocker les variables definies par l'interpreteur
+typedef map<string, string, less<string> > CmdVarList;
+
+  CmdVarList mVars;    // Liste des variables 
+  ofstream hist;       //  History file 
+  bool trace;          // Trace flag
+  bool timing;         // Display CPU Time
+  Timer* gltimer;      // pour Display CPU Time
+
+// g++ n'arrive pas a avaler ca (lignes trop longues)  on utilise donc des DlFunction  (Reza 20/08/98)
+// typedef map<string, DlUserProcFunction, less<string> > UsFmap;
+typedef map<string, DlFunction, less<string> > UsFmap;
+  PDynLinkMgr* dynlink;
+  UsFmap usfmap;
+
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/pigfd1.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pigfd1.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pigfd1.cc	(revision 1307)
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include "pigfd1.h"
+
+ 
+/* --Methode-- */
+PIGenFitDat::PIGenFitDat(GeneralFitData* gfd, bool ad)
+: PIDrawer(), mGFD(gfd), mAdDO(ad), VarX(0), ErrX(false), ErrY(false)
+{
+SelectX(0);
+SelectErrBar(false,false);
+}
+
+PIGenFitDat::~PIGenFitDat()
+{
+if(mAdDO && mGFD)  delete mGFD;
+}
+
+/* --Methode-- */
+void  PIGenFitDat::SelectX(int varx)
+{
+VarX = -1;
+if(mGFD == NULL) return;
+if(varx<0 || varx>=mGFD->NVar()) return;
+VarX = varx;
+}
+
+/* --Methode-- */
+void  PIGenFitDat::SelectErrBar(bool erbx,bool erby)
+{
+ErrX = erbx; ErrY = erby;
+if(mGFD == NULL) {ErrX = ErrY = false; return;}
+if(!mGFD->HasXErrors()) ErrX = false;
+}
+
+/* --Methode-- */
+void PIGenFitDat::UpdateLimits()
+{
+if(!mGFD) return;
+if(mGFD->NData()<=0) return;
+if(VarX<0) return;
+double dx, dy;
+double xmin=9.e19, xmax=-9.e19, ymin=9.e19, ymax=-9.e19;
+mGFD->GetMinMax(10*VarX+2,xmin,xmax);
+mGFD->GetMinMax(0,ymin, ymax);
+if(xmax<=xmin) xmax = xmin+1.;
+if(ymax<=ymin) ymax = ymin+1.;
+dx = 0.02*(xmax-xmin);
+dy = 0.02*(ymax-ymin);
+SetLimits((double)xmin-dx,(double)xmax+dx,(double)ymin-dy,(double)ymax+dy);
+SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+/* --Methode-- */
+void PIGenFitDat::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+if (!mGFD) return;
+if(mGFD->NData()<=0) return;
+if(VarX<0) return;
+// On plotte les barre d'erreurs ligne demandee explicitement
+if(mLAtt!=PI_NotDefLineAtt) SelectErrBar(true,true);
+double xp,yp,er;
+for (int i=0; i<mGFD->NData(); i++) {
+  xp = mGFD->Absc(VarX,i);
+  yp = mGFD->Val(i);
+  if(xp<xmin || xp>xmax || yp<ymin || yp>ymax)  continue;
+  if(ErrX) {
+    er = mGFD->EAbsc(VarX,i);
+    if(er>0.) g->DrawLine(xp-er,yp,xp+er,yp);
+  }
+  if(ErrY) {
+    er = mGFD->EVal(i);
+    if(er>0.) g->DrawLine(xp,yp-er,xp,yp+er);
+  }
+  g->DrawMarker(xp, yp); 
+}
+return;
+}
Index: /tags/DPC_V0/Poubelle/PIext/pigfd1.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pigfd1.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pigfd1.h	(revision 1307)
@@ -0,0 +1,25 @@
+#ifndef PIGFD1_H
+#define PIGFD1_H
+
+#include "generaldata.h"
+#include "pidrawer.h"
+
+class PIGenFitDat : public PIDrawer {
+public:
+                     PIGenFitDat(GeneralFitData* gfd, bool ad);
+  virtual           ~PIGenFitDat();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+          void       SelectX(int varx);
+          void       SelectErrBar(bool erbx,bool erby);
+       
+protected:
+  GeneralFitData* mGFD;
+  bool mAdDO;
+  int VarX;          // numero de variable X ds le GeneralFitData
+  bool ErrX,ErrY;    // Erreur en X et Y ?
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/pigfd2.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pigfd2.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pigfd2.cc	(revision 1307)
@@ -0,0 +1,104 @@
+#include <stdio.h>
+#include "pigfd2.h"
+
+/* --Methode-- */
+PIGenFitDat3D::PIGenFitDat3D(GeneralFitData* gfd, bool ad)
+: PIDrawer3D(), mGFD(gfd), mAdDO(ad)
+, VarX(0), VarY(1), ErrX(false), ErrY(false), ErrZ(false)
+{
+SelectXY(0,1);
+SelectErrBar(false,false,false);
+}
+
+PIGenFitDat3D::~PIGenFitDat3D()
+{
+if(mAdDO && mGFD)  delete mGFD;
+}
+
+/* --Methode-- */
+void  PIGenFitDat3D::SelectXY(int varx,int vary)
+{
+VarX = VarY = -1;
+if(mGFD == NULL) return;
+if(varx<0 || varx>=mGFD->NVar()) return;
+if(vary<0 || vary>=mGFD->NVar()) return;
+VarX = varx; VarY = vary;
+}
+
+/* --Methode-- */
+void  PIGenFitDat3D::SelectErrBar(bool erbx,bool erby,bool erbz)
+{
+ErrX = erbx; ErrY = erby; ErrZ = erbz;
+if(mGFD == NULL) {ErrX = ErrY = ErrZ = false; return;}
+if(!mGFD->HasXErrors()) ErrX = ErrY = false;
+}
+
+/* --Methode-- */
+void PIGenFitDat3D::UpdateLimits()
+{
+if(!mGFD) return;
+if(mGFD->NData()<=0) return;
+if(VarX<0 || VarY<0) return;
+double xmin=9.e19, xmax=-9.e19, ymin=9.e19, ymax=-9.e19, zmin=9.e19, zmax=-9.e19;
+mGFD->GetMinMax(10*VarX+2,xmin,xmax);
+mGFD->GetMinMax(10*VarY+2,ymin,ymax);
+mGFD->GetMinMax(0,zmin, zmax);
+if(xmax<=xmin) xmax = xmin+1.;
+if(ymax<=ymin) ymax = ymin+1.;
+if(zmax<=zmin) zmax = zmin+1.;
+// Voir commentaires pintuple3d.cc
+double D = xmax-xmin;
+if (D < (ymax-ymin))  D = ymax-ymin;
+D *= 1.4;
+Set3DView((xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)/2., 
+          (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25);  
+
+x3Min = xmin;    x3Max = xmax;
+y3Min = ymin;    y3Max = ymax;
+z3Min = zmin;    z3Max = zmax;
+
+}
+
+/* --Methode-- */
+void PIGenFitDat3D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+// On trace les axes - En attendant de faire mieux - Reza 8/12/98
+if (axesFlags != kAxesNone)  DrawAxes(g);
+
+if (!mGFD) return;
+if(mGFD->NData()<=0) return;
+if(VarX<0 || VarY<0) return;
+
+// On plotte les barre d'erreurs ligne demandee explicitement
+if(mLAtt!=PI_NotDefLineAtt) SelectErrBar(true,true,true);
+
+#if defined(__DECCXX) || defined(__KCC__)
+PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+
+if (mLAtt == PI_NotDefLineAtt)  g3->SelLine(PI_ThinLine);
+
+double xp,yp,zp,er;
+for (int i=0; i<mGFD->NData(); i++) {
+  xp = mGFD->Absc(VarX,i);
+  yp = mGFD->Absc(VarY,i);
+  zp = mGFD->Val(i);
+  if(ErrX) {
+    er = mGFD->EAbsc(VarX,i);
+    if(er>0.) g3->DrawLine3D(xp-er,yp,zp,xp+er,yp,zp);
+  }
+  if(ErrY) {
+    er = mGFD->EAbsc(VarY,i);
+    g3->DrawLine3D(xp,yp-er,zp,xp,yp+er,zp);
+  }
+  if(ErrZ) {
+    er = mGFD->EVal(i);
+    g3->DrawLine3D(xp,yp,zp-er,xp,yp,zp+er);
+  }
+  g3->DrawMarker3D(xp,yp,zp); 
+}
+
+return;
+}
Index: /tags/DPC_V0/Poubelle/PIext/pigfd2.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pigfd2.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pigfd2.h	(revision 1307)
@@ -0,0 +1,26 @@
+#ifndef PIGFD2_H
+#define PIGFD2_H
+
+#include "generaldata.h"
+#include "pi3ddrw.h"
+
+class PIGenFitDat3D : public PIDrawer3D {
+public:
+                     PIGenFitDat3D(GeneralFitData* gfd, bool ad);
+  virtual           ~PIGenFitDat3D();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+          void       SelectXY(int varx,int vary);
+          void       SelectErrBar(bool erbx,bool erby,bool erbz);
+
+       
+protected:
+  GeneralFitData* mGFD;
+  bool mAdDO;
+  int VarX,VarY;         // numero de variable X,Y ds le GeneralFitData
+  bool ErrX,ErrY,ErrZ;   // Erreur en X,Y et Z?
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/pihisto.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pihisto.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pihisto.cc	(revision 1307)
@@ -0,0 +1,117 @@
+#include <stdio.h>
+#include "pihisto.h"
+#include "hisprof.h"
+
+PIHisto::PIHisto(Histo* histo, bool ad)
+: PIDrawer(), mHisto(histo)
+{
+  mAdDO = ad;     // Flag pour suppression automatique de mHisto
+}
+
+PIHisto::~PIHisto()
+{
+  if (mAdDO) delete mHisto;
+}
+
+void
+PIHisto::UpdateLimits()
+{
+  if (!mHisto)  return;
+  float hmin = mHisto->VMin();
+  float hmax = mHisto->VMax()+0.2*(mHisto->VMax()-mHisto->VMin());
+  // si HBProf min,max calcules en tenant compte des erreurs
+  if( mHisto->ClassId() == HProf::classId ) {
+    float v1,v2;
+    for (int i=1; i<mHisto->NBins(); i++) {
+      v1 = (*mHisto)(i) - mHisto->Error(i);
+      v2 = (*mHisto)(i) + mHisto->Error(i);
+      if(v1<hmin) hmin = v1;
+      if(v2>hmax) hmax = v2;
+    }
+    v1 = 0.1*(hmax-hmin);
+    hmin -= v1;   hmax += v1;
+  }
+  if(hmax<=hmin) hmax += 1.;
+  SetLimits(mHisto->XMin(), mHisto->XMax(), hmin, hmax);
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+void
+PIHisto::Draw(PIGraphicUC* g, double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/)
+{
+  bool oktrace = false;
+  if (!mHisto)  return;  
+
+  if (mMrk != PI_NotDefMarker || mHisto->ClassId() == HProf::classId ) {
+    // Marqeurs definis OU HBProf => marqueurs+Erreurs si il y en a
+    if (mLAtt == PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
+    double x1,y1, x2,y2;
+    double bw = mHisto->BinWidth();
+    for (int i=0; i<mHisto->NBins(); i++) {
+      if(mHisto->Error(i)>0.) {
+        // barres d'erreur verticales
+        x1 = x2 = mHisto->BinCenter(i);
+        y1 = (*mHisto)(i) - mHisto->Error(i);
+        y2 = (*mHisto)(i) + mHisto->Error(i);
+        g->DrawLine(x1,y1, x1, y2);
+        // limites de barres d'erreurs (horizontales)
+        x1 -= bw/3.;  x2 += bw/3.;
+        g->DrawLine(x1,y1, x2, y1);
+        g->DrawLine(x1,y2, x2, y2);
+      }
+      // le marqueur
+      x1 = mHisto->BinCenter(i);
+      y1 = (*mHisto)(i);
+      g->DrawMarker(x1,y1);
+    }
+    oktrace = true;
+  }
+  if (mLAtt != PI_NotDefLineAtt) {
+    double x1,y1, x2, y2;
+    x1 = mHisto->BinLowEdge(0);
+    y1 = 0;
+    for (int i=0; i<mHisto->NBins(); i++) {
+      x2 = x1;
+      y2 = (*mHisto)(i);
+      g->DrawLine(x1,y1, x2, y2);
+      y1 = y2;
+      x2 = mHisto->BinHighEdge(i);
+      g->DrawLine(x1,y1, x2, y2);
+      x1 = x2;
+    }
+    y2 = 0; g->DrawLine(x1,y1, x2, y2);
+    oktrace = true;
+  }
+  if( !oktrace ) {
+    for(int i=0; i<mHisto->NBins(); i++) {
+      double left   = mHisto->BinLowEdge(i);
+      double width  = mHisto->BinWidth();
+      double bottom = 0;
+      double height = (*mHisto)(i);
+      g->DrawFBox(left,bottom,width,height);
+      g->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne...
+    }
+  }
+  // A faire a la fin - DrawStats change l'attribut de ligne 
+  DrawStats(g);
+}
+
+void
+PIHisto::DrawStats(PIGraphicUC* g)
+{
+  if (!mHisto) return;
+  //  if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+  g->SelLine(PI_ThinLine);
+  double cellHeight = (YMax() - YMin()) * 0.05;
+  double cellWidth  = (XMax() - XMin()) * 0.23;
+  g->DrawLine(XMax() - cellWidth, YMax(),
+                       XMax() - cellWidth, YMax() - cellHeight);
+  g->DrawLine(XMax() - cellWidth, YMax() - cellHeight,
+                       XMax()            , YMax() - cellHeight);
+  char label[50];
+  sprintf(label, "N = %.6g", mHisto->NData());
+  g->SelFontSz((YMax() - YMin())/30);
+  g->DrawString(XMax() - cellWidth*0.9, YMax() - cellHeight*0.8, label);
+                       
+}
+
Index: /tags/DPC_V0/Poubelle/PIext/pihisto.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pihisto.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pihisto.h	(revision 1307)
@@ -0,0 +1,21 @@
+#ifndef PIHISTO_H
+#define PIHISTO_H
+
+#include "histos.h"
+#include "pidrawer.h"
+
+class PIHisto : public PIDrawer {
+public:
+                     PIHisto(Histo* histo, bool ad=false);
+  virtual           ~PIHisto();
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  virtual void       DrawStats(PIGraphicUC* g);
+  inline  Histo*     Histogram() { return(mHisto); }
+
+protected:
+  Histo* mHisto;
+  bool mAdDO;
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/pihisto2d.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pihisto2d.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pihisto2d.cc	(revision 1307)
@@ -0,0 +1,794 @@
+#include <stdio.h>
+#include "piapplgen.h"
+#include "pihisto2d.h"
+#include "nbrandom.h"
+
+static int dbg = 0;
+
+//++
+// Class	PIHisto2D,PIH2DWdg,H2WinArg
+// Lib	PI
+// include	pihisto2d.h
+//
+//	Classes de dessin des histogrammes a 2 dimensions.
+//--
+
+//++
+// Titre	Dessin d'un histogramme 2D.
+//--
+
+//++
+PIHisto2D::PIHisto2D(Histo2D* histo, bool ad)
+//
+//	Createur d'une classe de dessin pour l'histogramme 2D histo.
+//--
+: PIDrawer(), mHisto(histo)
+{
+mAdDO = ad;     // Flag pour suppression automatique de mHisto  
+
+mLogScale = 10.;
+mFPoints = 0.5;
+
+UseColors();
+UseDisplay();
+UseDyn();
+UseFrac();
+}
+
+//++
+PIHisto2D::~PIHisto2D()
+//
+//	Destructeur.
+//--
+{
+if(mAdDO) delete mHisto;
+}
+
+//++
+void PIHisto2D::UseColors(bool fg, CMapId cmap)
+//
+//	Choix de la couleur si fg=true avec la color map cmap.
+//	(pour la couleur cmap cf picmap.h).
+//      Independamment du choix du display, la dynamique est
+//      codee sur la color map donnant ainsi une double
+//      information. Par exemple, carres de tailles variables
+//      en couleur. Cette option est incontournable dans le cas
+//      d'un display par des carres de taille fixe.
+//--
+{
+mFgCol = fg; mCmap = cmap;
+}
+
+//++
+void PIHisto2D::UseScale(unsigned short type,float logscale)
+//
+//	Pour changer les echelles (lineaire ou logarithmique)
+//| Type = 0 : echelle lineaire
+//|      = 1 : echelle log10
+//| -**- Explication du codage en type=0 (lineaire) :
+//|   1. [hmin,hmax] -> [0,1]
+//|           h      ->   f = (h-hmin)/(hmax-hmin)
+//|   2. codage de f=[0,1] sur la dynamique du display choisi
+//| -**- Explication du codage en type=1 (logarithmique base 10) :
+//|   1. map lineaire entre 0 et 1:
+//|      [hmin,hmax] -> [0,1]
+//|           h      ->   f = (h-hmin)/(hmax-hmin)
+//|   2. transformation logarithmique de base 10 :
+//|      [0,1] -> [0,1]
+//|        f   -> lf = log10(1.+f*(logscale-1))/log10(logscale)
+//|   3. codage de lf=[0,1] sur la dynamique du display choisi
+//--
+{
+if(type==0) mTypScal = 0;
+if(type==1) {
+  mTypScal = 1;
+  if(logscale>1.) mLogScale = logscale;
+} else mTypScal = 0;
+}
+
+//++
+void PIHisto2D::UseDisplay(unsigned short type, float fnpt)
+//
+//	Type de Display
+//| Type = 0 : carres de tailles variables
+//| Type = 1 : nuages de points
+//|            Le nombre de points a utiliser est fnpt*N
+//|            ou N est le nombre de pixels ecran contenu
+//|            dans un bin de l'histogramme.
+//| Type = 2 : code a la "hbook2" " .+123...9AB...YZ*"
+//|            (cf detail PIHisto2D::HPrint2)
+//| Type = 3 : carres de taille fixe (couleur).
+//--
+{
+if(fnpt<0.) fnpt=0; else if(fnpt>1.) fnpt=1.;
+if(type==0)        mTypDisp = 0;
+else if(type==1) { mTypDisp = 1; mFPoints = fnpt;}
+else if(type==2)   mTypDisp = 2;
+else if(type==3)   mTypDisp = 3;
+else               mTypDisp = 1;
+}
+
+//++
+void PIHisto2D::UseDyn(float hmin, float hmax)
+//
+//	Gestion de la dynamique a representer:
+//|  La dynamique va etre transformee de [hmin,hmax] vers [0,1] selon
+//|  [hmin,hmax] -> [0,1]
+//|       h      ->   f = (h-hmin)/(hmax-hmin)
+//|  Par la suite selon ce qui est demande, f va coder le display ou etre
+//|  transforme en une autre echelle [0,1].
+//|  Si hmax<=hmin, ils sont forces a la dynamique totale de l'histo2D.
+//--
+{
+if(hmin>=hmax) {hmin = mHisto->VMin(); hmax = mHisto->VMax();}
+if(hmin>=hmax) hmax = hmin+1.;
+mHMin = hmin; mHMax = hmax;
+}
+
+//++
+void PIHisto2D::UseFrac(float frmin, float frmax)
+//
+//	Pour definir la fraction de la dynamique a dessiner:
+//| Certains type de display (f=[0,1] cf PIHisto2D::UseDyn),
+//|  - on ne dessine rien si f <= frmin dans les cas de display avec
+//|    des nuages de points ou des carres de tailles variables.
+//|    Pour un display "a la hbook2" on force frmin = 0.
+//|  - frmax n'est utilise que pour la representation avec
+//|    des carres de tailles variables: c'est la taille
+//|    maximum que peut avoir le carre exprimee en unite
+//|    de la taille du bin (ex: si frmax=0.8 le carre
+//|    le + grand qui pourra etre dessine dans un bin
+//|    aura une taille egale a 0.8*(taille du bin)).
+//--
+{
+if(frmax<=0. || frmax>1.) frmax = 1.;
+if(frmin>=frmax) {frmin=0.1; frmax=0.9;}
+mFracMin = frmin; mFracMax = frmax;
+}
+
+//++
+void PIHisto2D::Print(int lp)
+//
+//	Print de l'etat des options du display.
+//--
+{
+printf("PIHisto2D::Print FgCol=%d Cmap=%d TypScal=%d TypDisp=%d (FPoints=%g)\n"
+      ,(int)mFgCol,(int)mCmap,mTypScal,mTypDisp,mFPoints);
+printf("                 Dyn=%g,%g Frac=%g,%g LogSc=%g H=%lx\n"
+      ,mHMin,mHMax,mFracMin,mFracMax,mLogScale,(long)mHisto);
+if(lp<1) return;
+mHisto->PrintStatus();
+}
+
+//++
+void PIHisto2D::UpdateLimits()
+//
+//	Definition des tailles graphiques en fonction
+//	des caracteristiques de l'histogramme a dessiner.
+//--
+{
+  if(!mHisto) return;
+  SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->YMin() , mHisto->YMax());
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+//++
+void PIHisto2D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+//
+//	Dessin de l'histogramme.
+//|  Code de dessin selon choix des options:
+//|  (detail voir UseColors UseScale UseDisplay UseDyn UseFrac)
+//|  [hmin,hmax] -> [0,1] [[ -> re-codage log10 entre [0,1] ]] -> f=[0,1]
+//|  Puis selon display:
+//|  0 carres variables : if(f>fracmin) taille carre = f*fracmax *taille_du_bin
+//|  1 nuage de points  : if(f>fracmin) npoints = f*PerPt *npoints_ecran_dans_bin
+//|  2 code hbook2      : if(f>0) map de f=]0,1] dans ".+...Z*"
+//|  3 carres fixes     : couleur = lut[f*nombre_d_entree_dans_la_lut]
+//--
+{
+if(!mHisto) return;
+// Caracteristiques histogramme
+double dx = mHisto->WBinX(),dy = mHisto->WBinY();
+double p1dx,p1dy;
+g->DGrC2UC(1.f,1.f,p1dx,p1dy);
+
+// Gamme a representer entre [0,1] mais >=fracmin et scale fracmax
+float fracmin=FMin(), fracmax=FMax();
+float llscale = (float) log10((double)LogScale());
+
+// gestion Couleurs.
+PIColorMap* cmap=NULL;
+PIColors coul = g->GetForeground();
+int ncol = 0;
+if (mFgCol) {
+  cmap = new PIColorMap(mCmap); ncol = cmap->NCol();
+  if(mTypDisp==3) fracmin=-1.;
+}
+
+// gestion epaisseur de ligne
+if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+
+// gestion Markers ou plot avec des points.
+PIMarker Mk = g->GetMarker();
+int MkSz = g->GetMarkerSize();
+int npt = 1;
+if(mTypDisp==1) {
+  g->SelMarker(1,PI_DotMarker);
+  npt = (int) ((float)NPixBin(g)*FPoints()); if(npt<=0) npt = 2;
+}
+
+// gestion Font.
+PIFontAtt FontAtt = g->GetFontAtt();
+int FontSize = g->GetFontSize();
+if(mTypDisp==2) {
+  double dxg,dyg,dg;
+  g->DUC2GrC(dx,dy,dxg,dyg);
+  dg =(dxg<dyg) ? dxg : dyg;
+  int npix = (int) (dg*0.9); if(npix<8) npix = 8;
+  //printf("PIHisto2D::Draw_Font H dx=%g dy=%g, G dx=%g dy=%g, npix = %g,%d\n"
+  //      ,dx,dy,dxg,dyg,dg,npix);
+  g->SelFontSzPt(npix,PI_RomanFont);
+  fracmin = 0;
+}
+
+// Print();
+
+// Plot de l'histogramme
+for (int i=0; i<mHisto->NBinX(); i++)
+for (int j=0; j<mHisto->NBinY(); j++) {
+
+  float left0,bottom0;
+  mHisto->BinLowEdge(i,j,left0,bottom0);
+
+  // Gestion de la dynamique a dessiner
+  float frac = ((*mHisto)(i,j)-HMin())/(HMax()-HMin());
+  if(frac<0.) continue;
+  if(mTypScal==1) {              // echelle log10
+    frac = log10(1.+frac*(LogScale()-1.))/llscale;
+    if(frac<0.) continue;
+  }
+  if(frac<=fracmin) continue;
+  if(frac>1.) frac = 1.;
+  float fracred = frac * fracmax;
+
+  // Gestion de la couleur
+  int icol = 0;
+  if (cmap) {
+    icol = int( (float) ncol*frac );
+    if(icol>=ncol) icol = ncol-1; else if(icol<0) icol=0;
+    g->SelForeground(*cmap,icol);
+  }
+
+// Pour ne pas dessiner en dehors des axes 
+  if ( (left0+dx/2. < xmin) || (left0+dx/2. > xmax) || 
+         (bottom0+dy/2. < ymin) || (bottom0+dy/2. > ymax) ) continue;
+
+  // Dessin proprement dit selon le choix graphique.
+  if(mTypDisp==0) {
+    //..... carres de tailles variables
+    double left   = left0   + 0.5*(1.-fracred)*dx, width  = fracred*dx;
+    double bottom = bottom0 + 0.5*(1.-fracred)*dy, height = fracred*dy;
+    if (cmap) g->DrawFBox(left,bottom,width,height);
+    else      g->DrawBox(left,bottom,width,height);
+  } else if(mTypDisp==1) {
+    //..... nuage de points .....
+    int ipt  = int( (float) npt *frac );
+    for(int k=0;k<ipt;k++) {
+      double x = left0 + frand01()*dx;
+      double y = bottom0 + frand01()*dy;
+      g->DrawMarker(x,y);
+    }
+  } else if(mTypDisp==2) {
+    //..... type hbook2/hprint .+23-Z*
+    char c[2];
+    c[0] = HPrint2(frac); c[1]='\0';
+    double x = left0 + dx/2.;
+    double y = bottom0 + dy/2.;
+    g->DrawString(x,y,c);
+  } else if(mTypDisp==3) {
+    //..... carres de tailles fixes (avec gestion de continuite)
+    if (cmap) g->DrawFBox(left0,bottom0,dx+p1dx,dy+p1dy);
+    else      g->DrawBox(left0,bottom0,dx+p1dx,dy+p1dy);
+  }
+
+}
+
+// Remise dans les conditions ulterieures pour la suite du graphique.
+g->SelMarker(MkSz,Mk);
+g->SelForeground(coul);
+g->SelFontSzPt(FontSize,FontAtt);
+if (cmap) delete cmap;
+
+// Fin du dessin, ecriture de la statistique.
+DrawStats(g);
+}
+
+//++
+void PIHisto2D::DrawStats(PIGraphicUC* g)
+//
+//	Dessin des informations statistiques de l'histogramme.
+//--
+{
+  // Une boite dans le coin superieur droit
+  if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+  double cellHeight = (YMax() - YMin()) * 0.05;
+  double cellWidth  = (XMax() - XMin()) * 0.23;
+  g->DrawLine(XMax() - cellWidth, YMax(),
+                       XMax() - cellWidth, YMax() - cellHeight);
+  g->DrawLine(XMax() - cellWidth, YMax() - cellHeight,
+                       XMax()            , YMax() - cellHeight);
+  char label[50];
+  sprintf(label, "N = %.6g", mHisto->NData());
+  g->SelFontSz((YMax() - YMin())/30);
+  g->DrawString(XMax() - cellWidth*0.9, YMax() - cellHeight*0.8, label);
+  printf("H[%d,%d] Dynamique: [%g,%g] Frac [%g,%g]\n"
+        ,mHisto->NBinX(),mHisto->NBinY(),HMin(),HMax(),FMin(),FMax());
+}
+
+//++
+char PIHisto2D::HPrint2(float f)
+//
+//	Codage des valeurs en caracteres (fct privee).
+//| f entre [0,1] mappee entre valeur=[0,37]
+//| si <0 alors =0, si >1 alors 1
+//| Display 4   ==> 4<=valeur<5
+//|         C   ==> 12<=valeur<13
+//|             ==> valeur<=0
+//|         *   ==> valeur>=1
+//|         .   ==> 0<valeur<1
+//|------------------------------------------
+//|            C1111111111222222222233333333
+//|  C01234567890123456789012345678901234567
+//| " .+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*"
+//|------------------------------------------
+//--
+{
+char str[39] = " .+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*";
+int i;
+if(f<=0.) i = 0;
+else if(f>=1.) i = 37;
+else { i = (int) (f*36.); i++;}
+if(i<0) i=0; else if (i>=38) i = 37;
+return str[i];
+}
+
+//++
+int PIHisto2D::NPixBin(PIGraphicUC* g)
+//
+//	Nombre de pixels ecran dans un bin d'histogramme
+//	(fct privee).
+//--
+{
+double dx = mHisto->WBinX(),dy = mHisto->WBinY();
+double dxg,dyg;
+g->DUC2GrC(dx,dy,dxg,dyg);
+int np = (int) dxg * (int) dyg;
+//printf("PIHisto2D::NPixBin H dx=%g dy=%g, G dx=%g dy=%g, np = %d\n"
+//      ,dx,dy,dxg,dyg,np);
+return np;
+}
+
+
+/////////////////////////////////////////////////////////////////
+//  Classe PIH2DWdg
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Widget de dessin d'un histogramme 2D.
+//--
+
+static H2WinArg* h2dWinArg=NULL;
+static int nb_h2dWinArg = 0;
+
+//++
+PIH2DWdg::PIH2DWdg(PIContainerGen *par, char *nom, int sx, int sy, int px, int py)
+//
+//	Createur d'un Widget de dessin d'histogramme 2D.
+//	Le menu pour choisir les options d'affichage apparait
+//	suite au clic du bouton-3 de la souris (cf H2WinArg::H2WinArg).
+//--
+: PIScDrawWdg(par,nom,sx,sy,px,py)
+{
+if (!h2dWinArg) h2dWinArg = new H2WinArg(this);
+nb_h2dWinArg++;
+if(dbg) printf("PIH2DWdg::PIH2DWdg %lx h2dWinArg=%lx %d\n"
+              ,(long)this,(long)h2dWinArg,nb_h2dWinArg);
+mPih = NULL;
+// Pour afficher le menu option de trace
+ActivateButton(3);
+}
+
+//++
+PIH2DWdg::~PIH2DWdg()
+//
+//	Destructeur.
+//--
+{
+nb_h2dWinArg--;
+if (nb_h2dWinArg == 0) {
+  h2dWinArg->Hide();
+  delete h2dWinArg;
+  h2dWinArg=NULL;
+}
+if(dbg) printf("PIH2DWdg::~PIH2DWdg h2dWinArg=%lx %d\n"
+              ,(long)h2dWinArg,nb_h2dWinArg);
+if (mPih) delete mPih;
+}
+
+//++
+void PIH2DWdg::SetHisto(Histo2D* histo)
+//
+//	Pour connecter un histogramme 2D au Widget.
+//--
+{
+if (!histo) return;
+if (mPih)  delete mPih;
+mPih = new PIHisto2D(histo, true);
+AddScDrawer(mPih);
+if(dbg) printf("PIH2DWdg::SetHisto mPih=%lx\n",(long)mPih);
+}
+
+//++
+void PIH2DWdg::SetPIHisto(PIHisto2D* pih2)
+//
+//	Pour connecter un traceur (Drawer) d'histo 2D au Widget.
+//--
+{
+if (!pih2) return;
+if (mPih)  delete mPih;
+mPih = pih2;
+AddScDrawer(mPih);
+if(dbg) printf("PIH2DWdg::SetPIHisto mPih=%lx\n",(long)mPih);
+}
+
+//++
+string  PIH2DWdg::GetClickText(double x, double y)
+//
+//	Quand on click (and drag) le bouton-1, affichage
+//	des positions x,y et de la valeur du bin de l'histogramme 2D.
+//--
+{
+int i,j;
+char str[128];
+
+if ((!mPih) || (!mPih->Histogram())) {
+  sprintf(str,"X=%g Y=%g ???",x,y);
+  return((string)str);
+}
+
+Histo2D* h = mPih->Histogram();
+
+h->FindBin(x,y,i,j);
+if(i<0 || i>=h->NBinX() || j<0 || j>=h->NBinY())
+  sprintf(str,"x= %g y= %g ???",x,y);
+else sprintf(str,"x= %g y= %g v= %g",x,y,(*h)(i,j));
+
+return((string)str);
+}
+
+//++
+void PIH2DWdg::ActivateSpecializedControls()
+//	Pour activer les contrôles spécifiques pour l'affichage Histo-2D	
+//--
+{
+h2dWinArg->SetPIH2DWdg(this);
+h2dWinArg->SetMsgParent((PIMsgHandler*)this);
+if(!h2dWinArg->Visible()) h2dWinArg->Show();
+}
+
+//++
+void PIH2DWdg::But3Press(int x, int y)
+//
+//	Gestion de l'utilisation du bouton-3 de la souris.
+//	Un seul objet est cree pour tous les histogrammes 2D.
+//	Il est connecte a un histogramme donnee par l'action du
+//	du bouton-3 de la souris dans la fenetre contenant
+//	le dessin de l'histogramme (cf H2WinArg::H2WinArg).
+//--
+{
+ActivateSpecializedControls();
+if(dbg) printf("PIH2DWdg::But3Press(%d,%d) h2dWinArg=%lx\n"
+              ,x,y,(long)h2dWinArg);
+}
+
+
+/////////////////////////////////////////////////////////////////
+//  Classe H2WinArg
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Fenetre de dialogue pour le choix des options..
+//--
+
+//++
+H2WinArg::H2WinArg(PIH2DWdg *par)
+//
+//	Creation de la fenetre de gestion des parametres
+//	des dessins des histogrammes 2D. Cette fenetre de
+//	dialogue est partagee par tous les widget de dessin
+//	des histogrammes 2D. Pour la faire apparaitre pour la
+//	faire apparaitre la premiere fois, cliquez avec le bouton
+//	numero 3 de la souris (bouton de droite) dans la fenetre
+//	de dessin de l'histogramme. Si elle est deja presente,
+//	pour la connecter a une autre fenetre de dessin cliquez avec
+//	le meme bouton dans cette fenetre.
+//--
+//++
+//| - Menu 1: Choix du type de display
+//|     Carres variables, nuages de points, caracteres a la hbook2
+//|     et carres de tailles fixe (couleur ou niveauz de gris).
+//| - Menu 2: Choix du type d'echelle
+//|     Lineaire ou logarithmique
+//| - Menu 3: Choix de la couleur
+//|     noir et blanc, niveau de gris et couleurs diverses.
+//| - Champ texte Dyn: Pour donner la dynamique, si min>=max
+//|     alors prend le min et le max de l'histogramme
+//| - Champ texte Frac: fraction mini et maxi
+//|     (cf PIHisto2D::UseFrac)
+//| - Champ texte LogScal: niveau de scaling pour le choix d'une
+//|     echelle logarithmique (cf PIHisto2D::UseScale)
+//--
+//++
+//| - Curseur interactif PerPt: pourcentage de points a dessiner
+//|     dans chaque bin (cf PIHisto2D::UseDisplay)
+//| - Bouton Apply: dessiner avec les options affichees
+//| - Bouton Dismiss: fermeture de la fenetre de dialogue.
+//| - Bouton Get: re-prendre les valeurs de display stoquees
+//|     pour un histogramme donne.
+//| - Bouton Print: Imprimer les caracteristiques du display
+//|     et de l'histogramme.
+//--
+: PIWindow((PIMsgHandler *)par, "Options", PIWK_dialog,250,260,150,150)
+{
+string sdum;
+if(dbg) printf("H2WinArg::H2WinArg %lx par=%lx\n",(long)this,(long)par);
+
+mH2Wdg = NULL;
+
+// Valeurs par defaut
+mFgCol    = false;
+mCmap     = CMAP_GREYINV32;
+mTypScal  = 0;
+mTypDisp  = 0;
+mFPoints  = 0.5;
+mHMin     = 1.;
+mHMax     = -1.;
+mFracMin  = 0.1;
+mFracMax  = 0.9;
+mLogScale = 10.;
+
+// Taille automatique
+int bsx, bsy;
+PIApplicationPrefCompSize(bsx, bsy);  // environ 6 lettres
+int spx = (bsx>=10) ? bsx/10 : 1;  // intervalle entre lettres X
+int spy = (bsy>=5) ? bsy/5 : 1;    // intervalle entre lettres Y
+int wszx = 5*spx+bsx+int(2.5*bsx); // Taille fenetre en X
+int wszy = 11*spy+8.5*bsy;           // Taille fenetre en Y
+SetSize(wszx, wszy);
+
+// menus bar
+  int cpx = 2*spx, cpy = 2*spy;
+mOPop[0] = new PIOptMenu(this, "optmen-h2d-1" ,2*bsx,bsy,cpx,cpy);
+mOPop[0]->AppendItem("Carres Var."  , 6101);
+mOPop[0]->AppendItem("....."        , 6102);
+mOPop[0]->AppendItem(".+12..Z*"     , 6103);
+mOPop[0]->AppendItem("Carres Pleins", 6104);
+sdum = "Carres Var."; mOPop[0]->SetValueStr(sdum);
+mOPop[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+  cpy += bsy+spy;
+mOPop[1] = new PIOptMenu(this, "optmen-h2d-2",2*bsx,bsy,cpx,cpy);
+mOPop[1]->AppendItem("Lineaire", 6201);
+mOPop[1]->AppendItem("Log10"   , 6202);
+sdum = "Lineaire"; mOPop[1]->SetValueStr(sdum);
+mOPop[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+  cpy += bsy+spy;
+mOPop[2] = new PIOptMenu(this, "optmen-h2d-3",2*bsx,bsy,cpx,cpy);
+mOPop[2]->AppendItem("Black&White", 6301);
+mOPop[2]->AppendItem("Grey32"    , 6302);
+mOPop[2]->AppendItem("GreyInv32" , 6303);
+mOPop[2]->AppendItem("ColRJ32"   , 6304);
+mOPop[2]->AppendItem("ColBR32"   , 6305);
+mOPop[2]->AppendItem("ColRV32"   , 6306);
+mOPop[2]->AppendItem("Grey128"   , 6307);
+mOPop[2]->AppendItem("GreyInv128", 6308);
+mOPop[2]->AppendItem("ColRJ128"  , 6309);
+mOPop[2]->AppendItem("ColBR128"  , 6310);
+mOPop[2]->AppendItem("Col16"     , 6311);
+sdum = "Black&White"; mOPop[2]->SetValueStr(sdum);
+mOPop[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// Labels et zone de saisie texte
+  cpy += 2*(bsy+spy);
+mLab[0] = new PILabel(this, "     Dyn: ",bsx,bsy,cpx,cpy); 
+mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[0] = new PIText(this, "Dynamique" ,int(2.5*bsx),bsy,cpx+bsx+spx,cpy);
+mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mLab[1] = new PILabel(this, "    Frac: ",bsx,bsy,cpx,cpy);
+mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[1] = new PIText(this, "Fraction"  ,int(2.5*bsx),bsy,cpx+bsx+spx,cpy);
+mText[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mLab[2] = new PILabel(this, " LogScal: ",bsx,bsy,cpx,cpy);
+mLab[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[2] = new PIText(this, "LogScale"  ,int(2.5*bsx),bsy,cpx+bsx+spx,cpy);
+mText[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+SetText();
+
+// Labels et curseur mobile
+cpy += bsy+spy;
+mLab[3] = new PILabel(this, "   PerPt: ",bsx,bsy,cpx,cpy+0.25*bsy);
+mLab[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mPScal = new PIScale(this,"FracPoints",6401,kSDirLtoR
+                        ,int(2.5*bsx),1.25*bsy,cpx+bsx+spx,cpy);
+mPScal->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mPScal->SetMinMax(0,100);
+int imfp = mFPoints*100.f; mPScal->SetValue(imfp);
+
+// Boutons
+  cpx = 2*bsx+5*spx, cpy = 2*spy;
+mBut[0] = new PIButton(this, "Apply",  6001,bsx,bsy,cpx,cpy);
+mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mBut[1] = new PIButton(this, "Dismiss",6002,bsx,bsy,cpx,cpy);
+mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mBut[2] = new PIButton(this, "Get"  ,  6003,bsx,bsy,cpx,cpy);
+mBut[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mBut[3] = new PIButton(this, "Print",  6004,bsx,bsy,cpx,cpy);
+mBut[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+// FinishCreate();
+}
+
+//++
+H2WinArg::~H2WinArg()
+//
+//	Destructeur.
+//--
+{
+int i;
+if(dbg) printf("H2WinArg::~H2WinArg %lx\n",(long)this);
+for(i=0;i<3;i++) delete mOPop[i];
+for(i=0;i<4;i++) delete mBut[i];
+for(i=0;i<4;i++) delete mLab[i];
+for(i=0;i<3;i++) delete mText[i];
+delete mPScal;
+}
+
+//++
+void H2WinArg::SetText()
+//
+//	Gestion des fenetres de saisie de texte.
+//--
+{
+string sdum;
+char str[256];
+sprintf(str,"%g %g",mHMin,mHMax);
+mText[0]->SetText(str);
+sprintf(str,"%g %g",mFracMin,mFracMax);
+mText[1]->SetText(str);
+sprintf(str,"%g",mLogScale);
+mText[2]->SetText(str);
+
+if(mTypDisp==0)      { sdum="Carres Var.";   mOPop[0]->SetValueStr(sdum);}
+else if(mTypDisp==1) { sdum=".....";         mOPop[0]->SetValueStr(sdum);}
+else if(mTypDisp==2) { sdum=".+12..Z*";      mOPop[0]->SetValueStr(sdum);}
+else if(mTypDisp==3) { sdum="Carres Pleins"; mOPop[0]->SetValueStr(sdum);}
+
+if(mTypScal==0)      { sdum="Lineaire"; mOPop[1]->SetValueStr(sdum);}
+else if(mTypScal==1) { sdum="Log10";    mOPop[1]->SetValueStr(sdum);}
+
+if(!mFgCol)                       { sdum="Black&White";mOPop[2]->SetValueStr(sdum);}
+else {
+  if(mCmap==CMAP_GREY32)          { sdum="Grey32";     mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_GREYINV32)  { sdum="GreyInv32";  mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLRJ32)    { sdum="ColRJ32";    mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLBR32)    { sdum="ColBR32";    mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLRV32)    { sdum="ColRV32";    mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_GREY128)    { sdum="Grey128";    mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_GREYINV128) { sdum="GreyInv128"; mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLRJ128)   { sdum="ColRJ128";   mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLBR128)   { sdum="ColBR128";   mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COL16)      { sdum="Col16";      mOPop[2]->SetValueStr(sdum);}
+}
+
+if(dbg)printf("H2WinArg::SetText\n");
+}
+
+//++
+void H2WinArg::GetText()
+//
+//	Gestion des fenetres de saisie de texte.
+//--
+{
+sscanf(mText[0]->GetText().c_str(),"%g %g",&mHMin,&mHMax);
+sscanf(mText[1]->GetText().c_str(),"%g %g",&mFracMin,&mFracMax);
+sscanf(mText[2]->GetText().c_str(),"%g",&mLogScale);
+if(dbg) printf("H2WinArg::GetText\n");
+}
+
+//++
+void H2WinArg::SetPIH2DWdg(PIH2DWdg* h2wdg)
+//
+//	Connexion du widget de representation d'un histogramme 2D
+//	avec la fenetre de gestion des parametres.
+//--
+{
+mH2Wdg = h2wdg;
+if(dbg) printf("H2WinArg::SetPIH2DWdg mH2Wdg = %lx\n",(long)mH2Wdg);
+}
+
+//++
+void H2WinArg::Process(PIMessage msg, PIMsgHandler* sender, void*)
+//
+//	Gestions des messages.
+//--
+{
+if(dbg) printf("PIH2DWdg::Process(%d-%d , %lx ...) \n"
+              ,(int)UserMsg(msg),(int)ModMsg(msg), (long)sender);
+
+if(!mH2Wdg) return;
+PIHisto2D* mpih = mH2Wdg->GetPIHisto();
+if(!mpih) return;
+
+int opt = UserMsg(msg);
+     if (opt == 6101) { mTypDisp = 0; }
+else if (opt == 6102) { mTypDisp = 1; }
+else if (opt == 6103) { mTypDisp = 2; }
+else if (opt == 6104) { mTypDisp = 3; }
+
+else if (opt == 6201) { mTypScal = 0; }
+else if (opt == 6202) { mTypScal = 1; }
+
+else if (opt == 6301) { mFgCol = false; }
+else if (opt == 6302) { mFgCol = true;  mCmap = CMAP_GREY32; }
+else if (opt == 6303) { mFgCol = true;  mCmap = CMAP_GREYINV32; }
+else if (opt == 6304) { mFgCol = true;  mCmap = CMAP_COLRJ32; }
+else if (opt == 6305) { mFgCol = true;  mCmap = CMAP_COLBR32; }
+else if (opt == 6306) { mFgCol = true;  mCmap = CMAP_COLRV32; }
+else if (opt == 6307) { mFgCol = true;  mCmap = CMAP_GREY128; }
+else if (opt == 6308) { mFgCol = true;  mCmap = CMAP_GREYINV128; }
+else if (opt == 6309) { mFgCol = true;  mCmap = CMAP_COLRJ128; }
+else if (opt == 6310) { mFgCol = true;  mCmap = CMAP_COLBR128; }
+else if (opt == 6311) { mFgCol = true;  mCmap = CMAP_COL16; }
+
+else if (opt == 6401) mFPoints = mPScal->GetValue()/100.;
+
+else if (opt==6001) {
+  GetText();
+  mpih->UseColors(mFgCol, mCmap);
+  mpih->UseScale(mTypScal,mLogScale);
+  mpih->UseDisplay(mTypDisp,mFPoints);
+  mpih->UseDyn(mHMin,mHMax);
+  mpih->UseFrac(mFracMin,mFracMax);
+  mH2Wdg->Refresh();  // On rafraichit le dessin (tout le PIScDrawWdg)
+}
+else if (opt==6002) {
+  this->Hide();
+}
+else if (opt==6003) {
+  mFgCol    = mpih->Color();
+  mCmap     = mpih->ColMap();
+  mTypScal  = mpih->TypScale();
+  mTypDisp  = mpih->TypDisplay();
+  mFPoints  = mpih->FPoints();
+  mHMin     = mpih->HMin();
+  mHMax     = mpih->HMax();
+  mFracMin  = mpih->FMin();
+  mFracMax  = mpih->FMax();
+  mLogScale = mpih->LogScale();
+  SetText();
+}
+else if (opt==6004) {
+  mpih->Print(2);
+}
+
+if(dbg) {
+  printf("H2WinArg::Process opt=%d col=%d,%d scal=%d disp=%d npt=%g\n"
+        ,opt,(int) mFgCol,(int) mCmap,mTypScal,mTypDisp,mFPoints);
+  printf("                  min,max= %g,%g frac= %g,%g logsc= %g\n"
+        ,mHMin,mHMax,mFracMin,mFracMax,mLogScale);
+}
+
+}
Index: /tags/DPC_V0/Poubelle/PIext/pihisto2d.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pihisto2d.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pihisto2d.h	(revision 1307)
@@ -0,0 +1,109 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PIext :   PIHisto2D PIH2DWdg 
+// Traceur Histo-2D    C. Magneville 97-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIHISTO2D_H
+#define PIHISTO2D_H
+
+#include "pisysdep.h"
+#include PIMENU_H 
+#include PIMENUBAR_H 
+#include PIOPTMENU_H
+
+#include "histos2.h"
+#include "piscdrawwdg.h"
+
+////////////////////////////////////////////////////////////////////
+class PIHisto2D : public PIDrawer {
+public:
+                     PIHisto2D(Histo2D* histo, bool ad=false);
+  virtual            ~PIHisto2D();
+          void       UseColors(bool fg=false, CMapId cmap=CMAP_GREYINV32);
+          void       UseScale(unsigned short type=0,float logscale=10.);
+          void       UseDisplay(unsigned short type=0, float fnpt=0.5);
+          void       UseDyn(float hmin=1., float hmax=-1.);
+          void       UseFrac(float frmin=0.1, float frmax=0.9);
+          void       Print(int lp=0);
+  virtual void       Draw(PIGraphicUC* g,double xmin,double ymin,double xmax,double ymax);
+  virtual void       UpdateLimits();
+  virtual void       DrawStats(PIGraphicUC* g);
+
+  inline Histo2D*       Histogram() { return(mHisto); }
+  inline bool           Color() { return(mFgCol); }
+  inline CMapId         ColMap() { return(mCmap); }
+  inline unsigned short TypScale() { return(mTypScal); }
+  inline unsigned short TypDisplay() { return(mTypDisp); }
+  inline float          FPoints() { return(mFPoints); }
+  inline float          HMax() { return(mHMax);}
+  inline float          HMin() { return(mHMin);}
+  inline float          FMax() { return(mFracMax);}
+  inline float          FMin() { return(mFracMin);}
+  inline float          LogScale() { return(mLogScale);}
+
+protected:
+  int NPixBin(PIGraphicUC* g);
+  char HPrint2(float f);
+
+  Histo2D* mHisto;
+  bool mAdDO;
+  bool mFgCol;
+  CMapId mCmap;
+  unsigned short mTypScal;
+  unsigned short mTypDisp;
+  float mFPoints;
+  float mHMin,mHMax;
+  float mFracMin,mFracMax;
+  float mLogScale;
+};
+
+////////////////////////////////////////////////////////////////////
+class PIH2DWdg : public PIScDrawWdg {
+public:
+                     PIH2DWdg(PIContainerGen *par, char *nom, int sx=300, int sy=300, 
+                              int px=0, int py=0);
+                     ~PIH2DWdg();
+
+  void               SetHisto(Histo2D* histo);
+  void               SetPIHisto(PIHisto2D* pih2);
+  inline PIHisto2D*  GetPIHisto() {return mPih;}
+
+  virtual string     GetClickText(double x, double y); 
+  virtual void	     ActivateSpecializedControls();   // Pour activer des controles specifiques
+  virtual void       But3Press(int x, int y);
+
+protected:
+  PIHisto2D*  mPih;
+
+};
+
+////////////////////////////////////////////////////////////////////
+class H2WinArg : public PIWindow {
+public :
+               H2WinArg(PIH2DWdg *par);
+               ~H2WinArg();
+          void SetPIH2DWdg(PIH2DWdg* h2wdg);
+          void SetText();
+          void GetText();
+  virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+protected:
+  PIH2DWdg  * mH2Wdg;
+
+  PIOptMenu * mOPop[3];
+  PIButton  * mBut[4];
+  PILabel   * mLab[4];
+  PIText    * mText[3];
+  PIScale   * mPScal;
+
+  bool mFgCol;
+  CMapId mCmap;
+  unsigned short mTypScal;
+  unsigned short mTypDisp;
+  float mFPoints;
+  float mHMin,mHMax;
+  float mFracMin,mFracMax;
+  float mLogScale;
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/piinit.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/piinit.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/piinit.cc	(revision 1307)
@@ -0,0 +1,25 @@
+#include "defs.h"
+#include "piinit.h"
+
+
+int PeidaInteractiveInitiator::FgInit = 0;
+
+PeidaInteractiveInitiator::PeidaInteractiveInitiator()
+ : PeidaOutilsInitiator()
+{
+  FgInit++;
+  if (FgInit > 1)  return;
+  
+} 
+
+PeidaInteractiveInitiator::~PeidaInteractiveInitiator()
+{
+  FgInit--;
+/*  if (FgInit == 0)
+    {
+    }  */
+}
+
+// On met un objet initiator en statique, pour les loaders qui savent 
+// appeler le constructeur des objets statiques   Reza 08/98
+static PeidaInteractiveInitiator  pinteractivexxinit;
Index: /tags/DPC_V0/Poubelle/PIext/piinit.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/piinit.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/piinit.h	(revision 1307)
@@ -0,0 +1,19 @@
+#ifndef PIINIT_H_SEEN
+#define PIINIT_H_SEEN
+
+#include "outilsinit.h"
+
+// Classe d'initialisation pour le module PI de PEIDA
+
+class PeidaInteractiveInitiator : public PeidaOutilsInitiator {
+private:
+  static int FgInit;
+public:
+  		PeidaInteractiveInitiator();
+ virtual	~PeidaInteractiveInitiator();
+};
+
+#undef PeidaInit
+#define PeidaInit() PeidaInteractiveInitiator peidainitiator
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/pimgadapter.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pimgadapter.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pimgadapter.h	(revision 1307)
@@ -0,0 +1,36 @@
+#ifndef PIMGADAPTER_SEEN
+#define PIMGADAPTER_SEEN
+
+#include "cimage.h"
+#include "parradapter.h"
+
+class RzImageAdapter : public P2DArrayAdapter {
+public:
+                  RzImageAdapter(RzImage* rzi, bool ad=false) :
+                    P2DArrayAdapter(rzi->XSize(), rzi->YSize())
+                    { aDel = ad; mImg = rzi; }
+
+  virtual 	  ~RzImageAdapter() { if (aDel) delete mImg; }
+  virtual double  Value(int ix, int iy) { return mImg->FValue(ix, iy); }
+
+protected :
+  bool aDel;
+  RzImage* mImg;
+};
+
+template <class T> 
+class ImageAdapter : public P2DArrayAdapter {
+public:
+                  ImageAdapter(Image<T>* img, bool ad=false) :
+                    P2DArrayAdapter(img->XSize(), img->YSize())
+                    { aDel = ad; mImg = img; }
+
+  virtual 	  ~ImageAdapter() { if (aDel) delete mImg; }
+  virtual double  Value(int ix, int iy) { return((*mImg)(ix, iy)); }
+
+protected :
+  bool aDel;
+  Image<T>* mImg;
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/pintup3d.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pintup3d.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pintup3d.cc	(revision 1307)
@@ -0,0 +1,128 @@
+#include <stdio.h>
+#include "pintup3d.h"
+
+ 
+/* --Methode-- */
+PINTuple3D::PINTuple3D(NTuple* nt, bool ad)
+: PIDrawer3D()
+{
+  mNT = nt;
+  mAdDO = ad; 
+  SelectXYZ(NULL, NULL, NULL);
+  SelectErrBar();
+}
+
+PINTuple3D::~PINTuple3D()
+{
+  if (mAdDO && mNT)  delete mNT;
+}
+
+/* --Methode-- */
+void  PINTuple3D::SelectXYZ(const char* px, const char* py, const char* pz)
+{
+if (mNT == NULL)  xK = yK = zK = -1;
+if (px == NULL) xK = -1;
+else xK = mNT->IndexNom(px);
+if (py == NULL) yK = -1;
+else yK = mNT->IndexNom(py);
+if (pz == NULL) zK = -1;
+else zK = mNT->IndexNom(pz);
+}
+
+/* --Methode-- */
+void  PINTuple3D::SelectErrBar(const char* erbx, const char* erby, const char* erbz)
+{
+if (mNT == NULL)  xebK = yebK = zebK = -1;
+if (erbx == NULL) xebK = -1;
+else xebK = mNT->IndexNom(erbx);
+if (erby == NULL) yebK = -1;
+else yebK = mNT->IndexNom(erby);
+if (erbz == NULL) zebK = -1;
+else zebK = mNT->IndexNom(erbz);
+}
+
+
+/* --Methode-- */
+void PINTuple3D::UpdateLimits()
+{
+  if (!mNT) return;
+  if (mNT->NEntry() <= 0)  return;
+  if ( (xK < 0) || (yK < 0)  || (zK < 0) )   return;
+
+  // Commencer par trouver nos limites
+  float xmin, xmax, ymin, ymax, zmin, zmax;
+  xmin = ymin = 9.e19;
+  xmax = ymax = -9.e19;
+  zmax = zmax = -9.e19;
+  mNT->GetMinMax(xK, xmin, xmax);
+  mNT->GetMinMax(yK, ymin, ymax);
+  mNT->GetMinMax(zK, zmin, zmax);
+
+// Centre du champ en C = (xmin+xmax)/2., (ymin+ymax)/2  (zmin+zmax)*0.5
+// Distance D = Max(xmax-xmin,ymin-ymax)*2
+// Observateur en O = X+D, Yc+2*D 
+  double D = xmax-xmin;
+  if (D < (ymax-ymin))  D = ymax-ymin;
+  D *= 1.4;
+  
+  Set3DView((xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)/2., 
+            (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25);  
+
+  x3Min = xmin;  // - 0.05*(xmax-xmin);
+  x3Max = xmax;  // + 0.05*(xmax-xmin);
+  y3Min = ymin;  // - 0.05*(ymax-ymin);
+  y3Max = ymax;  // + 0.05*(ymax-ymin);
+  z3Min = zmin;  // - 0.05*(zmax-zmin);
+  z3Max = zmax;  // + 0.05*(zmax-zmin);
+
+//  printf("PINTuple3D::UpdateLimits() : %g-%g  %g-%g  %g-%g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
+//  printf("PINTuple3D::UpdateLimits() :  %g %g %g << %g %g %g \n", 
+//         (xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)*0.5, 
+//         (xmin+xmax)/2.+D , (ymin+ymax)/2.+2.*D , zmin+(zmax-zmin)*0.1);
+}
+
+
+/* --Methode-- */
+void PINTuple3D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+double xp,yp,zp,xer,yer,zer;
+int nok;
+
+// On trace les axes - En attendant de faire mieux - Reza 8/12/98
+if (axesFlags != kAxesNone)  DrawAxes(g);
+
+if (!mNT) return;
+if ( (xK < 0) || (yK < 0) || (zK < 0) )  return;
+
+#if defined(__DECCXX) || defined(__KCC__)
+PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+
+if (mLAtt == PI_NotDefLineAtt)  g3->SelLine(PI_ThinLine);
+
+nok = 0;  
+for (int i=0; i<mNT->NEntry(); i++) {
+  xp = mNT->GetVal(i, xK);
+  yp = mNT->GetVal(i, yK);
+  zp = mNT->GetVal(i, zK);
+  nok++;
+  g3->DrawMarker3D(xp, yp, zp); 
+  if ( xebK >= 0 ) {
+    xer = mNT->GetVal(i, xebK);
+    g3->DrawLine3D(xp-xer, yp, zp, xp+xer, yp, zp);
+  }
+  if ( yebK >= 0 ) {
+    yer = mNT->GetVal(i, yebK);
+    g3->DrawLine3D(xp, yp-yer, zp, xp, yp+yer, zp);
+  }
+  if ( zebK >= 0 ) {
+    zer = mNT->GetVal(i, zebK);
+    g3->DrawLine3D(xp, yp, zp-zer, xp, yp, zp+zer);
+  }
+}
+
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PIext/pintup3d.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pintup3d.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pintup3d.h	(revision 1307)
@@ -0,0 +1,31 @@
+#ifndef PINTUPLE3D_H
+#define PINTUPLE3D_H
+
+#include "ntuple.h"
+#include "pi3ddrw.h"
+
+class PINTuple3D : public PIDrawer3D {
+public:
+                     PINTuple3D(NTuple* nt, bool ad=false);
+  virtual           ~PINTuple3D();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+          void       SelectXYZ(const char* px, const char* py, const char* pz);
+          void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL, const char* erbz=NULL);
+
+       
+protected:
+  NTuple* mNT;
+  bool mAdDO;
+  int xK, yK, zK;           // Index du nom de variable en X/Y/Z ds le ntuple
+  int xebK, yebK, zebK;     // Index du nom de variable en ErrBarX/Y/Z ds le ntuple
+
+};
+
+#endif
+
+
+
+
Index: /tags/DPC_V0/Poubelle/PIext/pintuple.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pintuple.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pintuple.cc	(revision 1307)
@@ -0,0 +1,96 @@
+#include <stdio.h>
+#include "pintuple.h"
+
+ 
+/* --Methode-- */
+PINTuple::PINTuple(NTuple* nt, bool ad)
+: PIDrawer()
+{
+  mNT = nt;
+  mAdDO = ad; 
+  SelectXY(NULL, NULL);
+  SelectErrBar();
+}
+
+PINTuple::~PINTuple()
+{
+  if (mAdDO && mNT)  delete mNT;
+}
+
+/* --Methode-- */
+void  PINTuple::SelectXY(const char* px, const char* py)
+{
+if (mNT == NULL)  xK = yK = -1;
+if (px == NULL) xK = -1;
+else xK = mNT->IndexNom(px);
+if (py == NULL) yK = -1;
+else yK = mNT->IndexNom(py);
+}
+
+/* --Methode-- */
+void  PINTuple::SelectErrBar(const char* erbx, const char* erby)
+{
+if (mNT == NULL)  xebK = yebK = -1;
+if (erbx == NULL) xebK = -1;
+else xebK = mNT->IndexNom(erbx);
+if (erby == NULL) yebK = -1;
+else yebK = mNT->IndexNom(erby);
+}
+
+
+/* --Methode-- */
+void PINTuple::UpdateLimits()
+{
+  if (!mNT) return;
+  if (mNT->NEntry() <= 0)  return;
+  if ( (xK < 0) || (yK < 0) )   return;
+
+  // Commencer par trouver nos limites
+  float dx, dy;
+  float xmin, xmax, ymin, ymax;
+  xmin = ymin = 9.e19;
+  xmax = ymax = -9.e19;
+  mNT->GetMinMax(xK, xmin, xmax);
+  mNT->GetMinMax(yK, ymin, ymax);
+    
+  dx = 0.02*(xmax-xmin);
+  dy = 0.02*(ymax-ymin);
+  
+  SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy);
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+
+/* --Methode-- */
+void PINTuple::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+double xp,yp,xer,yer;
+int nok;
+
+if (!mNT) return;
+if ( (xK < 0) || (yK < 0) )  return;
+if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+nok = 0;  
+for (int i=0; i<mNT->NEntry(); i++) {
+  xp = mNT->GetVal(i, xK);
+  yp = mNT->GetVal(i, yK);
+  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+  nok++;
+  if ( xebK >= 0 ) {
+    xer = mNT->GetVal(i, xebK);
+    if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
+  }
+  if ( yebK >= 0 ) {
+    yer = mNT->GetVal(i, yebK);
+    if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
+  }
+  g->DrawMarker(xp, yp); 
+}
+
+/*
+sprintf(buff, "NTuple:  NEntry= %d  NDisp= %d", (int)mNT->NEntry(), nok);
+g->BaseGraphic()->DrawString(15,15,buff);
+*/
+return;
+}
+
Index: /tags/DPC_V0/Poubelle/PIext/pintuple.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pintuple.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pintuple.h	(revision 1307)
@@ -0,0 +1,31 @@
+#ifndef PINTUPLE_H
+#define PINTUPLE_H
+
+#include "ntuple.h"
+#include "pidrawer.h"
+
+class PINTuple : public PIDrawer {
+public:
+                     PINTuple(NTuple* nt, bool ad);
+  virtual           ~PINTuple();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+          void       SelectXY(const char* px, const char* py);
+          void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL);
+
+       
+protected:
+  NTuple* mNT;
+  bool mAdDO;
+  int xK, yK;          // Index du nom de variable en X/Y ds le ntuple
+  int xebK, yebK;      // Index du nom de variable en ErrBarX/Y ds le ntuple
+
+};
+
+#endif
+
+
+
+
Index: /tags/DPC_V0/Poubelle/PIext/pipodrw.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pipodrw.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pipodrw.cc	(revision 1307)
@@ -0,0 +1,128 @@
+//  Adaptateurs et Drawers divers pour Outils PEIDA++
+//                             R. Ansari  06-08/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pipodrw.h"
+#include "generalfit.h"
+
+
+//================================================================
+// PIGFFDrawer
+//================================================================
+
+PIGFFDrawer::PIGFFDrawer(GeneralFunction* f)
+: mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms])
+{
+  ASSERT(f->NVar() == 1);
+}
+
+PIGFFDrawer::~PIGFFDrawer()
+{
+  delete[] mParms;
+}
+
+void
+PIGFFDrawer::SetParms(double const* p)
+{
+  for (int i=0; i<mNParms; i++)
+    mParms[i] = p[i];
+}
+
+
+void
+PIGFFDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/)
+{
+  PIGrCoord x1, x2, y1, y2;
+  g->GetGrSpace(x1, x2, y1, y2);
+  double xMax = x2;
+  double xMin = x1;
+  double yMax = y2;
+  double yMin = y1;
+  double xStep = (xMax - xMin)/100;
+  double xOld = xMin;
+  double yOld = 0;
+//  double yOld = f->Value(&xMin, mParms);
+  for (double x = xMin+xStep; x<xMax; x+=xStep) {
+   double y = 0; // $CHECK$
+//    double y = f->Value(&x, mParms);
+    if (y>yMin && yOld>yMin && 
+        y<yMax && yOld<yMax) 
+           g->DrawLine(xOld, yOld, x, y);
+    xOld = x;
+    yOld = y;
+  }
+}
+
+// ----------------------------------------------------------
+// Adaptateur de vecteurs Peida++ a P1DArrayAdapter
+// ----------------------------------------------------------
+
+/* --Methode-- */
+POVectorAdapter::POVectorAdapter(Vector* v, bool ad)
+        : P1DArrayAdapter(v->NElts())
+{
+aDel = ad; mVec = v;
+}
+
+/* --Methode-- */
+POVectorAdapter::~POVectorAdapter()
+{
+if (aDel) delete mVec;
+}
+
+/* --Methode-- */
+double POVectorAdapter::Value(int i)
+{ 
+return((*mVec)(i)); 
+}
+
+// ----------------------------------------------------------
+// Adaptateur d'Histo-2D Peida++ a P2DArrayAdapter
+// ----------------------------------------------------------
+
+/* --Methode-- */
+POH2DAdapter::POH2DAdapter(Histo2D* h2d, bool ad)
+        : P2DArrayAdapter(h2d->NBinX(), h2d->NBinY())
+{
+aDel = ad; mH2d = h2d;
+DefineXYCoordinates(h2d->XMin(), h2d->YMin(), h2d->WBinX(), h2d->WBinY() );
+}
+
+/* --Methode-- */
+POH2DAdapter::~POH2DAdapter()
+{
+if (aDel)  delete mH2d;
+}
+
+/* --Methode-- */
+double POH2DAdapter::Value(int ix, int iy)
+{
+return((*mH2d)(ix, iy));
+}
+
+// ----------------------------------------------------------
+// Adaptateur de matrice Peida++ a P2DArrayAdapter
+// Attention  Y: Lignes (rows)  X: Colonnes
+// ----------------------------------------------------------
+
+/* --Methode-- */
+POMatrixAdapter::POMatrixAdapter(Matrix* mtx, bool ad)
+        : P2DArrayAdapter(mtx->NCol(), mtx->NRows())
+{
+aDel = ad; mMtx = mtx;
+}
+
+/* --Methode-- */
+POMatrixAdapter::~POMatrixAdapter()
+{
+if (aDel)  delete mMtx;
+}
+
+/* --Methode-- */
+double POMatrixAdapter::Value(int ix, int iy)
+{
+// Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col)  
+return((*mMtx)(iy, ix));
+}
+
+
Index: /tags/DPC_V0/Poubelle/PIext/pipodrw.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pipodrw.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pipodrw.h	(revision 1307)
@@ -0,0 +1,71 @@
+// This may look like C code, but it is really -*- C++ -*-
+//  Adaptateurs et Drawers divers pour Outils PEIDA++
+//                             R. Ansari  06-08/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIPODRW_H_SEEN
+#define PIPODRW_H_SEEN
+
+#include "pidrawer.h"
+#include "parradapter.h"
+#include "cvector.h"
+#include "matrix.h"
+#include "histos2.h"
+
+
+class GeneralFunction;
+class PIGFFDrawer : public PIDrawer {
+public:
+                     PIGFFDrawer(GeneralFunction*);
+  virtual           ~PIGFFDrawer();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       SetParms(double const*);
+protected:
+  GeneralFunction*    mFunc;
+  int                 mNParms;
+  double*             mParms;
+};
+
+
+// Adaptateur de vecteurs Peida++ a P1DArrayAdapter
+class POVectorAdapter : public P1DArrayAdapter {
+public :
+                  POVectorAdapter(Vector* v, bool ad=false);
+  virtual         ~POVectorAdapter();
+  virtual double  Value(int i);
+
+protected:
+  bool aDel;
+  Vector* mVec;
+};
+
+// Adaptateur d'Histo-2D Peida++ a P2DArrayAdapter
+class POH2DAdapter :  public P2DArrayAdapter {
+public :
+                  POH2DAdapter(Histo2D* h2d, bool ad=false);
+  virtual         ~POH2DAdapter();
+
+  virtual double  Value(int ix, int iy);   
+
+protected:
+  bool aDel;
+  Histo2D* mH2d;
+};
+
+// Adaptateur de matrice Peida++ a P2DArrayAdapter
+// Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col)  
+class POMatrixAdapter :  public P2DArrayAdapter {
+public :
+                  POMatrixAdapter(Matrix* mtx, bool ad=false);
+  virtual         ~POMatrixAdapter();
+
+  virtual double  Value(int ix, int iy);   
+
+protected:
+  bool aDel;
+  Matrix* mMtx;
+};
+
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/pisiadw.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pisiadw.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pisiadw.cc	(revision 1307)
@@ -0,0 +1,265 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "machine.h"
+
+#include "perrors.h"
+#include "ctimer.h"
+
+#include "nbmath.h"
+
+#include "pistdimgapp.h"
+#include "nobjmgr.h"
+#include "servnobjm.h"
+
+
+
+/* ........................................................... */
+/*  Classe ObjMgrWind  interface de gestion d'objets nommes    */
+/* ........................................................... */
+
+/* --Methode-- */
+ObjMgrWind::ObjMgrWind(PIStdImgApp *par)
+: PIWindow((PIMsgHandler *)par, "objmgr", PIWK_dialog, 
+           400, 300, 250, 250)
+{
+int i;
+dap = par;
+
+int bsx, bsy;
+int tsx, tsy;
+int spx, spy;
+// On definit la taille a partir de la taille par defaut des composantes 
+PIApplicationPrefCompSize(bsx, bsy);
+spx = bsx/4;   spy = bsy/3;
+tsx = 5*bsx+6*spx;  tsy = 7*bsy+4*spy;
+SetSize(tsx,tsy);
+objlist = new PIList(this, "objlist", tsx-spx, tsy-4*spy-bsy, spx/2, spy/2);
+objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+objlist->SetBorderWidth(2);
+
+int py = tsy-2*spy-bsy;
+int px = spx;
+mBut[0] = new PIButton(this, "Display", 100, bsx, bsy, px, py);   px += (bsx+spx);
+mBut[1] = new PIButton(this, "Print",   200, bsx, bsy, px, py);   px += (bsx+spx);
+mBut[2] = new PIButton(this, "SavePPF", 300, bsx, bsy, px, py);   px += (bsx+spx);
+mBut[3] = new PIButton(this, "Delete",  400, bsx, bsy, px, py);   px += (bsx+spx);
+mBut[4] = new PIButton(this, "Dismiss", 900, bsx, bsy, px, py);   px += (bsx+spx);
+
+for(i=0; i<5; i++)
+  mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// FinishCreate(); pas necessaire ?
+}
+
+/* --Methode-- */
+ObjMgrWind::~ObjMgrWind()
+{
+int i;
+delete objlist;
+for(i=0; i<5; i++)  delete mBut[i];
+}
+
+/* --Methode-- */
+void ObjMgrWind::Show()
+{
+dap->SetBlocked();
+PIWindow::Show();
+return;
+}
+
+/* --Methode-- */
+void ObjMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+  // PIMessage ssg = ModMsg(msg);
+msg = UserMsg(msg);
+if (msg == 900)  {
+  dap->SetReady();
+  this->Hide();
+  return;
+}
+
+string nom = "";
+if ( (msg == 100) || (msg == 200) || (msg == 300) || (msg == 400) ) {
+  string sel = objlist->GetSelectionStr();
+  //  size_t p = sel.find_first_not_of(" \t");
+  //  if (p<0) p = 0;
+  size_t l = sel.length(); 
+  size_t q = sel.find_first_of(" \t");
+  if (q > l)   q = l; 
+  nom = sel.substr(0, q);
+}
+
+NamedObjMgr* om = dap->ObjMgr();
+if (om == NULL)  return;
+if (nom == "")  return;
+
+switch (msg)
+  {
+  case 100:
+    om->DisplayObj(nom);
+    break;
+  case 200:
+    om->PrintObj(nom);
+    break;
+  case 300:
+    if (dap->mPpfout)  om->SaveObj(nom, *(dap->mPpfout));
+    break;
+  case 400:
+    om->DelObj(nom);
+    break;
+
+  case 900:
+    dap->SetReady();
+    Hide();
+    break;
+
+  default:    
+    //    printf("DEBUG/ObjMgrW::Process %d %d \n", (int)msg, (int)ssg); 
+    break;
+  }
+    
+return;
+}
+
+
+/* ........................................................... */
+/*  Classe PPInMgrWind  interface de gestion d'objets nommes    */
+/* ........................................................... */
+
+/* --Methode-- */
+PPInMgrWind::PPInMgrWind(PIStdImgApp *par)
+: PIWindow((PIMsgHandler *)par, "PPF-FileManager", PIWK_dialog, 
+           400, 300, 250, 250)
+{
+int i;
+dap = par;
+
+int bsx, bsy;
+int tsx, tsy;
+int spx, spy;
+// On definit la taille a partir de la taille par defaut des composantes 
+PIApplicationPrefCompSize(bsx, bsy);
+spx = bsx/4;   spy = bsy/3;
+bsx *= 1.25;
+ttx = tsx = 3*bsx+8*spx;   tty = tsy = 7*bsy+5*spy;
+SetSize(tsx,tsy);
+
+mLab[0] = new PILabel(this, "filename", tsx-spx, bsy-spy, spx/2, spy/2);
+mLab[0]->SetLabel("");
+mLab[0]->SetBinding(PIBK_elastic,PIBK_fixed, PIBK_elastic,PIBK_fixed);
+mLab[0]->SetBorderWidth(1);
+
+polx = spx/2;  poly = bsy+1.5*spy;
+tolx = tsx-spx;   toly = tsy-2*bsy-5*spy;
+int py = tsy-2*spy-bsy;
+int px = 2*spx;
+mBut[0] = new PIButton(this, "Read", 2500, bsx, bsy, px, py);   px += (bsx+2*spx);
+mBut[1] = new PIButton(this, "ReadAll", 2600, bsx, bsy, px, py);   px += (bsx+2*spx);
+mBut[2] = new PIButton(this, "Close", 2700, bsx, bsy, px, py);   px += (bsx+2*spx);
+
+for(i=0; i<3; i++)
+  mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  
+objlist = NULL;
+mLab[1] = NULL;
+mPin = NULL;
+
+//   FinishCreate(); pas necessaire 
+}
+
+/* --Methode-- */
+PPInMgrWind::~PPInMgrWind()
+{
+int i;
+if (objlist) delete objlist;
+delete mLab[0];
+for(i=0; i<3; i++)  delete mBut[i];
+}
+
+/* --Methode-- */
+void PPInMgrWind::SetFile(string flnm)
+{
+char strg[128];
+char* nom;
+char  noms[32];
+int i, cid, key, ln;
+
+bool ok = true;
+
+TRY {
+  mPin = new PInPersist(flnm);
+}  CATCH(merr) 
+  { printf("ObjMgrWind::SetFile Exception= %ld (%s) \n", (long)merr, PeidaExc(merr)); 
+  ok = false; } ENDTRY;
+
+if (!ok) { mPin = NULL;  dap->SetReady(); return; }
+
+if (mPin->NbTags() < 1) {
+  delete mPin;   mPin = NULL;
+  dap->ObjMgr()->ReadObj(flnm);
+  return;
+}
+
+if (objlist)  delete objlist;
+SetSize(ttx,tty);
+mLab[0]->SetLabel(flnm);
+objlist = new PIList(this, "infileobjlist", tolx, toly, polx, poly);
+objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+objlist->SetBorderWidth(2);
+
+
+for(i=0; i<mPin->NbTags(); i++) {
+  key = mPin->TagKey(i, cid, ln); 
+  if (ln <= 0)  nom = "?";
+  else { strncpy(noms, mPin->TagName(i).c_str(), 31);  noms[31] = '\0'; nom = noms; }
+  sprintf(strg, "%s  (T=%s, Key=%d)",  nom, dap->ObjMgr()->GetServiceObj()->PClassIdToClassName(cid), key);
+  objlist->AppendItem(strg, 5000+i);
+}
+
+}
+
+/* --Methode-- */
+void PPInMgrWind::Show()
+{
+if (mPin == NULL)   return;
+dap->SetBlocked();
+PIWindow::Show();
+return;
+}
+
+/* --Methode-- */
+void PPInMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+int sel;
+msg = UserMsg(msg);
+
+if (msg == 2700)  {
+  delete mPin;  mPin = NULL;
+  delete objlist; objlist = NULL;
+  dap->SetReady();
+  this->Hide();
+  return;
+}
+
+NamedObjMgr* om = dap->ObjMgr();
+switch (msg)
+  {
+  case 2500:
+    sel = (PIMessage)objlist->GetSelection() - 5000;
+    if (sel >= 0) om->ReadObj((*mPin), sel);
+    break;
+  case 2600:
+    om->ReadObj((*mPin), -1);
+    dap->SetReady();
+    this->Hide();
+    break;
+
+  default:    
+    break;
+  }
+    
+return;
+}
Index: /tags/DPC_V0/Poubelle/PIext/pisiadw.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pisiadw.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pisiadw.h	(revision 1307)
@@ -0,0 +1,59 @@
+#ifndef PISIADW_H_SEEN
+#define PISIADW_H_SEEN
+
+#include <string.h>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PIOPTMENU_H 
+#include PISTDWDG_H 
+#include PILIST_H 
+
+
+class PIStdImgApp;
+
+
+
+
+
+
+/* --------------------------------------------------------------------------- */
+class ObjMgrWind : public PIWindow {
+public :
+  ObjMgrWind(PIStdImgApp *par);
+  ~ObjMgrWind();
+  virtual void  Show();
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  inline void AddObj(const char * objid, PIMessage msg) 
+    { objlist->AppendItem(objid, msg); }
+  inline void DelObj(PIMessage msg) 
+    { objlist->DeleteItemMsg(msg); }
+private:
+  PIStdImgApp* dap;
+  PIList* objlist;
+  PIButton * mBut[5];
+};
+
+/* --------------------------------------------------------------------------- */
+class PPInMgrWind :  public PIWindow {
+public:
+   PPInMgrWind(PIStdImgApp *par);
+   ~PPInMgrWind();
+   virtual void  Show();
+   virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+   void SetFile(string flnm);
+private:
+  PIStdImgApp* dap;
+  PIList* objlist;
+  PILabel * mLab[2];
+  PIButton* mBut[3];
+  PInPersist* mPin;
+  int tolx, toly, polx, poly;  // Taille et position de  objlist
+  int ttx, tty;   // Taille globale par defaut
+
+};
+ 
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/pistdimgapp.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pistdimgapp.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pistdimgapp.cc	(revision 1307)
@@ -0,0 +1,1184 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <string>
+#include <vector>
+#if defined(__KCC__)
+using std::string ;
+#include <vector.h>
+#endif
+
+#include "machine.h"
+
+#include "strutil.h"
+#include "timing.h"
+#include "perrors.h"
+#include "ctimer.h"
+
+#include "psighand.h"
+
+#include "cimage.h" // pour pouvoir faire extract 
+
+#include "pistdimgapp.h"
+#include "pihisto2d.h"
+#include "psfile.h"
+#include "piimgtools.h"
+#include "pidrwtools.h"
+
+#include "pistzwin.h"
+
+
+//  Il faudra virer ca (?)  Reza 19/08/98 
+// #include "parmst.h"
+// #define  FLAG_MAINGLPARMPIA  1
+// #include "glparmpia.h"
+static char ImgDir[256];
+static char WorkDir[256];
+
+
+/* ........................................................... */
+/*                    Classe PIStdImgApp                         */
+/* ........................................................... */
+
+/* --Methode-- */
+PIStdImgApp::PIStdImgApp(int narg, char* arg[])
+: PIApplication(420, 320, narg, arg)
+{
+
+// Les menus
+m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("Open-Fits", 10120);
+m[0]->AppendItem("Open-PPF", 10130);
+m[0]->AppendItem("Close", 10110);
+m[0]->AppendItem("delete", 10111);
+// m[0]->AppendItem("Options", 10101);
+m[0]->AppendItem("Exit", 10105);
+
+m[1] = new PIMenu(Menubar(),"Objets");
+m[1]->AppendItem("ObjectManager", 10201);
+m[1]->AppendItem("OpenOutPPF", 10220);
+m[1]->AppendItem("CloseOutPPF", 10230);
+
+m[2] = new PIMenu(Menubar(),"Tools");
+m[2]->AppendItem("Show ImageTools", 10301);
+m[2]->AppendItem("Show DrawerTools", 10302);
+m[2]->AppendItem("Extract Pave", 10305);
+m[2]->SetSensitivityMsg(10305, false);
+mc = new PIMenu(m[2], "StackTools");
+mc->AppendItem("DispNext", 10320);
+mc->AppendItem("Blink 0.5s", 10321);
+mc->AppendItem("Blink 1s", 10322);
+mc->AppendItem("Blink 2s", 10324);
+mc->AppendItem("Stop Blink", 10329);
+mc->AppendItem("RemoveCurrent", 10330);
+m[2]->AppendPDMenu(mc);
+m[2]->SetSensitivity("StackTools", false);
+
+m[3] = new PIMenu(Menubar(),"Window");
+m[3]->AppendItem("StackWindow", 10400);
+m[3]->AppendItem("Window", 10411);
+m[3]->AppendItem("Window 2x1", 10421);
+m[3]->AppendItem("Window 1x2", 10412);
+m[3]->AppendItem("Window 2x2", 10422);
+m[3]->AppendItem("Window 3x1", 10431);
+m[3]->AppendItem("Window 3x3", 10433);
+
+m[4] = new PIMenu(Menubar(),"PostScript");
+m[4]->AppendItem("OpenPS", 10501);
+m[4]->AppendItem("ClosePS", 10505);
+m[4]->AppendItem("Window->PS", 10511);
+m[4]->AppendItem("Image->PS", 10515);
+m[4]->AppendItem("Window->EPS", 10512);
+m[4]->AppendItem("Image->EPS", 10516);
+m[4]->SetSensitivityMsg(10515, false);
+m[4]->SetSensitivityMsg(10516, false);
+
+m[5] = new PIMenu(Menubar(),"Special");
+m[5]->AppendItem("CloseAll", 10601);
+m[5]->AppendCheckItem("Red.Out/Err", 10602);
+m[5]->AppendCheckItem("Catch SigFPE/SEGV", 10603);
+
+AppendMenu(m[0]);
+AppendMenu(m[1]);
+AppendMenu(m[2]);
+AppendMenu(m[3]);
+AppendMenu(m[4]);
+AppendMenu(m[5]);
+
+int scsx, scsy;
+ScreenSz(scsx, scsy);
+if (scsy <= 600)  mFgScSz = 0;
+else if (scsy <= 800)  mFgScSz = 1;
+else if (scsy <= 1024)  mFgScSz = 2;
+else   mFgScSz = 3;
+int msx = 420+mFgScSz*60;
+int msy = 320+mFgScSz*40;
+MainWin()->SetSize(msx, msy);
+
+int bss = 100+mFgScSz*15;
+gimv = new PIPixmap(MainWin(), "GloV", bss, bss, 5, 5);
+gimv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free); 
+zoom = new PIPixmap(MainWin(), "Zoom", bss, bss, bss+10, 5);
+zoom->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free); 
+cmapv = new PICMapView(MainWin(), "CMapView", msx-10, 14+mFgScSz*2, 5, bss+10); 
+cmapv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 
+
+int cpy = bss+10+14+mFgScSz*2+5;
+
+// Creation d'une console avec gestion des commandes  
+mCons = new PIConsole(MainWin(), "Console", 30200, 512, 132, msx, msy-cpy, 0, cpy );
+mCons->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); 
+mCons->AcceptCmd(true, 50);
+// RedirectStdOutErr(true);  pas par defaut 
+
+char buff[128];
+sprintf(buff, "piapp V2.0   ---  PEIDA++ Version %5.3f \n", (float)PeidaVersion());
+mCons->AddStr("  ............  starting piapp .............\n", PIVA_Blue );
+mCons->AddStr(buff, PIVA_Blue );
+mCons->AddStr("  ..........................................\n", PIVA_Blue );
+// PrintPeidaVersion();
+
+ 
+mObjMgr = new NamedObjMgr;
+mObjMgr->SetImgApp(this);
+mCmd = new PIACmd(mObjMgr, this);
+
+char* varenv;
+ImgDir[0] = WorkDir[0] = '\0';
+if ( (varenv=getenv("PEIDA_IMAGES")) != NULL )   strncpy(ImgDir, varenv, 256);
+if ( (varenv=getenv("PEIDA_WORK")) != NULL )  strncpy(WorkDir, varenv, 256);
+
+pfc = new PIFileChooser(this,"FileChooser", 5000); 
+
+// mCutTC = new CutTools(this, this->MainWin());
+
+mObjmgrw = new ObjMgrWind(this);
+mPpinmgrw = new PPInMgrWind(this);
+
+// Gestion des feneteres widgets et drawers
+mWId = mDId = mBWId = 0;
+mCurWin = NULL;  
+mCurWdg = NULL;
+mLastWdg = NULL;
+mGrW = NULL;
+mStW = NULL;
+mGrIdx = mStIdx = -1;
+
+mFCMsg = 0;
+mFgCWImg = false;
+
+// Gestion fichiers PS
+num_eps = 0;
+name_ps = "";
+name_ps = "pia.ps";
+mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
+
+// Gestion OUT-PPF
+mPpfout = NULL;
+name_outppf = "";
+
+// Attributs graphiques courants
+mFCol = mBCol = PI_NotDefColor;
+mLAtt = PI_NotDefLineAtt;
+mFSz = PI_NotDefFontSize;
+mFAtt = PI_NotDefFontAtt;
+mMSz = -1;
+mMrk = PI_NotDefMarker;
+mCmapid = CMAP_OTHER;
+mZoom = 0;
+mAxesFlags = kBoxAxes | kExtTicks | kLabels;
+SaveGraphicAtt();
+
+SetReady();
+}
+
+/* --Methode-- */
+PIStdImgApp::~PIStdImgApp()
+{
+int i;
+
+delete mc;
+for(i=0; i<6; i++)  
+  if (m[i]) delete m[i];
+
+WindMList::iterator it;
+for(it = mWList.begin(); it != mWList.end(); it++)  delete (*it).second;
+
+delete mObjMgr;
+delete mCmd;
+
+delete zoom;
+delete gimv;
+delete cmapv;
+
+delete pfc;
+
+delete mCons;
+
+delete mObjmgrw;
+delete mPpinmgrw;
+
+// Les fichiers 
+if (mpsfile) delete mpsfile;
+if (mPpfout) delete mPpfout;
+
+}  
+
+/* --Methode-- */
+void PIStdImgApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+PIWdg *sndw;
+PIMessage tmsg, smm;
+
+tmsg = msg;
+msg = UserMsg(msg);
+smm = ModMsg(tmsg);
+
+//printf("SuperDebug: msg=%d Mod=%d  State=%d\n", (int)msg, (int)smm, (int)GetState());
+if  ((GetState()) && (msg != mFCMsg)) { PIBeep(); return; }
+
+//   Messages active-window
+if (smm == PIMsg_Active)
+  {
+  sndw = (PIWdg *)sender;
+  switch(sndw->kind())
+    {
+    case PIWindow::ClassId :
+      mCurWin = (PIWindow *)sender;
+      break;
+
+    case PIScDrawWdg::ClassId :
+    case PIDraw3DWdg::ClassId :
+      mCurWdg = (PIBaseWdg *)sender;
+//      cerr << "*DBG11* ImgTools -> NonSensitive " << sndw->kind() << endl;
+      if (mFgCWImg) {
+//        cerr << "*DBG* ImgTools -> NonSensitive " << endl;
+        m[2]->SetSensitivityMsg(10305, false);
+        m[4]->SetSensitivityMsg(10515, false);
+        m[4]->SetSensitivityMsg(10516, false);
+        mFgCWImg = false;
+        }
+      break;
+    case PIImage::ClassId :
+      mCurWdg = (PIBaseWdg *)sender;
+      if (!mFgCWImg) {
+//        cerr << "*DBG* ImgTools -> Sensitive " << endl;
+        m[2]->SetSensitivityMsg(10305, true);
+        m[4]->SetSensitivityMsg(10515, true);
+        m[4]->SetSensitivityMsg(10516, true);
+        mFgCWImg = true;
+        }
+      break;
+    }
+  }
+//  Message window-close
+else if (smm == PIMsg_Close)
+  {
+  sndw = (PIWdg *)sender;
+  if(sndw->kind() == PIWindow::ClassId)
+    {
+    mCurWin = (PIWindow *)sender;
+    if (mCurWin == mStW) m[2]->SetSensitivity("StackTools", false); 
+    DeleteWindow(mCurWin);
+    }
+  else  
+    printf("PIStdImgApp/Bug ? CloseMsd received from NonWindow (%d %d %lx) \n",
+           (int)tmsg,  (int)sndw->kind(), (long)sender);       
+  }
+
+// Traitement des messages des menus 
+else if ( (msg >= 10100) && (msg < 10200) )  MBProcess1(msg, sender, data);
+else if ( (msg >= 10200) && (msg < 10300) )  MBProcess2(msg, sender, data);
+else if ( (msg >= 10300) && (msg < 10400) )  MBProcess3(msg, sender, data);
+else if ( (msg >= 10400) && (msg < 10500) )  MBProcess4(msg, sender, data);
+else if ( (msg >= 10500) && (msg < 10600) )  MBProcess5(msg, sender, data);
+else if ( (msg >= 10600) && (msg < 10700) )  MBProcess6(msg, sender, data);
+else if ( msg == 30200  ) {    // Objet PIConsole 
+  string s = mCons->GetCmdString();
+  string s2 = "\nExecuting " + s + "\n";
+  mCons->AddStr(s2.c_str(), PIVA_Blue, true);
+  SetBusy();
+  TRY {
+    CmdInterpreter()->Do(s);
+    }  CATCH(merr) { 
+    fflush(stdout); 
+    cout << endl; 
+    cerr << endl;
+    string es = PeidaExc(merr);
+    cerr << "PIStdImgApp::Process()/ Cmd->Do() Exception :" << es << " (" << merr << ")" << endl ;    
+  }
+
+  SetReady();
+  }
+
+else printf("PIStdImgApp::Process() BUG?? Msg %d (%d-%d) \n", 
+            (int)tmsg,(int)msg,(int)smm);
+
+
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::SetReady()
+{
+mCons->SetSensitive();
+gimv->SetSensitive();
+PIApplication::SetReady();
+}
+
+/* --Methode-- */
+void PIStdImgApp::SetBusy()
+{
+mCons->SetUnSensitive();
+gimv->SetUnSensitive();
+PIApplication::SetBusy();
+}
+
+/* --Methode-- */
+void PIStdImgApp::SetBlocked()
+{
+mCons->SetUnSensitive();
+gimv->SetUnSensitive();
+PIApplication::SetBlocked();
+}
+
+
+/* --Methode-- */
+int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, int opt)
+{
+PIImage* pii;
+PIWindow* win;
+int sx, sy, px, py, flag;
+
+if (nouv == NULL)
+  {
+  printf("PIStdImgApp::DispImage_Error  Cannot Display  NULL image \n");
+  return(-1);
+  }
+
+if ( (nouv->XSize() <= 0)  || (nouv->YSize() <= 0))
+  {
+  printf("PIStdImgApp::DispImage_Error Pb Size Sz=%d*%d  \n", 
+          nouv->XSize(), nouv->YSize());
+  return(-1);
+  }
+
+int zm = 1;
+if (mZoom == 0) {  // Facteur de zoom auto 
+  zm = (nouv->XSize() > nouv->YSize()) ? nouv->XSize() :  nouv->YSize();
+  zm = (zm >= 250) ? 250/zm : 1;
+  }
+else zm = mZoom;
+
+if (zm == 0)  zm = 1;
+if (zm < -10)  zm = -10; 
+if (zm > 10)  zm = 10;
+
+if (zm > 0)  { sx = nouv->XSize()*zm;  sy = nouv->YSize()*zm; }
+else  { 
+  sx = (int)((float)nouv->XSize()*(-1./float(zm)));  
+  sy = (int)((float)nouv->YSize()*(-1./float(zm))); 
+  } 
+if (sx > 400+mFgScSz*100) sx = 400+mFgScSz*100;
+if (sy > 400+mFgScSz*100) sy = 400+mFgScSz*100;
+px = py = 0;
+win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
+pii = new PIImage(win, (char *)name.c_str(), sx, sy, px,py);
+pii->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+pii->SetZoomWin(zoom, false);
+pii->SetGloVWin(gimv, false);
+pii->SetCMapWin(cmapv, false);
+pii->SetZoom(zm, false);
+if ( mCmapid != CMAP_OTHER ) pii->SetColMapId(mCmapid, false);
+pii->ShowCursor(true);
+pii->SetUserData(NULL, flag);
+pii->SetImage(nouv, true);
+// printf("!!DBG!! PIImage Pos= %d %d  Size= %d %d \n", pii->XPos(), pii->YPos(), pii->XSize(), pii->YSize()   );
+mCurWin = win;
+mCurWdg = pii;
+mLastWdg = pii;
+mBWId++;
+mBWList[mBWId] = pii;
+return(mBWId); 
+}
+
+
+/* --Methode-- */
+int PIStdImgApp::DispScDrawer(PIDrawer* scd, string const & name, int opt, string title, bool h2d)
+{
+if (scd == NULL)
+  {
+  printf("PIStdImgApp::DispScDrawer_Error  Cannot Add NULL ScDrawer \n");
+  return(-1);
+  }
+
+// Changement d'attributs graphiques courants du drawer
+if (mFCol != PI_NotDefColor) scd->SetColAtt(mFCol, mBCol);
+if (mLAtt != PI_NotDefLineAtt) scd->SetLineAtt(mLAtt);
+if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) ) scd->SetFontAtt(mFSz, mFAtt); 
+if ( (mMrk != PI_NotDefMarker) && (mMSz >= 0) ) scd->SetMarkerAtt(mMSz, mMrk);
+if ( mCmapid != CMAP_OTHER ) scd->SetColMapId(mCmapid);
+
+if ( (opt == Disp_Same) && (mLastWdg) ) {
+  if (mLastWdg->kind() == PIScDrawWdg::ClassId)  ((PIScDrawWdg*)mLastWdg)->AddScDrawer(scd, true);
+  else mLastWdg->AddDrawer(scd, true, true, true);
+  scd->Refresh();
+  mDId++;
+  mDrwList[mDId] = scd;
+  return(-mDId);   
+}
+else if (opt == Disp_Same)  opt = Disp_Next;
+
+PIWindow* win;
+PIScDrawWdg* scw;
+int sx, sy, px, py, flag;
+sx = 200+mFgScSz*100;
+sy = 200+mFgScSz*100;
+win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
+if (!h2d) scw = new PIScDrawWdg(win, (char *)name.c_str(), sx, sy, px, py);
+else scw = new PIH2DWdg(win, (char *)name.c_str(), sx, sy, px, py);
+scw->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+scw->SetUserData(NULL, flag);
+scw->SetAxesFlags(mAxesFlags);
+
+if (!h2d) scw->AddScDrawer(scd, true);
+else ((PIH2DWdg*)scw)->SetPIHisto((PIHisto2D*)scd);
+//   Titre du plot
+if (title.length() <= 0)  title = name;  string t2="";   
+scw->SetTitles(title, t2);    
+// scw->Refresh();  Pas necessaire  Reza 19/08/98 $CHECK$ 
+mCurWin = win;
+mCurWdg = scw;
+mLastWdg = scw;
+mBWId++;
+mBWList[mBWId] = scw;
+return(mBWId); 
+}
+
+/* --Methode-- */
+int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, int opt, string title)
+{
+if (dr3 == NULL)
+  {
+  printf("PIStdImgApp::Disp3DDrawer_Error  Cannot Add NULL 3DDrawer \n");
+  return(-1);
+  }
+
+// Changement d'attributs graphiques courants du drawer
+if (mFCol != PI_NotDefColor) dr3->SetColAtt(mFCol, mBCol);
+if (mLAtt != PI_NotDefLineAtt) dr3->SetLineAtt(mLAtt);
+if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) ) dr3->SetFontAtt(mFSz, mFAtt); 
+if ( (mMrk != PI_NotDefMarker) && (mMSz >= 0) ) dr3->SetMarkerAtt(mMSz, mMrk);
+if ( mCmapid != CMAP_OTHER ) dr3->SetColMapId(mCmapid);
+
+if ( (opt == Disp_Same) && (mLastWdg) ) {
+  if (mLastWdg->kind() == PIDraw3DWdg::ClassId)  ((PIDraw3DWdg*)mLastWdg)->AddDrawer3D(dr3, true);
+  else mLastWdg->AddDrawer(dr3, true, true, true);
+  dr3->Refresh();
+  mDId++;
+  mDrwList[mDId] = dr3;
+  return(-mDId);   
+}
+else if (opt == Disp_Same)  opt = Disp_Next;
+
+PIWindow* win;
+int sx, sy, px, py, flag;
+sx = 200+mFgScSz*100;
+sy = 200+mFgScSz*100;
+win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
+PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)name.c_str(), sx, sy, px, py);
+wd3->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+wd3->SetUserData(NULL, flag);
+wd3->AddDrawer3D(dr3, true);
+//   Titre du plot
+if (title.length() <= 0)  title = name;  string t2="";   
+wd3->SetTitles(title, t2);    
+// wd3->Refresh();  Pas necessaire   
+mCurWin = win;
+mCurWdg = wd3;
+mLastWdg = wd3;
+mBWId++;
+mBWList[mBWId] = wd3;
+return(mBWId); 
+}
+
+
+/* --Methode-- */
+void PIStdImgApp::CreateGraphWin(int nx, int ny, int sx, int sy)
+{
+if (nx < 1)  nx = 1;
+if (ny < 1)  ny = 1;
+if (nx > 8)  nx = 8;    
+if (ny > 8)  ny = 8;
+if ( (sx < 50) && (sy < 50) )   sx = sy = 400+mFgScSz*100; 
+char buff[64];
+mWId++;
+int px, py; 
+MainWin()->GetScreenPos(px, py);
+sprintf(buff, "PI-GraphicWin (%d)",mWId);
+PIZoneWindow* win = new PIZoneWindow(this,  buff, PIWK_normal, nx, ny, sx, sy, px+MainWin()->XSize()+30, 0);
+win->SetUserData(NULL, ny*10+nx);  // UserFlag= nY*10 + nX  
+mWList[mWId*10+1] = (PIWindow*)win;
+win->SetAutoDelChilds(true);
+win->Show();
+mGrW = win; 
+mGrIdx = 0;
+}
+
+/* --Methode-- */
+void PIStdImgApp::CreateStackWin(int sx, int sy)
+{
+if ( (sx < 50) && (sy < 50) )   sx = sy = 300+mFgScSz*100; 
+char buff[64];
+mWId++;
+int px, py; 
+MainWin()->GetScreenPos(px, py);
+sprintf(buff, "PI-StackWin (%d)",mWId); 
+PIStackWindow* win = new PIStackWindow(this,  buff, PIWK_normal, sx, sy, px+MainWin()->XSize()+30, 100);
+win->SetUserData(NULL, 9999);  // UserFlag= 9999 
+mWList[mWId*10+2] = (PIWindow*)win;
+win->SetAutoDelChilds(true);
+win->Show();
+mStW = win;
+m[2]->SetSensitivity("StackTools", true); 
+mStIdx = 0;
+}
+
+/* --Methode-- */
+PIWindow* PIStdImgApp::GetWindow(int typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom)
+{
+PIWindow* rw;
+
+switch (typ) {
+  case Disp_Next :  // Fenetre graphique courante
+    {
+    if (mGrW == NULL) CreateGraphWin();
+    int nx, ny;
+    mGrW->NbZone(nx, ny);
+    PIWdg* nw = mGrW->NextChildPosSize(px, py, sx, sy);
+//    cerr << "**DBG** PIStdImgApp::GetWindow() DispNext : nw = " << (long)nw << endl;
+    if (nw) DeleteBaseWidget((PIBaseWdg*)nw, false, false);
+    flag = mGrIdx;
+    mGrIdx = (mGrIdx+1)%(nx*ny);
+    rw = mGrW;
+    break;
+    }
+
+  case Disp_Stack :  // Fenetre de type stack (empilement)
+    {
+    if (mStW == NULL) CreateStackWin(sx, sy);
+    px = py = 0;
+    sx = mStW->XSize();
+    sy = mStW->YSize();
+    flag = mStIdx;
+    mStIdx++;
+    rw = mStW;
+    }
+    break;
+
+  default :      // Fenetre ordinaire
+    {
+    int pwx, pwy; 
+    MainWin()->GetScreenPos(pwx, pwy);
+    if ( (sx < 50) && (sy < 50) )   sx = sy = 300+mFgScSz*100; 
+    rw = new PIWindow(this,  nom, PIWK_normal, sx, sy, pwx+MainWin()->XSize()+30, 300);
+    rw->SetUserData(NULL, 0);  // UserFlag= 0 
+    mWId++;
+    mWList[mWId*10] = rw;
+    rw->SetAutoDelChilds(true);
+    rw->Show();
+    px = py = 0;
+    flag = 0;
+    break;
+    }
+  }
+
+// rw->Show();
+mCurWin = rw;
+return(rw);
+}
+
+/* --Methode-- */
+void PIStdImgApp::SetZone(int nzx, int nzy)
+{
+if (!mGrW) CreateGraphWin(nzx, nzy);
+else { 
+  int k;
+  PIWdg* cwd;
+  for(k=0; k<mGrW->NbChilds(); k++) {
+    if ((cwd = mGrW->GetChild(k)) == NULL)  continue; 
+    DeleteBaseWidget((PIBaseWdg*)cwd, false, false);
+    }
+  mGrW->SetZone(nzx, nzy);
+  }
+}
+
+/* --Methode-- */
+void PIStdImgApp::StackWinNext()
+{
+if (mStW)  mStW->DispNext();
+}
+
+/* --Methode-- */
+void PIStdImgApp::DeleteWindow(PIWindow* w)
+{
+if (w == NULL)  return;
+w->Hide();
+WindMList::iterator it;
+for(it = mWList.begin(); it != mWList.end(); it++) 
+  if ((*it).second == w)  { mWList.erase(it);  break; }
+if (w == mGrW) { mGrW = NULL;  mGrIdx = -1; }
+if (w == mStW) { mStW = NULL;  mStIdx = -1; m[2]->SetSensitivity("StackTools", false); }
+if (w == mCurWin) mCurWin = NULL;
+int k;
+PIWdg* cwd;
+for(k=0; k<w->NbChilds(); k++) {
+  if ((cwd = w->GetChild(k)) == NULL)  continue; 
+  DeleteBaseWidget((PIBaseWdg*)cwd,false,false);
+  }
+delete w;
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::DeleteBaseWidget(PIBaseWdg* w, bool dw, bool dwin)
+{
+if (w == NULL)  return;
+BWMList::iterator it;
+for(it = mBWList.begin(); it != mBWList.end(); it++) 
+  if ((*it).second == w)  { mBWList.erase(it);  break; }
+int k;
+PIDrawer* drw;
+for(k=0; k<w->NbDrawers(); k++) {
+  if ((drw = w->GetDrawer(k)) == NULL)  continue; 
+  DrwMList::iterator itt;
+  for(itt = mDrwList.begin(); itt != mDrwList.end(); itt++) 
+    if ((*itt).second == drw)  { mDrwList.erase(itt);  break; }
+  }
+
+if (w == mCurWdg) {  
+  mCurWdg = NULL;
+  if (mFgCWImg) {
+    m[4]->SetSensitivityMsg(10515, false);
+    m[4]->SetSensitivityMsg(10516, false);
+    mFgCWImg = false;
+    }
+  }
+
+if (w == mLastWdg)  mLastWdg = NULL;
+
+PIWdg* pw=NULL;
+if (dwin)  pw = (PIWdg*)(w->Parent());
+//DBG printf("DeleteBaseWidget(%lx)-DBG kind = %d - %d %d \n", (long)w, w->kind(), (int)dw, (int)dwin); 
+if (dw) delete w;
+if (pw && (pw->kind() == PIWindow::ClassId )) {
+ PIWindow* pww = (PIWindow*) pw;
+ if ((pww != (PIWindow*)mGrW) && (pww != (PIWindow*)mStW) && (pww->NbChilds()==0)) 
+    DeleteWindow((PIWindow*)pw);
+ } 
+return;
+}
+
+
+
+/* --Methode-- */
+void PIStdImgApp::DelWRsId(int k)
+{
+//DBG cerr << "-DBG- PIStdImgApp::DelWRsId(" << k << ")" << endl; 
+if (k > 0) { // C'est un BaseWidget
+  BWMList::iterator it;
+  it  = mBWList.find(k);
+  if (it == mBWList.end())  return;
+  PIBaseWdg* wd = (*it).second;
+//DBG cerr << "-DBG- PIStdImgApp::DelWRsId Deleting BaseWidget " << (long)(wd) << endl ; 
+  DeleteBaseWidget(wd, true, true);
+  }
+else {  // C'est un drawer
+  DrwMList::iterator it;
+  it  = mDrwList.find(-k);
+  if (it == mDrwList.end())  return;
+  delete (*it).second;  
+  mDrwList.erase(it);
+//  cerr << "+DBG+ PIStdImgApp::DelWRsId Deleting Drawer " << (long)((*it).second) << endl ; 
+  }
+}
+
+
+/* --Methode-- */
+void PIStdImgApp::RedirectStdOutErr(bool fg)
+{
+if (fg) { 
+  RedirectOutStream(mCons);
+  RedirectErrStream(mCons);
+  m[5]->SetStateMsg(10602, true);
+  }
+else {
+  RedirectOutStream(NULL);
+  RedirectErrStream(NULL);
+  m[5]->SetStateMsg(10602, false);
+  }
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::CatchSignals(bool fg)
+{    
+PeidaConfigureSignalhandling(fg, fg);  
+m[5]->SetStateMsg(10603, fg);
+}
+
+/* --Methode-- */
+void PIStdImgApp::CloseAllWindows()
+{
+WindMList::iterator it;
+for(it = mWList.begin(); it != mWList.end(); it++)   delete (*it).second;
+mWList.clear();
+mBWList.clear();
+mDrwList.clear(); 
+}
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess1(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+
+  switch(msg)
+    {
+    case 10120 :
+      pfc->SetPath(ImgDir);
+      pfc->AcceptNewFile(false);
+      mFCMsg = 10125; 
+      pfc->SetMsg(mFCMsg);
+      SetBlocked();
+      pfc->Show();
+      break;
+
+    case 10125 :
+      SetBusy();
+      if (data)  { 
+        ObjMgr()->ReadFits(pfc->GetFileName());
+        ObjMgr()->DisplayObj(ObjMgr()->LastObjName(), "win");
+      }
+      mFCMsg = 0;
+      SetReady();
+      break;
+
+    case 10130 :
+      pfc->SetPath(WorkDir);
+      pfc->AcceptNewFile(false); 
+      mFCMsg = 10135; 
+      pfc->SetMsg(mFCMsg);
+      SetBlocked();
+      pfc->Show();
+      break;
+
+    case 10135 :
+      mFCMsg = 0;
+      if (data)  { 
+        PPInMgrW()->SetFile(pfc->GetFileName());
+        PPInMgrW()->Show();
+      }
+      SetReady();
+      break;
+
+    case 10110 :
+      DeleteWindow(mCurWin);
+      break;
+        
+    case 10111 :
+      if (mCurWdg) {
+        string no = mCurWdg->Nom();
+        DeleteBaseWidget(mCurWdg);
+        mObjMgr->DelObj(no);
+        }
+      break;
+
+    case 10105:
+      Stop();
+      break;
+
+  }
+return;
+}
+
+
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess2(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+
+switch (msg)  { 
+  case 10201 :
+     ObjMgrW()->Show();
+     break;
+
+  case 10220 :
+     pfc->SetPath(WorkDir);
+     pfc->AcceptNewFile(true);
+     mFCMsg = 10225;
+     pfc->SetMsg(mFCMsg);
+     SetBlocked();
+     pfc->Show();
+     break;
+
+   case 10225 :
+     SetBusy();
+     if (data) {
+       if (mPpfout) {  
+         printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
+         delete mPpfout;  
+       }
+       name_outppf = pfc->GetFileName();
+       mPpfout = NULL;
+       printf("PIStdImg/Info: Opening POutPersist-File %s \n", name_outppf.c_str());
+       mPpfout = new POutPersist(name_outppf);
+    }
+    mFCMsg = 0;
+    SetReady();
+    break;
+
+  case 10230 :
+    if (!mPpfout)  break;
+    printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
+    delete mPpfout;  
+    name_outppf = "";
+    mPpfout = NULL;
+    break;
+
+
+  default:
+    cerr << "PIStdImgApp::MBProcess2() BUG?? Msg= " <<  msg << endl;    
+    break;
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess3(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+switch (msg)  { 
+  case 10301 :
+    PIImgTools::ShowPIImgTools();
+    break; 
+  case 10302 :
+    PIDrwTools::ShowPIDrwTools();
+    break;
+
+  case 10305 :
+    {
+    PIImage* curpimg = NULL;
+    if (!mCurWdg)  return;
+    if (mCurWdg->kind() != PIImage::ClassId)  return;
+    curpimg = (PIImage*)mCurWdg;
+    if (curpimg == NULL)   return;
+    P2DArrayAdapter* img = curpimg->Image();
+    if (img == NULL) return;
+    int dx = curpimg->XSzPave();
+    int dy = curpimg->YSzPave();  
+    int x0 = curpimg->XPave()-dx/2;
+    int y0 = curpimg->YPave()-dy/2;
+    if (x0 < 0)  x0 = 0;
+    if (y0 < 0)  y0 = 0;
+    int x1 = x0+dx;
+    int y1 = y0+dy;
+    if (x1 > img->XSize()) x1 = img->XSize();
+    if (y1 > img->YSize()) y1 = img->YSize();
+    dx = x1-x0;  dy = y1-y0;
+    ImageR4* pim = new ImageR4(dx, dy); 
+    int ii, jj;
+    for(jj=0; jj<dy; jj++) 
+      for(ii=0; ii<dx; ii++) (*pim)(ii,jj) = (*img)(ii+x0, jj+y0);
+    string nom = mCurWdg->Nom() + "_pave";
+    ObjMgr()->AddObj(pim, nom);
+    ObjMgr()->DisplayObj(nom, "w");
+    }
+
+  case 10320 :
+    if (mStW)  mStW->DispNext();
+    break;
+
+  case 10321 :
+  case 10322 :
+  case 10324 :
+//  case 10328 :
+    if (mStW) mStW->StartAutoDisp((msg-10320)*500);
+    break;
+
+  case 10329 :
+    if (mStW) mStW->StopAutoDisp();
+    break;
+
+  case 103330 :
+    if (mStW) {
+      PIWdg* cw =  mStW->CurrentWdg();
+      if (cw) DeleteBaseWidget((PIBaseWdg*)cw);
+      }
+    break;
+
+  default:
+    cerr << "PIStdImgApp::MBProcess3() BUG?? Msg= " <<  msg << endl;    
+    break;
+  }
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess4(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+switch (msg)  { 
+
+  case 10400 :
+    CreateStackWin();
+    break;
+
+  case 10411 :
+    CreateGraphWin(1,1);
+    break;
+  case 10421 :
+    CreateGraphWin(1,2);
+    break;
+  case 10412 :
+    CreateGraphWin(2,1);
+    break;
+  case 10422 :
+    CreateGraphWin(2,2);
+    break;
+  case 10431 :
+    CreateGraphWin(1,3);
+    break;
+  case 10433 :
+    CreateGraphWin(3,3);
+    break;
+
+  default:
+    cerr << "PIStdImgApp::MBProcess4() BUG?? Msg= " <<  msg << endl;    
+    break;
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess5(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+char nomps[64],strg[512];
+PSFile *mps;
+int sxt, syt, syo, syo1, sx[4], sy[4];
+
+switch (msg)
+  { 
+  case 10501 :
+     pfc->SetPath(WorkDir);
+     pfc->AcceptNewFile(true); 
+     mFCMsg = 10525; 
+     pfc->SetMsg(mFCMsg);
+     SetBlocked();
+     pfc->Show();
+     break;
+
+   case 10525 :
+     SetBusy();
+     if (data) {
+       if (mpsfile) {  
+         printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
+         delete mpsfile;  
+         }
+        name_ps = pfc->GetFileName();
+        printf("PIStdImg/Info: Opening PS-File %s \n", name_ps.c_str());
+        mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 2., 2.);
+        }
+      mFCMsg = 0;
+      SetReady();
+      break;
+
+  case 10505 :
+    if (!mpsfile)  break;
+    printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
+    delete mpsfile;
+    mpsfile = NULL;
+    name_ps = "";
+    break;
+
+  case 10511 :     // Window -> PS
+  case 10512 :     // Window -> EPS 
+    if (CurrentWindow() == NULL)  break;
+    if (msg == 10512) 
+      { 
+      num_eps++;
+      sprintf(nomps,"pia%d.eps", num_eps);
+      printf("PIStdImg/Info: Creating EPSFile %s (CurWin-> EPS) \n", nomps);
+      mps = new PSFile(nomps);
+      }
+    else {
+      if (mpsfile == NULL) {
+        name_ps = "pia.ps";
+        mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 0., 0.);
+        printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
+      }
+      printf("PIStdImg/Info: CurWin-> PSFile %s\n", name_ps.c_str());      
+      mps = mpsfile; 
+      }
+    CurrentWindow()->PSPrint(mps,0,0);
+
+    if (msg == 10512)   delete mps;   // fichier eps
+    break;
+
+  case 10515 :    // Image -> PS
+  case 10516 :    // Image -> EPS 
+     {
+     PIImage* curpimg = NULL;
+     if (!mCurWdg)  return;
+     if (mCurWdg->kind() != PIImage::ClassId)  return;
+     curpimg = (PIImage*)mCurWdg;
+     if (curpimg == NULL)   return;
+     if (msg == 10516) 
+      { 
+      num_eps++;
+      sprintf(nomps,"pia%d.eps", num_eps);
+      printf("PIStdImg/Info: Creating EPSFile %s (CurImage-> EPS)\n", nomps);
+      mps = new PSFile(nomps);
+      }
+    else {
+      if (mpsfile == NULL) {
+        name_ps = "pia.ps";
+        mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
+        printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
+      }
+      printf("PIStdImg/Info: CurImage-> PSFile %s\n", name_ps.c_str());       
+      mps = mpsfile; 
+      }
+
+    sx[0] = gimv->XSize(); 
+    sy[0] = gimv->YSize();
+    sx[1] = zoom->XSize(); 
+    sy[1] = zoom->YSize();
+    sx[2] = cmapv->XSize(); 
+    sy[2] = cmapv->YSize();
+    sx[3] = curpimg->XSize(); 
+    sy[3] = curpimg->YSize();
+    if (sy[1] > sy[0])  { syo1 = sy[1]+50;  syo = sy[1]+sy[2]+60; }
+    else  { syo1 = sy[0]+50;  syo = sy[0]+sy[2]+60; }
+    syt = sy[3]+syo;
+    sxt = sx[3];
+    if (sxt < (sx[0]+sx[1]+20))  sxt = sx[0]+sx[1]+20;
+    if (sxt < sx[2])  sxt = sx[2];
+
+    // Pour ecrire le titre 
+    mps->NewPage((float)sxt, (float)syt, PI_Portrait);
+    mps->NewBloc(0,0, (float)sxt, 30., (float)sxt, 30.);
+    sprintf(strg,"Image: %s -  Pave %d %d \n",  curpimg->Nom().c_str(), 
+            curpimg->XPave(),  curpimg->YPave());     
+    mps->DrawString(10., 25., strg, PI_Black, PI_BoldFont, 20);
+    mps->EndBloc();
+
+    // Les quatre fenetres glovimage, zoom, cmap, image 
+    gimv->PSPrint(mps, -gimv->XPos(), -gimv->YPos()+40);
+    zoom->PSPrint(mps, -zoom->XPos()+sx[0]+20, -zoom->YPos()+40);
+    cmapv->PSPrint(mps, -cmapv->XPos(), -cmapv->YPos()+syo1);
+    curpimg->PSPrint(mps, -curpimg->XPos(), -curpimg->YPos()+syo);
+     
+    if (msg == 10516)   delete mps;    // fichier eps
+    break;
+    }
+
+  default:
+    cerr << "PIStdImgApp::MBProcess5() BUG?? Msg= " <<  msg << endl;    
+    break;
+  }
+
+}
+
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess6(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+switch (msg)  { 
+  case 10601:
+    CloseAllWindows();
+    break;
+  case 10602:
+    RedirectStdOutErr(*((bool*)data));
+    break;
+  case 10603:
+    CatchSignals(*((bool*)data));
+    break;
+  default:
+    cerr << "PIStdImgApp::MBProcess6() BUG?? Msg= " <<  msg << endl;    
+    break;
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIStdImgApp::SetColAtt(PIColors fg, PIColors bg)
+{
+  mFCol = fg;
+  mBCol = bg;
+}
+/* --Methode-- */
+void PIStdImgApp::SetLineAtt(PILineAtt lat)
+{
+  mLAtt = lat;
+}
+/* --Methode-- */
+void PIStdImgApp::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
+{
+  mFSz = fsz;
+  mFAtt = fat;
+}
+/* --Methode-- */
+void PIStdImgApp::SetMarkerAtt(int sz, PIMarker mrk)
+{
+  mMSz = sz;
+  mMrk = mrk;
+}
+/* --Methode-- */
+void PIStdImgApp::SetColMapId(CMapId cid)
+{
+  mCmapid = cid;
+}
+/* --Methode-- */
+void PIStdImgApp::SetZoomAtt(int zoom)
+{
+  if ( (zoom > 10) || (zoom < -10) ) zoom = 0;
+  mZoom = zoom;
+}
+/* --Methode-- */
+void PIStdImgApp::SetAxesAtt(unsigned int axfl)
+{
+  mAxesFlags = axfl; 
+}
+
+/* --Methode-- */
+void PIStdImgApp::SaveGraphicAtt()
+{
+  mSFCol = mFCol;
+  mSBCol = mBCol;
+  mSLAtt = mLAtt;
+  mSFSz = mFSz;
+  mSFAtt = mFAtt;
+  mSMSz = mMSz;
+  mSMrk = mMrk;
+  mSCmapid = mCmapid;
+  mSZoom = mZoom;
+  mSAxesFlags = mAxesFlags;
+}
+
+/* --Methode-- */
+void PIStdImgApp::RestoreGraphicAtt()
+{
+  mFCol = mSFCol;
+  mBCol = mSBCol;
+  mLAtt = mSLAtt;
+  mFSz = mSFSz;
+  mFAtt = mSFAtt;
+  mMSz = mSMSz;
+  mMrk = mSMrk;
+  mCmapid = mSCmapid;
+  mZoom = mSZoom;
+  mAxesFlags = mSAxesFlags;
+}
Index: /tags/DPC_V0/Poubelle/PIext/pistdimgapp.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pistdimgapp.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pistdimgapp.h	(revision 1307)
@@ -0,0 +1,166 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Standard Image App      R. Ansari  97-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PISTIMGAPP_H_SEEN
+#define PISTIMGAPP_H_SEEN
+
+#include <string.h>
+#include <string>
+#include <map>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PIOPTMENU_H 
+
+#include PISTDWDG_H 
+
+#include PIFILECHO_H 
+#include "picons.h"
+
+#include "piimage.h"
+#include "pi3ddrw.h"
+#include "nobjmgr.h"
+#include "piacmd.h"
+#include "pisiadw.h"
+#include "pistzwin.h"
+
+
+enum {Disp_Next=0, Disp_Win=1, Disp_Same=2, Disp_Stack=3};
+
+typedef map<long, PIWindow*, less<long> > WindMList;
+typedef map<long, PIBaseWdg*, less<long> > BWMList;
+typedef map<long, PIDrawer*, less<long> > DrwMList;
+
+class PIStdImgApp : public PIApplication  {
+public:
+     PIStdImgApp(int narg=0, char* arg[]=NULL);
+     ~PIStdImgApp();
+
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+     virtual void   SetReady();
+     virtual void   SetBusy(); 
+     virtual void   SetBlocked();
+
+     int  DispImage(P2DArrayAdapter* nouv, string const & name, int opt);
+     int  DispScDrawer(PIDrawer* scd, string const & name, int opt, string title="", bool h2d=false);
+     int  Disp3DDrawer(PIDrawer3D* scd, string const & name, int opt, string title="");
+
+     void CreateGraphWin(int nx=1, int ny=1, int sx=0, int sy = 0);
+     void CreateStackWin(int sx=0, int sy = 0);
+     PIWindow * GetWindow(int typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom);
+     void SetZone(int nzx=1, int nzy=1);
+     void StackWinNext();
+
+     void DeleteWindow(PIWindow* w);
+     void DeleteBaseWidget(PIBaseWdg* w, bool dw=true, bool dwin=true);
+     void DelWRsId(int k);
+     void CloseAllWindows();
+
+     inline NamedObjMgr* ObjMgr() { return mObjMgr; }
+     inline PIACmd* CmdInterpreter() { return mCmd; }
+
+     PIWindow* CurrentWindow() { return (mCurWin); };
+     PIBaseWdg* CurrentBaseWdg() { return (mCurWdg); };
+
+     inline PIPixmap* ZoomW() { return zoom; }
+     inline PIPixmap* GloVW() { return gimv; }
+     inline PICMapView* CMapVW() { return cmapv; }
+     inline PIConsole* GetConsole() { return mCons; }
+
+//     inline CutTools*  CutTC()  { return mCutTC; }   A reactiver plus tard ?  Reza 08/98
+
+     inline ObjMgrWind* ObjMgrW() { return mObjmgrw; }
+     inline PPInMgrWind* PPInMgrW() { return mPpinmgrw; }
+
+// Redirection ou Non de StdOut/StdErr
+     void  RedirectStdOutErr(bool fg = true);
+// Gestion des signaux
+     void  CatchSignals(bool fg = true);
+
+//  Gestion d attributs graphiques courants
+     void  SetColAtt(PIColors fg=PI_NotDefColor, 
+                     PIColors bg=PI_NotDefColor);
+     void  SetLineAtt(PILineAtt lat=PI_NotDefLineAtt);
+     void  SetFontAtt(PIFontSize fsz=PI_NotDefFontSize,
+                      PIFontAtt fat=PI_NotDefFontAtt);
+     void  SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker);
+     void  SetColMapId(CMapId cid=CMAP_OTHER);
+     void  SetZoomAtt(int zoom=0);
+     void  SetAxesAtt(unsigned int axfl=kBoxAxes | kExtTicks | kLabels);
+// Pour sauvegarder-restauration de  l'etat des attributs graphiques
+     void  SaveGraphicAtt();   
+     void  RestoreGraphicAtt();   
+
+// Gestion fichiers PS
+    int num_eps;
+    PSFile *mpsfile;
+    string name_ps;
+
+// Gestion OUT-PPF
+    POutPersist* mPpfout;
+    string name_outppf;    
+
+private:
+    void MBProcess1(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess2(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess3(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess4(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess5(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess6(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+
+    NamedObjMgr* mObjMgr;
+    PIACmd* mCmd;
+
+    PIMenu* m[6];
+    PIMenu* mc;
+
+    PIPixmap* zoom;
+    PIPixmap* gimv;
+    PICMapView* cmapv;
+
+    PIFileChooser * pfc;
+
+//    CutTools* mCutTC;               // mTCId = 3   A reactiver plus tard ?  Reza 08/98
+//    PIContainer* mTC;   A reactiver plus tard ?  Reza 08/98 
+
+    PIConsole* mCons;
+
+    WindMList mWList;
+    BWMList mBWList;
+    DrwMList mDrwList;
+
+    int mWId,mDId,mBWId;
+
+    PIBaseWdg* mCurWdg;
+    PIBaseWdg* mLastWdg;
+    PIWindow* mCurWin;
+    PIZoneWindow* mGrW;
+    PIStackWindow* mStW;
+    int mGrIdx;
+    int mStIdx;
+
+    ObjMgrWind* mObjmgrw;
+    PPInMgrWind* mPpinmgrw;
+
+//  Gestion d attributs graphiques courants, etat sauvegarde
+    PIColors     mFCol, mBCol, mSFCol, mSBCol;
+    PILineAtt    mLAtt, mSLAtt;
+    PIFontSize   mFSz, mSFSz;
+    PIFontAtt    mFAtt, mSFAtt;
+    int          mMSz, mSMSz;
+    PIMarker     mMrk,mSMrk;  
+    CMapId       mCmapid, mSCmapid;
+    int 	 mZoom, mSZoom;
+    unsigned int mAxesFlags, mSAxesFlags;
+
+    PIMessage mFCMsg;  // Message for processing FileOpen
+    int mFgScSz;   // Dlag ScreenSize
+    bool mFgCWImg; // true -> Current Widget is PIImage
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/pistlist.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pistlist.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pistlist.cc	(revision 1307)
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include "pistlist.h"
+
+ 
+/* --Methode-- */
+PIStarList::PIStarList(StarList* stl, bool ad)
+: PIDrawer(), mStL(stl)
+{
+  mAdDO = ad;   
+  if (stl == NULL) return;
+  SetFluxLimits(1., -1.);
+}
+
+PIStarList::~PIStarList()
+{
+  if (mAdDO && mStL)  delete mStL;
+}
+
+/* --Methode-- */
+void  PIStarList::SetFluxLimits(float fmin, float fmax, int nl, bool dispflx, bool refr)
+{
+  if (!mStL)  return;  
+  if (fmin < fmax)  { mFmin = fmin;  mFmax = fmax; }
+  else mStL->CalcFluxLimits(mFmin, mFmax);
+  if (mFmin < 1.e-10)  mFmin = 1.e-10;
+  if (mFmax <= mFmin)  mFmax = 1.5*mFmin;
+  mDLgF = log10((double)mFmax/(double)mFmin);
+  if (mDLgF < 1.e-10)  mDLgF = 1.e-10;
+  mF0 = mFmin;
+  if (nl < 1)  nl = 1;
+  if (nl > 20)  nl = 20;
+  mNLev = nl;  
+  mDspFV = dispflx;
+  if (refr)  Refresh();
+  return;
+}
+
+
+/* --Methode-- */
+void PIStarList::UpdateLimits()
+{
+  if (!mStL) return;
+
+  // Commencer par trouver nos limites
+  double dx, dy;
+  double x1, x2, y1, y2;
+  mStL->CalcXYLimits(x1, x2, y1, y2);
+  
+  dx = 0.02*(x2-x1);
+  dy = 0.02*(y2-y1);
+  
+  SetLimits(x1-dx, x2+dx, y1-dy, y2+dy); 
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+
+/* --Methode-- */
+void PIStarList::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+BStar *sti;
+double xp,yp;
+float flx;
+int sz;
+char buff[128];
+int nok, nl2;
+
+if (!mStL) return;
+
+int msz = mMSz;
+if (msz < 1) msz = 1;
+PIMarker mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_FCircleMarker;
+// g->SelFont();
+nok = 0;  nl2 = mNLev*2-1;
+for (int i=0; i<mStL->NbStars(); i++) {
+  sti = mStL->Star(i);
+  if ( !(sti->Nice(BStar::flagOK)) )  continue;
+  flx = sti->Flux();
+  if ( (flx < mFmin) || (flx > mFmax) )  continue;
+  xp = sti->PosX();   yp = sti->PosY();
+  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+  nok++;
+  sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + msz;
+  if (sz < 2)  g->SelMarker(sz, PI_DotMarker);
+  else g->SelMarker(sz, mrk);
+  g->DrawMarker((double)xp,(double)yp ); 
+  if (mDspFV) {  
+    sprintf(buff," F=%g", flx);
+    double dx,dy;
+    g->DGrC2UC(sz, 4, dx, dy);
+    g->DrawString(xp+dx, yp-dy, buff);
+    } 
+  }
+
+/*
+sprintf(buff, "StarList:  NbStars= %d  NDisp= %d", (int)mStL->NbStars(), nok);
+g->BaseGraphic()->DrawString(15,15,buff);
+sprintf(buff, "FMin= %g  FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0);
+g->BaseGraphic()->DrawString(15,30,buff);
+*/
+
+}
+
Index: /tags/DPC_V0/Poubelle/PIext/pistlist.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/pistlist.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/pistlist.h	(revision 1307)
@@ -0,0 +1,30 @@
+#ifndef PISTLIST_H
+#define PISTLIST_H
+
+#include "stlist.h"
+#include "pidrawer.h"
+
+class PIStarList : public PIDrawer {
+public:
+                     PIStarList(StarList* stl, bool ad);
+  virtual           ~PIStarList();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+  void               SetFluxLimits(float min=1., float max=-1., int nl=5, bool dispflx=false, bool refr=false);
+
+  inline StarList*   StList()  { return(mStL); }  
+  inline float       FluxMin() { return(mFmin); }       
+  inline float       FluxMax() { return(mFmax); }
+       
+protected:
+  StarList* mStL;
+  bool mAdDO;
+  float mFmin, mFmax;
+  int mNLev;
+  double mF0, mDLgF;
+  bool mDspFV;
+};
+
+#endif
Index: /tags/DPC_V0/Poubelle/PIext/servnobjm.cc
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/servnobjm.cc	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/servnobjm.cc	(revision 1307)
@@ -0,0 +1,799 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <iostream.h>
+#include <string>
+#include <list>
+#include <map>
+#if defined(__KCC__)
+using std::string ;
+#include <list.h>
+#include <map.h>
+#endif
+
+#include "strutil.h"
+#include "datatypes.h"
+
+#include "nobjmgr.h"
+#include "servnobjm.h"
+#include "pistdimgapp.h"
+
+#include "pclassids.h"
+#include "histos.h"
+#include "histos2.h"
+#include "ntuple.h"
+#include "hisprof.h"
+#include "generaldata.h"
+
+#include "cimage.h"
+#include "cvector.h"
+#include "matrix.h"
+
+//  Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
+#ifdef SANS_EVOLPLANCK 
+#include "stlist.h"
+#include "star.h"
+#endif
+
+
+/* --Methode-- */
+Services2NObjMgr::Services2NObjMgr(PIStdImgApp* app, string& tmpdir)
+{
+TmpDir = tmpdir;
+PDynLinkMgr::SetTmpDir(tmpdir);
+mImgapp = app;
+dynlink = NULL;
+InitGrAttNames();
+}
+  
+/* --Methode-- */
+Services2NObjMgr::~Services2NObjMgr()
+{
+CloseDLL();
+}
+
+/* --Methode-- */
+void Services2NObjMgr::Nobj_ComputeExpressions(PPersist* obj, string& expx, string& expy, string& expz, 
+                          string& expwt, string& expcut, NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
+{
+int cid = obj->ClassId();
+
+string vardec;
+switch (cid) {
+  case ClassId_Vector : 
+    vardec = "double i,val; \n";
+    vardec += "i = _zz61qq_[0];  val = _zz61qq_[1]; \n";
+    break;
+
+  case ClassId_Matrix : 
+    vardec = "double i,j,val; \n";
+    vardec += "i = _zz61qq_[0];  j = _zz61qq_[1];  val = _zz61qq_[2]; \n";
+    break;
+
+  case ClassId_Histo1D : 
+  case ClassId_HProf : 
+    vardec = "double i,x,val,err; \n";
+    vardec += "i = _zz61qq_[0];  x = _zz61qq_[1];  val = _zz61qq_[2];  err = _zz61qq_[3]; \n";
+    break;
+
+  case ClassId_Histo2D : 
+    vardec = "double i,j,x,y,val,err; \n";
+    vardec += "i = _zz61qq_[0];  j = _zz61qq_[1]; \n";  
+    vardec += "x = _zz61qq_[2];  y = _zz61qq_[3]; \n";  
+    vardec += "val = _zz61qq_[4]; err = _zz61qq_[5]; \n";
+    break;
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kr_8 : 
+  case ClassId_Image + kuint_4 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 : 
+    vardec = "double x,y,pix,i,j,val; \n";
+    vardec += "x = i = _zz61qq_[0];  y = j = _zz61qq_[1];  pix = val = _zz61qq_[2]; \n";
+    break;
+
+#ifdef SANS_EVOLPLANCK 
+  case ClassId_StarList : 
+    vardec = "double x,y,flux,fond; \n";
+    vardec += "x = _zz61qq_[0];  y = _zz61qq_[1];  flux = _zz61qq_[2];  fond =  _zz61qq_[3]; \n";
+    break;
+#endif
+
+  case ClassId_NTuple :
+    vardec = ((NTuple*)obj)->VarList_C("_zz61qq_");
+    break;
+
+  case ClassId_GeneralFitData :
+    vardec = ((GeneralFitData*)obj)->VarList_C("_zz61qq_");
+    break;
+
+  default :
+    cerr << "NamedObjMgr_ComputeExpressions() Error , N/A to " << PClassIdToClassName(cid) << endl; 
+    return;
+  }
+
+PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expwt, expcut);
+if (!f) { 
+  cerr << "NamedObjMgr_ComputeExpressions() Error Creation PlotExprFunc " <<  endl; 
+  return;
+  }
+
+float x[10], xnt[10];
+
+int i,j,k;
+for(i=0; i<10; i++) x[i] = xnt[i] = 0.;
+
+TRY {                                 
+switch (cid) {
+  case ClassId_Vector :
+    { 
+    Vector* vv = (Vector*)obj;
+    for(k=0; k<vv->NElts(); k++) {
+      x[0] = k;   x[1] = (*vv)(k);
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        if (h1) h1->Add(xnt[0], xnt[3]);
+        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
+        }
+      }
+    }
+    break;
+
+  case ClassId_Matrix : 
+    {
+    Matrix* mm = (Matrix*)obj;
+    for(j=0; j<mm->NCol(); j++)
+      for(i=0; i<mm->NRows(); i++) {
+      x[0] = i; x[1] = j;  x[2] = (*mm)(i,j);
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        if (h1) h1->Add(xnt[0], xnt[3]);
+        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
+        }
+      }
+    }
+    break;
+
+  case ClassId_Histo1D : 
+  case ClassId_HProf : 
+    {
+    Histo* hh = (Histo*)obj;
+    for(k=0; k<hh->NBins(); k++) {
+      x[0] = k;  x[1] = hh->BinCenter(k);   
+      x[2] = (*hh)(k);  x[3] = hh->Error(k);
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        if (h1) h1->Add(xnt[0], xnt[3]);
+        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
+        }
+      }
+    }
+    break;
+
+  case ClassId_Histo2D : 
+    {
+    Histo2D* hh = (Histo2D*)obj;
+    for(j=0; j<hh->NBinY(); j++)
+      for(i=0; i<hh->NBinX(); i++) {
+      x[0] = i;   x[1] = j; 
+      hh->BinCenter(i,j,x[2],x[3]); 
+      x[4] = (*hh)(i,j);  x[5] = hh->Error(i, j);
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        if (h1) h1->Add(xnt[0], xnt[3]);
+        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
+        }
+      }
+    }
+    break;
+
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kr_8 : 
+  case ClassId_Image + kuint_4 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 :
+    {
+    RzImage* img = (RzImage*)obj; 
+    for(j=0; j<img->YSize(); j++)
+      for(i=0; i<img->XSize(); i++) {
+        x[0] = i;  x[1] = j;  x[2] = img->FValue(i, j);
+        if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+          if (nt) nt->Fill(xnt);
+          if (h1) h1->Add(xnt[0], xnt[3]);
+          if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+          if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
+          }
+      }
+    }
+    break;
+
+#ifdef SANS_EVOLPLANCK 
+  case ClassId_StarList : 
+    {
+    StarList* stl = (StarList*)obj;
+    BStar *sti;
+    for(k=0; k<stl->NbStars(); k++) {
+      sti = stl->Star(k);
+      if ( (!sti) || !(sti->Nice(BStar::flagOK)) )  continue;
+      x[0] = sti->PosX();   x[1] = sti->PosY();
+      x[2] = sti->Flux();   x[3] =  sti->Fond();  
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        if (h1) h1->Add(xnt[0], xnt[3]);
+        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
+        }
+      }
+    }
+    break;
+#endif
+
+  case ClassId_NTuple :
+    {
+    NTuple* ntp = (NTuple*)obj;
+    r_4* xn;
+    for(k=0; k<ntp->NEntry(); k++)    {
+      xn = ntp->GetVec(k);
+      if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        if (h1) h1->Add(xnt[0], xnt[3]);
+        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
+        }
+      }
+    }
+    break;
+
+  case ClassId_GeneralFitData :
+    {
+    GeneralFitData* data = (GeneralFitData*)obj;
+    r_4* xn;
+    int iok = 2*data->NVar()+2;
+    for(k=0; k<data->NData(); k++) {
+      xn = data->GetVecR4(k);
+      if(xn[iok]<0.001) continue;
+      if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        if (h1) h1->Add(xnt[0], xnt[3]);
+        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
+      }
+    }
+    }
+    break;
+
+  default :
+    cout << "NamedObjMgr_ComputeExpressions() Erreur: N/A to  " << PClassIdToClassName(cid) << endl; 
+    return;
+  }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "NamedObjMgr_ComputeExpressions()  Exception :" << merr << es;
+  } ENDTRY;
+ 
+
+// Fermeture du fichier .so 
+CloseDLL();
+return;
+}
+
+
+/* --Methode-- */
+PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy, string& expz, 
+                                            string& expwt, string& cut)
+{
+FILE *fip;
+string fname = TmpDir + "expf_pia_dl.c";
+string fnamer = TmpDir + "expf_pia_dl";
+string cmd;
+int rc;
+
+cmd = "rm " + fname;
+rc = system(cmd.c_str());
+//DBG printf("LinkExprFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "NamedObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl; 
+  return(NULL); 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("int expf_pia_dl_func(float* _zz61qq_, float* _rx_61qq_, float* _ry_61qq_, float* _rz_61qq_, float* _wt_61qq_) \n{\n", fip);
+fprintf(fip,"%s \n", vardec.c_str());
+fprintf(fip, "if (!(%s)) { *_rx_61qq_ = *_ry_61qq_ = *_rz_61qq_ = *_wt_61qq_ = 0.;  return(0); } \n", cut.c_str());
+fprintf(fip, "*_rx_61qq_ = %s ; \n", expx.c_str());
+fprintf(fip, "*_ry_61qq_ = %s ; \n", expy.c_str());
+fprintf(fip, "*_rz_61qq_ = %s ; \n", expz.c_str());
+fprintf(fip, "*_wt_61qq_ = %s ; \n", expwt.c_str());
+fputs("return(1); \n} \n", fip);
+fclose(fip);
+
+return((PlotExprFunc)LinkFunctionFromFile(fnamer, "expf_pia_dl_func"));
+}
+
+
+/* --Methode-- */
+DlFunction Services2NObjMgr::LinkFunctionFromFile(string& fnamer, char* funcname)
+{
+string fname = fnamer + ".c" ;
+string fnameobj = fnamer + ".o" ;
+string fnameso = fnamer + ".so";
+
+//  Le link dynamique
+CloseDLL();
+dynlink = PDynLinkMgr::BuildFromCFile(fname);
+if (dynlink == NULL) { 
+  cerr << "NamedObjMgr/LinkFunctionFromFile_Erreur: Erreur ouverture SO " << endl; 
+  return(NULL); 
+  }
+
+DlFunction retfunc = dynlink->GetFunction(funcname);
+if (retfunc == NULL) { 
+  string sn = funcname; 
+  cerr << "NamedObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl; 
+  CloseDLL();
+  return(NULL); 
+  }
+else return(retfunc);
+}
+
+/* --Methode-- */
+void Services2NObjMgr::CloseDLL()
+{
+if (dynlink) delete dynlink;   dynlink = NULL;
+}
+
+/* --Methode-- */
+string Services2NObjMgr::FileName2Name(string const & fn)
+{
+
+char fsep[2] = {FILESEP, '\0'};
+char tsep[2] = {'.', '\0'};
+size_t p = fn.find_last_of(fsep);
+size_t l = fn.length();
+if (p >= l)  p = 0;
+else p++;
+size_t q = fn.find_first_of(tsep,p);
+if (q < p) q = l;
+return(fn.substr(p,q-p));
+}
+
+
+typedef vector<string> GraTok;
+
+/* --Methode-- */
+int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
+{
+int ropt = Disp_Next;
+if (!mImgapp)  return(ropt); 
+
+for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
+
+if (fgsrgr) mImgapp->SaveGraphicAtt();
+
+if (gratt.substr(0,3) == "def")  {  // Remise aux valeurs par defaut = non defini
+  mImgapp->SetColAtt();
+  mImgapp->SetLineAtt();
+  mImgapp->SetFontAtt();
+  mImgapp->SetMarkerAtt();
+  mImgapp->SetColMapId();
+  mImgapp->SetZoomAtt();
+  return(ropt);
+  }
+
+// On separe en mots separes par des virgules 
+gratt = ","+gratt;
+size_t p = 0;
+size_t q = 0;
+size_t l = gratt.length();
+string token;
+
+GraTok grt;
+
+while (q < l)  {
+  p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
+  if (p>=l) break;
+  q = gratt.find_first_of(" ,",p); // la fin du token;
+  token = gratt.substr(p,q-p);
+  grt.push_back(token);
+  }
+
+
+static GrAttNames::iterator it;
+
+int k; 
+bool fgcont = true;
+fgsrgr = false;
+
+for(k=0; k<grt.size(); k++) {
+//  cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
+
+ // Decodage option affichage (win, next, etc 
+  fgcont = true;
+  if ( (grt[k] == "win") || (grt[k] == "w") )  ropt =  Disp_Win;
+  else if ( (grt[k] == "same") || (grt[k] == "s") )  ropt = Disp_Same;
+  else  if ( (grt[k] == "stack") || (grt[k] == "st") )  ropt = Disp_Stack;
+  else fgcont = false;
+  if (fgcont)   continue;
+  
+  // Si c'est une couleur
+  it = GrAcolors.find(grt[k]);
+  if (it != GrAcolors.end())  { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
+  // Si c'est un attribut de lignes
+  it = GrAlines.find(grt[k]);
+  if (it != GrAlines.end())  { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1));  fgsrgr = true; continue; }
+  // Si c'est un attribut de fontes
+  it = GrAfonts.find(grt[k]);
+  if (it != GrAfonts.end())  { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) ); 
+                               fgsrgr = true;  continue; }
+  // Si c'est un attribut de markers
+  it = GrAmarkers.find(grt[k]);
+  if (it != GrAmarkers.end())  { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) ); 
+                                 fgsrgr = true;  continue; }
+  // Si c'est un colormap
+  it = GrAcmap.find(grt[k]);
+  if (it != GrAcmap.end())  { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }  
+  // Si c'est un facteur de zoom
+  it = GrAzoom.find(grt[k]);
+  if (it != GrAzoom.end())  { mImgapp->SetZoomAtt( (*it).second.a1 );  fgsrgr = true; continue; }  
+  // Si c'est un attribut d'axe
+  it = GrAaxes.find(grt[k]);
+  if (it != GrAaxes.end())  { mImgapp->SetAxesAtt( (*it).second.a1 );  fgsrgr = true; continue; }  
+  
+  }  
+
+return(ropt);
+}
+
+/* --Methode-- */
+char* Services2NObjMgr::PClassIdToClassName(int cid)
+{
+switch (cid) {
+  case ClassId_Poly1 : 
+    return("Poly1");
+  case ClassId_Poly2 : 
+    return("Poly2");
+  case ClassId_Matrix : 
+    return("Matrix");
+  case ClassId_Vector : 
+    return("Vector");
+
+  case ClassId_DVList : 
+    return("DVList");
+
+  case ClassId_Histo1D : 
+    return("Histo1D");
+  case ClassId_Histo2D : 
+    return("Histo2D");
+  case ClassId_HProf : 
+    return("HProf");
+  case ClassId_NTuple : 
+    return("NTuple");
+  case ClassId_GeneralFitData : 
+    return("GeneralFitData");
+
+  case ClassId_Image : 
+    return("RzImage");
+  case ClassId_Image + kuint_1 : 
+    return("ImageU1");
+  case ClassId_Image + kint_1 : 
+    return("ImageI1");
+  case ClassId_Image + kuint_2 : 
+    return("ImageU2");
+  case ClassId_Image + kint_2 : 
+    return("ImageI2");
+  case ClassId_Image + kuint_4 : 
+    return("ImageU4");
+  case ClassId_Image + kint_4 : 
+    return("ImageI4");
+  case ClassId_Image + kr_4 : 
+    return("ImageR4");
+  case ClassId_Image + kr_8 : 
+    return("ImageR8");
+
+  case ClassId_ZFidu : 
+    return("ZFidu");
+
+#ifdef SANS_EVOLPLANCK 
+  case ClassId_StarList : 
+    return("StarList");
+  case ClassId_Transfo : 
+    return("Transfo");
+  case ClassId_PSF : 
+    return("PSF");
+
+  case ClassId_Star + BStar_Type : 
+    return("BStar");
+  case ClassId_Star + RzStar_Type : 
+    return("RzStar");
+  case ClassId_Star + PSFStar_Type : 
+    return("PSFStar");
+  case ClassId_Star + MCStar_Type : 
+    return("MCStar");
+  case ClassId_Star + CircRFixStar_Type : 
+    return("CircRFixStar");
+  case ClassId_Star + PSFDHStar_Type : 
+    return("PSFDHStar");
+  case ClassId_Star + PSFSEStar_Type : 
+    return("PSFSEStar");
+  case ClassId_Star + MCDHStar_Type : 
+    return("MCDHStar");
+#endif
+
+// - Ajout objet PPF
+  default:
+    return("Unknown");
+  }
+}  
+
+/* --Methode-- */
+char* Services2NObjMgr::PClassIdToShortClassName(int cid)
+{
+switch (cid) {
+  case ClassId_Poly1 : 
+  case ClassId_Poly2 : 
+    return("Poly");
+  case ClassId_Matrix : 
+    return("Mtx");
+  case ClassId_Vector : 
+    return("Vec");
+  case ClassId_DVList : 
+    return("Dvl");
+
+  case ClassId_Histo1D : 
+    return("H1D");
+  case ClassId_Histo2D : 
+    return("H2D");
+  case ClassId_HProf : 
+    return("HPF");
+  case ClassId_NTuple : 
+    return("NT");
+  case ClassId_GeneralFitData : 
+    return("GFD");
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kuint_4 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 : 
+  case ClassId_Image + kr_8 : 
+    return("Img");
+
+  case ClassId_ZFidu : 
+    return("Fidu");
+
+#ifdef SANS_EVOLPLANCK 
+  case ClassId_StarList : 
+    return("Stl");
+  case ClassId_Transfo : 
+    return("Tr");
+  case ClassId_PSF : 
+    return("PSF");
+
+  case ClassId_Star + BStar_Type : 
+  case ClassId_Star + RzStar_Type : 
+  case ClassId_Star + PSFStar_Type : 
+  case ClassId_Star + MCStar_Type : 
+  case ClassId_Star + CircRFixStar_Type : 
+  case ClassId_Star + PSFDHStar_Type : 
+  case ClassId_Star + PSFSEStar_Type : 
+  case ClassId_Star + MCDHStar_Type : 
+    return("Star");
+#endif
+
+// - Ajout objet PPF
+  default:
+    return("U");
+  }
+}  
+
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// Initialisation des chaines de caracteres designant les attributs graphiques 
+
+/* --Methode-- */
+void Services2NObjMgr::InitGrAttNames()
+{
+gratt_item gi;
+// Les couleurs
+gi.a2 = 0;
+gi.a1 = PI_NotDefColor;
+GrAcolors["defcol"] = gi;
+gi.a1 = PI_Black;
+GrAcolors["black"] = gi;
+gi.a1 = PI_White;
+GrAcolors["white"] = gi;
+gi.a1 = PI_Grey;
+GrAcolors["grey"] = gi;
+gi.a1 = PI_Red;
+GrAcolors["red"] = gi;
+gi.a1 = PI_Blue;
+GrAcolors["blue"] = gi;
+gi.a1 = PI_Green;
+GrAcolors["green"] = gi;
+gi.a1 = PI_Yellow;
+GrAcolors["yellow"] = gi;
+gi.a1 = PI_Magenta;
+GrAcolors["magenta"] = gi;
+
+gi.a1 = PI_Cyan;
+GrAcolors["cyan"] = gi;
+gi.a1 = PI_Turquoise;
+GrAcolors["turquoise"] = gi;
+gi.a1 = PI_NavyBlue;
+GrAcolors["navyblue"] = gi;
+gi.a1 = PI_Orange;
+GrAcolors["orange"] = gi;
+gi.a1 = PI_SiennaRed;
+GrAcolors["siennared"] = gi;
+gi.a1 = PI_Purple;
+GrAcolors["purple"] = gi;
+gi.a1 = PI_LimeGreen;
+GrAcolors["limegreen"] = gi;
+gi.a1 = PI_Gold;
+GrAcolors["gold"] = gi;
+
+// Les attributs de lignes
+gi.a2 = 0;
+gi.a1 = PI_NotDefLineAtt;
+GrAlines["defline"] = gi;
+gi.a1 = PI_NormalLine;
+GrAlines["normalline"] = gi;
+gi.a1 = PI_ThinLine;
+GrAlines["thinline"] = gi;
+gi.a1 = PI_ThickLine;
+GrAlines["thickline"] = gi;
+gi.a1 = PI_DashedLine;
+GrAlines["dashedline"] = gi;
+gi.a1 = PI_ThinDashedLine;
+GrAlines["thindashedline"] = gi;
+gi.a1 = PI_ThickDashedLine;
+GrAlines["thickdashedline"] = gi;
+gi.a1 = PI_DottedLine;
+GrAlines["dottedline"] = gi;
+gi.a1 = PI_ThinDottedLine;
+GrAlines["thindottedline"] = gi;
+gi.a1 = PI_ThickDottedLine;
+GrAlines["thickdottedline"] = gi;
+
+// Les fontes (a faire)
+gi.a2 = PI_NotDefFontSize;
+gi.a1 = PI_NotDefFontAtt;
+GrAlines["deffont"] = gi;
+
+gi.a2 = PI_NormalSizeFont;
+gi.a1 = PI_RomanFont;
+GrAlines["normalfont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAlines["boldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAlines["italicfont"] = gi;
+gi.a2 = PI_SmallSizeFont;
+gi.a1 = PI_RomanFont;
+GrAlines["smallfont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAlines["smallboldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAlines["smallitalicfont"] = gi;
+gi.a2 = PI_BigSizeFont;
+gi.a1 = PI_RomanFont;
+GrAlines["bigfont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAlines["bigboldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAlines["bigitalicfont"] = gi;
+gi.a2 = PI_HugeSizeFont;
+gi.a1 = PI_RomanFont;
+GrAlines["hugefont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAlines["hugeboldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAlines["hugeitalicfont"] = gi;
+
+
+// Les markers 
+const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker", 
+                         "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker", 
+                         "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
+PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker, 
+                     PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker, 
+                     PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
+
+gi.a2 = 0;
+gi.a1 = PI_NotDefMarker;
+GrAmarkers["defmarker"] = gi;
+ 
+for(int j=0; j<11; j++) {
+  string smrk;
+  char buff[16];
+  for(int m=1; m<10; m+=2) {
+    sprintf(buff,"%d",m);
+    smrk = (string)mrkn[j] + (string)buff;
+    gi.a1 = mrk[j];  gi.a2 = m;
+    GrAmarkers[smrk] = gi;
+    }
+  }
+
+// Les tables de couleurs 
+gi.a2 = 0;
+gi.a1 = CMAP_OTHER;
+GrAcmap["defcmap"] = gi;
+gi.a1 = CMAP_GREY32;
+GrAcmap["grey32"] = gi;
+gi.a1 = CMAP_GREYINV32;
+GrAcmap["greyinv32"] = gi;
+gi.a1 = CMAP_COLRJ32;
+GrAcmap["colrj32"] = gi;
+gi.a1 = CMAP_COLBR32;
+GrAcmap["colbr32"] = gi;
+gi.a1 = CMAP_GREY128;
+GrAcmap["grey128"] = gi;
+gi.a1 = CMAP_GREYINV128;
+GrAcmap["greyinv128"] = gi;
+gi.a1 = CMAP_COLRJ128;
+GrAcmap["colrj128"] = gi;
+gi.a1 = CMAP_COLBR128;
+GrAcmap["colbr128"] = gi;
+
+// La valeur de zoom
+gi.a2 = 0;
+gi.a1 = 0;
+GrAzoom["defzoom"] = gi;
+gi.a1 = 1;
+GrAzoom["zoomx1"] = gi;
+gi.a1 = 2;
+GrAzoom["zoomx2"] = gi;
+gi.a1 = 3;
+GrAzoom["zoomx3"] = gi;
+gi.a1 = 4;
+GrAzoom["zoomx4"] = gi;
+gi.a1 = 5;
+GrAzoom["zoomx5"] = gi;
+gi.a1 = -2;
+GrAzoom["zoom/2"] = gi;
+gi.a1 = -3;
+GrAzoom["zoom/3"] = gi;
+gi.a1 = -4;
+GrAzoom["zoom/4"] = gi;
+gi.a1 = -5;
+GrAzoom["zoom/5"] = gi;
+
+// Attributs d'axes
+gi.a2 = 0;
+gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
+GrAaxes["stdaxes"] = gi;
+GrAaxes["defaxes"] = gi;
+GrAaxes["boxaxes"] = gi;
+gi.a1 = (int)kAxesDflt;
+GrAaxes["simpleaxes"] = gi;
+gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
+GrAaxes["boxaxesgrid"] = gi;
+
+gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
+GrAaxes["fineaxes"] = gi;
+ gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
+GrAaxes["grid"] = gi;
+GrAaxes["fineaxesgrid"] = gi;
+                
+}
Index: /tags/DPC_V0/Poubelle/PIext/servnobjm.h
===================================================================
--- /tags/DPC_V0/Poubelle/PIext/servnobjm.h	(revision 1307)
+++ /tags/DPC_V0/Poubelle/PIext/servnobjm.h	(revision 1307)
@@ -0,0 +1,69 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe de services destinee a NamedObjMgr pour piapp
+// Reza                             Aout 98
+// CEA-DAPNIA      LAL-IN2P3/CNRS
+
+#ifndef SERVNOBJM_H_SEEN
+#define SERVNOBJM_H_SEEN
+
+#include "defs.h"
+#include <string>
+
+#include "ctimer.h"
+
+#include "pdlmgr.h"
+#include "dlftypes.h"
+
+class NTuple;
+class Histo;
+class Histo2D;
+class HProf;
+class PIStdImgApp;
+
+class Services2NObjMgr {
+public:
+         	Services2NObjMgr(PIStdImgApp* app, string& tmpdir);
+		~Services2NObjMgr();
+
+  inline void   SetImgApp(PIStdImgApp* app) {mImgapp = app; }
+
+  void 		Nobj_ComputeExpressions(PPersist* obj, string& expx, string& expy, string& expz, 
+                                        string& expwt, string& expcut,
+                                        NTuple* nt=NULL, Histo* h1=NULL,
+                                        Histo2D* h2=NULL, HProf* hp=NULL);
+  PlotExprFunc  LinkExprFunc(string& vardec, string& expx, string& expy, string& expz, 
+                             string& wt, string& cut);
+  DlFunction    LinkFunctionFromFile(string& fnamer, char* funcname);
+  void 		CloseDLL();  
+
+  char* 	PClassIdToClassName(int cid);
+  char* 	PClassIdToShortClassName(int cid);
+  string 	FileName2Name(string const & fn);
+  int 		DecodeDispOption(string& dopt, bool& fgsrgr);
+
+  void 		InitGrAttNames();
+
+//   Variables membre , en public pour le moment
+  struct gratt_item {
+    int a1, a2;
+  };
+  typedef map<string, gratt_item, less<string> > GrAttNames;
+
+//  Pour les changements d'attributs graphiques / de visualisation
+  GrAttNames GrAcolors;
+  GrAttNames GrAlines;
+  GrAttNames GrAmarkers;
+  GrAttNames GrAfonts;
+  GrAttNames GrAcmap;  
+  GrAttNames GrAzoom;  
+  GrAttNames GrAaxes;  
+
+  PDynLinkMgr * dynlink;  // shared-lib lib.so
+  string TmpDir;          // Pour fichiers temporaires
+
+  PIStdImgApp* mImgapp;
+  
+};
+
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/Blitz.o.list
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/Blitz.o.list	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/Blitz.o.list	(revision 1307)
@@ -0,0 +1,1 @@
+globals.o
Index: /tags/DPC_V0/SophyaExt/Blitz/GNUmakefile
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/GNUmakefile	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/GNUmakefile	(revision 1307)
@@ -0,0 +1,13 @@
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libBlitz.a
+clean:
+	rm -f $(OBJ)globals.o
+	rm $(LIB)libBlitz.a
+$(LIB)libBlitz.a : $(OBJ)globals.o
+	$(AR) $(ARFLAGS) $@ $?
+ifeq ($(CXX),cxx)
+	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS) -L$(LIB) -lBlitz -lSysTools -o $(OBJ)xx.x -Hf
+endif 
+ 
+$(OBJ)globals.o: globals.cc
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/applics.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/applics.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/applics.h	(revision 1307)
@@ -0,0 +1,394 @@
+/***************************************************************************
+ * blitz/applics.h      Applicative template classes
+ *
+ * $Id: applics.h,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com    
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_APPLICS_H
+#define BZ_APPLICS_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_PROMOTE_H
+ #include <blitz/promote.h>
+#endif
+
+#ifndef BZ_NUMTRAIT_H
+ #include <blitz/numtrait.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// These base classes are included for no other reason than to keep
+// the applicative templates clustered together in a graphical
+// class browser.
+class ApplicativeTemplatesBase { };
+class TwoOperandApplicativeTemplatesBase : public ApplicativeTemplatesBase { };
+class OneOperandApplicativeTemplatesBase : public ApplicativeTemplatesBase { };
+
+template<class P_numtype1, class P_numtype2>
+class _bz_Add : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote; 
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x + y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_Subtract : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote;
+    typedef T_promote  T_numtype;
+ 
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x - y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_Multiply : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x * y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_Divide : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x / y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_Mod : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x % y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_BitwiseXOR : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x ^ y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_BitwiseAnd : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x & y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_BitwiseOr : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x | y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_ShiftRight : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x >> y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_ShiftLeft : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1,T_numtype2) T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x << y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_Greater : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef _bz_bool   T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x > y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_Less : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef _bz_bool   T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x < y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_GreaterOrEqual : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef _bz_bool   T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x >= y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_LessOrEqual : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef _bz_bool   T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x <= y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_Equal : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef _bz_bool   T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x == y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_NotEqual : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef _bz_bool   T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x != y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_LogicalAnd : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef _bz_bool   T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x && y; }
+};
+
+template<class P_numtype1, class P_numtype2>
+class _bz_LogicalOr : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef _bz_bool   T_promote;
+    typedef T_promote  T_numtype;
+
+    static inline T_promote apply(P_numtype1 x, P_numtype2 y)
+    { return x || y; }
+};
+
+template<class P_numtype_in, class P_numtype_out>
+class _bz_Cast : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype_in T_numtype1;
+    typedef P_numtype_out T_promote;
+    typedef T_promote     T_numtype;
+
+    static inline P_numtype_out apply(P_numtype_in x)
+    { return P_numtype_out(x); }
+};
+
+template<class P_numtype>
+class _bz_LogicalNot : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype     T_numtype1;
+    typedef _bz_bool      T_promote;
+    typedef T_promote     T_numtype;
+
+    static inline P_numtype apply(P_numtype x)
+    { return !x; }
+};
+
+template<class P_numtype>
+class _bz_BitwiseNot : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype     T_numtype1;
+    typedef T_numtype1    T_promote;
+    typedef T_promote     T_numtype;
+
+    static inline P_numtype apply(P_numtype x)
+    { return ~x; }
+};
+
+/*****************************************************************************
+ * Math Functions
+ *****************************************************************************/
+
+// Applicative templates for these functions are defined in
+// <blitz/mathfunc.h>, which is included below:
+//
+// abs(i), labs(l)                     Absolute value
+// acos(d), acols(ld)                  Inverse cosine
+// acosh(d)                            Inverse hyperbolic cosine
+// asin(d), asinl(ld)                  Inverse sine
+// asinh(d)                            Inverse hyperbolic sine
+// atan(d), atanl(ld)                  Inverse tangent
+// atan2(d,d), atan2l(ld,ld)           Inverse tangent
+// atanh(d)                            Inverse hyperbolic tangent
+// cbrt(x)                             Cube root
+// ceil(d), ceill(ld)                  Smallest f-int not less than x
+// int class(d)                        Classification of x (FP_XXXXX)
+// cos(d), cosl(ld)                    Cosine
+// cosh(d), coshl(ld)                  Hyperbolic cosine
+// copysign(d,d)                       Return 1st arg with same sign as 2nd
+// drem(x,x)                           IEEE remainder
+// exp(d), expl(ld)                    Exponential
+// expm1(d)                            Exp(x)-1     
+// erf(d), erfl(ld)                    Error function
+// erfc(d), erfcl(ld)                  Complementary error function
+// fabs(d), fabsl(ld)                  Floating point absolute value
+// int finite(d)                       Nonzero if finite
+// floor(d), floor(ld)                 Largest f-int not greater than x
+// fmod(d,d), fmodl(ld,ld)             Floating point remainder
+// frexp(d, int* e)                    Break into mantissa/exponent  (*)
+// frexpl(ld, int* e)                  Break into mantissa/exponent  (*)
+// gammaFunc(d)                        Gamma function (** needs special 
+//                                     implementation using lgamma)
+// hypot(d,d)                          Hypotenuse: sqrt(x*x+y*y)
+// int ilogb(d)                        Integer unbiased exponent
+// int isnan(d)                        Nonzero if NaNS or NaNQ
+// int itrunc(d)                       Truncate and convert to integer
+// j0(d)                               Bessel function first kind, order 0
+// j1(d)                               Bessel function first kind, order 1
+// jn(int, double)                     Bessel function first kind, order i
+// ldexp(d,i), ldexpl(ld,i)            Compute d * 2^i
+// lgamma(d), lgammald(ld)             Log absolute gamma
+// log(d), logl(ld)                    Natural logarithm
+// logb(d)                             Unbiased exponent (IEEE)
+// log1p(d)                            Compute log(1 + x)
+// log10(d), log10l(ld)                Logarithm base 10
+// modf(d, int* i), modfl(ld, int* i)  Break into integral/fractional part
+// double nearest(double)              Nearest floating point integer
+// nextafter(d, d)                     Next representable neighbor of 1st
+//                                     in direction of 2nd
+// pow(d,d), pow(ld,ld)                Computes x ^ y
+// d remainder(d,d)                    IEEE remainder
+// d rint(d)                           Round to f-integer (depends on mode)
+// d rsqrt(d)                          Reciprocal square root
+// d scalb(d,d)                        Return x * (2^y)
+// sin(d), sinl(ld)                    Sine 
+// sinh(d), sinhl(ld)                  Hyperbolic sine
+// sqr(x)                              Return x * x
+// sqrt(d), sqrtl(ld)                  Square root
+// tan(d), tanl(ld)                    Tangent
+// tanh(d), tanhl(ld)                  Hyperbolic tangent
+// trunc(d)                            Nearest f-int in the direction of 0
+// unsigned uitrunc(d)                 Truncate and convert to unsigned
+// int unordered(d,d)                  Nonzero if comparison is unordered
+// y0(d)                               Bessel function 2nd kind, order 0
+// y1(d)                               Bessel function 2nd kind, order 1
+// yn(i,d)                             Bessel function 2nd kind, order d
+
+
+BZ_NAMESPACE_END
+
+#ifndef BZ_MATHFUNC_H
+ #include <blitz/mathfunc.h>
+#endif
+
+#ifndef BZ_MATHF2_H
+ #include <blitz/mathf2.h>
+#endif
+
+#endif // BZ_APPLICS_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array.h	(revision 1307)
@@ -0,0 +1,2531 @@
+/***************************************************************************
+ * blitz/array.h      Declaration of the Array<P_numtype, N_rank> class
+ *
+ * $Id: array.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+/*
+ * Wish list for array classes.
+ *  - Arrays whose dimensions are unknown at compile time.
+ *  - where()/elsewhere()/elsewhere() as in Dan Quinlan's implementation
+ *  - block reduction operations
+ *  - conversion to/from matrix & vector
+ *  - apply(T func(T))
+ *  - apply(T func(const T&))
+ *  - apply<T func(T)>
+ */
+
+#ifndef BZ_ARRAY_H
+#define BZ_ARRAY_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_MEMBLOCK_H
+ #include <blitz/memblock.h>
+#endif
+
+#ifndef BZ_RANGE_H
+ #include <blitz/range.h>
+#endif
+
+#ifndef BZ_TINYVEC_H
+ #include <blitz/tinyvec.h>
+#endif
+
+#ifndef BZ_TRAVERSAL_H
+ #include <blitz/traversal.h>
+#endif
+
+#ifndef BZ_INDEXEXPR_H
+ #include <blitz/indexexpr.h>
+#endif
+
+#ifndef BZ_PRETTYPRINT_H
+ #include <blitz/prettyprint.h>
+#endif
+
+#include <blitz/array/slice.h>     // Subarrays and slicing
+#include <blitz/array/map.h>       // Tensor index notation
+#include <blitz/array/multi.h>     // Multicomponent arrays
+#include <blitz/array/domain.h>    // RectDomain class
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * Forward declarations
+ */
+
+template<class T_numtype, int N_rank>
+class ArrayIterator;
+
+template<class P_expr>
+class _bz_ArrayExpr;
+
+#ifdef BZ_NEW_EXPRESSION_TEMPLATES
+template<class T>
+class ETBase { };
+#endif
+
+template<class T_array, class T_index>
+class IndirectArray;
+
+/*
+ * Declaration of class GeneralStorage<N_rank>
+ *
+ * This class describes a storage format for an N-dimensional array.
+ * The dimensions can be stored in an arbitrary order (for example, as
+ * a C-style row major array or Fortran-style column major array, or
+ * something else entirely).  Each dimension can be stored in either
+ * ascending (the most common) or descending order.  Each dimension
+ * can have its own base (starting index value: e.g. 0 for C-style arrays, 
+ * 1 for Fortran arrays).
+ *
+ * GeneralArrayStorage<N> defaults to C-style arrays.  To implement
+ * other storage formats, subclass and modify the constructor.  The
+ * class FortranArray, below, is an example.
+ *
+ * Objects inheriting from GeneralArrayStorage<N> can be passed as
+ * an optional constructor argument to Array objects.
+ * e.g. Array<int,3> A(16,16,16, FortranArray<3>());
+ * will create a 3-dimensional 16x16x16 Fortran-style array.
+ */
+
+template<int N_rank>
+class GeneralArrayStorage {
+public:
+    class noInitializeFlag { };
+
+    GeneralArrayStorage(noInitializeFlag)
+    { }
+
+    GeneralArrayStorage()
+    {
+        ordering_ = Range(N_rank - 1, 0, -1);
+        ascendingFlag_ = 1;
+        base_ = 0;
+    }
+
+    GeneralArrayStorage(const GeneralArrayStorage<N_rank>& x)
+        : ordering_(x.ordering_), ascendingFlag_(x.ascendingFlag_),
+          base_(x.base_)
+    { 
+    }
+
+    ~GeneralArrayStorage()
+    { }
+
+    TinyVector<int, N_rank>& ordering()
+    { return ordering_; }
+
+    const TinyVector<int, N_rank>& ordering() const
+    { return ordering_; }
+
+    int ordering(int i) const
+    { return ordering_[i]; }
+
+    void setOrdering(int i, int order) 
+    { ordering_[i] = order; }
+
+    _bz_bool allRanksStoredAscending() const
+    {
+        _bz_bool result = _bz_true;
+        for (int i=0; i < N_rank; ++i)
+            result &= ascendingFlag_[i];
+        return result;
+    }
+
+    _bz_bool isRankStoredAscending(int i) const
+    { return ascendingFlag_[i]; }
+
+    TinyVector<bool, N_rank>& ascendingFlag() 
+    { return ascendingFlag_; }
+
+    const TinyVector<bool, N_rank>& ascendingFlag() const
+    { return ascendingFlag_; }
+
+    void setAscendingFlag(int i, int ascendingFlag) 
+    { ascendingFlag_[i] = ascendingFlag; }
+
+    TinyVector<int, N_rank>& base()
+    { return base_; }
+
+    const TinyVector<int, N_rank>& base() const
+    { return base_; }
+
+    int base(int i) const
+    { return base_[i]; }
+
+    void setBase(int i, int base)
+    { base_[i] = base; }
+
+    void setBase(const TinyVector<int, N_rank>& base)
+    { base_ = base; }
+
+protected:
+    /*
+     * ordering_[] specifies the order in which the array is stored in
+     * memory.  For a newly allocated array, ordering_(0) will give the
+     * rank with unit stride, and ordering_(N_rank-1) will be the rank
+     * with largest stride.  An order like [2, 1, 0] corresponds to
+     * C-style array storage; an order like [0, 1, 2] corresponds to
+     * Fortran array storage.
+     *
+     * ascendingFlag_[] indicates whether the data in a rank is stored
+     * in ascending or descending order.  Most of the time these values
+     * will all be true (indicating ascending order).  Some peculiar 
+     * formats (e.g. MS-Windows BMP image format) store the data in 
+     * descending order.
+     *  
+     * base_[] gives the first valid index for each rank.  For a C-style
+     * array, all the base_ elements will be zero; for a Fortran-style
+     * array, they will be one.  base_[] can be set arbitrarily using
+     * the Array constructor which takes a Range argument, e.g.
+     * Array<float,2> A(Range(30,40),Range(23,33));
+     * will create an array with base_[] = { 30, 23 }.
+     */
+    TinyVector<int,  N_rank> ordering_;
+    TinyVector<bool, N_rank> ascendingFlag_;
+    TinyVector<int,  N_rank> base_;
+};
+
+/*
+ * Class FortranArray specializes GeneralArrayStorage to provide Fortran
+ * style arrays (column major ordering, base of 1).  The noInitializeFlag()
+ * passed to the base constructor indicates that the subclass will take
+ * care of initializing the ordering_, ascendingFlag_ and base_ members.
+ */
+
+template<int N_rank>
+class FortranArray : public GeneralArrayStorage<N_rank> {
+public:
+    FortranArray()
+        : GeneralArrayStorage<N_rank>(noInitializeFlag())
+    {
+        ordering_ = Range(0, N_rank - 1);
+        ascendingFlag_ = 1;
+        base_ = 1;
+    }
+};
+
+/*
+ * Class ColumnMajorArray specializes GeneralArrayStorage to provide column
+ * major arrays (column major ordering, base of 0).
+ */
+
+template<int N_rank>
+class ColumnMajorArray : public GeneralArrayStorage<N_rank> {
+public:
+    ColumnMajorArray()
+        : GeneralArrayStorage<N_rank>(noInitializeFlag())
+    {
+        ordering_ = Range(0, N_rank - 1);
+        ascendingFlag_ = 1;
+        base_ = 0;
+    }
+};
+
+/*
+ * Declaration of class Array
+ */
+
+// NEEDS_WORK: Array should inherit protected from MemoryBlockReference.
+// To make this work, need to expose MemoryBlockReference::numReferences()
+// and make Array<P,N2> a friend of Array<P,N> for slicing.
+
+template<class P_numtype, int N_rank>
+class Array : public MemoryBlockReference<P_numtype> 
+#ifdef BZ_NEW_EXPRESSION_TEMPLATES
+    , public ETBase<Array<P_numtype,N_rank> >
+#endif
+{
+
+public:
+    //////////////////////////////////////////////
+    // Public Types
+    //////////////////////////////////////////////
+
+    /*
+     * T_numtype  is the numeric type stored in the array.
+     * T_index    is a vector type which can be used to access elements
+     *            of many-dimensional arrays.
+     * T_array    is the array type itself -- Array<T_numtype, N_rank>
+     * T_iterator is an iterator for the array.
+     */
+
+    typedef P_numtype                T_numtype;
+    typedef TinyVector<int, N_rank>  T_index;
+    typedef Array<T_numtype, N_rank> T_array;
+    typedef ArrayIterator<T_numtype, N_rank> T_iterator;
+
+    enum { _bz_rank = N_rank };
+
+    //////////////////////////////////////////////
+    // Constructors                             //
+    //////////////////////////////////////////////
+
+    
+    /*
+     * Construct an array from an array expression.
+     */
+
+    template<class T_expr>
+    Array(_bz_ArrayExpr<T_expr> expr);
+
+    /*
+     * Any missing length arguments will have their value taken from the
+     * last argument.  For example,
+     *   Array<int,3> A(32,64);
+     * will create a 32x64x64 array.  This is handled by setupStorage().
+     */
+
+    Array(GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        length_ = 0;
+        stride_ = 0;
+        zeroOffset_ = 0;
+        storageContiguous_ = false;
+    }
+
+    _bz_explicit Array(int length0, 
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        length_[0] = length0;
+        setupStorage(0);
+    }
+
+    Array(int length0, int length1,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 2);
+        TAU_TYPE_STRING(p1, "Array<T,N>::Array() [T="
+            + CT(T_numtype) + ",N=" + CT(N_rank) + "]");
+        TAU_PROFILE(p1, "void (int,int)", TAU_BLITZ);
+
+        length_[0] = length0;
+        length_[1] = length1;
+        setupStorage(1);
+    }
+
+    Array(int length0, int length1, int length2,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 3);
+        length_[0] = length0;
+        length_[1] = length1;
+        length_[2] = length2;
+        setupStorage(2);
+    }
+
+    Array(int length0, int length1, int length2, int length3,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 4);
+        length_[0] = length0;
+        length_[1] = length1;
+        length_[2] = length2;
+        length_[3] = length3;
+        setupStorage(3);
+    }
+
+    Array(int length0, int length1, int length2, int length3, int length4,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 5);
+        length_[0] = length0;
+        length_[1] = length1;
+        length_[2] = length2;
+        length_[3] = length3;
+        length_[4] = length4;
+        setupStorage(4);
+    }
+
+    Array(int length0, int length1, int length2, int length3, int length4,
+        int length5,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 6);
+        length_[0] = length0;
+        length_[1] = length1;
+        length_[2] = length2;
+        length_[3] = length3;
+        length_[4] = length4;
+        length_[5] = length5;
+        setupStorage(5);
+    }
+
+    Array(int length0, int length1, int length2, int length3, int length4,
+        int length5, int length6,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 7);
+        length_[0] = length0;
+        length_[1] = length1;
+        length_[2] = length2;
+        length_[3] = length3;
+        length_[4] = length4;
+        length_[5] = length5;
+        length_[6] = length6;
+        setupStorage(6);
+    }
+
+    Array(int length0, int length1, int length2, int length3, int length4,
+        int length5, int length6, int length7,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 8);
+        length_[0] = length0;
+        length_[1] = length1;
+        length_[2] = length2;
+        length_[3] = length3;
+        length_[4] = length4;
+        length_[5] = length5;
+        length_[6] = length6;
+        length_[7] = length7;
+        setupStorage(7);
+    }
+
+    Array(int length0, int length1, int length2, int length3, int length4,
+        int length5, int length6, int length7, int length8,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 9);
+        length_[0] = length0;
+        length_[1] = length1;
+        length_[2] = length2;
+        length_[3] = length3;
+        length_[4] = length4;
+        length_[5] = length5;
+        length_[6] = length6;
+        length_[7] = length7;
+        length_[8] = length8;
+        setupStorage(8);
+    }
+
+    Array(int length0, int length1, int length2, int length3, int length4,
+        int length5, int length6, int length7, int length8, int length9,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 10);
+        length_[0] = length0;
+        length_[1] = length1;
+        length_[2] = length2;
+        length_[3] = length3;
+        length_[4] = length4;
+        length_[5] = length5;
+        length_[6] = length6;
+        length_[7] = length7;
+        length_[8] = length8;
+        length_[9] = length9;
+        setupStorage(9);
+    }
+
+    Array(int length0, int length1, int length2, int length3, int length4,
+        int length5, int length6, int length7, int length8, int length9,
+        int length10,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(N_rank >= 11);
+        length_[0] = length0;
+        length_[1] = length1;
+        length_[2] = length2;
+        length_[3] = length3;
+        length_[4] = length4;
+        length_[5] = length5;
+        length_[6] = length6;
+        length_[7] = length7;
+        length_[8] = length8;
+        length_[9] = length9;
+        length_[10] = length10;
+        setupStorage(10);
+    }
+
+    /*
+     * Construct an array from an existing block of memory.  Ownership
+     * is not acquired (i.e. the memory block will not be freed by Blitz++).
+     */
+    Array(T_numtype* _bz_restrict dataFirst, TinyVector<int, N_rank> shape,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+      : MemoryBlockReference<T_numtype>(product(shape), dataFirst),
+        storage_(storage)
+    {
+        BZPRECONDITION(dataFirst != 0);
+
+        length_ = shape;
+        computeStrides();
+        data_ += zeroOffset_;
+        storageContiguous_ = _bz_true;
+    }
+
+    /*
+     * Construct an array from an existing block of memory, with a
+     * given set of strides.  Ownership is not acquired (i.e. the memory
+     * block will not be freed by Blitz++).
+     */
+    Array(T_numtype* _bz_restrict dataFirst, TinyVector<int, N_rank> shape,
+        TinyVector<int, N_rank> stride, 
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+      : MemoryBlockReference<T_numtype>(product(shape), dataFirst),
+        storage_(storage)
+    {
+        BZPRECONDITION(dataFirst != 0);
+
+        length_ = shape;
+        stride_ = stride;
+        calculateZeroOffset();
+        data_ += zeroOffset_;
+
+        // NEEDS_WORK: the setting of storageContiguous should be determined
+        // by inspecting the strides.
+        storageContiguous_ = _bz_false;   
+    }
+
+    /*
+     * This constructor takes an extent (length) vector and storage format.
+     */
+
+    Array(const TinyVector<int, N_rank>& extent, 
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        length_ = extent;
+        setupStorage(N_rank - 1);
+    }
+
+    /*
+     * This construct takes a vector of bases (lbounds) and a vector of
+     * extents.
+     */
+
+    Array(const TinyVector<int, N_rank>& lbounds,
+        const TinyVector<int, N_rank>& extent,
+        const GeneralArrayStorage<N_rank>& storage);
+
+    /*
+     * These constructors allow arbitrary bases (starting indices) to be set.
+     * e.g. Array<int,2> A(Range(10,20), Range(20,30))
+     * will create an 11x11 array whose indices are 10..20 and 20..30
+     */
+    Array(Range r0, 
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        setupStorage(0);
+    }
+
+    Array(Range r0, Range r1,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() && 
+            r1.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+
+        setupStorage(1);
+    }
+
+    Array(Range r0, Range r1, Range r2,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() &&
+            r1.isAscendingContiguous() && r2.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+        length_[2] = r2.length();
+        storage_.setBase(2, r2.first());
+
+        setupStorage(2);
+    }
+
+    Array(Range r0, Range r1, Range r2, Range r3,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() &&
+            r1.isAscendingContiguous() && r2.isAscendingContiguous()
+            && r3.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+        length_[2] = r2.length();
+        storage_.setBase(2, r2.first());
+        length_[3] = r3.length();
+        storage_.setBase(3, r3.first());
+
+        setupStorage(3);
+    }
+
+    Array(Range r0, Range r1, Range r2, Range r3, Range r4,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() &&
+            r1.isAscendingContiguous() && r2.isAscendingContiguous()
+            && r3.isAscendingContiguous() && r4.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+        length_[2] = r2.length();
+        storage_.setBase(2, r2.first());
+        length_[3] = r3.length();
+        storage_.setBase(3, r3.first());
+        length_[4] = r4.length();
+        storage_.setBase(4, r4.first());
+
+        setupStorage(4);
+    }
+
+    Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() &&
+            r1.isAscendingContiguous() && r2.isAscendingContiguous()
+            && r3.isAscendingContiguous() && r4.isAscendingContiguous()
+            && r5.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+        length_[2] = r2.length();
+        storage_.setBase(2, r2.first());
+        length_[3] = r3.length();
+        storage_.setBase(3, r3.first());
+        length_[4] = r4.length();
+        storage_.setBase(4, r4.first());
+        length_[5] = r5.length();
+        storage_.setBase(5, r5.first());
+
+        setupStorage(5);
+    }
+
+    Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
+        Range r6,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() &&
+            r1.isAscendingContiguous() && r2.isAscendingContiguous()
+            && r3.isAscendingContiguous() && r4.isAscendingContiguous()
+            && r5.isAscendingContiguous() && r6.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+        length_[2] = r2.length();
+        storage_.setBase(2, r2.first());
+        length_[3] = r3.length();
+        storage_.setBase(3, r3.first());
+        length_[4] = r4.length();
+        storage_.setBase(4, r4.first());
+        length_[5] = r5.length();
+        storage_.setBase(5, r5.first());
+        length_[6] = r6.length();
+        storage_.setBase(6, r6.first());
+
+        setupStorage(6);
+    }
+
+    Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
+        Range r6, Range r7,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() &&
+            r1.isAscendingContiguous() && r2.isAscendingContiguous()
+            && r3.isAscendingContiguous() && r4.isAscendingContiguous()
+            && r5.isAscendingContiguous() && r6.isAscendingContiguous()
+            && r7.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+        length_[2] = r2.length();
+        storage_.setBase(2, r2.first());
+        length_[3] = r3.length();
+        storage_.setBase(3, r3.first());
+        length_[4] = r4.length();
+        storage_.setBase(4, r4.first());
+        length_[5] = r5.length();
+        storage_.setBase(5, r5.first());
+        length_[6] = r6.length();
+        storage_.setBase(6, r6.first());
+        length_[7] = r7.length();
+        storage_.setBase(7, r7.first());
+
+        setupStorage(7);
+    }
+
+    Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
+        Range r6, Range r7, Range r8,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() &&
+            r1.isAscendingContiguous() && r2.isAscendingContiguous()
+            && r3.isAscendingContiguous() && r4.isAscendingContiguous()
+            && r5.isAscendingContiguous() && r6.isAscendingContiguous()
+            && r7.isAscendingContiguous() && r8.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+        length_[2] = r2.length();
+        storage_.setBase(2, r2.first());
+        length_[3] = r3.length();
+        storage_.setBase(3, r3.first());
+        length_[4] = r4.length();
+        storage_.setBase(4, r4.first());
+        length_[5] = r5.length();
+        storage_.setBase(5, r5.first());
+        length_[6] = r6.length();
+        storage_.setBase(6, r6.first());
+        length_[7] = r7.length();
+        storage_.setBase(7, r7.first());
+        length_[8] = r8.length();
+        storage_.setBase(8, r8.first());
+
+        setupStorage(8);
+    }
+
+    Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
+        Range r6, Range r7, Range r8, Range r9,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() &&
+            r1.isAscendingContiguous() && r2.isAscendingContiguous()
+            && r3.isAscendingContiguous() && r4.isAscendingContiguous()
+            && r5.isAscendingContiguous() && r6.isAscendingContiguous()
+            && r7.isAscendingContiguous() && r8.isAscendingContiguous()
+            && r9.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+        length_[2] = r2.length();
+        storage_.setBase(2, r2.first());
+        length_[3] = r3.length();
+        storage_.setBase(3, r3.first());
+        length_[4] = r4.length();
+        storage_.setBase(4, r4.first());
+        length_[5] = r5.length();
+        storage_.setBase(5, r5.first());
+        length_[6] = r6.length();
+        storage_.setBase(6, r6.first());
+        length_[7] = r7.length();
+        storage_.setBase(7, r7.first());
+        length_[8] = r8.length();
+        storage_.setBase(8, r8.first());
+        length_[9] = r9.length();
+        storage_.setBase(9, r9.first());
+
+        setupStorage(9);
+    }
+
+    Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
+        Range r6, Range r7, Range r8, Range r9, Range r10,
+        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
+        : storage_(storage)
+    {
+        BZPRECONDITION(r0.isAscendingContiguous() &&
+            r1.isAscendingContiguous() && r2.isAscendingContiguous()
+            && r3.isAscendingContiguous() && r4.isAscendingContiguous()
+            && r5.isAscendingContiguous() && r6.isAscendingContiguous()
+            && r7.isAscendingContiguous() && r8.isAscendingContiguous()
+            && r9.isAscendingContiguous() && r10.isAscendingContiguous());
+
+        length_[0] = r0.length();
+        storage_.setBase(0, r0.first());
+        length_[1] = r1.length();
+        storage_.setBase(1, r1.first());
+        length_[2] = r2.length();
+        storage_.setBase(2, r2.first());
+        length_[3] = r3.length();
+        storage_.setBase(3, r3.first());
+        length_[4] = r4.length();
+        storage_.setBase(4, r4.first());
+        length_[5] = r5.length();
+        storage_.setBase(5, r5.first());
+        length_[6] = r6.length();
+        storage_.setBase(6, r6.first());
+        length_[7] = r7.length();
+        storage_.setBase(7, r7.first());
+        length_[8] = r8.length();
+        storage_.setBase(8, r8.first());
+        length_[9] = r9.length();
+        storage_.setBase(9, r9.first());
+        length_[10] = r10.length();
+        storage_.setBase(10, r10.first());
+
+        setupStorage(10);
+    }
+
+    /*
+     * Create a reference of another array
+     */
+    Array(const Array<T_numtype, N_rank>& array)
+    {
+        // NEEDS_WORK: this const_cast is a tad ugly.
+        reference(const_cast<T_array&>(array));
+    }
+
+    /*
+     * These constructors are used for creating interlaced arrays (see
+     * <blitz/arrayshape.h>
+     */
+    Array(const TinyVector<int,N_rank-1>& shape,
+        int lastExtent, const GeneralArrayStorage<N_rank>& storage);
+    //Array(const TinyVector<Range,N_rank-1>& shape,
+    //    int lastExtent, const GeneralArrayStorage<N_rank>& storage);
+
+    /*
+     * These constructors make the array a view of a subportion of another
+     * array.  If there fewer than N_rank Range arguments provided, no
+     * slicing is performed in the unspecified ranks.
+     * e.g. Array<int,3> A(20,20,20);
+     *      Array<int,3> B(A, Range(5,15));
+     * is equivalent to:
+     *      Array<int,3> B(A, Range(5,15), Range::all(), Range::all());
+     */
+    Array(Array<T_numtype, N_rank>& array, Range r0)
+    {
+        constructSubarray(array, r0);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1)
+    {
+        constructSubarray(array, r0, r1);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2)
+    {
+        constructSubarray(array, r0, r1, r2);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2,
+        Range r3)
+    {
+        constructSubarray(array, r0, r1, r2, r3);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2,
+        Range r3, Range r4)
+    {
+        constructSubarray(array, r0, r1, r2, r3, r4);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2,
+        Range r3, Range r4, Range r5)
+    {
+        constructSubarray(array, r0, r1, r2, r3, r4, r5);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2,
+        Range r3, Range r4, Range r5, Range r6)
+    {
+        constructSubarray(array, r0, r1, r2, r3, r4, r5, r6);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2,
+        Range r3, Range r4, Range r5, Range r6, Range r7)
+    {
+        constructSubarray(array, r0, r1, r2, r3, r4, r5, r6, r7);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2,
+        Range r3, Range r4, Range r5, Range r6, Range r7, Range r8)
+    {
+        constructSubarray(array, r0, r1, r2, r3, r4, r5, r6, r7, r8);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2,
+        Range r3, Range r4, Range r5, Range r6, Range r7, Range r8, Range r9)
+    {
+        constructSubarray(array, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2,
+        Range r3, Range r4, Range r5, Range r6, Range r7, Range r8, Range r9,
+        Range r10)
+    {
+        constructSubarray(array, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10);
+    }
+
+    Array(Array<T_numtype, N_rank>& array, 
+        const RectDomain<N_rank>& subdomain)
+    {
+        constructSubarray(array, subdomain);
+    }
+
+    /*
+     * This constructor is invoked by the operator()'s which take
+     * a combination of integer and Range arguments.  It's not intended
+     * for end-user use.
+     */
+    template<int N_rank2, class R0, class R1, class R2, class R3, class R4,
+        class R5, class R6, class R7, class R8, class R9, class R10>
+    Array(Array<T_numtype,N_rank2>& array, R0 r0, R1 r1, R2 r2,
+        R3 r3, R4 r4, R5 r5, R6 r6, R7 r7, R8 r8, R9 r9, R10 r10)
+    {
+        constructSlice(array, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10);
+    }
+
+    //////////////////////////////////////////////
+    // Member functions
+    //////////////////////////////////////////////
+
+    const TinyVector<int, N_rank>&    base() const
+    { return storage_.base(); }
+
+    int                               base(int rank) const
+    { return storage_.base(rank); }
+
+    T_iterator                        begin() const
+    { return T_iterator(*this); }
+
+    // Deprecated: now extractComponent(...)
+    template<class T_numtype2>
+    Array<T_numtype2,N_rank>          chopComponent(T_numtype2 a, int compNum,
+                                          int numComponents)
+    { return extractComponent(a, compNum, numComponents); }
+
+    int                               cols() const
+    { return length_[1]; }
+
+    int                               columns() const
+    { return length_[1]; }
+
+    T_array                           copy() const;
+
+    // data_ always refers to the point (0,0,...,0) which may
+    // not be in the array if the base is not zero in each rank.
+    // These data() routines return a pointer to the first
+    // element in the array (but note that it may not be
+    // stored first in memory if some ranks are stored descending).
+
+    const T_numtype* _bz_restrict     data() const
+    { return data_ + dot(storage_.base(), stride_); }
+
+    T_numtype* _bz_restrict           data() 
+    { return data_ + dot(storage_.base(), stride_); }
+
+    // These dataZero() routines refer to the point (0,0,...,0)
+    // which may not be in the array if the bases are nonzero.
+    
+    const T_numtype* _bz_restrict     dataZero() const
+    { return data_; }
+
+    T_numtype* _bz_restrict           dataZero()
+    { return data_; }
+
+    // These dataFirst() routines refer to the element in the
+    // array which falls first in memory.
+    
+    const T_numtype* _bz_restrict     dataFirst() const
+    {
+        return data_ + dot(storage_.base() 
+            + (1 - storage_.ascendingFlag()) * (length_ - 1), stride_);
+    }
+
+    T_numtype* _bz_restrict           dataFirst()
+    {
+        return data_ + dot(storage_.base()
+            + (1 - storage_.ascendingFlag()) * (length_ - 1), stride_);
+    }
+
+    int                               depth() const
+    { return length_[2]; }
+
+    int                               dimensions() const
+    { return N_rank; }
+
+    RectDomain<N_rank>                domain() const
+    {
+        return RectDomain<N_rank>(lbound(), ubound());
+    }
+
+    void dumpStructureInformation(ostream& os = cout) const;
+
+    // NEEDS_WORK -- end()
+
+    int                               extent(int rank) const
+    { return length_[rank]; }
+
+    const TinyVector<int,N_rank>&     extent() const
+    { return length_; }
+
+    template<class T_numtype2>
+    Array<T_numtype2,N_rank>          extractComponent(T_numtype2, int compNum,
+                                          int numComponents);
+
+    void                              free() 
+    {
+        changeToNullBlock();
+        length_ = 0;
+    }
+ 
+    _bz_bool                          isMajorRank(int rank) const
+    { return storage_.ordering(rank) == 0; }
+
+    _bz_bool                          isMinorRank(int rank) const
+    { return storage_.ordering(rank) != 0; }
+
+    _bz_bool                          isRankStoredAscending(int rank) const
+    { return storage_.isRankStoredAscending(rank); }
+
+    _bz_bool                          isStorageContiguous() const
+    { return storageContiguous_; }
+
+    int                               lbound(int rank) const
+    { return base(rank); }
+
+    TinyVector<int,N_rank>            lbound() const
+    {
+        return base();
+    }
+
+    int                               length(int rank) const
+    { return length_[rank]; }
+
+    const TinyVector<int, N_rank>&    length() const
+    { return length_; }
+
+    void                              makeUnique();
+
+    int                               numElements() const
+    { return product(length_); }
+
+    // NEEDS_WORK -- Expose the numReferences() method
+    // MemoryBlockReference<T_numtype>::numReferences;
+
+    // The storage_.ordering_ array is a list of dimensions from
+    // the most minor (stride 1) to major dimension.  Generally,
+    // ordering(0) will return the dimension which has the smallest
+    // stride, and ordering(N_rank-1) will return the dimension with
+    // the largest stride.
+    int                               ordering(int storageRankIndex) const
+    { return storage_.ordering(storageRankIndex); }
+
+    const TinyVector<int, N_rank>&    ordering() const
+    { return storage_.ordering(); }
+
+    void                              transposeSelf(int r0, int r1, int r2=0, 
+        int r3=0, int r4=0, int r5=0, int r6=0, int r7=0, int r8=0, int 
+        r9=0, int r10=0);
+    T_array                           transpose(int r0, int r1, int r2=0,
+        int r3=0, int r4=0, int r5=0, int r6=0, int r7=0, int r8=0, int
+        r9=0, int r10=0);
+
+    int                               rank() const
+    { return N_rank; }
+
+    void                              reference(T_array&);
+
+    void                              resize(int extent);
+    void                              resize(int extent1, int extent2);
+    void                              resize(int extent1, int extent2,
+                                        int extent3);
+    void                              resize(int extent1, int extent2,
+                                        int extent3, int extent4);
+    void                              resize(int extent1, int extent2,
+                                        int extent3, int extent4, int extent5);
+    void                              resize(int extent1, int extent2,
+                                        int extent3, int extent4, int extent5,
+                                        int extent6);
+    void                              resize(int extent1, int extent2,
+                                        int extent3, int extent4, int extent5,
+                                        int extent6, int extent7);
+    void                              resize(int extent1, int extent2,
+                                        int extent3, int extent4, int extent5,
+                                        int extent6, int extent7, int extent8);
+    void                              resize(int extent1, int extent2,
+                                        int extent3, int extent4, int extent5,
+                                        int extent6, int extent7, int extent8,
+                                        int extent9);
+    void                              resize(int extent1, int extent2,
+                                        int extent3, int extent4, int extent5,
+                                        int extent6, int extent7, int extent8,
+                                        int extent9, int extent10);
+    void                              resize(int extent1, int extent2,
+                                        int extent3, int extent4, int extent5,
+                                        int extent6, int extent7, int extent8,
+                                        int extent9, int extent10, 
+                                        int extent11);
+
+
+    void                              resize(Range r1);
+    void                              resize(Range r1, Range r2);
+    void                              resize(Range r1, Range r2, Range r3);
+    void                              resize(Range r1, Range r2, Range r3,
+                                        Range r4);
+    void                              resize(Range r1, Range r2, Range r3,
+                                        Range r4, Range r5);
+    void                              resize(Range r1, Range r2, Range r3,
+                                        Range r4, Range r5, Range r6);
+    void                              resize(Range r1, Range r2, Range r3,
+                                        Range r4, Range r5, Range r6,
+                                        Range r7);
+    void                              resize(Range r1, Range r2, Range r3,
+                                        Range r4, Range r5, Range r6,
+                                        Range r7, Range r8);
+    void                              resize(Range r1, Range r2, Range r3,
+                                        Range r4, Range r5, Range r6,
+                                        Range r7, Range r8, Range r9);
+    void                              resize(Range r1, Range r2, Range r3,
+                                        Range r4, Range r5, Range r6,
+                                        Range r7, Range r8, Range r9, 
+                                        Range r10);
+    void                              resize(Range r1, Range r2, Range r3,
+                                        Range r4, Range r5, Range r6,
+                                        Range r7, Range r8, Range r9, 
+                                        Range r10, Range r11);
+
+    void                              resize(const TinyVector<int,N_rank>&);
+ 
+
+    void                              resizeAndPreserve(int extent);
+    void                              resizeAndPreserve(int extent1, 
+                                        int extent2);
+    void                              resizeAndPreserve(int extent1, 
+                                        int extent2, int extent3);
+    void                              resizeAndPreserve(int extent1,
+                                        int extent2, int extent3, int extent4);
+    void                              resizeAndPreserve(int extent1,
+                                        int extent2, int extent3, int extent4,
+                                        int extent5);
+    void                              resizeAndPreserve(int extent1,
+                                        int extent2, int extent3, int extent4,
+                                        int extent5, int extent6);
+    void                              resizeAndPreserve(int extent1,
+                                        int extent2, int extent3, int extent4,
+                                        int extent5, int extent6, int extent7);
+    void                              resizeAndPreserve(int extent1,
+                                        int extent2, int extent3, int extent4,
+                                        int extent5, int extent6, int extent7,
+                                        int extent8);
+    void                              resizeAndPreserve(int extent1,
+                                        int extent2, int extent3, int extent4,
+                                        int extent5, int extent6, int extent7,
+                                        int extent8, int extent9);
+    void                              resizeAndPreserve(int extent1,
+                                        int extent2, int extent3, int extent4,
+                                        int extent5, int extent6, int extent7,
+                                        int extent8, int extent9, 
+                                        int extent10);
+    void                              resizeAndPreserve(int extent1,
+                                        int extent2, int extent3, int extent4,
+                                        int extent5, int extent6, int extent7,
+                                        int extent8, int extent9, int extent10,
+                                        int extent11);
+
+    // NEEDS_WORK -- resizeAndPreserve(Range,...)
+    // NEEDS_WORK -- resizeAndPreserve(const TinyVector<int,N_rank>&);
+    // NEEDS_WORK -- resizeAndPreserve(const Domain<N_rank>&);
+
+    T_array                           reverse(int rank);
+    void                              reverseSelf(int rank);
+
+    int                               rows() const
+    { return length_[0]; }
+
+    void                              slice(int rank, Range r);
+
+    const TinyVector<int, N_rank>&    shape() const
+    { return length_; }
+
+    int                               size() const
+    { return numElements(); }
+
+    const TinyVector<int, N_rank>&    stride() const
+    { return stride_; }
+
+    int                               stride(int rank) const
+    { return stride_[rank]; }
+
+    int                               ubound(int rank) const
+    { return base(rank) + length_(rank) - 1; }
+
+    TinyVector<int, N_rank>           ubound() const
+    { 
+        TinyVector<int, N_rank> ub;
+        ub = base() + extent() - 1;
+        return ub;
+    }
+
+    int                               zeroOffset() const
+    { return zeroOffset_; }
+
+    //////////////////////////////////////////////
+    // Debugging routines
+    //////////////////////////////////////////////
+
+    _bz_bool isInRange(int i0) const
+    {
+        return unsigned(i0 - base(0)) < length_[0];
+    }
+
+    _bz_bool isInRange(int i0, int i1) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1];
+    }
+
+    _bz_bool isInRange(int i0, int i1, int i2) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1]
+            && unsigned(i2 - base(2)) < length_[2];
+    }
+
+    _bz_bool isInRange(int i0, int i1, int i2, int i3) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1]
+            && unsigned(i2 - base(2)) < length_[2]
+            && unsigned(i3 - base(3)) < length_[3];
+    }
+
+    _bz_bool isInRange(int i0, int i1, int i2, int i3, int i4) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1]
+            && unsigned(i2 - base(2)) < length_[2]
+            && unsigned(i3 - base(3)) < length_[3]
+            && unsigned(i4 - base(4)) < length_[4];
+    }
+
+    _bz_bool isInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1]
+            && unsigned(i2 - base(2)) < length_[2]
+            && unsigned(i3 - base(3)) < length_[3]
+            && unsigned(i4 - base(4)) < length_[4]
+            && unsigned(i5 - base(5)) < length_[5];
+    }
+
+    _bz_bool isInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1]
+            && unsigned(i2 - base(2)) < length_[2]
+            && unsigned(i3 - base(3)) < length_[3]
+            && unsigned(i4 - base(4)) < length_[4]
+            && unsigned(i5 - base(5)) < length_[5]
+            && unsigned(i6 - base(6)) < length_[6];
+    }
+
+    _bz_bool isInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6, int i7) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1]
+            && unsigned(i2 - base(2)) < length_[2]
+            && unsigned(i3 - base(3)) < length_[3]
+            && unsigned(i4 - base(4)) < length_[4]
+            && unsigned(i5 - base(5)) < length_[5]
+            && unsigned(i6 - base(6)) < length_[6]
+            && unsigned(i7 - base(7)) < length_[7];
+    }
+
+    _bz_bool isInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6, int i7, int i8) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1]
+            && unsigned(i2 - base(2)) < length_[2]
+            && unsigned(i3 - base(3)) < length_[3]
+            && unsigned(i4 - base(4)) < length_[4]
+            && unsigned(i5 - base(5)) < length_[5]
+            && unsigned(i6 - base(6)) < length_[6]
+            && unsigned(i7 - base(7)) < length_[7]
+            && unsigned(i8 - base(8)) < length_[8];
+    }
+
+    _bz_bool isInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6, int i7, int i8, int i9) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1]
+            && unsigned(i2 - base(2)) < length_[2]
+            && unsigned(i3 - base(3)) < length_[3]
+            && unsigned(i4 - base(4)) < length_[4]
+            && unsigned(i5 - base(5)) < length_[5]
+            && unsigned(i6 - base(6)) < length_[6]
+            && unsigned(i7 - base(7)) < length_[7]
+            && unsigned(i8 - base(8)) < length_[8]
+            && unsigned(i9 - base(9)) < length_[9];
+    }
+
+    _bz_bool isInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6, int i7, int i8, int i9, int i10) const
+    {
+        return unsigned(i0 - base(0)) < length_[0]
+            && unsigned(i1 - base(1)) < length_[1]
+            && unsigned(i2 - base(2)) < length_[2]
+            && unsigned(i3 - base(3)) < length_[3]
+            && unsigned(i4 - base(4)) < length_[4]
+            && unsigned(i5 - base(5)) < length_[5]
+            && unsigned(i6 - base(6)) < length_[6]
+            && unsigned(i7 - base(7)) < length_[7]
+            && unsigned(i8 - base(8)) < length_[8]
+            && unsigned(i9 - base(9)) < length_[9]
+            && unsigned(i10 - base(10)) < length_[10];
+    }
+
+    _bz_bool isInRange(const T_index& index) const
+    {
+        for (int i=0; i < N_rank; ++i)
+            if (unsigned(index[i] - base(i)) >= length_[i])
+                return _bz_false;
+
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(const T_index& index) const
+    {
+        BZPRECHECK(isInRange(index), "Array index out of range: " << index
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0) const
+    {
+        BZPRECHECK(isInRange(i0), "Array index out of range: " << i0
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1) const
+    {
+        BZPRECHECK(isInRange(i0,i1), "Array index out of range: (" 
+            << i0 << ", " << i1 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1, int i2) const
+    {
+        BZPRECHECK(isInRange(i0,i1,i2), "Array index out of range: ("
+            << i0 << ", " << i1 << ", " << i2 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1, int i2, int i3) const
+    {
+        BZPRECHECK(isInRange(i0,i1,i2,i3), "Array index out of range: ("
+            << i0 << ", " << i1 << ", " << i2 << ", " << i3 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1, int i2, int i3, int i4) const
+    {
+        BZPRECHECK(isInRange(i0,i1,i2,i3,i4), "Array index out of range: ("
+            << i0 << ", " << i1 << ", " << i2 << ", " << i3 
+            << ", " << i4 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1, int i2, int i3, int i4, 
+        int i5) const
+    {
+        BZPRECHECK(isInRange(i0,i1,i2,i3,i4,i5), "Array index out of range: ("
+            << i0 << ", " << i1 << ", " << i2 << ", " << i3
+            << ", " << i4 << ", " << i5 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6) const
+    {
+        BZPRECHECK(isInRange(i0,i1,i2,i3,i4,i5,i6), 
+            "Array index out of range: ("
+            << i0 << ", " << i1 << ", " << i2 << ", " << i3
+            << ", " << i4 << ", " << i5 << ", " << i6 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6, int i7) const
+    {
+        BZPRECHECK(isInRange(i0,i1,i2,i3,i4,i5,i6,i7),
+            "Array index out of range: ("
+            << i0 << ", " << i1 << ", " << i2 << ", " << i3
+            << ", " << i4 << ", " << i5 << ", " << i6 << ", " << i7 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6, int i7, int i8) const
+    {
+        BZPRECHECK(isInRange(i0,i1,i2,i3,i4,i5,i6,i7,i8),
+            "Array index out of range: ("
+            << i0 << ", " << i1 << ", " << i2 << ", " << i3
+            << ", " << i4 << ", " << i5 << ", " << i6 << ", " << i7 
+            << ", " << i8 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6, int i7, int i8, int i9) const
+    {
+        BZPRECHECK(isInRange(i0,i1,i2,i3,i4,i5,i6,i7,i8,i9),
+            "Array index out of range: ("
+            << i0 << ", " << i1 << ", " << i2 << ", " << i3
+            << ", " << i4 << ", " << i5 << ", " << i6 << ", " << i7
+            << ", " << i8 << ", " << i9 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    _bz_bool assertInRange(int i0, int i1, int i2, int i3, int i4,
+        int i5, int i6, int i7, int i8, int i9, int i10) const
+    {
+        BZPRECHECK(isInRange(i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10),
+            "Array index out of range: ("
+            << i0 << ", " << i1 << ", " << i2 << ", " << i3
+            << ", " << i4 << ", " << i5 << ", " << i6 << ", " << i7
+            << ", " << i8 << ", " << i9 << ", " << i10 << ")"
+            << endl << "Lower bounds: " << storage_.base() << endl
+            << "Upper bounds: " << (storage_.base() + length_ - 1) << endl);
+        return _bz_true;
+    }
+
+    //////////////////////////////////////////////
+    // Subscripting operators
+    //////////////////////////////////////////////
+
+    template<int N_rank2>
+    T_numtype operator()(const TinyVector<int,N_rank2>& index) const
+    {
+        assertInRange(index);
+        return data_[dot(index, stride_)];
+    }
+
+    template<int N_rank2>
+    T_numtype& _bz_restrict operator()(const TinyVector<int,N_rank2>& index) 
+    {
+        assertInRange(index);
+        return data_[dot(index, stride_)];
+    }
+
+    T_numtype operator()(TinyVector<int,1> index) const
+    {
+        assertInRange(index[0]);
+        return data_[index[0] * stride_[0]];
+    }
+
+    T_numtype& operator()(TinyVector<int,1> index)
+    {
+        assertInRange(index[0]);
+        return data_[index[0] * stride_[0]];
+    }
+
+    T_numtype operator()(TinyVector<int,2> index) const
+    {
+        assertInRange(index[0], index[1]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]];
+    }
+
+    T_numtype& operator()(TinyVector<int,2> index)
+    {
+        assertInRange(index[0], index[1]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]];
+    }
+
+    T_numtype operator()(TinyVector<int,3> index) const
+    {
+        assertInRange(index[0], index[1], index[2]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2]];
+    }
+
+    T_numtype& operator()(TinyVector<int,3> index)
+    {
+        assertInRange(index[0], index[1], index[2]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2]];
+    }
+
+    T_numtype operator()(const TinyVector<int,4>& index) const
+    {
+        assertInRange(index[0], index[1], index[2], index[3]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]];
+    }
+
+    T_numtype& operator()(const TinyVector<int,4>& index)
+    {
+        assertInRange(index[0], index[1], index[2], index[3]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]];
+    }
+
+    T_numtype operator()(const TinyVector<int,5>& index) const
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4]];
+    }
+
+    T_numtype& operator()(const TinyVector<int,5>& index)
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4]];
+    }
+
+    T_numtype operator()(const TinyVector<int,6>& index) const
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]];
+    }
+
+    T_numtype& operator()(const TinyVector<int,6>& index)
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]];
+    }
+
+    T_numtype operator()(const TinyVector<int,7>& index) const
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6]];
+    }
+
+    T_numtype& operator()(const TinyVector<int,7>& index)
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6]];
+    }
+
+    T_numtype operator()(const TinyVector<int,8>& index) const
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6], index[7]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6] + index[7] * stride_[7]];
+    }
+
+    T_numtype& operator()(const TinyVector<int,8>& index)
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6], index[7]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6] + index[7] * stride_[7]];
+    }
+
+    T_numtype operator()(const TinyVector<int,9>& index) const
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6], index[7], index[8]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6] + index[7] * stride_[7]
+            + index[8] * stride_[8]];
+    }
+
+    T_numtype& operator()(const TinyVector<int,9>& index)
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6], index[7], index[8]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6] + index[7] * stride_[7]
+            + index[8] * stride_[8]];
+    }
+
+    T_numtype operator()(const TinyVector<int,10>& index) const
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6], index[7], index[8], index[9]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6] + index[7] * stride_[7]
+            + index[8] * stride_[8] + index[9] * stride_[9]];
+    }
+
+    T_numtype& operator()(const TinyVector<int,10>& index)
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6], index[7], index[8], index[9]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6] + index[7] * stride_[7]
+            + index[8] * stride_[8] + index[9] * stride_[9]];
+    }
+
+    T_numtype operator()(const TinyVector<int,11>& index) const
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6], index[7], index[8], index[9],
+            index[10]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6] + index[7] * stride_[7]
+            + index[8] * stride_[8] + index[9] * stride_[9]
+            + index[10] * stride_[10]];
+    }
+
+    T_numtype& operator()(const TinyVector<int,11>& index)
+    {
+        assertInRange(index[0], index[1], index[2], index[3],
+            index[4], index[5], index[6], index[7], index[8], index[9],
+            index[10]);
+        return data_[index[0] * stride_[0] + index[1] * stride_[1]
+            + index[2] * stride_[2] + index[3] * stride_[3]
+            + index[4] * stride_[4] + index[5] * stride_[5]
+            + index[6] * stride_[6] + index[7] * stride_[7]
+            + index[8] * stride_[8] + index[9] * stride_[9]
+            + index[10] * stride_[10]];
+    }
+
+    T_numtype operator()(int i0) const
+    { 
+        assertInRange(i0);
+        return data_[i0 * stride_[0]]; 
+    }
+
+    T_numtype& _bz_restrict operator()(int i0) 
+    {
+        assertInRange(i0);
+        return data_[i0 * stride_[0]];
+    }
+
+    T_numtype operator()(int i0, int i1) const
+    { 
+        assertInRange(i0, i1);
+        return data_[i0 * stride_[0] + i1 * stride_[1]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1)
+    {
+        assertInRange(i0, i1);
+        return data_[i0 * stride_[0] + i1 * stride_[1]];
+    }
+
+    T_numtype operator()(int i0, int i1, int i2) const
+    {
+        assertInRange(i0, i1, i2);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1, int i2) 
+    {
+        assertInRange(i0, i1, i2);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2]];
+    }
+
+    T_numtype operator()(int i0, int i1, int i2, int i3) const
+    {
+        assertInRange(i0, i1, i2, i3);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1, int i2, int i3)
+    {
+        assertInRange(i0, i1, i2, i3);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3]];
+    }
+
+    T_numtype operator()(int i0, int i1, int i2, int i3,
+        int i4) const
+    {
+        assertInRange(i0, i1, i2, i3, i4);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1, int i2, int i3,
+        int i4)
+    {
+        assertInRange(i0, i1, i2, i3, i4);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]];
+    }
+
+    T_numtype operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5) const
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5)
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5]];
+    }
+
+    T_numtype operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6) const
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6)
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6]];
+    }
+
+    T_numtype operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6, int i7) const
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6, i7);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6, int i7)
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6, i7);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]];
+    }
+
+    T_numtype operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6, int i7, int i8) const
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+            + i8 * stride_[8]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6, int i7, int i8)
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+            + i8 * stride_[8]];
+    }
+
+    T_numtype operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6, int i7, int i8, int i9) const
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+            + i8 * stride_[8] + i9 * stride_[9]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6, int i7, int i8, int i9)
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+            + i8 * stride_[8] + i9 * stride_[9]];
+    }
+
+    T_numtype operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6, int i7, int i8, int i9, int i10) const
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, 
+            i9, i10);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+            + i8 * stride_[8] + i9 * stride_[9] + i10 * stride_[10]];
+    }
+
+    T_numtype& _bz_restrict operator()(int i0, int i1, int i2, int i3,
+        int i4, int i5, int i6, int i7, int i8, int i9, int i10)
+    {
+        assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, 
+            i9, i10);
+        return data_[i0 * stride_[0] + i1 * stride_[1]
+            + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+            + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+            + i8 * stride_[8] + i9 * stride_[9] + i10 * stride_[10]];
+    }
+
+    /*
+     * Slicing to produce subarrays.  If the number of Range arguments is
+     * fewer than N_rank, then missing arguments are treated like Range::all().
+     */
+
+    T_array operator()(const RectDomain<N_rank>& subdomain)
+    {
+        return T_array(*this, subdomain);
+    }
+
+    T_array operator()(Range r0)
+    {
+        return T_array(*this, r0);
+    }
+
+    T_array operator()(Range r0, Range r1)
+    {
+        return T_array(*this, r0, r1);
+    }
+
+    T_array operator()(Range r0, Range r1, Range r2)
+    {
+        return T_array(*this, r0, r1, r2);
+    }
+
+    T_array operator()(Range r0, Range r1, Range r2, Range r3)
+    {
+        return T_array(*this, r0, r1, r2, r3);
+    }
+
+    T_array operator()(Range r0, Range r1, Range r2, Range r3, Range r4)
+    {
+        return T_array(*this, r0, r1, r2, r3, r4);
+    }
+
+    T_array operator()(Range r0, Range r1, Range r2, Range r3, Range r4,
+        Range r5)
+    {
+        return T_array(*this, r0, r1, r2, r3, r4, r5);
+    }
+
+    T_array operator()(Range r0, Range r1, Range r2, Range r3, Range r4,
+        Range r5, Range r6)
+    {
+        return T_array(*this, r0, r1, r2, r3, r4, r5, r6);
+    }
+
+    T_array operator()(Range r0, Range r1, Range r2, Range r3, Range r4,
+        Range r5, Range r6, Range r7)
+    {
+        return T_array(*this, r0, r1, r2, r3, r4, r5, r6, r7);
+    }
+
+    T_array operator()(Range r0, Range r1, Range r2, Range r3, Range r4,
+        Range r5, Range r6, Range r7, Range r8)
+    {
+        return T_array(*this, r0, r1, r2, r3, r4, r5, r6, r7, r8);
+    }
+
+    T_array operator()(Range r0, Range r1, Range r2, Range r3, Range r4,
+        Range r5, Range r6, Range r7, Range r8, Range r9)
+    {
+        return T_array(*this, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9);
+    }
+
+    T_array operator()(Range r0, Range r1, Range r2, Range r3, Range r4,
+        Range r5, Range r6, Range r7, Range r8, Range r9, Range r10)
+    {
+        return T_array(*this, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10);
+    }
+
+    // Allow any mixture of Range, int and Vector<int> objects as
+    // operands for operator():   A(Range(3,7), 5, Range(2,4))
+
+    /*
+     * These versions of operator() allow any combination of int
+     * and Range operands to be used.  Each int operand reduces
+     * the rank of the resulting array by one.  
+     *
+     * e.g.  Array<int,4> A(20,20,20,20);
+     *       Array<int,2> B = A(Range(5,15), 3, 5, Range(8,9));
+     *
+     * SliceInfo is a helper class defined in <blitz/arrayslice.h>.
+     * It counts the number of Range vs. int arguments and does some
+     * other helpful things.
+     *
+     * Once partial specialization becomes widely implemented, these
+     * operators may be expanded to accept Vector<int> arguments
+     * and produce ArrayPick<T,N> objects.
+     *
+     * This operator() is not provided with a single argument because
+     * the appropriate cases exist above.
+     */
+
+#ifdef BZ_PARTIAL_ORDERING
+
+    template<class T1, class T2>
+    _bz_typename SliceInfo<T_numtype,T1,T2>::T_slice
+    operator()(T1 r1, T2 r2)
+    {
+        return SliceInfo<T_numtype,T1,T2>::T_slice(*this, r1, r2,
+            nilArraySection(), nilArraySection(), nilArraySection(),
+            nilArraySection(), nilArraySection(), nilArraySection(),
+            nilArraySection(), nilArraySection(), nilArraySection());
+    }
+
+    template<class T1, class T2, class T3>
+    _bz_typename SliceInfo<T_numtype,T1,T2,T3>::T_slice 
+    operator()(T1 r1, T2 r2, T3 r3)
+    {
+        return SliceInfo<T_numtype,T1,T2,T3>::T_slice(*this, r1, r2, r3,
+            nilArraySection(), nilArraySection(), nilArraySection(),
+            nilArraySection(), nilArraySection(), nilArraySection(),
+            nilArraySection(), nilArraySection());
+    }
+
+    template<class T1, class T2, class T3, class T4>
+    _bz_typename SliceInfo<T_numtype,T1,T2,T3,T4>::T_slice
+    operator()(T1 r1, T2 r2, T3 r3, T4 r4)
+    {
+        return SliceInfo<T_numtype,T1,T2,T3,T4>::T_slice(*this, r1, r2, r3,
+            r4, nilArraySection(), nilArraySection(),
+            nilArraySection(), nilArraySection(), nilArraySection(),
+            nilArraySection(), nilArraySection());
+    }
+
+    template<class T1, class T2, class T3, class T4, class T5>
+    _bz_typename SliceInfo<T_numtype,T1,T2,T3,T4,T5>::T_slice
+    operator()(T1 r1, T2 r2, T3 r3, T4 r4, T5 r5)
+    {
+        return SliceInfo<T_numtype,T1,T2,T3,T4,T5>::T_slice(*this, r1, r2, r3,
+            r4, r5, nilArraySection(),
+            nilArraySection(), nilArraySection(), nilArraySection(),
+            nilArraySection(), nilArraySection());
+    }
+
+    template<class T1, class T2, class T3, class T4, class T5, class T6>
+    _bz_typename SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6>::T_slice
+    operator()(T1 r1, T2 r2, T3 r3, T4 r4, T5 r5, T6 r6)
+    {
+        return SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6>::T_slice(*this, r1, r2, 
+            r3, r4, r5, r6, 
+            nilArraySection(), nilArraySection(), nilArraySection(),
+            nilArraySection(), nilArraySection());
+    }
+
+    template<class T1, class T2, class T3, class T4, class T5, class T6,
+        class T7>
+    _bz_typename SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7>::T_slice
+    operator()(T1 r1, T2 r2, T3 r3, T4 r4, T5 r5, T6 r6, T7 r7)
+    {
+        return SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7>::T_slice(*this, r1, 
+            r2, r3, r4, r5, r6, r7,
+            nilArraySection(), nilArraySection(),
+            nilArraySection(), nilArraySection());
+    }
+
+    template<class T1, class T2, class T3, class T4, class T5, class T6,
+        class T7, class T8>
+    _bz_typename SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7,T8>::T_slice
+    operator()(T1 r1, T2 r2, T3 r3, T4 r4, T5 r5, T6 r6, T7 r7, T8 r8)
+    {
+        return SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7,T8>::T_slice(*this, 
+            r1, r2, r3, r4, r5, r6, r7, r8,
+            nilArraySection(), nilArraySection(), nilArraySection());
+    }
+
+    template<class T1, class T2, class T3, class T4, class T5, class T6,
+        class T7, class T8, class T9>
+    _bz_typename SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7,T8,T9>::T_slice
+    operator()(T1 r1, T2 r2, T3 r3, T4 r4, T5 r5, T6 r6, T7 r7, T8 r8, 
+        T9 r9)
+    {
+        return SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7,T8,T9>::T_slice(*this, 
+            r1, r2, r3, r4, r5, r6, r7, r8, r9, 
+            nilArraySection(), nilArraySection());
+    }
+
+    template<class T1, class T2, class T3, class T4, class T5, class T6,
+        class T7, class T8, class T9, class T10>
+    _bz_typename SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>::T_slice
+    operator()(T1 r1, T2 r2, T3 r3, T4 r4, T5 r5, T6 r6, T7 r7, T8 r8,
+        T9 r9, T10 r10)
+    {
+        return SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7,T8,T9,
+            T10>::T_slice(*this, r1, r2, r3, r4, r5, r6, r7, r8, 
+            r9, r10, nilArraySection());
+    }
+
+    template<class T1, class T2, class T3, class T4, class T5, class T6,
+        class T7, class T8, class T9, class T10, class T11>
+    _bz_typename SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,
+        T11>::T_slice
+    operator()(T1 r1, T2 r2, T3 r3, T4 r4, T5 r5, T6 r6, T7 r7, T8 r8,
+        T9 r9, T10 r10, T11 r11)
+    {
+        return SliceInfo<T_numtype,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,
+            T11>::T_slice(*this, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11);
+    }
+
+#endif // BZ_PARTIAL_ORDERING
+
+    /*
+     * These versions of operator() are provided to support tensor-style
+     * array notation, e.g.
+     *
+     * Array<float, 2> A, B;
+     * firstIndex i;
+     * secondIndex j;
+     * thirdIndex k;
+     * Array<float, 3> C = A(i,j) * B(j,k);
+     */
+
+    template<int N0>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0> >
+    operator()(IndexPlaceholder<N0>)
+    { 
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0> >(*this);
+    }
+
+    template<int N0, int N1>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1> >(*this);
+    } 
+
+    template<int N0, int N1, int N2>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
+        IndexPlaceholder<N2>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1, N2> >(*this);
+    }
+
+    template<int N0, int N1, int N2, int N3>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
+        IndexPlaceholder<N2>, IndexPlaceholder<N3>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1, N2, N3> >(*this);
+    }
+
+    template<int N0, int N1, int N2, int N3, int N4>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3, N4> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
+        IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1, N2, N3, N4> >(*this);
+    }
+
+    template<int N0, int N1, int N2, int N3, int N4, int N5>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3, 
+        N4, N5> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
+        IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
+        IndexPlaceholder<N5>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1, N2, N3, N4, N5> >(*this);
+    }
+
+    template<int N0, int N1, int N2, int N3, int N4, int N5, int N6>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3,
+        N4, N5, N6> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
+        IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
+        IndexPlaceholder<N5>, IndexPlaceholder<N6>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1, N2, N3, N4, N5, N6> >(*this);
+    }
+
+    template<int N0, int N1, int N2, int N3, int N4, int N5, int N6,
+        int N7>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3,
+        N4, N5, N6, N7> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
+        IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
+        IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1, N2, N3, N4, N5, N6, N7> >(*this);
+    }
+
+    template<int N0, int N1, int N2, int N3, int N4, int N5, int N6,
+        int N7, int N8>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3,
+        N4, N5, N6, N7, N8> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
+        IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
+        IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>,
+        IndexPlaceholder<N8>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1, N2, N3, N4, N5, N6, N7, N8> >(*this);
+    }
+
+    template<int N0, int N1, int N2, int N3, int N4, int N5, int N6,
+        int N7, int N8, int N9>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3,
+        N4, N5, N6, N7, N8, N9> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
+        IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
+        IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>,
+        IndexPlaceholder<N8>, IndexPlaceholder<N9>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1, N2, N3, N4, N5, N6, N7, N8, N9> >(*this);
+    }
+
+    template<int N0, int N1, int N2, int N3, int N4, int N5, int N6,
+        int N7, int N8, int N9, int N10>
+    _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3,
+        N4, N5, N6, N7, N8, N9, N10> >
+    operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
+        IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
+        IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>,
+        IndexPlaceholder<N8>, IndexPlaceholder<N9>, IndexPlaceholder<N10>)
+    {
+        return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0,
+            N1, N2, N3, N4, N5, N6, N7, N8, N9, N10> >(*this);
+    }
+
+    //////////////////////////////////////////////
+    // Support for multicomponent arrays
+    //////////////////////////////////////////////
+
+    /*
+     * See <blitz/array/multi.h> for an explanation of the traits class
+     * multicomponent_traits.
+     */
+    Array<_bz_typename multicomponent_traits<T_numtype>::T_element,N_rank>
+    operator[](int component)
+    {
+        typedef _bz_typename multicomponent_traits<T_numtype>::T_element 
+            T_compType;
+
+        return extractComponent(T_compType(), 
+            component, multicomponent_traits<T_numtype>::numComponents);
+    }
+
+    //////////////////////////////////////////////
+    // Indirection
+    //////////////////////////////////////////////
+  
+    template<class T_indexContainer>
+    IndirectArray<T_array, T_indexContainer>
+    operator[](const T_indexContainer& index)
+    {
+        return IndirectArray<T_array, T_indexContainer>(*this,
+            const_cast<T_indexContainer&>(index));
+    }
+ 
+    //////////////////////////////////////////////
+    // Assignment Operators
+    //////////////////////////////////////////////
+
+    // Scalar operand
+    // NEEDS_WORK : need a precondition check on
+    // isStorageContiguous when operator, is used.
+    ListInitializationSwitch<T_array> operator=(T_numtype x)
+    {
+        return ListInitializationSwitch<T_array>(*this, x);
+    }
+
+    T_array& initialize(T_numtype);
+
+    // Was:
+    // T_array& operator=(T_numtype);
+
+    T_array& operator+=(T_numtype);
+    T_array& operator-=(T_numtype);
+    T_array& operator*=(T_numtype);
+    T_array& operator/=(T_numtype);
+    T_array& operator%=(T_numtype);
+    T_array& operator^=(T_numtype);
+    T_array& operator&=(T_numtype);
+    T_array& operator|=(T_numtype);
+    T_array& operator>>=(T_numtype);
+    T_array& operator<<=(T_numtype);
+
+    // Array operands
+    T_array& operator=(const Array<T_numtype,N_rank>&);
+
+    template<class T_numtype2> 
+    T_array& operator=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator+=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator-=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator*=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator/=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator%=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator^=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator&=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator|=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator>>=(const Array<T_numtype2,N_rank>&);
+    template<class T_numtype2>
+    T_array& operator<<=(const Array<T_numtype2,N_rank>&);
+
+    // Array expression operands
+    template<class T_expr>
+    inline T_array& operator=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator+=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator-=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator*=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator/=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator%=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator^=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator&=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator|=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator>>=(_bz_ArrayExpr<T_expr> expr);
+    template<class T_expr>
+    inline T_array& operator<<=(_bz_ArrayExpr<T_expr> expr);
+
+    // NEEDS_WORK -- Index placeholder operand
+
+    // NEEDS_WORK -- Random operand
+
+
+public:
+    // Undocumented implementation routines
+
+    template<class T_expr, class T_update>
+    inline T_array& evaluate(_bz_ArrayExpr<T_expr> expr,
+        T_update);
+
+#ifdef BZ_HAVE_STD
+    template<class T_expr, class T_update>
+    inline T_array& evaluateWithFastTraversal(
+        const TraversalOrder<N_rank - 1>& order, _bz_ArrayExpr<T_expr> expr,
+        T_update);
+#endif
+
+#ifdef BZ_ARRAY_2D_STENCIL_TILING
+    template<class T_expr, class T_update>
+    inline T_array& evaluateWithTiled2DTraversal(_bz_ArrayExpr<T_expr> expr,
+        T_update);
+#endif
+
+    template<class T_expr, class T_update>
+    inline T_array& evaluateWithIndexTraversal1(_bz_ArrayExpr<T_expr> expr,
+        T_update);
+
+    template<class T_expr, class T_update>
+    inline T_array& evaluateWithIndexTraversalN(_bz_ArrayExpr<T_expr> expr,
+        T_update);
+
+    template<class T_expr, class T_update>
+    inline T_array& evaluateWithStackTraversal1(_bz_ArrayExpr<T_expr> expr,
+        T_update);
+
+    template<class T_expr, class T_update>
+    inline T_array& evaluateWithStackTraversalN(_bz_ArrayExpr<T_expr> expr,
+        T_update);
+
+    T_numtype* _bz_restrict getInitializationIterator()
+    { return dataFirst(); }
+
+    _bz_bool canCollapse(int outerRank, int innerRank) const
+    { 
+#ifdef BZ_DEBUG_TRAVERSE
+        BZ_DEBUG_MESSAGE("stride(" << innerRank << ")=" << stride(innerRank)
+          << ", extent()=" << extent(innerRank) << ", stride(outerRank)="
+          << stride(outerRank));
+#endif
+        return (stride(innerRank) * extent(innerRank) == stride(outerRank)); 
+    }
+
+protected:
+    //////////////////////////////////////////////
+    // Implementation routines
+    //////////////////////////////////////////////
+
+    _bz_inline2 void computeStrides();
+    _bz_inline2 void setupStorage(int rank);
+    void constructSubarray(Array<T_numtype, N_rank>& array, 
+        const RectDomain<N_rank>&);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0, Range r1);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0,
+        Range r1, Range r2);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0,
+        Range r1, Range r2, Range r3);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0,
+        Range r1, Range r2, Range r3, Range r4);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0,
+        Range r1, Range r2, Range r3, Range r4, Range r5);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0,
+        Range r1, Range r2, Range r3, Range r4, Range r5, Range r6);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0,
+        Range r1, Range r2, Range r3, Range r4, Range r5, Range r6,
+        Range r7);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0,
+        Range r1, Range r2, Range r3, Range r4, Range r5, Range r6,
+        Range r7, Range r8);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0,
+        Range r1, Range r2, Range r3, Range r4, Range r5, Range r6,
+        Range r7, Range r8, Range r9);
+    void constructSubarray(Array<T_numtype, N_rank>& array, Range r0,
+        Range r1, Range r2, Range r3, Range r4, Range r5, Range r6,
+        Range r7, Range r8, Range r9, Range r10);
+
+    void calculateZeroOffset();
+
+    template<int N_rank2, class R0, class R1, class R2, class R3, class R4, 
+        class R5, class R6, class R7, class R8, class R9, class R10>
+    void constructSlice(Array<T_numtype, N_rank2>& array, R0 r0, R1 r1, R2 r2, 
+        R3 r3, R4 r4, R5 r5, R6 r6, R7 r7, R8 r8, R9 r9, R10 r10);
+
+    template<int N_rank2>
+    void slice(int& setRank, Range r, Array<T_numtype,N_rank2>& array,
+        TinyVector<int,N_rank2>& rankMap, int sourceRank);
+
+    template<int N_rank2>
+    void slice(int& setRank, int i, Array<T_numtype,N_rank2>& array,
+        TinyVector<int,N_rank2>& rankMap, int sourceRank);
+
+    template<int N_rank2>
+    void slice(int& setRank, nilArraySection, Array<T_numtype,N_rank2>& array,
+        TinyVector<int,N_rank2>& rankMap, int sourceRank)
+    { }
+
+    void doTranspose(int destRank, int sourceRank, T_array& array);
+
+protected:
+    //////////////////////////////////////////////
+    // Data members
+    //////////////////////////////////////////////
+
+    // NB: adding new data members may require changes to ctors, reference()
+
+    /*
+     * For a description of the storage_ members, see the comments for class 
+     * GeneralArrayStorage<N_rank> above.
+     *
+     * length_[] contains the extent of each rank.  E.g. a 10x20x30 array
+     *           would have length_ = { 10, 20, 30}.
+     * stride_[] contains the stride to move to the next element along each
+     *           rank.
+     * zeroOffset_ is the distance from the first element in the array 
+     *           to the point (0,0,...,0).  If base_ is zero and all ranks are 
+     *           stored ascending, then zeroOffset_ is zero.  This value
+     *           is needed because to speed up indexing, the data_ member
+     *           (inherited from MemoryBlockReference) always refers to
+     *           (0,0,...,0).
+     * storageContiguous_ is true if all the elements in the array are
+     *           stored contiguously in memory.  If this is true, then
+     *           the array can be converted to a one-dimensional array.
+     *           If the array is sliced, then this becomes false.
+     */
+    GeneralArrayStorage<N_rank> storage_;
+    TinyVector<int, N_rank> length_;
+    TinyVector<int, N_rank> stride_;
+    int zeroOffset_;
+    _bz_bool storageContiguous_;
+};
+
+/*
+ * Rank numbers start with zero, which may be confusing to users coming
+ * from Fortran.  To make code more readable, the following constants
+ * may help.  Example: instead of
+ * 
+ * int firstRankExtent = A.extent(0);
+ *
+ * One can write:
+ *
+ * int firstRankExtent = A.extent(firstRank);
+ */
+
+const int firstRank    = 0;
+const int secondRank   = 1;
+const int thirdRank    = 2;
+const int fourthRank   = 3;
+const int fifthRank    = 4;
+const int sixthRank    = 5;
+const int seventhRank  = 6;
+const int eighthRank   = 7;
+const int ninthRank    = 8;
+const int tenthRank    = 9;
+const int eleventhRank = 10;
+
+const int firstDim    = 0;
+const int secondDim   = 1;
+const int thirdDim    = 2;
+const int fourthDim   = 3;
+const int fifthDim    = 4;
+const int sixthDim    = 5;
+const int seventhDim  = 6;
+const int eighthDim   = 7;
+const int ninthDim    = 8;
+const int tenthDim    = 9;
+const int eleventhDim = 10;
+
+/*
+ * Global Functions
+ */
+
+template<class T_numtype>
+ostream& operator<<(ostream&, const Array<T_numtype,1>&);
+
+template<class T_numtype>
+ostream& operator<<(ostream&, const Array<T_numtype,2>&);
+
+// NEEDS_WORK -- output formatting for N > 2?
+
+BZ_NAMESPACE_END
+
+/*
+ * Include implementations of the member functions and some additional
+ * global functions.
+ */
+
+#include <blitz/array/iter.h>       // Array iterators
+#include <blitz/array/expr.h>       // Array expression objects
+#include <blitz/array/methods.cc>   // Member functions
+#include <blitz/array/eval.cc>      // Array expression evaluation
+#include <blitz/array/ops.cc>       // Assignment operators
+#include <blitz/array/io.cc>        // Output formatting
+#include <blitz/array/bops.cc>      // Expression templates, two operands
+#include <blitz/array/uops.cc>      // Expression templates, math functions
+#include <blitz/array/misc.cc>      // Expression templates, miscellaneous
+#include <blitz/array/reduce.h>     // Array reduction expression templates
+#include <blitz/array/interlace.cc> // Allocation of interlaced arrays
+#include <blitz/array/resize.cc>    // Array resize, resizeAndPreserve
+#include <blitz/array/slicing.cc>   // Slicing and subarrays
+#include <blitz/array/cycle.cc>     // Cycling arrays
+#include <blitz/array/complex.cc>   // Special support for complex arrays
+#include <blitz/array/zip.h>        // Zipping multicomponent types
+#include <blitz/array/where.h>      // where(X,Y,Z)
+#include <blitz/array/stencil.h>    // Stencil objects
+#include <blitz/array/indirect.h>   // Indirection
+
+#endif // BZ_ARRAY_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/asexpr.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/asexpr.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/asexpr.h	(revision 1307)
@@ -0,0 +1,39 @@
+#ifndef BZ_ARRAYASEXPR_H
+#define BZ_ARRAYASEXPR_H
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/asexpr.h> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// The traits class asExpr converts arbitrary things to
+// expression templatable operands.
+
+// Default to scalar.
+template<class T>
+struct asExpr {
+    typedef _bz_ArrayExprConstant<T> T_expr;
+};
+
+// Already an expression template term
+template<class T>
+struct asExpr<_bz_ArrayExpr<T> > {
+    typedef _bz_ArrayExpr<T> T_expr;
+};
+
+// An array operand
+template<class T, int N>
+struct asExpr<Array<T,N> > {
+    typedef ArrayIterator<T,N> T_expr;
+};
+
+// Index placeholder
+template<int N>
+struct asExpr<IndexPlaceholder<N> > {
+    typedef IndexPlaceholder<N> T_expr;
+};
+
+BZ_NAMESPACE_END
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/bops.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/bops.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/bops.cc	(revision 1307)
@@ -0,0 +1,8371 @@
+/***************************************************************************
+ * blitz/arraybops.cc	Array expression templates (2 operands)
+ *
+ * $Id: bops.cc,v 1.1.1.1 1999-04-09 17:59:04 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.   Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ */ 
+
+// Generated source file.  Do not edit. 
+// genarrbops.cpp Aug  7 1997 15:04:14
+
+#ifndef BZ_ARRAYBOPS_CC
+#define BZ_ARRAYBOPS_CC
+
+#ifndef BZ_ARRAYEXPR_H
+ #error <blitz/arraybops.cc> must be included after <blitz/arrayexpr.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/****************************************************************************
+ * Addition Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> + Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Add<T_numtype1, T_numtype2 > > >
+operator+(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Add<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> + _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Add<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator+(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Add<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> + IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      Add<T_numtype1, int > > >
+operator+(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      Add<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> + int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      Add<T_numtype1, int > > >
+operator+(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      Add<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> + float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      Add<T_numtype1, float > > >
+operator+(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      Add<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> + double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      Add<T_numtype1, double > > >
+operator+(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      Add<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> + long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      Add<T_numtype1, long double > > >
+operator+(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Add<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> + complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Add<T_numtype1, complex<T2>  > > >
+operator+(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Add<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> + Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Add<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator+(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Add<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> + _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Add<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator+(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Add<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> + IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      Add<_bz_typename P_expr1::T_numtype, int > > >
+operator+(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      Add<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> + int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      Add<_bz_typename P_expr1::T_numtype, int > > >
+operator+(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      Add<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> + float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      Add<_bz_typename P_expr1::T_numtype, float > > >
+operator+(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      Add<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> + double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      Add<_bz_typename P_expr1::T_numtype, double > > >
+operator+(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      Add<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> + long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      Add<_bz_typename P_expr1::T_numtype, long double > > >
+operator+(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Add<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> + complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Add<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator+(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Add<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> + Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Add<int, T_numtype2 > > >
+operator+(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Add<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> + _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Add<int, _bz_typename P_expr2::T_numtype > > >
+operator+(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Add<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> + IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      Add<int, int > > >
+operator+(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      Add<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> + int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      Add<int, int > > >
+operator+(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      Add<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> + float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      Add<int, float > > >
+operator+(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      Add<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> + double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      Add<int, double > > >
+operator+(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      Add<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> + long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      Add<int, long double > > >
+operator+(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Add<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> + complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Add<int, complex<T2>  > > >
+operator+(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Add<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int + Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Add<int, T_numtype2 > > >
+operator+(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Add<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int + _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      Add<int, _bz_typename P_expr2::T_numtype > > >
+operator+(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Add<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int + IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      Add<int, int > > >
+operator+(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      Add<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float + Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Add<float, T_numtype2 > > >
+operator+(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Add<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float + _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      Add<float, _bz_typename P_expr2::T_numtype > > >
+operator+(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Add<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float + IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      Add<float, int > > >
+operator+(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      Add<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double + Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Add<double, T_numtype2 > > >
+operator+(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Add<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double + _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Add<double, _bz_typename P_expr2::T_numtype > > >
+operator+(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Add<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double + IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      Add<double, int > > >
+operator+(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      Add<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double + Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Add<long double, T_numtype2 > > >
+operator+(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Add<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double + _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Add<long double, _bz_typename P_expr2::T_numtype > > >
+operator+(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Add<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double + IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      Add<long double, int > > >
+operator+(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      Add<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> + Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Add<complex<T1> , T_numtype2 > > >
+operator+(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Add<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> + _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      Add<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator+(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      Add<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> + IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      Add<complex<T1> , int > > >
+operator+(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      Add<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Subtraction Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> - Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Subtract<T_numtype1, T_numtype2 > > >
+operator-(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Subtract<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> - _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Subtract<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator-(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Subtract<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> - IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      Subtract<T_numtype1, int > > >
+operator-(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      Subtract<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> - int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      Subtract<T_numtype1, int > > >
+operator-(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      Subtract<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> - float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      Subtract<T_numtype1, float > > >
+operator-(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      Subtract<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> - double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      Subtract<T_numtype1, double > > >
+operator-(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      Subtract<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> - long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      Subtract<T_numtype1, long double > > >
+operator-(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Subtract<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> - complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Subtract<T_numtype1, complex<T2>  > > >
+operator-(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Subtract<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> - Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Subtract<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator-(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Subtract<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> - _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Subtract<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator-(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Subtract<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> - IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      Subtract<_bz_typename P_expr1::T_numtype, int > > >
+operator-(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      Subtract<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> - int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      Subtract<_bz_typename P_expr1::T_numtype, int > > >
+operator-(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      Subtract<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> - float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      Subtract<_bz_typename P_expr1::T_numtype, float > > >
+operator-(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      Subtract<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> - double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      Subtract<_bz_typename P_expr1::T_numtype, double > > >
+operator-(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      Subtract<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> - long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      Subtract<_bz_typename P_expr1::T_numtype, long double > > >
+operator-(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Subtract<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> - complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Subtract<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator-(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Subtract<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> - Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Subtract<int, T_numtype2 > > >
+operator-(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Subtract<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> - _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Subtract<int, _bz_typename P_expr2::T_numtype > > >
+operator-(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Subtract<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> - IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      Subtract<int, int > > >
+operator-(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      Subtract<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> - int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      Subtract<int, int > > >
+operator-(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      Subtract<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> - float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      Subtract<int, float > > >
+operator-(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      Subtract<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> - double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      Subtract<int, double > > >
+operator-(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      Subtract<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> - long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      Subtract<int, long double > > >
+operator-(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Subtract<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> - complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Subtract<int, complex<T2>  > > >
+operator-(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Subtract<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int - Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Subtract<int, T_numtype2 > > >
+operator-(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Subtract<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int - _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      Subtract<int, _bz_typename P_expr2::T_numtype > > >
+operator-(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Subtract<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int - IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      Subtract<int, int > > >
+operator-(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      Subtract<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float - Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Subtract<float, T_numtype2 > > >
+operator-(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Subtract<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float - _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      Subtract<float, _bz_typename P_expr2::T_numtype > > >
+operator-(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Subtract<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float - IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      Subtract<float, int > > >
+operator-(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      Subtract<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double - Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Subtract<double, T_numtype2 > > >
+operator-(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Subtract<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double - _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Subtract<double, _bz_typename P_expr2::T_numtype > > >
+operator-(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Subtract<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double - IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      Subtract<double, int > > >
+operator-(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      Subtract<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double - Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Subtract<long double, T_numtype2 > > >
+operator-(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Subtract<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double - _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Subtract<long double, _bz_typename P_expr2::T_numtype > > >
+operator-(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Subtract<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double - IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      Subtract<long double, int > > >
+operator-(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      Subtract<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> - Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Subtract<complex<T1> , T_numtype2 > > >
+operator-(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Subtract<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> - _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      Subtract<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator-(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      Subtract<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> - IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      Subtract<complex<T1> , int > > >
+operator-(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      Subtract<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Multiplication Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> * Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Multiply<T_numtype1, T_numtype2 > > >
+operator*(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Multiply<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> * _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Multiply<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator*(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Multiply<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> * IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      Multiply<T_numtype1, int > > >
+operator*(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      Multiply<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> * int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      Multiply<T_numtype1, int > > >
+operator*(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      Multiply<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> * float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      Multiply<T_numtype1, float > > >
+operator*(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      Multiply<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> * double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      Multiply<T_numtype1, double > > >
+operator*(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      Multiply<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> * long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      Multiply<T_numtype1, long double > > >
+operator*(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Multiply<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> * complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Multiply<T_numtype1, complex<T2>  > > >
+operator*(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Multiply<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> * Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Multiply<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator*(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Multiply<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> * _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Multiply<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator*(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Multiply<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> * IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      Multiply<_bz_typename P_expr1::T_numtype, int > > >
+operator*(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      Multiply<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> * int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      Multiply<_bz_typename P_expr1::T_numtype, int > > >
+operator*(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      Multiply<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> * float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      Multiply<_bz_typename P_expr1::T_numtype, float > > >
+operator*(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      Multiply<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> * double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      Multiply<_bz_typename P_expr1::T_numtype, double > > >
+operator*(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      Multiply<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> * long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      Multiply<_bz_typename P_expr1::T_numtype, long double > > >
+operator*(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Multiply<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> * complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Multiply<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator*(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Multiply<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> * Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Multiply<int, T_numtype2 > > >
+operator*(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Multiply<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> * _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Multiply<int, _bz_typename P_expr2::T_numtype > > >
+operator*(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Multiply<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> * IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      Multiply<int, int > > >
+operator*(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      Multiply<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> * int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      Multiply<int, int > > >
+operator*(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      Multiply<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> * float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      Multiply<int, float > > >
+operator*(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      Multiply<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> * double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      Multiply<int, double > > >
+operator*(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      Multiply<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> * long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      Multiply<int, long double > > >
+operator*(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Multiply<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> * complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Multiply<int, complex<T2>  > > >
+operator*(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Multiply<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int * Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Multiply<int, T_numtype2 > > >
+operator*(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Multiply<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int * _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      Multiply<int, _bz_typename P_expr2::T_numtype > > >
+operator*(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Multiply<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int * IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      Multiply<int, int > > >
+operator*(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      Multiply<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float * Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Multiply<float, T_numtype2 > > >
+operator*(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Multiply<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float * _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      Multiply<float, _bz_typename P_expr2::T_numtype > > >
+operator*(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Multiply<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float * IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      Multiply<float, int > > >
+operator*(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      Multiply<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double * Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Multiply<double, T_numtype2 > > >
+operator*(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Multiply<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double * _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Multiply<double, _bz_typename P_expr2::T_numtype > > >
+operator*(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Multiply<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double * IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      Multiply<double, int > > >
+operator*(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      Multiply<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double * Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Multiply<long double, T_numtype2 > > >
+operator*(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Multiply<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double * _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Multiply<long double, _bz_typename P_expr2::T_numtype > > >
+operator*(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Multiply<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double * IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      Multiply<long double, int > > >
+operator*(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      Multiply<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> * Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Multiply<complex<T1> , T_numtype2 > > >
+operator*(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Multiply<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> * _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      Multiply<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator*(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      Multiply<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> * IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      Multiply<complex<T1> , int > > >
+operator*(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      Multiply<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Division Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> / Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Divide<T_numtype1, T_numtype2 > > >
+operator/(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Divide<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> / _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Divide<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator/(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Divide<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> / IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      Divide<T_numtype1, int > > >
+operator/(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      Divide<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> / int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      Divide<T_numtype1, int > > >
+operator/(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      Divide<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> / float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      Divide<T_numtype1, float > > >
+operator/(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      Divide<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> / double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      Divide<T_numtype1, double > > >
+operator/(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      Divide<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> / long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      Divide<T_numtype1, long double > > >
+operator/(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Divide<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> / complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Divide<T_numtype1, complex<T2>  > > >
+operator/(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Divide<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> / Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Divide<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator/(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Divide<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> / _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Divide<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator/(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Divide<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> / IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      Divide<_bz_typename P_expr1::T_numtype, int > > >
+operator/(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      Divide<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> / int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      Divide<_bz_typename P_expr1::T_numtype, int > > >
+operator/(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      Divide<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> / float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      Divide<_bz_typename P_expr1::T_numtype, float > > >
+operator/(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      Divide<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> / double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      Divide<_bz_typename P_expr1::T_numtype, double > > >
+operator/(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      Divide<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> / long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      Divide<_bz_typename P_expr1::T_numtype, long double > > >
+operator/(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Divide<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> / complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Divide<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator/(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Divide<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> / Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Divide<int, T_numtype2 > > >
+operator/(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Divide<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> / _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Divide<int, _bz_typename P_expr2::T_numtype > > >
+operator/(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Divide<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> / IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      Divide<int, int > > >
+operator/(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      Divide<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> / int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      Divide<int, int > > >
+operator/(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      Divide<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> / float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      Divide<int, float > > >
+operator/(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      Divide<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> / double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      Divide<int, double > > >
+operator/(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      Divide<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> / long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      Divide<int, long double > > >
+operator/(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Divide<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> / complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Divide<int, complex<T2>  > > >
+operator/(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Divide<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int / Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Divide<int, T_numtype2 > > >
+operator/(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Divide<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int / _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      Divide<int, _bz_typename P_expr2::T_numtype > > >
+operator/(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Divide<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int / IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      Divide<int, int > > >
+operator/(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      Divide<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float / Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Divide<float, T_numtype2 > > >
+operator/(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Divide<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float / _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      Divide<float, _bz_typename P_expr2::T_numtype > > >
+operator/(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Divide<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float / IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      Divide<float, int > > >
+operator/(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      Divide<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double / Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Divide<double, T_numtype2 > > >
+operator/(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Divide<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double / _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Divide<double, _bz_typename P_expr2::T_numtype > > >
+operator/(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Divide<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double / IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      Divide<double, int > > >
+operator/(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      Divide<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double / Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Divide<long double, T_numtype2 > > >
+operator/(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Divide<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double / _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Divide<long double, _bz_typename P_expr2::T_numtype > > >
+operator/(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Divide<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double / IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      Divide<long double, int > > >
+operator/(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      Divide<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> / Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Divide<complex<T1> , T_numtype2 > > >
+operator/(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Divide<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> / _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      Divide<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator/(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      Divide<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> / IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      Divide<complex<T1> , int > > >
+operator/(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      Divide<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Modulus Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> % Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Modulo<T_numtype1, T_numtype2 > > >
+operator%(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Modulo<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> % _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Modulo<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator%(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Modulo<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> % IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      Modulo<T_numtype1, int > > >
+operator%(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      Modulo<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> % int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      Modulo<T_numtype1, int > > >
+operator%(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      Modulo<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> % Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Modulo<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator%(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Modulo<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> % _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Modulo<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator%(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Modulo<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> % IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      Modulo<_bz_typename P_expr1::T_numtype, int > > >
+operator%(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      Modulo<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> % int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      Modulo<_bz_typename P_expr1::T_numtype, int > > >
+operator%(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      Modulo<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> % Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Modulo<int, T_numtype2 > > >
+operator%(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Modulo<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> % _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Modulo<int, _bz_typename P_expr2::T_numtype > > >
+operator%(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Modulo<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> % IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      Modulo<int, int > > >
+operator%(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      Modulo<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> % int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      Modulo<int, int > > >
+operator%(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      Modulo<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// int % Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Modulo<int, T_numtype2 > > >
+operator%(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Modulo<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int % _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      Modulo<int, _bz_typename P_expr2::T_numtype > > >
+operator%(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Modulo<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int % IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      Modulo<int, int > > >
+operator%(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      Modulo<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+/****************************************************************************
+ * Greater-than Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> > Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Greater<T_numtype1, T_numtype2 > > >
+operator>(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Greater<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> > _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Greater<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Greater<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> > IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      Greater<T_numtype1, int > > >
+operator>(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      Greater<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> > int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      Greater<T_numtype1, int > > >
+operator>(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      Greater<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> > float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      Greater<T_numtype1, float > > >
+operator>(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      Greater<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> > double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      Greater<T_numtype1, double > > >
+operator>(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      Greater<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> > long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      Greater<T_numtype1, long double > > >
+operator>(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Greater<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> > complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Greater<T_numtype1, complex<T2>  > > >
+operator>(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Greater<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> > Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Greater<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator>(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Greater<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> > _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Greater<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator>(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Greater<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> > IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      Greater<_bz_typename P_expr1::T_numtype, int > > >
+operator>(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      Greater<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> > int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      Greater<_bz_typename P_expr1::T_numtype, int > > >
+operator>(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      Greater<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> > float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      Greater<_bz_typename P_expr1::T_numtype, float > > >
+operator>(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      Greater<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> > double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      Greater<_bz_typename P_expr1::T_numtype, double > > >
+operator>(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      Greater<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> > long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      Greater<_bz_typename P_expr1::T_numtype, long double > > >
+operator>(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Greater<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> > complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Greater<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator>(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Greater<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> > Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Greater<int, T_numtype2 > > >
+operator>(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Greater<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> > _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Greater<int, _bz_typename P_expr2::T_numtype > > >
+operator>(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Greater<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> > IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      Greater<int, int > > >
+operator>(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      Greater<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> > int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      Greater<int, int > > >
+operator>(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      Greater<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> > float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      Greater<int, float > > >
+operator>(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      Greater<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> > double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      Greater<int, double > > >
+operator>(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      Greater<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> > long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      Greater<int, long double > > >
+operator>(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Greater<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> > complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Greater<int, complex<T2>  > > >
+operator>(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Greater<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int > Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Greater<int, T_numtype2 > > >
+operator>(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Greater<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int > _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      Greater<int, _bz_typename P_expr2::T_numtype > > >
+operator>(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Greater<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int > IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      Greater<int, int > > >
+operator>(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      Greater<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float > Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Greater<float, T_numtype2 > > >
+operator>(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Greater<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float > _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      Greater<float, _bz_typename P_expr2::T_numtype > > >
+operator>(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Greater<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float > IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      Greater<float, int > > >
+operator>(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      Greater<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double > Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Greater<double, T_numtype2 > > >
+operator>(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Greater<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double > _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Greater<double, _bz_typename P_expr2::T_numtype > > >
+operator>(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Greater<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double > IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      Greater<double, int > > >
+operator>(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      Greater<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double > Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Greater<long double, T_numtype2 > > >
+operator>(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Greater<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double > _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Greater<long double, _bz_typename P_expr2::T_numtype > > >
+operator>(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Greater<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double > IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      Greater<long double, int > > >
+operator>(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      Greater<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> > Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Greater<complex<T1> , T_numtype2 > > >
+operator>(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Greater<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> > _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      Greater<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator>(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      Greater<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> > IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      Greater<complex<T1> , int > > >
+operator>(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      Greater<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Less-than Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> < Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Less<T_numtype1, T_numtype2 > > >
+operator<(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Less<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> < _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Less<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Less<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> < IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      Less<T_numtype1, int > > >
+operator<(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      Less<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> < int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      Less<T_numtype1, int > > >
+operator<(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      Less<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> < float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      Less<T_numtype1, float > > >
+operator<(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      Less<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> < double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      Less<T_numtype1, double > > >
+operator<(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      Less<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> < long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      Less<T_numtype1, long double > > >
+operator<(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Less<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> < complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Less<T_numtype1, complex<T2>  > > >
+operator<(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Less<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> < Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Less<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator<(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Less<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> < _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Less<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator<(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Less<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> < IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      Less<_bz_typename P_expr1::T_numtype, int > > >
+operator<(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      Less<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> < int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      Less<_bz_typename P_expr1::T_numtype, int > > >
+operator<(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      Less<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> < float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      Less<_bz_typename P_expr1::T_numtype, float > > >
+operator<(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      Less<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> < double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      Less<_bz_typename P_expr1::T_numtype, double > > >
+operator<(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      Less<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> < long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      Less<_bz_typename P_expr1::T_numtype, long double > > >
+operator<(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Less<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> < complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Less<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator<(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Less<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> < Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Less<int, T_numtype2 > > >
+operator<(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Less<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> < _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Less<int, _bz_typename P_expr2::T_numtype > > >
+operator<(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Less<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> < IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      Less<int, int > > >
+operator<(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      Less<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> < int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      Less<int, int > > >
+operator<(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      Less<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> < float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      Less<int, float > > >
+operator<(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      Less<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> < double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      Less<int, double > > >
+operator<(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      Less<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> < long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      Less<int, long double > > >
+operator<(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Less<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> < complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Less<int, complex<T2>  > > >
+operator<(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Less<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int < Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Less<int, T_numtype2 > > >
+operator<(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Less<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int < _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      Less<int, _bz_typename P_expr2::T_numtype > > >
+operator<(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Less<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int < IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      Less<int, int > > >
+operator<(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      Less<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float < Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Less<float, T_numtype2 > > >
+operator<(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Less<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float < _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      Less<float, _bz_typename P_expr2::T_numtype > > >
+operator<(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Less<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float < IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      Less<float, int > > >
+operator<(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      Less<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double < Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Less<double, T_numtype2 > > >
+operator<(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Less<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double < _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Less<double, _bz_typename P_expr2::T_numtype > > >
+operator<(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Less<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double < IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      Less<double, int > > >
+operator<(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      Less<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double < Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Less<long double, T_numtype2 > > >
+operator<(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Less<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double < _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Less<long double, _bz_typename P_expr2::T_numtype > > >
+operator<(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Less<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double < IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      Less<long double, int > > >
+operator<(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      Less<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> < Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Less<complex<T1> , T_numtype2 > > >
+operator<(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Less<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> < _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      Less<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator<(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      Less<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> < IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      Less<complex<T1> , int > > >
+operator<(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      Less<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Greater or equal (>=) operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> >= Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      GreaterOrEqual<T_numtype1, T_numtype2 > > >
+operator>=(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      GreaterOrEqual<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> >= _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      GreaterOrEqual<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>=(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      GreaterOrEqual<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> >= IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      GreaterOrEqual<T_numtype1, int > > >
+operator>=(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      GreaterOrEqual<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> >= int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      GreaterOrEqual<T_numtype1, int > > >
+operator>=(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      GreaterOrEqual<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> >= float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      GreaterOrEqual<T_numtype1, float > > >
+operator>=(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      GreaterOrEqual<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> >= double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      GreaterOrEqual<T_numtype1, double > > >
+operator>=(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      GreaterOrEqual<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> >= long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      GreaterOrEqual<T_numtype1, long double > > >
+operator>=(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      GreaterOrEqual<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> >= complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      GreaterOrEqual<T_numtype1, complex<T2>  > > >
+operator>=(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      GreaterOrEqual<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> >= Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator>=(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> >= _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator>=(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> >= IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator>=(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> >= int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator>=(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> >= float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, float > > >
+operator>=(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> >= double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, double > > >
+operator>=(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> >= long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, long double > > >
+operator>=(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> >= complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator>=(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> >= Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      GreaterOrEqual<int, T_numtype2 > > >
+operator>=(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      GreaterOrEqual<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> >= _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      GreaterOrEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator>=(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      GreaterOrEqual<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> >= IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      GreaterOrEqual<int, int > > >
+operator>=(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      GreaterOrEqual<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> >= int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      GreaterOrEqual<int, int > > >
+operator>=(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      GreaterOrEqual<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> >= float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      GreaterOrEqual<int, float > > >
+operator>=(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      GreaterOrEqual<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> >= double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      GreaterOrEqual<int, double > > >
+operator>=(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      GreaterOrEqual<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> >= long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      GreaterOrEqual<int, long double > > >
+operator>=(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      GreaterOrEqual<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> >= complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      GreaterOrEqual<int, complex<T2>  > > >
+operator>=(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      GreaterOrEqual<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int >= Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      GreaterOrEqual<int, T_numtype2 > > >
+operator>=(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      GreaterOrEqual<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int >= _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      GreaterOrEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator>=(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      GreaterOrEqual<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int >= IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      GreaterOrEqual<int, int > > >
+operator>=(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      GreaterOrEqual<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float >= Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      GreaterOrEqual<float, T_numtype2 > > >
+operator>=(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      GreaterOrEqual<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float >= _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      GreaterOrEqual<float, _bz_typename P_expr2::T_numtype > > >
+operator>=(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      GreaterOrEqual<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float >= IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      GreaterOrEqual<float, int > > >
+operator>=(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      GreaterOrEqual<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double >= Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      GreaterOrEqual<double, T_numtype2 > > >
+operator>=(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      GreaterOrEqual<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double >= _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      GreaterOrEqual<double, _bz_typename P_expr2::T_numtype > > >
+operator>=(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      GreaterOrEqual<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double >= IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      GreaterOrEqual<double, int > > >
+operator>=(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      GreaterOrEqual<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double >= Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      GreaterOrEqual<long double, T_numtype2 > > >
+operator>=(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      GreaterOrEqual<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double >= _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      GreaterOrEqual<long double, _bz_typename P_expr2::T_numtype > > >
+operator>=(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      GreaterOrEqual<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double >= IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      GreaterOrEqual<long double, int > > >
+operator>=(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      GreaterOrEqual<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> >= Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      GreaterOrEqual<complex<T1> , T_numtype2 > > >
+operator>=(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      GreaterOrEqual<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> >= _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      GreaterOrEqual<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator>=(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      GreaterOrEqual<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> >= IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      GreaterOrEqual<complex<T1> , int > > >
+operator>=(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      GreaterOrEqual<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Less or equal (<=) operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> <= Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LessOrEqual<T_numtype1, T_numtype2 > > >
+operator<=(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LessOrEqual<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> <= _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      LessOrEqual<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<=(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LessOrEqual<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> <= IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      LessOrEqual<T_numtype1, int > > >
+operator<=(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      LessOrEqual<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> <= int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      LessOrEqual<T_numtype1, int > > >
+operator<=(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      LessOrEqual<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> <= float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      LessOrEqual<T_numtype1, float > > >
+operator<=(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      LessOrEqual<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> <= double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      LessOrEqual<T_numtype1, double > > >
+operator<=(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      LessOrEqual<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> <= long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      LessOrEqual<T_numtype1, long double > > >
+operator<=(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      LessOrEqual<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> <= complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      LessOrEqual<T_numtype1, complex<T2>  > > >
+operator<=(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      LessOrEqual<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> <= Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LessOrEqual<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator<=(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LessOrEqual<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> <= _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      LessOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator<=(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LessOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> <= IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      LessOrEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator<=(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      LessOrEqual<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> <= int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      LessOrEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator<=(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      LessOrEqual<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> <= float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      LessOrEqual<_bz_typename P_expr1::T_numtype, float > > >
+operator<=(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      LessOrEqual<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> <= double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      LessOrEqual<_bz_typename P_expr1::T_numtype, double > > >
+operator<=(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      LessOrEqual<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> <= long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      LessOrEqual<_bz_typename P_expr1::T_numtype, long double > > >
+operator<=(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      LessOrEqual<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> <= complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      LessOrEqual<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator<=(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      LessOrEqual<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> <= Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LessOrEqual<int, T_numtype2 > > >
+operator<=(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LessOrEqual<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> <= _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      LessOrEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator<=(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LessOrEqual<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> <= IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      LessOrEqual<int, int > > >
+operator<=(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      LessOrEqual<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> <= int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      LessOrEqual<int, int > > >
+operator<=(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      LessOrEqual<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> <= float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      LessOrEqual<int, float > > >
+operator<=(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      LessOrEqual<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> <= double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      LessOrEqual<int, double > > >
+operator<=(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      LessOrEqual<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> <= long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      LessOrEqual<int, long double > > >
+operator<=(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      LessOrEqual<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> <= complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      LessOrEqual<int, complex<T2>  > > >
+operator<=(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      LessOrEqual<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int <= Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LessOrEqual<int, T_numtype2 > > >
+operator<=(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LessOrEqual<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int <= _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      LessOrEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator<=(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LessOrEqual<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int <= IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      LessOrEqual<int, int > > >
+operator<=(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      LessOrEqual<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float <= Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LessOrEqual<float, T_numtype2 > > >
+operator<=(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LessOrEqual<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float <= _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      LessOrEqual<float, _bz_typename P_expr2::T_numtype > > >
+operator<=(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LessOrEqual<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float <= IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      LessOrEqual<float, int > > >
+operator<=(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      LessOrEqual<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double <= Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LessOrEqual<double, T_numtype2 > > >
+operator<=(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LessOrEqual<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double <= _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      LessOrEqual<double, _bz_typename P_expr2::T_numtype > > >
+operator<=(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LessOrEqual<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double <= IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      LessOrEqual<double, int > > >
+operator<=(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      LessOrEqual<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double <= Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LessOrEqual<long double, T_numtype2 > > >
+operator<=(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LessOrEqual<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double <= _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      LessOrEqual<long double, _bz_typename P_expr2::T_numtype > > >
+operator<=(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LessOrEqual<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double <= IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      LessOrEqual<long double, int > > >
+operator<=(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      LessOrEqual<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> <= Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LessOrEqual<complex<T1> , T_numtype2 > > >
+operator<=(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LessOrEqual<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> <= _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      LessOrEqual<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator<=(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      LessOrEqual<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> <= IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      LessOrEqual<complex<T1> , int > > >
+operator<=(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      LessOrEqual<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Equality operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> == Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Equal<T_numtype1, T_numtype2 > > >
+operator==(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Equal<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> == _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Equal<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator==(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Equal<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> == IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      Equal<T_numtype1, int > > >
+operator==(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      Equal<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> == int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      Equal<T_numtype1, int > > >
+operator==(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      Equal<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> == float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      Equal<T_numtype1, float > > >
+operator==(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      Equal<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> == double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      Equal<T_numtype1, double > > >
+operator==(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      Equal<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> == long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      Equal<T_numtype1, long double > > >
+operator==(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Equal<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> == complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Equal<T_numtype1, complex<T2>  > > >
+operator==(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Equal<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> == Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Equal<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator==(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Equal<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> == _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Equal<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator==(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Equal<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> == IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      Equal<_bz_typename P_expr1::T_numtype, int > > >
+operator==(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      Equal<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> == int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      Equal<_bz_typename P_expr1::T_numtype, int > > >
+operator==(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      Equal<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> == float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      Equal<_bz_typename P_expr1::T_numtype, float > > >
+operator==(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      Equal<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> == double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      Equal<_bz_typename P_expr1::T_numtype, double > > >
+operator==(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      Equal<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> == long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      Equal<_bz_typename P_expr1::T_numtype, long double > > >
+operator==(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Equal<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> == complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Equal<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator==(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Equal<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> == Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Equal<int, T_numtype2 > > >
+operator==(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Equal<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> == _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      Equal<int, _bz_typename P_expr2::T_numtype > > >
+operator==(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Equal<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> == IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      Equal<int, int > > >
+operator==(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      Equal<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> == int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      Equal<int, int > > >
+operator==(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      Equal<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> == float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      Equal<int, float > > >
+operator==(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      Equal<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> == double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      Equal<int, double > > >
+operator==(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      Equal<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> == long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      Equal<int, long double > > >
+operator==(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      Equal<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> == complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      Equal<int, complex<T2>  > > >
+operator==(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      Equal<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int == Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Equal<int, T_numtype2 > > >
+operator==(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Equal<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int == _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      Equal<int, _bz_typename P_expr2::T_numtype > > >
+operator==(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Equal<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int == IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      Equal<int, int > > >
+operator==(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      Equal<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float == Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Equal<float, T_numtype2 > > >
+operator==(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Equal<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float == _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      Equal<float, _bz_typename P_expr2::T_numtype > > >
+operator==(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Equal<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float == IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      Equal<float, int > > >
+operator==(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      Equal<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double == Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Equal<double, T_numtype2 > > >
+operator==(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Equal<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double == _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Equal<double, _bz_typename P_expr2::T_numtype > > >
+operator==(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Equal<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double == IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      Equal<double, int > > >
+operator==(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      Equal<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double == Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Equal<long double, T_numtype2 > > >
+operator==(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Equal<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double == _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      Equal<long double, _bz_typename P_expr2::T_numtype > > >
+operator==(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      Equal<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double == IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      Equal<long double, int > > >
+operator==(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      Equal<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> == Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      Equal<complex<T1> , T_numtype2 > > >
+operator==(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      Equal<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> == _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      Equal<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator==(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      Equal<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> == IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      Equal<complex<T1> , int > > >
+operator==(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      Equal<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Not-equal operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> != Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      NotEqual<T_numtype1, T_numtype2 > > >
+operator!=(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      NotEqual<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> != _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      NotEqual<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator!=(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      NotEqual<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> != IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      NotEqual<T_numtype1, int > > >
+operator!=(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      NotEqual<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> != int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      NotEqual<T_numtype1, int > > >
+operator!=(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      NotEqual<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// Array<T_numtype1, N_rank1> != float
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>,
+      NotEqual<T_numtype1, float > > >
+operator!=(const Array<T_numtype1, N_rank1>& d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<float>, 
+      NotEqual<T_numtype1, float> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// Array<T_numtype1, N_rank1> != double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>,
+      NotEqual<T_numtype1, double > > >
+operator!=(const Array<T_numtype1, N_rank1>& d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<double>, 
+      NotEqual<T_numtype1, double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// Array<T_numtype1, N_rank1> != long double
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>,
+      NotEqual<T_numtype1, long double > > >
+operator!=(const Array<T_numtype1, N_rank1>& d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<long double>, 
+      NotEqual<T_numtype1, long double> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Array<T_numtype1, N_rank1> != complex<T2>
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      NotEqual<T_numtype1, complex<T2>  > > >
+operator!=(const Array<T_numtype1, N_rank1>& d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      NotEqual<T_numtype1, complex<T2> > >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_ArrayExpr<P_expr1> != Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      NotEqual<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator!=(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      NotEqual<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> != _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      NotEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator!=(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      NotEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> != IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      NotEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator!=(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      NotEqual<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> != int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      NotEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator!=(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      NotEqual<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> != float
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>,
+      NotEqual<_bz_typename P_expr1::T_numtype, float > > >
+operator!=(_bz_ArrayExpr<P_expr1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<float>, 
+      NotEqual<_bz_typename P_expr1::T_numtype, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> != double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>,
+      NotEqual<_bz_typename P_expr1::T_numtype, double > > >
+operator!=(_bz_ArrayExpr<P_expr1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<double>, 
+      NotEqual<_bz_typename P_expr1::T_numtype, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> != long double
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>,
+      NotEqual<_bz_typename P_expr1::T_numtype, long double > > >
+operator!=(_bz_ArrayExpr<P_expr1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<long double>, 
+      NotEqual<_bz_typename P_expr1::T_numtype, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_ArrayExpr<P_expr1> != complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      NotEqual<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator!=(_bz_ArrayExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      NotEqual<_bz_typename P_expr1::T_numtype, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// IndexPlaceholder<N_index1> != Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      NotEqual<int, T_numtype2 > > >
+operator!=(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      NotEqual<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> != _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      NotEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator!=(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      NotEqual<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> != IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      NotEqual<int, int > > >
+operator!=(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      NotEqual<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> != int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      NotEqual<int, int > > >
+operator!=(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      NotEqual<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> != float
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>,
+      NotEqual<int, float > > >
+operator!=(IndexPlaceholder<N_index1> d1, 
+      float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<float>, 
+      NotEqual<int, float> >
+      (d1, 
+      _bz_ArrayExprConstant<float>(d2));
+}
+
+// IndexPlaceholder<N_index1> != double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>,
+      NotEqual<int, double > > >
+operator!=(IndexPlaceholder<N_index1> d1, 
+      double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<double>, 
+      NotEqual<int, double> >
+      (d1, 
+      _bz_ArrayExprConstant<double>(d2));
+}
+
+// IndexPlaceholder<N_index1> != long double
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>,
+      NotEqual<int, long double > > >
+operator!=(IndexPlaceholder<N_index1> d1, 
+      long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<long double>, 
+      NotEqual<int, long double> >
+      (d1, 
+      _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// IndexPlaceholder<N_index1> != complex<T2>
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > ,
+      NotEqual<int, complex<T2>  > > >
+operator!=(IndexPlaceholder<N_index1> d1, 
+      complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<complex<T2> > , 
+      NotEqual<int, complex<T2> > >
+      (d1, 
+      _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int != Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      NotEqual<int, T_numtype2 > > >
+operator!=(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      NotEqual<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int != _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      NotEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator!=(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      NotEqual<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int != IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      NotEqual<int, int > > >
+operator!=(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      NotEqual<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// float != Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      NotEqual<float, T_numtype2 > > >
+operator!=(float d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      NotEqual<float, T_numtype2> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2.begin());
+}
+
+// float != _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>,
+      NotEqual<float, _bz_typename P_expr2::T_numtype > > >
+operator!=(float d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      _bz_ArrayExpr<P_expr2>, 
+      NotEqual<float, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// float != IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>,
+      NotEqual<float, int > > >
+operator!=(float d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, 
+      IndexPlaceholder<N_index2>, 
+      NotEqual<float, int> >
+      (_bz_ArrayExprConstant<float>(d1), 
+      d2);
+}
+
+// double != Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      NotEqual<double, T_numtype2 > > >
+operator!=(double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      NotEqual<double, T_numtype2> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2.begin());
+}
+
+// double != _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>,
+      NotEqual<double, _bz_typename P_expr2::T_numtype > > >
+operator!=(double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      NotEqual<double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// double != IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>,
+      NotEqual<double, int > > >
+operator!=(double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, 
+      IndexPlaceholder<N_index2>, 
+      NotEqual<double, int> >
+      (_bz_ArrayExprConstant<double>(d1), 
+      d2);
+}
+
+// long double != Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      NotEqual<long double, T_numtype2 > > >
+operator!=(long double d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      NotEqual<long double, T_numtype2> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2.begin());
+}
+
+// long double != _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>,
+      NotEqual<long double, _bz_typename P_expr2::T_numtype > > >
+operator!=(long double d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      _bz_ArrayExpr<P_expr2>, 
+      NotEqual<long double, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+// long double != IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>,
+      NotEqual<long double, int > > >
+operator!=(long double d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, 
+      IndexPlaceholder<N_index2>, 
+      NotEqual<long double, int> >
+      (_bz_ArrayExprConstant<long double>(d1), 
+      d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> != Array<T_numtype2, N_rank2>
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>,
+      NotEqual<complex<T1> , T_numtype2 > > >
+operator!=(complex<T1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      NotEqual<complex<T1> , T_numtype2> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2.begin());
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> != _bz_ArrayExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>,
+      NotEqual<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator!=(complex<T1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      _bz_ArrayExpr<P_expr2>, 
+      NotEqual<complex<T1> , _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<T1> != IndexPlaceholder<N_index2>
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>,
+      NotEqual<complex<T1> , int > > >
+operator!=(complex<T1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , 
+      IndexPlaceholder<N_index2>, 
+      NotEqual<complex<T1> , int> >
+      (_bz_ArrayExprConstant<complex<T1> > (d1), 
+      d2);
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Logical AND operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> && Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LogicalAnd<T_numtype1, T_numtype2 > > >
+operator&&(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LogicalAnd<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> && _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      LogicalAnd<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator&&(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LogicalAnd<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> && IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      LogicalAnd<T_numtype1, int > > >
+operator&&(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      LogicalAnd<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> && int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      LogicalAnd<T_numtype1, int > > >
+operator&&(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      LogicalAnd<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> && Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LogicalAnd<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator&&(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LogicalAnd<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> && _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      LogicalAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator&&(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LogicalAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> && IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      LogicalAnd<_bz_typename P_expr1::T_numtype, int > > >
+operator&&(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      LogicalAnd<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> && int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      LogicalAnd<_bz_typename P_expr1::T_numtype, int > > >
+operator&&(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      LogicalAnd<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> && Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LogicalAnd<int, T_numtype2 > > >
+operator&&(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LogicalAnd<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> && _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      LogicalAnd<int, _bz_typename P_expr2::T_numtype > > >
+operator&&(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LogicalAnd<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> && IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      LogicalAnd<int, int > > >
+operator&&(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      LogicalAnd<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> && int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      LogicalAnd<int, int > > >
+operator&&(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      LogicalAnd<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// int && Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LogicalAnd<int, T_numtype2 > > >
+operator&&(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LogicalAnd<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int && _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      LogicalAnd<int, _bz_typename P_expr2::T_numtype > > >
+operator&&(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LogicalAnd<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int && IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      LogicalAnd<int, int > > >
+operator&&(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      LogicalAnd<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+/****************************************************************************
+ * Logical OR operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> || Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LogicalOr<T_numtype1, T_numtype2 > > >
+operator||(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LogicalOr<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> || _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      LogicalOr<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator||(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LogicalOr<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> || IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      LogicalOr<T_numtype1, int > > >
+operator||(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      LogicalOr<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> || int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      LogicalOr<T_numtype1, int > > >
+operator||(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      LogicalOr<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> || Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LogicalOr<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator||(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LogicalOr<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> || _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      LogicalOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator||(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LogicalOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> || IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      LogicalOr<_bz_typename P_expr1::T_numtype, int > > >
+operator||(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      LogicalOr<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> || int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      LogicalOr<_bz_typename P_expr1::T_numtype, int > > >
+operator||(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      LogicalOr<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> || Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LogicalOr<int, T_numtype2 > > >
+operator||(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LogicalOr<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> || _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      LogicalOr<int, _bz_typename P_expr2::T_numtype > > >
+operator||(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LogicalOr<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> || IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      LogicalOr<int, int > > >
+operator||(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      LogicalOr<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> || int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      LogicalOr<int, int > > >
+operator||(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      LogicalOr<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// int || Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      LogicalOr<int, T_numtype2 > > >
+operator||(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      LogicalOr<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int || _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      LogicalOr<int, _bz_typename P_expr2::T_numtype > > >
+operator||(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      LogicalOr<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int || IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      LogicalOr<int, int > > >
+operator||(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      LogicalOr<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+/****************************************************************************
+ * Bitwise XOR Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> ^ Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseXor<T_numtype1, T_numtype2 > > >
+operator^(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseXor<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> ^ _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseXor<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator^(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseXor<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> ^ IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseXor<T_numtype1, int > > >
+operator^(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseXor<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> ^ int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      BitwiseXor<T_numtype1, int > > >
+operator^(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      BitwiseXor<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> ^ Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseXor<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator^(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseXor<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> ^ _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseXor<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator^(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseXor<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> ^ IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseXor<_bz_typename P_expr1::T_numtype, int > > >
+operator^(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseXor<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> ^ int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      BitwiseXor<_bz_typename P_expr1::T_numtype, int > > >
+operator^(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      BitwiseXor<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> ^ Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseXor<int, T_numtype2 > > >
+operator^(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseXor<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> ^ _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseXor<int, _bz_typename P_expr2::T_numtype > > >
+operator^(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseXor<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> ^ IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseXor<int, int > > >
+operator^(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseXor<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> ^ int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      BitwiseXor<int, int > > >
+operator^(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      BitwiseXor<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// int ^ Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseXor<int, T_numtype2 > > >
+operator^(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseXor<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int ^ _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseXor<int, _bz_typename P_expr2::T_numtype > > >
+operator^(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseXor<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int ^ IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseXor<int, int > > >
+operator^(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseXor<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+/****************************************************************************
+ * Bitwise And Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> & Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseAnd<T_numtype1, T_numtype2 > > >
+operator&(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseAnd<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> & _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseAnd<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator&(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseAnd<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> & IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseAnd<T_numtype1, int > > >
+operator&(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseAnd<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> & int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      BitwiseAnd<T_numtype1, int > > >
+operator&(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      BitwiseAnd<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> & Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseAnd<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator&(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseAnd<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> & _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator&(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> & IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseAnd<_bz_typename P_expr1::T_numtype, int > > >
+operator&(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseAnd<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> & int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      BitwiseAnd<_bz_typename P_expr1::T_numtype, int > > >
+operator&(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      BitwiseAnd<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> & Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseAnd<int, T_numtype2 > > >
+operator&(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseAnd<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> & _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseAnd<int, _bz_typename P_expr2::T_numtype > > >
+operator&(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseAnd<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> & IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseAnd<int, int > > >
+operator&(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseAnd<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> & int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      BitwiseAnd<int, int > > >
+operator&(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      BitwiseAnd<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// int & Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseAnd<int, T_numtype2 > > >
+operator&(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseAnd<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int & _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseAnd<int, _bz_typename P_expr2::T_numtype > > >
+operator&(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseAnd<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int & IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseAnd<int, int > > >
+operator&(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseAnd<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+/****************************************************************************
+ * Bitwise Or Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> | Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseOr<T_numtype1, T_numtype2 > > >
+operator|(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseOr<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> | _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseOr<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator|(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseOr<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> | IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseOr<T_numtype1, int > > >
+operator|(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseOr<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> | int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      BitwiseOr<T_numtype1, int > > >
+operator|(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      BitwiseOr<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> | Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseOr<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator|(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseOr<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> | _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator|(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> | IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseOr<_bz_typename P_expr1::T_numtype, int > > >
+operator|(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseOr<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> | int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      BitwiseOr<_bz_typename P_expr1::T_numtype, int > > >
+operator|(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      BitwiseOr<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> | Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseOr<int, T_numtype2 > > >
+operator|(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseOr<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> | _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseOr<int, _bz_typename P_expr2::T_numtype > > >
+operator|(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseOr<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> | IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseOr<int, int > > >
+operator|(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseOr<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> | int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      BitwiseOr<int, int > > >
+operator|(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      BitwiseOr<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// int | Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      BitwiseOr<int, T_numtype2 > > >
+operator|(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      BitwiseOr<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int | _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      BitwiseOr<int, _bz_typename P_expr2::T_numtype > > >
+operator|(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      BitwiseOr<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int | IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      BitwiseOr<int, int > > >
+operator|(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      BitwiseOr<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+/****************************************************************************
+ * Shift right Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> >> Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      ShiftRight<T_numtype1, T_numtype2 > > >
+operator>>(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      ShiftRight<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> >> _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      ShiftRight<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>>(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      ShiftRight<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> >> IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      ShiftRight<T_numtype1, int > > >
+operator>>(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      ShiftRight<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> >> int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      ShiftRight<T_numtype1, int > > >
+operator>>(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      ShiftRight<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> >> Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      ShiftRight<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator>>(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      ShiftRight<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> >> _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      ShiftRight<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator>>(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      ShiftRight<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> >> IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      ShiftRight<_bz_typename P_expr1::T_numtype, int > > >
+operator>>(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      ShiftRight<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> >> int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      ShiftRight<_bz_typename P_expr1::T_numtype, int > > >
+operator>>(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      ShiftRight<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> >> Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      ShiftRight<int, T_numtype2 > > >
+operator>>(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      ShiftRight<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> >> _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      ShiftRight<int, _bz_typename P_expr2::T_numtype > > >
+operator>>(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      ShiftRight<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> >> IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      ShiftRight<int, int > > >
+operator>>(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      ShiftRight<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> >> int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      ShiftRight<int, int > > >
+operator>>(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      ShiftRight<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// int >> Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      ShiftRight<int, T_numtype2 > > >
+operator>>(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      ShiftRight<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int >> _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      ShiftRight<int, _bz_typename P_expr2::T_numtype > > >
+operator>>(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      ShiftRight<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int >> IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      ShiftRight<int, int > > >
+operator>>(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      ShiftRight<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+/****************************************************************************
+ * Shift left Operators
+ ****************************************************************************/
+
+// Array<T_numtype1, N_rank1> << Array<T_numtype2, N_rank2>
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      ShiftLeft<T_numtype1, T_numtype2 > > >
+operator<<(const Array<T_numtype1, N_rank1>& d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      ShiftLeft<T_numtype1, T_numtype2> >
+      (d1.begin(), 
+      d2.begin());
+}
+
+// Array<T_numtype1, N_rank1> << _bz_ArrayExpr<P_expr2>
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>,
+      ShiftLeft<T_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<<(const Array<T_numtype1, N_rank1>& d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      ShiftLeft<T_numtype1, _bz_typename P_expr2::T_numtype> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> << IndexPlaceholder<N_index2>
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>,
+      ShiftLeft<T_numtype1, int > > >
+operator<<(const Array<T_numtype1, N_rank1>& d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      IndexPlaceholder<N_index2>, 
+      ShiftLeft<T_numtype1, int> >
+      (d1.begin(), 
+      d2);
+}
+
+// Array<T_numtype1, N_rank1> << int
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>,
+      ShiftLeft<T_numtype1, int > > >
+operator<<(const Array<T_numtype1, N_rank1>& d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, 
+      _bz_ArrayExprConstant<int>, 
+      ShiftLeft<T_numtype1, int> >
+      (d1.begin(), 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// _bz_ArrayExpr<P_expr1> << Array<T_numtype2, N_rank2>
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      ShiftLeft<_bz_typename P_expr1::T_numtype, T_numtype2 > > >
+operator<<(_bz_ArrayExpr<P_expr1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      ShiftLeft<_bz_typename P_expr1::T_numtype, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// _bz_ArrayExpr<P_expr1> << _bz_ArrayExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>,
+      ShiftLeft<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator<<(_bz_ArrayExpr<P_expr1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      ShiftLeft<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> << IndexPlaceholder<N_index2>
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>,
+      ShiftLeft<_bz_typename P_expr1::T_numtype, int > > >
+operator<<(_bz_ArrayExpr<P_expr1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      IndexPlaceholder<N_index2>, 
+      ShiftLeft<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      d2);
+}
+
+// _bz_ArrayExpr<P_expr1> << int
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>,
+      ShiftLeft<_bz_typename P_expr1::T_numtype, int > > >
+operator<<(_bz_ArrayExpr<P_expr1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, 
+      _bz_ArrayExprConstant<int>, 
+      ShiftLeft<_bz_typename P_expr1::T_numtype, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// IndexPlaceholder<N_index1> << Array<T_numtype2, N_rank2>
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      ShiftLeft<int, T_numtype2 > > >
+operator<<(IndexPlaceholder<N_index1> d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      ShiftLeft<int, T_numtype2> >
+      (d1, 
+      d2.begin());
+}
+
+// IndexPlaceholder<N_index1> << _bz_ArrayExpr<P_expr2>
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>,
+      ShiftLeft<int, _bz_typename P_expr2::T_numtype > > >
+operator<<(IndexPlaceholder<N_index1> d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExpr<P_expr2>, 
+      ShiftLeft<int, _bz_typename P_expr2::T_numtype> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> << IndexPlaceholder<N_index2>
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>,
+      ShiftLeft<int, int > > >
+operator<<(IndexPlaceholder<N_index1> d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      IndexPlaceholder<N_index2>, 
+      ShiftLeft<int, int> >
+      (d1, 
+      d2);
+}
+
+// IndexPlaceholder<N_index1> << int
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>,
+      ShiftLeft<int, int > > >
+operator<<(IndexPlaceholder<N_index1> d1, 
+      int d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, 
+      _bz_ArrayExprConstant<int>, 
+      ShiftLeft<int, int> >
+      (d1, 
+      _bz_ArrayExprConstant<int>(d2));
+}
+
+// int << Array<T_numtype2, N_rank2>
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>,
+      ShiftLeft<int, T_numtype2 > > >
+operator<<(int d1, 
+      const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      ArrayIterator<T_numtype2, N_rank2>, 
+      ShiftLeft<int, T_numtype2> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2.begin());
+}
+
+// int << _bz_ArrayExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>,
+      ShiftLeft<int, _bz_typename P_expr2::T_numtype > > >
+operator<<(int d1, 
+      _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      _bz_ArrayExpr<P_expr2>, 
+      ShiftLeft<int, _bz_typename P_expr2::T_numtype> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+
+// int << IndexPlaceholder<N_index2>
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>,
+      ShiftLeft<int, int > > >
+operator<<(int d1, 
+      IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<int>, 
+      IndexPlaceholder<N_index2>, 
+      ShiftLeft<int, int> >
+      (_bz_ArrayExprConstant<int>(d1), 
+      d2);
+}
+BZ_NAMESPACE_END
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/cartesian.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/cartesian.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/cartesian.h	(revision 1307)
@@ -0,0 +1,155 @@
+#ifndef BZ_ARRAY_CARTESIAN_H
+#define BZ_ARRAY_CARTESIAN_H
+
+/*
+ * CartesianProduct<T_tuple,T_container> is an adaptor which represents
+ * the cartesian product of several containers.  
+ */
+
+// forward declaration of iterator
+template<class T_tuple, class T_container, int N_containers>
+class CartesianProductIterator;
+
+struct _cp_end_tag { };
+
+template<class T_tuple, class T_container, int N_containers>
+class CartesianProduct {
+public:
+    typedef T_tuple value_type;
+    typedef T_tuple& reference;
+    typedef const T_tuple& const_reference;
+    typedef CartesianProductIterator<T_tuple,T_container,N_containers> iterator;
+    typedef int difference_type;
+    typedef int size_type;
+
+    iterator begin()
+    { return iterator(*this); }
+
+    iterator end()
+    { return iterator(_cp_end_tag()); }
+
+    CartesianProduct(const T_container& container0, 
+        const T_container& container1)
+    { 
+        BZPRECONDITION(N_containers == 2);
+        containers_[0] = &container0;
+        containers_[1] = &container1;
+    }
+
+    CartesianProduct(const T_container& container0, 
+        const T_container& container1,
+        const T_container& container2)
+    { 
+        BZPRECONDITION(N_containers == 3);
+        containers_[0] = &container0;
+        containers_[1] = &container1;
+        containers_[2] = &container2;
+    }
+
+    const T_container& operator[](int i)
+    { return *(containers_[i]); }
+
+    void debugDump();
+
+protected:
+    const T_container* containers_[N_containers]; 
+};
+
+template<class T_tuple, class T_container, int N_containers>
+void CartesianProduct<T_tuple,T_container,N_containers>::debugDump()
+{
+    cout << "Dump of CartesianProduct<..,..," << N_containers << ">" << endl;
+    for (int i=0; i < N_containers; ++i)
+    {
+        cout << "Container " << (i+1) << ": ";
+        _bz_typename T_container::const_iterator iter = containers_[i]->begin(),
+            end = containers_[i]->end();
+        for (; iter != end; ++iter)
+            cout << (*iter) << '\t'; 
+    }
+}
+
+template<class T_tuple, class T_container, int N_containers>
+class CartesianProductIterator {
+public:
+    typedef _bz_typename T_container::const_iterator citerator;
+    typedef CartesianProductIterator<T_tuple,T_container,N_containers> iterator;
+    typedef CartesianProduct<T_tuple,T_container,N_containers> T_cp;
+
+    CartesianProductIterator(T_cp& container)
+    {
+        for (int i=0; i < N_containers; ++i)
+        {
+            firstiters_[i] = container[i].begin();
+            iters_[i] = firstiters_[i];
+            enditers_[i] = container[i].end();
+            tuple_[i] = *iters_[i];
+        }
+
+        endflag_ = _bz_false;
+    }
+
+    void operator++();
+
+    CartesianProductIterator(_cp_end_tag)
+    {
+        endflag_ = _bz_true;
+    }
+
+    _bz_bool operator==(const iterator& x) const
+    {
+        return (endflag_ == x.endflag_);
+    }
+
+    _bz_bool operator!=(const iterator& x) const
+    {   
+        return endflag_ != x.endflag_;
+    }
+
+    const T_tuple& operator*() const
+    { return tuple_; }
+
+protected:
+    citerator iters_[N_containers];
+    citerator firstiters_[N_containers];
+    citerator enditers_[N_containers];
+    T_tuple tuple_;
+    _bz_bool endflag_;
+};
+
+template<class T_tuple, class T_container, int N_containers>
+void CartesianProductIterator<T_tuple, T_container, 
+    N_containers>::operator++()
+{
+    // NEEDS_WORK: put in short-circuit for most common case
+    // (just increment the last iterator)
+
+    // Usual stack-style increment
+    const int Nminus1 = N_containers - 1;
+
+    int i = Nminus1;
+
+    for (; i >= 0; --i)
+    {
+        ++iters_[i];
+        if (iters_[i] != enditers_[i])
+            break;
+    }
+
+    if (i == -1)
+    {
+        endflag_ = _bz_true;
+        return;
+    }
+
+    tuple_[i] = *iters_[i];
+
+    for (++i; i < N_containers; ++i)  
+    {
+        iters_[i] = firstiters_[i];
+        tuple_[i] = *iters_[i];
+    }
+}
+
+#endif // BZ_ARRAY_CARTESIAN_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/cgsolve.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/cgsolve.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/cgsolve.h	(revision 1307)
@@ -0,0 +1,126 @@
+#ifndef BZ_CGSOLVE_H
+#define BZ_CGSOLVE_H
+
+BZ_NAMESPACE(blitz)
+
+template<class T_numtype>
+void dump(const char* name, Array<T_numtype,3>& A)
+{
+    T_numtype normA = 0;
+
+    for (int i=A.lbound(0); i <= A.ubound(0); ++i)
+    {
+      for (int j=A.lbound(1); j <= A.ubound(1); ++j)
+      {
+        for (int k=A.lbound(2); k <= A.ubound(2); ++k)
+        {
+            T_numtype tmp = A(i,j,k);
+            normA += ::fabs(tmp);
+        }
+      }
+    }
+
+    normA /= A.numElements();
+    cout << "Average magnitude of " << name << " is " << normA << endl;
+}
+
+template<class T_stencil, class T_numtype, int N_rank, class T_BCs>
+int conjugateGradientSolver(T_stencil stencil,
+    Array<T_numtype,N_rank>& x,
+    Array<T_numtype,N_rank>& rhs, double haltrho, 
+    const T_BCs& boundaryConditions)
+{
+    // NEEDS_WORK: only apply CG updates over interior; need to handle
+    // BCs separately.
+
+    // x = unknowns being solved for (initial guess assumed)
+    // r = residual
+    // p = descent direction for x
+    // q = descent direction for r
+
+    RectDomain<N_rank> interior = interiorDomain(stencil, x, rhs);
+
+cout << "Interior: " << interior.lbound() << ", " << interior.ubound()
+     << endl;
+
+    // Calculate initial residual
+    Array<T_numtype,N_rank> r = rhs.copy();
+    r *= -1.0;
+
+    boundaryConditions.applyBCs(x);
+
+    applyStencil(stencil, r, x);
+
+ dump("r after stencil", r);
+ cout << "Slice through r: " << endl << r(23,17,Range::all()) << endl;
+ cout << "Slice through x: " << endl << x(23,17,Range::all()) << endl;
+ cout << "Slice through rhs: " << endl << rhs(23,17,Range::all()) << endl;
+
+    r *= -1.0;
+
+ dump("r", r);
+
+    // Allocate the descent direction arrays
+    Array<T_numtype,N_rank> p, q;
+    allocateArrays(x.shape(), p, q);
+
+    int iteration = 0;
+    int converged = 0;
+    T_numtype rho = 0.;
+    T_numtype oldrho = 0.;
+
+    const int maxIterations = 1000;
+
+    // Get views of interior of arrays (without boundaries)
+    Array<T_numtype,N_rank> rint = r(interior);
+    Array<T_numtype,N_rank> pint = p(interior);
+    Array<T_numtype,N_rank> qint = q(interior);
+    Array<T_numtype,N_rank> xint = x(interior);
+
+    while (iteration < maxIterations)
+    {
+        rho = sum(r * r);
+
+        if ((iteration % 20) == 0)
+            cout << "CG: Iter " << iteration << "\t rho = " << rho << endl;
+
+        // Check halting condition
+        if (rho < haltrho)
+        {
+            converged = 1;
+            break;
+        }
+
+        if (iteration == 0)
+        {
+            p = r;
+        }
+        else {
+            T_numtype beta = rho / oldrho;
+            p = beta * p + r;
+        }
+
+        q = 0.;
+//        boundaryConditions.applyBCs(p);
+        applyStencil(stencil, q, p);
+
+        T_numtype pq = sum(p*q);
+
+        T_numtype alpha = rho / pq;
+
+        x += alpha * p;
+        r -= alpha * q;
+
+        oldrho = rho;
+        ++iteration;
+    }
+
+    if (!converged)
+        cout << "Warning: CG solver did not converge" << endl;
+
+    return iteration;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_CGSOLVE_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/complex.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/complex.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/complex.cc	(revision 1307)
@@ -0,0 +1,31 @@
+// Special functions for complex arrays
+
+#ifndef BZ_ARRAYCOMPLEX_CC
+#define BZ_ARRAYCOMPLEX_CC
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/complex.cc> must be included via <blitz/array/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+#ifdef BZ_HAVE_COMPLEX
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank> real(Array<complex<T_numtype>,N_rank>& A)
+{
+    return A.extractComponent(T_numtype(), 0, 2);
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank> imag(Array<complex<T_numtype>,N_rank>& A)
+{
+    return A.extractComponent(T_numtype(), 1, 2);
+}
+
+#endif
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYCOMPLEX_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/cycle.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/cycle.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/cycle.cc	(revision 1307)
@@ -0,0 +1,54 @@
+#ifndef BZ_ARRAYCYCLE_CC
+#define BZ_ARRAYCYCLE_CC
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/cycle.cc> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class T_numtype, int N_rank>
+void cycleArrays(Array<T_numtype, N_rank>& a, Array<T_numtype, N_rank>& b)
+{
+    Array<T_numtype, N_rank> tmp(a);
+    a.reference(b);
+    b.reference(tmp);
+}
+
+template<class T_numtype, int N_rank>
+void cycleArrays(Array<T_numtype, N_rank>& a, Array<T_numtype, N_rank>& b,
+    Array<T_numtype, N_rank>& c)
+{
+    Array<T_numtype, N_rank> tmp(a);
+    a.reference(b);
+    b.reference(c);
+    c.reference(tmp);
+}
+
+template<class T_numtype, int N_rank>
+void cycleArrays(Array<T_numtype, N_rank>& a, Array<T_numtype, N_rank>& b,
+    Array<T_numtype, N_rank>& c, Array<T_numtype, N_rank>& d)
+{
+    Array<T_numtype, N_rank> tmp(a);
+    a.reference(b);
+    b.reference(c);
+    c.reference(d);
+    d.reference(tmp);
+}
+
+template<class T_numtype, int N_rank>
+void cycleArrays(Array<T_numtype, N_rank>& a, Array<T_numtype, N_rank>& b,
+    Array<T_numtype, N_rank>& c, Array<T_numtype, N_rank>& d,
+    Array<T_numtype, N_rank>& e)
+{
+    Array<T_numtype, N_rank> tmp(a);
+    a.reference(b);
+    b.reference(c);
+    c.reference(d);
+    d.reference(e);
+    e.reference(tmp);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYCYCLE_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/domain.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/domain.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/domain.h	(revision 1307)
@@ -0,0 +1,89 @@
+#ifndef BZ_DOMAIN_H
+#define BZ_DOMAIN_H
+
+#ifndef BZ_TINYVEC_H
+ #include <blitz/tinyvec.h>
+#endif
+
+#ifndef BZ_RANGE_H
+ #include <blitz/range.h>
+#endif
+
+/*
+ * Portions of this class were inspired by the "RectDomain" class
+ * provided by the Titanium language (UC Berkeley).
+ */
+
+BZ_NAMESPACE(blitz)
+
+template<int N_rank>
+class RectDomain {
+
+public:
+    RectDomain(const TinyVector<int,N_rank>& lbound,
+        const TinyVector<int,N_rank>& ubound)
+      : lbound_(lbound), ubound_(ubound)
+    { }
+
+    // NEEDS_WORK: better constructors
+    // RectDomain(Range, Range, ...)
+    // RectDomain with any combination of Range and int
+
+    const TinyVector<int,N_rank>& lbound() const
+    { return lbound_; }
+
+    int lbound(int i) const
+    { return lbound_(i); }
+
+    const TinyVector<int,N_rank>& ubound() const
+    { return ubound_; }
+
+    int ubound(int i) const
+    { return ubound_(i); }
+
+    Range operator[](int rank) const
+    { return Range(lbound_(rank), ubound_(rank)); }
+
+    void shrink(int amount)
+    {
+        lbound_ += amount;
+        ubound_ -= amount;
+    }
+
+    void shrink(int dim, int amount)
+    {
+        lbound_(dim) += amount;
+        ubound_(dim) -= amount;
+    }
+
+    void expand(int amount)
+    {
+        lbound_ -= amount;
+        ubound_ += amount;
+    }
+
+    void expand(int dim, int amount)
+    {
+        lbound_(dim) -= amount;
+        ubound_(dim) += amount;
+    }
+
+private:
+    TinyVector<int,N_rank> lbound_, ubound_;
+};
+
+template<int N_rank>
+inline RectDomain<N_rank> strip(const TinyVector<int,N_rank>& startPosition,
+    int stripDimension, int ubound)
+{
+    BZPRECONDITION((stripDimension >= 0) && (stripDimension < N_rank));
+    BZPRECONDITION(ubound >= startPosition(stripDimension));
+
+    TinyVector<int,N_rank> endPosition = startPosition;
+    endPosition(stripDimension) = ubound;
+    return RectDomain<N_rank>(startPosition, endPosition);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_DOMAIN_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/eval.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/eval.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/eval.cc	(revision 1307)
@@ -0,0 +1,1206 @@
+/*
+ * $Id: eval.cc,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1998/02/25 20:04:01  tveldhui
+ * Initial revision
+ *
+ */
+
+#ifndef BZ_ARRAYEVAL_CC
+#define BZ_ARRAYEVAL_CC
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/eval.cc> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * Assign an expression to an array.  For performance reasons, there are
+ * several traversal mechanisms:
+ *
+ * - Index traversal scans through the destination array in storage order.
+ *   The expression is evaluated using a TinyVector<int,N> operand.  This
+ *   version is used only when there are index placeholders in the expression
+ *   (see <blitz/indexexpr.h>)
+ * - Stack traversal also scans through the destination array in storage
+ *   order.  However, push/pop stack iterators are used.
+ * - Fast traversal follows a Hilbert (or other) space-filling curve to
+ *   improve cache reuse for stencilling operations.  Currently, the
+ *   space filling curves must be generated by calling 
+ *   generateFastTraversalOrder(TinyVector<int,N_dimensions>).
+ * - 2D tiled traversal follows a tiled traversal, to improve cache reuse
+ *   for 2D stencils.  Space filling curves have too much overhead to use
+ *   in two-dimensions.
+ *
+ * _bz_tryFastTraversal is a helper class.  Fast traversals are only
+ * attempted if the expression looks like a stencil -- it's at least
+ * three-dimensional, has at least six array operands, and there are
+ * no index placeholders in the expression.  These are all things which
+ * can be checked at compile time, so the if()/else() syntax has been
+ * replaced with this class template.
+ */
+
+// Fast traversals require <set> from the ISO/ANSI C++ standard library
+#ifdef BZ_HAVE_STD
+
+template<_bz_bool canTryFastTraversal>
+struct _bz_tryFastTraversal {
+    template<class T_numtype, int N_rank, class T_expr, class T_update>
+    static _bz_bool tryFast(Array<T_numtype,N_rank>& array, 
+        _bz_ArrayExpr<T_expr> expr, T_update)
+    {
+        return _bz_false;
+    }
+};
+
+template<>
+struct _bz_tryFastTraversal<_bz_true> {
+    template<class T_numtype, int N_rank, class T_expr, class T_update>
+    static _bz_bool tryFast(Array<T_numtype,N_rank>& array, 
+        _bz_ArrayExpr<T_expr> expr, T_update)
+    {
+        // See if there's an appropriate space filling curve available.
+        // Currently fast traversals use an N-1 dimensional curve.  The
+        // Nth dimension column corresponding to each point on the curve
+        // is traversed in the normal fashion.
+        TraversalOrderCollection<N_rank-1> traversals;
+        TinyVector<int, N_rank - 1> traversalGridSize;
+
+        for (int i=0; i < N_rank - 1; ++i)
+            traversalGridSize[i] = array.length(array.ordering(i+1));
+
+#ifdef BZ_DEBUG_TRAVERSE
+cout << "traversalGridSize = " << traversalGridSize << endl;
+cout.flush();
+#endif
+
+        const TraversalOrder<N_rank-1>* order =
+            traversals.find(traversalGridSize);
+
+        if (order)
+        {
+#ifdef BZ_DEBUG_TRAVERSE
+    cerr << "Array<" << BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(T_numtype)
+         << ", " << N_rank << ">: Using stack traversal" << endl;
+#endif
+            // A curve was available -- use fast traversal.
+            array.evaluateWithFastTraversal(*order, expr, T_update());
+            return _bz_true;
+        }
+
+        return _bz_false;
+    }
+};
+
+#endif // BZ_HAVE_STD
+
+template<class T_numtype, int N_rank> template<class T_expr, class T_update>
+inline Array<T_numtype, N_rank>& 
+Array<T_numtype, N_rank>::evaluate(_bz_ArrayExpr<T_expr> expr, T_update)
+{
+    // Check that all arrays have the same shape
+#ifdef BZ_DEBUG
+    if (!expr.shapeCheck(shape()))
+    {
+      if (assertFailMode == _bz_false)
+      {
+        cerr << "[Blitz++] Shape check failed: Module " << __FILE__
+             << " line " << __LINE__ << endl
+             << "          Expression: ";
+        prettyPrintFormat format(_bz_true);   // Use terse formatting
+        string str;
+        expr.prettyPrint(str, format);
+        cerr << str << endl ;
+      }
+
+#if 0
+// Shape dumping is broken by change to using string for prettyPrint
+             << "          Shapes: " << shape() << " = ";
+        prettyPrintFormat format2;
+        format2.setDumpArrayShapesMode();
+        expr.prettyPrint(cerr, format2);
+        cerr << endl;
+#endif
+        BZ_PRE_FAIL;
+    }
+#endif
+
+    BZPRECHECK(expr.shapeCheck(shape()),
+        "Shape check failed." << endl << "Expression:");
+
+    BZPRECHECK((T_expr::rank == N_rank) || (T_expr::numArrayOperands == 0), 
+        "Assigned rank " << T_expr::rank << " expression to rank " 
+        << N_rank << " array.");
+
+#ifdef BZ_DEBUG_TRAVERSE
+cout << "T_expr::numIndexPlaceholders = " << T_expr::numIndexPlaceholders
+     << endl; cout.flush();
+#endif
+
+    // Tau profiling code.  Provide Tau with a pretty-printed version of
+    // the expression.
+    // NEEDS_WORK-- use a static initializer somehow.
+
+#ifdef BZ_TAU_PROFILING
+    static string exprDescription;
+    if (!exprDescription.length())   // faked static initializer
+    {
+        exprDescription = "A";
+        prettyPrintFormat format(_bz_true);   // Terse mode on
+        format.nextArrayOperandSymbol();
+        T_update::prettyPrint(exprDescription);
+        expr.prettyPrint(exprDescription, format);
+    }
+    TAU_PROFILE(" ", exprDescription, TAU_BLITZ);
+#endif
+
+    // Determine which evaluation mechanism to use 
+    if (T_expr::numIndexPlaceholders > 0)
+    {
+        // The expression involves index placeholders, so have to
+        // use index traversal rather than stack traversal.
+
+        if (N_rank == 1)
+            return evaluateWithIndexTraversal1(expr, T_update());
+        else
+            return evaluateWithIndexTraversalN(expr, T_update());
+    }
+    else {
+
+        // If this expression looks like an array stencil, then attempt to
+        // use a fast traversal order.
+        // Fast traversals require <set> from the ISO/ANSI C++ standard
+        // library.
+
+#ifdef BZ_HAVE_STD
+
+        enum { isStencil = (N_rank >= 3) && (T_expr::numArrayOperands > 6)
+            && (T_expr::numIndexPlaceholders == 0) };
+
+        if (_bz_tryFastTraversal<isStencil>::tryFast(*this, expr, T_update()))
+            return *this;
+
+#endif
+
+#ifdef BZ_ARRAY_2D_STENCIL_TILING
+        // Does this look like a 2-dimensional stencil on a largeish
+        // array?
+
+        if ((N_rank == 2) && (T_expr::numArrayOperands >= 5))
+        {
+            // Use a heuristic to determine whether a tiled traversal
+            // is desirable.  First, estimate how much L1 cache is needed 
+            // to achieve a high hit rate using the stack traversal.
+            // Try to err on the side of using tiled traversal even when
+            // it isn't strictly needed.
+
+            // Assumptions:
+            //    Stencil width 3
+            //    3 arrays involved in stencil
+            //    Uniform data type in arrays (all T_numtype)
+            
+            int cacheNeeded = 3 * 3 * sizeof(T_numtype) * length(ordering(0));
+            if (cacheNeeded > BZ_L1_CACHE_ESTIMATED_SIZE)
+                return evaluateWithTiled2DTraversal(expr, T_update());
+        }
+
+#endif
+
+        // If fast traversal isn't available or appropriate, then just
+        // do a stack traversal.
+        if (N_rank == 1)
+            return evaluateWithStackTraversal1(expr, T_update());
+        else
+            return evaluateWithStackTraversalN(expr, T_update());
+    }
+}
+
+template<class T_numtype, int N_rank> template<class T_expr, class T_update>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::evaluateWithStackTraversal1(_bz_ArrayExpr<T_expr> 
+    expr, T_update)
+{
+#ifdef BZ_DEBUG_TRAVERSE
+    BZ_DEBUG_MESSAGE("Array<" << BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(T_numtype)
+         << ", " << N_rank << ">: Using stack traversal");
+#endif
+    ArrayIterator<T_numtype, N_rank> iter(*this);
+    iter.loadStride(firstRank);
+    expr.loadStride(firstRank);
+
+    _bz_bool useUnitStride = iter.isUnitStride(firstRank)
+          && expr.isUnitStride(firstRank);
+
+#ifdef BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+    int commonStride = expr.suggestStride(firstRank);
+    if (iter.suggestStride(firstRank) > commonStride)
+        commonStride = iter.suggestStride(firstRank);
+    bool useCommonStride = iter.isStride(firstRank,commonStride)
+        && expr.isStride(firstRank,commonStride);
+
+ #ifdef BZ_DEBUG_TRAVERSE
+    BZ_DEBUG_MESSAGE("BZ_ARRAY_EXPR_USE_COMMON_STRIDE:" << endl
+        << "    commonStride = " << commonStride << " useCommonStride = "
+        << useCommonStride);
+ #endif
+#else
+    int commonStride = 1;
+    bool useCommonStride = _bz_false;
+#endif
+
+    const T_numtype * last = iter.data() + length(firstRank) 
+        * stride(firstRank);
+
+    if (useUnitStride || useCommonStride)
+    {
+#ifdef BZ_USE_FAST_READ_ARRAY_EXPR
+
+#ifdef BZ_DEBUG_TRAVERSE
+    BZ_DEBUG_MESSAGE("BZ_USE_FAST_READ_ARRAY_EXPR with commonStride");
+#endif
+        int ubound = length(firstRank) * commonStride;
+        T_numtype* _bz_restrict data = const_cast<T_numtype*>(iter.data());
+
+        if (commonStride == 1)
+        {
+ #ifndef BZ_ARRAY_STACK_TRAVERSAL_UNROLL
+            for (int i=0; i < ubound; ++i)
+                T_update::update(data[i], expr.fastRead(i));
+ #else
+            int n1 = ubound & 3;
+            int i = 0;
+            for (; i < n1; ++i)
+                T_update::update(data[i], expr.fastRead(i));
+           
+            for (; i < ubound; i += 4)
+            {
+#ifndef BZ_ARRAY_STACK_TRAVERSAL_CSE_AND_ANTIALIAS
+                T_update::update(data[i], expr.fastRead(i));
+                T_update::update(data[i+1], expr.fastRead(i+1));
+                T_update::update(data[i+2], expr.fastRead(i+2));
+                T_update::update(data[i+3], expr.fastRead(i+3));
+#else
+                int t1 = i+1;
+                int t2 = i+2;
+                int t3 = i+3;
+
+                _bz_typename T_expr::T_numtype tmp1, tmp2, tmp3, tmp4;
+
+                tmp1 = expr.fastRead(i);
+                tmp2 = expr.fastRead(BZ_NO_PROPAGATE(t1));
+                tmp3 = expr.fastRead(BZ_NO_PROPAGATE(t2));
+                tmp4 = expr.fastRead(BZ_NO_PROPAGATE(t3));
+
+                T_update::update(data[i], BZ_NO_PROPAGATE(tmp1));
+                T_update::update(data[BZ_NO_PROPAGATE(t1)], tmp2);
+                T_update::update(data[BZ_NO_PROPAGATE(t2)], tmp3);
+                T_update::update(data[BZ_NO_PROPAGATE(t3)], tmp4);
+#endif
+            }
+ #endif // BZ_ARRAY_STACK_TRAVERSAL_UNROLL
+
+        }
+ #ifdef BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+        else {
+
+  #ifndef BZ_ARRAY_STACK_TRAVERSAL_UNROLL
+            for (int i=0; i < ubound; i += commonStride)
+                T_update::update(data[i], expr.fastRead(i));
+  #else
+            int n1 = (length(firstRank) & 3) * commonStride;
+
+            int i = 0;
+            for (; i < n1; i += commonStride)
+                T_update::update(data[i], expr.fastRead(i));
+
+            int strideInc = 4 * commonStride;
+            for (; i < ubound; i += strideInc)
+            {
+                T_update::update(data[i], expr.fastRead(i));
+                int i2 = i + commonStride;
+                T_update::update(data[i2], expr.fastRead(i2));
+                int i3 = i + 2 * commonStride;
+                T_update::update(data[i3], expr.fastRead(i3));
+                int i4 = i + 3 * commonStride;
+                T_update::update(data[i4], expr.fastRead(i4));
+            }
+  #endif  // BZ_ARRAY_STACK_TRAVERSAL_UNROLL
+        }
+ #endif  // BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+
+#else   // ! BZ_USE_FAST_READ_ARRAY_EXPR
+
+#ifdef BZ_DEBUG_TRAVERSE
+    BZ_DEBUG_MESSAGE("Common stride, no fast read");
+#endif
+        while (iter.data() != last)
+        {
+            T_update::update(*const_cast<T_numtype*>(iter.data()), *expr);
+            iter.advance(commonStride);
+            expr.advance(commonStride);
+        }
+#endif
+    }
+    else {
+        while (iter.data() != last)
+        {
+            T_update::update(*const_cast<T_numtype*>(iter.data()), *expr);
+            iter.advance();
+            expr.advance();
+        }
+    }
+
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr, class T_update>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::evaluateWithStackTraversalN(_bz_ArrayExpr<T_expr>
+    expr, T_update)
+{
+    /*
+     * A stack traversal replaces the usual nested loops:
+     *
+     * for (int i=A.lbound(firstDim); i <= A.ubound(firstDim); ++i)
+     *   for (int j=A.lbound(secondDim); j <= A.ubound(secondDim); ++j)
+     *     for (int k=A.lbound(thirdDim); k <= A.ubound(thirdDim); ++k)
+     *       A(i,j,k) = 0;
+     *
+     * with a stack data structure.  The stack allows this single
+     * routine to replace any number of nested loops.
+     *
+     * For each dimension (loop), these quantities are needed:
+     * - a pointer to the first element encountered in the loop
+     * - the stride associated with the dimension/loop
+     * - a pointer to the last element encountered in the loop
+     *
+     * The basic idea is that entering each loop is a "push" onto the
+     * stack, and exiting each loop is a "pop".  In practice, this
+     * routine treats accesses the stack in a random-access way,
+     * which confuses the picture a bit.  But conceptually, that's
+     * what is going on.
+     */
+
+    /*
+     * ordering(0) gives the dimension associated with the smallest
+     * stride (usually; the exceptions have to do with subarrays and
+     * are uninteresting).  We call this dimension maxRank; it will
+     * become the innermost "loop".
+     *
+     * Ordering the loops from ordering(N_rank-1) down to
+     * ordering(0) ensures that the largest stride is associated
+     * with the outermost loop, and the smallest stride with the
+     * innermost.  This is critical for good performance on
+     * cached machines.
+     */
+    const int maxRank = ordering(0);
+    const int secondLastRank = ordering(1);
+
+    // Create an iterator for the array receiving the result
+    ArrayIterator<T_numtype, N_rank> iter(*this);
+
+    // Set the initial stack configuration by pushing the pointer
+    // to the first element of the array onto the stack N times.
+
+    int i;
+    for (i=1; i < N_rank; ++i)
+    {
+        iter.push(i);
+        expr.push(i);
+    }
+
+    // Load the strides associated with the innermost loop.
+    iter.loadStride(maxRank);
+    expr.loadStride(maxRank);
+
+    /* 
+     * Is the stride in the innermost loop equal to 1?  If so,
+     * we might take advantage of this and generate more
+     * efficient code.
+     */
+    _bz_bool useUnitStride = iter.isUnitStride(maxRank)
+                          && expr.isUnitStride(maxRank);
+
+    /*
+     * Do all array operands share a common stride in the innermost
+     * loop?  If so, we can generate more efficient code (but only
+     * if this optimization has been enabled).
+     */
+#ifdef BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+    int commonStride = expr.suggestStride(maxRank);
+    if (iter.suggestStride(maxRank) > commonStride)
+        commonStride = iter.suggestStride(maxRank);
+    bool useCommonStride = iter.isStride(maxRank,commonStride)
+        && expr.isStride(maxRank,commonStride);
+
+#ifdef BZ_DEBUG_TRAVERSE
+    BZ_DEBUG_MESSAGE("BZ_ARRAY_EXPR_USE_COMMON_STRIDE" << endl
+        << "commonStride = " << commonStride << " useCommonStride = "
+        << useCommonStride);
+#endif
+
+#else
+    int commonStride = 1;
+    bool useCommonStride = _bz_false;
+#endif
+
+    /*
+     * The "last" array contains a pointer to the last element
+     * encountered in each "loop".
+     */
+    const T_numtype* _bz_restrict last[N_rank];
+
+    // Set up the initial state of the "last" array
+    for (i=1; i < N_rank; ++i)
+        last[i] = iter.data() + length(ordering(i)) * stride(ordering(i));
+
+    int lastLength = length(maxRank);
+    int firstNoncollapsedLoop = 1;
+
+#ifdef BZ_COLLAPSE_LOOPS
+
+    /*
+     * This bit of code handles collapsing loops.  When possible,
+     * the N nested loops are converted into a single loop (basically,
+     * the N-dimensional array is treated as a long vector).
+     * This is important for cases where the length of the innermost
+     * loop is very small, for example a 100x100x3 array.
+     * If this code can't collapse all the loops into a single loop,
+     * it will collapse as many loops as possible starting from the
+     * innermost and working out.
+     */
+
+    // Collapse loops when possible
+    for (i=1; i < N_rank; ++i)
+    {
+        // Figure out which pair of loops we are considering combining.
+        int outerLoopRank = ordering(i);
+        int innerLoopRank = ordering(i-1);
+
+        /*
+         * The canCollapse() routines look at the strides and extents
+         * of the loops, and determine if they can be combined into
+         * one loop.
+         */
+
+        if (canCollapse(outerLoopRank,innerLoopRank) 
+          && expr.canCollapse(outerLoopRank,innerLoopRank))
+        {
+            lastLength *= length(outerLoopRank);
+            firstNoncollapsedLoop = i+1;
+        }
+    }
+#endif // BZ_COLLAPSE_LOOPS
+
+    /*
+     * Now we actually perform the loops.  This while loop contains
+     * two parts: first, the innermost loop is performed.  Then we
+     * exit the loop, and pop our way down the stack until we find
+     * a loop that isn't completed.  We then restart the inner loops
+     * and push them onto the stack.
+     */
+
+    while (true) {
+
+        /*
+         * This bit of code handles the innermost loop.  It would look
+         * a lot simpler if it weren't for unit stride and common stride
+         * optimizations; these clutter up the code with multiple versions.
+         */
+
+        if ((useUnitStride) || (useCommonStride))
+        {
+            T_numtype * _bz_restrict end = const_cast<T_numtype*>(iter.data()) 
+                + lastLength;
+
+#ifdef BZ_USE_FAST_READ_ARRAY_EXPR
+
+            /*
+             * The check for BZ_USE_FAST_READ_ARRAY_EXPR can probably
+             * be taken out.  This was put in place while the unit stride/
+             * common stride optimizations were being implemented and
+             * tested.
+             */
+
+            // Calculate the end of the innermost loop
+            int ubound = lastLength * commonStride;
+
+            /*
+             * This is a real kludge.  I didn't want to have to write
+             * a const and non-const version of ArrayIterator, so I use a
+             * const iterator and cast away const.  This could
+             * probably be avoided with some trick, but the whole routine
+             * is ugly, so why bother.
+             */
+
+            T_numtype* _bz_restrict data = const_cast<T_numtype*>(iter.data());
+
+            /*
+             * BZ_NEEDS_WORK-- need to implement optional unrolling.
+             */
+            if (commonStride == 1)
+            {
+                for (int i=0; i < ubound; ++i)
+                    T_update::update(data[i], expr.fastRead(i));
+            }
+#ifdef BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+            else {
+                for (int i=0; i < ubound; i += commonStride)
+                    T_update::update(data[i], expr.fastRead(i));
+            }
+#endif
+            /*
+             * Tidy up for the fact that we haven't actually been
+             * incrementing the iterators in the innermost loop, by
+             * faking it afterward.
+             */
+            iter.advance(lastLength * commonStride);
+            expr.advance(lastLength * commonStride);
+#else        
+            // !BZ_USE_FAST_READ_ARRAY_EXPR
+            // This bit of code not really needed; should remove at some
+            // point, along with the test for BZ_USE_FAST_READ_ARRAY_EXPR 
+
+            while (iter.data() != end) 
+            {
+                T_update::update(*const_cast<T_numtype*>(iter.data()), *expr);
+                iter.advance(commonStride);
+                expr.advance(commonStride);
+            }
+#endif
+        }
+        else {
+            /*
+             * We don't have a unit stride or common stride in the innermost
+             * loop.  This is going to hurt performance.  Luckily 95% of
+             * the time, we hit the cases above.
+             */
+            T_numtype * _bz_restrict end = const_cast<T_numtype*>(iter.data())
+                + lastLength * stride(maxRank);
+
+            while (iter.data() != end)
+            {
+                T_update::update(*const_cast<T_numtype*>(iter.data()), *expr);
+                iter.advance();
+                expr.advance();
+            }
+        }
+
+
+        /*
+         * We just finished the innermost loop.  Now we pop our way down
+         * the stack, until we hit a loop that hasn't completed yet.
+         */ 
+        int j = firstNoncollapsedLoop;
+        for (; j < N_rank; ++j)
+        {
+            // Get the next loop
+            int r = ordering(j);
+
+            // Pop-- this restores the data pointers to the first element
+            // encountered in the loop.
+            iter.pop(j);
+            expr.pop(j);
+
+            // Load the stride associated with this loop, and increment
+            // once.
+            iter.loadStride(r);
+            expr.loadStride(r);
+            iter.advance();
+            expr.advance();
+
+            // If we aren't at the end of this loop, then stop popping.
+            if (iter.data() != last[j])
+                break;
+        }
+
+        // Are we completely done?
+        if (j == N_rank)
+            break;
+
+        // No, so push all the inner loops back onto the stack.
+        for (; j >= firstNoncollapsedLoop; --j)
+        {
+            int r2 = ordering(j-1);
+            iter.push(j);
+            expr.push(j);
+            last[j-1] = iter.data() + length(r2) * stride(r2);
+        }
+
+        // Load the stride for the innermost loop again.
+        iter.loadStride(maxRank);
+        expr.loadStride(maxRank);
+    }
+
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr, class T_update>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::evaluateWithIndexTraversal1(_bz_ArrayExpr<T_expr> 
+    expr, T_update)
+{
+    TinyVector<int,N_rank> index;
+
+    if (stride(firstRank) == 1)
+    {
+        T_numtype * _bz_restrict iter = data_;
+        int last = ubound(firstRank);
+
+        for (index[0] = lbound(firstRank); index[0] <= last;
+            ++index[0])
+        {
+            iter[index[0]] = expr(index);
+        }
+    }
+    else {
+        ArrayIterator<T_numtype, N_rank> iter(*this);
+        iter.loadStride(0);
+        int last = ubound(firstRank);
+
+        for (index[0] = lbound(firstRank); index[0] <= last;
+            ++index[0])
+        {
+            T_update::update(*const_cast<T_numtype*>(iter.data()), 
+                expr(index));
+            iter.advance();
+        }
+    }
+
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr, class T_update>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::evaluateWithIndexTraversalN(_bz_ArrayExpr<T_expr> 
+    expr, T_update)
+{
+    // Do a stack-type traversal for the destination array and use
+    // index traversal for the source expression
+   
+    const int maxRank = ordering(0);
+    const int secondLastRank = ordering(1);
+
+#ifdef BZ_DEBUG_TRAVERSE
+cout << "Index traversal: N_rank = " << N_rank << endl;
+cout << "maxRank = " << maxRank << " secondLastRank = " << secondLastRank
+     << endl;
+cout.flush();
+#endif
+
+    ArrayIterator<T_numtype, N_rank> iter(*this);
+    for (int i=1; i < N_rank; ++i)
+        iter.push(ordering(i));
+
+    iter.loadStride(maxRank);
+
+    TinyVector<int,N_rank> index, last;
+
+    index = storage_.base();
+    last = storage_.base() + length_;
+
+    int lastLength = length(maxRank);
+
+    while (true) {
+
+        for (index[maxRank] = base(maxRank); 
+             index[maxRank] < last[maxRank]; 
+             ++index[maxRank])
+        {
+#ifdef BZ_DEBUG_TRAVERSE
+#if 0
+    cout << "(" << index[0] << "," << index[1] << ") " << endl;
+    cout.flush();
+#endif
+#endif
+
+            T_update::update(*const_cast<T_numtype*>(iter.data()), expr(index));
+            iter.advance();
+        }
+
+        int j = 1;
+        for (; j < N_rank; ++j)
+        {
+            iter.pop(ordering(j));
+            iter.loadStride(ordering(j));
+            iter.advance();
+
+            index[ordering(j-1)] = base(ordering(j-1));
+            ++index[ordering(j)];
+            if (index[ordering(j)] != last[ordering(j)])
+                break;
+        }
+
+        if (j == N_rank)
+            break;
+
+        for (; j > 0; --j)
+        {
+            iter.push(ordering(j));
+        }
+        iter.loadStride(maxRank);
+    }
+
+    return *this; 
+}
+
+// Fast traversals require <set> from the ISO/ANSI C++ standard library
+
+#ifdef BZ_HAVE_STD
+
+template<class T_numtype, int N_rank> template<class T_expr, class T_update>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::evaluateWithFastTraversal(
+    const TraversalOrder<N_rank - 1>& order, _bz_ArrayExpr<T_expr> expr,
+    T_update)
+{
+    const int maxRank = ordering(0);
+    const int secondLastRank = ordering(1);
+
+#ifdef BZ_DEBUG_TRAVERSE
+cerr << "maxRank = " << maxRank << " secondLastRank = " << secondLastRank
+     << endl;
+#endif
+
+    ArrayIterator<T_numtype, N_rank> iter(*this);
+    iter.push(0);
+    expr.push(0);
+
+    _bz_bool useUnitStride = iter.isUnitStride(maxRank) 
+                          && expr.isUnitStride(maxRank);
+
+#ifdef BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+    int commonStride = expr.suggestStride(maxRank);
+    if (iter.suggestStride(maxRank) > commonStride)
+        commonStride = iter.suggestStride(maxRank);
+    bool useCommonStride = iter.isStride(maxRank,commonStride)
+        && expr.isStride(maxRank,commonStride);
+#else
+    int commonStride = 1;
+    bool useCommonStride = _bz_false;
+#endif
+
+    int lastLength = length(maxRank);
+
+    for (int i=0; i < order.length(); ++i)
+    {
+        iter.pop(0);
+        expr.pop(0);
+
+#ifdef BZ_DEBUG_TRAVERSE
+    cerr << "Traversing: " << order[i] << endl;
+#endif
+        // Position the iterator at the start of the next column       
+        for (int j=1; j < N_rank; ++j)
+        {
+            iter.loadStride(ordering(j));
+            expr.loadStride(ordering(j));
+
+            int offset = order[i][j-1];
+            iter.advance(offset);
+            expr.advance(offset);
+        }
+
+        iter.loadStride(maxRank);
+        expr.loadStride(maxRank);
+
+        // Evaluate the expression along the column
+
+        if ((useUnitStride) || (useCommonStride))
+        {
+            T_numtype* _bz_restrict last = const_cast<T_numtype*>(iter.data()) 
+                + lastLength * commonStride;
+
+#ifdef BZ_USE_FAST_READ_ARRAY_EXPR
+            int ubound = lastLength * commonStride;
+            T_numtype* _bz_restrict data = const_cast<T_numtype*>(iter.data());
+
+            if (commonStride == 1)
+            {            
+ #ifndef BZ_ARRAY_FAST_TRAVERSAL_UNROLL
+                for (int i=0; i < ubound; ++i)
+                    T_update::update(data[i], expr.fastRead(i));
+ #else
+                int n1 = ubound & 3;
+                int i=0;
+                for (; i < n1; ++i)
+                    T_update::update(data[i], expr.fastRead(i));
+
+                for (; i < ubound; i += 4)
+                {
+                    T_update::update(data[i], expr.fastRead(i));
+                    T_update::update(data[i+1], expr.fastRead(i+1));
+                    T_update::update(data[i+2], expr.fastRead(i+2));
+                    T_update::update(data[i+3], expr.fastRead(i+3));
+                }
+ #endif  // BZ_ARRAY_FAST_TRAVERSAL_UNROLL
+            }
+ #ifdef BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+            else {
+                for (int i=0; i < ubound; i += commonStride)
+                    T_update::update(data[i], expr.fastRead(i));
+            }
+ #endif // BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+
+            iter.advance(lastLength * commonStride);
+            expr.advance(lastLength * commonStride);
+#else   // ! BZ_USE_FAST_READ_ARRAY_EXPR
+            while (iter.data() != last)
+            {
+                T_update::update(*const_cast<T_numtype*>(iter.data()), *expr);
+                iter.advance(commonStride);
+                expr.advance(commonStride);
+            }
+#endif  // BZ_USE_FAST_READ_ARRAY_EXPR
+
+        }
+        else {
+            // No common stride
+
+            T_numtype* _bz_restrict last = const_cast<T_numtype*>(iter.data()) 
+                + lastLength * stride(maxRank);
+
+            while (iter.data() != last)
+            {
+                T_update::update(*const_cast<T_numtype*>(iter.data()), *expr);
+                iter.advance();
+                expr.advance();
+            }
+        }
+    }
+
+    return *this;
+}
+#endif // BZ_HAVE_STD
+
+#ifdef BZ_ARRAY_2D_NEW_STENCIL_TILING
+
+#ifdef BZ_ARRAY_2D_STENCIL_TILING
+
+template<class T_numtype, int N_rank> template<class T_expr, class T_update>
+inline Array<T_numtype, N_rank>& 
+Array<T_numtype, N_rank>::evaluateWithTiled2DTraversal(_bz_ArrayExpr<T_expr> 
+    expr, T_update)
+{
+    const int minorRank = ordering(0);
+    const int majorRank = ordering(1);
+
+    ArrayIterator<T_numtype, N_rank> iter(*this);
+    iter.push(0);
+    expr.push(0);
+
+#ifdef BZ_2D_STENCIL_DEBUG
+    int count = 0;
+#endif
+
+    _bz_bool useUnitStride = iter.isUnitStride(minorRank)
+                          && expr.isUnitStride(minorRank);
+
+#ifdef BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+    int commonStride = expr.suggestStride(minorRank);
+    if (iter.suggestStride(minorRank) > commonStride)
+        commonStride = iter.suggestStride(minorRank);
+    bool useCommonStride = iter.isStride(minorRank,commonStride)
+        && expr.isStride(minorRank,commonStride);
+#else
+    int commonStride = 1;
+    bool useCommonStride = _bz_false;
+#endif
+
+    // Determine if a common major stride exists
+    int commonMajorStride = expr.suggestStride(majorRank);
+    if (iter.suggestStride(majorRank) > commonMajorStride)
+        commonMajorStride = iter.suggestStride(majorRank);
+    bool haveCommonMajorStride = iter.isStride(majorRank,commonMajorStride)
+        && expr.isStride(majorRank,commonMajorStride);
+
+
+    int maxi = length(majorRank);
+    int maxj = length(minorRank);
+
+    const int tileHeight = 16, tileWidth = 3;
+
+    int bi, bj;
+    for (bi=0; bi < maxi; bi += tileHeight)
+    {
+        int ni = bi + tileHeight;
+        if (ni > maxi)
+            ni = maxi;
+
+        // Move back to the beginning of the array
+        iter.pop(0);
+        expr.pop(0);
+
+        // Move to the start of this tile row
+        iter.loadStride(majorRank);
+        iter.advance(bi);
+        expr.loadStride(majorRank);
+        expr.advance(bi);
+
+        // Save this position
+        iter.push(1);
+        expr.push(1);
+
+        for (bj=0; bj < maxj; bj += tileWidth)
+        {
+            // Move to the beginning of the tile row
+            iter.pop(1);
+            expr.pop(1);
+
+            // Move to the top of the current tile (bi,bj)
+            iter.loadStride(minorRank);
+            iter.advance(bj);
+            expr.loadStride(minorRank);
+            expr.advance(bj);
+
+            if (bj + tileWidth <= maxj)
+            {
+                // Strip mining
+
+                if ((useUnitStride) && (haveCommonMajorStride))
+                {
+                    int offset = 0;
+                    T_numtype* _bz_restrict data = const_cast<T_numtype*>
+                        (iter.data());
+
+                    for (int i=bi; i < ni; ++i)
+                    {
+                        _bz_typename T_expr::T_numtype tmp1, tmp2, tmp3;
+
+                        // Common subexpression elimination -- compilers
+                        // won't necessarily do this on their own.
+                        int t1 = offset+1;
+                        int t2 = offset+2;
+
+                        tmp1 = expr.fastRead(offset);
+                        tmp2 = expr.fastRead(t1);
+                        tmp3 = expr.fastRead(t2);
+
+                        T_update::update(data[0], tmp1);
+                        T_update::update(data[1], tmp2);
+                        T_update::update(data[2], tmp3);
+
+                        offset += commonMajorStride;
+                        data += commonMajorStride;
+
+#ifdef BZ_2D_STENCIL_DEBUG
+    count += 3;
+#endif
+                    }
+                }
+                else {
+
+                    for (int i=bi; i < ni; ++i)
+                    {
+                        iter.loadStride(minorRank);
+                        expr.loadStride(minorRank);
+
+                        // Loop through current row elements
+                        T_update::update(*const_cast<T_numtype*>(iter.data()),
+                            *expr);
+                        iter.advance();
+                        expr.advance();
+
+                        T_update::update(*const_cast<T_numtype*>(iter.data()),
+                            *expr);
+                        iter.advance();
+                        expr.advance();
+
+                        T_update::update(*const_cast<T_numtype*>(iter.data()),
+                            *expr);
+                        iter.advance(-2);
+                        expr.advance(-2);
+
+                        iter.loadStride(majorRank);
+                        expr.loadStride(majorRank);
+                        iter.advance();
+                        expr.advance();
+
+#ifdef BZ_2D_STENCIL_DEBUG
+    count += 3;
+#endif
+
+                    }
+                }
+            }
+            else {
+
+                // This code handles partial tiles at the bottom of the
+                // array.
+
+                for (int j=bj; j < maxj; ++j)
+                {
+                    iter.loadStride(majorRank);
+                    expr.loadStride(majorRank);
+
+                    for (int i=bi; i < ni; ++i)
+                    {
+                        T_update::update(*const_cast<T_numtype*>(iter.data()),
+                            *expr);
+                        iter.advance();
+                        expr.advance();
+#ifdef BZ_2D_STENCIL_DEBUG
+    ++count;
+#endif
+
+                    }
+
+                    // Move back to the top of this column
+                    iter.advance(bi-ni);
+                    expr.advance(bi-ni);
+
+                    // Move over to the next column
+                    iter.loadStride(minorRank);
+                    expr.loadStride(minorRank);
+
+                    iter.advance();
+                    expr.advance();
+                }
+            }
+        }
+    }
+
+#ifdef BZ_2D_STENCIL_DEBUG
+    cout << "BZ_2D_STENCIL_DEBUG: count = " << count << endl;
+#endif
+
+    return *this;
+}
+
+#endif // BZ_ARRAY_2D_STENCIL_TILING
+#endif // BZ_ARRAY_2D_NEW_STENCIL_TILING
+
+
+
+#ifndef BZ_ARRAY_2D_NEW_STENCIL_TILING
+
+#ifdef BZ_ARRAY_2D_STENCIL_TILING
+
+template<class T_numtype, int N_rank> template<class T_expr, class T_update>
+inline Array<T_numtype, N_rank>& 
+Array<T_numtype, N_rank>::evaluateWithTiled2DTraversal(_bz_ArrayExpr<T_expr> 
+    expr, T_update)
+{
+    const int minorRank = ordering(0);
+    const int majorRank = ordering(1);
+
+    const int blockSize = 16;
+    
+    ArrayIterator<T_numtype, N_rank> iter(*this);
+    iter.push(0);
+    expr.push(0);
+
+    _bz_bool useUnitStride = iter.isUnitStride(minorRank)
+                          && expr.isUnitStride(minorRank);
+
+#ifdef BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+    int commonStride = expr.suggestStride(minorRank);
+    if (iter.suggestStride(minorRank) > commonStride)
+        commonStride = iter.suggestStride(minorRank);
+    bool useCommonStride = iter.isStride(minorRank,commonStride)
+        && expr.isStride(minorRank,commonStride);
+#else
+    int commonStride = 1;
+    bool useCommonStride = _bz_false;
+#endif
+
+    int maxi = length(majorRank);
+    int maxj = length(minorRank);
+
+    int bi, bj;
+    for (bi=0; bi < maxi; bi += blockSize)
+    {
+        int ni = bi + blockSize;
+        if (ni > maxi)
+            ni = maxi;
+
+        for (bj=0; bj < maxj; bj += blockSize)
+        {
+            int nj = bj + blockSize;
+            if (nj > maxj)
+                nj = maxj;
+
+            // Move to the beginning of the array
+            iter.pop(0);
+            expr.pop(0);
+
+            // Move to the beginning of the tile (bi,bj)
+            iter.loadStride(majorRank);
+            iter.advance(bi);
+            iter.loadStride(minorRank);
+            iter.advance(bj);
+
+            expr.loadStride(majorRank);
+            expr.advance(bi);
+            expr.loadStride(minorRank);
+            expr.advance(bj);
+
+            // Loop through tile rows
+            for (int i=bi; i < ni; ++i)
+            {
+                // Save the beginning of this tile row
+                iter.push(1);
+                expr.push(1);
+
+                // Load the minor stride
+                iter.loadStride(minorRank);
+                expr.loadStride(minorRank);
+
+                if (useUnitStride)
+                {
+                    T_numtype* _bz_restrict data = const_cast<T_numtype*>
+                        (iter.data());
+
+                    int ubound = (nj-bj);
+                    for (int j=0; j < ubound; ++j)
+                        T_update::update(data[j], expr.fastRead(j));
+                }
+#ifdef BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+                else if (useCommonStride)
+                {
+                    int ubound = (nj-bj) * commonStride;
+                    T_numtype* _bz_restrict data = const_cast<T_numtype*>
+                        (iter.data());
+
+                    for (int j=0; j < ubound; j += commonStride)
+                        T_update::update(data[j], expr.fastRead(j));
+                }
+#endif
+                else {
+                    for (int j=bj; j < nj; ++j)
+                    {
+                        // Loop through current row elements
+                        T_update::update(*const_cast<T_numtype*>(iter.data()), 
+                            *expr);
+                        iter.advance();
+                        expr.advance();
+                    }
+                }
+
+                // Move back to the beginning of the tile row, then
+                // move to the next row
+                iter.pop(1);
+                iter.loadStride(majorRank);
+                iter.advance(1);
+
+                expr.pop(1);
+                expr.loadStride(majorRank);
+                expr.advance(1);
+            }
+        }
+    }
+
+    return *this;
+}
+#endif // BZ_ARRAY_2D_STENCIL_TILING
+#endif // BZ_ARRAY_2D_NEW_STENCIL_TILING
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYEVAL_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/expr.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/expr.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/expr.h	(revision 1307)
@@ -0,0 +1,646 @@
+/***************************************************************************
+ * blitz/arrayexpr.h     Array<T,N> expression templates
+ *
+ * $Id: expr.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_ARRAYEXPR_H
+#define BZ_ARRAYEXPR_H
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/expr.h> must be included via <blitz/array.h>
+#endif
+
+#ifndef BZ_OPS_H
+ #include <blitz/ops.h>
+#endif
+
+#ifndef BZ_PRETTYPRINT_H
+ #include <blitz/prettyprint.h>
+#endif
+
+#ifndef BZ_SHAPECHECK_H
+ #include <blitz/shapecheck.h>
+#endif
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+#ifndef BZ_NUMINQUIRE_H
+ #include <blitz/numinquire.h>
+#endif
+#endif
+
+/*
+ * The array expression templates iterator interface is followed by
+ * these classes:
+ *
+ * ArrayIterator              <blitz/arrayiter.h>
+ * _bz_ArrayExpr              <blitz/arrayexpr.h>
+ * _bz_ArrayExprOp                    "
+ * _bz_ArrayExprUnaryOp               "
+ * _bz_ArrayExprConstant              "
+ * _bz_ArrayMap               <blitz/arraymap.h>
+ * _bz_ArrayExprReduce        <blitz/arrayreduce.h>
+ * IndexPlaceholder           <blitz/indexexpr.h>
+ */
+
+BZ_NAMESPACE(blitz)
+
+template<class T1, class T2>
+class _bz_ExprPair {
+public:
+    _bz_ExprPair(const T1& a, const T2& b)
+        : first_(a), second_(b)
+    { }
+
+    const T1& first() const
+    { return first_; }
+
+    const T2& second() const
+    { return second_; }
+
+protected:
+    T1 first_;
+    T2 second_;
+};
+
+template<class T1, class T2>
+inline _bz_ExprPair<T1,T2> makeExprPair(const T1& a, const T2& b)
+{
+    return _bz_ExprPair<T1,T2>(a,b);
+}
+
+template<class P_expr>
+class _bz_ArrayExpr 
+#ifdef BZ_NEW_EXPRESSION_TEMPLATES
+    : public ETBase<_bz_ArrayExpr<P_expr> >
+#endif
+{
+
+public:
+    typedef P_expr T_expr;
+    typedef _bz_typename T_expr::T_numtype T_numtype;
+    typedef T_expr T_ctorArg1;
+    typedef int    T_ctorArg2;    // dummy
+
+    enum { numArrayOperands = BZ_ENUM_CAST(P_expr::numArrayOperands),
+        numIndexPlaceholders = BZ_ENUM_CAST(P_expr::numIndexPlaceholders),
+        rank = BZ_ENUM_CAST(P_expr::rank) };
+
+    _bz_ArrayExpr(const _bz_ArrayExpr<P_expr>& a)
+        : iter_(a.iter_)
+    { }
+
+    _bz_ArrayExpr(T_expr a)
+        : iter_(a)
+    { }
+
+    _bz_ArrayExpr(_bz_typename T_expr::T_ctorArg1 a)
+        : iter_(a)
+    { }
+
+    // This template is not possible because it masks the copy constructor,
+    // wreaking havoc.
+
+#if BZ_TEMPLATE_CTOR_DOESNT_CAUSE_HAVOC
+    template<class T1>
+    _bz_explicit _bz_ArrayExpr(T1 a)
+       : iter_(a)
+    { }
+#endif
+
+    template<class T1, class T2>
+    _bz_ArrayExpr(T1 a, T2 b)
+        : iter_(a, b)
+    { }
+
+    template<class T1, class T2, class T3>
+    _bz_ArrayExpr(T1 a, T2 b, T3 c)
+        : iter_(a, b, c)
+    { }
+
+    template<class T1, class T2>
+    _bz_ArrayExpr(_bz_ExprPair<T1,T2> pair)
+        : iter_(pair.first(), pair.second())
+    { }
+
+    T_numtype operator*()
+    { return *iter_; }
+
+#ifdef BZ_ARRAY_EXPR_PASS_INDEX_BY_VALUE
+    template<int N_rank>
+    T_numtype operator()(TinyVector<int, N_rank> i)
+    { return iter_(i); }
+#else
+    template<int N_rank>
+    T_numtype operator()(const TinyVector<int, N_rank>& i)
+    { return iter_(i); }
+#endif
+
+    int lbound(int rank)
+    { return iter_.lbound(rank); }
+
+    int ubound(int rank)
+    { return iter_.ubound(rank); }
+
+    void push(int position)
+    { iter_.push(position); }
+
+    void pop(int position)
+    { iter_.pop(position); }
+
+    void advance()
+    { iter_.advance(); }
+
+    void advance(int n)
+    { iter_.advance(n); }
+
+    void loadStride(int rank)
+    { iter_.loadStride(rank); }
+
+    _bz_bool isUnitStride(int rank) const
+    { return iter_.isUnitStride(rank); }
+
+    void advanceUnitStride()
+    { iter_.advanceUnitStride(); }
+
+    _bz_bool canCollapse(int outerLoopRank, int innerLoopRank) const
+    { 
+        // BZ_DEBUG_MESSAGE("_bz_ArrayExpr<>::canCollapse()");
+        return iter_.canCollapse(outerLoopRank, innerLoopRank); 
+    }
+
+    T_numtype operator[](int i)
+    { return iter_[i]; }
+
+    T_numtype fastRead(int i)
+    { return iter_.fastRead(i); }
+
+    int suggestStride(int rank) const
+    { return iter_.suggestStride(rank); }
+
+    _bz_bool isStride(int rank, int stride) const
+    { return iter_.isStride(rank,stride); }
+
+    void prettyPrint(string& str) const
+    {
+        prettyPrintFormat format(_bz_true);  // Terse formatting by default
+        iter_.prettyPrint(str, format);
+    }
+
+    void prettyPrint(string& str, prettyPrintFormat& format) const
+    { iter_.prettyPrint(str, format); }
+
+    template<class T_shape>
+    _bz_bool shapeCheck(const T_shape& shape)
+    { return iter_.shapeCheck(shape); }
+
+    template<int N_rank>
+    void moveTo(const TinyVector<int,N_rank>& i)
+    {
+        iter_.moveTo(i);
+    }
+
+protected:
+    _bz_ArrayExpr() { }
+
+    T_expr iter_;
+};
+
+struct bounds {
+    static int compute_lbound(int rank, int lbound1, int lbound2)
+    {
+        // The value INT_MIN indicates that there are no arrays
+        // in a subtree of the expression.  This logic returns
+        // whichever lbound is available.  If there are two
+        // conflicting lbound values, this is an error.
+
+        if (lbound1 == lbound2)
+            return lbound1;
+        else if (lbound1 == INT_MIN)
+            return lbound2;
+        else if (lbound2 == INT_MIN)
+            return lbound1;
+
+        BZ_DEBUG_MESSAGE("Two array operands have different"
+            << endl << "lower bounds: in rank " << rank << ", the bounds are "
+            << lbound1 << " and " << lbound2 << endl);
+        BZ_PRE_FAIL;
+        return 0;
+    }
+
+    static int compute_ubound(int rank, int ubound1, int ubound2)
+    {
+        // The value INT_MAX indicates that there are no arrays
+        // in a subtree of the expression.  This logic returns
+        // whichever ubound is available.  If there are two
+        // conflicting ubound values, this is an error.
+
+        if (ubound1 == ubound2)
+            return ubound1;
+        else if (ubound1 == INT_MAX)
+            return ubound2;
+        else if (ubound2 == INT_MAX)
+            return ubound1;
+
+        BZ_DEBUG_MESSAGE("Two array operands have different"
+            << endl << "upper bounds: in rank " << rank << ", the bounds are "
+            << ubound1 << " and " << ubound2 << endl);
+        BZ_PRE_FAIL;
+        return 0;
+    }
+
+};
+
+template<class P_expr1, class P_expr2, class P_op>
+class _bz_ArrayExprOp {
+public:
+    typedef P_expr1 T_expr1;
+    typedef P_expr2 T_expr2;
+    typedef _bz_typename T_expr1::T_numtype T_numtype1;
+    typedef _bz_typename T_expr2::T_numtype T_numtype2;
+    typedef _bz_typename P_op::T_numtype T_numtype;
+    typedef P_op T_op;
+    typedef T_expr1 T_ctorArg1;
+    typedef T_expr2 T_ctorArg2;
+
+    enum { numArrayOperands = BZ_ENUM_CAST(P_expr1::numArrayOperands)
+                            + BZ_ENUM_CAST(P_expr2::numArrayOperands),
+           numIndexPlaceholders = BZ_ENUM_CAST(P_expr1::numIndexPlaceholders)
+                            + BZ_ENUM_CAST(P_expr2::numIndexPlaceholders),
+           rank = (BZ_ENUM_CAST(P_expr1::rank) > BZ_ENUM_CAST(P_expr2::rank)) 
+                ? BZ_ENUM_CAST(P_expr1::rank) : BZ_ENUM_CAST(P_expr2::rank)
+    };
+
+    _bz_ArrayExprOp(const _bz_ArrayExprOp<P_expr1, P_expr2, P_op>& a)
+        : iter1_(a.iter1_), iter2_(a.iter2_)
+    { }
+
+    template<class T1, class T2>
+    _bz_ArrayExprOp(T1 a, T2 b)
+        : iter1_(a), iter2_(b)
+    { }
+
+//    _bz_ArrayExprOp(T_expr1 a, T_expr2 b)
+//       : iter1_(a), iter2_(b)
+//    { }
+
+    T_numtype operator*()
+    { return T_op::apply(*iter1_, *iter2_); }
+
+#ifdef BZ_ARRAY_EXPR_PASS_INDEX_BY_VALUE
+    template<int N_rank>
+    T_numtype operator()(TinyVector<int, N_rank> i)
+    { return T_op::apply(iter1_(i), iter2_(i)); }
+#else
+    template<int N_rank>
+    T_numtype operator()(const TinyVector<int, N_rank>& i)
+    { return T_op::apply(iter1_(i), iter2_(i)); }
+#endif
+
+    int lbound(int rank)
+    { 
+        return bounds::compute_lbound(rank, iter1_.lbound(rank),
+            iter2_.lbound(rank));
+    }
+
+    int ubound(int rank)
+    {
+        return bounds::compute_ubound(rank, iter1_.ubound(rank),
+            iter2_.ubound(rank));
+    }
+
+    void push(int position)
+    { 
+        iter1_.push(position); 
+        iter2_.push(position);
+    }
+
+    void pop(int position)
+    { 
+        iter1_.pop(position); 
+        iter2_.pop(position);
+    }
+
+    void advance()
+    { 
+        iter1_.advance(); 
+        iter2_.advance();
+    }
+
+    void advance(int n)
+    {
+        iter1_.advance(n);
+        iter2_.advance(n);
+    }
+
+    void loadStride(int rank)
+    { 
+        iter1_.loadStride(rank); 
+        iter2_.loadStride(rank);
+    }
+    
+    _bz_bool isUnitStride(int rank) const
+    { return iter1_.isUnitStride(rank) && iter2_.isUnitStride(rank); }
+
+    void advanceUnitStride()
+    { 
+        iter1_.advanceUnitStride(); 
+        iter2_.advanceUnitStride();
+    }
+
+    _bz_bool canCollapse(int outerLoopRank, int innerLoopRank) const
+    { 
+        // BZ_DEBUG_MESSAGE("_bz_ArrayExprOp<>::canCollapse");
+        return iter1_.canCollapse(outerLoopRank, innerLoopRank)
+            && iter2_.canCollapse(outerLoopRank, innerLoopRank);
+    } 
+
+    T_numtype operator[](int i)
+    { return T_op::apply(iter1_[i], iter2_[i]); }
+
+    T_numtype fastRead(int i)
+    { return T_op::apply(iter1_.fastRead(i), iter2_.fastRead(i)); }
+
+    int suggestStride(int rank) const
+    {
+        int stride1 = iter1_.suggestStride(rank);
+        int stride2 = iter2_.suggestStride(rank);
+        return (stride1 > stride2) ? stride1 : stride2;
+    }
+
+    _bz_bool isStride(int rank, int stride) const
+    {
+        return iter1_.isStride(rank,stride) && iter2_.isStride(rank,stride);
+    }
+
+    template<int N_rank>
+    void moveTo(const TinyVector<int,N_rank>& i)
+    {
+        iter1_.moveTo(i);
+        iter2_.moveTo(i);
+    }
+
+    void prettyPrint(string& str, prettyPrintFormat& format) const
+    {
+        T_op::prettyPrint(str, format, iter1_, iter2_);
+    }
+
+    template<class T_shape>
+    _bz_bool shapeCheck(const T_shape& shape)
+    { return iter1_.shapeCheck(shape) && iter2_.shapeCheck(shape); }
+
+protected:
+    _bz_ArrayExprOp() { }
+
+    T_expr1 iter1_;
+    T_expr2 iter2_; 
+};
+
+template<class P_expr, class P_op>
+class _bz_ArrayExprUnaryOp {
+public:
+    typedef P_expr T_expr;
+    typedef _bz_typename P_expr::T_numtype T_numtype1;
+    typedef _bz_typename P_op::T_numtype T_numtype;
+    typedef P_op T_op;
+    typedef T_expr T_ctorArg1;
+    typedef int    T_ctorArg2;    // dummy
+
+    enum { numArrayOperands = BZ_ENUM_CAST(T_expr::numArrayOperands),
+        numIndexPlaceholders = BZ_ENUM_CAST(T_expr::numIndexPlaceholders),
+        rank = BZ_ENUM_CAST(T_expr::rank) };
+
+    _bz_ArrayExprUnaryOp(const _bz_ArrayExprUnaryOp<T_expr, P_op>& a)
+        : iter_(a.iter_)
+    { }
+
+    _bz_ArrayExprUnaryOp(T_expr a)
+        : iter_(a)
+    { }
+
+    _bz_ArrayExprUnaryOp(_bz_typename T_expr::T_ctorArg1 a)
+        : iter_(a)
+    { }
+
+#if BZ_TEMPLATE_CTOR_DOESNT_CAUSE_HAVOC
+    template<class T1>
+    _bz_explicit _bz_ArrayExprUnaryOp(T1 a)
+        : iter_(a)
+    { }
+#endif
+
+    int lbound(int rank)
+    { return iter_.lbound(rank); }
+
+    int ubound(int rank)
+    { return iter_.ubound(rank); }
+
+    T_numtype operator*()
+    { return T_op::apply(*iter_); }
+
+#ifdef BZ_ARRAY_EXPR_PASS_INDEX_BY_VALUE
+    template<int N_rank>
+    T_numtype operator()(TinyVector<int, N_rank> i)
+    { return T_op::apply(iter_(i)); }
+#else
+    template<int N_rank>
+    T_numtype operator()(const TinyVector<int, N_rank>& i)
+    { return T_op::apply(iter_(i)); }
+#endif
+
+    void push(int position)
+    {
+        iter_.push(position);
+    }
+
+    void pop(int position)
+    {
+        iter_.pop(position);
+    }
+
+    void advance()
+    {
+        iter_.advance();
+    }
+
+    void advance(int n)
+    {
+        iter_.advance(n);
+    }
+
+    void loadStride(int rank)
+    {
+        iter_.loadStride(rank);
+    }
+
+    _bz_bool isUnitStride(int rank) const
+    { return iter_.isUnitStride(rank); }
+
+    void advanceUnitStride()
+    {
+        iter_.advanceUnitStride();
+    }
+
+    template<int N_rank>
+    void moveTo(const TinyVector<int,N_rank>& i)
+    {
+        iter_.moveTo(i);
+    }
+
+    _bz_bool canCollapse(int outerLoopRank, int innerLoopRank) const
+    { 
+        // BZ_DEBUG_MESSAGE("_bz_ArrayExprUnaryOp<>::canCollapse");
+        return iter_.canCollapse(outerLoopRank, innerLoopRank); 
+    }
+
+    T_numtype operator[](int i)
+    { return T_op::apply(iter_[i]); }
+
+    T_numtype fastRead(int i)
+    { return T_op::apply(iter_.fastRead(i)); }
+
+    int suggestStride(int rank) const
+    { return iter_.suggestStride(rank); }
+
+    _bz_bool isStride(int rank, int stride) const
+    { return iter_.isStride(rank,stride); }
+
+    void prettyPrint(string& str, prettyPrintFormat& format) const
+    { T_op::prettyPrint(str, format, iter_); }
+
+    template<class T_shape>
+    _bz_bool shapeCheck(const T_shape& shape)
+    { return iter_.shapeCheck(shape); }
+
+protected:
+    _bz_ArrayExprUnaryOp() { }
+
+    T_expr iter_;
+};
+
+template<class P_numtype>
+class _bz_ArrayExprConstant {
+public:
+    typedef P_numtype T_numtype;
+    typedef T_numtype T_ctorArg1;
+    typedef int       T_ctorArg2;    // dummy
+
+    enum { numArrayOperands = 0, numIndexPlaceholders = 0, rank = 0 };
+
+    _bz_ArrayExprConstant(const _bz_ArrayExprConstant<T_numtype>& a)
+        : value_(a.value_)
+    { }
+
+    _bz_ArrayExprConstant(T_numtype value)
+        : value_(BZ_NO_PROPAGATE(value))
+    { 
+    }
+
+    // tiny() and huge() return the smallest and largest representable
+    // integer values.  See <blitz/numinquire.h>
+    // NEEDS_WORK: use tiny(int()) once numeric_limits<T> available on
+    // all platforms
+    int lbound(int)
+    { return INT_MIN; }
+
+    int ubound(int)
+    { return INT_MAX; }
+    // NEEDS_WORK: use huge(int()) once numeric_limits<T> available on
+    // all platforms
+
+    T_numtype operator*()
+    { return value_; }
+
+#ifdef BZ_ARRAY_EXPR_PASS_INDEX_BY_VALUE
+    template<int N_rank>
+    T_numtype operator()(TinyVector<int,N_rank>)
+    { return value_; }
+#else
+    template<int N_rank>
+    T_numtype operator()(const TinyVector<int,N_rank>&)
+    { return value_; }
+#endif
+
+    void push(int) { }
+    void pop(int) { }
+    void advance() { }
+    void advance(int) { }
+    void loadStride(int) { }
+
+    _bz_bool isUnitStride(int rank) const
+    { return _bz_true; }
+
+    void advanceUnitStride()
+    { }
+
+    _bz_bool canCollapse(int,int) const 
+    { return _bz_true; }
+
+    T_numtype operator[](int)
+    { return value_; }
+
+    T_numtype fastRead(int)
+    { return value_; }
+
+    int suggestStride(int) const
+    { return 1; }
+
+    _bz_bool isStride(int,int) const
+    { return _bz_true; }
+
+    template<int N_rank>
+    void moveTo(const TinyVector<int,N_rank>& i)
+    {
+    }
+
+    void prettyPrint(string& str, prettyPrintFormat& format) const
+    {
+        if (format.tersePrintingSelected())
+            str += format.nextScalarOperandSymbol();
+        else
+            str += BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(T_numtype);
+    }
+
+    template<class T_shape>
+    _bz_bool shapeCheck(const T_shape&)
+    { return _bz_true; }
+
+protected:
+    _bz_ArrayExprConstant() { }
+
+    T_numtype value_;
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/array/asexpr.h>
+
+#endif // BZ_ARRAYEXPR_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/geometry.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/geometry.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/geometry.h	(revision 1307)
@@ -0,0 +1,81 @@
+#ifndef BZ_GEOMETRY_H
+#define BZ_GEOMETRY_H
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/geometry.h> must be included after <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+typedef double T_defaultSpatialCoordinate;
+
+template<int N_dim, class T = T_defaultSpatialCoordinate>
+class UniformOrthoGeometry {
+public:
+};
+
+template<int N_dim, class T = T_defaultSpatialCoordinate>
+class UniformCubicGeometry {
+    T h_;
+    T recip_h_;
+    T recip2_h_;
+    T recip3_h_;
+    TinyVector<T,N_dim> zero_;
+
+public:
+    typedef T T_coord;
+
+    UniformCubicGeometry()
+    {
+        h_ = 0.0;
+        recip_h_ = 0.0;
+        recip2_h_ = 0.0;
+        recip3_h_ = 0.0;
+        zero_ = 0.0;
+    }
+
+    UniformCubicGeometry(T spatialStep)
+    {
+        h_ = spatialStep;
+        zero_ = T(0);
+        setup();
+    }
+
+    UniformCubicGeometry(T spatialStep, TinyVector<T,N_dim> zeroCoordinates)
+    {   
+        h_ = spatialStep;
+        zero_ = zeroCoordinates;
+        setup();
+    }    
+
+    TinyVector<T,N_dim> toSpatial(TinyVector<int,N_dim> logicalCoord) const
+    {
+        return zero_ + h_ * logicalCoord;
+    }
+
+    T spatialStep() const
+    { return h_; }
+
+    T recipSpatialStep() const
+    { return recip_h_; }
+
+    T recipSpatialStepPow2() const
+    { return recip2_h_; }
+
+private:
+    void setup()
+    {
+        recip_h_ = 1.0 / h_;
+        recip2_h_ = 1.0 / pow2(h_);
+        recip3_h_ = 1.0 / pow3(h_);
+    }
+};
+
+template<int N_dim, class T = T_defaultSpatialCoordinate>
+class TensorProductGeometry {
+public:
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_GEOMETRY_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/indirect.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/indirect.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/indirect.h	(revision 1307)
@@ -0,0 +1,270 @@
+#ifndef BZ_ARRAY_INDIRECT_H
+#define BZ_ARRAY_INDIRECT_H
+
+#include <blitz/array/asexpr.h>
+#include <blitz/array/cartesian.h>
+
+BZ_NAMESPACE(blitz)
+
+template<class T_array, class T_index>
+class IndirectArray {
+
+public:
+    IndirectArray(T_array& array, T_index& index)
+        : array_(array), index_(index)
+    { }
+
+    template<class T_expr>
+    void operator=(T_expr expr);
+
+protected:
+    T_array& array_;
+    T_index& index_;
+};
+
+// Forward declarations
+template<class T_array, class T_arrayiter, class T_subdomain, class T_expr>
+inline void applyOverSubdomain(const T_array& array, T_arrayiter& arrayIter,
+    T_subdomain subdomain, T_expr expr);
+template<class T_array, class T_arrayiter, int N_rank, class T_expr>
+inline void applyOverSubdomain(const T_array& array, T_arrayiter& arrayIter,
+    RectDomain<N_rank> subdomain,
+    T_expr expr);
+
+template<class T_array, class T_index> template<class T_rhs>
+void IndirectArray<T_array, T_index>::operator=(T_rhs rhs)
+{
+    typedef _bz_typename asExpr<T_rhs>::T_expr T_expr;
+    T_expr expr(rhs);
+
+    _bz_typename T_array::T_iterator arrayIter(array_);
+
+    _bz_typename T_index::iterator iter = index_.begin(),
+                       end = index_.end();
+
+    for (; iter != end; ++iter)
+    {
+        _bz_typename T_index::value_type subdomain = *iter;
+        applyOverSubdomain(array_, arrayIter, subdomain, expr);
+    }
+}
+
+template<class T_array, class T_arrayiter, class T_subdomain, class T_expr>
+inline void applyOverSubdomain(const T_array& array, T_arrayiter& arrayIter, 
+    T_subdomain subdomain, T_expr expr)
+{
+    BZPRECHECK(array.isInRange(subdomain),
+        "In indirection using an STL container of TinyVector<int,"
+        << array.rank() << ">, one of the" << endl << "positions is out of"
+        " range: " << endl << subdomain << endl
+        << "Array lower bounds: " << array.lbound() << endl
+        << "Array upper bounds: " << array.ubound() << endl)
+
+    arrayIter.moveTo(subdomain);
+    expr.moveTo(subdomain);
+
+    *const_cast<_bz_typename T_arrayiter::T_numtype*>(arrayIter.data()) = *expr;
+}
+
+// Specialization for RectDomain<N>
+template<class T_array, class T_arrayiter, int N_rank, class T_expr>
+inline void applyOverSubdomain(const T_array& array, T_arrayiter& arrayIter, 
+    RectDomain<N_rank> subdomain,
+    T_expr expr)
+{
+    typedef _bz_typename T_array::T_numtype T_numtype;
+
+    // Assume that the RectDomain<N_rank> is a 1-D strip.
+    // Find the dimension in which the strip is oriented.  This
+    // variable is static so that we cache the value; likely to be
+    // the same for all strips within a container.
+
+    static int stripDim = 0;
+
+    if (subdomain.lbound(stripDim) == subdomain.ubound(stripDim))
+    {
+        // Cached value was wrong, find the correct value of stripDim
+        for (stripDim=0; stripDim < N_rank; ++stripDim)
+          if (subdomain.lbound(stripDim) != subdomain.ubound(stripDim))
+            break;
+
+        // Handle case where the strip is just a single point
+        if (stripDim == N_rank)
+            stripDim = 0;
+    }
+
+#ifdef BZ_DEBUG
+    // Check that this is in fact a 1D strip
+    for (int i=0; i < N_rank; ++i)
+      if ((i != stripDim) && (subdomain.lbound(i) != subdomain.ubound(i)))
+        BZPRECHECK(0, "In indirection using an STL container of RectDomain<"
+          << N_rank << ">, one of" << endl << "the RectDomain objects was not"
+          " a one-dimensional strip:" << endl << "RectDomain<" << N_rank
+          << ">::lbound() = " << subdomain.lbound() << endl
+          << "RectDomain<" << N_rank << ">::ubound() = " << subdomain.ubound())
+#endif
+
+    // Check that the start and end position are in range
+    BZPRECHECK(array.isInRange(subdomain.lbound()),
+        "In indirection using an STL container of RectDomain<"
+        << N_rank << ">, one of" << endl << "the RectDomain objects has a"
+        " lbound which is out of range:" << endl
+        << subdomain.lbound() << endl
+        << "Array lower bounds: " << array.lbound() << endl
+        << "Array upper bounds: " << array.ubound() << endl)
+
+    BZPRECHECK(array.isInRange(subdomain.ubound()),
+        "In indirection using an STL container of RectDomain<"
+        << N_rank << ">, one of" << endl << "the RectDomain objects has a"
+        " ubound which is out of range:" << endl
+        << subdomain.lbound() << endl
+        << "Array lower bounds: " << array.lbound() << endl
+        << "Array upper bounds: " << array.ubound() << endl)
+
+    // Position at the beginning of the strip
+    arrayIter.moveTo(subdomain.lbound());
+    expr.moveTo(subdomain.lbound());
+
+    // Loop through the strip
+
+#ifdef BZ_USE_FAST_READ_ARRAY_EXPR
+
+    _bz_bool useUnitStride = arrayIter.isUnitStride(stripDim)
+          && expr.isUnitStride(stripDim);
+
+    int lbound = subdomain.lbound(stripDim); 
+    int ubound = subdomain.ubound(stripDim);
+
+    if (useUnitStride)
+    {
+        T_numtype* _bz_restrict data = const_cast<T_numtype*>(arrayIter.data());
+
+        int length = ubound - lbound + 1;
+        for (int i=0; i < length; ++i)
+            data[i] = expr.fastRead(i);
+    }
+    else {
+#endif
+
+    arrayIter.loadStride(stripDim);
+    expr.loadStride(stripDim);
+
+    for (int i=lbound; i <= ubound; ++i)
+    {
+        *const_cast<_bz_typename T_arrayiter::T_numtype*>(arrayIter.data()) 
+            = *expr;
+        expr.advance();
+        arrayIter.advance();
+    }
+
+#ifdef BZ_USE_FAST_READ_ARRAY_EXPR
+    }
+#endif
+}
+
+// Global functions for cartesian product of index sets
+template<class T_container>
+CartesianProduct<TinyVector<int,2>,T_container,2>
+indexSet(const T_container& container0, const T_container& container1)
+{
+    return CartesianProduct<TinyVector<int,2>,T_container,2>(
+        const_cast<T_container&>(container0), 
+        const_cast<T_container&>(container1));
+}
+
+template<class T_container>
+CartesianProduct<TinyVector<int,3>,T_container,3>
+indexSet(const T_container& container0, const T_container& container1,
+    const T_container& container2)
+{
+    return CartesianProduct<TinyVector<int,3>,T_container,3>(
+        const_cast<T_container&>(container0), 
+        const_cast<T_container&>(container1), 
+        const_cast<T_container&>(container2));
+}
+
+// Mixture of singletons and containers, e.g. A[indexSet(I,3,K)]
+
+// cp_findContainerType<T1,T2,T3,...,Tn>::T_container
+// The set of parameters T1, T2, T3, ... Tn is a mixture of
+// int and T_container.  This traits class finds the container
+// type, and sets T_container.
+//
+// e.g. cp_findContainerType<int,int,list<int>,int>::T_container is list<int>
+//      cp_findContainerType<int,deque<int>,deque<int>>::T_container 
+//        is deque<int>
+
+template<class T1, class T2, class T3=int, class T4=int>
+struct cp_findContainerType {
+    typedef T1 T_container;
+};
+
+template<class T2, class T3, class T4>
+struct cp_findContainerType<int,T2,T3,T4> {
+    typedef _bz_typename cp_findContainerType<T2,T3,T4>::T_container T_container;
+};
+
+
+// The cp_traits class handles promotion of singleton integers to
+// containers.  It takes two template parameters:
+//    T = argument type
+//    T2 = container type
+// If T is an integer, then a container of type T2 is created and the
+// integer is inserted.  This container is returned.
+// Otherwise, T is assumed to be the same type as T2, and the original
+// container is returned.
+
+template<class T, class T2>
+struct cp_traits {
+    typedef T T_container;
+
+    static const T_container& make(const T& x)
+    { return x; }
+};
+
+template<class T2>
+struct cp_traits<int,T2> {
+    typedef T2 T_container;
+
+    static T2 make(int x)
+    { 
+        T2 singleton;
+        singleton.push_back(x);
+        return singleton;
+    }
+};
+
+// These versions of indexSet() allow mixtures of integer
+// and container arguments.  At least one integer must be
+// specified.
+
+template<class T1, class T2>
+CartesianProduct<TinyVector<int,2>, _bz_typename 
+    cp_findContainerType<T1,T2>::T_container,2> 
+indexSet(const T1& c1, const T2& c2)
+{
+    typedef _bz_typename cp_findContainerType<T1,T2>::T_container
+        T_container;
+
+    return CartesianProduct<TinyVector<int,2>, T_container, 2>(
+          cp_traits<T1,T_container>::make(c1),
+          cp_traits<T2,T_container>::make(c2));
+}
+
+template<class T1, class T2, class T3>
+CartesianProduct<TinyVector<int,3>, _bz_typename
+    cp_findContainerType<T1,T2,T3>::T_container, 3>
+indexSet(const T1& c1, const T2& c2, const T3& c3)
+{
+    typedef _bz_typename cp_findContainerType<T1,T2,T3>::T_container
+        T_container;
+
+    return CartesianProduct<TinyVector<int,3>, T_container, 3>(
+          cp_traits<T1,T_container>::make(c1),
+          cp_traits<T2,T_container>::make(c2),
+          cp_traits<T3,T_container>::make(c3));
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAY_INDIRECT_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/interlace.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/interlace.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/interlace.cc	(revision 1307)
@@ -0,0 +1,549 @@
+/***************************************************************************
+ * blitz/array/interlace.cc
+ *
+ * $Id: interlace.cc,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ *
+ */
+
+#ifndef BZ_ARRAYINTERLACE_CC
+#define BZ_ARRAYINTERLACE_CC
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/interlace.cc> must be included via <blitz/array.h>
+#endif
+
+#ifndef BZ_ARRAYSHAPE_H
+ #include <blitz/array/shape.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * This header provides two collections of routines:
+ *
+ * interlaceArrays(shape, A1, A2, ...);
+ * allocateArrays(shape, A1, A2, ...);
+ *
+ * interlaceArrays allocates a set of arrays so that their data is
+ * interlaced.  For example,
+ *
+ * Array<int,2> A, B;
+ * interlaceArrays(shape(10,10), A, B);
+ *
+ * sets up the array storage so that A(0,0) is followed by B(0,0) in
+ * memory; then A(0,1) and B(0,1), and so on.
+ *
+ * The allocateArrays() routines may or may not interlace the data,
+ * depending on whether interlacing is advantageous for the architecture.
+ * This is controlled by the setting of BZ_INTERLACE_ARRAYS in
+ * <blitz/tuning.h>.
+ */
+
+// Warning: Can't instantiate TinyVector<Range,N> because causes
+// conflict between TinyVector<T,N>::operator=(T) and
+// TinyVector<T,N>::operator=(Range)
+
+// NEEDS_WORK -- also shape for up to N=11
+// NEEDS_WORK -- shape(Range r1, Range r2, ...) (return TinyVector<Range,n>)
+//               maybe use Domain objects
+// NEEDS_WORK -- doesn't make a lot of sense for user to provide a
+//               GeneralArrayStorage<N_rank+1>
+
+template<class T_numtype>
+void makeInterlacedArray(Array<T_numtype,2>& mainArray,
+    Array<T_numtype,1>& subarray, int slice)
+{
+    Array<T_numtype,1> tmp = mainArray(Range::all(), slice);
+    subarray.reference(tmp);
+}
+
+template<class T_numtype>
+void makeInterlacedArray(Array<T_numtype,3>& mainArray,
+    Array<T_numtype,2>& subarray, int slice)
+{
+    Array<T_numtype,2> tmp = mainArray(Range::all(), Range::all(), 
+        slice);
+    subarray.reference(tmp);
+}
+
+template<class T_numtype>
+void makeInterlacedArray(Array<T_numtype,4>& mainArray,
+    Array<T_numtype,3>& subarray, int slice)
+{
+    Array<T_numtype,3> tmp = mainArray(Range::all(), Range::all(), 
+        Range::all(), slice);
+    subarray.reference(tmp);
+}
+
+// These routines always allocate interlaced arrays
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 2, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+}
+
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 3, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+    makeInterlacedArray(array, a3, 2);
+}
+
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 4, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+    makeInterlacedArray(array, a3, 2);
+    makeInterlacedArray(array, a4, 3);
+}
+
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 5, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+    makeInterlacedArray(array, a3, 2);
+    makeInterlacedArray(array, a4, 3);
+    makeInterlacedArray(array, a5, 4);
+}
+
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 6, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+    makeInterlacedArray(array, a3, 2);
+    makeInterlacedArray(array, a4, 3);
+    makeInterlacedArray(array, a5, 4);
+    makeInterlacedArray(array, a6, 5);
+}
+
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 7, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+    makeInterlacedArray(array, a3, 2);
+    makeInterlacedArray(array, a4, 3);
+    makeInterlacedArray(array, a5, 4);
+    makeInterlacedArray(array, a6, 5);
+    makeInterlacedArray(array, a7, 6);
+}
+
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7, Array<T_numtype,N_rank>& a8)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 8, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+    makeInterlacedArray(array, a3, 2);
+    makeInterlacedArray(array, a4, 3);
+    makeInterlacedArray(array, a5, 4);
+    makeInterlacedArray(array, a6, 5);
+    makeInterlacedArray(array, a7, 6);
+    makeInterlacedArray(array, a8, 7);
+}
+
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7, Array<T_numtype,N_rank>& a8,
+    Array<T_numtype,N_rank>& a9)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 9, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+    makeInterlacedArray(array, a3, 2);
+    makeInterlacedArray(array, a4, 3);
+    makeInterlacedArray(array, a5, 4);
+    makeInterlacedArray(array, a6, 5);
+    makeInterlacedArray(array, a7, 6);
+    makeInterlacedArray(array, a8, 7);
+    makeInterlacedArray(array, a9, 8);
+}
+
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7, Array<T_numtype,N_rank>& a8,
+    Array<T_numtype,N_rank>& a9, Array<T_numtype,N_rank>& a10)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 10, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+    makeInterlacedArray(array, a3, 2);
+    makeInterlacedArray(array, a4, 3);
+    makeInterlacedArray(array, a5, 4);
+    makeInterlacedArray(array, a6, 5);
+    makeInterlacedArray(array, a7, 6);
+    makeInterlacedArray(array, a8, 7);
+    makeInterlacedArray(array, a9, 8);
+    makeInterlacedArray(array, a10, 9);
+}
+
+template<class T_numtype, int N_rank>
+void interlaceArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7, Array<T_numtype,N_rank>& a8,
+    Array<T_numtype,N_rank>& a9, Array<T_numtype,N_rank>& a10,
+    Array<T_numtype,N_rank>& a11)
+{
+    GeneralArrayStorage<N_rank+1> storage;
+    Array<T_numtype, N_rank+1> array(shape, 11, storage);
+    makeInterlacedArray(array, a1, 0);
+    makeInterlacedArray(array, a2, 1);
+    makeInterlacedArray(array, a3, 2);
+    makeInterlacedArray(array, a4, 3);
+    makeInterlacedArray(array, a5, 4);
+    makeInterlacedArray(array, a6, 5);
+    makeInterlacedArray(array, a7, 6);
+    makeInterlacedArray(array, a8, 7);
+    makeInterlacedArray(array, a9, 8);
+    makeInterlacedArray(array, a10, 9);
+    makeInterlacedArray(array, a11, 10);
+}
+
+// NEEDS_WORK -- make `storage' a parameter in these routines
+//  Will be tricky: have to convert GeneralArrayStorage<N_rank> to
+//  GeneralArrayStorage<N_rank+1>
+
+// These routines may or may not interlace arrays, depending on
+// whether it is advantageous for this platform.
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+#endif
+}
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2, a3);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+    a3.resize(shape);
+#endif
+}
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2, a3, a4);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+    a3.resize(shape);
+    a4.resize(shape);
+#endif
+}
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2, a3, a4, a5);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+    a3.resize(shape);
+    a4.resize(shape);
+    a5.resize(shape);
+#endif
+}
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2, a3, a4, a5, a6);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+    a3.resize(shape);
+    a4.resize(shape);
+    a5.resize(shape);
+    a6.resize(shape);
+#endif
+}
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2, a3, a4, a5, a6, a7);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+    a3.resize(shape);
+    a4.resize(shape);
+    a5.resize(shape);
+    a6.resize(shape);
+    a7.resize(shape);
+#endif
+}
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7, Array<T_numtype,N_rank>& a8)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2, a3, a4, a5, a6, a7, a8);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+    a3.resize(shape);
+    a4.resize(shape);
+    a5.resize(shape);
+    a6.resize(shape);
+    a7.resize(shape);
+    a8.resize(shape);
+#endif
+}
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7, Array<T_numtype,N_rank>& a8,
+    Array<T_numtype,N_rank>& a9)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+    a3.resize(shape);
+    a4.resize(shape);
+    a5.resize(shape);
+    a6.resize(shape);
+    a7.resize(shape);
+    a8.resize(shape);
+    a9.resize(shape);
+#endif
+}
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7, Array<T_numtype,N_rank>& a8,
+    Array<T_numtype,N_rank>& a9, Array<T_numtype,N_rank>& a10)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+    a3.resize(shape);
+    a4.resize(shape);
+    a5.resize(shape);
+    a6.resize(shape);
+    a7.resize(shape);
+    a8.resize(shape);
+    a9.resize(shape);
+    a10.resize(shape);
+#endif
+}
+
+template<class T_numtype, int N_rank>
+void allocateArrays(const TinyVector<int,N_rank>& shape,
+    Array<T_numtype,N_rank>& a1, Array<T_numtype,N_rank>& a2,
+    Array<T_numtype,N_rank>& a3, Array<T_numtype,N_rank>& a4,
+    Array<T_numtype,N_rank>& a5, Array<T_numtype,N_rank>& a6,
+    Array<T_numtype,N_rank>& a7, Array<T_numtype,N_rank>& a8,
+    Array<T_numtype,N_rank>& a9, Array<T_numtype,N_rank>& a10,
+    Array<T_numtype,N_rank>& a11)
+{
+#ifdef BZ_INTERLACE_ARRAYS
+    interlaceArrays(shape, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
+#else
+    a1.resize(shape);
+    a2.resize(shape);
+    a3.resize(shape);
+    a4.resize(shape);
+    a5.resize(shape);
+    a6.resize(shape);
+    a7.resize(shape);
+    a8.resize(shape);
+    a9.resize(shape);
+    a10.resize(shape);
+    a11.resize(shape);
+#endif
+}
+
+// NEEDS_WORK -- allocateArrays for TinyVector<Range,N_rank>
+
+// This constructor is used to create interlaced arrays.
+template<class T_numtype, int N_rank>
+Array<T_numtype,N_rank>::Array(const TinyVector<int,N_rank-1>& shape,
+    int lastExtent, const GeneralArrayStorage<N_rank>& storage)
+    : storage_(storage)
+{
+    // Create an array with the given shape, plus an extra dimension
+    // for the number of arrays being allocated.  This extra dimension
+    // must have minor storage order.
+
+    if (ordering(0) == 0)
+    {
+        // Column major storage order (or something like it)
+        length_[0] = lastExtent;
+        storage_.setBase(0,0);
+        for (int i=1; i < N_rank; ++i)
+            length_[i] = shape[i-1];
+    }
+    else if (ordering(0) == N_rank-1)
+    {
+        // Row major storage order (or something like it)
+        for (int i=0; i < N_rank-1; ++i)
+            length_[i] = shape[i];
+        length_[N_rank-1] = lastExtent;
+        storage_.setBase(N_rank-1, 0);
+    }
+    else {
+        BZPRECHECK(0, "Used allocateArrays() with a peculiar storage format");
+    }
+
+    setupStorage(N_rank-1);
+}
+
+// NEEDS_WORK -- see note about TinyVector<Range,N> in <blitz/arrayshape.h>
+#if 0
+template<class T_numtype, int N_rank>
+Array<T_numtype,N_rank>::Array(const TinyVector<Range,N_rank-1>& shape,
+    int lastExtent, const GeneralArrayStorage<N_rank>& storage)
+    : storage_(storage)
+{
+#ifdef BZ_DEBUG
+    for (int i=0; i < N_rank; ++i)
+      BZPRECHECK(shape[i].isAscendingContiguous(),
+        "In call to allocateArrays(), a Range object is not ascending" << endl
+        << "contiguous: " << shape[i] << endl);
+#endif
+
+    if (ordering(0) == 0)
+    {
+        // Column major storage order (or something like it)
+        length_[0] = lastExtent;
+        storage_.setBase(0,0);
+        for (int i=1; i < N_rank; ++i)
+        {
+            length_[i] = shape[i-1].length();
+            storage_.setBase(i, shape[i-1].first());
+        }
+    }
+    else if (ordering(0) == N_rank-1)
+    {
+        // Row major storage order (or something like it)
+        for (int i=0; i < N_rank-1; ++i)
+        {
+            length_[i] = shape[i];
+            storage_.setBase(i, shape[i].first());
+        }
+        length_[N_rank-1] = lastExtent;
+        storage_.setBase(N_rank-1, 0);
+    }
+    else {
+        BZPRECHECK(0, "Used allocateArrays() with a peculiar storage format");
+    }
+
+    setupStorage(N_rank-1);
+}
+#endif
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYINTER_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/io.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/io.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/io.cc	(revision 1307)
@@ -0,0 +1,44 @@
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/io.cc> must be included via <blitz/array.h>
+#endif
+
+#ifndef BZ_ARRAYIO_CC
+#define BZ_ARRAYIO_CC
+
+BZ_NAMESPACE(blitz)
+
+template<class T_numtype>
+ostream& operator<<(ostream& os, const Array<T_numtype,1>& x)
+{
+    os << "[ ";
+    for (int i=x.lbound(firstRank); i <= x.ubound(firstRank); ++i)
+    {
+        os << setw(10) << x(i);
+        if (!((i+1)%7))
+            os << endl << "  ";
+    }
+    os << " ]";
+    return os;
+}
+
+template<class T_numtype>
+ostream& operator<<(ostream& os, const Array<T_numtype,2>& x)
+{
+    os << x.rows() << " x " << x.columns() << endl;
+    for (int i=x.lbound(firstRank); i <= x.ubound(firstRank); ++i)
+    {
+        for (int j=x.lbound(secondRank); j <= x.ubound(secondRank); ++j)
+        {
+            os << setw(10) << x(i,j);
+            if (!((j+1)%7))
+                os << endl << "  ";
+        }
+        os << endl;
+    }
+
+    return os;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYIO_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/iter.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/iter.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/iter.h	(revision 1307)
@@ -0,0 +1,262 @@
+/***************************************************************************
+ * blitz/array/iter.h     Declaration of ArrayIterator<P_numtype,N_rank>
+ *
+ * $Id: iter.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_ARRAYITER_H
+#define BZ_ARRAYITER_H
+
+#ifdef BZ_HAVE_STD
+ #include <strstream>
+#else
+ #include <strstream.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/iter.h> must be included via <blitz/array.h>
+#endif
+
+template<class P_numtype, int N_rank>
+class ArrayIterator {
+public:
+    typedef P_numtype                T_numtype;
+    typedef Array<T_numtype, N_rank> T_array;
+    typedef ArrayIterator<P_numtype, N_rank> T_iterator;
+    typedef const T_array& T_ctorArg1;
+    typedef int            T_ctorArg2;    // dummy
+
+    enum { numArrayOperands = 1, numIndexPlaceholders = 0,
+        rank = N_rank };
+
+    // NB: this ctor does NOT preserve stack and stride
+    // parameters.  This is for speed purposes.
+    ArrayIterator(const ArrayIterator<P_numtype, N_rank>& x)
+        : array_(x.array_), data_(x.data_)
+    { }
+
+    void operator=(const ArrayIterator<P_numtype, N_rank>& x)
+    {
+        array_ = x.array_;
+        data_ = x.data_;
+        stack_ = x.stack_;
+        stride_ = x.stride_;
+    }
+
+    ArrayIterator(const T_array& array)
+        : array_(array)
+    {
+        data_   = array.data();
+    }
+
+    ~ArrayIterator()
+    { }
+
+#ifdef BZ_ARRAY_EXPR_PASS_INDEX_BY_VALUE
+    T_numtype operator()(TinyVector<int, N_rank> i)
+    { return array_(i); }
+#else
+    T_numtype operator()(const TinyVector<int, N_rank>& i)
+    { return array_(i); }
+#endif
+
+    int lbound(int rank)
+    { 
+        if (rank < N_rank)
+            return array_.lbound(rank); 
+        else
+            return INT_MIN;   // tiny(int());
+    }
+
+    int ubound(int rank)
+    { 
+        if (rank < N_rank)
+            return array_.ubound(rank); 
+        else
+            return INT_MAX;   // huge(int());
+    }
+
+    T_numtype operator*()
+    { return *data_; }
+
+    T_numtype operator[](int i)
+    { return data_[i * stride_]; }
+
+    T_numtype fastRead(int i)
+    { return data_[i]; }
+
+    int suggestStride(int rank) const
+    { return array_.stride(rank); }
+
+    _bz_bool isStride(int rank, int stride) const
+    { return array_.stride(rank) == stride; }
+
+    void push(int position)
+    {
+        stack_[position] = data_;
+    }
+  
+    void pop(int position)
+    { 
+        data_ = stack_[position];
+    }
+
+    void advance()
+    {
+        data_ += stride_;
+    }
+
+    void advance(int n)
+    {
+        data_ += n * stride_;
+    }
+
+    void loadStride(int rank)
+    {
+        stride_ = array_.stride(rank);
+    }
+
+    const T_numtype * _bz_restrict data() const
+    { return data_; }
+
+    int stride() const
+    { return stride_; }
+
+    _bz_bool isUnitStride(int rank) const
+    { return array_.stride(rank) == 1; }
+
+    void advanceUnitStride()
+    { ++data_; }
+
+    _bz_bool canCollapse(int outerLoopRank, int innerLoopRank) const
+    { return array_.canCollapse(outerLoopRank, innerLoopRank); }
+
+    void prettyPrint(string& str, prettyPrintFormat& format) const
+    {
+        if (format.tersePrintingSelected())
+            str += format.nextArrayOperandSymbol();
+        else if (format.dumpArrayShapesMode())
+        {
+            ostrstream ostr;
+            ostr << array_.shape();
+            str += ostr.str();
+        }
+        else {
+            str += "Array<";
+            str += BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(T_numtype);
+            str += ",";
+
+            char tmpBuf[10];
+            sprintf(tmpBuf, "%d", N_rank);
+
+            str += tmpBuf;
+            str += ">";
+        }
+    }
+
+    template<class T_shape>
+    _bz_bool shapeCheck(const T_shape& shape)
+    { return areShapesConformable(shape, array_.length()); }
+
+    // Experimental
+    T_numtype& operator()(int i, int j)
+    {
+        return (T_numtype&)data_[i*array_.stride(0) + j*array_.stride(1)];
+    }
+
+    // Experimental
+    T_numtype& operator()(int i, int j, int k)
+    {
+        return (T_numtype&)data_[i*array_.stride(0) + j*array_.stride(1)
+          + k*array_.stride(2)];
+    }
+
+    // Experimental
+
+    void moveTo(int i, int j)
+    {
+        data_ = &const_cast<T_array&>(array_)(i,j);
+    }
+
+    void moveTo(int i, int j, int k)
+    {
+        data_ = &const_cast<T_array&>(array_)(i,j,k);
+    }
+
+    void moveTo(const TinyVector<int,N_rank>& i)
+    {
+        data_ = &const_cast<T_array&>(array_)(i);
+    }
+
+    // Experimental
+    void operator=(T_numtype x)
+    {   *const_cast<T_numtype* _bz_restrict>(data_) = x; }
+
+    // Experimental
+    template<class T_value>
+    void operator=(T_value x)
+    {   *const_cast<T_numtype* _bz_restrict>(data_) = x; }
+
+    // Experimental
+    template<class T_value>
+    void operator+=(T_value x)
+    { *const_cast<T_numtype* _bz_restrict>(data_) += x; }
+
+    // NEEDS_WORK: other operators
+
+    // Experimental
+    operator T_numtype() const
+    { return *data_; }
+
+    // Experimental
+    T_numtype shift(int offset, int dim)
+    {
+        return data_[offset*array_.stride(dim)];
+    }
+
+    // Experimental
+    T_numtype shift(int offset1, int dim1, int offset2, int dim2)
+    {
+        return data_[offset1*array_.stride(dim1) 
+            + offset2*array_.stride(dim2)];
+    }
+
+private:
+    const T_array&                          array_;
+    const T_numtype * _bz_restrict          data_;
+    const T_numtype * _bz_restrict          stack_[N_rank];
+    int                                     stride_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYITER_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/map.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/map.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/map.h	(revision 1307)
@@ -0,0 +1,430 @@
+/***************************************************************************
+ * blitz/array/map.h      Declaration of the ArrayIndexMapping class
+ *
+ * $Id: map.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+/*
+ * ArrayIndexMapping is used to implement tensor array notation.  For
+ * example:
+ *
+ * Array<float, 2> A, B;
+ * firstIndex i;
+ * secondIndex j;
+ * thirdIndex k;
+ * Array<float, 3> C = A(i,j) * B(j,k);
+ *
+ * For expression templates purposes, something like B(j,k) is represented
+ * by an instance of class ArrayIndexMapping.  This class maps an array onto
+ * the destination array coordinate system, e.g. B(j,k) -> C(i,j,k)
+ */
+
+#ifndef BZ_ARRAYMAP_H
+#define BZ_ARRAYMAP_H
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/map.h> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * _bz_doArrayIndexMapping is a helper class.  It is specialized for
+ * ranks 1, 2, 3, ..., 11.
+ */
+
+template<int N_rank>
+struct _bz_doArrayIndexMapping {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, N_rank>&, 
+        const TinyVector<int,N_destRank>&, int, int, int, int, int, int,
+        int, int, int, int, int)
+    {
+        // If you try to use an array index mapping on an array with
+        // rank greater than 11, then you'll get a precondition failure
+        // here.
+        BZPRECONDITION(0);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<1> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 1>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int, int, int, int, 
+        int, int, int, int, int, int)
+    {
+        return array(index[i0]);
+    }
+};
+
+
+template<>
+struct _bz_doArrayIndexMapping<2> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 2>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int, 
+        int, int, int, int, int, int, int, int)
+    {
+        return array(index[i0], index[i1]);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<3> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 3>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int i2,
+        int, int, int, int, int, int, int, int)
+    {
+        return array(index[i0], index[i1], index[i2]);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<4> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 4>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int i2,
+        int i3, int, int, int, int, int, int, int)
+    {
+        return array(index[i0], index[i1], index[i2], index[i3]);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<5> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 5>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int i2,
+        int i3, int i4, int, int, int, int, int, int)
+    {
+        return array(index[i0], index[i1], index[i2], index[i3], index[i4]);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<6> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 6>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int i2,
+        int i3, int i4, int i5, int, int, int, int, int)
+    {
+        return array(index[i0], index[i1], index[i2], index[i3], index[i4],
+            index[i5]);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<7> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 7>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int i2,
+        int i3, int i4, int i5, int i6, int, int, int, int)
+    {
+        return array(index[i0], index[i1], index[i2], index[i3], index[i4],
+            index[i5], index[i6]);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<8> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 8>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int i2,
+        int i3, int i4, int i5, int i6, int i7, int, int, int)
+    {
+        return array(index[i0], index[i1], index[i2], index[i3], index[i4],
+            index[i5], index[i6], index[i7]);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<9> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 9>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int i2,
+        int i3, int i4, int i5, int i6, int i7, int i8, int, int)
+    {
+        return array(index[i0], index[i1], index[i2], index[i3], index[i4],
+            index[i5], index[i6], index[i7], index[i8]);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<10> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 10>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int i2,
+        int i3, int i4, int i5, int i6, int i7, int i8, int i9, int)
+    {
+        return array(index[i0], index[i1], index[i2], index[i3], index[i4],
+            index[i5], index[i6], index[i7], index[i8], index[i9]);
+    }
+};
+
+template<>
+struct _bz_doArrayIndexMapping<11> {
+    template<class T_numtype, int N_destRank>
+    static T_numtype map(const Array<T_numtype, 11>& array,
+        const TinyVector<int,N_destRank>& index, int i0, int i1, int i2,
+        int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10)
+    {
+        return array(index[i0], index[i1], index[i2], index[i3], index[i4],
+            index[i5], index[i6], index[i7], index[i8], index[i9],
+            index[i10]);
+    }
+};
+
+template<class P_numtype, int N_rank, int N_map0, int N_map1=0, int N_map2=0,
+    int N_map3=0, int N_map4=0, int N_map5=0, int N_map6=0, int N_map7=0, 
+    int N_map8=0, int N_map9=0, int N_map10=0>
+class ArrayIndexMapping {
+public:
+    typedef P_numtype T_numtype;
+    typedef const Array<T_numtype,N_rank>& T_ctorArg1;
+    typedef int                            T_ctorArg2;    // dummy
+
+    /*
+     * This enum block finds the maximum of the N_map0, N_map1, ..., N_map10
+     * parameters and stores it in maxRank10.  The rank of the expression is
+     * then maxRank10 + 1, since the IndexPlaceholders start at 0 rather than
+     * 1.  
+     */
+    enum {
+        maxRank1 = (N_map0 > N_map1) ? N_map0 : N_map1,
+        maxRank2 = (N_map2 > maxRank1) ? N_map2 : maxRank1,
+        maxRank3 = (N_map3 > maxRank2) ? N_map3 : maxRank2,
+        maxRank4 = (N_map4 > maxRank3) ? N_map4 : maxRank3,
+        maxRank5 = (N_map5 > maxRank4) ? N_map5 : maxRank4,
+        maxRank6 = (N_map6 > maxRank5) ? N_map6 : maxRank5,
+        maxRank7 = (N_map7 > maxRank6) ? N_map7 : maxRank6,
+        maxRank8 = (N_map8 > maxRank7) ? N_map8 : maxRank7,
+        maxRank9 = (N_map9 > maxRank8) ? N_map9 : maxRank8,
+        maxRank10 = (N_map10 > maxRank9) ? N_map10 : maxRank9
+    };
+
+    enum { numArrayOperands = 1, numIndexPlaceholders = 1,
+        rank = maxRank10 + 1 };
+
+    ArrayIndexMapping(const Array<T_numtype, N_rank>& array)
+        : array_(array)
+    { 
+    }
+
+    ArrayIndexMapping(const ArrayIndexMapping<T_numtype,N_rank,N_map0,
+        N_map1,N_map2,N_map3,N_map4,N_map5,N_map6,N_map7,N_map8,N_map9,
+        N_map10>& z)
+        : array_(z.array_)
+    { 
+    }
+
+#ifdef BZ_ARRAY_EXPR_PASS_INDEX_BY_VALUE
+    template<int N_destRank>
+    T_numtype operator()(TinyVector<int, N_destRank> i)
+    {
+        return _bz_doArrayIndexMapping<N_rank>::map(array_, i,
+            N_map0, N_map1, N_map2, N_map3, N_map4, N_map5, N_map6,
+            N_map7, N_map8, N_map9, N_map10);
+    }
+#else
+    template<int N_destRank>
+    T_numtype operator()(const TinyVector<int, N_destRank>& i)
+    {
+        return _bz_doArrayIndexMapping<N_rank>::map(array_, i,
+            N_map0, N_map1, N_map2, N_map3, N_map4, N_map5, N_map6,
+            N_map7, N_map8, N_map9, N_map10);
+    }
+#endif
+
+    int lbound(int rank)
+    { 
+        if (N_map0 == rank)    
+            return array_.lbound(0);
+        else if ((N_map1 == rank) && (N_rank > 1))
+            return array_.lbound(1);
+        else if ((N_map2 == rank) && (N_rank > 2))
+            return array_.lbound(2);
+        else if ((N_map3 == rank) && (N_rank > 3))
+            return array_.lbound(3);
+        else if ((N_map4 == rank) && (N_rank > 4))
+            return array_.lbound(4);
+        else if ((N_map5 == rank) && (N_rank > 5))
+            return array_.lbound(5);
+        else if ((N_map6 == rank) && (N_rank > 6))
+            return array_.lbound(6);
+        else if ((N_map7 == rank) && (N_rank > 7))
+            return array_.lbound(7);
+        else if ((N_map8 == rank) && (N_rank > 8))
+            return array_.lbound(8);
+        else if ((N_map9 == rank) && (N_rank > 9))
+            return array_.lbound(9);
+        else if ((N_map10 == rank) && (N_rank > 10))
+            return array_.lbound(10);
+        else
+            return INT_MIN;   // tiny(int());
+    }
+
+    int ubound(int rank)
+    {   
+        if (N_map0 == rank)
+            return array_.ubound(0);
+        else if ((N_map1 == rank) && (N_rank > 1))
+            return array_.ubound(1);
+        else if ((N_map2 == rank) && (N_rank > 2))
+            return array_.ubound(2);
+        else if ((N_map3 == rank) && (N_rank > 3))
+            return array_.ubound(3);
+        else if ((N_map4 == rank) && (N_rank > 4))
+            return array_.ubound(4);
+        else if ((N_map5 == rank) && (N_rank > 5))
+            return array_.ubound(5);
+        else if ((N_map6 == rank) && (N_rank > 6))
+            return array_.ubound(6);
+        else if ((N_map7 == rank) && (N_rank > 7))
+            return array_.ubound(7);
+        else if ((N_map8 == rank) && (N_rank > 8))
+            return array_.ubound(8);
+        else if ((N_map9 == rank) && (N_rank > 9))
+            return array_.ubound(9);
+        else if ((N_map10 == rank) && (N_rank > 10))
+            return array_.ubound(10);
+        else
+            return INT_MAX;   // huge(int());
+    }
+
+    // If you have a precondition failure on this routine, it means
+    // you are trying to use stack iteration mode on an expression
+    // which contains an index placeholder.  You must use index
+    // iteration mode instead.
+    int operator*()
+    {
+        BZPRECONDITION(0);
+        return 0;
+    }
+
+    // See operator*() note
+    void push(int)
+    {
+        BZPRECONDITION(0);
+    }
+
+    // See operator*() note
+    void pop(int)
+    {
+        BZPRECONDITION(0);
+    }
+
+    // See operator*() note
+    void advance()
+    {
+        BZPRECONDITION(0);
+    }
+
+    // See operator*() note
+    void advance(int)
+    {
+        BZPRECONDITION(0);
+    }
+
+    // See operator*() note
+    void loadStride(int)
+    {
+        BZPRECONDITION(0);
+    }
+
+    _bz_bool isUnitStride(int rank) const
+    {
+        BZPRECONDITION(0);
+        return false;
+    }
+
+    void advanceUnitStride()
+    {
+        BZPRECONDITION(0);
+    }
+
+    _bz_bool canCollapse(int,int) const
+    {   BZPRECONDITION(0);  return _bz_false; }
+
+    T_numtype operator[](int)
+    {   
+        BZPRECONDITION(0);
+        return T_numtype();
+    }
+
+    T_numtype fastRead(int)
+    {
+        BZPRECONDITION(0);
+        return T_numtype();
+    }
+
+    int suggestStride(int) const
+    {
+        BZPRECONDITION(0);
+        return 0;
+    }
+
+    _bz_bool isStride(int,int) const
+    {
+        BZPRECONDITION(0);
+        return _bz_true;
+    }
+
+    template<int N_rank2>
+    void moveTo(const TinyVector<int,N_rank2>& i)
+    {
+        BZPRECONDITION(0);
+        return ;
+    }
+
+    void prettyPrint(string& str, prettyPrintFormat& format) const
+    {
+        // NEEDS_WORK-- do real formatting for reductions
+        str += "map[NEEDS_WORK]";
+    }
+
+    template<class T_shape>
+    _bz_bool shapeCheck(const T_shape& shape) const
+    { 
+        // NEEDS_WORK-- do a real shape check (tricky)
+        return _bz_true; 
+    }
+
+private:
+    ArrayIndexMapping() { }
+
+    const Array<T_numtype, N_rank>& array_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYMAP_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/methods.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/methods.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/methods.cc	(revision 1307)
@@ -0,0 +1,321 @@
+/*
+ * $Id: methods.cc,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/08/18 19:13:08  tveldhui
+ * Just prior to implementing fastRead() optimization for array
+ * expression evaluation.
+ *
+ * Revision 1.2  1997/08/15 21:14:10  tveldhui
+ * Just prior to loop-collapse change
+ *
+ */
+
+#ifndef BZ_ARRAYMETHODS_CC
+#define BZ_ARRAYMETHODS_CC
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/methods.cc> must be included via <blitz/array.h>
+#endif
+
+#include <blitz/minmax.h>  // Needed for resizeAndPreserve()
+
+BZ_NAMESPACE(blitz)
+
+template<class P_numtype, int N_rank> template<class T_expr>
+Array<P_numtype,N_rank>::Array(_bz_ArrayExpr<T_expr> expr)
+{
+    BZ_NOT_IMPLEMENTED();
+
+    // Obtain storage order from an operand in the expression
+    // (if possible).  Probably best to assume C-style storage,
+    // then pass the storage object to the expression for possible
+    // modification.
+
+    // Obtain ubounds/lbounds from array operands.  Precondition
+    // failure if any bounds missing.
+
+    // Size array.
+
+    // assignment of expression.
+}
+
+template<class T_numtype, int N_rank>
+Array<T_numtype,N_rank>::Array(const TinyVector<int, N_rank>& lbounds,
+    const TinyVector<int, N_rank>& extent,
+    const GeneralArrayStorage<N_rank>& storage)
+    : storage_(storage)
+{
+    length_ = extent;
+    storage_.setBase(lbounds);
+    setupStorage(N_rank - 1);
+}
+
+
+/*
+ * This routine takes the storage information for the array
+ * (ascendingFlag_[], base_[], and ordering_[]) and the size
+ * of the array (length_[]) and computes the stride vector
+ * (stride_[]) and the zero offset (see explanation in array.h).
+ */
+template<class P_numtype, int N_rank>
+_bz_inline2 void Array<P_numtype, N_rank>::computeStrides()
+{
+    if (N_rank > 1)
+    {
+      int stride = 1;
+
+      // This flag simplifies the code in the loop, encouraging
+      // compile-time computation of strides through constant folding.
+      _bz_bool allAscending = storage_.allRanksStoredAscending();
+
+      // BZ_OLD_FOR_SCOPING
+      int n;
+      for (n=0; n < N_rank; ++n)
+      {
+          int strideSign = +1;
+
+          // If this rank is stored in descending order, then the stride
+          // will be negative.
+          if (!allAscending)
+          {
+            if (!isRankStoredAscending(ordering(n)))
+                strideSign = -1;
+          }
+
+          // The stride for this rank is the product of the lengths of
+          // the ranks minor to it.
+          stride_[ordering(n)] = stride * strideSign;
+
+          stride *= length_[ordering(n)];
+      }
+    }
+    else {
+        // Specialization for N_rank == 1
+        // This simpler calculation makes it easier for the compiler
+        // to propagate stride values.
+
+        if (isRankStoredAscending(0))
+            stride_[0] = 1;
+        else
+            stride_[0] = -1;
+    }
+
+    calculateZeroOffset();
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::calculateZeroOffset()
+{
+    // Calculate the offset of (0,0,...,0)
+    zeroOffset_ = 0;
+
+    // zeroOffset_ = - sum(where(ascendingFlag_, stride_ * base_,
+    //     (length_ - 1 + base_) * stride_))
+    for (int n=0; n < N_rank; ++n)
+    {
+        if (!isRankStoredAscending(n))
+            zeroOffset_ -= (length_[n] - 1 + base(n)) * stride_[n];
+        else
+            zeroOffset_ -= stride_[n] * base(n);
+    }
+}
+
+
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::dumpStructureInformation(ostream& os) const
+{
+    os << "Dump of Array<" << BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(P_numtype) 
+       << ", " << N_rank << ">:" << endl
+       << "ordering_      = " << storage_.ordering() << endl
+       << "ascendingFlag_ = " << storage_.ascendingFlag() << endl
+       << "base_          = " << storage_.base() << endl
+       << "length_        = " << length_ << endl
+       << "stride_        = " << stride_ << endl
+       << "zeroOffset_    = " << zeroOffset_ << endl
+       << "numElements()  = " << numElements() << endl
+       << "storageContiguous = " << storageContiguous_ << endl;
+}
+
+/*
+ * Make this array a view of another array's data.
+ */
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::reference(Array<P_numtype, N_rank>& array)
+{
+    storage_ = array.storage_;
+    length_ = array.length_;
+    stride_ = array.stride_;
+    zeroOffset_ = array.zeroOffset_;
+    storageContiguous_ = array.storageContiguous_;
+
+    MemoryBlockReference<P_numtype>::changeBlock(array, array.zeroOffset_);
+
+    data_ = array.data_;
+}
+
+/*
+ * This method is called to allocate memory for a new array.  
+ */
+template<class P_numtype, int N_rank>
+_bz_inline2 void Array<P_numtype, N_rank>::setupStorage(int lastRankInitialized)
+{
+    TAU_TYPE_STRING(p1, "Array<T,N>::setupStorage() [T="
+        + CT(P_numtype) + ",N=" + CT(N_rank) + "]");
+    TAU_PROFILE(" ", p1, TAU_BLITZ);
+
+    /*
+     * If the length of some of the ranks was unspecified, fill these
+     * in using the last specified value.
+     *
+     * e.g. Array<int,3> A(40) results in a 40x40x40 array.
+     */
+    for (int i=lastRankInitialized + 1; i < N_rank; ++i)
+    {
+        storage_.setBase(i, storage_.base(lastRankInitialized));
+        length_[i] = length_[lastRankInitialized];
+    }
+
+    // Compute strides
+    computeStrides();
+
+    // Allocate a block of memory
+    MemoryBlockReference<P_numtype>::newBlock(numElements());
+
+    // Adjust the base of the array to account for non-zero base
+    // indices and reversals
+    data_ += zeroOffset_;
+
+    // A new array will always have contiguous storage
+    storageContiguous_ = _bz_true;
+}
+
+template<class T_numtype, int N_rank>
+Array<T_numtype, N_rank> Array<T_numtype, N_rank>::copy() const
+{
+    if (numElements())
+    {
+        Array<T_numtype, N_rank> z(length_, storage_);
+        z = *this;
+        return z;
+    }
+    else {
+        // Null array-- don't bother allocating an empty block.
+        return *this;
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::makeUnique()
+{
+    if (numReferences() > 1)
+    {
+        T_array tmp = copy();
+        reference(tmp);
+    }
+}
+
+template<class T_numtype, int N_rank>
+Array<T_numtype, N_rank> Array<T_numtype, N_rank>::transpose(int r0, int r1, 
+    int r2, int r3, int r4, int r5, int r6, int r7, int r8, int r9, int r10)
+{
+    T_array B(*this);
+    B.transposeSelf(r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10);
+    return B;
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::transposeSelf(int r0, int r1, int r2, int r3,
+    int r4, int r5, int r6, int r7, int r8, int r9, int r10)
+{
+    BZPRECHECK(r0+r1+r2+r3+r4+r5+r6+r7+r8+r9+r10 == N_rank * (N_rank-1) / 2,
+        "Invalid array transpose() arguments." << endl
+        << "Arguments must be a permutation of the numerals (0,...,"
+        << (N_rank - 1) << ")");
+
+    // Create a temporary reference copy of this array
+    Array<T_numtype, N_rank> x(*this);
+
+    // Now reorder the dimensions using the supplied permutation
+    doTranspose(0, r0, x);
+    doTranspose(1, r1, x);
+    doTranspose(2, r2, x);
+    doTranspose(3, r3, x);
+    doTranspose(4, r4, x);
+    doTranspose(5, r5, x);
+    doTranspose(6, r6, x);
+    doTranspose(7, r7, x);
+    doTranspose(8, r8, x);
+    doTranspose(9, r9, x);
+    doTranspose(10, r10, x);
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::doTranspose(int destRank, int sourceRank,
+    Array<T_numtype, N_rank>& array)
+{
+    // BZ_NEEDS_WORK: precondition check
+
+    if (destRank >= N_rank)
+        return;
+
+    length_[destRank] = array.length_[sourceRank];
+    stride_[destRank] = array.stride_[sourceRank];
+    storage_.setAscendingFlag(destRank, 
+        array.isRankStoredAscending(sourceRank));
+    storage_.setBase(destRank, array.base(sourceRank));
+
+    // BZ_NEEDS_WORK: Handling the storage ordering is currently O(N^2)
+    // but it can be done fairly easily in linear time by constructing
+    // the appropriate permutation.
+
+    // Find sourceRank in array.storage_.ordering_
+    int i=0;
+    for (; i < N_rank; ++i)
+        if (array.storage_.ordering(i) == sourceRank)
+            break;
+
+    storage_.setOrdering(i, destRank);
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::reverseSelf(int rank)
+{
+    BZPRECONDITION(rank < N_rank);
+
+    storage_.setAscendingFlag(rank, !isRankStoredAscending(rank));
+
+    int adjustment = stride_[rank] * (length_[rank] - 1);
+    zeroOffset_ += adjustment;
+    data_ += adjustment;
+    stride_[rank] *= -1;
+}
+
+template<class T_numtype, int N_rank>
+Array<T_numtype, N_rank> Array<T_numtype,N_rank>::reverse(int rank)
+{
+    T_array B(*this);
+    B.reverseSelf(rank);
+    return B;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+Array<T_numtype2,N_rank> Array<T_numtype,N_rank>::extractComponent(T_numtype2, 
+    int componentNumber, int numComponents)
+{
+    BZPRECONDITION((componentNumber >= 0) && (componentNumber < numComponents));
+
+    TinyVector<int,N_rank> stride2;
+    stride2 = stride_ * numComponents;
+    T_numtype2* dataFirst2 = ((T_numtype2*)dataFirst()) + componentNumber;
+    return Array<T_numtype2,N_rank>(dataFirst2, length_, stride2, storage_);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAY_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/misc.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/misc.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/misc.cc	(revision 1307)
@@ -0,0 +1,82 @@
+#ifndef BZ_ARRAYMISC_CC
+#define BZ_ARRAYMISC_CC
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/misc.cc> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+#define BZ_ARRAY_DECLARE_UOP(fn, fnobj)                                \
+template<class T_numtype, int N_rank>                                  \
+inline                                                                 \
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype,N_rank>,    \
+    fnobj<T_numtype> > >                                               \
+fn(const Array<T_numtype,N_rank>& array)                               \
+{                                                                      \
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype,N_rank>,       \
+        fnobj<T_numtype> >(array.begin());                             \
+}                                                                      \
+                                                                       \
+template<class T_expr>                                                 \
+inline                                                                 \
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<T_expr>,              \
+    fnobj<_bz_typename T_expr::T_numtype> > >                          \
+fn(_bz_ArrayExpr<T_expr> expr)                                         \
+{                                                                      \
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<T_expr>,                 \
+        fnobj<_bz_typename T_expr::T_numtype> >(expr);                 \
+}                                                                      \
+                                                                       \
+template<int N_index>                                                  \
+inline                                                                 \
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index>,          \
+    fnobj<int> > >                                                     \
+fn(IndexPlaceholder<N_index> index)                                    \
+{                                                                      \
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index>,             \
+        fnobj<int> >(index);                                           \
+}
+
+BZ_ARRAY_DECLARE_UOP(operator!, LogicalNot)
+BZ_ARRAY_DECLARE_UOP(operator~, BitwiseNot)
+BZ_ARRAY_DECLARE_UOP(operator-, Negate)
+
+/*
+ * cast() functions, for explicit type casting
+ */
+
+template<class T_numtype, int N_rank, class T_cast>
+inline                                                                 
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype,N_rank>,   
+    Cast<T_numtype, T_cast> > >
+cast(const Array<T_numtype,N_rank>& array, T_cast)
+{                                                                      
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype,N_rank>,      
+        Cast<T_numtype,T_cast> >(array.begin());                            
+}                                                                      
+                                                                       
+template<class T_expr, class T_cast>
+inline                                                                 
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<T_expr>,              
+    Cast<_bz_typename T_expr::T_numtype,T_cast> > >                          
+cast(_bz_ArrayExpr<T_expr> expr, T_cast)
+{                                                                      
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<T_expr>,                 
+        Cast<_bz_typename T_expr::T_numtype,T_cast> >(expr);                 
+}                                                                      
+                                                                       
+template<int N_index, class T_cast>
+inline                                                                 
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index>,          
+    Cast<int,T_cast> > >                                                     
+cast(IndexPlaceholder<N_index> index, T_cast)
+{                                                                      
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index>,             
+        Cast<int,T_cast> >(index);                                           
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYMISC_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/multi.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/multi.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/multi.h	(revision 1307)
@@ -0,0 +1,56 @@
+// Support for multicomponent arrays
+
+#ifndef BZ_ARRAYMULTI_H
+#define BZ_ARRAYMULTI_H
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/multi.h> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * The multicomponent_traits class provides a mapping from multicomponent
+ * tuples to the element type they contain.  For example:
+ *
+ * multicomponent_traits<complex<float> >::T_numtype is float,
+ * multicomponent_traits<TinyVector<int,3> >::T_numtype is int.
+ *
+ * This is used to support Array<T,N>::operator[], which extracts components
+ * from a multicomponent array.
+ */
+
+// By default, produce a harmless component type, and zero components.
+template<class T_component>
+struct multicomponent_traits {
+    typedef T_component T_element;
+    enum { numComponents = 0 };
+};
+
+// TinyVector
+template<class T_numtype, int N_rank>
+struct multicomponent_traits<TinyVector<T_numtype,N_rank> > {
+    typedef T_numtype T_element;
+    enum { numComponents = N_rank };
+};
+
+// complex<T>
+template<class T>
+struct multicomponent_traits<complex<T> > {
+    typedef T T_element;
+    enum { numComponents = 2 };
+};
+
+// This macro is provided so that users can register their own
+// multicomponent types.
+
+#define BZ_DECLARE_MULTICOMPONENT_TYPE(T_tuple,T,N)          \
+  template<>                                                 \
+  struct multicomponent_traits<T_tuple > {                   \
+    typedef T T_element;                                     \
+    enum { numComponents = N };                              \
+  };
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYMULTI_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/ops.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/ops.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/ops.cc	(revision 1307)
@@ -0,0 +1,309 @@
+#ifndef BZ_ARRAYOPS_CC
+#define BZ_ARRAYOPS_CC
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/ops.cc> must be included via <blitz/array.h>
+#endif
+
+#ifndef BZ_UPDATE_H
+ #include <blitz/update.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * Constant operands
+ */
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>& Array<T_numtype,N_rank>::initialize(
+    T_numtype x)
+{
+    (*this) = _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>& 
+Array<T_numtype,N_rank>::operator+=(T_numtype x)
+{
+    (*this) += _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype,N_rank>::operator-=(T_numtype x)
+{
+    (*this) -= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype,N_rank>::operator*=(T_numtype x)
+{
+    (*this) *= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype,N_rank>::operator/=(T_numtype x)
+{
+    (*this) /= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype,N_rank>::operator%=(T_numtype x)
+{
+    (*this) %= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype,N_rank>::operator^=(T_numtype x)
+{
+    (*this) ^= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype,N_rank>::operator&=(T_numtype x)
+{
+    (*this) &= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype,N_rank>::operator|=(T_numtype x)
+{
+    (*this) |= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype,N_rank>::operator>>=(T_numtype x)
+{
+    (*this) <<= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype,N_rank>::operator<<=(T_numtype x)
+{
+    (*this) <<= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
+    return *this;
+}
+
+/*
+ * Array operands
+ */
+
+template<class T_numtype, int N_rank>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator=(const Array<T_numtype,N_rank>& x)
+{
+    (*this) = _bz_ArrayExpr<ArrayIterator<T_numtype, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) = _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator+=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) += _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator-=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) -= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator*=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) *= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator/=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) /= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator%=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) %= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator^=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) ^= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator&=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) &= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator|=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) |= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator>>=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) >>= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_numtype2>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator<<=(const Array<T_numtype2,N_rank>& x)
+{
+    (*this) <<= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
+    return *this;
+}
+
+/*
+ * Array expression operands
+ */
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_update<T_numtype, _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator+=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_plus_update<T_numtype, _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator-=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_minus_update<T_numtype, 
+        _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator*=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_multiply_update<T_numtype,
+        _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator/=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_divide_update<T_numtype,
+        _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator%=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_mod_update<T_numtype,
+        _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator^=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_xor_update<T_numtype,
+        _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator&=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_bitand_update<T_numtype,
+        _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator|=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_bitor_update<T_numtype,
+        _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator>>=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_shiftr_update<T_numtype,
+        _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+template<class T_numtype, int N_rank> template<class T_expr>
+inline Array<T_numtype, N_rank>&
+Array<T_numtype, N_rank>::operator<<=(_bz_ArrayExpr<T_expr> expr)
+{
+    evaluate(expr, _bz_shiftl_update<T_numtype,
+        _bz_typename T_expr::T_numtype>());
+    return *this;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYOPS_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/reduce.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/reduce.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/reduce.cc	(revision 1307)
@@ -0,0 +1,122 @@
+#ifndef BZ_ARRAYREDUCE_H
+ #error <blitz/array/reduce.cc> must be included via <blitz/array/reduce.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class T_expr, class T_reduction>
+_bz_typename T_reduction::T_resulttype
+_bz_reduceWithIndexTraversal(T_expr expr, T_reduction reduction);
+
+template<class T_expr, class T_reduction>
+_bz_typename T_reduction::T_resulttype
+_bz_reduceWithStackTraversal(T_expr expr, T_reduction reduction);
+
+template<class T_expr, class T_reduction>
+_bz_typename T_reduction::T_resulttype
+_bz_ArrayExprFullReduce(T_expr expr, T_reduction reduction)
+{
+#ifdef BZ_TAU_PROFILING
+    // Tau profiling code.  Provide Tau with a pretty-printed version of
+    // the expression.
+    static string exprDescription;
+    if (!exprDescription.length())      // faked static initializer
+    {
+        exprDescription = T_reduction::name();
+        exprDescription += "(";
+        prettyPrintFormat format(_bz_true);   // Terse mode on
+        expr.prettyPrint(exprDescription, format);
+        exprDescription += ")";
+    }
+    TAU_PROFILE(" ", exprDescription, TAU_BLITZ);
+#endif // BZ_TAU_PROFILING
+
+    return _bz_reduceWithIndexTraversal(expr, reduction);
+
+#ifdef NOT_IMPLEMENTED
+    if ((T_expr::numIndexPlaceholders > 0) || (T_reduction::needIndex))
+    {
+        // The expression involves index placeholders, so have to
+        // use index traversal rather than stack traversal.
+        return reduceWithIndexTraversal(expr, reduction);
+    }
+    else {
+        // Use a stack traversal
+        return reduceWithStackTraversal(expr, reduction);
+    }
+#endif
+}
+
+template<class T_expr, class T_reduction>
+_bz_typename T_reduction::T_resulttype
+_bz_reduceWithIndexTraversal(T_expr expr, T_reduction reduction)
+{
+    // This is optimized assuming C-style arrays.
+
+    reduction.reset();
+
+    const int rank = T_expr::rank;
+
+    TinyVector<int,rank> index, first, last;
+
+    unsigned long count = 1;
+
+    for (int i=0; i < rank; ++i)
+    {
+        index(i) = expr.lbound(i);
+        first(i) = index(i);
+        last(i) = expr.ubound(i) + 1;
+        count *= last(i) - first(i);
+    }
+
+    const int maxRank = rank - 1;
+    int lastlbound = expr.lbound(maxRank);
+    int lastubound = expr.ubound(maxRank);
+
+    int lastIndex = lastubound + 1;
+
+    _bz_bool loopFlag = _bz_true;
+
+    while(loopFlag) {
+        for (index[maxRank] = lastlbound; index[maxRank] < lastIndex;
+            ++index[maxRank])
+        {
+            if (!reduction(expr(index), index[maxRank]))
+            {
+                loopFlag = _bz_false;
+                break;
+            }
+        }
+
+#if 0
+        int j = 1;
+        for (; j < rank; ++j)
+        {
+            index(j-1) = first(j-1);
+            ++index(j);
+            if (index(j) != last(j))
+                break;
+        }
+
+        if (j == rank)
+            break;
+#endif
+
+        int j = rank-2;
+        for (; j >= 0; --j)
+        {
+            index(j+1) = first(j+1);
+            ++index(j);
+            if (index(j) != last(j))
+                break;
+        }
+
+        if (j < 0)
+            break;
+    }
+
+    return reduction.result(count);
+}
+
+BZ_NAMESPACE_END
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/reduce.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/reduce.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/reduce.h	(revision 1307)
@@ -0,0 +1,303 @@
+/***************************************************************************
+ * blitz/array/reduce.h   Reductions of an array (or array expression) in a 
+ *                        single rank: sum, mean, min, minIndex, max, maxIndex, 
+ *                        product, count, any, all
+ *
+ * $Id: reduce.h,v 1.1.1.1 1999-04-09 17:59:04 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_ARRAYREDUCE_H
+#define BZ_ARRAYREDUCE_H
+
+#ifndef BZ_ARRAYEXPR_H
+ #error <blitz/array/reduce.h> must be included after <blitz/array/expr.h>
+#endif
+
+#ifndef BZ_REDUCE_H
+ #include <blitz/reduce.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class T_expr, int N_index, class T_reduction>
+class _bz_ArrayExprReduce {
+
+public:   
+    typedef _bz_typename T_reduction::T_numtype T_numtype;
+    typedef T_expr      T_ctorArg1;
+    typedef T_reduction T_ctorArg2;
+
+    enum { numArrayOperands = BZ_ENUM_CAST(T_expr::numArrayOperands),
+        numIndexPlaceholders = BZ_ENUM_CAST(T_expr::numIndexPlaceholders) + 1,
+        rank = BZ_ENUM_CAST(T_expr::rank) - 1 };
+
+    _bz_ArrayExprReduce(const _bz_ArrayExprReduce<T_expr,N_index,T_reduction>&
+        reduce)
+        : reduce_(reduce.reduce_), iter_(reduce.iter_)
+    {
+    }
+
+    _bz_ArrayExprReduce(T_expr expr)
+        : iter_(expr)
+    { }
+
+    _bz_ArrayExprReduce(T_expr expr, T_reduction reduce)
+        : iter_(expr), reduce_(reduce)
+    { }
+
+    int lbound(int rank)
+    { return iter_.lbound(rank); }
+
+    int ubound(int rank)
+    { return iter_.ubound(rank); }
+
+    template<int N_destRank>
+    T_numtype operator()(const TinyVector<int, N_destRank>& destIndex)
+    {
+        BZPRECHECK(N_destRank == N_index,  
+            "Array reduction performed over rank " << N_index 
+            << " to produce a rank " << N_destRank << " expression." << endl
+            << "You must reduce over rank " << N_destRank << " instead.");
+
+        TinyVector<int, N_destRank + 1> index;
+
+        // This metaprogram copies elements 0..N-1 of destIndex into index
+        _bz_meta_vecAssign<N_index, 0>::assign(index, destIndex, 
+            _bz_update<int,int>());
+
+        int lbound = iter_.lbound(N_index);
+        int ubound = iter_.ubound(N_index);
+
+        // NEEDS_WORK: replace with tiny(int()) and huge(int()) once
+        // <limits> widely available
+        BZPRECHECK((lbound != INT_MIN) && (ubound != INT_MAX),
+           "Array reduction performed over rank " << N_index
+           << " is unbounded." << endl 
+           << "There must be an array object in the expression being reduced"
+           << endl << "which provides a bound in rank " << N_index << ".");
+
+        reduce_.reset();
+
+        for (index[N_index] = iter_.lbound(N_index);
+            index[N_index] <= ubound; ++index[N_index])
+        {
+            if (!reduce_(iter_(index), index[N_index]))
+                break;
+        }
+
+        return reduce_.result(ubound-lbound+1);
+    }
+
+    // If you have a precondition failure on this routine, it means
+    // you are trying to use stack iteration mode on an expression
+    // which contains an index placeholder.  You must use index
+    // iteration mode instead.
+    int operator*()
+    {
+        BZPRECONDITION(0);
+        return 0;
+    }
+
+    // See operator*() note
+    void push(int)
+    {
+        BZPRECONDITION(0);
+    }
+
+    // See operator*() note
+    void pop(int)
+    {
+        BZPRECONDITION(0);
+    }
+
+    // See operator*() note
+    void advance()
+    {
+        BZPRECONDITION(0);
+    }
+
+    // See operator*() note
+    void advance(int)
+    {
+        BZPRECONDITION(0);
+    }
+
+    // See operator*() note
+    void loadStride(int)
+    {
+        BZPRECONDITION(0);
+    }
+
+    _bz_bool isUnitStride(int rank) const
+    {
+        BZPRECONDITION(0);
+        return false;
+    }
+
+    void advanceUnitStride()
+    {
+        BZPRECONDITION(0);
+    }
+
+    _bz_bool canCollapse(int,int) const
+    {   BZPRECONDITION(0); return _bz_false; }
+
+    T_numtype operator[](int)
+    {
+        BZPRECONDITION(0);
+        return T_numtype();
+    }
+
+    T_numtype fastRead(int)
+    {
+        BZPRECONDITION(0);
+        return T_numtype();
+    }
+
+    int suggestStride(int) const
+    {
+        BZPRECONDITION(0);
+        return 0;
+    }
+
+    _bz_bool isStride(int,int) const
+    {
+        BZPRECONDITION(0);
+        return _bz_true;
+    }
+
+    template<int N_rank>
+    void moveTo(const TinyVector<int,N_rank>& i)
+    {
+        BZPRECONDITION(0);
+        return;
+    }
+
+    void prettyPrint(std::string& str, prettyPrintFormat& format) const
+    {
+        // NEEDS_WORK-- do real formatting for reductions
+        str += "reduce[NEEDS_WORK](";
+        iter_.prettyPrint(str,format);
+        str += ")";
+    }
+
+    template<class T_shape>
+    _bz_bool shapeCheck(const T_shape& shape) const
+    { 
+        // NEEDS_WORK-- do a real shape check (tricky)
+        return _bz_true; 
+    }
+
+private: 
+    _bz_ArrayExprReduce() { }
+
+    T_reduction reduce_;
+    T_expr iter_;
+};
+
+#define BZ_DECL_ARRAY_PARTIAL_REDUCE(fn,reduction)                      \
+template<class T_expr, int N_index>                                     \
+inline                                                                  \
+_bz_ArrayExpr<_bz_ArrayExprReduce<_bz_ArrayExpr<T_expr>, N_index,       \
+    reduction<_bz_typename T_expr::T_numtype> > >                       \
+fn(_bz_ArrayExpr<T_expr> expr, const IndexPlaceholder<N_index>&)        \
+{                                                                       \
+    return _bz_ArrayExprReduce<_bz_ArrayExpr<T_expr>, N_index,          \
+        reduction<_bz_typename T_expr::T_numtype> >(expr);              \
+}                                                                       \
+                                                                        \
+template<class T_numtype, int N_rank, int N_index>                      \
+inline                                                                  \
+_bz_ArrayExpr<_bz_ArrayExprReduce<ArrayIterator<T_numtype,N_rank>,      \
+    N_index, reduction<T_numtype> > >                                   \
+fn(const Array<T_numtype, N_rank>& array,                               \
+    const IndexPlaceholder<N_index>&)                                   \
+{                                                                       \
+    return _bz_ArrayExprReduce<ArrayIterator<T_numtype,N_rank>,         \
+        N_index, reduction<T_numtype> > (array.begin());                \
+}                        
+
+BZ_DECL_ARRAY_PARTIAL_REDUCE(sum,      ReduceSum)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(mean,     ReduceMean)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(min,      ReduceMin)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(minIndex, ReduceMinIndex)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(max,      ReduceMax)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(maxIndex, ReduceMaxIndex)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(product,  ReduceProduct)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(count,    ReduceCount)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(any,      ReduceAny)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(all,      ReduceAll)
+BZ_DECL_ARRAY_PARTIAL_REDUCE(first,    ReduceFirst)
+
+/*
+ * Complete reductions
+ */
+
+// Prototype of reduction function
+template<class T_expr, class T_reduction>
+_bz_typename T_reduction::T_resulttype
+_bz_ArrayExprFullReduce(T_expr expr, T_reduction reduction);
+
+#define BZ_DECL_ARRAY_FULL_REDUCE(fn,reduction)                         \
+template<class T_expr>                                                  \
+inline                                                                  \
+_bz_typename reduction<_bz_typename T_expr::T_numtype>::T_resulttype    \
+fn(_bz_ArrayExpr<T_expr> expr)                                          \
+{                                                                       \
+    return _bz_ArrayExprFullReduce(expr,                                \
+        reduction<_bz_typename T_expr::T_numtype>());                   \
+}                                                                       \
+                                                                        \
+template<class T_numtype, int N_rank>                                   \
+inline                                                                  \
+_bz_typename reduction<T_numtype>::T_resulttype                         \
+fn(const Array<T_numtype, N_rank>& array)                               \
+{                                                                       \
+    return _bz_ArrayExprFullReduce(array.begin(),                       \
+        reduction<T_numtype>());                                        \
+}                                                                     
+
+BZ_DECL_ARRAY_FULL_REDUCE(sum,      ReduceSum)
+BZ_DECL_ARRAY_FULL_REDUCE(mean,     ReduceMean)
+BZ_DECL_ARRAY_FULL_REDUCE(min,      ReduceMin)
+BZ_DECL_ARRAY_FULL_REDUCE(minIndex, ReduceMinIndex)
+BZ_DECL_ARRAY_FULL_REDUCE(max,      ReduceMax)
+BZ_DECL_ARRAY_FULL_REDUCE(maxIndex, ReduceMaxIndex)
+BZ_DECL_ARRAY_FULL_REDUCE(product,  ReduceProduct)
+BZ_DECL_ARRAY_FULL_REDUCE(count,    ReduceCount)
+BZ_DECL_ARRAY_FULL_REDUCE(any,      ReduceAny)
+BZ_DECL_ARRAY_FULL_REDUCE(all,      ReduceAll)
+BZ_DECL_ARRAY_FULL_REDUCE(first,    ReduceFirst)
+
+BZ_NAMESPACE_END
+
+#include <blitz/array/reduce.cc>
+
+#endif // BZ_ARRAYREDUCE_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/resize.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/resize.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/resize.cc	(revision 1307)
@@ -0,0 +1,425 @@
+#ifndef BZ_ARRAYRESIZE_CC
+#define BZ_ARRAYRESIZE_CC
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/resize.cc> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int length0)
+{
+    BZPRECONDITION(length0 > 0);
+    BZPRECONDITION(N_rank == 1);
+
+    if (length0 != length_[firstRank])
+    {
+        length_[firstRank] = length0;
+        setupStorage(0);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0));
+    BZPRECONDITION(N_rank == 2);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        setupStorage(1);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1,
+    int extent2)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0) && (extent2 > 0));
+    BZPRECONDITION(N_rank == 3);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1])
+        || (extent2 != length_[2]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        length_[2] = extent2;
+        setupStorage(1);
+    }
+}
+
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1,
+    int extent2, int extent3)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0) && (extent2 > 0)
+        && (extent3 > 0));
+    BZPRECONDITION(N_rank == 4);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1])
+        || (extent2 != length_[2]) || (extent3 != length_[3]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        length_[2] = extent2;
+        length_[3] = extent3;
+        setupStorage(1);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1,
+    int extent2, int extent3, int extent4)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0) && (extent2 > 0)
+        && (extent3 > 0) && (extent4 > 0));
+    BZPRECONDITION(N_rank == 5);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1])
+        || (extent2 != length_[2]) || (extent3 != length_[3])
+        || (extent4 != length_[4]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        length_[2] = extent2;
+        length_[3] = extent3;
+        length_[4] = extent4;
+        setupStorage(1);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1,
+    int extent2, int extent3, int extent4, int extent5)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0) && (extent2 > 0)
+        && (extent3 > 0) && (extent4 > 0) && (extent5 > 0));
+    BZPRECONDITION(N_rank == 6);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1])
+        || (extent2 != length_[2]) || (extent3 != length_[3])
+        || (extent4 != length_[4]) || (extent5 != length_[5]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        length_[2] = extent2;
+        length_[3] = extent3;
+        length_[4] = extent4;
+        length_[5] = extent5;
+        setupStorage(1);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1,
+    int extent2, int extent3, int extent4, int extent5,
+    int extent6)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0) && (extent2 > 0)
+        && (extent3 > 0) && (extent4 > 0) && (extent5 > 0)
+        && (extent6 > 0));
+    BZPRECONDITION(N_rank == 7);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1])
+        || (extent2 != length_[2]) || (extent3 != length_[3])
+        || (extent4 != length_[4]) || (extent5 != length_[5])
+        || (extent6 != length_[6]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        length_[2] = extent2;
+        length_[3] = extent3;
+        length_[4] = extent4;
+        length_[5] = extent5;
+        length_[6] = extent6;
+        setupStorage(1);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1,
+    int extent2, int extent3, int extent4, int extent5,
+    int extent6, int extent7)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0) && (extent2 > 0)
+        && (extent3 > 0) && (extent4 > 0) && (extent5 > 0)
+        && (extent6 > 0) && (extent7 > 0));
+    BZPRECONDITION(N_rank == 8);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1])
+        || (extent2 != length_[2]) || (extent3 != length_[3])
+        || (extent4 != length_[4]) || (extent5 != length_[5])
+        || (extent6 != length_[6]) || (extent7 != length_[7]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        length_[2] = extent2;
+        length_[3] = extent3;
+        length_[4] = extent4;
+        length_[5] = extent5;
+        length_[6] = extent6;
+        length_[7] = extent7;
+        setupStorage(1);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1,
+    int extent2, int extent3, int extent4, int extent5,
+    int extent6, int extent7, int extent8)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0) && (extent2 > 0)
+        && (extent3 > 0) && (extent4 > 0) && (extent5 > 0)
+        && (extent6 > 0) && (extent7 > 0) && (extent8 > 0));
+    BZPRECONDITION(N_rank == 9);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1])
+        || (extent2 != length_[2]) || (extent3 != length_[3])
+        || (extent4 != length_[4]) || (extent5 != length_[5])
+        || (extent6 != length_[6]) || (extent7 != length_[7])
+        || (extent8 != length_[8]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        length_[2] = extent2;
+        length_[3] = extent3;
+        length_[4] = extent4;
+        length_[5] = extent5;
+        length_[6] = extent6;
+        length_[7] = extent7;
+        length_[8] = extent8;
+        setupStorage(1);
+    }
+}
+
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1,
+    int extent2, int extent3, int extent4, int extent5,
+    int extent6, int extent7, int extent8, int extent9)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0) && (extent2 > 0)
+        && (extent3 > 0) && (extent4 > 0) && (extent5 > 0)
+        && (extent6 > 0) && (extent7 > 0) && (extent8 > 0)
+        && (extent9 > 0));
+    BZPRECONDITION(N_rank == 10);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1])
+        || (extent2 != length_[2]) || (extent3 != length_[3])
+        || (extent4 != length_[4]) || (extent5 != length_[5])
+        || (extent6 != length_[6]) || (extent7 != length_[7])
+        || (extent8 != length_[8]) || (extent9 != length_[9]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        length_[2] = extent2;
+        length_[3] = extent3;
+        length_[4] = extent4;
+        length_[5] = extent5;
+        length_[6] = extent6;
+        length_[7] = extent7;
+        length_[8] = extent8;
+        length_[9] = extent9;
+        setupStorage(1);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(int extent0, int extent1,
+    int extent2, int extent3, int extent4, int extent5,
+    int extent6, int extent7, int extent8, int extent9,
+    int extent10)
+{
+    BZPRECONDITION((extent0 > 0) && (extent1 > 0) && (extent2 > 0)
+        && (extent3 > 0) && (extent4 > 0) && (extent5 > 0)
+        && (extent6 > 0) && (extent7 > 0) && (extent8 > 0)
+        && (extent9 > 0) && (extent10 > 0));
+    BZPRECONDITION(N_rank == 11);
+
+    if ((extent0 != length_[0]) || (extent1 != length_[1])
+        || (extent2 != length_[2]) || (extent3 != length_[3])
+        || (extent4 != length_[4]) || (extent5 != length_[5])
+        || (extent6 != length_[6]) || (extent7 != length_[7])
+        || (extent8 != length_[8]) || (extent9 != length_[9])
+        || (extent10 != length_[10]))
+    {
+        length_[0] = extent0;
+        length_[1] = extent1;
+        length_[2] = extent2;
+        length_[3] = extent3;
+        length_[4] = extent4;
+        length_[5] = extent5;
+        length_[6] = extent6;
+        length_[7] = extent7;
+        length_[8] = extent8;
+        length_[9] = extent9;
+        length_[10] = extent10;
+        setupStorage(1);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resizeAndPreserve(int length0)
+{
+    BZPRECONDITION(length0 > 0);
+    BZPRECONDITION(N_rank == 1);
+
+    if (length0 != length_[firstRank])
+    {
+#if defined(__KCC) || defined(__DECCXX)
+        // NEEDS_WORK: have to discard the base() parameter for EDG,
+        // because it gives the following bizarre error:
+
+/*
+ * "blitz/tinyvec.h", line 421: error: the size of an array must be greater
+ *         than zero
+ *     T_numtype data_[N_length];
+ *                     ^
+ *         detected during:
+ *           instantiation of class "blitz::TinyVector<int, 0>" at line 273 of
+ *                     "./../blitz/array/resize.cc"
+ *           instantiation of
+ *                     "void blitz::Array<int, 1>::resizeAndPreserve(int)" 
+ */
+        T_array B(length0, storage_);
+#else
+        T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0), storage_);  // line 273
+#endif
+        Range overlap0 = Range(fromStart, min(B.ubound(0), ubound(0)));
+        B(overlap0) = (*this)(overlap0);
+        reference(B);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1)
+{
+    BZPRECONDITION((length0 > 0) && (length1 > 0));
+    BZPRECONDITION(N_rank == 2);
+
+    if ((length0 != length_[0]) || (length1 != length_[1]))
+    {
+        T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1), storage_);
+        Range overlap0 = Range(fromStart, min(B.ubound(0), ubound(0)));
+        Range overlap1 = Range(fromStart, min(B.ubound(1), ubound(1)));
+        B(overlap0, overlap1) = (*this)(overlap0, overlap1);
+        reference(B);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1,
+    int length2)
+{
+    BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0));
+    BZPRECONDITION(N_rank == 3);
+
+    if ((length0 != length_[0]) || (length1 != length_[1])
+        || (length2 != length_[2]))
+    {
+        T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2), storage_);
+        Range overlap0 = Range(fromStart, min(B.ubound(0), ubound(0)));
+        Range overlap1 = Range(fromStart, min(B.ubound(1), ubound(1)));
+        Range overlap2 = Range(fromStart, min(B.ubound(2), ubound(2)));
+        B(overlap0, overlap1, overlap2) = (*this)(overlap0, overlap1, overlap2);
+        reference(B);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1,
+    int length2, int length3)
+{
+    BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0)
+        && (length3 > 0));
+    BZPRECONDITION(N_rank == 4);
+
+    if ((length0 != length_[0]) || (length1 != length_[1])
+        || (length2 != length_[2]) || (length3 != length_[3]))
+    {
+        T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2, length3),
+            storage_);
+        Range overlap0 = Range(fromStart, min(B.ubound(0), ubound(0)));
+        Range overlap1 = Range(fromStart, min(B.ubound(1), ubound(1)));
+        Range overlap2 = Range(fromStart, min(B.ubound(2), ubound(2)));
+        Range overlap3 = Range(fromStart, min(B.ubound(3), ubound(3)));
+        B(overlap0, overlap1, overlap2, overlap3) = (*this)(overlap0,
+            overlap1, overlap2, overlap3);
+        reference(B);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1,
+    int length2, int length3, int length4)
+{
+    BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0)
+        && (length3 > 0) && (length4 > 0));
+    BZPRECONDITION(N_rank == 5);
+
+    if ((length0 != length_[0]) || (length1 != length_[1])
+        || (length2 != length_[2]) || (length3 != length_[3])
+        || (length4 != length_[4]))
+    {
+        T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2, length3, length4),
+            storage_);
+        Range overlap0 = Range(fromStart, min(B.ubound(0), ubound(0)));
+        Range overlap1 = Range(fromStart, min(B.ubound(1), ubound(1)));
+        Range overlap2 = Range(fromStart, min(B.ubound(2), ubound(2)));
+        Range overlap3 = Range(fromStart, min(B.ubound(3), ubound(3)));
+        Range overlap4 = Range(fromStart, min(B.ubound(4), ubound(4)));
+        B(overlap0, overlap1, overlap2, overlap3, overlap4) = (*this)(overlap0,
+            overlap1, overlap2, overlap3, overlap4);
+        reference(B);
+    }
+}
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1,
+    int length2, int length3, int length4, int length5)
+{
+    BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0)
+        && (length3 > 0) && (length4 > 0) && (length5 > 0));
+    BZPRECONDITION(N_rank == 6);
+
+    if ((length0 != length_[0]) || (length1 != length_[1])
+        || (length2 != length_[2]) || (length3 != length_[3])
+        || (length4 != length_[4]) || (length5 != length_[5]))
+    {
+        T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2, length3,
+            length4, length5), storage_);
+        Range overlap0 = Range(fromStart, min(B.ubound(0), ubound(0)));
+        Range overlap1 = Range(fromStart, min(B.ubound(1), ubound(1)));
+        Range overlap2 = Range(fromStart, min(B.ubound(2), ubound(2)));
+        Range overlap3 = Range(fromStart, min(B.ubound(3), ubound(3)));
+        Range overlap4 = Range(fromStart, min(B.ubound(4), ubound(4)));
+        Range overlap5 = Range(fromStart, min(B.ubound(5), ubound(5)));
+        B(overlap0, overlap1, overlap2, overlap3, overlap4, overlap5)
+            = (*this)(overlap0, overlap1, overlap2, overlap3, overlap4,
+            overlap5);
+        reference(B);
+    }
+}
+
+
+// NEEDS_WORK: resizeAndPreserve for N_rank = 7..11
+
+template<class T_numtype, int N_rank>
+void Array<T_numtype, N_rank>::resize(const TinyVector<int,N_rank>& extent)
+{
+// NEEDS_WORK
+//    BZPRECONDITION(all(extent > 0));
+//    if (any(extent != length_))
+//    {
+        length_ = extent;
+        setupStorage(1);
+//    }
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYRESIZE_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/shape.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/shape.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/shape.h	(revision 1307)
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * blitz/array/shape.h        
+ *
+ * $Id: shape.h,v 1.1.1.1 1999-04-09 17:59:04 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.1  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ */
+
+#ifndef BZ_ARRAYSHAPE_H
+#define BZ_ARRAYSHAPE_H
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/shape.h> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * These routines make it easier to create shape parameters on
+ * the fly: instead of having to write
+ *
+ * A.resize(TinyVector<int,4>(8,8,8,12));
+ *
+ * you can just say
+ *
+ * A.resize(shape(8,8,8,12));
+ *
+ */
+inline TinyVector<int,1> shape(int n1)
+{ return TinyVector<int,1>(n1); }
+
+inline TinyVector<int,2> shape(int n1, int n2)
+{ return TinyVector<int,2>(n1,n2); }
+
+inline TinyVector<int,3> shape(int n1, int n2, int n3)
+{ return TinyVector<int,3>(n1,n2,n3); }
+
+inline TinyVector<int,4> shape(int n1, int n2, int n3, int n4)
+{ return TinyVector<int,4>(n1,n2,n3,n4); }
+
+inline TinyVector<int,5> shape(int n1, int n2, int n3, int n4,
+    int n5)
+{ return TinyVector<int,5>(n1,n2,n3,n4,n5); }
+
+inline TinyVector<int,6> shape(int n1, int n2, int n3, int n4,
+    int n5, int n6)
+{ return TinyVector<int,6>(n1,n2,n3,n4,n5,n6); }
+
+inline TinyVector<int,7> shape(int n1, int n2, int n3, int n4,
+    int n5, int n6, int n7)
+{ return TinyVector<int,7>(n1,n2,n3,n4,n5,n6,n7); }
+
+inline TinyVector<int,8> shape(int n1, int n2, int n3, int n4,
+    int n5, int n6, int n7, int n8)
+{ return TinyVector<int,8>(n1,n2,n3,n4,n5,n6,n7,n8); }
+
+inline TinyVector<int,9> shape(int n1, int n2, int n3, int n4,
+    int n5, int n6, int n7, int n8, int n9)
+{ return TinyVector<int,9>(n1,n2,n3,n4,n5,n6,n7,n8,n9); }
+
+inline TinyVector<int,10> shape(int n1, int n2, int n3, int n4,
+    int n5, int n6, int n7, int n8, int n9, int n10)
+{ return TinyVector<int,10>(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10); }
+
+inline TinyVector<int,11> shape(int n1, int n2, int n3, int n4,
+    int n5, int n6, int n7, int n8, int n9, int n10, int n11)
+{ return TinyVector<int,11>(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11); }
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYSHAPE_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/slice.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/slice.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/slice.h	(revision 1307)
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * blitz/array/slice.h    Helper classes for slicing arrays
+ *
+ * $Id: slice.h,v 1.1.1.1 1999-04-09 17:59:04 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_ARRAYSLICE_H
+#define BZ_ARRAYSLICE_H
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/slice.h> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Forward declaration
+template<class T, int N>
+class Array;
+
+
+
+class nilArraySection { };
+
+template<class T>
+class ArraySectionInfo {
+public:
+    enum { isValidType = 0, rank = 0, isPick = 0 };
+};
+
+template<>
+class ArraySectionInfo<Range> {
+public:
+    enum { isValidType = 1, rank = 1, isPick = 0 };
+};
+
+template<>
+class ArraySectionInfo<int> {
+public:
+    enum { isValidType = 1, rank = 0, isPick = 0 };
+};
+
+template<>
+class ArraySectionInfo<nilArraySection> {
+public:
+    enum { isValidType = 1, rank = 0, isPick = 0 };
+};
+
+template<class T_numtype, class T1, class T2 = nilArraySection, 
+    class T3 = nilArraySection, class T4 = nilArraySection, 
+    class T5 = nilArraySection, class T6 = nilArraySection, 
+    class T7 = nilArraySection, class T8 = nilArraySection, 
+    class T9 = nilArraySection, class T10 = nilArraySection, 
+    class T11 = nilArraySection>
+class SliceInfo {
+public:
+    enum { 
+        numValidTypes = ArraySectionInfo<T1>::isValidType
+                      + ArraySectionInfo<T2>::isValidType
+                      + ArraySectionInfo<T3>::isValidType
+                      + ArraySectionInfo<T4>::isValidType
+                      + ArraySectionInfo<T5>::isValidType
+                      + ArraySectionInfo<T6>::isValidType
+                      + ArraySectionInfo<T7>::isValidType
+                      + ArraySectionInfo<T8>::isValidType
+                      + ArraySectionInfo<T9>::isValidType
+                      + ArraySectionInfo<T10>::isValidType
+                      + ArraySectionInfo<T11>::isValidType,
+
+        rank          = ArraySectionInfo<T1>::rank
+                      + ArraySectionInfo<T2>::rank
+                      + ArraySectionInfo<T3>::rank
+                      + ArraySectionInfo<T4>::rank
+                      + ArraySectionInfo<T5>::rank
+                      + ArraySectionInfo<T6>::rank
+                      + ArraySectionInfo<T7>::rank
+                      + ArraySectionInfo<T8>::rank
+                      + ArraySectionInfo<T9>::rank
+                      + ArraySectionInfo<T10>::rank
+                      + ArraySectionInfo<T11>::rank,
+
+        isPick        = ArraySectionInfo<T1>::isPick
+                      + ArraySectionInfo<T2>::isPick
+                      + ArraySectionInfo<T3>::isPick
+                      + ArraySectionInfo<T4>::isPick
+                      + ArraySectionInfo<T5>::isPick
+                      + ArraySectionInfo<T6>::isPick
+                      + ArraySectionInfo<T7>::isPick
+                      + ArraySectionInfo<T8>::isPick
+                      + ArraySectionInfo<T9>::isPick
+                      + ArraySectionInfo<T10>::isPick
+                      + ArraySectionInfo<T11>::isPick
+        };
+
+    typedef Array<T_numtype,numValidTypes> T_array;
+    typedef Array<T_numtype,rank> T_slice;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYSLICE_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/slicing.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/slicing.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/slicing.cc	(revision 1307)
@@ -0,0 +1,330 @@
+#ifndef BZ_ARRAYSLICING_CC
+#define BZ_ARRAYSLICING_CC
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/slicing.cc> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * These routines make the array a view of a portion of another array.
+ * They all work by first referencing the other array, and then slicing.
+ */
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, const RectDomain<N_rank>& subdomain)
+{
+    reference(array);
+    for (int i=0; i < N_rank; ++i)
+        slice(i, subdomain[i]);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0)
+{
+    reference(array);
+    slice(0, r0);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+    slice(2, r2);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+    slice(2, r2);
+    slice(3, r3);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3,
+    Range r4)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+    slice(2, r2);
+    slice(3, r3);
+    slice(4, r4);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3,
+    Range r4, Range r5)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+    slice(2, r2);
+    slice(3, r3);
+    slice(4, r4);
+    slice(5, r5);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3,
+    Range r4, Range r5, Range r6)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+    slice(2, r2);
+    slice(3, r3);
+    slice(4, r4);
+    slice(5, r5);
+    slice(6, r6);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3,
+    Range r4, Range r5, Range r6, Range r7)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+    slice(2, r2);
+    slice(3, r3);
+    slice(4, r4);
+    slice(5, r5);
+    slice(6, r6);
+    slice(7, r7);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3,
+    Range r4, Range r5, Range r6, Range r7, Range r8)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+    slice(2, r2);
+    slice(3, r3);
+    slice(4, r4);
+    slice(5, r5);
+    slice(6, r6);
+    slice(7, r7);
+    slice(8, r8);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3,
+    Range r4, Range r5, Range r6, Range r7, Range r8, Range r9)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+    slice(2, r2);
+    slice(3, r3);
+    slice(4, r4);
+    slice(5, r5);
+    slice(6, r6);
+    slice(7, r7);
+    slice(8, r8);
+    slice(9, r9);
+}
+
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::constructSubarray(
+    Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3,
+    Range r4, Range r5, Range r6, Range r7, Range r8, Range r9, Range r10)
+{
+    reference(array);
+    slice(0, r0);
+    slice(1, r1);
+    slice(2, r2);
+    slice(3, r3);
+    slice(4, r4);
+    slice(5, r5);
+    slice(6, r6);
+    slice(7, r7);
+    slice(8, r8);
+    slice(9, r9);
+    slice(10, r10);
+}
+
+/*
+ * This member template is used to implement operator() with any
+ * combination of int and Range parameters.  There's room for up
+ * to 11 parameters, but any unused parameters have no effect.
+ */
+template<class P_numtype, int N_rank> template<int N_rank2, class R0,
+    class R1, class R2, class R3, class R4, class R5, class R6, class R7,
+    class R8, class R9, class R10>
+void Array<P_numtype, N_rank>::constructSlice(Array<T_numtype, N_rank2>& array,
+    R0 r0, R1 r1, R2 r2, R3 r3, R4 r4, R5 r5, R6 r6, R7 r7, R8 r8, R9 r9,
+    R10 r10)
+{
+    MemoryBlockReference<P_numtype>::changeBlock(array, array.zeroOffset());
+    data_ = array.dataZero();
+
+    int setRank = 0;
+
+    TinyVector<int, N_rank2> rankMap;
+
+    slice(setRank, r0, array, rankMap, 0);
+    slice(setRank, r1, array, rankMap, 1);
+    slice(setRank, r2, array, rankMap, 2);
+    slice(setRank, r3, array, rankMap, 3);
+    slice(setRank, r4, array, rankMap, 4);
+    slice(setRank, r5, array, rankMap, 5);
+    slice(setRank, r6, array, rankMap, 6);
+    slice(setRank, r7, array, rankMap, 7);
+    slice(setRank, r8, array, rankMap, 8);
+    slice(setRank, r9, array, rankMap, 9);
+    slice(setRank, r10, array, rankMap, 10);
+
+    // Redo the ordering_ array to account for dimensions which
+    // have been sliced away.
+    int j = 0;
+    for (int i=0; i < N_rank2; ++i)
+    {
+        if (rankMap[array.ordering(i)] != -1)
+            storage_.setOrdering(j++, rankMap[array.ordering(i)]);
+    }
+
+    calculateZeroOffset();
+}
+
+/*
+ * This member template is also used in the implementation of
+ * operator() with any combination of int and Rank parameters.
+ * It's called by constructSlice(), above.  This version handles
+ * Range parameters.
+ */
+template<class T_numtype, int N_rank> template<int N_rank2>
+void Array<T_numtype, N_rank>::slice(int& setRank, Range r,
+    Array<T_numtype,N_rank2>& array, TinyVector<int,N_rank2>& rankMap,
+    int sourceRank)
+{
+    // NEEDS WORK: ordering will change completely when some ranks
+    // are deleted.
+
+#ifdef BZ_DEBUG_SLICE
+cout << "slice(" << setRank << ", [" << r.first(array.lbound(sourceRank))
+     << ", " << r.last(array.ubound(sourceRank)) << "], Array<T,"
+     << N_rank2 << ">, " << sourceRank << ")" << endl;
+#endif
+
+    rankMap[sourceRank] = setRank;
+    length_[setRank] = array.length(sourceRank);
+    stride_[setRank] = array.stride(sourceRank);
+    storage_.setAscendingFlag(setRank, array.isRankStoredAscending(sourceRank));
+    storage_.setBase(setRank, array.base(sourceRank));
+    slice(setRank, r);
+    ++setRank;
+}
+
+/*
+ * This member template is also used in the implementation of
+ * operator() with any combination of int and Rank parameters.
+ * It's called by constructSlice(), above.  This version handles
+ * int parameters, which reduce the dimensionality by one.
+ */
+template<class T_numtype, int N_rank> template<int N_rank2>
+void Array<T_numtype, N_rank>::slice(int& setRank, int i,
+    Array<T_numtype,N_rank2>& array, TinyVector<int,N_rank2>& rankMap,
+    int sourceRank)
+{
+#ifdef BZ_DEBUG_SLICE
+    cout << "slice(" << setRank << ", " << i
+         << ", Array<T," << N_rank2 << ">, " << sourceRank << ")" << endl;
+    cout << "Offset by " << (i * array.stride(sourceRank))
+         << endl;
+#endif
+    rankMap[sourceRank] = -1;
+    data_ += i * array.stride(sourceRank);
+#ifdef BZ_DEBUG_SLICE
+    cout << "data_ = " << data_ << endl;
+#endif
+}
+
+/*
+ * After calling slice(int rank, Range r), the array refers only to the
+ * Range r of the original array.
+ * e.g. Array<int,1> x(100);
+ *      x.slice(firstRank, Range(25,50));
+ *      x = 0;       // Sets elements 25..50 of the original array to 0
+ */
+template<class P_numtype, int N_rank>
+void Array<P_numtype, N_rank>::slice(int rank, Range r)
+{
+    BZPRECONDITION((rank >= 0) && (rank < N_rank));
+
+    int first = r.first(lbound(rank));
+    int last  = r.last(ubound(rank));
+    int stride = r.stride();
+
+#ifdef BZ_DEBUG_SLICE
+cout << "slice(" << rank << ", Range):" << endl
+     << "first = " << first << " last = " << last << "stride = " << stride
+     << endl << "length_[rank] = " << length_[rank] << endl;
+#endif
+
+    BZPRECHECK(
+        ((first <= last) && (stride > 0)
+         || (first >= last) && (stride < 0))
+        && (unsigned(first - base(rank)) < length_[rank])
+        && (unsigned(last - base(rank)) < length_[rank]),
+        "Bad array slice: Range(" << first << ", " << last << ", "
+        << stride << ").  Array is Range(" << lbound(rank) << ", "
+        << ubound(rank) << ")");
+
+    // Will the storage be non-contiguous?
+    // (1) Slice in the minor dimension and the range does not span
+    //     the entire index interval (NB: non-unit strides are possible)
+    // (2) Slice in a middle dimension and the range is not Range::all()
+
+    // Note: this code ignores a few weird cases that would hopefully come
+    // up rarely, e.g. slicing the array 0..99,0..99 with
+    // Range::all() and Range(1,99,2).  This preserves contiguous
+    // storage, but the contiguousStorage_ flag will still be set
+    // false.  This isn't a serious problem -- array operations will
+    // just be a tad slower in this situation.
+    if (isMinorRank(rank) &&
+      ((first != base(rank)) || (last != base(rank) + length_[rank] - 1)))
+        storageContiguous_ = _bz_false;
+
+    if ((ordering(rank) != N_rank-1) && (stride != 1))
+        storageContiguous_ = _bz_false;
+
+    length_[rank] = (last - first) / stride + 1;
+
+    int offset = (first - base(rank)) * stride_[rank];
+    data_ += offset;
+    zeroOffset_ -= offset;
+
+    stride_[rank] *= stride;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYSLICING_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/stencil.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/stencil.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/stencil.cc	(revision 1307)
@@ -0,0 +1,523 @@
+#ifndef BZ_ARRAYSTENCIL_CC
+#define BZ_ARRAYSTENCIL_CC
+
+#ifndef BZ_ARRAYSTENCIL_H
+ #error <blitz/array/stencil.cc> must be included via <blitz/array/stencil.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// NEEDS_WORK:
+// o Need to allow scalar arguments as well as arrays
+// o Unit stride optimization
+// o Tiling
+// o Pass coordinate vector to stencil, so that where-like constructs
+//   can depend on location
+// o Maybe allow expression templates to be passed as
+//   array parameters?
+
+/*
+ * There are a lot of kludges in this code to work around the fact that
+ * you can't have default template parameters with function templates.
+ * Ideally, one would implement applyStencil(..) as:
+ *
+ * template<class T_stencil, class T_numtype1, class T_array2,
+ *    class T_array3, class T_array4, class T_array5, class T_array6,
+ *    class T_array7, class T_array8, class T_array9, class T_array10,
+ *    class T_array11>
+ * void applyStencil(const T_stencil& stencil, Array<T_numtype1,3>& A,
+ *    T_array2& B = _dummyArray, T_array3& C = _dummyArray, ......)
+ *
+ * and allow for up to (say) 11 arrays to be passed.  But this doesn't
+ * appear to be legal C++.  Instead, 11 versions of applyStencil are
+ * provided, each one with a different number of array parameters,
+ * and these stubs fill in the _dummyArray parameters and invoke
+ * applyStencil_imp().
+ */
+
+template<int N_rank, class T_numtype1, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7, class T_array8, class T_array9, class T_array10,
+    class T_array11>
+inline void checkShapes(const Array<T_numtype1,N_rank>& A,
+    const T_array2& B, const T_array3& C, const T_array4& D, 
+    const T_array5& E, const T_array6& F, const T_array7& G, 
+    const T_array8& H, const T_array9& I, const T_array10& J, 
+    const T_array11& K)
+{
+    BZPRECONDITION(areShapesConformable(A.shape(),B.shape())
+        && areShapesConformable(A.shape(),C.shape())
+        && areShapesConformable(A.shape(),D.shape())
+        && areShapesConformable(A.shape(),E.shape())
+        && areShapesConformable(A.shape(),F.shape())
+        && areShapesConformable(A.shape(),G.shape())
+        && areShapesConformable(A.shape(),H.shape())
+        && areShapesConformable(A.shape(),I.shape())
+        && areShapesConformable(A.shape(),J.shape())
+        && areShapesConformable(A.shape(),K.shape()));
+}
+
+template<class T_extent, int N_rank, 
+    class T_stencil, class T_numtype1, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7, class T_array8, class T_array9, class T_array10,
+    class T_array11>
+inline void calcStencilExtent(T_extent& At, const T_stencil& stencil, 
+    const Array<T_numtype1,N_rank>& A,
+    const T_array2& B, const T_array3& C, const T_array4& D, const T_array5& E, 
+    const T_array6& F, const T_array7& G, const T_array8& H, const T_array9& I, 
+    const T_array10& J, const T_array11& K)
+{
+    // Interrogate the stencil to find out its extent
+    stencilExtent_traits<T_array2>::T_stencilExtent Bt;
+    stencilExtent_traits<T_array3>::T_stencilExtent Ct;
+    stencilExtent_traits<T_array4>::T_stencilExtent Dt;
+    stencilExtent_traits<T_array5>::T_stencilExtent Et;
+    stencilExtent_traits<T_array6>::T_stencilExtent Ft;
+    stencilExtent_traits<T_array7>::T_stencilExtent Gt;
+    stencilExtent_traits<T_array8>::T_stencilExtent Ht;
+    stencilExtent_traits<T_array9>::T_stencilExtent It;
+    stencilExtent_traits<T_array10>::T_stencilExtent Jt;
+    stencilExtent_traits<T_array11>::T_stencilExtent Kt;
+
+    stencil.apply(At, Bt, Ct, Dt, Et, Ft, Gt, Ht, It, Jt, Kt);
+    At.combine(Bt);
+    At.combine(Ct);
+    At.combine(Dt);
+    At.combine(Et);
+    At.combine(Ft);
+    At.combine(Gt);
+    At.combine(Ht);
+    At.combine(It);
+    At.combine(Jt);
+    At.combine(Kt);
+}
+
+template<int N_rank, class T_stencil, class T_numtype1, class T_array2>
+inline RectDomain<N_rank> interiorDomain(const T_stencil& stencil,
+    const Array<T_numtype1,N_rank>& A,
+    const T_array2& B)
+{
+    RectDomain<N_rank> domain = A.domain();
+
+    // Interrogate the stencil to find out its extent
+    stencilExtent<3, T_numtype1> At;
+    calcStencilExtent(At, stencil, A, B, _dummyArray, _dummyArray, 
+        _dummyArray, _dummyArray, _dummyArray, _dummyArray, _dummyArray, 
+        _dummyArray, _dummyArray);
+
+    // Shrink the domain according to the stencil size
+    TinyVector<int,N_rank> lbound, ubound;
+    lbound = domain.lbound() - At.min();
+    ubound = domain.ubound() - At.max();
+    return RectDomain<N_rank>(lbound,ubound);
+}
+
+/*
+ * This version applies a stencil to a set of 3D arrays.  Up to 11 arrays
+ * may be used.  Any unused arrays are turned into dummyArray objects.
+ * Operations on dummyArray objects are translated into no-ops.
+ */
+template<class T_stencil, class T_numtype1, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7, class T_array8, class T_array9, class T_array10,
+    class T_array11>
+void applyStencil_imp(const T_stencil& stencil, Array<T_numtype1,3>& A,
+    T_array2& B, T_array3& C, T_array4& D, T_array5& E, T_array6& F,
+    T_array7& G, T_array8& H, T_array9& I, T_array10& J, T_array11& K)
+{
+    checkShapes(A,B,C,D,E,F,G,H,I,J,K);
+  
+    // Interrogate the stencil to find out its extent
+    stencilExtent<3, T_numtype1> At;
+    calcStencilExtent(At, stencil, A, B, C, D, E, F, G, H, I, J, K);
+
+    // Now determine the subdomain over which the stencil
+    // can be applied without worrying about overrunning the
+    // boundaries of the array
+    int stencil_lbound0 = At.min(0);
+    int stencil_lbound1 = At.min(1);
+    int stencil_lbound2 = At.min(2);
+
+    int stencil_ubound0 = At.max(0);
+    int stencil_ubound1 = At.max(1);
+    int stencil_ubound2 = At.max(2);
+
+    int lbound0 = max(A.lbound(0), A.lbound(0) - stencil_lbound0);
+    int lbound1 = max(A.lbound(1), A.lbound(1) - stencil_lbound1);
+    int lbound2 = max(A.lbound(2), A.lbound(2) - stencil_lbound2);
+
+    int ubound0 = min(A.ubound(0), A.ubound(0) - stencil_ubound0);
+    int ubound1 = min(A.ubound(1), A.ubound(1) - stencil_ubound1);
+    int ubound2 = min(A.ubound(2), A.ubound(2) - stencil_ubound2);
+
+#if 0
+    cout << "Stencil bounds are:" << endl
+     << lbound0 << '\t' << ubound0 << endl
+     << lbound1 << '\t' << ubound1 << endl
+     << lbound2 << '\t' << ubound2 << endl;
+#endif
+
+    // Now do the actual loop
+    ArrayIterator<T_numtype1,3> Aiter(A);
+    _bz_typename T_array2::T_iterator Biter(B);
+    _bz_typename T_array3::T_iterator Citer(C);
+    _bz_typename T_array4::T_iterator Diter(D);
+    _bz_typename T_array5::T_iterator Eiter(E);
+    _bz_typename T_array6::T_iterator Fiter(F);
+    _bz_typename T_array7::T_iterator Giter(G);
+    _bz_typename T_array8::T_iterator Hiter(H);
+    _bz_typename T_array9::T_iterator Iiter(I);
+    _bz_typename T_array10::T_iterator Jiter(J);
+    _bz_typename T_array11::T_iterator Kiter(K);
+
+    // Load the strides for the innermost loop
+    Aiter.loadStride(2);
+    Biter.loadStride(2);
+    Citer.loadStride(2);
+    Diter.loadStride(2);
+    Eiter.loadStride(2);
+    Fiter.loadStride(2);
+    Giter.loadStride(2);
+    Hiter.loadStride(2);
+    Iiter.loadStride(2);
+    Jiter.loadStride(2);
+    Kiter.loadStride(2);
+
+    for (int i=lbound0; i <= ubound0; ++i)
+    {
+      for (int j=lbound1; j <= ubound1; ++j)
+      {
+        Aiter.moveTo(i,j,lbound2);
+        Biter.moveTo(i,j,lbound2);
+        Citer.moveTo(i,j,lbound2);
+        Diter.moveTo(i,j,lbound2);
+        Eiter.moveTo(i,j,lbound2);
+        Fiter.moveTo(i,j,lbound2);
+        Giter.moveTo(i,j,lbound2);
+        Hiter.moveTo(i,j,lbound2);
+        Iiter.moveTo(i,j,lbound2);
+        Jiter.moveTo(i,j,lbound2);
+        Kiter.moveTo(i,j,lbound2);
+
+        for (int k=lbound2; k <= ubound2; ++k)
+        {
+            stencil.apply(Aiter, Biter, Citer, Diter, Eiter, Fiter, Giter,
+                Hiter, Iiter, Jiter, Kiter);
+
+            Aiter.advance();
+            Biter.advance();
+            Citer.advance();
+            Diter.advance();
+            Eiter.advance();
+            Fiter.advance();
+            Giter.advance();
+            Hiter.advance();
+            Iiter.advance();
+            Jiter.advance();
+            Kiter.advance();
+        }
+      }
+    }
+}
+
+/*
+ * This version applies a stencil to a set of 2D arrays.  Up to 11 arrays
+ * may be used.  Any unused arrays are turned into dummyArray objects.
+ * Operations on dummyArray objects are translated into no-ops.
+ */
+template<class T_stencil, class T_numtype1, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7, class T_array8, class T_array9, class T_array10,
+    class T_array11>
+void applyStencil_imp(const T_stencil& stencil, const Array<T_numtype1,2>& A,
+    const T_array2& B, const T_array3& C, const T_array4& D, 
+    const T_array5& E, const T_array6& F, const T_array7& G, 
+    const T_array8& H, const T_array9& I, const T_array10& J, 
+    const T_array11& K)
+{
+    checkShapes(A,B,C,D,E,F,G,H,I,J,K);
+
+    // Interrogate the stencil to find out its extent
+    stencilExtent<2, T_numtype1> At;
+    calcStencilExtent(At, stencil, A, B, C, D, E, F, G, H, I, J, K);
+
+    // Now determine the subdomain over which the stencil
+    // can be applied without worrying about overrunning the
+    // boundaries of the array
+    int stencil_lbound0 = At.min(0);
+    int stencil_lbound1 = At.min(1);
+
+    int stencil_ubound0 = At.max(0);
+    int stencil_ubound1 = At.max(1);
+
+    int lbound0 = max(A.lbound(0), A.lbound(0) - stencil_lbound0);
+    int lbound1 = max(A.lbound(1), A.lbound(1) - stencil_lbound1);
+
+    int ubound0 = min(A.ubound(0), A.ubound(0) - stencil_ubound0);
+    int ubound1 = min(A.ubound(1), A.ubound(1) - stencil_ubound1);
+
+#if 0
+    cout << "Stencil bounds are:" << endl
+     << lbound0 << '\t' << ubound0 << endl
+     << lbound1 << '\t' << ubound1 << endl;
+#endif 
+
+    // Now do the actual loop
+    ArrayIterator<T_numtype1,2> Aiter(A);
+    _bz_typename T_array2::T_iterator Biter(B);
+    _bz_typename T_array3::T_iterator Citer(C);
+    _bz_typename T_array4::T_iterator Diter(D);
+    _bz_typename T_array5::T_iterator Eiter(E);
+    _bz_typename T_array6::T_iterator Fiter(F);
+    _bz_typename T_array7::T_iterator Giter(G);
+    _bz_typename T_array8::T_iterator Hiter(H);
+    _bz_typename T_array9::T_iterator Iiter(I);
+    _bz_typename T_array10::T_iterator Jiter(J);
+    _bz_typename T_array11::T_iterator Kiter(K);
+
+    // Load the strides for the innermost loop
+    Aiter.loadStride(1);
+    Biter.loadStride(1);
+    Citer.loadStride(1);
+    Diter.loadStride(1);
+    Eiter.loadStride(1);
+    Fiter.loadStride(1);
+    Giter.loadStride(1);
+    Hiter.loadStride(1);
+    Iiter.loadStride(1);
+    Jiter.loadStride(1);
+    Kiter.loadStride(1);
+
+    for (int i=lbound0; i <= ubound0; ++i)
+    {
+        Aiter.moveTo(i,lbound1);
+        Biter.moveTo(i,lbound1);
+        Citer.moveTo(i,lbound1);
+        Diter.moveTo(i,lbound1);
+        Eiter.moveTo(i,lbound1);
+        Fiter.moveTo(i,lbound1);
+        Giter.moveTo(i,lbound1);
+        Hiter.moveTo(i,lbound1);
+        Iiter.moveTo(i,lbound1);
+        Jiter.moveTo(i,lbound1);
+        Kiter.moveTo(i,lbound1);
+
+        for (int k=lbound1; k <= ubound1; ++k)
+        {
+            stencil.apply(Aiter, Biter, Citer, Diter, Eiter, Fiter, Giter,
+                Hiter, Iiter, Jiter, Kiter);
+
+            Aiter.advance();
+            Biter.advance();
+            Citer.advance();
+            Diter.advance();
+            Eiter.advance();
+            Fiter.advance();
+            Giter.advance();
+            Hiter.advance();
+            Iiter.advance();
+            Jiter.advance();
+            Kiter.advance();
+        }
+    }
+}
+
+/*
+ * This version applies a stencil to a set of 1D arrays.  Up to 11 arrays
+ * may be used.  Any unused arrays are turned into dummyArray objects.
+ * Operations on dummyArray objects are translated into no-ops.
+ */
+template<class T_stencil, class T_numtype1, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7, class T_array8, class T_array9, class T_array10,
+    class T_array11>
+void applyStencil_imp(const T_stencil& stencil, const Array<T_numtype1,1>& A,
+    const T_array2& B, const T_array3& C, const T_array4& D,
+    const T_array5& E, const T_array6& F, const T_array7& G,
+    const T_array8& H, const T_array9& I, const T_array10& J,
+    const T_array11& K)
+{
+    checkShapes(A,B,C,D,E,F,G,H,I,J,K);
+
+    // Interrogate the stencil to find out its extent
+    stencilExtent<1, T_numtype1> At;
+    calcStencilExtent(At, stencil, A, B, C, D, E, F, G, H, I, J, K);
+
+    // Now determine the subdomain over which the stencil
+    // can be applied without worrying about overrunning the
+    // boundaries of the array
+    int stencil_lbound0 = At.min(0);
+
+    int stencil_ubound0 = At.max(0);
+
+    int lbound0 = max(A.lbound(0), A.lbound(0) - stencil_lbound0);
+    int ubound0 = min(A.ubound(0), A.ubound(0) - stencil_ubound0);
+
+#if 0
+    cout << "Stencil bounds are:" << endl
+     << lbound0 << '\t' << ubound0 << endl;
+#endif
+
+    // Now do the actual loop
+    ArrayIterator<T_numtype1,1> Aiter(A);
+    _bz_typename T_array2::T_iterator Biter(B);
+    _bz_typename T_array3::T_iterator Citer(C);
+    _bz_typename T_array4::T_iterator Diter(D);
+    _bz_typename T_array5::T_iterator Eiter(E);
+    _bz_typename T_array6::T_iterator Fiter(F);
+    _bz_typename T_array7::T_iterator Giter(G);
+    _bz_typename T_array8::T_iterator Hiter(H);
+    _bz_typename T_array9::T_iterator Iiter(I);
+    _bz_typename T_array10::T_iterator Jiter(J);
+    _bz_typename T_array11::T_iterator Kiter(K);
+
+    // Load the strides for the innermost loop
+    Aiter.loadStride(0);
+    Biter.loadStride(0);
+    Citer.loadStride(0);
+    Diter.loadStride(0);
+    Eiter.loadStride(0);
+    Fiter.loadStride(0);
+    Giter.loadStride(0);
+    Hiter.loadStride(0);
+    Iiter.loadStride(0);
+    Jiter.loadStride(0);
+    Kiter.loadStride(0);
+
+    for (int i=lbound0; i <= ubound0; ++i)
+    {
+        stencil.apply(Aiter, Biter, Citer, Diter, Eiter, Fiter, Giter,
+            Hiter, Iiter, Jiter, Kiter);
+
+        Aiter.advance();
+        Biter.advance();
+        Citer.advance();
+        Diter.advance();
+        Eiter.advance();
+        Fiter.advance();
+        Giter.advance();
+        Hiter.advance();
+        Iiter.advance();
+        Jiter.advance();
+        Kiter.advance();
+    }
+}
+
+/*
+ * These 11 versions of applyStencil handle from 1 to 11 array parameters.
+ * They pad their argument list with enough dummyArray objects to call
+ * applyStencil_imp with 11 array parameters.
+ */
+template<class T_stencil, class T_numtype1, int N_rank>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A)
+{
+    applyStencil_imp(stencil, A, _dummyArray, _dummyArray,
+        _dummyArray, _dummyArray, _dummyArray, _dummyArray,
+        _dummyArray, _dummyArray, _dummyArray, _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+    T_array2& B)
+{
+    applyStencil_imp(stencil, A, B, _dummyArray, _dummyArray,
+        _dummyArray, _dummyArray, _dummyArray, _dummyArray,
+        _dummyArray, _dummyArray, _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2,
+    class T_array3>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+    T_array2& B, T_array3& C)
+{
+    applyStencil_imp(stencil, A, B, C, _dummyArray, _dummyArray,
+        _dummyArray, _dummyArray, _dummyArray, _dummyArray, _dummyArray,
+        _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2,
+    class T_array3, class T_array4>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+    T_array2& B, T_array3& C, T_array4& D)
+{
+    applyStencil_imp(stencil, A, B, C, D, _dummyArray, _dummyArray,
+        _dummyArray, _dummyArray, _dummyArray, _dummyArray, _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2,
+    class T_array3, class T_array4, class T_array5>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+   T_array2& B, T_array3& C, T_array4& D, T_array5& E)
+{
+    applyStencil_imp(stencil, A, B, C, D, E, _dummyArray,
+        _dummyArray, _dummyArray, _dummyArray, _dummyArray, _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+   T_array2& B, T_array3& C, T_array4& D, T_array5& E, T_array6& F)
+{
+    applyStencil_imp(stencil, A, B, C, D, E, F,
+        _dummyArray, _dummyArray, _dummyArray, _dummyArray, _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+   T_array2& B, T_array3& C, T_array4& D, T_array5& E, T_array6& F,
+   T_array7& G)
+{
+    applyStencil_imp(stencil, A, B, C, D, E, F, G,
+        _dummyArray, _dummyArray, _dummyArray, _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7, class T_array8>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+   T_array2& B, T_array3& C, T_array4& D, T_array5& E, T_array6& F,
+   T_array7& G, T_array8& H)
+{
+    applyStencil_imp(stencil, A, B, C, D, E, F, G, H,
+        _dummyArray, _dummyArray, _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7, class T_array8, class T_array9>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+   T_array2& B, T_array3& C, T_array4& D, T_array5& E, T_array6& F,
+   T_array7& G, T_array8& H, T_array9& I)
+{
+    applyStencil_imp(stencil, A, B, C, D, E, F, G, H, I,
+        _dummyArray, _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7, class T_array8, class T_array9, class T_array10>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+   T_array2& B, T_array3& C, T_array4& D, T_array5& E, T_array6& F,
+   T_array7& G, T_array8& H, T_array9& I, T_array10& J)
+{
+    applyStencil_imp(stencil, A, B, C, D, E, F, G, H, I, J,
+        _dummyArray);
+}
+
+template<class T_stencil, class T_numtype1, int N_rank, class T_array2,
+    class T_array3, class T_array4, class T_array5, class T_array6,
+    class T_array7, class T_array8, class T_array9, class T_array10,
+    class T_array11>
+inline void applyStencil(const T_stencil& stencil, Array<T_numtype1,N_rank>& A,
+   T_array2& B, T_array3& C, T_array4& D, T_array5& E, T_array6& F,
+   T_array7& G, T_array8& H, T_array9& I, T_array10& J, T_array11& K)
+{
+    applyStencil_imp(stencil, A, B, C, D, E, F, G, H, I, J, K);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYSTENCIL_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/stencil.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/stencil.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/stencil.h	(revision 1307)
@@ -0,0 +1,301 @@
+#ifndef BZ_ARRAYSTENCIL_H
+#define BZ_ARRAYSTENCIL_H
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/stencil.h> must be included via <blitz/array.h>
+#endif
+
+#include <blitz/array/stencilops.h>
+
+BZ_NAMESPACE(blitz)
+
+// NEEDS_WORK: currently stencilExtent returns int(1).  What if the
+// stencil contains calls to math functions, or divisions, etc.?
+// Should at least return a number of the appropriate type.  Probably
+// return a sequence of quasi-random floating point numbers.
+
+/*
+ * These macros make it easier for users to declare stencil objects.
+ * The syntax is:
+ *
+ * BZ_DECLARE_STENCILN(stencilname, Array1, Array2, ..., ArrayN)
+ *    // stencil operations go here
+ * BZ_END_STENCIL
+ */
+
+#define BZ_DECLARE_STENCIL2(name,A,B)    \
+  struct name {                          \
+    template<class T1, class T2, class T3, class T4, class T5, class T6, \
+        class T7, class T8, class T9, class T10, class T11>         \
+    static inline void apply(T1& A, T2& B, T3, T4, T5, T6, T7, T8, T9, T10, T11) \
+    {
+
+#define BZ_END_STENCIL } };
+#define BZ_STENCIL_END } };
+
+#define BZ_DECLARE_STENCIL3(name,A,B,C)         \
+  struct name {                                 \
+    template<class T1, class T2, class T3, class T4, class T5, class T6, \
+        class T7, class T8, class T9, class T10, class T11>      \
+    static inline void apply(T1& A, T2& B, T3& C, T4, T5, T6, T7, T8, T9,  \
+        T10, T11)      \
+    {
+
+#define BZ_DECLARE_STENCIL4(name,A,B,C,D)             \
+  struct name {                                       \
+    template<class T1, class T2, class T3, class T4, class T5, class T6,  \
+        class T7, class T8, class T9, class T10, class T11>  \
+    static inline void apply(T1& A, T2& B, T3& C, T4& D, T5, T6, T7, \
+        T8, T9, T10, T11)     \
+    {
+
+#define BZ_DECLARE_STENCIL5(name,A,B,C,D,E) \
+  struct name { \
+    template<class T1, class T2, class T3, class T4, class T5, class T6, \
+        class T7, class T8, class T9, class T10, class T11> \
+    static inline void apply(T1& A, T2& B, T3& C, T4& D, T5& E, T6, T7, T8, \
+        T9, T10, T11) \
+    {
+
+#define BZ_DECLARE_STENCIL6(name,A,B,C,D,E,F) \
+  struct name { \
+    template<class T1, class T2, class T3, class T4, class T5, class T6, \
+        class T7, class T8, class T9, class T10, class T11> \
+    static inline void apply(T1& A, T2& B, T3& C, T4& D, T5& E, T6& F, \
+        T7, T8, T9, T10, T11) \
+    {
+
+#define BZ_DECLARE_STENCIL7(name,A,B,C,D,E,F,G) \
+  struct name { \
+    template<class T1, class T2, class T3, class T4, \
+      class T5, class T6, class T7, class T8, class T9, class T10, class T11> \
+    static inline void apply(T1& A, T2& B, T3& C, T4& D, T5& E, T6& F, T7& G, \
+        T8, T9, T10, T11) \
+    {
+
+#define BZ_DECLARE_STENCIL8(name,A,B,C,D,E,F,G,H) \
+  struct name { \
+    template<class T1, class T2, class T3, class T4, \
+      class T5, class T6, class T7, class T8, class T9, class T10, class T11> \
+    static inline void apply(T1& A, T2& B, T3& C, T4& D, T5& E, T6& F, T7& G, \
+      T8& H, T9, T10, T11) \
+    {
+
+#define BZ_DECLARE_STENCIL9(name,A,B,C,D,E,F,G,H,I) \
+  struct name { \
+    template<class T1, class T2, class T3, class T4, \
+      class T5, class T6, class T7, class T8, class T9, class T10, \
+      class T11> \
+    static inline void apply(T1& A, T2& B, T3& C, T4& D, T5& E, T6& F, T7& G, \
+      T8& H, T9& I, T10, T11) \
+    {
+
+#define BZ_DECLARE_STENCIL10(name,A,B,C,D,E,F,G,H,I,J) \
+  struct name { \
+    template<class T1, class T2, class T3, class T4, \
+      class T5, class T6, class T7, class T8, class T9, class T10, class T11> \
+    static inline void apply(T1& A, T2& B, T3& C, T4& D, T5& E, T6& F, T7& G, \
+      T8& H, T9& I, T10& J, T11) \
+    {
+
+#define BZ_DECLARE_STENCIL11(name,A,B,C,D,E,F,G,H,I,J,K) \
+  struct name { \
+    template<class T1, class T2, class T3, class T4, \
+      class T5, class T6, class T7, class T8, class T9, class T10, \
+      class T11> \
+    static inline void apply(T1& A, T2& B, T3& C, T4& D, T5& E, T6& F, T7& G, \
+      T8& H, T9& I, T10& J, T11& K) \
+    {
+
+
+
+/*
+ * dummyArray is used to provide "dummy" padding parameters to applyStencil(),
+ * so that any number of arrays (up to 11) can be given as arguments.
+ */
+
+template<class T> class dummy;
+
+struct dummyArray {
+    typedef dummy<double> T_iterator;
+
+    const dummyArray& shape() const { return *this; }
+};
+
+_bz_global dummyArray _dummyArray;
+
+/*
+ * This dummy class pretends to be a scalar of type T, or an array iterator
+ * of type T, but really does nothing.
+ */
+template<class T>
+class dummy {
+public:
+    dummy() { }
+
+    dummy(T value)
+      : value_(value)
+    { }
+
+    dummy(const dummyArray&)
+    { }
+
+    operator T() const { return value_; };
+
+    template<class T2>
+    void operator=(T2) { }
+
+    _bz_typename multicomponent_traits<T>::T_element operator[](int i) const
+    { return value_[i]; }
+
+    void loadStride(int) { }
+    void moveTo(int) { }
+    void moveTo(int,int) { }
+    void moveTo(int,int,int) { }
+    void moveTo(int,int,int,int) { }
+    void advance() { }
+    T shift(int,int) { return T(); }
+
+private:
+    T value_;
+};
+
+
+/*
+ * The stencilExtent object is passed to stencil objects to find out
+ * the spatial extent of the stencil.  It pretends it's an array,
+ * but really it's just recording the locations of the array reads
+ * via operator().
+ */
+
+template<int N_rank, class P_numtype>
+class stencilExtent {
+public:
+    typedef P_numtype T_numtype;
+
+    stencilExtent()
+    {
+        min_ = 0;
+        max_ = 0;
+    }
+  
+    dummy<T_numtype> operator()(int i)
+    {
+        update(0, i);
+        return dummy<T_numtype>(1);
+    }
+ 
+    dummy<T_numtype> operator()(int i, int j)
+    {
+        update(0, i);
+        update(1, j);
+        return dummy<T_numtype>(1);
+    }
+
+    dummy<T_numtype> operator()(int i, int j, int k)
+    {
+        update(0, i);
+        update(1, j);
+        update(2, k);
+        return dummy<T_numtype>(1);
+    }
+
+    dummy<T_numtype> shift(int offset, int dim)
+    {
+        update(dim, offset);
+        return dummy<T_numtype>(1);
+    }
+   
+    dummy<_bz_typename multicomponent_traits<T_numtype>::T_element> 
+        operator[](int)
+    {
+        return dummy<_bz_typename multicomponent_traits<T_numtype>::T_element>
+            (1);
+    }
+ 
+    void update(int rank, int offset)
+    {
+        if (offset < min_[rank])
+            min_[rank] = offset;
+        if (offset > max_[rank])
+            max_[rank] = offset;
+    }
+
+    template<class T_numtype2>
+    void combine(const stencilExtent<N_rank,T_numtype2>& x)
+    {
+        for (int i=0; i < N_rank; ++i)
+        {
+            min_[i] = ::min(min_[i], x.min(i));
+            max_[i] = ::max(max_[i], x.max(i));
+        }
+    }
+
+    template<class T_numtype2>
+    void combine(const dummy<T_numtype2>&)
+    { }
+
+    int min(int i) const
+    { return min_[i]; }
+
+    int max(int i) const
+    { return max_[i]; }
+
+    const TinyVector<int,N_rank>& min() const
+    { return min_; }
+
+    const TinyVector<int,N_rank>& max() const
+    { return max_; }
+
+    template<class T>
+    void operator=(T)
+    { }
+
+    // NEEDS_WORK: other operators
+    template<class T> void operator+=(T) { }
+    template<class T> void operator-=(T) { }
+    template<class T> void operator*=(T) { }
+    template<class T> void operator/=(T) { }
+
+    operator T_numtype()
+    { return T_numtype(1); }
+
+    T_numtype operator*()
+    { return T_numtype(1); }
+ 
+private:
+    _bz_mutable TinyVector<int,N_rank> min_, max_;
+};
+
+
+/*
+ * stencilExtent_traits gives a stencilExtent<N,T> object for arrays,
+ * and a dummy object for dummy arrays.
+ */
+template<class T>
+struct stencilExtent_traits {
+    typedef dummy<double> T_stencilExtent;
+};
+
+template<class T_numtype, int N_rank>
+struct stencilExtent_traits<Array<T_numtype,N_rank> > {
+    typedef stencilExtent<N_rank,T_numtype> T_stencilExtent;
+};
+
+/*
+ * Specialization of areShapesConformable(), originally
+ * defined in <blitz/shapecheck.h>
+ */
+
+template<class T_shape1>
+inline _bz_bool areShapesConformable(const T_shape1&, const dummyArray&)
+{
+    return _bz_true;
+}
+
+BZ_NAMESPACE_END
+
+#include <blitz/array/stencil.cc>
+
+#endif // BZ_ARRAYSTENCIL_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/stencilops.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/stencilops.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/stencilops.h	(revision 1307)
@@ -0,0 +1,963 @@
+#ifndef BZ_ARRAYSTENCILOPS_H
+#define BZ_ARRAYSTENCILOPS_H
+
+// NEEDS_WORK: need to factor many of the stencils in terms of the
+// integer constants, e.g. 16*(A(-1,0)+A(0,-1)+A(0,1)+A(1,0))
+
+#ifndef BZ_ARRAYSTENCIL_H
+ #error <blitz/array/stencilops.h> must be included via <blitz/array/stencil.h>
+#endif
+
+#ifndef BZ_GEOMETRY_H
+ #include <blitz/array/geometry.h>
+#endif
+
+#ifndef BZ_TINYMAT_H
+ #include <blitz/tinymat.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+#define BZ_DECLARE_STENCIL_OPERATOR1(name,A)     \
+  template<class T>                              \
+  inline _bz_typename T::T_numtype name(T& A)    \
+  {
+
+#define BZ_END_STENCIL_OPERATOR   }
+
+#define BZ_DECLARE_STENCIL_OPERATOR3(name,A,B,C) \
+  template<class T>                              \
+  inline _bz_typename T::T_numtype name(T& A, T& B, T& C)    \
+  {
+
+// These constants are accurate to 45 decimal places = 149 bits of mantissa
+const double recip_2 = .500000000000000000000000000000000000000000000;
+const double recip_4 = .250000000000000000000000000000000000000000000;
+const double recip_6 = .166666666666666666666666666666666666666666667;
+const double recip_8 = .125000000000000000000000000000000000000000000;
+const double recip_12 = .0833333333333333333333333333333333333333333333;
+const double recip_144 = .00694444444444444444444444444444444444444444444;
+
+/****************************************************************************
+ * Laplacian Operators
+ ****************************************************************************/
+
+BZ_DECLARE_STENCIL_OPERATOR1(Laplacian2D, A)
+    return -4*A(0,0) + A(-1,0) + A(1,0) + A(0,-1) + A(0,1);
+BZ_END_STENCIL_OPERATOR
+
+BZ_DECLARE_STENCIL_OPERATOR1(Laplacian3D, A)
+    return -6*A(0,0,0) + A(-1,0,0) + A(1,0,0) + A(0,-1,0) + A(0,1,0)
+        + A(0,0,-1) + A(0,0,1);
+BZ_END_STENCIL_OPERATOR
+
+BZ_DECLARE_STENCIL_OPERATOR1(Laplacian2D4, A)
+    return -1*A(-2,0) + 16*A(-1,0) -A(0,-2) + 16*A(0,-1) -60*A(0,0)
+      +16*A(0,1) -A(0,2) + 16*A(1,0) - A(2,0);
+BZ_END_STENCIL_OPERATOR
+
+BZ_DECLARE_STENCIL_OPERATOR1(Laplacian2D4n, A)
+    return Laplacian2D4(A) * recip_12;
+BZ_END_STENCIL_OPERATOR
+
+BZ_DECLARE_STENCIL_OPERATOR1(Laplacian3D4, A)
+    return -1*A(-2,0,0) + 16*A(-1,0,0) -A(0,-2,0) + 16*A(0,-1,0) -90*A
+      +16*A(0,1,0) -A(0,2,0) + 16*A(1,0,0) - A(2,0,0)
+      - A(0,0,-2) + 16*A(0,0,-1) + 16*A(0,0,1) - A(0,0,2);
+BZ_END_STENCIL_OPERATOR
+
+BZ_DECLARE_STENCIL_OPERATOR1(Laplacian3D4n, A)
+    return Laplacian3D4(A) * recip_12;
+BZ_END_STENCIL_OPERATOR
+
+/****************************************************************************
+ * Derivatives
+ ****************************************************************************/
+
+#define BZ_DECLARE_DIFF(name)  \
+  template<class T> \
+  inline _bz_typename T::T_numtype name(T& A, int dim = firstDim)
+
+#define BZ_DECLARE_MULTIDIFF(name) \
+  template<class T> \
+  inline _bz_typename multicomponent_traits<_bz_typename     \
+     T::T_numtype>::T_element name(T& A, int comp, int dim)
+
+/****************************************************************************
+ * Central differences with accuracy O(h^2)
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(central12) {
+  return A.shift(1,dim) - A.shift(-1,dim);
+}
+
+BZ_DECLARE_DIFF(central22) {
+  return A.shift(-1,dim) - 2 * A + A.shift(+1,dim);
+}
+
+BZ_DECLARE_DIFF(central32) {
+  return -A.shift(-2,dim) + 2*A.shift(-1,dim) -2*A.shift(+1,dim) + A.shift(+2,dim);
+}
+
+BZ_DECLARE_DIFF(central42) {
+  return A.shift(-2,dim) -4*A.shift(-1,dim) +6*A.shift(0,dim) -4*A.shift(1,dim)
+    +A.shift(2,dim);
+}
+
+/****************************************************************************
+ * Central differences with accuracy O(h^2)  (multicomponent versions)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(central12) {
+  return A.shift(1,dim)[comp] - A.shift(-1,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(central22) {
+  return A.shift(-1,dim)[comp] - 2 * (*A)[comp] + A.shift(+1,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(central32) {
+  return -A.shift(-2,dim)[comp] + 2*A.shift(-1,dim)[comp] 
+    -2*A.shift(+1,dim)[comp] + A.shift(+2,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(central42) {
+  return A.shift(-2,dim)[comp] -4*A.shift(-1,dim)[comp] 
+    +6*A.shift(0,dim)[comp] -4*A.shift(1,dim)[comp] +A.shift(2,dim)[comp];
+}
+
+/****************************************************************************
+ * Central differences with accuracy O(h^2)  (normalized versions)
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(central12n) {
+  return central12(A,dim) * recip_2;
+}
+
+BZ_DECLARE_DIFF(central22n) {
+  return central22(A,dim);
+}
+
+BZ_DECLARE_DIFF(central32n) {
+  return central32(A,dim) * recip_2;
+}
+
+BZ_DECLARE_DIFF(central42n) {
+  return central42(A,dim);
+}
+
+/****************************************************************************
+ * Central differences with accuracy O(h^2)  (normalized multicomponent)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(central12n) {
+  return central12(A,comp,dim) * recip_2;
+}
+
+BZ_DECLARE_MULTIDIFF(central22n) {
+  return central22(A,comp,dim);
+}
+
+BZ_DECLARE_MULTIDIFF(central32n) {
+  return central32(A,comp,dim) * recip_2;
+}
+
+BZ_DECLARE_MULTIDIFF(central42n) {
+  return central42(A,comp,dim);
+}
+
+/****************************************************************************
+ * Central differences with accuracy O(h^4)  
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(central14) {
+  return (A.shift(-2,dim) - A.shift(2,dim)) 
+     + 8*(A.shift(1,dim)-A.shift(-1,dim));
+}
+
+BZ_DECLARE_DIFF(central24) {
+  return -30*A + 16*(A.shift(-1,dim)+A.shift(1,dim))
+    - (A.shift(-2,dim)+A.shift(2,dim));
+}
+
+BZ_DECLARE_DIFF(central34) {
+  return A.shift(-3,dim) - 8*A.shift(-2,dim) +13*A.shift(-1,dim) 
+     -13*A.shift(1,dim)+8*A.shift(2,dim)-A.shift(3,dim);
+}
+
+BZ_DECLARE_DIFF(central44) {
+  return -1*A.shift(-3,dim)+12*A.shift(-2,dim)-39*A.shift(-1,dim)
+    +56*A-39*A.shift(1,dim)+12*A.shift(2,dim)-A.shift(3,dim);
+}
+
+/****************************************************************************
+ * Central differences with accuracy O(h^4)  (multicomponent versions)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(central14) {
+  return A.shift(-2,dim)[comp] - 8 * A.shift(-1,dim)[comp] 
+    + 8 * A.shift(1,dim)[comp] - A.shift(2,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(central24) {
+  return - A.shift(-2,dim)[comp] + 16*A.shift(-1,dim)[comp] - 30*(*A)[comp]
+    + 16*A.shift(1,dim)[comp] - A.shift(2,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(central34) {
+  return A.shift(-3,dim)[comp] - 8*A.shift(-2,dim)[comp] 
+    +13*A.shift(-1,dim)[comp] - 13*A.shift(1,dim)[comp] 
+    + 8*A.shift(2,dim)[comp] - A.shift(3,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(central44) {
+  return -1*A.shift(-3,dim)[comp]+12*A.shift(-2,dim)[comp]
+    -39*A.shift(-1,dim)[comp] +56*(*A)[comp]-39*A.shift(1,dim)[comp]
+    +12*A.shift(2,dim)[comp]-A.shift(3,dim)[comp];
+}
+
+/****************************************************************************
+ * Central differences with accuracy O(h^4)  (normalized)
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(central14n) {
+  return central14(A,dim) * recip_12;
+}
+
+BZ_DECLARE_DIFF(central24n) {
+  return central24(A,dim) * recip_12;
+}
+
+BZ_DECLARE_DIFF(central34n) {
+  return central34(A,dim) * recip_8;
+}
+
+BZ_DECLARE_DIFF(central44n) {
+  return central44(A,dim) * recip_6;
+}
+
+/****************************************************************************
+ * Central differences with accuracy O(h^4)  (normalized, multicomponent)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(central14n) {
+  return central14(A,comp,dim) * recip_12;
+}
+
+BZ_DECLARE_MULTIDIFF(central24n) {
+  return central24(A,comp,dim) * recip_12;
+}
+
+BZ_DECLARE_MULTIDIFF(central34n) {
+  return central34(A,comp,dim) * recip_8;
+}
+
+BZ_DECLARE_MULTIDIFF(central44n) {
+  return central44(A,comp,dim) * recip_6;
+}
+
+/****************************************************************************
+ * Backward differences with accuracy O(h)
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(backward11) {
+  return A - A.shift(-1,dim);
+}
+
+BZ_DECLARE_DIFF(backward21) {
+  return A -2*A.shift(-1,dim) + A.shift(-2,dim);
+}
+
+BZ_DECLARE_DIFF(backward31) {
+  return A -3*A.shift(-1,dim) + 3*A.shift(-2,dim)-A.shift(-3,dim);
+}
+
+BZ_DECLARE_DIFF(backward41) {
+  return A - 4*A.shift(-1,dim) + 6*A.shift(-2,dim) -4*A.shift(-3,dim) 
+    + A.shift(-4,dim);
+}
+
+/****************************************************************************
+ * Backward differences with accuracy O(h) (multicomponent versions)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(backward11) {
+  return (*A)[comp] - A.shift(-1,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(backward21) {
+  return (*A)[comp] -2*A.shift(-1,dim)[comp] + A.shift(-2,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(backward31) {
+  return (*A)[comp] -3*A.shift(-1,dim)[comp] + 3*A.shift(-2,dim)[comp]
+    -A.shift(-3,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(backward41) {
+  return (*A)[comp] - 4*A.shift(-1,dim)[comp] + 6*A.shift(-2,dim)[comp]
+    -4*A.shift(-3,dim)[comp] + A.shift(-4,dim)[comp];
+}
+
+/****************************************************************************
+ * Backward differences with accuracy O(h)  (normalized)
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(backward11n) { return backward11(A,dim); }
+BZ_DECLARE_DIFF(backward21n) { return backward21(A,dim); }
+BZ_DECLARE_DIFF(backward31n) { return backward31(A,dim); }
+BZ_DECLARE_DIFF(backward41n) { return backward41(A,dim); }
+
+/****************************************************************************
+ * Backward differences with accuracy O(h)  (normalized, multicomponent)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(backward11n) { return backward11(A,comp,dim); }
+BZ_DECLARE_MULTIDIFF(backward21n) { return backward21(A,comp,dim); }
+BZ_DECLARE_MULTIDIFF(backward31n) { return backward31(A,comp,dim); }
+BZ_DECLARE_MULTIDIFF(backward41n) { return backward41(A,comp,dim); }
+
+/****************************************************************************
+ * Backward differences with accuracy O(h^2)
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(backward12) {
+  return 3*A -4*A.shift(-1,dim) + A.shift(-2,dim);
+}
+
+BZ_DECLARE_DIFF(backward22) {
+  return 2*A -5*A.shift(-1,dim) + 4*A.shift(-2,dim) -1*A.shift(-3,dim);
+}
+
+BZ_DECLARE_DIFF(backward32) {
+  return 5*A - 18*A.shift(-1,dim) + 24*A.shift(-2,dim) -14*A.shift(-3,dim) 
+    + 3*A.shift(-4,dim);
+}
+
+BZ_DECLARE_DIFF(backward42) {
+  return 3*A -14*A.shift(-1,dim) + 26*A.shift(-2,dim) -24*A.shift(-3,dim) 
+    + 11*A.shift(-4,dim) -2*A.shift(-5,dim);
+}
+
+/****************************************************************************
+ * Backward differences with accuracy O(h^2) (multicomponent versions)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(backward12) {
+  return 3*(*A)[comp] -4*A.shift(-1,dim)[comp] + A.shift(-2,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(backward22) {
+  return 2*(*A)[comp] -5*A.shift(-1,dim)[comp] + 4*A.shift(-2,dim)[comp]
+     -1*A.shift(-3,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(backward32) {
+  return 5*(*A)[comp] - 18*A.shift(-1,dim)[comp] + 24*A.shift(-2,dim)[comp]
+     -14*A.shift(-3,dim)[comp] + 3*A.shift(-4,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(backward42) {
+  return 3*(*A)[comp] -14*A.shift(-1,dim)[comp] + 26*A.shift(-2,dim)[comp]
+    -24*A.shift(-3,dim)[comp] + 11*A.shift(-4,dim)[comp] 
+    -2*A.shift(-5,dim)[comp];
+}
+
+/****************************************************************************
+ * Backward differences with accuracy O(h^2)  (normalized)
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(backward12n) { return backward12(A,dim) * recip_2; }
+BZ_DECLARE_DIFF(backward22n) { return backward22(A,dim); }
+BZ_DECLARE_DIFF(backward32n) { return backward32(A,dim) * recip_2; }
+BZ_DECLARE_DIFF(backward42n) { return backward42(A,dim); }
+
+/****************************************************************************
+ * Backward differences with accuracy O(h^2)  (normalized, multicomponent)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(backward12n) { return backward12(A,comp,dim) * recip_2; }
+BZ_DECLARE_MULTIDIFF(backward22n) { return backward22(A,comp,dim); }
+BZ_DECLARE_MULTIDIFF(backward32n) { return backward32(A,comp,dim) * recip_2; }
+BZ_DECLARE_MULTIDIFF(backward42n) { return backward42(A,comp,dim); }
+
+/****************************************************************************
+ * Forward differences with accuracy O(h)  
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(forward11) {
+  return -1*A+A.shift(1,dim);
+}
+
+BZ_DECLARE_DIFF(forward21) {
+  return A - 2*A.shift(1,dim) + A.shift(2,dim);
+}
+
+BZ_DECLARE_DIFF(forward31) {
+  return -A + 3*A.shift(1,dim) -3*A.shift(2,dim) + A.shift(3,dim);
+}
+
+BZ_DECLARE_DIFF(forward41) {
+  return A -4*A.shift(1,dim) + 6*A.shift(2,dim) -4*A.shift(3,dim) 
+    + A.shift(4,dim);
+}
+
+/****************************************************************************
+ * Forward differences with accuracy O(h)  (multicomponent versions)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(forward11) {
+  return -1*(*A)[comp]+A.shift(1,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(forward21) {
+  return (*A)[comp] - 2*A.shift(1,dim)[comp] + A.shift(2,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(forward31) {
+  return -(*A)[comp] + 3*A.shift(1,dim)[comp] -3*A.shift(2,dim)[comp] 
+    + A.shift(3,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(forward41) {
+  return (*A)[comp] -4*A.shift(1,dim)[comp] + 6*A.shift(2,dim)[comp] 
+    -4*A.shift(3,dim)[comp] + A.shift(4,dim)[comp];
+}
+
+/****************************************************************************
+ * Forward differences with accuracy O(h)     (normalized)
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(forward11n) { return forward11(A,dim); }
+BZ_DECLARE_DIFF(forward21n) { return forward21(A,dim); }
+BZ_DECLARE_DIFF(forward31n) { return forward31(A,dim); }
+BZ_DECLARE_DIFF(forward41n) { return forward41(A,dim); }
+
+/****************************************************************************
+ * Forward differences with accuracy O(h)     (multicomponent,normalized)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(forward11n) { return forward11(A,comp,dim); }
+BZ_DECLARE_MULTIDIFF(forward21n) { return forward21(A,comp,dim); }
+BZ_DECLARE_MULTIDIFF(forward31n) { return forward31(A,comp,dim); }
+BZ_DECLARE_MULTIDIFF(forward41n) { return forward41(A,comp,dim); }
+
+/****************************************************************************
+ * Forward differences with accuracy O(h^2)     
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(forward12) {
+  return -3*A + 4*A.shift(1,dim) - A.shift(2,dim);
+}
+
+BZ_DECLARE_DIFF(forward22) {
+  return 2*A -5*A.shift(1,dim) + 4*A.shift(2,dim) -A.shift(3,dim);
+}
+
+BZ_DECLARE_DIFF(forward32) {
+  return -5*A + 18*A.shift(1,dim) -24*A.shift(2,dim) 
+    + 14*A.shift(3,dim) -3*A.shift(4,dim);
+}
+
+BZ_DECLARE_DIFF(forward42) {
+  return 3*A -14*A.shift(1,dim) + 26*A.shift(2,dim) -24*A.shift(3,dim) 
+    +11*A.shift(4,dim) + 11*A.shift(5,dim);
+}
+
+/****************************************************************************
+ * Forward differences with accuracy O(h^2)   (multicomponent versions)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(forward12) {
+  return -3*(*A)[comp] + 4*A.shift(1,dim)[comp] - A.shift(2,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(forward22) {
+  return 2*(*A)[comp] -5*A.shift(1,dim)[comp] + 4*A.shift(2,dim)[comp] 
+    -A.shift(3,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(forward32) {
+  return -5*(*A)[comp] + 18*A.shift(1,dim)[comp] -24*A.shift(2,dim)[comp]
+    + 14*A.shift(3,dim)[comp] -3*A.shift(4,dim)[comp];
+}
+
+BZ_DECLARE_MULTIDIFF(forward42) {
+  return 3*(*A)[comp] -14*A.shift(1,dim)[comp] + 26*A.shift(2,dim)[comp] 
+    -24*A.shift(3,dim)[comp] +11*A.shift(4,dim)[comp] 
+    + 11*A.shift(5,dim)[comp];
+}
+
+
+/****************************************************************************
+ * Forward differences with accuracy O(h^2)     (normalized)
+ ****************************************************************************/
+
+BZ_DECLARE_DIFF(forward12n) { return forward12(A,dim) * recip_2; }
+BZ_DECLARE_DIFF(forward22n) { return forward22(A,dim); }
+BZ_DECLARE_DIFF(forward32n) { return forward32(A,dim) * recip_2; }
+BZ_DECLARE_DIFF(forward42n) { return forward42(A,dim); }
+
+/****************************************************************************
+ * Forward differences with accuracy O(h^2)     (normalized)
+ ****************************************************************************/
+
+BZ_DECLARE_MULTIDIFF(forward12n) { return forward12(A,comp,dim) * recip_2; }
+BZ_DECLARE_MULTIDIFF(forward22n) { return forward22(A,comp,dim); }
+BZ_DECLARE_MULTIDIFF(forward32n) { return forward32(A,comp,dim) * recip_2; }
+BZ_DECLARE_MULTIDIFF(forward42n) { return forward42(A,comp,dim); }
+
+/****************************************************************************
+ * Gradient operators
+ ****************************************************************************/
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,2> grad2D(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,2>(
+    central12(A,firstDim),
+    central12(A,secondDim));
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,2> grad2D4(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,2>(
+    central14(A,firstDim),
+    central14(A,secondDim));
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3> grad3D(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    central12(A,firstDim),
+    central12(A,secondDim),
+    central12(A,thirdDim));
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3> grad3D4(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    central14(A,firstDim),
+    central14(A,secondDim),
+    central14(A,thirdDim));
+}
+
+/****************************************************************************
+ * Grad-squared operators
+ ****************************************************************************/
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,2> gradSqr2D(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,2>(
+    central22(A,firstDim),
+    central22(A,secondDim));
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,2> gradSqr2D4(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,2>(
+    central24(A,firstDim),
+    central24(A,secondDim));
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3> gradSqr3D(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    central22(A,firstDim),
+    central22(A,secondDim),
+    central22(A,thirdDim));
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3> gradSqr3D4(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    central24(A,firstDim),
+    central24(A,secondDim),
+    central24(A,thirdDim));
+}
+
+/****************************************************************************
+ * Grad-squared operators (normalized)
+ ****************************************************************************/
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,2> gradSqr2Dn(T& A) {
+  return gradSqr2D(A);
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,2> gradSqr2D4n(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,2>(
+    central24(A,firstDim) * recip_12,
+    central24(A,secondDim) * recip_12);
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3> gradSqr3Dn(T& A) {
+  return gradSqr3D(A);
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3> gradSqr3D4n(T& A) {
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    central24(A,firstDim) * recip_12,
+    central24(A,secondDim) * recip_12,
+    central24(A,thirdDim) * recip_12);
+}
+
+/****************************************************************************
+ * Gradient operators on a vector field
+ ****************************************************************************/
+
+template<class T>
+inline TinyMatrix<_bz_typename multicomponent_traits<_bz_typename 
+    T::T_numtype>::T_element, 3, 3>
+Jacobian3D(T& A)
+{
+    const int x=0, y=1, z=2;
+    const int u=0, v=1, w=2;
+
+    TinyMatrix<_bz_typename multicomponent_traits<_bz_typename 
+        T::T_numtype>::T_element, 3, 3> grad;
+
+    grad(u,x) = central12(A,u,x);
+    grad(u,y) = central12(A,u,y);
+    grad(u,z) = central12(A,u,z);
+    grad(v,x) = central12(A,v,x);
+    grad(v,y) = central12(A,v,y);
+    grad(v,z) = central12(A,v,z);
+    grad(w,x) = central12(A,w,x);
+    grad(w,y) = central12(A,w,y);
+    grad(w,z) = central12(A,w,z);
+
+    return grad;
+}
+
+template<class T>
+inline TinyMatrix<_bz_typename multicomponent_traits<_bz_typename 
+    T::T_numtype>::T_element, 3, 3>
+Jacobian3Dn(T& A)
+{
+    const int x=0, y=1, z=2;
+    const int u=0, v=1, w=2;
+
+    TinyMatrix<_bz_typename multicomponent_traits<_bz_typename 
+        T::T_numtype>::T_element, 3, 3> grad;
+    
+    grad(u,x) = central12n(A,u,x);
+    grad(u,y) = central12n(A,u,y);
+    grad(u,z) = central12n(A,u,z);
+    grad(v,x) = central12n(A,v,x);
+    grad(v,y) = central12n(A,v,y);
+    grad(v,z) = central12n(A,v,z);
+    grad(w,x) = central12n(A,w,x);
+    grad(w,y) = central12n(A,w,y);
+    grad(w,z) = central12n(A,w,z);
+
+    return grad;
+}
+
+template<class T>
+inline TinyMatrix<_bz_typename multicomponent_traits<_bz_typename
+    T::T_numtype>::T_element, 3, 3>
+Jacobian3D4(T& A)
+{
+    const int x=0, y=1, z=2;
+    const int u=0, v=1, w=2;
+
+    TinyMatrix<_bz_typename multicomponent_traits<_bz_typename 
+        T::T_numtype>::T_element, 3, 3> grad;
+    
+    grad(u,x) = central14(A,u,x);
+    grad(u,y) = central14(A,u,y);
+    grad(u,z) = central14(A,u,z);
+    grad(v,x) = central14(A,v,x);
+    grad(v,y) = central14(A,v,y);
+    grad(v,z) = central14(A,v,z);
+    grad(w,x) = central14(A,w,x);
+    grad(w,y) = central14(A,w,y);
+    grad(w,z) = central14(A,w,z);
+
+    return grad;
+}
+
+template<class T>
+inline TinyMatrix<_bz_typename multicomponent_traits<_bz_typename
+    T::T_numtype>::T_element, 3, 3>
+Jacobian3D4n(T& A)
+{
+    const int x=0, y=1, z=2;
+    const int u=0, v=1, w=2;
+
+    TinyMatrix<_bz_typename multicomponent_traits<_bz_typename 
+        T::T_numtype>::T_element, 3, 3> grad;
+    
+    grad(u,x) = central14n(A,u,x);
+    grad(u,y) = central14n(A,u,y);
+    grad(u,z) = central14n(A,u,z);
+    grad(v,x) = central14n(A,v,x);
+    grad(v,y) = central14n(A,v,y);
+    grad(v,z) = central14n(A,v,z);
+    grad(w,x) = central14n(A,w,x);
+    grad(w,y) = central14n(A,w,y);
+    grad(w,z) = central14n(A,w,z);
+
+    return grad;
+}
+
+/****************************************************************************
+ * Curl operators
+ ****************************************************************************/
+
+// O(h^2) curl, using central difference
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3> 
+curl(T& vx, T& vy, T& vz) {
+  const int x = firstDim, y = secondDim, z = thirdDim;
+
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    central12(vz,y)-central12(vy,z),
+    central12(vx,z)-central12(vz,x),
+    central12(vy,x)-central12(vx,y));
+}
+
+// Normalized O(h^2) curl, using central difference
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3>
+curln(T& vx, T& vy, T& vz) {
+  const int x = firstDim, y = secondDim, z = thirdDim;
+
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    (central12(vz,y)-central12(vy,z)) * recip_2,
+    (central12(vx,z)-central12(vz,x)) * recip_2,
+    (central12(vy,x)-central12(vx,y)) * recip_2);
+}
+
+// Multicomponent curl
+template<class T>
+inline _bz_typename T::T_numtype curl(T& A) {
+  const int x = firstDim, y = secondDim, z = thirdDim;
+
+  return _bz_typename T::T_numtype(
+    central12(A,z,y)-central12(A,y,z),
+    central12(A,x,z)-central12(A,z,x),
+    central12(A,y,x)-central12(A,x,y));
+}
+
+// Normalized multicomponent curl
+template<class T>
+inline _bz_typename T::T_numtype curln(T& A) {
+  const int x = firstDim, y = secondDim, z = thirdDim;
+
+  return _bz_typename T::T_numtype(
+    (central12(A,z,y)-central12(A,y,z)) * recip_2,
+    (central12(A,x,z)-central12(A,z,x)) * recip_2,
+    (central12(A,y,x)-central12(A,x,y)) * recip_2);
+}
+
+// O(h^4) curl, using 4th order central difference
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3>
+curl4(T& vx, T& vy, T& vz) {
+  const int x = firstDim, y = secondDim, z = thirdDim;
+
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    central14(vz,y)-central14(vy,z),
+    central14(vx,z)-central14(vz,x),
+    central14(vy,x)-central14(vx,y));
+}
+
+// O(h^4) curl, using 4th order central difference (multicomponent version)
+template<class T>
+inline _bz_typename T::T_numtype
+curl4(T& A) {
+  const int x = firstDim, y = secondDim, z = thirdDim;
+
+  return _bz_typename T::T_numtype(
+    central14(A,z,y)-central14(A,y,z),
+    central14(A,x,z)-central14(A,z,x),
+    central14(A,y,x)-central14(A,x,y));
+}
+
+// Normalized O(h^4) curl, using 4th order central difference
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3>
+curl4n(T& vx, T& vy, T& vz) {
+  const int x = firstDim, y = secondDim, z = thirdDim;
+
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    (central14(vz,y)-central14(vy,z)) * recip_2,
+    (central14(vx,z)-central14(vz,x)) * recip_2,
+    (central14(vy,x)-central14(vx,y)) * recip_2);
+}
+
+// O(h^4) curl, using 4th order central difference (normalized multicomponent)
+template<class T>
+inline _bz_typename T::T_numtype
+curl4n(T& A) {
+  const int x = firstDim, y = secondDim, z = thirdDim;
+
+  return _bz_typename T::T_numtype(
+    (central14(A,z,y)-central14(A,y,z)) * recip_2,
+    (central14(A,x,z)-central14(A,z,x)) * recip_2,
+    (central14(A,y,x)-central14(A,x,y)) * recip_2);
+}
+
+/****************************************************************************
+ * Divergence
+ ****************************************************************************/
+
+BZ_DECLARE_STENCIL_OPERATOR3(div,vx,vy,vz)
+  return central12(vx,firstDim) + central12(vy,secondDim) 
+    + central12(vz,thirdDim);
+BZ_END_STENCIL_OPERATOR
+
+BZ_DECLARE_STENCIL_OPERATOR3(divn,vx,vy,vz)
+  return (central12(vx,firstDim) + central12(vy,secondDim) 
+    + central12(vz,thirdDim)) * recip_2;
+BZ_END_STENCIL_OPERATOR
+
+BZ_DECLARE_STENCIL_OPERATOR3(div4,vx,vy,vz)
+  return central14(vx,firstDim) + central14(vy,secondDim) 
+    + central14(vz,thirdDim);
+BZ_END_STENCIL_OPERATOR
+
+BZ_DECLARE_STENCIL_OPERATOR3(div4n,vx,vy,vz)
+  return (central14(vx,firstDim) + central14(vy,secondDim)
+    + central14(vz,thirdDim)) * recip_12;
+BZ_END_STENCIL_OPERATOR
+
+/****************************************************************************
+ * Mixed Partial derivatives
+ ****************************************************************************/
+
+template<class T>
+inline _bz_typename T::T_numtype
+mixed22(T& A, int x, int y)
+{
+    return A.shift(-1,x,-1,y) - A.shift(-1,x,1,y)
+        -A.shift(1,x,-1,y) + A.shift(1,x,1,y);
+}
+
+template<class T>
+inline _bz_typename T::T_numtype
+mixed22n(T& A, int x, int y)
+{
+    return mixed22(A, x, y) * recip_4;
+}
+
+template<class T>
+inline _bz_typename T::T_numtype
+mixed24(T& A, int x, int y)
+{
+    return 64*(A.shift(-1,x,-1,y) - A.shift(-1,x,1,y)
+        -A.shift(1,x,-1,y) + A.shift(1,x,1,y))
+        + (A.shift(-2,x,+1,y) - A.shift(-1,x,2,y)
+        - A.shift(1,x,2,y)-A.shift(2,x,1,y)
+        + A.shift(2,x,-1,y)+A.shift(1,x,-2,y)
+        - A.shift(-1,x,-2,y)+A.shift(-2,x,-1,y))
+        + 8*(A.shift(-1,x,1,y)+A.shift(-1,x,2,y)
+        -A.shift(2,x,-2,y) + A.shift(2,x,2,y));
+}
+
+template<class T>
+inline _bz_typename T::T_numtype
+mixed24n(T& A, int x, int y)
+{
+    return mixed24(A,x,y) * recip_144;
+}
+
+/****************************************************************************
+ * Smoothers
+ ****************************************************************************/
+
+// NEEDS_WORK-- put other stencil operators here:
+//   Average5pt2D
+//   Average7pt3D
+// etc.
+
+/****************************************************************************
+ * Stencil operators with geometry (experimental)
+ ****************************************************************************/
+
+template<class T>
+inline _bz_typename multicomponent_traits<_bz_typename
+    T::T_numtype>::T_element div3DVec4(T& A, 
+    const UniformCubicGeometry<3>& geom)
+{
+    const int x = 0, y = 1, z = 2;
+
+    return (central14(A, x, firstDim) + central14(A, y, secondDim)
+        + central14(A, z, thirdDim)) * recip_12 * geom.recipSpatialStep();
+}
+
+template<class T>
+inline _bz_typename T::T_numtype Laplacian3D4(T& A, 
+    const UniformCubicGeometry<3>& geom)
+{
+    return Laplacian3D4n(A) * geom.recipSpatialStepPow2();
+}
+
+template<class T>
+inline _bz_typename T::T_numtype Laplacian3DVec4(T& A,
+    const UniformCubicGeometry<3>& geom)
+{
+    typedef _bz_typename T::T_numtype vector3d;
+    typedef multicomponent_traits<vector3d>::T_element 
+        T_element;
+    const int u = 0, v = 1, w = 2;
+    const int x = 0, y = 1, z = 2;
+
+    // central24 is a 5-point stencil
+    // This is a 9*5 = 45 point stencil
+
+    T_element t1 = (central24(A,u,x) + central24(A,u,y) + central24(A,u,z))
+        * recip_12 * geom.recipSpatialStepPow2();
+
+    T_element t2 = (central24(A,v,x) + central24(A,v,y) + central24(A,v,z))
+        * recip_12 * geom.recipSpatialStepPow2();
+
+    T_element t3 = (central24(A,w,x) + central24(A,w,y) + central24(A,w,z))
+        * recip_12 * geom.recipSpatialStepPow2();
+
+    return vector3d(t1,t2,t3);
+}
+
+template<class T>
+inline TinyMatrix<_bz_typename multicomponent_traits<_bz_typename
+    T::T_numtype>::T_element, 3, 3>
+grad3DVec4(T& A, const UniformCubicGeometry<3>& geom)
+{
+    const int x=0, y=1, z=2;
+    const int u=0, v=1, w=2;
+
+    TinyMatrix<_bz_typename multicomponent_traits<_bz_typename
+        T::T_numtype>::T_element, 3, 3> grad;
+
+    // This is a 9*4 = 36 point stencil
+    grad(u,x) = central14n(A,u,x) * geom.recipSpatialStep();
+    grad(u,y) = central14n(A,u,y) * geom.recipSpatialStep();
+    grad(u,z) = central14n(A,u,z) * geom.recipSpatialStep();
+    grad(v,x) = central14n(A,v,x) * geom.recipSpatialStep();
+    grad(v,y) = central14n(A,v,y) * geom.recipSpatialStep();
+    grad(v,z) = central14n(A,v,z) * geom.recipSpatialStep();
+    grad(w,x) = central14n(A,w,x) * geom.recipSpatialStep();
+    grad(w,y) = central14n(A,w,y) * geom.recipSpatialStep();
+    grad(w,z) = central14n(A,w,z) * geom.recipSpatialStep();
+
+    return grad;
+}
+
+template<class T>
+inline TinyVector<_bz_typename T::T_numtype,3> grad3D4(T& A,
+    const UniformCubicGeometry<3>& geom) {
+  return TinyVector<_bz_typename T::T_numtype,3>(
+    central14(A,firstDim) * recip_12 * geom.recipSpatialStep(),
+    central14(A,secondDim) * recip_12 * geom.recipSpatialStep(),
+    central14(A,thirdDim) * recip_12 * geom.recipSpatialStep());
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYSTENCILOPS_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/uops.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/uops.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/uops.cc	(revision 1307)
@@ -0,0 +1,5419 @@
+/***************************************************************************
+ * blitz/arrayuops.cc	Expression templates for arrays, unary functions
+ *
+ * $Id: uops.cc,v 1.1.1.1 1999-04-09 17:59:04 ansari Exp $
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ */ 
+
+// Generated source file.  Do not edit. 
+// genarruops.cpp Jun 10 1998 16:02:18
+
+#ifndef BZ_ARRAYUOPS_CC
+#define BZ_ARRAYUOPS_CC
+
+#ifndef BZ_ARRAYEXPR_H
+ #error <blitz/array/uops.cc> must be included after <blitz/arrayexpr.h>
+#endif // BZ_ARRAYEXPR_H
+
+BZ_NAMESPACE(blitz)
+
+/****************************************************************************
+ * abs
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_abs<T_numtype1> > >
+abs(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_abs<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_abs<_bz_typename P_expr1::T_numtype> > >
+abs(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_abs<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_abs<int> > >
+abs(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_abs<int> >(d1);
+}
+
+
+/****************************************************************************
+ * acos
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_acos<T_numtype1> > >
+acos(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_acos<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_acos<_bz_typename P_expr1::T_numtype> > >
+acos(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_acos<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_acos<int> > >
+acos(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_acos<int> >(d1);
+}
+
+
+/****************************************************************************
+ * acosh
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_acosh<T_numtype1> > >
+acosh(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_acosh<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_acosh<_bz_typename P_expr1::T_numtype> > >
+acosh(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_acosh<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_acosh<int> > >
+acosh(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_acosh<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * asin
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_asin<T_numtype1> > >
+asin(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_asin<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_asin<_bz_typename P_expr1::T_numtype> > >
+asin(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_asin<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_asin<int> > >
+asin(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_asin<int> >(d1);
+}
+
+
+/****************************************************************************
+ * asinh
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_asinh<T_numtype1> > >
+asinh(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_asinh<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_asinh<_bz_typename P_expr1::T_numtype> > >
+asinh(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_asinh<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_asinh<int> > >
+asinh(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_asinh<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * atan
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_atan<T_numtype1> > >
+atan(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_atan<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_atan<_bz_typename P_expr1::T_numtype> > >
+atan(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_atan<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_atan<int> > >
+atan(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_atan<int> >(d1);
+}
+
+
+/****************************************************************************
+ * atanh
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_atanh<T_numtype1> > >
+atanh(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_atanh<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_atanh<_bz_typename P_expr1::T_numtype> > >
+atanh(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_atanh<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_atanh<int> > >
+atanh(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_atanh<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * atan2
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<T_numtype1,T_numtype2> > >
+atan2(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+atan2(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_atan2<T_numtype1,int> > >
+atan2(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_atan2<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_atan2<T_numtype1,float> > >
+atan2(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_atan2<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_atan2<T_numtype1,double> > >
+atan2(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_atan2<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_atan2<T_numtype1,long double> > >
+atan2(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_atan2<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_atan2<T_numtype1,complex<T2> > > >
+atan2(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_atan2<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+atan2(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+atan2(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,int> > >
+atan2(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,float> > >
+atan2(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,double> > >
+atan2(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,long double> > >
+atan2(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+atan2(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_atan2<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<int,T_numtype2> > >
+atan2(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<int,_bz_typename P_expr2::T_numtype> > >
+atan2(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_atan2<int,int> > >
+atan2(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_atan2<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_atan2<int,float> > >
+atan2(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_atan2<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_atan2<int,double> > >
+atan2(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_atan2<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_atan2<int,long double> > >
+atan2(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_atan2<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_atan2<int,complex<T2> > > >
+atan2(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_atan2<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<float,T_numtype2> > >
+atan2(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<float,_bz_typename P_expr2::T_numtype> > >
+atan2(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_atan2<float,int> > >
+atan2(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_atan2<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<double,T_numtype2> > >
+atan2(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<double,_bz_typename P_expr2::T_numtype> > >
+atan2(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_atan2<double,int> > >
+atan2(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_atan2<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<long double,T_numtype2> > >
+atan2(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<long double,_bz_typename P_expr2::T_numtype> > >
+atan2(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_atan2<long double,int> > >
+atan2(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_atan2<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<complex<T1> ,T_numtype2> > >
+atan2(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_atan2<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+atan2(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_atan2<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_atan2<complex<T1> ,int> > >
+atan2(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_atan2<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+
+/****************************************************************************
+ * _class
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz__class<T_numtype1> > >
+_class(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz__class<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz__class<_bz_typename P_expr1::T_numtype> > >
+_class(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz__class<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz__class<int> > >
+_class(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz__class<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * cbrt
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_cbrt<T_numtype1> > >
+cbrt(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_cbrt<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_cbrt<_bz_typename P_expr1::T_numtype> > >
+cbrt(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_cbrt<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_cbrt<int> > >
+cbrt(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_cbrt<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * ceil
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_ceil<T_numtype1> > >
+ceil(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_ceil<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_ceil<_bz_typename P_expr1::T_numtype> > >
+ceil(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_ceil<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_ceil<int> > >
+ceil(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_ceil<int> >(d1);
+}
+
+
+/****************************************************************************
+ * cexp
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_cexp<T_numtype1> > >
+cexp(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_cexp<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_cexp<_bz_typename P_expr1::T_numtype> > >
+cexp(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_cexp<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_cexp<int> > >
+cexp(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_cexp<int> >(d1);
+}
+
+
+/****************************************************************************
+ * cos
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_cos<T_numtype1> > >
+cos(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_cos<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_cos<_bz_typename P_expr1::T_numtype> > >
+cos(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_cos<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_cos<int> > >
+cos(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_cos<int> >(d1);
+}
+
+
+/****************************************************************************
+ * cosh
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_cosh<T_numtype1> > >
+cosh(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_cosh<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_cosh<_bz_typename P_expr1::T_numtype> > >
+cosh(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_cosh<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_cosh<int> > >
+cosh(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_cosh<int> >(d1);
+}
+
+
+/****************************************************************************
+ * copysign
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<T_numtype1,T_numtype2> > >
+copysign(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+copysign(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_copysign<T_numtype1,int> > >
+copysign(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_copysign<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_copysign<T_numtype1,float> > >
+copysign(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_copysign<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_copysign<T_numtype1,double> > >
+copysign(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_copysign<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_copysign<T_numtype1,long double> > >
+copysign(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_copysign<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_copysign<T_numtype1,complex<T2> > > >
+copysign(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_copysign<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+copysign(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+copysign(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,int> > >
+copysign(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,float> > >
+copysign(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,double> > >
+copysign(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,long double> > >
+copysign(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+copysign(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_copysign<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<int,T_numtype2> > >
+copysign(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<int,_bz_typename P_expr2::T_numtype> > >
+copysign(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_copysign<int,int> > >
+copysign(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_copysign<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_copysign<int,float> > >
+copysign(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_copysign<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_copysign<int,double> > >
+copysign(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_copysign<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_copysign<int,long double> > >
+copysign(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_copysign<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_copysign<int,complex<T2> > > >
+copysign(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_copysign<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<float,T_numtype2> > >
+copysign(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<float,_bz_typename P_expr2::T_numtype> > >
+copysign(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_copysign<float,int> > >
+copysign(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_copysign<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<double,T_numtype2> > >
+copysign(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<double,_bz_typename P_expr2::T_numtype> > >
+copysign(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_copysign<double,int> > >
+copysign(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_copysign<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<long double,T_numtype2> > >
+copysign(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<long double,_bz_typename P_expr2::T_numtype> > >
+copysign(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_copysign<long double,int> > >
+copysign(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_copysign<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<complex<T1> ,T_numtype2> > >
+copysign(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_copysign<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+copysign(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_copysign<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_copysign<complex<T1> ,int> > >
+copysign(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_copysign<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#endif
+
+/****************************************************************************
+ * csqrt
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_csqrt<T_numtype1> > >
+csqrt(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_csqrt<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_csqrt<_bz_typename P_expr1::T_numtype> > >
+csqrt(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_csqrt<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_csqrt<int> > >
+csqrt(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_csqrt<int> >(d1);
+}
+
+
+/****************************************************************************
+ * drem
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<T_numtype1,T_numtype2> > >
+drem(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+drem(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_drem<T_numtype1,int> > >
+drem(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_drem<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_drem<T_numtype1,float> > >
+drem(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_drem<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_drem<T_numtype1,double> > >
+drem(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_drem<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_drem<T_numtype1,long double> > >
+drem(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_drem<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_drem<T_numtype1,complex<T2> > > >
+drem(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_drem<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+drem(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+drem(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,int> > >
+drem(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,float> > >
+drem(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,double> > >
+drem(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,long double> > >
+drem(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_drem<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_drem<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+drem(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_drem<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<int,T_numtype2> > >
+drem(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<int,_bz_typename P_expr2::T_numtype> > >
+drem(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_drem<int,int> > >
+drem(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_drem<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_drem<int,float> > >
+drem(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_drem<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_drem<int,double> > >
+drem(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_drem<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_drem<int,long double> > >
+drem(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_drem<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_drem<int,complex<T2> > > >
+drem(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_drem<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<float,T_numtype2> > >
+drem(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<float,_bz_typename P_expr2::T_numtype> > >
+drem(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_drem<float,int> > >
+drem(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_drem<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<double,T_numtype2> > >
+drem(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<double,_bz_typename P_expr2::T_numtype> > >
+drem(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_drem<double,int> > >
+drem(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_drem<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<long double,T_numtype2> > >
+drem(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<long double,_bz_typename P_expr2::T_numtype> > >
+drem(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_drem<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_drem<long double,int> > >
+drem(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_drem<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<complex<T1> ,T_numtype2> > >
+drem(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_drem<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_drem<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+drem(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_drem<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_drem<complex<T1> ,int> > >
+drem(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_drem<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#endif
+
+/****************************************************************************
+ * exp
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_exp<T_numtype1> > >
+exp(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_exp<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_exp<_bz_typename P_expr1::T_numtype> > >
+exp(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_exp<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_exp<int> > >
+exp(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_exp<int> >(d1);
+}
+
+
+/****************************************************************************
+ * expm1
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_expm1<T_numtype1> > >
+expm1(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_expm1<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_expm1<_bz_typename P_expr1::T_numtype> > >
+expm1(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_expm1<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_expm1<int> > >
+expm1(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_expm1<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * erf
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_erf<T_numtype1> > >
+erf(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_erf<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_erf<_bz_typename P_expr1::T_numtype> > >
+erf(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_erf<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_erf<int> > >
+erf(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_erf<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * erfc
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_erfc<T_numtype1> > >
+erfc(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_erfc<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_erfc<_bz_typename P_expr1::T_numtype> > >
+erfc(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_erfc<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_erfc<int> > >
+erfc(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_erfc<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * fabs
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_abs<T_numtype1> > >
+fabs(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_abs<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_abs<_bz_typename P_expr1::T_numtype> > >
+fabs(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_abs<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_abs<int> > >
+fabs(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_abs<int> >(d1);
+}
+
+
+/****************************************************************************
+ * finite
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_finite<T_numtype1> > >
+finite(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_finite<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_finite<_bz_typename P_expr1::T_numtype> > >
+finite(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_finite<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_finite<int> > >
+finite(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_finite<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * floor
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_floor<T_numtype1> > >
+floor(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_floor<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_floor<_bz_typename P_expr1::T_numtype> > >
+floor(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_floor<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_floor<int> > >
+floor(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_floor<int> >(d1);
+}
+
+
+/****************************************************************************
+ * fmod
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<T_numtype1,T_numtype2> > >
+fmod(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+fmod(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_fmod<T_numtype1,int> > >
+fmod(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_fmod<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_fmod<T_numtype1,float> > >
+fmod(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_fmod<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_fmod<T_numtype1,double> > >
+fmod(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_fmod<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_fmod<T_numtype1,long double> > >
+fmod(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_fmod<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_fmod<T_numtype1,complex<T2> > > >
+fmod(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_fmod<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+fmod(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+fmod(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,int> > >
+fmod(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,float> > >
+fmod(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,double> > >
+fmod(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,long double> > >
+fmod(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+fmod(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_fmod<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<int,T_numtype2> > >
+fmod(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<int,_bz_typename P_expr2::T_numtype> > >
+fmod(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_fmod<int,int> > >
+fmod(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_fmod<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_fmod<int,float> > >
+fmod(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_fmod<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_fmod<int,double> > >
+fmod(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_fmod<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_fmod<int,long double> > >
+fmod(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_fmod<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_fmod<int,complex<T2> > > >
+fmod(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_fmod<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<float,T_numtype2> > >
+fmod(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<float,_bz_typename P_expr2::T_numtype> > >
+fmod(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_fmod<float,int> > >
+fmod(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_fmod<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<double,T_numtype2> > >
+fmod(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<double,_bz_typename P_expr2::T_numtype> > >
+fmod(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_fmod<double,int> > >
+fmod(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_fmod<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<long double,T_numtype2> > >
+fmod(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<long double,_bz_typename P_expr2::T_numtype> > >
+fmod(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_fmod<long double,int> > >
+fmod(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_fmod<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<complex<T1> ,T_numtype2> > >
+fmod(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_fmod<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+fmod(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_fmod<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_fmod<complex<T1> ,int> > >
+fmod(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_fmod<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#endif
+
+/****************************************************************************
+ * hypot
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<T_numtype1,T_numtype2> > >
+hypot(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+hypot(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_hypot<T_numtype1,int> > >
+hypot(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_hypot<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_hypot<T_numtype1,float> > >
+hypot(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_hypot<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_hypot<T_numtype1,double> > >
+hypot(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_hypot<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_hypot<T_numtype1,long double> > >
+hypot(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_hypot<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_hypot<T_numtype1,complex<T2> > > >
+hypot(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_hypot<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+hypot(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+hypot(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,int> > >
+hypot(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,float> > >
+hypot(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,double> > >
+hypot(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,long double> > >
+hypot(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+hypot(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_hypot<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<int,T_numtype2> > >
+hypot(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<int,_bz_typename P_expr2::T_numtype> > >
+hypot(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_hypot<int,int> > >
+hypot(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_hypot<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_hypot<int,float> > >
+hypot(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_hypot<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_hypot<int,double> > >
+hypot(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_hypot<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_hypot<int,long double> > >
+hypot(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_hypot<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_hypot<int,complex<T2> > > >
+hypot(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_hypot<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<float,T_numtype2> > >
+hypot(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<float,_bz_typename P_expr2::T_numtype> > >
+hypot(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_hypot<float,int> > >
+hypot(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_hypot<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<double,T_numtype2> > >
+hypot(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<double,_bz_typename P_expr2::T_numtype> > >
+hypot(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_hypot<double,int> > >
+hypot(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_hypot<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<long double,T_numtype2> > >
+hypot(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<long double,_bz_typename P_expr2::T_numtype> > >
+hypot(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_hypot<long double,int> > >
+hypot(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_hypot<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<complex<T1> ,T_numtype2> > >
+hypot(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_hypot<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+hypot(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_hypot<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_hypot<complex<T1> ,int> > >
+hypot(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_hypot<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#endif
+
+/****************************************************************************
+ * ilogb
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_ilogb<T_numtype1> > >
+ilogb(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_ilogb<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_ilogb<_bz_typename P_expr1::T_numtype> > >
+ilogb(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_ilogb<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_ilogb<int> > >
+ilogb(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_ilogb<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * isnan
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_isnan<T_numtype1> > >
+isnan(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_isnan<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_isnan<_bz_typename P_expr1::T_numtype> > >
+isnan(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_isnan<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_isnan<int> > >
+isnan(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_isnan<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * itrunc
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_itrunc<T_numtype1> > >
+itrunc(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_itrunc<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_itrunc<_bz_typename P_expr1::T_numtype> > >
+itrunc(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_itrunc<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_itrunc<int> > >
+itrunc(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_itrunc<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * j0
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_j0<T_numtype1> > >
+j0(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_j0<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_j0<_bz_typename P_expr1::T_numtype> > >
+j0(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_j0<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_j0<int> > >
+j0(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_j0<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * j1
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_j1<T_numtype1> > >
+j1(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_j1<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_j1<_bz_typename P_expr1::T_numtype> > >
+j1(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_j1<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_j1<int> > >
+j1(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_j1<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * lgamma
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_lgamma<T_numtype1> > >
+lgamma(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_lgamma<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_lgamma<_bz_typename P_expr1::T_numtype> > >
+lgamma(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_lgamma<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_lgamma<int> > >
+lgamma(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_lgamma<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * log
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_log<T_numtype1> > >
+log(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_log<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_log<_bz_typename P_expr1::T_numtype> > >
+log(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_log<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_log<int> > >
+log(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_log<int> >(d1);
+}
+
+
+/****************************************************************************
+ * logb
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_logb<T_numtype1> > >
+logb(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_logb<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_logb<_bz_typename P_expr1::T_numtype> > >
+logb(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_logb<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_logb<int> > >
+logb(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_logb<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * log1p
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_log1p<T_numtype1> > >
+log1p(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_log1p<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_log1p<_bz_typename P_expr1::T_numtype> > >
+log1p(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_log1p<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_log1p<int> > >
+log1p(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_log1p<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * log10
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_log10<T_numtype1> > >
+log10(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_log10<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_log10<_bz_typename P_expr1::T_numtype> > >
+log10(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_log10<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_log10<int> > >
+log10(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_log10<int> >(d1);
+}
+
+
+/****************************************************************************
+ * nearest
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_nearest<T_numtype1> > >
+nearest(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_nearest<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_nearest<_bz_typename P_expr1::T_numtype> > >
+nearest(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_nearest<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_nearest<int> > >
+nearest(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_nearest<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * nextafter
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<T_numtype1,T_numtype2> > >
+nextafter(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+nextafter(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<T_numtype1,int> > >
+nextafter(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_nextafter<T_numtype1,float> > >
+nextafter(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_nextafter<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_nextafter<T_numtype1,double> > >
+nextafter(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_nextafter<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_nextafter<T_numtype1,long double> > >
+nextafter(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_nextafter<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_nextafter<T_numtype1,complex<T2> > > >
+nextafter(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_nextafter<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+nextafter(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+nextafter(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,int> > >
+nextafter(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,float> > >
+nextafter(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,double> > >
+nextafter(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,long double> > >
+nextafter(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+nextafter(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_nextafter<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<int,T_numtype2> > >
+nextafter(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<int,_bz_typename P_expr2::T_numtype> > >
+nextafter(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<int,int> > >
+nextafter(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_nextafter<int,float> > >
+nextafter(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_nextafter<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_nextafter<int,double> > >
+nextafter(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_nextafter<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_nextafter<int,long double> > >
+nextafter(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_nextafter<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_nextafter<int,complex<T2> > > >
+nextafter(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_nextafter<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<float,T_numtype2> > >
+nextafter(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<float,_bz_typename P_expr2::T_numtype> > >
+nextafter(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<float,int> > >
+nextafter(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<double,T_numtype2> > >
+nextafter(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<double,_bz_typename P_expr2::T_numtype> > >
+nextafter(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<double,int> > >
+nextafter(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<long double,T_numtype2> > >
+nextafter(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<long double,_bz_typename P_expr2::T_numtype> > >
+nextafter(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<long double,int> > >
+nextafter(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_nextafter<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<complex<T1> ,T_numtype2> > >
+nextafter(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_nextafter<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+nextafter(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_nextafter<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_nextafter<complex<T1> ,int> > >
+nextafter(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_nextafter<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#endif
+
+/****************************************************************************
+ * pow
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<T_numtype1,T_numtype2> > >
+pow(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+pow(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_pow<T_numtype1,int> > >
+pow(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_pow<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_pow<T_numtype1,float> > >
+pow(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_pow<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_pow<T_numtype1,double> > >
+pow(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_pow<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_pow<T_numtype1,long double> > >
+pow(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_pow<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_pow<T_numtype1,complex<T2> > > >
+pow(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_pow<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+pow(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+pow(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,int> > >
+pow(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,float> > >
+pow(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,double> > >
+pow(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,long double> > >
+pow(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_pow<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_pow<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+pow(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_pow<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<int,T_numtype2> > >
+pow(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<int,_bz_typename P_expr2::T_numtype> > >
+pow(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_pow<int,int> > >
+pow(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_pow<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_pow<int,float> > >
+pow(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_pow<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_pow<int,double> > >
+pow(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_pow<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_pow<int,long double> > >
+pow(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_pow<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_pow<int,complex<T2> > > >
+pow(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_pow<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<float,T_numtype2> > >
+pow(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<float,_bz_typename P_expr2::T_numtype> > >
+pow(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_pow<float,int> > >
+pow(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_pow<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<double,T_numtype2> > >
+pow(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<double,_bz_typename P_expr2::T_numtype> > >
+pow(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_pow<double,int> > >
+pow(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_pow<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<long double,T_numtype2> > >
+pow(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<long double,_bz_typename P_expr2::T_numtype> > >
+pow(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_pow<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_pow<long double,int> > >
+pow(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_pow<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<complex<T1> ,T_numtype2> > >
+pow(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_pow<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_pow<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+pow(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_pow<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_pow<complex<T1> ,int> > >
+pow(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_pow<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+
+/****************************************************************************
+ * pow2
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow2<T_numtype1> > >
+pow2(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow2<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow2<_bz_typename P_expr1::T_numtype> > >
+pow2(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow2<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow2<int> > >
+pow2(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow2<int> >(d1);
+}
+
+
+/****************************************************************************
+ * pow3
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow3<T_numtype1> > >
+pow3(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow3<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow3<_bz_typename P_expr1::T_numtype> > >
+pow3(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow3<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow3<int> > >
+pow3(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow3<int> >(d1);
+}
+
+
+/****************************************************************************
+ * pow4
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow4<T_numtype1> > >
+pow4(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow4<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow4<_bz_typename P_expr1::T_numtype> > >
+pow4(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow4<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow4<int> > >
+pow4(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow4<int> >(d1);
+}
+
+
+/****************************************************************************
+ * pow5
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow5<T_numtype1> > >
+pow5(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow5<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow5<_bz_typename P_expr1::T_numtype> > >
+pow5(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow5<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow5<int> > >
+pow5(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow5<int> >(d1);
+}
+
+
+/****************************************************************************
+ * pow6
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow6<T_numtype1> > >
+pow6(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow6<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow6<_bz_typename P_expr1::T_numtype> > >
+pow6(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow6<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow6<int> > >
+pow6(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow6<int> >(d1);
+}
+
+
+/****************************************************************************
+ * pow7
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow7<T_numtype1> > >
+pow7(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow7<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow7<_bz_typename P_expr1::T_numtype> > >
+pow7(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow7<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow7<int> > >
+pow7(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow7<int> >(d1);
+}
+
+
+/****************************************************************************
+ * pow8
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow8<T_numtype1> > >
+pow8(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_pow8<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow8<_bz_typename P_expr1::T_numtype> > >
+pow8(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_pow8<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow8<int> > >
+pow8(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_pow8<int> >(d1);
+}
+
+
+/****************************************************************************
+ * remainder
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<T_numtype1,T_numtype2> > >
+remainder(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+remainder(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_remainder<T_numtype1,int> > >
+remainder(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_remainder<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_remainder<T_numtype1,float> > >
+remainder(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_remainder<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_remainder<T_numtype1,double> > >
+remainder(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_remainder<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_remainder<T_numtype1,long double> > >
+remainder(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_remainder<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_remainder<T_numtype1,complex<T2> > > >
+remainder(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_remainder<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+remainder(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+remainder(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,int> > >
+remainder(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,float> > >
+remainder(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,double> > >
+remainder(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,long double> > >
+remainder(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+remainder(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_remainder<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<int,T_numtype2> > >
+remainder(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<int,_bz_typename P_expr2::T_numtype> > >
+remainder(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_remainder<int,int> > >
+remainder(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_remainder<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_remainder<int,float> > >
+remainder(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_remainder<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_remainder<int,double> > >
+remainder(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_remainder<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_remainder<int,long double> > >
+remainder(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_remainder<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_remainder<int,complex<T2> > > >
+remainder(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_remainder<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<float,T_numtype2> > >
+remainder(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<float,_bz_typename P_expr2::T_numtype> > >
+remainder(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_remainder<float,int> > >
+remainder(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_remainder<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<double,T_numtype2> > >
+remainder(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<double,_bz_typename P_expr2::T_numtype> > >
+remainder(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_remainder<double,int> > >
+remainder(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_remainder<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<long double,T_numtype2> > >
+remainder(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<long double,_bz_typename P_expr2::T_numtype> > >
+remainder(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_remainder<long double,int> > >
+remainder(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_remainder<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<complex<T1> ,T_numtype2> > >
+remainder(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_remainder<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+remainder(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_remainder<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_remainder<complex<T1> ,int> > >
+remainder(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_remainder<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#endif
+
+/****************************************************************************
+ * rint
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_rint<T_numtype1> > >
+rint(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_rint<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_rint<_bz_typename P_expr1::T_numtype> > >
+rint(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_rint<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_rint<int> > >
+rint(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_rint<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * rsqrt
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_rsqrt<T_numtype1> > >
+rsqrt(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_rsqrt<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_rsqrt<_bz_typename P_expr1::T_numtype> > >
+rsqrt(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_rsqrt<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_rsqrt<int> > >
+rsqrt(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_rsqrt<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * scalb
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<T_numtype1,T_numtype2> > >
+scalb(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+scalb(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_scalb<T_numtype1,int> > >
+scalb(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_scalb<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_scalb<T_numtype1,float> > >
+scalb(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_scalb<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_scalb<T_numtype1,double> > >
+scalb(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_scalb<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_scalb<T_numtype1,long double> > >
+scalb(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_scalb<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_scalb<T_numtype1,complex<T2> > > >
+scalb(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_scalb<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+scalb(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+scalb(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,int> > >
+scalb(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,float> > >
+scalb(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,double> > >
+scalb(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,long double> > >
+scalb(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+scalb(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_scalb<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<int,T_numtype2> > >
+scalb(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<int,_bz_typename P_expr2::T_numtype> > >
+scalb(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_scalb<int,int> > >
+scalb(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_scalb<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_scalb<int,float> > >
+scalb(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_scalb<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_scalb<int,double> > >
+scalb(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_scalb<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_scalb<int,long double> > >
+scalb(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_scalb<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_scalb<int,complex<T2> > > >
+scalb(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_scalb<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<float,T_numtype2> > >
+scalb(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<float,_bz_typename P_expr2::T_numtype> > >
+scalb(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_scalb<float,int> > >
+scalb(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_scalb<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<double,T_numtype2> > >
+scalb(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<double,_bz_typename P_expr2::T_numtype> > >
+scalb(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_scalb<double,int> > >
+scalb(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_scalb<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<long double,T_numtype2> > >
+scalb(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<long double,_bz_typename P_expr2::T_numtype> > >
+scalb(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_scalb<long double,int> > >
+scalb(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_scalb<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<complex<T1> ,T_numtype2> > >
+scalb(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_scalb<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+scalb(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_scalb<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_scalb<complex<T1> ,int> > >
+scalb(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_scalb<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#endif
+
+/****************************************************************************
+ * sin
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_sin<T_numtype1> > >
+sin(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_sin<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_sin<_bz_typename P_expr1::T_numtype> > >
+sin(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_sin<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_sin<int> > >
+sin(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_sin<int> >(d1);
+}
+
+
+/****************************************************************************
+ * sinh
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_sinh<T_numtype1> > >
+sinh(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_sinh<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_sinh<_bz_typename P_expr1::T_numtype> > >
+sinh(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_sinh<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_sinh<int> > >
+sinh(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_sinh<int> >(d1);
+}
+
+
+/****************************************************************************
+ * sqr
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_sqr<T_numtype1> > >
+sqr(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_sqr<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_sqr<_bz_typename P_expr1::T_numtype> > >
+sqr(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_sqr<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_sqr<int> > >
+sqr(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_sqr<int> >(d1);
+}
+
+
+/****************************************************************************
+ * sqrt
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_sqrt<T_numtype1> > >
+sqrt(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_sqrt<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_sqrt<_bz_typename P_expr1::T_numtype> > >
+sqrt(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_sqrt<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_sqrt<int> > >
+sqrt(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_sqrt<int> >(d1);
+}
+
+
+/****************************************************************************
+ * tan
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_tan<T_numtype1> > >
+tan(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_tan<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_tan<_bz_typename P_expr1::T_numtype> > >
+tan(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_tan<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_tan<int> > >
+tan(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_tan<int> >(d1);
+}
+
+
+/****************************************************************************
+ * tanh
+ ****************************************************************************/
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_tanh<T_numtype1> > >
+tanh(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_tanh<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_tanh<_bz_typename P_expr1::T_numtype> > >
+tanh(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_tanh<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_tanh<int> > >
+tanh(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_tanh<int> >(d1);
+}
+
+
+/****************************************************************************
+ * trunc
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_trunc<T_numtype1> > >
+trunc(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_trunc<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_trunc<_bz_typename P_expr1::T_numtype> > >
+trunc(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_trunc<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_trunc<int> > >
+trunc(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_trunc<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * uitrunc
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_uitrunc<T_numtype1> > >
+uitrunc(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_uitrunc<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_uitrunc<_bz_typename P_expr1::T_numtype> > >
+uitrunc(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_uitrunc<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_uitrunc<int> > >
+uitrunc(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_uitrunc<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * unordered
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class T_numtype1, int N_rank1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<T_numtype1,T_numtype2> > >
+unordered(const Array<T_numtype1, N_rank1>& d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<T_numtype1,T_numtype2> >(d1.begin(), d2.begin());
+}
+
+template<class T_numtype1, int N_rank1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<T_numtype1,_bz_typename P_expr2::T_numtype> > >
+unordered(const Array<T_numtype1, N_rank1>& d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<T_numtype1,_bz_typename P_expr2::T_numtype> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_unordered<T_numtype1,int> > >
+unordered(const Array<T_numtype1, N_rank1>& d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, IndexPlaceholder<N_index2>,
+    _bz_unordered<T_numtype1,int> >(d1.begin(), d2);
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_unordered<T_numtype1,float> > >
+unordered(const Array<T_numtype1, N_rank1>& d1, float d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<float>,
+    _bz_unordered<T_numtype1,float> >(d1.begin(), _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_unordered<T_numtype1,double> > >
+unordered(const Array<T_numtype1, N_rank1>& d1, double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<double>,
+    _bz_unordered<T_numtype1,double> >(d1.begin(), _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_unordered<T_numtype1,long double> > >
+unordered(const Array<T_numtype1, N_rank1>& d1, long double d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<long double>,
+    _bz_unordered<T_numtype1,long double> >(d1.begin(), _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T_numtype1, int N_rank1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_unordered<T_numtype1,complex<T2> > > >
+unordered(const Array<T_numtype1, N_rank1>& d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<ArrayIterator<T_numtype1, N_rank1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_unordered<T_numtype1,complex<T2> > >(d1.begin(), _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class P_expr1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,T_numtype2> > >
+unordered(_bz_ArrayExpr<P_expr1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,T_numtype2> >(d1, d2.begin());
+}
+
+template<class P_expr1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> > >
+unordered(_bz_ArrayExpr<P_expr1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<class P_expr1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,int> > >
+unordered(_bz_ArrayExpr<P_expr1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, IndexPlaceholder<N_index2>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,int> >(d1, d2);
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,float> > >
+unordered(_bz_ArrayExpr<P_expr1> d1, float d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<float>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,double> > >
+unordered(_bz_ArrayExpr<P_expr1> d1, double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<double>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,long double> > >
+unordered(_bz_ArrayExpr<P_expr1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<long double>,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,complex<T2> > > >
+unordered(_bz_ArrayExpr<P_expr1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExpr<P_expr1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_unordered<_bz_typename P_expr1::T_numtype,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<int N_index1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<int,T_numtype2> > >
+unordered(IndexPlaceholder<N_index1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<int,T_numtype2> >(d1, d2.begin());
+}
+
+template<int N_index1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<int,_bz_typename P_expr2::T_numtype> > >
+unordered(IndexPlaceholder<N_index1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<int,_bz_typename P_expr2::T_numtype> >(d1, d2);
+}
+
+template<int N_index1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_unordered<int,int> > >
+unordered(IndexPlaceholder<N_index1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, IndexPlaceholder<N_index2>,
+    _bz_unordered<int,int> >(d1, d2);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_unordered<int,float> > >
+unordered(IndexPlaceholder<N_index1> d1, float d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<float>,
+    _bz_unordered<int,float> >(d1, _bz_ArrayExprConstant<float>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_unordered<int,double> > >
+unordered(IndexPlaceholder<N_index1> d1, double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<double>,
+    _bz_unordered<int,double> >(d1, _bz_ArrayExprConstant<double>(d2));
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_unordered<int,long double> > >
+unordered(IndexPlaceholder<N_index1> d1, long double d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<long double>,
+    _bz_unordered<int,long double> >(d1, _bz_ArrayExprConstant<long double>(d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<int N_index1, class T2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_unordered<int,complex<T2> > > >
+unordered(IndexPlaceholder<N_index1> d1, complex<T2> d2)
+{
+    return _bz_ArrayExprOp<IndexPlaceholder<N_index1>, _bz_ArrayExprConstant<complex<T2> > ,
+    _bz_unordered<int,complex<T2> > >(d1, _bz_ArrayExprConstant<complex<T2> > (d2));
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<float,T_numtype2> > >
+unordered(float d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<float,T_numtype2> >(_bz_ArrayExprConstant<float>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<float,_bz_typename P_expr2::T_numtype> > >
+unordered(float d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<float,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_unordered<float,int> > >
+unordered(float d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<float>, IndexPlaceholder<N_index2>,
+    _bz_unordered<float,int> >(_bz_ArrayExprConstant<float>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<double,T_numtype2> > >
+unordered(double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<double,T_numtype2> >(_bz_ArrayExprConstant<double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<double,_bz_typename P_expr2::T_numtype> > >
+unordered(double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_unordered<double,int> > >
+unordered(double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<double>, IndexPlaceholder<N_index2>,
+    _bz_unordered<double,int> >(_bz_ArrayExprConstant<double>(d1), d2);
+}
+
+template<class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<long double,T_numtype2> > >
+unordered(long double d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<long double,T_numtype2> >(_bz_ArrayExprConstant<long double>(d1), d2.begin());
+}
+
+template<class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<long double,_bz_typename P_expr2::T_numtype> > >
+unordered(long double d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<long double,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+template<int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_unordered<long double,int> > >
+unordered(long double d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<long double>, IndexPlaceholder<N_index2>,
+    _bz_unordered<long double,int> >(_bz_ArrayExprConstant<long double>(d1), d2);
+}
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class T_numtype2, int N_rank2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<complex<T1> ,T_numtype2> > >
+unordered(complex<T1> d1, const Array<T_numtype2, N_rank2>& d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , ArrayIterator<T_numtype2, N_rank2>,
+    _bz_unordered<complex<T1> ,T_numtype2> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2.begin());
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, class P_expr2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<complex<T1> ,_bz_typename P_expr2::T_numtype> > >
+unordered(complex<T1> d1, _bz_ArrayExpr<P_expr2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , _bz_ArrayExpr<P_expr2>,
+    _bz_unordered<complex<T1> ,_bz_typename P_expr2::T_numtype> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+template<class T1, int N_index2>
+inline
+_bz_ArrayExpr<_bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_unordered<complex<T1> ,int> > >
+unordered(complex<T1> d1, IndexPlaceholder<N_index2> d2)
+{
+    return _bz_ArrayExprOp<_bz_ArrayExprConstant<complex<T1> > , IndexPlaceholder<N_index2>,
+    _bz_unordered<complex<T1> ,int> >(_bz_ArrayExprConstant<complex<T1> > (d1), d2);
+}
+
+#endif // BZ_HAVE_COMPLEX
+
+#endif
+
+/****************************************************************************
+ * y0
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_y0<T_numtype1> > >
+y0(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_y0<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_y0<_bz_typename P_expr1::T_numtype> > >
+y0(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_y0<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_y0<int> > >
+y0(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_y0<int> >(d1);
+}
+
+#endif
+
+/****************************************************************************
+ * y1
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class T_numtype1, int N_rank1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_y1<T_numtype1> > >
+y1(const Array<T_numtype1, N_rank1>& d1)
+{
+    return _bz_ArrayExprUnaryOp<ArrayIterator<T_numtype1, N_rank1>,
+    _bz_y1<T_numtype1> >(d1.begin());
+}
+
+template<class P_expr1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_y1<_bz_typename P_expr1::T_numtype> > >
+y1(_bz_ArrayExpr<P_expr1> d1)
+{
+    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<P_expr1>,
+    _bz_y1<_bz_typename P_expr1::T_numtype> >(d1);
+}
+
+template<int N_index1>
+inline
+_bz_ArrayExpr<_bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_y1<int> > >
+y1(IndexPlaceholder<N_index1> d1)
+{
+    return _bz_ArrayExprUnaryOp<IndexPlaceholder<N_index1>,
+    _bz_y1<int> >(d1);
+}
+
+#endif
+
+BZ_NAMESPACE_END
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/where.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/where.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/where.h	(revision 1307)
@@ -0,0 +1,186 @@
+#ifndef BZ_ARRAYWHERE_H
+#define BZ_ARRAYWHERE_H
+
+#ifndef BZ_ARRAYEXPR_H
+ #error <blitz/array/where.h> must be included via <blitz/array/expr.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr1, class P_expr2, class P_expr3>
+class _bz_ArrayWhere {
+
+public:
+    typedef P_expr1 T_expr1;
+    typedef P_expr2 T_expr2;
+    typedef P_expr3 T_expr3;
+    typedef _bz_typename T_expr2::T_numtype T_numtype2;
+    typedef _bz_typename T_expr3::T_numtype T_numtype3;
+    typedef BZ_PROMOTE(T_numtype2, T_numtype3) T_numtype;
+    typedef T_expr1 T_ctorArg1;
+    typedef T_expr2 T_ctorArg2;
+    typedef T_expr3 T_ctorArg3;
+
+    enum { numArrayOperands = BZ_ENUM_CAST(P_expr1::numArrayOperands)
+                            + BZ_ENUM_CAST(P_expr2::numArrayOperands)
+                            + BZ_ENUM_CAST(P_expr3::numArrayOperands),
+           numIndexPlaceholders = BZ_ENUM_CAST(P_expr1::numIndexPlaceholders)
+                            + BZ_ENUM_CAST(P_expr2::numIndexPlaceholders)
+                            + BZ_ENUM_CAST(P_expr3::numIndexPlaceholders),
+           rank = _bz_meta_max<_bz_meta_max<P_expr1::rank,P_expr2::rank>::max,
+                            P_expr3::rank>::max
+    };
+
+    _bz_ArrayWhere(const _bz_ArrayWhere<T_expr1,T_expr2,T_expr3>& a)
+      : iter1_(a.iter1_), iter2_(a.iter2_), iter3_(a.iter3_)
+    { }
+
+    template<class T1, class T2, class T3>
+    _bz_ArrayWhere(T1 a, T2 b, T3 c)
+      : iter1_(a), iter2_(b), iter3_(c)
+    { }
+
+    T_numtype operator*()
+    { return (*iter1_) ? (*iter2_) : (*iter3_); }
+
+    template<int N_rank>
+    T_numtype operator()(const TinyVector<int, N_rank>& i)
+    { return iter1_(i) ? iter2_(i) : iter3_(i); }
+
+    int lbound(int rank)
+    {
+        return bounds::compute_lbound(rank, bounds::compute_lbound(
+          rank, iter1_.lbound(rank), iter2_.lbound(rank)), 
+          iter3_.lbound(rank));
+    }
+   
+    int ubound(int rank)
+    {
+        return bounds::compute_ubound(rank, bounds::compute_ubound(
+          rank, iter1_.ubound(rank), iter2_.ubound(rank)), 
+          iter3_.ubound(rank));
+    } 
+
+    void push(int position)
+    {
+        iter1_.push(position);
+        iter2_.push(position);
+        iter3_.push(position);
+    }
+
+    void pop(int position)
+    {
+        iter1_.pop(position);
+        iter2_.pop(position);
+        iter3_.pop(position);
+    }
+
+    void advance()
+    {
+        iter1_.advance();
+        iter2_.advance();
+        iter3_.advance();
+    }
+
+    void advance(int n)
+    {
+        iter1_.advance(n);
+        iter2_.advance(n);
+        iter3_.advance(n);
+    }
+
+    void loadStride(int rank)
+    {
+        iter1_.loadStride(rank);
+        iter2_.loadStride(rank);
+        iter3_.loadStride(rank);
+    }
+
+    _bz_bool isUnitStride(int rank) const
+    { 
+        return iter1_.isUnitStride(rank) 
+            && iter2_.isUnitStride(rank) 
+            && iter3_.isUnitStride(rank);
+    }
+
+    void advanceUnitStride()
+    {
+        iter1_.advanceUnitStride();
+        iter2_.advanceUnitStride();
+        iter3_.advanceUnitStride();
+    }
+
+    _bz_bool canCollapse(int outerLoopRank, int innerLoopRank) const
+    {
+        // BZ_DEBUG_MESSAGE("_bz_ArrayExprOp<>::canCollapse");
+        return iter1_.canCollapse(outerLoopRank, innerLoopRank)
+            && iter2_.canCollapse(outerLoopRank, innerLoopRank)
+            && iter3_.canCollapse(outerLoopRank, innerLoopRank);
+    }
+
+    template<int N_rank>
+    void moveTo(const TinyVector<int,N_rank>& i)
+    {
+        iter1_.moveTo(i);
+        iter2_.moveTo(i);
+        iter3_.moveTo(i);
+    }
+
+    T_numtype operator[](int i)
+    { return iter1_[i] ? iter2_[i] : iter3_[i]; }
+
+    T_numtype fastRead(int i)
+    { return iter1_.fastRead(i) ? iter2_.fastRead(i) : iter3_.fastRead(i); }
+
+    int suggestStride(int rank) const
+    {
+        int stride1 = iter1_.suggestStride(rank);
+        int stride2 = iter2_.suggestStride(rank);
+        int stride3 = iter3_.suggestStride(rank);
+        return max(max(stride1,stride2),stride3);
+    }
+
+    _bz_bool isStride(int rank, int stride) const
+    {
+        return iter1_.isStride(rank,stride) 
+            && iter2_.isStride(rank,stride)
+            && iter3_.isStride(rank,stride);
+    }
+
+    void prettyPrint(string& str, prettyPrintFormat& format) const
+    {
+        str += "[WHERE]";
+        // NEEDS_WORK
+    }
+
+    template<class T_shape>
+    _bz_bool shapeCheck(const T_shape& shape)
+    { 
+        return iter1_.shapeCheck(shape) 
+            && iter2_.shapeCheck(shape)
+            && iter3_.shapeCheck(shape); 
+    }
+
+private:
+    _bz_ArrayWhere() { }
+
+    T_expr1 iter1_;
+    T_expr2 iter2_;
+    T_expr3 iter3_;
+};
+
+template<class T1, class T2, class T3>
+inline
+_bz_ArrayExpr<_bz_ArrayWhere<_bz_typename asExpr<T1>::T_expr,
+    _bz_typename asExpr<T2>::T_expr, _bz_typename asExpr<T3>::T_expr> >
+where(const T1& a, const T2& b, const T3& c)
+{
+    return _bz_ArrayExpr<_bz_ArrayWhere<_bz_typename asExpr<T1>::T_expr,
+       _bz_typename asExpr<T2>::T_expr, 
+       _bz_typename asExpr<T3>::T_expr> >(a,b,c);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYWHERE_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/array/zip.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/array/zip.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/array/zip.h	(revision 1307)
@@ -0,0 +1,46 @@
+#ifndef BZ_ARRAYZIP_H
+#define BZ_ARRAYZIP_H
+
+#ifndef BZ_ARRAY_H
+ #error <blitz/array/zip.h> must be included via <blitz/array.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_component, class T1, class T2>
+struct Zip2 {
+    typedef P_component T_numtype;
+
+    static inline T_numtype apply(T1 a, T2 b)
+    { return T_numtype(a,b); }
+
+    template<class T_left, class T_right>
+    static inline void prettyPrint(string& str,
+        prettyPrintFormat& format, const T_left& t1,
+        const T_right& t2)
+    {
+        str += "zip(";
+        t1.prettyPrint(str, format);
+        str += ",";
+        t2.prettyPrint(str, format);
+        str += ")";
+    }
+};
+
+template<class T_component, class T1, class T2>
+inline _bz_ArrayExpr<_bz_ArrayExprOp<_bz_typename asExpr<T1>::T_expr, 
+    _bz_typename asExpr<T2>::T_expr, Zip2<T_component, 
+    _bz_typename asExpr<T1>::T_expr::T_numtype,
+    _bz_typename asExpr<T2>::T_expr::T_numtype> > >
+zip(const T1& a, const T2& b, T_component)
+{
+    return _bz_ArrayExpr<_bz_ArrayExprOp<_bz_typename asExpr<T1>::T_expr,
+        _bz_typename asExpr<T2>::T_expr, Zip2<T_component, 
+        _bz_typename asExpr<T1>::T_expr::T_numtype,
+        _bz_typename asExpr<T2>::T_expr::T_numtype> > >(a,b);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ARRAYZIP_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/bench.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/bench.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/bench.cc	(revision 1307)
@@ -0,0 +1,189 @@
+/*
+ * $Id: bench.cc,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_BENCH_CC
+#define BZ_BENCH_CC
+
+#ifndef BZ_BENCH_H
+ #error <blitz/bench.cc> must be included via <blitz/bench.h>
+#endif
+
+#ifdef BZ_HAVE_STD
+ #include <fstream>
+#else
+ #include <fstream.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_parameter>
+Benchmark<P_parameter>::Benchmark(unsigned numImplementations)
+{
+    state_ = uninitialized;
+    numImplementations_ = numImplementations;
+    numStoredImplementations_ = 0;
+    implementations_ = new BenchmarkImplementation<P_parameter>* [numImplementations_];
+    rates_.resize(numImplementations, numParameterSettings());
+    Mflops_.resize(numImplementations, numParameterSettings());
+}
+
+template<class P_parameter>
+Benchmark<P_parameter>::~Benchmark()
+{
+    delete [] implementations_;
+}
+
+template<class P_parameter>
+void Benchmark<P_parameter>::addImplementation(
+    BenchmarkImplementation<P_parameter> * implementation)
+{
+    BZPRECONDITION(state_ == uninitialized);
+    BZPRECONDITION(numStoredImplementations_ < numImplementations_);
+
+    implementations_[numStoredImplementations_++] = implementation;
+
+    if (numStoredImplementations_ == numImplementations_)
+        state_ = initialized;
+}
+
+template<class P_parameter>
+void Benchmark<P_parameter>::run(ostream& log)
+{
+    BZPRECONDITION(state_ == initialized);
+    state_ = running;
+
+    Timer t;
+
+    for (unsigned j=0; j < numImplementations_; ++j)
+    {
+        for (unsigned i=0; i < numParameterSettings(); ++i)
+        {
+            log  << setw(20) << implementations_[j]->implementationName()
+                 << " " << setw(8) << getParameterSetting(i) << "  ";
+            log.flush();
+
+            implementations_[j]->initialize(getParameterSetting(i));
+            implementations_[j]->tickle();
+
+            unsigned long iterations = getIterationSetting(i);
+
+            t.start();
+            implementations_[j]->run(iterations);
+            t.stop();
+            double tm = t.elapsedSeconds();
+
+            t.start();
+            implementations_[j]->runOverhead(iterations);
+            t.stop();
+            double tmOverhead = t.elapsedSeconds();
+
+            rates_(j,i) = iterations / (tm - tmOverhead);
+            Mflops_(j,i) = rates_(j,i) 
+                * implementations_[j]->flopsPerIteration() / 1.0e+6;
+
+            log << setw(10) << (rates_(j,i)/1.0e+6) << " Mops/s ";
+
+            if (implementations_[j]->flopsPerIteration() != 0)
+            {
+                log << "[" << setw(7) << Mflops_(j,i) << " Mflops]";
+            }
+
+            log << endl;
+            log.flush();
+
+            implementations_[j]->done();
+        }
+    }
+
+    state_ = done;
+}
+
+template<class P_parameter>
+double Benchmark<P_parameter>::getMflops(unsigned implementation, 
+    unsigned setting) const
+{
+    BZPRECONDITION(state_ == done);
+    BZPRECONDITION(implementation < numImplementations_);
+    BZPRECONDITION(setting < numParameterSettings());
+
+    return Mflops_(implementation, setting);
+}
+
+template<class P_parameter>
+double Benchmark<P_parameter>::getRate(unsigned implementation,  
+    unsigned setting) const
+{
+    BZPRECONDITION(state_ == done);
+    BZPRECONDITION(implementation < numImplementations_);
+    BZPRECONDITION(setting < numParameterSettings());
+
+    return rates_(implementation, setting);
+}
+
+template<class P_parameter>
+void Benchmark<P_parameter>::saveMatlabGraph(const char* filename) const
+{
+    BZPRECONDITION(state_ == done);
+
+    ofstream ofs(filename);
+     
+    assert(ofs.good());
+
+    ofs << "% This matlab file generated automatically by class Benchmark"
+        << endl << "% of the Blitz++ class library." << endl << endl;
+
+    ofs.setf(ios::scientific);
+
+    ofs << "parm = [ ";
+    int i;
+    for (i=0; i < numParameterSettings(); ++i)
+        ofs << setprecision(12) << double(getParameterSetting(i)) << " ";
+    ofs << "]; " << endl << endl;
+
+    ofs << "Mf = [ ";
+    for (i=0; i < numParameterSettings(); ++i)
+    {
+        for (int j=0; j < numImplementations_; ++j)
+        {
+            ofs << setprecision(12) << getMflops(j,i) << " ";
+        }
+        if (i != numParameterSettings()-1)
+            ofs << ";" << endl;
+    }
+    ofs << "] ;" << endl << endl;
+
+    ofs << "semilogx(parm,Mf), title('" << description() << "'), " << endl
+        << "    xlabel('" << parameterDescription() << "'), "
+        << "ylabel('Mflops')" << endl
+        << "legend(";
+    
+    for (int j=0; j < numImplementations_; ++j)
+    {
+        ofs << "'" << implementations_[j]->implementationName()
+            << "'";
+        if (j != numImplementations_ - 1)
+            ofs << ", ";
+    } 
+
+    ofs << ")" << endl;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_BENCH_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/bench.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/bench.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/bench.h	(revision 1307)
@@ -0,0 +1,147 @@
+/***************************************************************************
+ * blitz/bench.h      Benchmark classes
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:30:34  tveldhui
+ * Prior to rewrite of Bench class; in this version, Bench contains
+ * each benchmark implementation.
+ *
+ */
+
+#ifndef BZ_BENCH_H
+#define BZ_BENCH_H
+
+#ifndef BZ_MATRIX_H
+ #include <blitz/matrix.h>
+#endif
+
+#ifndef BZ_TIMER_H
+ #include <blitz/timer.h>
+#endif
+
+#include <math.h>
+
+BZ_NAMESPACE(blitz)
+
+// Forward declaration
+template<class P_parameter = unsigned>
+class BenchmarkImplementation;
+
+
+// Declaration of class Benchmark<T>
+// The template parameter T is the parameter type which is varied in
+// the benchmark.  Typically T will be an unsigned, and will represent
+// the length of a vector, size of an array, etc.
+
+template<class P_parameter = unsigned>
+class Benchmark {
+
+public:
+    typedef P_parameter T_parameter;
+
+    Benchmark(unsigned numImplementations);
+
+    ~Benchmark();
+
+    void addImplementation(BenchmarkImplementation<T_parameter>* 
+        implementation);
+
+    void run(ostream& log = cout);
+
+    double getMflops(unsigned implementation, unsigned setting) const;
+
+    double getRate(unsigned implementation, unsigned setting) const;
+
+    void saveMatlabGraph(const char* filename) const;
+
+public:
+    // Virtual functions
+
+    virtual const char* description() const
+    { return ""; }
+
+    virtual const char* parameterDescription() const
+    { return "Vector length"; }
+
+    virtual unsigned numParameterSettings() const
+    { return 19; }
+
+    virtual T_parameter getParameterSetting(unsigned i) const
+    { return ::pow(10.0, (i+1)/4.0); }
+
+    virtual long getIterationSetting(unsigned i) const
+    { return 1000000L / getParameterSetting(i); }
+
+private:
+    Benchmark(const Benchmark<P_parameter>&) { }
+    void operator=(const Benchmark<P_parameter>&) { }
+
+    enum { uninitialized, initialized, running, done } state_;
+
+    unsigned numImplementations_;
+    unsigned numStoredImplementations_;
+
+    BenchmarkImplementation<T_parameter>** implementations_;
+
+    Matrix<double,RowMajor> rates_;       // Iterations per second array
+    Matrix<double,RowMajor> Mflops_;
+};
+
+template<class P_parameter>
+class BenchmarkImplementation {
+
+public:
+    typedef P_parameter T_parameter;
+
+    virtual void initialize(P_parameter parameter) { }
+
+    virtual void done() { }
+
+    virtual const char* implementationName() const
+    { return ""; }
+
+    virtual void run(long iterations) = 0;
+
+    virtual void runOverhead(long iterations) 
+    { 
+        for (long i=0; i < iterations; ++i)
+        {
+        }
+    };
+
+    virtual void tickle() { }
+
+    virtual long flopsPerIteration() const
+    { return 0; }
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/bench.cc>  
+
+#endif // BZ_BENCH_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/benchext.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/benchext.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/benchext.cc	(revision 1307)
@@ -0,0 +1,307 @@
+/*
+ * $Id: benchext.cc,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_BENCHEXT_CC
+#define BZ_BENCHEXT_CC
+
+#ifndef BZ_BENCHEXT_H
+ #error <blitz/benchext.cc> must be included via <blitz/benchext.h>
+#endif
+
+#ifdef BZ_HAVE_STD
+ #include <fstream>
+#else
+ #include <fstream.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_parameter>
+BenchmarkExt<P_parameter>::BenchmarkExt(const char* name, 
+    int numImplementations)
+{
+    BZPRECONDITION(numImplementations > 0);
+
+    description_ = name;
+    numImplementations_ = numImplementations;
+
+    implementationDescriptions_.resize(numImplementations);
+    parameterDescription_ = "Vector length";
+    rateDescription_ = "Mflops/s";
+
+    // Set up default parameters and iterations
+    setNumParameters(19);
+
+    // NEEDS_WORK: once pow(X,Y) is supported, can just say
+    // parameters_ = pow(10.0, Range(1,20)/4.0);
+
+    for (int i=0; i < numParameters_; ++i)
+        parameters_[i] = (P_parameter)::pow(10.0, (i+1)/4.0);
+
+    iterations_ = 5.0e+5 / parameters_;
+    flopsPerIteration_ = parameters_;
+
+    // Set up initial state
+    state_ = initializing;
+    implementationNumber_ = 0;
+}
+
+template<class P_parameter>
+BenchmarkExt<P_parameter>::~BenchmarkExt()
+{
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::setNumParameters(int numParameters)
+{
+    BZPRECONDITION(state_ == initializing);
+
+    numParameters_ = numParameters;
+
+    parameters_.resize(numParameters_);
+    iterations_.resize(numParameters_);
+    flopsPerIteration_.resize(numParameters_);
+
+    // Set up timer and Mflops array
+    times_.resize(numImplementations_, numParameters_);
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::setParameterVector(Vector<P_parameter> parms)
+{
+    BZPRECONDITION(state_ == initializing);
+    BZPRECONDITION(parms.length() == parameters_.length());
+
+    // NEEDS_WORK: should use operator=(), once that problem
+    // gets sorted out.
+    // parameters_ = parms;
+    for (int i=0; i < parameters_.length(); ++i)
+        parameters_[i] = parms(i);
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::setParameterDescription(const char* string)
+{
+    parameterDescription_ = string;
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::setIterations(Vector<long> iters)
+{
+    BZPRECONDITION(state_ == initializing);
+
+    // NEEDS_WORK: should use operator=(), once that problem
+    // gets sorted out.
+    // iterations_ = iters;
+
+    for (int i=0; i < iterations_.length(); ++i)
+        iterations_[i] = iters(i);
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::setFlopsPerIteration(Vector<double> 
+    flopsPerIteration)
+{
+    BZPRECONDITION(flopsPerIteration_.length() == flopsPerIteration.length());
+
+    // NEEDS_WORK: should use operator=(), once that problem
+    // gets sorted out.
+    // flopsPerIteration_ = flopsPerIteration;
+
+    for (int i=0; i < flopsPerIteration_.length(); ++i)
+        flopsPerIteration_[i] = flopsPerIteration[i];
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::setRateDescription(const char* string)
+{
+    rateDescription_ = string;
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::beginBenchmarking()
+{
+    BZPRECONDITION(state_ == initializing);
+    state_ = benchmarking;
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::beginImplementation(const char* description)
+{
+    BZPRECONDITION(implementationNumber_ < numImplementations_);
+    BZPRECONDITION(state_ == benchmarking);
+
+    implementationDescriptions_[implementationNumber_] = description;
+
+    state_ = benchmarkingImplementation;
+    parameterNumber_ = 0;
+}
+
+template<class P_parameter>
+_bz_bool BenchmarkExt<P_parameter>::doneImplementationBenchmark() const
+{
+    BZPRECONDITION(state_ == benchmarkingImplementation);
+    return parameterNumber_ == numParameters_;
+}
+
+template<class P_parameter>
+P_parameter BenchmarkExt<P_parameter>::getParameter() const
+{
+    BZPRECONDITION(state_ == benchmarkingImplementation);
+    BZPRECONDITION(parameterNumber_ >= 0);
+    BZPRECONDITION(parameterNumber_ < numParameters_);
+
+    return parameters_[parameterNumber_];
+}
+
+template<class P_parameter>
+long BenchmarkExt<P_parameter>::getIterations() const
+{
+    BZPRECONDITION(state_ == benchmarkingImplementation);
+    BZPRECONDITION(parameterNumber_ >= 0);
+    BZPRECONDITION(parameterNumber_ < numParameters_);
+
+    return iterations_[parameterNumber_];
+}
+
+template<class P_parameter>
+inline void BenchmarkExt<P_parameter>::start()
+{
+    BZPRECONDITION(state_ == benchmarkingImplementation);
+    BZPRECONDITION(parameterNumber_ < numParameters_);
+    state_ = running;
+    timer_.start();
+}
+
+template<class P_parameter>
+inline void BenchmarkExt<P_parameter>::stop()
+{
+    timer_.stop();
+    BZPRECONDITION(state_ == running);
+    state_ = benchmarkingImplementation;
+    
+    times_(implementationNumber_, parameterNumber_) = timer_.elapsedSeconds();
+
+    ++parameterNumber_;
+}
+
+template<class P_parameter>
+inline void BenchmarkExt<P_parameter>::startOverhead()
+{
+    BZPRECONDITION(state_ == benchmarkingImplementation);
+    BZPRECONDITION(parameterNumber_ > 0);
+    BZPRECONDITION(parameterNumber_ <= numParameters_);
+    state_ = runningOverhead;
+    overheadTimer_.start();
+}
+
+template<class P_parameter>
+inline void BenchmarkExt<P_parameter>::stopOverhead()
+{
+    BZPRECONDITION(state_ == runningOverhead);
+    overheadTimer_.stop();
+    times_(implementationNumber_, parameterNumber_-1) -= 
+        overheadTimer_.elapsedSeconds();
+
+    state_ = benchmarkingImplementation;
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::endImplementation()
+{
+    BZPRECONDITION(state_ == benchmarkingImplementation);
+    BZPRECONDITION(parameterNumber_ == numParameters_);
+
+    ++implementationNumber_;
+
+    state_ = benchmarking;
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::endBenchmarking()
+{
+    BZPRECONDITION(state_ == benchmarking);
+    BZPRECONDITION(implementationNumber_ == numImplementations_);
+    
+    state_ = done;
+}
+
+template<class P_parameter>
+double BenchmarkExt<P_parameter>::getMflops(unsigned implementation,
+    unsigned parameterNum) const
+{
+    BZPRECONDITION(state_ == done);
+    BZPRECONDITION(implementation < numImplementations_);
+    BZPRECONDITION(parameterNum < numParameters_);
+    return iterations_(parameterNum) * flopsPerIteration_(parameterNum)
+        / times_(implementation, parameterNum) / 1.0e+6;
+}
+
+template<class P_parameter>
+void BenchmarkExt<P_parameter>::saveMatlabGraph(const char* filename) const
+{
+    BZPRECONDITION(state_ == done);
+
+    ofstream ofs(filename);
+     
+    assert(ofs.good());
+
+    ofs << "% This matlab file generated automatically by class Benchmark"
+        << endl << "% of the Blitz++ class library." << endl << endl;
+
+    ofs.setf(ios::scientific);
+
+    // This will be a lot simpler once Matlab-style output formatting
+    // of vectors & matrices is finished.
+
+    // ofs << "parm = " << parameters_ << ";" << endl << endl;
+
+    ofs << "parm = [ ";
+    int i;
+    for (i=0; i < numParameters_; ++i)
+        ofs << setprecision(12) << double(parameters_[i]) << " ";
+    ofs << "]; " << endl << endl;
+
+    ofs << "Mf = [ ";
+    for (i=0; i < numParameters_; ++i)
+    {
+        for (int j=0; j < numImplementations_; ++j)
+        {
+            ofs << setprecision(12) << getMflops(j,i) << " ";
+        }
+        if (i != numParameters_ - 1)
+            ofs << ";" << endl;
+    }
+    ofs << "] ;" << endl << endl;
+
+    ofs << "semilogx(parm,Mf), title('" << description_ << "'), " << endl
+        << "    xlabel('" << parameterDescription_ << "'), "
+        << "ylabel('" << rateDescription_ << "')" << endl
+        << "legend(";
+    
+    for (int j=0; j < numImplementations_; ++j)
+    {
+        ofs << "'" << implementationDescriptions_(j) << "'";
+        if (j != numImplementations_ - 1)
+            ofs << ", ";
+    } 
+
+    ofs << ")" << endl;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_BENCHEXT_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/benchext.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/benchext.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/benchext.h	(revision 1307)
@@ -0,0 +1,129 @@
+/***************************************************************************
+ * blitz/benchext.h      BenchmarkExt classes (Benchmarks with external
+ *                       control)
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_BENCHEXT_H
+#define BZ_BENCHEXT_H
+
+#ifndef BZ_MATRIX_H
+ #include <blitz/matrix.h>
+#endif
+
+#ifndef BZ_TIMER_H
+ #include <blitz/timer.h>
+#endif
+
+#include <math.h>
+
+// NEEDS_WORK: replace use of const char* with <string>, once standard
+// library is widely supported.
+
+BZ_NAMESPACE(blitz)
+
+// Declaration of class BenchmarkExt<T>
+// The template parameter T is the parameter type which is varied in
+// the benchmark.  Typically T will be an unsigned, and will represent
+// the length of a vector, size of an array, etc.
+
+template<class P_parameter = unsigned>
+class BenchmarkExt {
+
+public:
+    typedef P_parameter T_parameter;
+
+    BenchmarkExt(const char* description, int numImplementations);
+
+    ~BenchmarkExt();
+
+    void setNumParameters(int numParameters);
+    void setParameterVector(Vector<T_parameter> parms);
+    void setParameterDescription(const char* string);
+    void setIterations(Vector<long> iters);
+    void setFlopsPerIteration(Vector<double> flopsPerIteration);
+    void setRateDescription(const char* string);
+
+    void beginBenchmarking();
+
+    void beginImplementation(const char* description);
+
+    _bz_bool doneImplementationBenchmark() const;
+
+    T_parameter getParameter() const;
+    long        getIterations() const;
+
+    inline void start();
+    inline void stop();
+
+    void startOverhead();
+    void stopOverhead();
+
+    void endImplementation();
+
+    void endBenchmarking();
+ 
+    double getMflops(unsigned implementation, unsigned parameterNum) const;
+
+    void saveMatlabGraph(const char* filename) const;
+
+protected:
+    BenchmarkExt(const BenchmarkExt<P_parameter>&) { }
+    void operator=(const BenchmarkExt<P_parameter>&) { }
+
+    enum { initializing, benchmarking, benchmarkingImplementation, 
+       running, runningOverhead, done } state_;
+
+    unsigned numImplementations_;
+    unsigned implementationNumber_;
+
+    const char* description_;
+    Vector<const char*> implementationDescriptions_;
+
+    Matrix<double,RowMajor> times_;       // Elapsed time
+
+    Vector<T_parameter> parameters_;
+    Vector<long> iterations_;
+    Vector<double> flopsPerIteration_;
+
+    Timer timer_;
+    Timer overheadTimer_;
+
+    const char* parameterDescription_;
+    const char* rateDescription_;
+
+    int numParameters_;
+    int parameterNumber_;
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/benchext.cc>  
+
+#endif // BZ_BENCHEXT_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/blitz.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/blitz.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/blitz.h	(revision 1307)
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * blitz/blitz.h      Includes all the important header files
+ *
+ * $Id: blitz.h,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ * 
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com    
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.7  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.6  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.5  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.4  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1996/11/11 17:29:13  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1996/04/14  21:13:00  todd
+ * Initial revision
+ *
+ */
+
+#ifndef BZ_BLITZ_H
+#define BZ_BLITZ_H
+
+/*
+ * These symbols allow use of the IEEE and System V math libraries
+ * (libm.a and libmsaa.a) on some platforms.
+ */
+
+#ifndef BZ_DISABLE_XOPEN_SOURCE
+ #ifndef _ALL_SOURCE
+  #define _ALL_SOURCE
+ #endif
+ #ifndef _XOPEN_SOURCE
+  #define _XOPEN_SOURCE
+ #endif
+ #ifndef _XOPEN_SOURCE_EXTENDED
+  #define _XOPEN_SOURCE_EXTENDED 1
+ #endif
+#endif
+
+#include <blitz/compiler.h>          // Compiler-specific directives
+#include <blitz/tuning.h>            // Performance tuning
+#include <blitz/tau.h>               // Profiling
+
+#include <string>
+#include <stdio.h>                   // sprintf, etc.
+
+#ifdef BZ_HAVE_STD
+  #include <iostream>
+  #include <iomanip>
+  #include <cmath>
+#else
+  #include <iostream.h>
+  #include <iomanip.h>
+#endif
+
+#include <math.h>
+
+#ifdef BZ_HAVE_COMPLEX
+  #include <complex>
+#endif
+
+#define BZ_THROW                     // Needed in <blitz/numinquire.h>
+
+BZ_NAMESPACE(blitz)
+
+#ifdef BZ_HAVE_STD
+ BZ_USING_NAMESPACE(std)
+#endif
+
+#ifdef BZ_GENERATE_GLOBAL_INSTANCES
+ #define _bz_global
+ #define BZ_GLOBAL_INIT(X)   =X
+#else
+ #define _bz_global extern
+ #define BZ_GLOBAL_INIT(X) 
+#endif
+
+BZ_NAMESPACE_END
+
+#include <blitz/bzdebug.h>           // Debugging macros
+
+#endif // BZ_BLITZ_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/bzdebug.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/bzdebug.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/bzdebug.h	(revision 1307)
@@ -0,0 +1,238 @@
+/***************************************************************************
+ * blitz/bzdebug.h      Debugging macros
+ *
+ * $Id: bzdebug.h,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.7  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.6  1998/02/26 18:09:36  tveldhui
+ * Added testsuite support for precondition fail checking
+ *
+ * Revision 1.5  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.4  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1996/11/11 17:29:13  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1996/04/14  12:36:45  todd
+ * Initial revision
+ *
+ *
+ */
+
+#ifndef BZ_DEBUG_H
+#define BZ_DEBUG_H
+
+#include <stdlib.h>
+#include <assert.h>
+
+#ifdef BZ_RTTI
+ #include <typeinfo>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * These globals are used by the Blitz++ testsuite.  The _bz_global 
+ * modifier ensures that they will reside in libblitz.a, but appear
+ * "extern" elsewhere.
+ */
+
+_bz_global _bz_bool assertFailMode     BZ_GLOBAL_INIT(_bz_false);
+_bz_global int      assertFailCount    BZ_GLOBAL_INIT(0);
+_bz_global int      assertSuccessCount BZ_GLOBAL_INIT(0);
+
+
+#ifdef BZ_TESTSUITE
+  /*
+   * In testsuite mode, these routines allow a test suite to check
+   * that precondition checking is being done properly.  A typical
+   * use looks like this:
+   *
+   * beginCheckAssert();
+   *   // Some operation which should cause an assert to fail
+   * endCheckAssert();
+   *
+   * The routine beginCheckAssert() sets a flag which results in
+   * failed asserts being silently tallied.  If no asserts have
+   * failed by the time endCheckAssert() is invoked, the program
+   * halts and issues an error code.
+   *
+   * In normal operation (i.e. when beginCheckAssert() has not
+   * been called), failed preconditions will cause the program
+   * to halt and issue an error code.   -- TV 980226
+   */
+
+  inline void checkAssert(_bz_bool condition, const char* where=0, 
+    int line=0)
+  {
+    if (assertFailMode == _bz_true)
+    {
+      if (condition == _bz_true)
+        ++assertSuccessCount;
+      else
+        ++assertFailCount;
+    }
+    else {
+      if (!condition)
+      {
+        cerr << "Unexpected assert failure!" << endl;
+        if (where)
+            cerr << where << ":" << line << endl;
+        cerr.flush();
+        assert(0);
+      }
+    }
+  }
+
+  inline void beginCheckAssert()
+  {
+    assertFailMode = _bz_true;
+    assertSuccessCount = 0;
+    assertFailCount = 0;
+  }
+
+  inline void endCheckAssert()
+  {
+    assert(assertFailMode == _bz_true);
+    assertFailMode = _bz_false;
+    if (assertFailCount == 0)
+    {
+      cerr << "Assert check failed!" << endl;
+      assert(0);
+    }
+  }
+
+    #define BZASSERT(X)        checkAssert(X, __FILE__, __LINE__)
+    #define BZPRECONDITION(X)  checkAssert(X, __FILE__, __LINE__)
+    #define BZPOSTCONDITION(X) checkAssert(X, __FILE__, __LINE__)
+    #define BZSTATECHECK(X,Y)  checkAssert(X == Y, __FILE__, __LINE__)
+    #define BZPRECHECK(X,Y)                                    \
+        {                                                      \
+            if ((assertFailMode == _bz_false) && (!(X)))       \
+                cerr << Y << endl;                             \
+            checkAssert(X, __FILE__, __LINE__);                \
+        }
+
+    #define BZ_DEBUG_MESSAGE(X) \
+        { if (assertFailMode == _bz_false) { cout << __FILE__ << ":" << __LINE__ << " " << X << endl; } }
+
+    #define BZ_PRE_FAIL        checkAssert(0)
+#else 
+#ifdef BZ_DEBUG
+    #define BZASSERT(X)        assert(X)
+    #define BZPRECONDITION(X)  assert(X)
+    #define BZPOSTCONDITION(X) assert(X)
+    #define BZSTATECHECK(X,Y)  assert(X == Y)
+    #define BZPRECHECK(X,Y)        \
+        { if (!(X))                                                           \
+          { cerr << "[Blitz++] Precondition failure: Module " << __FILE__   \
+               << " line " << __LINE__ << endl                              \
+               << Y << endl;                                                \
+            cerr.flush();                                                   \
+            assert(0);                                                      \
+          }                                                                 \
+        }
+
+    #define BZ_PRE_FAIL      assert(0)
+
+    #define BZ_DEBUG_MESSAGE(X) \
+        { cout << __FILE__ << ":" << __LINE__ << " " << X << endl; }
+
+    void _bz_debug_marker();
+    #define BZ_ASM_DEBUG_MARKER   _bz_debug_marker();
+#else   // !BZ_DEBUG
+    #define BZASSERT(X)
+    #define BZPRECONDITION(X)
+    #define BZPOSTCONDITION(X)
+    #define BZSTATECHECK(X,Y)
+    #define BZPRECHECK(X,Y)
+    #define BZ_PRE_FAIL
+    #define BZ_DEBUG_MESSAGE(X)
+#endif  // !BZ_DEBUG
+#endif  // !BZ_TESTSUITE
+
+// This routine doesn't exist anywhere; it's used to mark a
+// position of interest in assembler (.s) files
+void _bz_debug_marker();
+
+#define BZ_NOT_IMPLEMENTED()   { cerr << "[Blitz++] Not implemented: module " \
+    << __FILE__ << " line " << __LINE__ << endl;                \
+    exit(1); }
+
+#ifdef BZ_RTTI
+#define BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(X)  typeid(X).name()
+#else
+
+template<class T>
+class _bz_stringLiteralForNumericType {
+public:
+    static const char* string()
+    { return "unknown"; }
+};
+
+#define BZ_DECL_SLFNT(X,Y) \
+ template<>                 \
+ class _bz_stringLiteralForNumericType< X > {  \
+ public:                                       \
+     static const char* string()               \
+     { return Y; }                             \
+ }
+
+#ifdef BZ_BOOL
+BZ_DECL_SLFNT(bool, "bool");
+#endif
+
+BZ_DECL_SLFNT(char, "char");
+BZ_DECL_SLFNT(unsigned char, "unsigned char");
+BZ_DECL_SLFNT(short int, "short int");
+BZ_DECL_SLFNT(short unsigned int, "short unsigned int");
+BZ_DECL_SLFNT(int, "int");
+BZ_DECL_SLFNT(unsigned int, "unsigned int");
+BZ_DECL_SLFNT(long, "long");
+BZ_DECL_SLFNT(unsigned long, "unsigned long");
+BZ_DECL_SLFNT(float, "float");
+BZ_DECL_SLFNT(double, "double");
+BZ_DECL_SLFNT(long double, "long double");
+
+#ifdef BZ_HAVE_COMPLEX
+BZ_DECL_SLFNT(complex<float>, "complex<float>");
+BZ_DECL_SLFNT(complex<double>, "complex<double>");
+BZ_DECL_SLFNT(complex<long double>, "complex<long double>");
+#endif
+
+#define BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(X) \
+    _bz_stringLiteralForNumericType<X>::string()
+
+#endif // !BZ_RTTI
+
+BZ_NAMESPACE_END
+
+#endif // BZ_DEBUG_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/compiler.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/compiler.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/compiler.h	(revision 1307)
@@ -0,0 +1,166 @@
+/***************************************************************************
+ * blitz/compiler.h      Compiler specific directives and kludges
+ *
+ * $Id: compiler.h,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.7  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.6  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.5  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.4  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1996/11/11 17:29:13  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+
+#ifndef BZ_COMPILER_H
+#define BZ_COMPILER_H
+
+// The file <blitz/config.h> is generated automatically by the
+// script 'bzconfig', located in the 'compiler' directory.
+
+#include <blitz/config.h>
+
+/*
+ * Define some kludges.
+ */
+
+#ifndef BZ_TEMPLATES
+    #error  In <blitz/config.h>: A working template implementation is required by Blitz++ (you may need to rerun the compiler/bzconfig script)
+#endif
+
+#ifndef BZ_MEMBER_TEMPLATES
+  #error  In <blitz/config.h>: Your compiler does not support member templates.  (you may need to rerun the compiler/bzconfig script)
+#endif
+
+#ifndef BZ_FULL_SPECIALIZATION_SYNTAX
+  #error In <blitz/config.h>: Your compiler does not support template<> full specialization syntax.  You may need to rerun the compiler/bzconfig script.
+#endif
+
+#ifndef BZ_PARTIAL_ORDERING
+  #error In <blitz/config.h>: Your compiler does not support partial ordering (you may need to rerun the compiler/bzconfig script)
+#endif
+
+#ifndef BZ_PARTIAL_SPECIALIZATION
+  #error In <blitz/config.h>: Your compiler does not support partial specialization (you may need to rerun the compiler/bzconfig script)
+#endif
+
+#ifdef BZ_NAMESPACES
+    #define BZ_NAMESPACE(X)        namespace X {
+    #define BZ_NAMESPACE_END       }
+    #define BZ_USING_NAMESPACE(X)  using namespace X;
+#else
+    #define BZ_NAMESPACE(X)
+    #define BZ_NAMESPACE_END
+    #define BZ_USING_NAMESPACE(X)
+#endif
+
+#ifdef BZ_TEMPLATE_QUALIFIED_RETURN_TYPE
+  #define BZ_USE_NUMTRAIT
+#endif
+
+#ifdef BZ_DEFAULT_TEMPLATE_PARAMETERS
+    #define BZ_TEMPLATE_DEFAULT(X)   = X
+#else
+    #define BZ_TEMPLATE_DEFAULT
+#endif
+
+#ifdef BZ_EXPLICIT
+    #define _bz_explicit     explicit
+#else
+    #define _bz_explicit   
+#endif
+
+#ifdef BZ_TYPENAME
+    #define _bz_typename     typename
+#else
+    #define _bz_typename
+#endif
+
+#ifdef BZ_MUTABLE
+    #define _bz_mutable      mutable
+#else
+    #define _bz_mutable
+#endif
+
+#ifdef BZ_DISABLE_RESTRICT
+ #undef BZ_NCEG_RESTRICT
+#endif
+
+#ifdef BZ_NCEG_RESTRICT
+    #define _bz_restrict     restrict
+#else
+    #define _bz_restrict
+#endif
+
+#ifdef BZ_BOOL
+    #define _bz_bool         bool
+    #define _bz_true         true
+    #define _bz_false        false
+#else
+    #define _bz_bool         int
+    #define _bz_true         1
+    #define _bz_false        0
+#endif
+
+#ifdef BZ_ENUM_COMPUTATIONS_WITH_CAST
+    #define BZ_ENUM_CAST(X)   (int)X
+#elif defined(BZ_ENUM_COMPUTATIONS)
+    #define BZ_ENUM_CAST(X)   X
+#else
+    #error In <blitz/config.h>: Your compiler does not support enum computations.  You may have to rerun compiler/bzconfig.
+#endif
+
+#if defined(BZ_MATH_FN_IN_NAMESPACE_STD)
+  #define BZ_MATHFN_SCOPE(x) std::x
+#elif defined(BZ_NAMESPACES)
+  #define BZ_MATHFN_SCOPE(x) ::x
+#else
+  #define BZ_MATHFN_SCOPE(x) x
+#endif
+
+#if defined(BZ_COMPLEX_MATH_IN_NAMESPACE_STD)
+  #define BZ_CMATHFN_SCOPE(x) std::x
+#elif defined(BZ_NAMESPACES)
+  #define BZ_CMATHFN_SCOPE(x) ::x
+#else
+  #define BZ_CMATHFN_SCOPE(x) x
+#endif
+
+#if defined(BZ_NAMESPACES)
+  #define BZ_BLITZ_SCOPE(x) blitz::x
+#else
+  #define BZ_BLITZ_SCOPE(x) ::x
+#endif
+
+#endif // BZ_COMPILER_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/config-ICL.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/config-ICL.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/config-ICL.h	(revision 1307)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * config.h           Compiler language support flags
+ *
+ * This file was generated automatically by the script bzconfig.
+ * You should rerun bzconfig each time you switch compilers, install new
+ * standard libraries, or change compiler versions.
+ *
+ */
+
+// This configuration file is for the Intel C/C++ compiler which
+// comes with the VTune 2.4 cdrom.
+ 
+#ifndef BZ_CONFIG_H
+#define BZ_CONFIG_H
+ 
+#define BZ_COMPILER_NAME   "icl"
+#define BZ_COMPILER_OPTIONS ""
+#define BZ_OS_NAME         "Windows 95"
+#define BZ_BZCONFIG_DATE   "Thu Aug 21 09:00:00 EST 1997"
+ 
+#define BZ_NAMESPACES
+#define BZ_EXCEPTIONS
+#define BZ_RTTI
+#define BZ_MEMBER_CONSTANTS
+#undef  BZ_OLD_FOR_SCOPING
+#define BZ_EXPLICIT
+#define BZ_MUTABLE
+#define BZ_TYPENAME
+#undef  BZ_NCEG_RESTRICT
+#define BZ_BOOL
+#define BZ_CONST_CAST
+#define BZ_STATIC_CAST
+#define BZ_REINTERPRET_CAST
+#define BZ_DYNAMIC_CAST
+#define BZ_TEMPLATES
+#undef  BZ_PARTIAL_SPECIALIZATION
+#undef  BZ_PARTIAL_ORDERING
+#define BZ_DEFAULT_TEMPLATE_PARAMETERS
+#define BZ_MEMBER_TEMPLATES
+#define BZ_MEMBER_TEMPLATES_OUTSIDE_CLASS
+#define BZ_FULL_SPECIALIZATION_SYNTAX
+#define BZ_FUNCTION_NONTYPE_PARAMETERS
+#define BZ_TEMPLATE_QUALIFIED_BASE_CLASS
+#define BZ_TEMPLATE_QUALIFIED_RETURN_TYPE
+#undef  BZ_EXPLICIT_TEMPLATE_FUNCTION_QUALIFICATION
+#undef  BZ_TEMPLATES_AS_TEMPLATE_ARGUMENTS
+#undef  BZ_TEMPLATE_KEYWORD_QUALIFIER
+#undef  BZ_TEMPLATE_SCOPED_ARGUMENT_MATCHING
+#define BZ_TYPE_PROMOTION
+#define BZ_USE_NUMTRAIT
+#undef  BZ_HAVE_COMPLEX
+#define BZ_HAVE_NUMERIC_LIMITS
+#define BZ_HAVE_VALARRAY
+#undef  BZ_HAVE_COMPLEX_MATH
+#undef  BZ_HAVE_IEEE_MATH
+#undef  BZ_HAVE_SYSTEM_V_MATH
+#undef  BZ_HAVE_STD
+#undef  BZ_HAVE_RUSAGE
+ 
+#endif // BZ_CONFIG_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/config-KCC.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/config-KCC.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/config-KCC.h	(revision 1307)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * config.h           Compiler language support flags
+ *
+ * This file was generated automatically by the script bzconfig.
+ * You should rerun bzconfig each time you switch compilers, install new
+ * standard libraries, or change compiler versions.
+ *
+ */
+
+ 
+#ifndef BZ_CONFIG_H
+#define BZ_CONFIG_H
+ 
+#define BZ_COMPILER_NAME   "KCC"
+#define BZ_COMPILER_OPTIONS "-x --restrict"
+#define BZ_OS_NAME         "AIX 2"
+#define BZ_BZCONFIG_DATE   "Wed Jul 29 12:57:56 EDT 1998"
+#define BZ_PLATFORM        "powerpc-ibm-aix4.2.0.0"
+ 
+#define BZ_NAMESPACES
+#define BZ_EXCEPTIONS
+#define BZ_RTTI
+#define BZ_MEMBER_CONSTANTS
+#undef  BZ_OLD_FOR_SCOPING
+#define BZ_EXPLICIT
+#define BZ_MUTABLE
+#define BZ_TYPENAME
+#define BZ_NCEG_RESTRICT
+#define BZ_BOOL
+#define BZ_CONST_CAST
+#define BZ_STATIC_CAST
+#define BZ_REINTERPRET_CAST
+#define BZ_DYNAMIC_CAST
+#define BZ_TEMPLATES
+#define BZ_PARTIAL_SPECIALIZATION
+#define BZ_PARTIAL_ORDERING
+#define BZ_DEFAULT_TEMPLATE_PARAMETERS
+#define BZ_MEMBER_TEMPLATES
+#define BZ_MEMBER_TEMPLATES_OUTSIDE_CLASS
+#define BZ_FULL_SPECIALIZATION_SYNTAX
+#define BZ_FUNCTION_NONTYPE_PARAMETERS
+#define BZ_TEMPLATE_QUALIFIED_BASE_CLASS
+#define BZ_TEMPLATE_QUALIFIED_RETURN_TYPE
+#undef  BZ_EXPLICIT_TEMPLATE_FUNCTION_QUALIFICATION
+#undef  BZ_TEMPLATES_AS_TEMPLATE_ARGUMENTS
+#undef  BZ_TEMPLATE_KEYWORD_QUALIFIER
+#undef  BZ_TEMPLATE_SCOPED_ARGUMENT_MATCHING
+#define BZ_TYPE_PROMOTION
+#define BZ_USE_NUMTRAIT
+#define BZ_HAVE_COMPLEX
+#define BZ_HAVE_NUMERIC_LIMITS
+#define BZ_HAVE_VALARRAY
+#define BZ_HAVE_COMPLEX_MATH1
+#undef  BZ_HAVE_COMPLEX_MATH2
+#define BZ_HAVE_IEEE_MATH
+#define BZ_HAVE_SYSTEM_V_MATH
+#define BZ_MATH_FN_IN_NAMESPACE_STD
+#define BZ_COMPLEX_MATH_IN_NAMESPACE_STD
+#define BZ_HAVE_STD
+#define BZ_HAVE_STL
+#define BZ_HAVE_RUSAGE
+#define BZ_ENUM_COMPUTATIONS
+#define BZ_ENUM_COMPUTATIONS_WITH_CAST
+ 
+#endif // BZ_CONFIG_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/config-SC4.0.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/config-SC4.0.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/config-SC4.0.h	(revision 1307)
@@ -0,0 +1,54 @@
+// From: Doug Moore <dougm@rice.edu>
+// Organization: Rice University Computer Science
+// SC4.0 18 Oct 1995 C++ 4.1
+
+/******************************************************************************
+ * config.h           Compiler language support flags
+ *
+ * This file was generated automatically by the script bzconfig.
+ * You should rerun bzconfig each time you switch compilers, install new
+ * standard libraries, or change compiler versions.
+ *
+ */
+ 
+ 
+#ifndef BZ_CONFIG_H
+#define BZ_CONFIG_H
+ 
+#define BZ_COMPILER_NAME   "CC"
+#define BZ_OS_NAME         "SunOS 5.5"
+#define BZ_BZCONFIG_DATE   "Fri Nov  8 16:56:17 CST 1996"
+ 
+#undef  BZ_NAMESPACES
+#undef  BZ_EXCEPTIONS
+#undef  BZ_RTTI
+#undef  BZ_MEMBER_CONSTANTS
+#define BZ_OLD_FOR_SCOPING
+#undef  BZ_EXPLICIT
+#undef  BZ_MUTABLE
+#undef  BZ_TYPENAME
+#undef  BZ_NCEG_RESTRICT
+#undef  BZ_BOOL
+#undef  BZ_CONST_CAST
+#undef  BZ_STATIC_CAST
+#undef  BZ_REINTERPRET_CAST
+#undef  BZ_DYNAMIC_CAST
+#define BZ_TEMPLATES
+#undef  BZ_PARTIAL_SPECIALIZATION
+#undef  BZ_DEFAULT_TEMPLATE_PARAMETERS
+#undef  BZ_MEMBER_TEMPLATES
+#undef  BZ_MEMBER_TEMPLATES_OUTSIDE_CLASS
+#undef  BZ_FULL_SPECIALIZATION_SYNTAX
+#undef  BZ_FUNCTION_NONTYPE_PARAMETERS
+#undef  BZ_TEMPLATE_QUALIFIED_BASE_CLASS
+#undef  BZ_TEMPLATE_QUALIFIED_RETURN_TYPE
+#undef  BZ_EXPLICIT_TEMPLATE_FUNCTION_QUALIFICATION
+#undef  BZ_TEMPLATES_AS_TEMPLATE_ARGUMENTS
+#undef  BZ_TEMPLATE_KEYWORD_QUALIFIER
+#define BZ_TYPE_PROMOTION
+#undef  BZ_HAVE_COMPLEX
+#undef  BZ_HAVE_NUMERIC_LIMITS
+#undef  BZ_HAVE_VALARRAY
+ 
+#endif // BZ_CONFIG_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/config-egcs.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/config-egcs.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/config-egcs.h	(revision 1307)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * config.h           Compiler language support flags
+ *
+ * This file was generated automatically by the script bzconfig.
+ * You should rerun bzconfig each time you switch compilers, install new
+ * standard libraries, or change compiler versions.
+ *
+ */
+
+ 
+#ifndef BZ_CONFIG_H
+#define BZ_CONFIG_H
+ 
+#define BZ_COMPILER_NAME   "xgcc"
+#define BZ_COMPILER_OPTIONS "-I /home/tveldhui/software/egcs/include -B /home/tveldhui/software/egcs/include"
+#define BZ_OS_NAME         "AIX 2"
+#define BZ_BZCONFIG_DATE   "Mon Sep  8 13:14:14 EDT 1997"
+ 
+#undef  BZ_NAMESPACES
+#undef  BZ_EXCEPTIONS
+#define BZ_RTTI
+#define BZ_MEMBER_CONSTANTS
+#define BZ_OLD_FOR_SCOPING
+#define BZ_EXPLICIT
+#define BZ_MUTABLE
+#define BZ_TYPENAME
+#undef  BZ_NCEG_RESTRICT
+#define BZ_BOOL
+#define BZ_CONST_CAST
+#define BZ_STATIC_CAST
+#define BZ_REINTERPRET_CAST
+#define BZ_DYNAMIC_CAST
+#define BZ_TEMPLATES
+#define BZ_PARTIAL_SPECIALIZATION
+#undef  BZ_PARTIAL_ORDERING
+#define BZ_DEFAULT_TEMPLATE_PARAMETERS
+#undef  BZ_MEMBER_TEMPLATES
+#undef  BZ_MEMBER_TEMPLATES_OUTSIDE_CLASS
+#define BZ_FULL_SPECIALIZATION_SYNTAX
+#undef  BZ_FUNCTION_NONTYPE_PARAMETERS
+#define BZ_TEMPLATE_QUALIFIED_BASE_CLASS
+#define BZ_TEMPLATE_QUALIFIED_RETURN_TYPE
+#undef  BZ_EXPLICIT_TEMPLATE_FUNCTION_QUALIFICATION
+#undef  BZ_TEMPLATES_AS_TEMPLATE_ARGUMENTS
+#undef  BZ_TEMPLATE_KEYWORD_QUALIFIER
+#undef  BZ_TEMPLATE_SCOPED_ARGUMENT_MATCHING
+#define BZ_TYPE_PROMOTION
+#define BZ_USE_NUMTRAIT
+#undef  BZ_HAVE_COMPLEX
+#undef  BZ_HAVE_NUMERIC_LIMITS
+#undef  BZ_HAVE_VALARRAY
+#undef  BZ_HAVE_COMPLEX_MATH
+#define BZ_HAVE_IEEE_MATH
+#define BZ_HAVE_SYSTEM_V_MATH
+#undef  BZ_HAVE_STD
+#define BZ_HAVE_RUSAGE
+#define BZ_ENUM_COMPUTATIONS
+ 
+#endif // BZ_CONFIG_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/config.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/config.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/config.h	(revision 1307)
@@ -0,0 +1,23 @@
+/******************************************************************************
+  Selection de fichier config suivant compilateur supporte ds PEIDA
+                                      Reza 04/99
+*/
+
+
+ 
+#ifndef BZ_CONFIG_S_H
+#define BZ_CONFIG_S_H
+
+#if defined(Linux)  || defined(linux)
+#endif
+
+#ifdef __DECCXX
+#include "peida_config_cxx.h"
+#else
+/* EGCS uniquement */
+#include "peida_config_egcs.h"
+#endif
+
+ 
+ 
+#endif // BZ_CONFIG_S_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/extremum.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/extremum.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/extremum.h	(revision 1307)
@@ -0,0 +1,88 @@
+/***************************************************************************
+ * blitz/extremum.h      Declaration of the Extremum<T_numtype, T_index> class
+ *
+ * $Id: extremum.h,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_EXTREMUM_H
+#define BZ_EXTREMUM_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// The Extremum class is used for returning extreme values and their
+// locations in a numeric container.  It's a simple 2-tuple, with the
+// first element being the extreme value, and the send its location.
+// An object of type Extremum can be automatically converted to
+// the numeric type via operator T_numtype().
+template<class P_numtype, class P_index>
+class Extremum {
+public:
+    typedef P_numtype T_numtype;
+    typedef P_index   T_index;
+
+    Extremum(T_numtype value, T_index index)
+        : value_(value), index_(index)
+    { }
+
+    T_numtype value() const
+    { return value_; }
+
+    T_index index() const
+    { return index_; }
+
+    void setValue(T_numtype value)
+    { value_ = value; }
+
+    void setIndex(T_index index)
+    { index_ = index; }
+
+    operator T_numtype() const
+    { return value_; }
+
+protected:
+    T_numtype value_;
+    T_index index_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_EXTREMUM_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/indexexpr.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/indexexpr.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/indexexpr.h	(revision 1307)
@@ -0,0 +1,213 @@
+/***************************************************************************
+ * blitz/indexexpr.h     Declaration of the IndexPlaceholder<N> class
+ *
+ * $Id: indexexpr.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    p://seurat.uhttwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_INDEXEXPR_H
+#define BZ_INDEXEXPR_H
+
+#ifndef BZ_TINYVEC_H
+ #include <blitz/tinyvec.h>
+#endif
+
+#ifndef BZ_PRETTYPRINT_H
+ #include <blitz/prettyprint.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<int N>
+class IndexPlaceholder {
+public:
+    IndexPlaceholder()
+    { }
+
+    IndexPlaceholder(const IndexPlaceholder<N>&)
+    { }
+
+    ~IndexPlaceholder()
+    { }
+
+    void operator=(const IndexPlaceholder<N>&)
+    { }
+
+    typedef int T_numtype;
+    typedef int T_ctorArg1;     // Dummy; not used
+    typedef int T_ctorArg2;     // Ditto
+
+    enum { numArrayOperands = 0, numIndexPlaceholders = 1,
+        rank = N+1 };
+
+    // If you have a precondition failure on this routine, it means
+    // you are trying to use stack iteration mode on an expression
+    // which contains an index placeholder.  You must use index 
+    // iteration mode instead.
+    int operator*()
+    { 
+        BZPRECONDITION(0); 
+        return 0;
+    }
+
+#ifdef BZ_ARRAY_EXPR_PASS_INDEX_BY_VALUE
+    template<int N_rank>
+    T_numtype operator()(TinyVector<int, N_rank> i)
+    { return i[N]; }
+#else
+    template<int N_rank>
+    T_numtype operator()(const TinyVector<int, N_rank>& i)
+    { return i[N]; }
+#endif
+
+    int lbound(int) const
+    { return INT_MIN; }   // tiny(int());
+
+    int ubound(int) const
+    { return INT_MAX; }  // huge(int()); 
+
+    // See operator*() note
+    void push(int)
+    { 
+        BZPRECONDITION(0); 
+    }
+
+    // See operator*() note
+    void pop(int)
+    { 
+        BZPRECONDITION(0); 
+    }
+
+    // See operator*() note
+    void advance()
+    { 
+        BZPRECONDITION(0); 
+    }
+
+    // See operator*() note
+    void advance(int)
+    { 
+        BZPRECONDITION(0); 
+    }
+
+    // See operator*() note
+    void loadStride(int)
+    { 
+        BZPRECONDITION(0); 
+    }
+
+    _bz_bool isUnitStride(int rank) const
+    { 
+        BZPRECONDITION(0);
+        return false;
+    }
+
+    void advanceUnitStride()
+    { 
+        BZPRECONDITION(0);
+    }
+
+    _bz_bool canCollapse(int,int) const
+    {   
+        BZPRECONDITION(0); 
+        return _bz_false; 
+    }
+
+    T_numtype operator[](int)
+    {
+        BZPRECONDITION(0);
+        return T_numtype();
+    }
+
+    T_numtype fastRead(int)
+    {
+        BZPRECONDITION(0);
+        return T_numtype();
+    }
+
+    int suggestStride(int) const
+    {
+        BZPRECONDITION(0);
+        return 0;
+    }
+
+    _bz_bool isStride(int,int) const
+    {
+        BZPRECONDITION(0);
+        return _bz_true;
+    }
+
+    void prettyPrint(string& str, prettyPrintFormat& format) const
+    {
+        // NEEDS_WORK-- do real formatting for reductions
+        str += "index-expr[NEEDS_WORK]";
+    }
+
+    template<class T_shape>
+    _bz_bool shapeCheck(const T_shape& shape) const
+    {
+        return _bz_true;
+    }
+};
+
+typedef IndexPlaceholder<0> firstIndex;
+typedef IndexPlaceholder<1> secondIndex;
+typedef IndexPlaceholder<2> thirdIndex;
+typedef IndexPlaceholder<3> fourthIndex;
+typedef IndexPlaceholder<4> fifthIndex;
+typedef IndexPlaceholder<5> sixthIndex;
+typedef IndexPlaceholder<6> seventhIndex;
+typedef IndexPlaceholder<7> eighthIndex;
+typedef IndexPlaceholder<8> ninthIndex;
+typedef IndexPlaceholder<9> tenthIndex;
+typedef IndexPlaceholder<10> eleventhIndex;
+
+#ifndef BZ_NO_TENSOR_INDEX_OBJECTS
+
+BZ_NAMESPACE(tensor)
+    _bz_global IndexPlaceholder<0> i;
+    _bz_global IndexPlaceholder<1> j;
+    _bz_global IndexPlaceholder<2> k;
+    _bz_global IndexPlaceholder<3> l;
+    _bz_global IndexPlaceholder<4> m;
+    _bz_global IndexPlaceholder<5> n;
+    _bz_global IndexPlaceholder<6> o;
+    _bz_global IndexPlaceholder<7> p;
+    _bz_global IndexPlaceholder<8> q;
+    _bz_global IndexPlaceholder<9> r;
+    _bz_global IndexPlaceholder<10> s;
+    _bz_global IndexPlaceholder<11> t;
+BZ_NAMESPACE_END // tensor
+
+#endif
+
+BZ_NAMESPACE_END
+
+#endif // BZ_INDEXEXPR_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/listinit.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/listinit.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/listinit.h	(revision 1307)
@@ -0,0 +1,121 @@
+/***************************************************************************
+ * blitz/listinit.h      Classes for initialization lists
+ *
+ * $Id: listinit.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+/*
+ * Initialization lists provide a convenient way to set the elements
+ * of an array.  For example,
+ *
+ * Array<int,2> A(3,3);
+ * A = 1, 0, 0,
+ *     0, 1, 0,
+ *     0, 0, 1;
+ */
+
+#ifndef BZ_LISTINIT_H
+#define BZ_LISTINIT_H
+
+BZ_NAMESPACE(blitz)
+
+template<class T_numtype, class T_iterator>
+class ListInitializer {
+
+public:
+    ListInitializer(T_iterator iter)
+        : iter_(iter)
+    {
+    }
+
+    ListInitializer<T_numtype, T_iterator> operator,(T_numtype x)
+    {
+        *iter_ = x;
+        return ListInitializer(iter_ + 1);
+    }
+
+private:
+    ListInitializer();
+
+protected:
+    T_iterator iter_;
+};
+
+template<class T_array, class T_iterator = _bz_typename T_array::T_numtype*>
+class ListInitializationSwitch {
+
+public:
+    typedef _bz_typename T_array::T_numtype T_numtype;
+
+    ListInitializationSwitch(const ListInitializationSwitch<T_array>& lis)
+        : array_(lis.array_), value_(lis.value_), 
+          wipeOnDestruct_(_bz_true)
+    {
+        lis.disable();
+    }
+
+    ListInitializationSwitch(T_array& array, T_numtype value)
+        : array_(array), value_(value), wipeOnDestruct_(_bz_true)
+    { }
+
+    ~ListInitializationSwitch()
+    {
+        if (wipeOnDestruct_)
+            array_.initialize(value_);
+    }
+
+    ListInitializer<T_numtype, T_iterator> operator,(T_numtype x)
+    {
+        wipeOnDestruct_ = _bz_false;
+        T_iterator iter = array_.getInitializationIterator();
+        *iter = value_;
+        T_iterator iter2 = iter + 1;
+        *iter2 = x;
+        return ListInitializer<T_numtype, T_iterator>(iter2 + 1);
+    }
+
+    void disable() const
+    {
+        wipeOnDestruct_ = _bz_false;
+    }
+
+private:
+    ListInitializationSwitch();
+
+protected:
+    T_array& array_;
+    T_numtype value_;
+    mutable _bz_bool wipeOnDestruct_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_LISTINIT_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matbops.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matbops.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matbops.h	(revision 1307)
@@ -0,0 +1,6070 @@
+// Generated source file.  Do not edit.
+// Created by: genmatbops.cpp Aug  8 1997 15:21:36
+
+#ifndef BZ_MATBOPS_H
+#define BZ_MATBOPS_H
+
+BZ_NAMESPACE(blitz)
+
+#ifndef BZ_MATEXPR_H
+ #error <blitz/matbops.h> must be included via <blitz/matexpr.h>
+#endif
+
+/****************************************************************************
+ * Addition Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> + Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Add<P_numtype1, P_numtype2> > >
+operator+(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> + _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_Add<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator+(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Add<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> + int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_Add<P_numtype1, int> > >
+operator+(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Add<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> + float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_Add<P_numtype1, float> > >
+operator+(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Add<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> + double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_Add<P_numtype1, double> > >
+operator+(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Add<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> + long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_Add<P_numtype1, long double> > >
+operator+(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Add<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> + complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Add<P_numtype1, complex<float> > > >
+operator+(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Add<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> + complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Add<P_numtype1, complex<double> > > >
+operator+(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Add<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> + complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Add<P_numtype1, complex<long double> > > >
+operator+(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Add<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> + Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Add<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator+(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> + _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_Add<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator+(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> + int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_Add<_bz_typename P_expr1::T_numtype, int> > >
+operator+(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> + float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_Add<_bz_typename P_expr1::T_numtype, float> > >
+operator+(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> + double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_Add<_bz_typename P_expr1::T_numtype, double> > >
+operator+(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> + long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_Add<_bz_typename P_expr1::T_numtype, long double> > >
+operator+(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> + complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Add<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator+(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> + complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Add<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator+(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> + complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Add<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator+(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int + Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Add<int, P_numtype2> > >
+operator+(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Add<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int + _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_Add<int, _bz_typename P_expr2::T_numtype> > >
+operator+(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Add<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float + Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Add<float, P_numtype2> > >
+operator+(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Add<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float + _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_Add<float, _bz_typename P_expr2::T_numtype> > >
+operator+(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Add<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double + Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Add<double, P_numtype2> > >
+operator+(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Add<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double + _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_Add<double, _bz_typename P_expr2::T_numtype> > >
+operator+(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Add<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double + Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Add<long double, P_numtype2> > >
+operator+(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Add<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double + _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_Add<long double, _bz_typename P_expr2::T_numtype> > >
+operator+(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Add<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  + Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Add<complex<float> , P_numtype2> > >
+operator+(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Add<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  + _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_Add<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator+(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Add<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  + Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Add<complex<double> , P_numtype2> > >
+operator+(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Add<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  + _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_Add<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator+(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Add<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  + Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Add<complex<long double> , P_numtype2> > >
+operator+(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Add<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  + _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_Add<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator+(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Add<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Subtraction Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> - Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Subtract<P_numtype1, P_numtype2> > >
+operator-(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> - _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_Subtract<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator-(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Subtract<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> - int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_Subtract<P_numtype1, int> > >
+operator-(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Subtract<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> - float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_Subtract<P_numtype1, float> > >
+operator-(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Subtract<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> - double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_Subtract<P_numtype1, double> > >
+operator-(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Subtract<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> - long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_Subtract<P_numtype1, long double> > >
+operator-(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Subtract<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> - complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Subtract<P_numtype1, complex<float> > > >
+operator-(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Subtract<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> - complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Subtract<P_numtype1, complex<double> > > >
+operator-(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Subtract<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> - complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Subtract<P_numtype1, complex<long double> > > >
+operator-(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Subtract<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> - Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Subtract<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator-(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> - _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_Subtract<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator-(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> - int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_Subtract<_bz_typename P_expr1::T_numtype, int> > >
+operator-(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> - float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_Subtract<_bz_typename P_expr1::T_numtype, float> > >
+operator-(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> - double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_Subtract<_bz_typename P_expr1::T_numtype, double> > >
+operator-(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> - long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_Subtract<_bz_typename P_expr1::T_numtype, long double> > >
+operator-(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> - complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Subtract<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator-(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> - complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Subtract<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator-(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> - complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Subtract<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator-(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int - Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Subtract<int, P_numtype2> > >
+operator-(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Subtract<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int - _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_Subtract<int, _bz_typename P_expr2::T_numtype> > >
+operator-(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Subtract<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float - Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Subtract<float, P_numtype2> > >
+operator-(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Subtract<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float - _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_Subtract<float, _bz_typename P_expr2::T_numtype> > >
+operator-(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Subtract<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double - Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Subtract<double, P_numtype2> > >
+operator-(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Subtract<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double - _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_Subtract<double, _bz_typename P_expr2::T_numtype> > >
+operator-(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Subtract<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double - Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Subtract<long double, P_numtype2> > >
+operator-(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Subtract<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double - _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_Subtract<long double, _bz_typename P_expr2::T_numtype> > >
+operator-(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Subtract<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  - Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Subtract<complex<float> , P_numtype2> > >
+operator-(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Subtract<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  - _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_Subtract<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator-(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Subtract<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  - Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Subtract<complex<double> , P_numtype2> > >
+operator-(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Subtract<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  - _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_Subtract<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator-(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Subtract<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  - Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Subtract<complex<long double> , P_numtype2> > >
+operator-(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Subtract<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  - _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_Subtract<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator-(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Subtract<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Multiplication Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> * Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Multiply<P_numtype1, P_numtype2> > >
+operator*(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> * _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_Multiply<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator*(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Multiply<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> * int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_Multiply<P_numtype1, int> > >
+operator*(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Multiply<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> * float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_Multiply<P_numtype1, float> > >
+operator*(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Multiply<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> * double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_Multiply<P_numtype1, double> > >
+operator*(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Multiply<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> * long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_Multiply<P_numtype1, long double> > >
+operator*(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Multiply<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> * complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Multiply<P_numtype1, complex<float> > > >
+operator*(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Multiply<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> * complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Multiply<P_numtype1, complex<double> > > >
+operator*(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Multiply<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> * complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Multiply<P_numtype1, complex<long double> > > >
+operator*(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Multiply<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> * Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Multiply<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator*(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> * _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_Multiply<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator*(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> * int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_Multiply<_bz_typename P_expr1::T_numtype, int> > >
+operator*(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> * float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_Multiply<_bz_typename P_expr1::T_numtype, float> > >
+operator*(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> * double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_Multiply<_bz_typename P_expr1::T_numtype, double> > >
+operator*(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> * long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_Multiply<_bz_typename P_expr1::T_numtype, long double> > >
+operator*(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> * complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Multiply<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator*(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> * complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Multiply<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator*(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> * complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Multiply<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator*(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int * Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Multiply<int, P_numtype2> > >
+operator*(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Multiply<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int * _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_Multiply<int, _bz_typename P_expr2::T_numtype> > >
+operator*(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Multiply<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float * Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Multiply<float, P_numtype2> > >
+operator*(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Multiply<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float * _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_Multiply<float, _bz_typename P_expr2::T_numtype> > >
+operator*(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Multiply<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double * Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Multiply<double, P_numtype2> > >
+operator*(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Multiply<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double * _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_Multiply<double, _bz_typename P_expr2::T_numtype> > >
+operator*(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Multiply<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double * Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Multiply<long double, P_numtype2> > >
+operator*(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Multiply<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double * _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_Multiply<long double, _bz_typename P_expr2::T_numtype> > >
+operator*(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Multiply<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  * Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Multiply<complex<float> , P_numtype2> > >
+operator*(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Multiply<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  * _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_Multiply<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator*(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Multiply<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  * Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Multiply<complex<double> , P_numtype2> > >
+operator*(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Multiply<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  * _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_Multiply<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator*(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Multiply<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  * Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Multiply<complex<long double> , P_numtype2> > >
+operator*(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Multiply<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  * _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_Multiply<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator*(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Multiply<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Division Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> / Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Divide<P_numtype1, P_numtype2> > >
+operator/(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> / _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_Divide<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator/(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Divide<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> / int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_Divide<P_numtype1, int> > >
+operator/(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Divide<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> / float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_Divide<P_numtype1, float> > >
+operator/(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Divide<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> / double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_Divide<P_numtype1, double> > >
+operator/(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Divide<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> / long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_Divide<P_numtype1, long double> > >
+operator/(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Divide<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> / complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Divide<P_numtype1, complex<float> > > >
+operator/(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Divide<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> / complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Divide<P_numtype1, complex<double> > > >
+operator/(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Divide<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> / complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Divide<P_numtype1, complex<long double> > > >
+operator/(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Divide<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> / Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Divide<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator/(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> / _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_Divide<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator/(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> / int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_Divide<_bz_typename P_expr1::T_numtype, int> > >
+operator/(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> / float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_Divide<_bz_typename P_expr1::T_numtype, float> > >
+operator/(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> / double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_Divide<_bz_typename P_expr1::T_numtype, double> > >
+operator/(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> / long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_Divide<_bz_typename P_expr1::T_numtype, long double> > >
+operator/(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> / complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Divide<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator/(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> / complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Divide<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator/(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> / complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Divide<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator/(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int / Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Divide<int, P_numtype2> > >
+operator/(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Divide<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int / _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_Divide<int, _bz_typename P_expr2::T_numtype> > >
+operator/(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Divide<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float / Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Divide<float, P_numtype2> > >
+operator/(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Divide<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float / _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_Divide<float, _bz_typename P_expr2::T_numtype> > >
+operator/(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Divide<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double / Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Divide<double, P_numtype2> > >
+operator/(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Divide<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double / _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_Divide<double, _bz_typename P_expr2::T_numtype> > >
+operator/(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Divide<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double / Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Divide<long double, P_numtype2> > >
+operator/(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Divide<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double / _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_Divide<long double, _bz_typename P_expr2::T_numtype> > >
+operator/(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Divide<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  / Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Divide<complex<float> , P_numtype2> > >
+operator/(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Divide<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  / _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_Divide<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator/(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Divide<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  / Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Divide<complex<double> , P_numtype2> > >
+operator/(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Divide<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  / _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_Divide<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator/(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Divide<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  / Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Divide<complex<long double> , P_numtype2> > >
+operator/(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Divide<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  / _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_Divide<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator/(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Divide<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Modulus Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> % Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Mod<P_numtype1, P_numtype2> > >
+operator%(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> % _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_Mod<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator%(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Mod<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> % int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_Mod<P_numtype1, int> > >
+operator%(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Mod<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> % Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Mod<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator%(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Mod<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> % _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_Mod<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator%(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Mod<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> % int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_Mod<_bz_typename P_expr1::T_numtype, int> > >
+operator%(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Mod<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// int % Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Mod<int, P_numtype2> > >
+operator%(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Mod<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int % _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_Mod<int, _bz_typename P_expr2::T_numtype> > >
+operator%(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Mod<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+/****************************************************************************
+ * Bitwise XOR Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> ^ Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_BitwiseXOR<P_numtype1, P_numtype2> > >
+operator^(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> ^ _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_BitwiseXOR<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator^(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_BitwiseXOR<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> ^ int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_BitwiseXOR<P_numtype1, int> > >
+operator^(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_BitwiseXOR<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> ^ Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator^(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> ^ _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator^(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> ^ int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, int> > >
+operator^(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// int ^ Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_BitwiseXOR<int, P_numtype2> > >
+operator^(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_BitwiseXOR<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int ^ _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_BitwiseXOR<int, _bz_typename P_expr2::T_numtype> > >
+operator^(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_BitwiseXOR<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+/****************************************************************************
+ * Bitwise And Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> & Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_BitwiseAnd<P_numtype1, P_numtype2> > >
+operator&(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> & _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_BitwiseAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator&(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_BitwiseAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> & int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_BitwiseAnd<P_numtype1, int> > >
+operator&(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_BitwiseAnd<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> & Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator&(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> & _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator&(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> & int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, int> > >
+operator&(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// int & Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_BitwiseAnd<int, P_numtype2> > >
+operator&(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_BitwiseAnd<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int & _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_BitwiseAnd<int, _bz_typename P_expr2::T_numtype> > >
+operator&(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_BitwiseAnd<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+/****************************************************************************
+ * Bitwise Or Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> | Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_BitwiseOr<P_numtype1, P_numtype2> > >
+operator|(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> | _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_BitwiseOr<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator|(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_BitwiseOr<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> | int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_BitwiseOr<P_numtype1, int> > >
+operator|(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_BitwiseOr<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> | Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator|(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> | _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator|(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> | int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, int> > >
+operator|(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// int | Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_BitwiseOr<int, P_numtype2> > >
+operator|(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_BitwiseOr<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int | _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_BitwiseOr<int, _bz_typename P_expr2::T_numtype> > >
+operator|(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_BitwiseOr<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+/****************************************************************************
+ * Shift right Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> >> Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_ShiftRight<P_numtype1, P_numtype2> > >
+operator>>(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> >> _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_ShiftRight<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator>>(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_ShiftRight<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> >> int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_ShiftRight<P_numtype1, int> > >
+operator>>(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_ShiftRight<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> >> Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_ShiftRight<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator>>(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> >> _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_ShiftRight<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator>>(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> >> int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_ShiftRight<_bz_typename P_expr1::T_numtype, int> > >
+operator>>(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// int >> Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_ShiftRight<int, P_numtype2> > >
+operator>>(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_ShiftRight<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int >> _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_ShiftRight<int, _bz_typename P_expr2::T_numtype> > >
+operator>>(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_ShiftRight<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+/****************************************************************************
+ * Shift left Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> << Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_ShiftLeft<P_numtype1, P_numtype2> > >
+operator<<(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> << _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_ShiftLeft<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator<<(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_ShiftLeft<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> << int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_ShiftLeft<P_numtype1, int> > >
+operator<<(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_ShiftLeft<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> << Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator<<(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> << _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator<<(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> << int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, int> > >
+operator<<(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// int << Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_ShiftLeft<int, P_numtype2> > >
+operator<<(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_ShiftLeft<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int << _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_ShiftLeft<int, _bz_typename P_expr2::T_numtype> > >
+operator<<(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_ShiftLeft<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+/****************************************************************************
+ * Greater-than Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> > Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Greater<P_numtype1, P_numtype2> > >
+operator>(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> > _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_Greater<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator>(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Greater<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> > int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_Greater<P_numtype1, int> > >
+operator>(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Greater<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> > float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_Greater<P_numtype1, float> > >
+operator>(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Greater<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> > double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_Greater<P_numtype1, double> > >
+operator>(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Greater<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> > long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_Greater<P_numtype1, long double> > >
+operator>(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Greater<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> > complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Greater<P_numtype1, complex<float> > > >
+operator>(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Greater<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> > complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Greater<P_numtype1, complex<double> > > >
+operator>(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Greater<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> > complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Greater<P_numtype1, complex<long double> > > >
+operator>(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Greater<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> > Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Greater<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator>(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> > _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_Greater<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator>(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> > int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_Greater<_bz_typename P_expr1::T_numtype, int> > >
+operator>(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> > float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_Greater<_bz_typename P_expr1::T_numtype, float> > >
+operator>(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> > double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_Greater<_bz_typename P_expr1::T_numtype, double> > >
+operator>(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> > long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_Greater<_bz_typename P_expr1::T_numtype, long double> > >
+operator>(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> > complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Greater<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator>(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> > complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Greater<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator>(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> > complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Greater<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator>(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int > Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Greater<int, P_numtype2> > >
+operator>(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Greater<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int > _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_Greater<int, _bz_typename P_expr2::T_numtype> > >
+operator>(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Greater<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float > Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Greater<float, P_numtype2> > >
+operator>(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Greater<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float > _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_Greater<float, _bz_typename P_expr2::T_numtype> > >
+operator>(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Greater<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double > Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Greater<double, P_numtype2> > >
+operator>(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Greater<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double > _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_Greater<double, _bz_typename P_expr2::T_numtype> > >
+operator>(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Greater<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double > Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Greater<long double, P_numtype2> > >
+operator>(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Greater<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double > _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_Greater<long double, _bz_typename P_expr2::T_numtype> > >
+operator>(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Greater<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  > Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Greater<complex<float> , P_numtype2> > >
+operator>(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Greater<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  > _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_Greater<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator>(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Greater<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  > Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Greater<complex<double> , P_numtype2> > >
+operator>(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Greater<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  > _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_Greater<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator>(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Greater<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  > Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Greater<complex<long double> , P_numtype2> > >
+operator>(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Greater<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  > _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_Greater<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator>(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Greater<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Less-than Operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> < Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Less<P_numtype1, P_numtype2> > >
+operator<(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> < _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_Less<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator<(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Less<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> < int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_Less<P_numtype1, int> > >
+operator<(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Less<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> < float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_Less<P_numtype1, float> > >
+operator<(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Less<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> < double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_Less<P_numtype1, double> > >
+operator<(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Less<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> < long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_Less<P_numtype1, long double> > >
+operator<(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Less<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> < complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Less<P_numtype1, complex<float> > > >
+operator<(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Less<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> < complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Less<P_numtype1, complex<double> > > >
+operator<(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Less<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> < complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Less<P_numtype1, complex<long double> > > >
+operator<(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Less<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> < Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Less<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator<(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> < _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_Less<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator<(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> < int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_Less<_bz_typename P_expr1::T_numtype, int> > >
+operator<(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> < float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_Less<_bz_typename P_expr1::T_numtype, float> > >
+operator<(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> < double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_Less<_bz_typename P_expr1::T_numtype, double> > >
+operator<(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> < long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_Less<_bz_typename P_expr1::T_numtype, long double> > >
+operator<(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> < complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Less<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator<(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> < complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Less<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator<(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> < complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Less<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator<(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int < Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Less<int, P_numtype2> > >
+operator<(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Less<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int < _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_Less<int, _bz_typename P_expr2::T_numtype> > >
+operator<(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Less<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float < Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Less<float, P_numtype2> > >
+operator<(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Less<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float < _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_Less<float, _bz_typename P_expr2::T_numtype> > >
+operator<(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Less<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double < Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Less<double, P_numtype2> > >
+operator<(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Less<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double < _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_Less<double, _bz_typename P_expr2::T_numtype> > >
+operator<(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Less<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double < Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Less<long double, P_numtype2> > >
+operator<(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Less<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double < _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_Less<long double, _bz_typename P_expr2::T_numtype> > >
+operator<(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Less<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  < Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Less<complex<float> , P_numtype2> > >
+operator<(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Less<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  < _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_Less<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator<(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Less<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  < Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Less<complex<double> , P_numtype2> > >
+operator<(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Less<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  < _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_Less<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator<(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Less<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  < Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Less<complex<long double> , P_numtype2> > >
+operator<(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Less<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  < _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_Less<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator<(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Less<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Greater or equal (>=) operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> >= Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_GreaterOrEqual<P_numtype1, P_numtype2> > >
+operator>=(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> >= _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_GreaterOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator>=(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_GreaterOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> >= int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_GreaterOrEqual<P_numtype1, int> > >
+operator>=(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_GreaterOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> >= float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_GreaterOrEqual<P_numtype1, float> > >
+operator>=(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_GreaterOrEqual<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> >= double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_GreaterOrEqual<P_numtype1, double> > >
+operator>=(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_GreaterOrEqual<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> >= long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_GreaterOrEqual<P_numtype1, long double> > >
+operator>=(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_GreaterOrEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> >= complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_GreaterOrEqual<P_numtype1, complex<float> > > >
+operator>=(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_GreaterOrEqual<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> >= complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_GreaterOrEqual<P_numtype1, complex<double> > > >
+operator>=(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_GreaterOrEqual<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> >= complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_GreaterOrEqual<P_numtype1, complex<long double> > > >
+operator>=(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_GreaterOrEqual<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> >= Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator>=(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> >= _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator>=(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> >= int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, int> > >
+operator>=(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> >= float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, float> > >
+operator>=(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> >= double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, double> > >
+operator>=(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> >= long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, long double> > >
+operator>=(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> >= complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator>=(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> >= complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator>=(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> >= complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator>=(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int >= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_GreaterOrEqual<int, P_numtype2> > >
+operator>=(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_GreaterOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int >= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_GreaterOrEqual<int, _bz_typename P_expr2::T_numtype> > >
+operator>=(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_GreaterOrEqual<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float >= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_GreaterOrEqual<float, P_numtype2> > >
+operator>=(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_GreaterOrEqual<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float >= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_GreaterOrEqual<float, _bz_typename P_expr2::T_numtype> > >
+operator>=(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_GreaterOrEqual<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double >= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_GreaterOrEqual<double, P_numtype2> > >
+operator>=(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_GreaterOrEqual<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double >= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_GreaterOrEqual<double, _bz_typename P_expr2::T_numtype> > >
+operator>=(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_GreaterOrEqual<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double >= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_GreaterOrEqual<long double, P_numtype2> > >
+operator>=(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_GreaterOrEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double >= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_GreaterOrEqual<long double, _bz_typename P_expr2::T_numtype> > >
+operator>=(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_GreaterOrEqual<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  >= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_GreaterOrEqual<complex<float> , P_numtype2> > >
+operator>=(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_GreaterOrEqual<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  >= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_GreaterOrEqual<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator>=(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_GreaterOrEqual<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  >= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_GreaterOrEqual<complex<double> , P_numtype2> > >
+operator>=(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_GreaterOrEqual<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  >= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_GreaterOrEqual<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator>=(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_GreaterOrEqual<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  >= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_GreaterOrEqual<complex<long double> , P_numtype2> > >
+operator>=(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_GreaterOrEqual<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  >= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_GreaterOrEqual<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator>=(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_GreaterOrEqual<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Less or equal (<=) operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> <= Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LessOrEqual<P_numtype1, P_numtype2> > >
+operator<=(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> <= _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_LessOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator<=(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LessOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> <= int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_LessOrEqual<P_numtype1, int> > >
+operator<=(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_LessOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> <= float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_LessOrEqual<P_numtype1, float> > >
+operator<=(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_LessOrEqual<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> <= double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_LessOrEqual<P_numtype1, double> > >
+operator<=(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_LessOrEqual<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> <= long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_LessOrEqual<P_numtype1, long double> > >
+operator<=(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_LessOrEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> <= complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_LessOrEqual<P_numtype1, complex<float> > > >
+operator<=(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_LessOrEqual<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> <= complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_LessOrEqual<P_numtype1, complex<double> > > >
+operator<=(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_LessOrEqual<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> <= complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_LessOrEqual<P_numtype1, complex<long double> > > >
+operator<=(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_LessOrEqual<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> <= Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator<=(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> <= _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator<=(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> <= int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, int> > >
+operator<=(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> <= float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, float> > >
+operator<=(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> <= double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, double> > >
+operator<=(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> <= long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, long double> > >
+operator<=(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> <= complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator<=(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> <= complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator<=(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> <= complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator<=(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int <= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LessOrEqual<int, P_numtype2> > >
+operator<=(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LessOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int <= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_LessOrEqual<int, _bz_typename P_expr2::T_numtype> > >
+operator<=(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LessOrEqual<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float <= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LessOrEqual<float, P_numtype2> > >
+operator<=(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LessOrEqual<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float <= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_LessOrEqual<float, _bz_typename P_expr2::T_numtype> > >
+operator<=(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LessOrEqual<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double <= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LessOrEqual<double, P_numtype2> > >
+operator<=(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LessOrEqual<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double <= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_LessOrEqual<double, _bz_typename P_expr2::T_numtype> > >
+operator<=(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LessOrEqual<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double <= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LessOrEqual<long double, P_numtype2> > >
+operator<=(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LessOrEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double <= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_LessOrEqual<long double, _bz_typename P_expr2::T_numtype> > >
+operator<=(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LessOrEqual<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  <= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LessOrEqual<complex<float> , P_numtype2> > >
+operator<=(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LessOrEqual<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  <= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_LessOrEqual<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator<=(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LessOrEqual<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  <= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LessOrEqual<complex<double> , P_numtype2> > >
+operator<=(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LessOrEqual<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  <= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_LessOrEqual<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator<=(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LessOrEqual<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  <= Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LessOrEqual<complex<long double> , P_numtype2> > >
+operator<=(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LessOrEqual<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  <= _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_LessOrEqual<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator<=(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LessOrEqual<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Equality operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> == Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Equal<P_numtype1, P_numtype2> > >
+operator==(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> == _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_Equal<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator==(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Equal<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> == int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_Equal<P_numtype1, int> > >
+operator==(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Equal<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> == float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_Equal<P_numtype1, float> > >
+operator==(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Equal<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> == double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_Equal<P_numtype1, double> > >
+operator==(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Equal<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> == long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_Equal<P_numtype1, long double> > >
+operator==(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Equal<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> == complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Equal<P_numtype1, complex<float> > > >
+operator==(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Equal<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> == complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Equal<P_numtype1, complex<double> > > >
+operator==(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Equal<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> == complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Equal<P_numtype1, complex<long double> > > >
+operator==(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Equal<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> == Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Equal<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator==(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> == _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_Equal<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator==(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> == int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_Equal<_bz_typename P_expr1::T_numtype, int> > >
+operator==(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> == float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_Equal<_bz_typename P_expr1::T_numtype, float> > >
+operator==(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> == double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_Equal<_bz_typename P_expr1::T_numtype, double> > >
+operator==(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> == long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_Equal<_bz_typename P_expr1::T_numtype, long double> > >
+operator==(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> == complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_Equal<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator==(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> == complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_Equal<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator==(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> == complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_Equal<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator==(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int == Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Equal<int, P_numtype2> > >
+operator==(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Equal<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int == _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_Equal<int, _bz_typename P_expr2::T_numtype> > >
+operator==(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Equal<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float == Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Equal<float, P_numtype2> > >
+operator==(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Equal<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float == _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_Equal<float, _bz_typename P_expr2::T_numtype> > >
+operator==(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Equal<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double == Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Equal<double, P_numtype2> > >
+operator==(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Equal<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double == _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_Equal<double, _bz_typename P_expr2::T_numtype> > >
+operator==(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Equal<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double == Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Equal<long double, P_numtype2> > >
+operator==(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Equal<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double == _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_Equal<long double, _bz_typename P_expr2::T_numtype> > >
+operator==(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Equal<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  == Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Equal<complex<float> , P_numtype2> > >
+operator==(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Equal<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  == _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_Equal<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator==(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Equal<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  == Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Equal<complex<double> , P_numtype2> > >
+operator==(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Equal<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  == _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_Equal<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator==(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Equal<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  == Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_Equal<complex<long double> , P_numtype2> > >
+operator==(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_Equal<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  == _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_Equal<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator==(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_Equal<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Not-equal operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> != Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_NotEqual<P_numtype1, P_numtype2> > >
+operator!=(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> != _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_NotEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator!=(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_NotEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> != int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_NotEqual<P_numtype1, int> > >
+operator!=(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_NotEqual<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> != float
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<float>, _bz_NotEqual<P_numtype1, float> > >
+operator!=(const Matrix<P_numtype1, P_struct1>& d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<float>, 
+      _bz_NotEqual<P_numtype1, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> != double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<double>, _bz_NotEqual<P_numtype1, double> > >
+operator!=(const Matrix<P_numtype1, P_struct1>& d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<double>, 
+      _bz_NotEqual<P_numtype1, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// Matrix<P_numtype1, P_struct1> != long double
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<long double>, _bz_NotEqual<P_numtype1, long double> > >
+operator!=(const Matrix<P_numtype1, P_struct1>& d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_NotEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> != complex<float> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<float> >, _bz_NotEqual<P_numtype1, complex<float> > > >
+operator!=(const Matrix<P_numtype1, P_struct1>& d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_NotEqual<P_numtype1, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> != complex<double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<double> >, _bz_NotEqual<P_numtype1, complex<double> > > >
+operator!=(const Matrix<P_numtype1, P_struct1>& d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_NotEqual<P_numtype1, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// Matrix<P_numtype1, P_struct1> != complex<long double> 
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_NotEqual<P_numtype1, complex<long double> > > >
+operator!=(const Matrix<P_numtype1, P_struct1>& d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_NotEqual<P_numtype1, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// _bz_MatExpr<P_expr1> != Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_NotEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator!=(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> != _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_NotEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator!=(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> != int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_NotEqual<_bz_typename P_expr1::T_numtype, int> > >
+operator!=(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> != float
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<float>, _bz_NotEqual<_bz_typename P_expr1::T_numtype, float> > >
+operator!=(_bz_MatExpr<P_expr1> d1, float d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<float>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<float>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> != double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<double>, _bz_NotEqual<_bz_typename P_expr1::T_numtype, double> > >
+operator!=(_bz_MatExpr<P_expr1> d1, double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<double>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<double>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> != long double
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<long double>, _bz_NotEqual<_bz_typename P_expr1::T_numtype, long double> > >
+operator!=(_bz_MatExpr<P_expr1> d1, long double d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<long double>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<long double>(d2)));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> != complex<float> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<float> >, _bz_NotEqual<_bz_typename P_expr1::T_numtype, complex<float> > > >
+operator!=(_bz_MatExpr<P_expr1> d1, complex<float>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<float> >, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, complex<float> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<float> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> != complex<double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<double> >, _bz_NotEqual<_bz_typename P_expr1::T_numtype, complex<double> > > >
+operator!=(_bz_MatExpr<P_expr1> d1, complex<double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<double> >, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, complex<double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// _bz_MatExpr<P_expr1> != complex<long double> 
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<complex<long double> >, _bz_NotEqual<_bz_typename P_expr1::T_numtype, complex<long double> > > >
+operator!=(_bz_MatExpr<P_expr1> d1, complex<long double>  d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<complex<long double> >, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, complex<long double> > > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<complex<long double> >(d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// int != Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_NotEqual<int, P_numtype2> > >
+operator!=(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_NotEqual<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int != _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_NotEqual<int, _bz_typename P_expr2::T_numtype> > >
+operator!=(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_NotEqual<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+// float != Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_NotEqual<float, P_numtype2> > >
+operator!=(float d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_NotEqual<float, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2._bz_getRef()));
+}
+
+// float != _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<float>,
+    _bz_MatExpr<P_expr2>, _bz_NotEqual<float, _bz_typename P_expr2::T_numtype> > >
+operator!=(float d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<float>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_NotEqual<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<float>(d1), 
+        d2));
+}
+
+// double != Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_NotEqual<double, P_numtype2> > >
+operator!=(double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_NotEqual<double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2._bz_getRef()));
+}
+
+// double != _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<double>,
+    _bz_MatExpr<P_expr2>, _bz_NotEqual<double, _bz_typename P_expr2::T_numtype> > >
+operator!=(double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_NotEqual<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<double>(d1), 
+        d2));
+}
+
+// long double != Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_NotEqual<long double, P_numtype2> > >
+operator!=(long double d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_NotEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2._bz_getRef()));
+}
+
+// long double != _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<long double>,
+    _bz_MatExpr<P_expr2>, _bz_NotEqual<long double, _bz_typename P_expr2::T_numtype> > >
+operator!=(long double d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<long double>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_NotEqual<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<long double>(d1), 
+        d2));
+}
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  != Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_NotEqual<complex<float> , P_numtype2> > >
+operator!=(complex<float>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_NotEqual<complex<float> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<float>  != _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+    _bz_MatExpr<P_expr2>, _bz_NotEqual<complex<float> , _bz_typename P_expr2::T_numtype> > >
+operator!=(complex<float>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<float> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_NotEqual<complex<float> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<float> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  != Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_NotEqual<complex<double> , P_numtype2> > >
+operator!=(complex<double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_NotEqual<complex<double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<double>  != _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+    _bz_MatExpr<P_expr2>, _bz_NotEqual<complex<double> , _bz_typename P_expr2::T_numtype> > >
+operator!=(complex<double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_NotEqual<complex<double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  != Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_NotEqual<complex<long double> , P_numtype2> > >
+operator!=(complex<long double>  d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_NotEqual<complex<long double> , P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2._bz_getRef()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+// complex<long double>  != _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+    _bz_MatExpr<P_expr2>, _bz_NotEqual<complex<long double> , _bz_typename P_expr2::T_numtype> > >
+operator!=(complex<long double>  d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<complex<long double> >,
+      _bz_MatExpr<P_expr2>, 
+      _bz_NotEqual<complex<long double> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<complex<long double> >(d1), 
+        d2));
+}
+#endif // BZ_HAVE_COMPLEX
+/****************************************************************************
+ * Logical AND operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> && Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LogicalAnd<P_numtype1, P_numtype2> > >
+operator&&(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> && _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_LogicalAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator&&(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LogicalAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> && int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_LogicalAnd<P_numtype1, int> > >
+operator&&(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_LogicalAnd<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> && Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator&&(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> && _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator&&(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> && int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, int> > >
+operator&&(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// int && Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LogicalAnd<int, P_numtype2> > >
+operator&&(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LogicalAnd<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int && _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_LogicalAnd<int, _bz_typename P_expr2::T_numtype> > >
+operator&&(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LogicalAnd<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+/****************************************************************************
+ * Logical OR operators
+ ****************************************************************************/
+
+// Matrix<P_numtype1, P_struct1> || Matrix<P_numtype2, P_struct2>
+template<class P_numtype1, class P_struct1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LogicalOr<P_numtype1, P_numtype2> > >
+operator||(const Matrix<P_numtype1, P_struct1>& d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2._bz_getRef()));
+}
+
+// Matrix<P_numtype1, P_struct1> || _bz_MatExpr<P_expr2>
+template<class P_numtype1, class P_struct1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExpr<P_expr2>, _bz_LogicalOr<P_numtype1, _bz_typename P_expr2::T_numtype> > >
+operator||(const Matrix<P_numtype1, P_struct1>& d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LogicalOr<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        d2));
+}
+
+// Matrix<P_numtype1, P_struct1> || int
+template<class P_numtype1, class P_struct1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+    _bz_MatExprConstant<int>, _bz_LogicalOr<P_numtype1, int> > >
+operator||(const Matrix<P_numtype1, P_struct1>& d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatrixRef<P_numtype1, P_struct1>,
+      _bz_MatExprConstant<int>, 
+      _bz_LogicalOr<P_numtype1, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1._bz_getRef(), 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// _bz_MatExpr<P_expr1> || Matrix<P_numtype2, P_struct2>
+template<class P_expr1, class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LogicalOr<_bz_typename P_expr1::T_numtype, P_numtype2> > >
+operator||(_bz_MatExpr<P_expr1> d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2._bz_getRef()));
+}
+
+// _bz_MatExpr<P_expr1> || _bz_MatExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExpr<P_expr2>, _bz_LogicalOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > >
+operator||(_bz_MatExpr<P_expr1> d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        d2));
+}
+
+// _bz_MatExpr<P_expr1> || int
+template<class P_expr1>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExpr<P_expr1>,
+    _bz_MatExprConstant<int>, _bz_LogicalOr<_bz_typename P_expr1::T_numtype, int> > >
+operator||(_bz_MatExpr<P_expr1> d1, int d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExpr<P_expr1>,
+      _bz_MatExprConstant<int>, 
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(d1, 
+        _bz_MatExprConstant<int>(d2)));
+}
+
+// int || Matrix<P_numtype2, P_struct2>
+template<class P_numtype2, class P_struct2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatrixRef<P_numtype2, P_struct2>, _bz_LogicalOr<int, P_numtype2> > >
+operator||(int d1, const Matrix<P_numtype2, P_struct2>& d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatrixRef<P_numtype2, P_struct2>, 
+      _bz_LogicalOr<int, P_numtype2> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2._bz_getRef()));
+}
+
+// int || _bz_MatExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_MatExpr<_bz_MatExprOp<_bz_MatExprConstant<int>,
+    _bz_MatExpr<P_expr2>, _bz_LogicalOr<int, _bz_typename P_expr2::T_numtype> > >
+operator||(int d1, _bz_MatExpr<P_expr2> d2)
+{
+    typedef _bz_MatExprOp<_bz_MatExprConstant<int>,
+      _bz_MatExpr<P_expr2>, 
+      _bz_LogicalOr<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_MatExpr<T_expr>(T_expr(_bz_MatExprConstant<int>(d1), 
+        d2));
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATBOPS_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matdiag.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matdiag.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matdiag.h	(revision 1307)
@@ -0,0 +1,176 @@
+/***************************************************************************
+ * blitz/matdiag.h      Declarations for Diagonal matrices 
+ *
+ * $Id: matdiag.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_MATDIAG_H
+#define BZ_MATDIAG_H
+
+#ifndef BZ_MSTRUCT_H
+ #error <blitz/matdiag.h> must be included via <blitz/mstruct.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Diagonal matrix
+// [ 0 . . . ]
+// [ . 1 . . ]
+// [ . . 2 . ]
+// [ . . . 3 ]
+
+class DiagonalIterator {
+public:
+    DiagonalIterator(unsigned rows, unsigned cols)
+    {
+        BZPRECONDITION(rows == cols);
+        size_ = rows;
+        i_ = 0;
+    }
+
+    operator _bz_bool() const
+    {
+        return i_ < size_;
+    }
+
+    void operator++()
+    {
+        ++i_;
+    }
+
+    unsigned row() const
+    { return i_; }
+
+    unsigned col() const
+    { return i_; }
+
+    unsigned offset() const
+    { return i_; }
+
+protected:
+    unsigned i_, size_;
+};
+
+class Diagonal : public MatrixStructure {
+
+public:
+    typedef DiagonalIterator T_iterator;
+
+    Diagonal()
+        : size_(0)
+    { }
+
+    Diagonal(unsigned size)
+        : size_(size)
+    { }
+
+    Diagonal(unsigned rows, unsigned cols)
+        : size_(rows)
+    {
+        BZPRECONDITION(rows == cols);
+    }
+
+    unsigned columns() const
+    { return size_; }
+
+    unsigned coordToOffset(unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        BZPRECONDITION(i == j);
+        return i;
+    }
+
+    unsigned firstInRow(unsigned i) const
+    { return i; }
+
+    template<class T_numtype>
+    T_numtype get(const T_numtype * _bz_restrict data,
+        unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        if (i == j)
+            return data[coordToOffset(i,j)];
+        else
+            return ZeroElement<T_numtype>::zero();
+    }
+
+    template<class T_numtype>
+    T_numtype& get(T_numtype * _bz_restrict data, unsigned i, unsigned j)
+    {
+        BZPRECONDITION(inRange(i,j));
+        if (i == j)
+            return data[coordToOffset(i,j)];
+        else
+            return ZeroElement<T_numtype>::zero();
+    }
+
+    unsigned lastInRow(unsigned i) const
+    { return i; }
+
+    unsigned firstInCol(unsigned j) const
+    { return j; }
+
+    unsigned lastInCol(unsigned j) const
+    { return j; }
+
+    _bz_bool inRange(unsigned i, unsigned j) const
+    {
+        return (i < size_) && (j < size_);
+    }
+
+    unsigned numElements() const
+    { return size_; }
+
+    unsigned rows() const
+    { return size_; }
+
+    void resize(unsigned size)
+    {
+        size_ = size;
+    }
+
+    void resize(unsigned rows, unsigned cols)
+    {
+        BZPRECONDITION(rows == cols);
+        size_  = rows;
+    }
+
+private:
+    unsigned size_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATSYMM_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matexpr.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matexpr.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matexpr.h	(revision 1307)
@@ -0,0 +1,185 @@
+/***************************************************************************
+ * blitz/matexpr.h      Matrix<P_numtype, P_structure> expression templates
+ *
+ * $Id: matexpr.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_MATEXPR_H
+#define BZ_MATEXPR_H
+
+#ifndef BZ_MATRIX_H
+ #error <blitz/matexpr.h> must be included via <blitz/matrix.h>
+#endif
+
+#include <blitz/applics.h>
+
+BZ_NAMESPACE(blitz)
+
+// BlitzMatrixExpressionsBase is a dummy class provided for users of
+// graphical class browsers.  
+class BlitzMatrixExpressionsBase { };
+
+template<class P_expr>
+class _bz_MatExpr : public BlitzMatrixExpressionsBase {
+
+public:
+    typedef P_expr T_expr;
+    typedef _bz_typename T_expr::T_numtype T_numtype;
+
+#ifdef BZ_PASS_EXPR_BY_VALUE
+    _bz_MatExpr(T_expr a)
+        : iter_(a)
+    { }
+#else
+    _bz_MatExpr(const T_expr& a)
+        : iter_(a)
+    { }
+#endif
+
+    T_numtype operator()(unsigned i, unsigned j) const
+    { return iter_(i,j); }
+
+    unsigned rows(unsigned recommendedRows) const
+    { return iter_.rows(recommendedRows); }
+
+    unsigned cols(unsigned recommendedCols) const
+    { return iter_.cols(recommendedCols); }
+
+private:
+    T_expr iter_;
+};
+
+template<class P_expr1, class P_expr2, class P_op>
+class _bz_MatExprOp : public BlitzMatrixExpressionsBase {
+
+public:
+    typedef P_expr1 T_expr1;
+    typedef P_expr2 T_expr2;
+    typedef _bz_typename T_expr1::T_numtype T_numtype1;
+    typedef _bz_typename T_expr2::T_numtype T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1, T_numtype2) T_numtype;
+    typedef P_op    T_op;
+
+#ifdef BZ_PASS_EXPR_BY_VALUE
+    _bz_MatExprOp(T_expr1 a, T_expr2 b)
+        : iter1_(a), iter2_(b)
+    { }
+#else
+    _bz_MatExprOp(const T_expr1& a, const T_expr2& b)
+        : iter1_(a), iter2_(b)
+    { }
+#endif
+
+    T_numtype operator()(unsigned i, unsigned j) const
+    { return T_op::apply(iter1_(i,j), iter2_(i,j)); }
+
+    unsigned rows(unsigned recommendedRows) const
+    {
+        BZPRECONDITION(iter2_.rows(recommendedRows) == 
+            iter1_.rows(recommendedRows));
+        return iter1_.rows(recommendedRows);
+    }
+
+    unsigned cols(unsigned recommendedCols) const
+    {
+        BZPRECONDITION(iter2_.cols(recommendedCols) == 
+            iter1_.cols(recommendedCols));
+        return iter1_.cols(recommendedCols);
+    }
+
+private:
+    T_expr1 iter1_;
+    T_expr2 iter2_;
+};
+
+template<class P_expr, class P_unaryOp>
+class _bz_MatExprUnaryOp : public BlitzMatrixExpressionsBase {
+
+public:
+    typedef P_expr T_expr;
+    typedef P_unaryOp T_unaryOp;
+    typedef _bz_typename T_unaryOp::T_numtype T_numtype;
+
+#ifdef BZ_PASS_EXPR_BY_VALUE
+    _bz_MatExprUnaryOp(T_expr iter)
+        : iter_(iter)
+    { }
+#else
+    _bz_MatExprUnaryOp(const T_expr& iter)
+        : iter_(iter)
+    { }
+#endif
+
+    T_numtype operator()(unsigned i, unsigned j) const
+    { return T_unaryOp::apply(iter_(i,j)); }
+
+    unsigned rows(unsigned recommendedRows) const
+    { return iter_.rows(recommendedRows); }
+
+    unsigned cols(unsigned recommendedCols) const
+    { return iter_.cols(recommendedCols); }
+
+private:
+    T_expr iter_;    
+};
+
+template<class P_numtype>
+class _bz_MatExprConstant : public BlitzMatrixExpressionsBase {
+public:
+    typedef P_numtype T_numtype;
+
+    _bz_MatExprConstant(P_numtype value)
+        : value_(value)
+    { }
+
+    T_numtype operator()(unsigned i, unsigned j) const
+    { return value_; }
+
+    unsigned rows(unsigned recommendedRows) const
+    { return recommendedRows; }
+
+    unsigned cols(unsigned recommendedCols) const
+    { return recommendedCols; }
+
+private:
+    T_numtype value_;
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/matref.h>
+#include <blitz/matbops.h>
+#include <blitz/matuops.h>
+
+#endif // BZ_MATEXPR_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matgen.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matgen.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matgen.h	(revision 1307)
@@ -0,0 +1,213 @@
+/***************************************************************************
+ * blitz/matgen.h       Declarations for RowMajor and ColumnMajor matrices
+ *
+ * $Id: matgen.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_MATGEN_H
+#define BZ_MATGEN_H
+
+#ifndef BZ_MSTRUCT_H
+ #error <blitz/matgen.h> must be included via <blitz/mstruct.h>
+#endif // BZ_MSTRUCT_H
+
+BZ_NAMESPACE(blitz)
+
+class GeneralMatrix : public AsymmetricMatrix {
+
+public:
+    GeneralMatrix()
+    { }
+
+    GeneralMatrix(unsigned rows, unsigned cols)
+        : AsymmetricMatrix(rows, cols)
+    {
+    }
+
+    unsigned firstInRow(unsigned i) const
+    { return 0; }
+
+    unsigned lastInRow(unsigned i) const
+    { return cols_ - 1; }
+
+    unsigned firstInCol(unsigned j) const
+    { return 0; }
+
+    unsigned lastInCol(unsigned j) const
+    { return rows_ - 1; }
+
+    unsigned numElements() const
+    { return rows_ * cols_; }
+};
+
+class GeneralIterator {
+public:
+    GeneralIterator(unsigned rows, unsigned cols)
+    {
+        rows_ = rows;
+        cols_ = cols;
+        i_ = 0;
+        j_ = 0;
+        offset_ = 0;
+        good_ = true;
+    }
+
+    unsigned offset() const
+    { return offset_; }
+
+    operator _bz_bool() const
+    { return good_; }
+   
+    unsigned row() const
+    { return i_; }
+
+    unsigned col() const
+    { return j_; }
+ 
+protected:
+    unsigned rows_, cols_;
+    unsigned offset_;
+    unsigned i_, j_;
+    _bz_bool good_;
+};
+
+class RowMajorIterator : public GeneralIterator {
+public:
+    RowMajorIterator(unsigned rows, unsigned cols)
+        : GeneralIterator(rows, cols)
+    { }
+
+    void operator++()
+    {
+        ++offset_;
+        ++j_;
+        if (j_ == cols_)
+        {
+            j_ = 0;
+            ++i_;
+            if (i_ == rows_)
+                good_ = false;
+        }
+    }
+};
+
+class RowMajor : public GeneralMatrix {
+
+public:
+    typedef RowMajorIterator T_iterator;
+
+    RowMajor()
+    { }
+
+    RowMajor(unsigned rows, unsigned cols)
+        : GeneralMatrix(rows, cols)
+    { }
+
+    unsigned coordToOffset(unsigned i, unsigned j) const
+    {
+        return i*cols_+j;
+    }
+
+    template<class T_numtype>
+    T_numtype get(const T_numtype * _bz_restrict data,
+        unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        return data[coordToOffset(i,j)];
+    }
+
+    template<class T_numtype>
+    T_numtype& get(T_numtype * _bz_restrict data, unsigned i, unsigned j)
+    {
+        BZPRECONDITION(inRange(i,j));
+        return data[coordToOffset(i,j)];
+    }
+};
+
+class ColumnMajorIterator : public GeneralIterator {
+public:
+    ColumnMajorIterator(unsigned rows, unsigned cols)
+        : GeneralIterator(rows, cols)
+    {
+    }
+
+    void operator++()
+    {
+        ++offset_;
+        ++i_;
+        if (i_ == rows_)
+        {
+            i_ = 0;
+            ++j_;
+            if (j_ == cols_)
+                good_ = false;
+        }
+    }
+};
+
+class ColumnMajor : public GeneralMatrix {
+
+public:
+    ColumnMajor()
+    { }
+
+    ColumnMajor(unsigned rows, unsigned cols)
+        : GeneralMatrix(rows, cols)
+    { }
+
+    unsigned coordToOffset(unsigned i, unsigned j) const
+    {
+        return j*rows_ + i;
+    }
+
+    template<class T_numtype>
+    T_numtype get(const T_numtype * _bz_restrict data,
+        unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        return data[coordToOffset(i,j)];
+    }
+
+    template<class T_numtype>
+    T_numtype& get(T_numtype * _bz_restrict data, unsigned i, unsigned j)
+    {
+        BZPRECONDITION(inRange(i,j));
+        return data[coordToOffset(i,j)];
+    }
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATGEN_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/mathf2.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/mathf2.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/mathf2.h	(revision 1307)
@@ -0,0 +1,252 @@
+#ifndef BZ_MATHF2_H
+#define BZ_MATHF2_H
+
+#ifndef BZ_APPLICS_H
+ #error <blitz/mathf2.h> should be included via <blitz/applics.h>
+#endif
+
+#ifndef BZ_PRETTYPRINT_H
+ #include <blitz/prettyprint.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// cexp(z)     Complex exponential
+template<class P_numtype1>
+class _bz_cexp : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return _bz_exp<T_numtype1>::apply(x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cexp(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// csqrt(z)    Complex square root
+template<class P_numtype1>
+class _bz_csqrt : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return _bz_sqrt<T_numtype1>::apply(x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "csqrt(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// pow2        Square
+template<class P_numtype1>
+class _bz_pow2 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { 
+        return BZ_NO_PROPAGATE(x) * BZ_NO_PROPAGATE(x);
+    }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "pow2(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// pow3        Cube
+template<class P_numtype1>
+class _bz_pow3 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { 
+        return BZ_NO_PROPAGATE(x) * BZ_NO_PROPAGATE(x) *
+          BZ_NO_PROPAGATE(x);
+    }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "pow3(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// pow4        Fourth power
+template<class P_numtype1>
+class _bz_pow4 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { 
+        T_numtype t1 = BZ_NO_PROPAGATE(x) * BZ_NO_PROPAGATE(x);
+        return BZ_NO_PROPAGATE(t1) * BZ_NO_PROPAGATE(t1);
+    }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "pow4(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// pow5        Fifth power
+template<class P_numtype1>
+class _bz_pow5 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    {
+        T_numtype t1 = BZ_NO_PROPAGATE(x) * BZ_NO_PROPAGATE(x);
+        return BZ_NO_PROPAGATE(t1) * BZ_NO_PROPAGATE(t1)
+            * BZ_NO_PROPAGATE(t1);
+    }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "pow5(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// pow6        Sixth power
+template<class P_numtype1>
+class _bz_pow6 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    {
+        T_numtype t1 = BZ_NO_PROPAGATE(x) * BZ_NO_PROPAGATE(x) 
+            * BZ_NO_PROPAGATE(x);
+        return BZ_NO_PROPAGATE(t1) * BZ_NO_PROPAGATE(t1);
+    }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "pow6(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+
+// pow7        Seventh power
+template<class P_numtype1>
+class _bz_pow7 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    {
+        T_numtype t1 = BZ_NO_PROPAGATE(x) * BZ_NO_PROPAGATE(x) 
+            * BZ_NO_PROPAGATE(x);
+        return BZ_NO_PROPAGATE(t1) * BZ_NO_PROPAGATE(t1)
+            * BZ_NO_PROPAGATE(x);
+    }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "pow7(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// pow8        Eighth power
+template<class P_numtype1>
+class _bz_pow8 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    {
+        T_numtype t1 = BZ_NO_PROPAGATE(x) * BZ_NO_PROPAGATE(x);
+        T_numtype t2 = BZ_NO_PROPAGATE(t1) * BZ_NO_PROPAGATE(t1);
+        return BZ_NO_PROPAGATE(t2) * BZ_NO_PROPAGATE(t2);
+    }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "pow8(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+/*
+ * These scalar versions of pow2, pow3, ..., pow8 are provided for
+ * convenience.
+ *
+ * NEEDS_WORK -- include BZ_NO_PROPAGATE for these scalar versions.
+ */
+
+// NEEDS_WORK -- make these templates.  Rely on specialization to
+// handle expression template versions.
+
+#define BZ_DECLARE_POW(T)  \
+ inline T pow2(T x) { return x*x; }                  \
+ inline T pow3(T x) { return x*x*x; }                \
+ inline T pow4(T x) { T t1 = x*x; return t1*t1; }    \
+ inline T pow5(T x) { T t1 = x*x; return t1*t1*x; }  \
+ inline T pow6(T x) { T t1 = x*x*x; return t1*t1; }  \
+ inline T pow7(T x) { T t1 = x*x; return t1*t1*t1*x; } \
+ inline T pow8(T x) { T t1 = x*x, t2=t1*t1; return t2*t2; }  
+
+BZ_DECLARE_POW(int)
+BZ_DECLARE_POW(float)
+BZ_DECLARE_POW(double)
+BZ_DECLARE_POW(long double)
+
+#ifdef BZ_HAVE_COMPLEX
+BZ_DECLARE_POW(complex<float>)
+BZ_DECLARE_POW(complex<double>)
+BZ_DECLARE_POW(complex<long double>)
+#endif
+
+BZ_NAMESPACE_END
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/mathfunc.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/mathfunc.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/mathfunc.h	(revision 1307)
@@ -0,0 +1,2680 @@
+// Generated: genmathfunc.cpp Jul 28 1998 17:29:02
+
+#ifndef BZ_MATHFUNC_H
+#define BZ_MATHFUNC_H
+
+#ifndef BZ_APPLICS_H
+ #error <blitz/mathfunc.h> should be included via <blitz/applics.h>
+#endif
+
+
+#ifndef BZ_PRETTYPRINT_H
+ #include <blitz/prettyprint.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// abs(P_numtype1)    Absolute value
+template<class P_numtype1>
+class _bz_abs : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype1 T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(abs)(x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "abs(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// abs(long)
+template<>
+class _bz_abs<long> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long T_numtype1;
+    typedef long T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(labs)((long)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "labs(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// abs(float)
+template<>
+class _bz_abs<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(fabs)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "fabs(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// abs(double)
+template<>
+class _bz_abs<double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef double T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(fabs)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "fabs(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// abs(long double)
+template<>
+class _bz_abs<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(fabs)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "fabs(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// acos(P_numtype1)    Inverse cosine
+template<class P_numtype1>
+class _bz_acos : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(acos)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "acos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// acos(float)
+template<>
+class _bz_acos<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(acos)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "acos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// acos(long double)
+template<>
+class _bz_acos<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(acos)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "acos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// acos(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_acos<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(acos)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "acos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// acos(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_acos<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(acos)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "acos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// acos(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_acos<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(acos)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "acos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// acosh(P_numtype1)    Inverse hyperbolic cosine
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_acosh : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(acosh)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "acosh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// asin(P_numtype1)    Inverse sine
+template<class P_numtype1>
+class _bz_asin : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(asin)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "asin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// asin(float)
+template<>
+class _bz_asin<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(asin)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "asin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// asin(long double)
+template<>
+class _bz_asin<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(asin)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "asin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// asin(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_asin<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(asin)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "asin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// asin(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_asin<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(asin)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "asin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// asin(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_asin<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(asin)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "asin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// asinh(P_numtype1)    Inverse hyperbolic sine
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_asinh : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(asinh)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "asinh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// atan(P_numtype1)    Inverse tangent
+template<class P_numtype1>
+class _bz_atan : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(atan)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "atan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// atan(float)
+template<>
+class _bz_atan<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(atan)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "atan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// atan(long double)
+template<>
+class _bz_atan<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(atan)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "atan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// atan(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_atan<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(atan)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "atan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// atan(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_atan<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(atan)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "atan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// atan(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_atan<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(atan)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "atan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// atanh(P_numtype1)    Inverse hyperbolic tangent
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_atanh : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(atanh)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "atanh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// atan2(P_numtype1, P_numtype2)    Inverse tangent
+template<class P_numtype1, class P_numtype2>
+class _bz_atan2 : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(atan2)((double)x,(double)y); }
+};
+
+// atan2(float, float)
+template<>
+class _bz_atan2<float, float > : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype2;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(atan2)((float)x,(float)y); }
+};
+
+// atan2(long double, long double)
+template<>
+class _bz_atan2<long double, long double > : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype2;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(atan2)((long double)x,(long double)y); }
+};
+
+// _class(P_numtype1)    Classification of float-point value (FP_xxx)
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1>
+class _bz__class : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef int T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(_class)(x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "_class(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// cbrt(P_numtype1)    Cube root
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_cbrt : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(cbrt)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cbrt(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// ceil(P_numtype1)    Ceiling
+template<class P_numtype1>
+class _bz_ceil : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(ceil)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "ceil(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// ceil(float)
+template<>
+class _bz_ceil<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(ceil)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "ceil(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// ceil(long double)
+template<>
+class _bz_ceil<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(ceil)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "ceil(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// cos(P_numtype1)    Cosine
+template<class P_numtype1>
+class _bz_cos : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(cos)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// cos(float)
+template<>
+class _bz_cos<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(cos)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// cos(long double)
+template<>
+class _bz_cos<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(cos)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// cos(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_cos<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(cos)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// cos(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_cos<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(cos)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// cos(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_cos<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(cos)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cos(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// copysign(P_numtype1, P_numtype2)
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1, class P_numtype2>
+class _bz_copysign : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(copysign)((double)x,(double)y); }
+};
+#endif
+
+// cosh(P_numtype1)    Hyperbolic cosine
+template<class P_numtype1>
+class _bz_cosh : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(cosh)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cosh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// cosh(float)
+template<>
+class _bz_cosh<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(cosh)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cosh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// cosh(long double)
+template<>
+class _bz_cosh<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(cosh)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cosh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// cosh(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_cosh<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(cosh)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cosh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// cosh(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_cosh<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(cosh)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cosh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// cosh(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_cosh<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(cosh)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "cosh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// drem(P_numtype1, P_numtype2)    Remainder
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1, class P_numtype2>
+class _bz_drem : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(drem)((double)x,(double)y); }
+};
+#endif
+
+// exp(P_numtype1)    Exponential
+template<class P_numtype1>
+class _bz_exp : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(exp)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "exp(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// exp(float)
+template<>
+class _bz_exp<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(exp)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "exp(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// exp(long double)
+template<>
+class _bz_exp<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(exp)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "exp(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// exp(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_exp<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(exp)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "exp(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// exp(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_exp<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(exp)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "exp(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// exp(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_exp<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(exp)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "exp(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// expm1(P_numtype1)    Exp(x)-1
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_expm1 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(expm1)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "expm1(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// erf(P_numtype1)    Error function
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_erf : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(erf)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "erf(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// erfc(P_numtype1)    Complementary error function
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_erfc : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(erfc)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "erfc(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// finite(P_numtype1)    Nonzero if finite
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_finite : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef int T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(finite)(x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "finite(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// floor(P_numtype1)    Floor function
+template<class P_numtype1>
+class _bz_floor : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(floor)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "floor(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// floor(float)
+template<>
+class _bz_floor<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(floor)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "floor(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// floor(long double)
+template<>
+class _bz_floor<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(floor)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "floor(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// fmod(P_numtype1, P_numtype2)    Modulo remainder
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1, class P_numtype2>
+class _bz_fmod : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(fmod)((double)x,(double)y); }
+};
+#endif
+
+// hypot(P_numtype1, P_numtype2)    sqrt(x*x+y*y)
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1, class P_numtype2>
+class _bz_hypot : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(hypot)((double)x,(double)y); }
+};
+#endif
+
+// ilogb(P_numtype1)    Integer unbiased exponent
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1>
+class _bz_ilogb : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef int T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(ilogb)(x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "ilogb(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// isnan(P_numtype1)    Nonzero if NaNS or NaNQ
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_isnan : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef int T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(isnan)(x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "isnan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// itrunc(P_numtype1)    Truncate and convert to integer
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1>
+class _bz_itrunc : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef int T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(itrunc)(x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "itrunc(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// j0(P_numtype1)    Bessel function first kind, order 0
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_j0 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(j0)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "j0(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// j1(P_numtype1)    Bessel function first kind, order 1
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_j1 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(j1)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "j1(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// lgamma(P_numtype1)    Log absolute gamma
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_lgamma : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(lgamma)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "lgamma(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// log(P_numtype1)    Natural logarithm
+template<class P_numtype1>
+class _bz_log : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(log)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// log(float)
+template<>
+class _bz_log<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(log)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// log(long double)
+template<>
+class _bz_log<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(log)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// log(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_log<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(log)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// log(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_log<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(log)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// log(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_log<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(log)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// logb(P_numtype1)    Unbiased exponent (IEEE)
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_logb : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(logb)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "logb(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// log1p(P_numtype1)    Compute log(1 + x)
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_log1p : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(log1p)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log1p(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// log10(P_numtype1)    Logarithm base 10
+template<class P_numtype1>
+class _bz_log10 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(log10)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log10(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// log10(float)
+template<>
+class _bz_log10<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(log10)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log10(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// log10(long double)
+template<>
+class _bz_log10<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(log10)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log10(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// log10(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_log10<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(log10)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log10(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// log10(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_log10<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(log10)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log10(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// log10(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH2
+template<>
+class _bz_log10<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(log10)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "log10(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// nearest(P_numtype1)    Nearest floating point integer
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1>
+class _bz_nearest : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(nearest)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "nearest(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// nextafter(P_numtype1, P_numtype2)    Next representable number after x towards y
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1, class P_numtype2>
+class _bz_nextafter : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(nextafter)((double)x,(double)y); }
+};
+#endif
+
+template<class P_numtype>
+class _bz_negate : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef BZ_SIGNEDTYPE(P_numtype) T_numtype;
+
+    static inline T_numtype apply(T_numtype x)
+    { return -x; }
+};
+
+// pow(P_numtype1, P_numtype2)    Power
+template<class P_numtype1, class P_numtype2>
+class _bz_pow : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(pow)((double)x,(double)y); }
+};
+
+// pow(float, float)
+template<>
+class _bz_pow<float, float > : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype2;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(pow)((float)x,(float)y); }
+};
+
+// pow(long double, long double)
+template<>
+class _bz_pow<long double, long double > : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype2;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(pow)((long double)x,(long double)y); }
+};
+
+// pow(complex<float>, complex<float>)
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_pow<complex<float>, complex<float> > : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float> T_numtype1;
+    typedef complex<float> T_numtype2;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_CMATHFN_SCOPE(pow)((complex<float>)x,(complex<float>)y); }
+};
+#endif
+
+// pow(complex<double>, complex<double>)
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_pow<complex<double>, complex<double> > : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double> T_numtype1;
+    typedef complex<double> T_numtype2;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_CMATHFN_SCOPE(pow)((complex<double>)x,(complex<double>)y); }
+};
+#endif
+
+// pow(complex<long double>, complex<long double>)
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_pow<complex<long double>, complex<long double> > : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double> T_numtype1;
+    typedef complex<long double> T_numtype2;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_CMATHFN_SCOPE(pow)((complex<long double>)x,(complex<long double>)y); }
+};
+#endif
+
+// remainder(P_numtype1, P_numtype2)    Remainder
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1, class P_numtype2>
+class _bz_remainder : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(remainder)((double)x,(double)y); }
+};
+#endif
+
+// rint(P_numtype1)    Round to floating point integer
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_rint : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(rint)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "rint(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// rsqrt(P_numtype1)    Reciprocal square root
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1>
+class _bz_rsqrt : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(rsqrt)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "rsqrt(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// scalb(P_numtype1, P_numtype2)    x * (2**y)
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1, class P_numtype2>
+class _bz_scalb : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(scalb)((double)x,(double)y); }
+};
+#endif
+
+// sin(P_numtype1)    Sine
+template<class P_numtype1>
+class _bz_sin : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(sin)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sin(float)
+template<>
+class _bz_sin<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(sin)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sin(long double)
+template<>
+class _bz_sin<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(sin)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sin(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_sin<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(sin)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// sin(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_sin<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(sin)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// sin(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_sin<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(sin)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sin(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// sinh(P_numtype1)    Hyperbolic sine
+template<class P_numtype1>
+class _bz_sinh : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(sinh)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sinh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sinh(float)
+template<>
+class _bz_sinh<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(sinh)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sinh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sinh(long double)
+template<>
+class _bz_sinh<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(sinh)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sinh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sinh(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_sinh<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(sinh)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sinh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// sinh(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_sinh<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(sinh)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sinh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// sinh(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_sinh<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(sinh)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sinh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+template<class P_numtype>
+class _bz_sqr : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype T_numtype;
+
+    static inline T_numtype apply(T_numtype x)
+    { return x*x; }
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sqr(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// Specialization of _bz_sqr for complex<T>
+template<class T>
+class _bz_sqr<complex<T> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<T> T_numtype;
+
+    static inline T_numtype apply(T_numtype x)
+    {
+        T r = x.real();  T i = x.imag();
+        return T_numtype(r*r-i*i, 2*r*i);
+    }
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sqr(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sqrt(P_numtype1)    Square root
+template<class P_numtype1>
+class _bz_sqrt : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(sqrt)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sqrt(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sqrt(float)
+template<>
+class _bz_sqrt<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(sqrt)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sqrt(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sqrt(long double)
+template<>
+class _bz_sqrt<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(sqrt)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sqrt(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// sqrt(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_sqrt<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(sqrt)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sqrt(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// sqrt(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_sqrt<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(sqrt)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sqrt(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// sqrt(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_sqrt<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(sqrt)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "sqrt(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// tan(P_numtype1)    Tangent
+template<class P_numtype1>
+class _bz_tan : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(tan)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// tan(float)
+template<>
+class _bz_tan<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(tan)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// tan(long double)
+template<>
+class _bz_tan<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(tan)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// tan(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_tan<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(tan)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// tan(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_tan<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(tan)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// tan(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_tan<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(tan)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tan(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// tanh(P_numtype1)    Hyperbolic tangent
+template<class P_numtype1>
+class _bz_tanh : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(tanh)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tanh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// tanh(float)
+template<>
+class _bz_tanh<float> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef float T_numtype1;
+    typedef float T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(tanh)((float)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tanh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// tanh(long double)
+template<>
+class _bz_tanh<long double> : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef long double T_numtype1;
+    typedef long double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(tanh)((long double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tanh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+
+// tanh(complex<float> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_tanh<complex<float> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<float>  T_numtype1;
+    typedef complex<float> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(tanh)((complex<float> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tanh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// tanh(complex<double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_tanh<complex<double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<double>  T_numtype1;
+    typedef complex<double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(tanh)((complex<double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tanh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// tanh(complex<long double> )
+#ifdef BZ_HAVE_COMPLEX_MATH1
+template<>
+class _bz_tanh<complex<long double> > : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef complex<long double>  T_numtype1;
+    typedef complex<long double> T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_CMATHFN_SCOPE(tanh)((complex<long double> )x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "tanh(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// trunc(P_numtype1)    Nearest floating integer in the direction of zero
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_trunc : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(trunc)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "trunc(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// uitrunc(P_numtype1)    Truncate and convert to unsigned
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1>
+class _bz_uitrunc : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef unsigned T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(uitrunc)((unsigned)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "uitrunc(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// unordered(P_numtype1, P_numtype2)    True if a comparison of x and y would be unordered
+#ifdef BZ_HAVE_SYSTEM_V_MATH
+template<class P_numtype1, class P_numtype2>
+class _bz_unordered : public TwoOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef P_numtype2 T_numtype2;
+    typedef int T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
+    { return BZ_MATHFN_SCOPE(unordered)(x,y); }
+};
+#endif
+
+// y0(P_numtype1)    Bessel function of the second kind, order zero
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_y0 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(y0)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "y0(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+// y1(P_numtype1)    Bessel function of the second kind, order one
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+class _bz_y1 : public OneOperandApplicativeTemplatesBase {
+public:
+    typedef P_numtype1 T_numtype1;
+    typedef double T_numtype;
+
+    static inline T_numtype apply(T_numtype1 x)
+    { return BZ_MATHFN_SCOPE(y1)((double)x); }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "y1(";
+        a.prettyPrint(str,format);
+        str += ")";
+    }
+};
+#endif
+
+
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATHFUNC_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matltri.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matltri.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matltri.h	(revision 1307)
@@ -0,0 +1,190 @@
+/***************************************************************************
+ * blitz/matltri.h      Declarations for LowerTriangular matrices
+ *
+ * $Id: matltri.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+
+#ifndef BZ_MATLTRI_H
+#define BZ_MATLTRI_H
+
+#ifndef BZ_MSTRUCT_H
+ #error <blitz/matltri.h> must be included via <blitz/mstruct.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Lower triangular, row major ordering
+// [ 0 . . . ]
+// [ 1 2 . . ]
+// [ 3 4 5 . ]
+// [ 6 7 8 9 ]
+
+class LowerTriangularIterator {
+public:
+    LowerTriangularIterator(unsigned rows, unsigned cols)
+    {
+        BZPRECONDITION(rows == cols);
+        size_ = rows;
+        good_ = true;
+        offset_ = 0;
+        i_ = 0;
+        j_ = 0;
+    }
+   
+    operator _bz_bool() const
+    { return good_; }
+
+    void operator++()
+    {
+        BZPRECONDITION(good_);
+        ++offset_;
+        ++j_;
+        if (j_ > i_)
+        {
+            j_ = 0;
+            ++i_;
+            if (i_ == size_)
+                good_ = false;
+        }
+    }
+
+    unsigned row() const
+    { return i_; }
+
+    unsigned col() const
+    { return j_; }
+
+    unsigned offset() const
+    { return offset_; }
+
+protected:
+    unsigned size_;
+    _bz_bool good_;
+    unsigned offset_;
+    unsigned i_, j_;
+};
+
+class LowerTriangular : public MatrixStructure {
+
+public:
+    typedef LowerTriangularIterator T_iterator;
+
+    LowerTriangular()
+        : size_(0)
+    { }
+
+    LowerTriangular(unsigned size)
+        : size_(size)
+    { }
+
+    LowerTriangular(unsigned rows, unsigned cols)
+        : size_(rows)
+    {
+        BZPRECONDITION(rows == cols);
+    }
+
+    unsigned columns() const
+    { return size_; }
+
+    unsigned coordToOffset(unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        BZPRECONDITION(i >= j);
+        return i*(i+1)/2 + j;
+    }
+
+    unsigned firstInRow(unsigned i) const
+    { return 0; }
+
+    template<class T_numtype>
+    T_numtype get(const T_numtype * _bz_restrict data,
+        unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        if (i >= j)
+            return data[coordToOffset(i,j)];
+        else
+            return ZeroElement<T_numtype>::zero();
+    }
+
+    template<class T_numtype>
+    T_numtype& get(T_numtype * _bz_restrict data, unsigned i, unsigned j)
+    {
+        BZPRECONDITION(inRange(i,j));
+        if (i >= j)
+            return data[coordToOffset(i,j)];
+        else
+            return ZeroElement<T_numtype>::zero();
+    }
+
+    unsigned lastInRow(unsigned i) const
+    { return i; }
+
+    unsigned firstInCol(unsigned j) const
+    { return j; }
+
+    unsigned lastInCol(unsigned j) const
+    { return size_ - 1; }
+
+    _bz_bool inRange(unsigned i, unsigned j) const
+    {
+        return (i < size_) && (j < size_);
+    }
+
+    unsigned numElements() const
+    { return size_ * (size_ + 1) / 2; }
+
+    unsigned rows() const
+    { return size_; }
+
+    void resize(unsigned size)
+    {
+        size_ = size;
+    }
+
+    void resize(unsigned rows, unsigned cols)
+    {
+        BZPRECONDITION(rows == cols);
+        size_  = rows;
+    }
+
+private:
+    unsigned size_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATLTRI_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matref.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matref.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matref.h	(revision 1307)
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * blitz/matref.h      Declaration of the _bz_MatrixRef<P_numtype, P_structure>
+ *                     class.
+ *
+ * $Id: matref.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_MATREF_H
+#define BZ_MATREF_H
+
+#ifndef BZ_MATEXPR_H
+ #error <blitz/matref.h> must be included via <blitz/matexpr.h>
+#endif // BZ_MATEXPR_H
+
+BZ_NAMESPACE(blitz)
+
+template<class P_numtype, class P_structure>
+class _bz_MatrixRef {
+
+public:
+    typedef P_numtype T_numtype;
+
+    _bz_MatrixRef(const Matrix<P_numtype, P_structure>& m)
+        : matrix_(&m)
+    { }
+
+    T_numtype operator()(unsigned i, unsigned j) const
+    { return (*matrix_)(i,j); }
+
+    unsigned rows(unsigned) const
+    { return matrix_->rows(); }
+
+    unsigned cols(unsigned) const
+    { return matrix_->cols(); }
+
+private:
+    _bz_MatrixRef() { } 
+
+    const Matrix<P_numtype, P_structure>* matrix_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATREF_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matrix.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matrix.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matrix.cc	(revision 1307)
@@ -0,0 +1,71 @@
+/*
+ * $Id: matrix.cc,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_MATRIX_CC
+#define BZ_MATRIX_CC
+
+#ifndef BZ_MATRIX_H
+ #include <blitz/matrix.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Matrix expression operand
+template<class P_numtype, class P_structure> template<class P_expr>
+Matrix<P_numtype, P_structure>& 
+Matrix<P_numtype, P_structure>::operator=(_bz_MatExpr<P_expr> expr)
+{
+    // Check for compatible structures.
+
+    // Fast evaluation (compatible structures)
+    // (not implemented)
+
+    // Slow evaluation
+    _bz_typename P_structure::T_iterator iter(rows(), cols());
+    while (iter)
+    {
+        data_[iter.offset()] = expr(iter.row(), iter.col());
+        ++iter;
+    }
+
+    return *this;
+}
+
+template<class P_numtype, class P_structure>
+ostream& operator<<(ostream& os, const Matrix<P_numtype, P_structure>& matrix)
+{
+    os << "[ ";
+    for (int i=0; i < matrix.rows(); ++i)
+    {
+        for (int j=0; j < matrix.columns(); ++j)
+        {
+            os << setw(10) << matrix(i,j);
+            if ((!((j+1)%7)) && (j < matrix.cols()-1))
+                os << endl << "         ...";
+        }
+        if (i != matrix.rows() - 1)
+            os << endl  << "  ";
+    }
+    os << " ]";
+    return os;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATRIX_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matrix.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matrix.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matrix.h	(revision 1307)
@@ -0,0 +1,234 @@
+/***************************************************************************
+ * blitz/matrix.h      Declaration of the Matrix<T_type, T_structure> class
+ *
+ * $Id: matrix.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.6  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.5  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.4  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1996/11/11 17:29:13  tveldhui
+ * Initial revision
+ *
+ * Revision 1.2  1996/10/31 21:06:54  tveldhui
+ * Did away with multiple template parameters.  Only numeric type
+ * and structure parameters now.
+ *
+ *
+ */
+
+#ifndef BZ_MATRIX_H
+#define BZ_MATRIX_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_MEMBLOCK_H
+ #include <blitz/memblock.h>
+#endif
+
+#ifndef BZ_MSTRUCT_H
+ #include <blitz/mstruct.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Forward declarations
+template<class P_numtype, class P_structure>
+class _bz_MatrixRef;
+
+template<class P_expr>
+class _bz_MatExpr;
+
+// Declaration of class Matrix
+template<class P_numtype, class P_structure BZ_TEMPLATE_DEFAULT(RowMajor)>
+class Matrix : protected MemoryBlockReference<P_numtype> {
+
+public:
+
+    //////////////////////////////////////////////
+    // Public Types
+    //////////////////////////////////////////////
+
+    typedef P_numtype        T_numtype;
+    typedef P_structure      T_structure;
+    typedef Matrix<P_numtype, P_structure>   T_matrix;
+
+    //////////////////////////////////////////////
+    // Constructors                             //
+    //////////////////////////////////////////////
+
+    Matrix()
+    { }
+
+    Matrix(int rows, int cols, T_structure structure = T_structure())
+        : structure_(structure) 
+    {
+        structure_.resize(rows, cols);
+        MemoryBlockReference<T_numtype>::newBlock(structure_.numElements());
+    }
+
+    // Matrix(int rows, int cols, T_numtype initValue,
+    //    T_structure structure = T_structure(rows, cols));
+    // Matrix(int rows, int cols, Random);
+    // Matrix(int rows, int cols, matrix-expression);
+    // Matrix(int rows, int cols, T_numtype* data, int rowStride, int colStride);
+    // _bz_explicit Matrix(Vector<T_numtype>& matrix);
+    // _bz_explicit Matrix(unsigned length);
+
+    // Create a vector view of an already allocated block of memory.
+    // Note that the memory will not be freed when this vector is
+    // destroyed.
+    // Matrix(unsigned length, T_numtype* data, int stride = 1);
+
+    //////////////////////////////////////////////
+    // Member functions
+    //////////////////////////////////////////////
+
+    //T_iterator      begin()  const;
+    //T_constIterator begin()  const;
+    //T_vector        copy()   const;
+    //T_iterator      end()    const;
+    //T_constIterator end()    const;
+
+    unsigned        cols()        const
+    { return structure_.columns(); }
+
+    unsigned        columns()     const
+    { return structure_.columns(); }
+
+    void            makeUnique()  const;
+
+    unsigned        numElements() const
+    { return structure_.numElements(); }
+
+    void            reference(T_matrix&);
+
+    void            resize(unsigned rows, unsigned cols)
+    {
+        structure_.resize(rows, cols);
+        MemoryBlockReference<T_numtype>::newBlock(structure_.numElements());
+    }
+
+//    void            resizeAndPreserve(unsigned newLength);
+
+    unsigned        rows()   const
+    { return structure_.rows(); }
+
+    _bz_MatrixRef<T_numtype, T_structure> _bz_getRef() const
+    { return _bz_MatrixRef<T_numtype, T_structure>(*this); }
+
+    //////////////////////////////////////////////
+    // Subscripting operators
+    //////////////////////////////////////////////
+
+    T_numtype           operator()(unsigned i, unsigned j) const
+    {
+        return structure_.get(data_, i, j);
+    }
+
+    T_numtype& _bz_restrict operator()(unsigned i, unsigned j)
+    {
+        return structure_.get(data_, i, j);
+    }
+
+    // T_matrix      operator()(Range,Range);
+
+    // T_matrixIndirect operator()(Vector<int>,Vector<int>);
+    // T_matrixIndirect operator()(integer-placeholder-expression, Range);
+    // T_matrix         operator()(difference-equation-expression)
+
+    //////////////////////////////////////////////
+    // Assignment operators
+    //////////////////////////////////////////////
+
+    // Scalar operand
+    T_matrix& operator=(T_numtype);
+    T_matrix& operator+=(T_numtype);
+    T_matrix& operator-=(T_numtype);
+    T_matrix& operator*=(T_numtype);
+    T_matrix& operator/=(T_numtype);
+
+    // Matrix operand
+
+    template<class P_numtype2, class P_structure2> 
+    T_matrix& operator=(const Matrix<P_numtype2, P_structure2> &);
+    template<class P_numtype2, class P_structure2> 
+    T_matrix& operator+=(const Matrix<P_numtype2, P_structure2>&);
+    template<class P_numtype2, class P_structure2> 
+    T_matrix& operator-=(const Matrix<P_numtype2, P_structure2> &);
+    template<class P_numtype2, class P_structure2> 
+    T_matrix& operator*=(const Matrix<P_numtype2, P_structure2> &);
+    template<class P_numtype2, class P_structure2> 
+    T_matrix& operator/=(const Matrix<P_numtype2, P_structure2> &);
+
+    // Matrix expression operand
+    template<class P_expr>
+    T_matrix& operator=(_bz_MatExpr<P_expr>);
+
+    // Integer placeholder expression operand
+    // MatrixPick operand
+
+    //////////////////////////////////////////////
+    // Unary operators
+    //////////////////////////////////////////////
+
+    T_matrix& operator++();
+    void operator++(int);
+    T_matrix& operator--();
+    void operator--(int);
+    
+private:
+    T_structure structure_;
+};
+
+template<class P_numtype, class P_structure>
+ostream& operator<<(ostream& os, const Matrix<P_numtype, P_structure>& matrix);
+
+// Global operators
+// +,-,*,/ with all possible combinations of:
+//    - scalar
+//    - matrix
+//    - matrix pick
+//    - matrix expression
+// Pointwise Math functions: sin, cos, etc.
+// Global functions
+
+BZ_NAMESPACE_END
+
+#include <blitz/matrix.cc>
+#include <blitz/matexpr.h>
+
+#endif // BZ_MATRIX_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matsymm.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matsymm.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matsymm.h	(revision 1307)
@@ -0,0 +1,185 @@
+/***************************************************************************
+ * blitz/matsymm.h      Declarations for Symmetric matrices
+ *
+ * $Id: matsymm.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_MATSYMM_H
+#define BZ_MATSYMM_H
+
+#ifndef BZ_MSTRUCT_H
+ #error <blitz/matsymm.h> must be included via <blitz/mstruct.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Symmetric, lower triangular row major ordering
+// [ 0 1 3 6 ]
+// [ 1 2 4 7 ]
+// [ 3 4 5 8 ]
+// [ 6 7 8 9 ]
+
+class SymmetricIterator {
+public:
+    SymmetricIterator(unsigned rows, unsigned cols)
+    {
+        BZPRECONDITION(rows == cols);
+        size_ = rows;
+        good_ = true;
+        offset_ = 0;
+        i_ = 0;
+        j_ = 0;
+    }
+   
+    operator _bz_bool() const
+    { return good_; }
+
+    void operator++()
+    {
+        BZPRECONDITION(good_);
+        ++offset_;
+        ++j_;
+        if (j_ > i_)
+        {
+            j_ = 0;
+            ++i_;
+            if (i_ == size_)
+                good_ = false;
+        }
+    }
+
+    unsigned row() const
+    { return i_; }
+
+    unsigned col() const
+    { return j_; }
+
+    unsigned offset() const
+    { return offset_; }
+
+protected:
+    unsigned size_;
+    _bz_bool good_;
+    unsigned offset_;
+    unsigned i_, j_;
+};
+
+class Symmetric : public MatrixStructure {
+
+public:
+    typedef SymmetricIterator T_iterator;
+
+    Symmetric()
+        : size_(0)
+    { }
+
+    Symmetric(unsigned size)
+        : size_(size)
+    { }
+
+    Symmetric(unsigned rows, unsigned cols)
+        : size_(rows)
+    {
+        BZPRECONDITION(rows == cols);
+    }
+
+    unsigned columns() const
+    { return size_; }
+
+    unsigned coordToOffset(unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        if (i >= j)
+            return i*(i+1)/2 + j;
+        else
+            return j*(j+1)/2 + i;
+    }
+
+    unsigned firstInRow(unsigned i) const
+    { return 0; }
+
+    template<class T_numtype>
+    T_numtype get(const T_numtype * _bz_restrict data,
+        unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        return data[coordToOffset(i,j)];
+    }
+
+    template<class T_numtype>
+    T_numtype& get(T_numtype * _bz_restrict data, unsigned i, unsigned j)
+    {
+        BZPRECONDITION(inRange(i,j));
+        return data[coordToOffset(i,j)];
+    }
+
+    unsigned lastInRow(unsigned i) const
+    { return i; }
+
+    unsigned firstInCol(unsigned j) const
+    { return j; }
+
+    unsigned lastInCol(unsigned j) const
+    { return size_ - 1; }
+
+    _bz_bool inRange(unsigned i, unsigned j) const
+    {
+        return (i < size_) && (j < size_);
+    }
+
+    unsigned numElements() const
+    { return size_ * (size_ + 1) / 2; }
+
+    unsigned rows() const
+    { return size_; }
+
+    void resize(unsigned size)
+    {
+        size_ = size;
+    }
+
+    void resize(unsigned rows, unsigned cols)
+    {
+        BZPRECONDITION(rows == cols);
+        size_  = rows;
+    }
+
+private:
+    unsigned size_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATSYMM_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/mattoep.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/mattoep.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/mattoep.h	(revision 1307)
@@ -0,0 +1,170 @@
+/***************************************************************************
+ * blitz/mattoep.h      Declarations for Toeplitz matrices
+ *
+ * $Id: mattoep.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_MATTOEP_H
+#define BZ_MATTOEP_H
+
+#ifndef BZ_MSTRUCT_H
+ #error <blitz/mattoep.h> must be included via <blitz/mstruct.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Toeplitz matrix
+// [ 0 1 2 3 ]
+// [ 1 2 3 4 ]
+// [ 2 3 4 5 ]
+// [ 3 4 5 6 ]
+
+class ToeplitzIterator {
+public:
+    ToeplitzIterator(unsigned rows, unsigned cols)
+    {
+        rows_ = rows;
+        cols_ = cols;
+        i_ = 0;
+        j_ = 0;
+        good_ = true;
+        offset_ = 0;
+    }
+
+    operator _bz_bool() const
+    {
+        return good_;
+    }
+
+    void operator++()
+    {
+        ++offset_;
+        if (i_ < rows_ - 1)
+            ++i_;
+        else if (j_ < cols_ - 1)
+            ++j_;
+        else
+            good_ = false;
+    }
+
+    unsigned row() const
+    { return i_; }
+
+    unsigned col() const
+    { return j_; }
+
+    unsigned offset() const
+    { return offset_; }
+
+protected:
+    unsigned offset_;
+    unsigned i_, j_;
+    unsigned rows_, cols_;
+    _bz_bool good_;
+};
+
+class Toeplitz : public GeneralMatrix {
+
+public:
+    typedef ToeplitzIterator T_iterator;
+
+    Toeplitz()
+        : rows_(0), cols_(0)
+    { }
+
+    Toeplitz(unsigned rows, unsigned cols)
+        : rows_(rows), cols_(cols)
+    { }
+
+    unsigned columns() const
+    { return cols_; }
+
+    unsigned coordToOffset(unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        return i + j;
+    }
+
+    unsigned firstInRow(unsigned i) const
+    { return 0; }
+
+    template<class T_numtype>
+    T_numtype get(const T_numtype * _bz_restrict data,
+        unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        return data[coordToOffset(i,j)];
+    }
+
+    template<class T_numtype>
+    T_numtype& get(T_numtype * _bz_restrict data, unsigned i, unsigned j)
+    {
+        BZPRECONDITION(inRange(i,j));
+        return data[coordToOffset(i,j)];
+    }
+
+    unsigned lastInRow(unsigned i) const
+    { return cols_ - 1; }
+
+    unsigned firstInCol(unsigned j) const
+    { return 0; }
+
+    unsigned lastInCol(unsigned j) const
+    { return rows_ - 1; }
+
+    _bz_bool inRange(unsigned i, unsigned j) const
+    {
+        return (i < rows_) && (j < cols_);
+    }
+
+    unsigned numElements() const
+    { return rows_ + cols_ - 1; }
+
+    unsigned rows() const
+    { return rows_; }
+
+    void resize(unsigned rows, unsigned cols)
+    {
+        rows_ = rows;
+        cols_ = cols;
+    }
+
+private:
+    unsigned rows_, cols_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATSYMM_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matuops.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matuops.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matuops.h	(revision 1307)
@@ -0,0 +1,1 @@
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/matutri.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/matutri.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/matutri.h	(revision 1307)
@@ -0,0 +1,187 @@
+/***************************************************************************
+ * blitz/matutri.h      Declarations for UpperTriangular matrices
+ *
+ * $Id: matutri.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ */
+
+#ifndef BZ_MATUTRI_H
+#define BZ_MATUTRI_H
+
+#ifndef BZ_MSTRUCT_H
+ #error <blitz/matutri.h> must be included via <blitz/mstruct.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Upper triangular, column major ordering
+// [ 0 1 3 6 ]
+// [ . 2 4 7 ]
+// [ . . 5 8 ]
+// [ . . . 9 ]
+
+class UpperTriangularIterator {
+public:
+    UpperTriangularIterator(unsigned rows, unsigned cols)
+    {
+        BZPRECONDITION(rows == cols);
+        size_ = rows;
+        good_ = true;
+        offset_ = 0;
+        i_ = 0;
+        j_ = 0;
+    }
+   
+    operator _bz_bool() const
+    { return good_; }
+
+    void operator++()
+    {
+        BZPRECONDITION(good_);
+        ++offset_;
+        ++i_;
+        if (i_ > j_)
+        {
+            i_ = 0;
+            ++j_;
+            if (j_ == size_)
+                good_ = false;
+        }
+    }
+
+    unsigned row() const
+    { return i_; }
+
+    unsigned col() const
+    { return j_; }
+
+    unsigned offset() const
+    { return offset_; }
+
+protected:
+    unsigned size_;
+    _bz_bool good_;
+    unsigned offset_;
+    unsigned i_, j_;
+};
+
+class UpperTriangular : public MatrixStructure {
+
+public:
+    typedef UpperTriangularIterator T_iterator;
+
+    UpperTriangular()
+        : size_(0)
+    { }
+
+    UpperTriangular(unsigned size)
+        : size_(size)
+    { }
+
+    UpperTriangular(unsigned rows, unsigned cols)
+        : size_(rows)
+    {
+        BZPRECONDITION(rows == cols);
+    }
+
+    unsigned columns() const
+    { return size_; }
+
+    unsigned coordToOffset(unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        BZPRECONDITION(j >= i);
+        return j*(j+1)/2 + i;
+    }
+
+    unsigned firstInRow(unsigned i) const
+    { return 0; }
+
+    template<class T_numtype>
+    T_numtype get(const T_numtype * _bz_restrict data,
+        unsigned i, unsigned j) const
+    {
+        BZPRECONDITION(inRange(i,j));
+        if (j >= i)
+            return data[coordToOffset(i,j)];
+        else
+            return ZeroElement<T_numtype>::zero();
+    }
+
+    template<class T_numtype>
+    T_numtype& get(T_numtype * _bz_restrict data, unsigned i, unsigned j)
+    {
+        BZPRECONDITION(inRange(i,j));
+        if (j >= i)
+            return data[coordToOffset(i,j)];
+        else
+            return ZeroElement<T_numtype>::zero();
+    }
+
+    unsigned lastInRow(unsigned i) const
+    { return size_ - 1; }
+
+    unsigned firstInCol(unsigned j) const
+    { return 0; }
+
+    unsigned lastInCol(unsigned j) const
+    { return j; }
+
+    _bz_bool inRange(unsigned i, unsigned j) const
+    {
+        return (i < size_) && (j < size_);
+    }
+
+    unsigned numElements() const
+    { return size_ * (size_ + 1) / 2; }
+
+    unsigned rows() const
+    { return size_; }
+
+    void resize(unsigned size)
+    {
+        size_ = size;
+    }
+
+    void resize(unsigned rows, unsigned cols)
+    {
+        BZPRECONDITION(rows == cols);
+        size_  = rows;
+    }
+
+private:
+    unsigned size_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MATUTRI_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/memblock.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/memblock.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/memblock.cc	(revision 1307)
@@ -0,0 +1,77 @@
+/*
+ * $Id: memblock.cc,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_MEMBLOCK_CC
+#define BZ_MEMBLOCK_CC
+
+#ifndef BZ_MEMBLOCK_H
+ #include <blitz/memblock.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Null memory block for each (template) instantiation of MemoryBlockReference
+template<class P_type> 
+NullMemoryBlock<P_type> MemoryBlockReference<P_type>::nullBlock_;
+
+template<class P_type>
+inline void MemoryBlock<P_type>::allocate(int length)
+{
+    TAU_TYPE_STRING(p1, "MemoryBlock<T>::allocate() [T="
+        + CT(P_type) + "]");
+    TAU_PROFILE(p1, "void ()", TAU_BLITZ);
+
+#ifndef BZ_ALIGN_BLOCKS_ON_CACHELINE_BOUNDARY
+    data_ =  new T_type[length];
+    dataBlockAddress_ = data_;
+#else
+    int numBytes = length * sizeof(T_type);
+
+    if (numBytes < 1024)
+    {
+        data_ =  new T_type[length];
+        dataBlockAddress_ = data_;
+    }
+    else
+    {
+        // We're allocating a large array.  For performance reasons,
+        // it's advantageous to force the array to start on a
+        // cache line boundary.  We do this by allocating a little
+        // more memory than necessary, then shifting the pointer
+        // to the next cache line boundary.
+        // NB: This code assumes that T_type has a trivial
+        // constructor.
+        const int cacheBlockSize = 128;    // Will work for 32, 16 also
+
+        dataBlockAddress_ = new T_type[length
+            + (cacheBlockSize + sizeof(T_type) - 1) / sizeof(T_type)];
+
+        // Shift to the next cache line boundary
+
+        ptrdiff_t offset = ptrdiff_t(dataBlockAddress_) % cacheBlockSize;
+        int shift = (offset == 0) ? 0 : (cacheBlockSize - offset);
+        data_ = (T_type*)(((char *)dataBlockAddress_) + shift);
+    }
+#endif
+}
+
+
+BZ_NAMESPACE_END
+
+#endif // BZ_MEMBLOCK_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/memblock.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/memblock.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/memblock.h	(revision 1307)
@@ -0,0 +1,318 @@
+/***************************************************************************
+ * blitz/memblock.h      MemoryBlock<T> and MemoryBlockReference<T>
+ *
+ * $Id: memblock.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.7  1998/06/15 16:07:01  tveldhui
+ * When a memory block is created from an existing block of data,
+ * add an additional reference count so that makeUnique() will
+ * create a copy of the data.
+ *
+ * Revision 1.6  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.5  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.4  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1996/11/11 17:29:13  tveldhui
+ * Initial revision
+ *
+ *
+ ***************************************************************************
+ *
+ */
+
+#ifndef __BZ_MEMBLOCK_H__
+#define __BZ_MEMBLOCK_H__
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#include <stddef.h>     // ptrdiff_t
+
+BZ_NAMESPACE(blitz)
+
+// Forward declaration of MemoryBlockReference
+template<class T_type> class MemoryBlockReference;
+
+// Class MemoryBlock provides a reference-counted block of memory.  This block
+// may be referred to by multiple vector, matrix and array objects.  The memory
+// is automatically deallocated when the last referring object is destructed.
+// MemoryBlock may be subclassed to provide special allocators.
+template<class P_type>
+class MemoryBlock {
+
+    friend class MemoryBlockReference<P_type>;
+
+public:
+    typedef P_type T_type;
+
+protected:
+    MemoryBlock()
+    {
+        length_ = 0;
+        data_ = 0;
+        dataBlockAddress_ = 0;
+        references_ = 0;
+        ownData_ = 0;
+    }
+
+    _bz_explicit MemoryBlock(size_t items)
+    {
+        length_ = items;
+        allocate(length_);
+
+#ifdef BZ_DEBUG_LOG_ALLOCATIONS
+    cout << "MemoryBlock: allocated " << setw(8) << length_ 
+         << " at " << ((void *)dataBlockAddress_) << endl;
+#endif
+
+        BZASSERT(dataBlockAddress_ != 0);
+
+        references_ = 0;
+        ownData_ = 1;
+    }
+
+    MemoryBlock(size_t length, T_type* _bz_restrict data)
+    {
+        length_ = length;
+        data_ = data;
+        dataBlockAddress_ = 0;
+        references_ = 0;
+        ownData_ = 0;
+    }
+
+    virtual ~MemoryBlock()
+    {
+        if ((dataBlockAddress_) && (ownData_))
+        {
+
+#ifdef BZ_DEBUG_LOG_ALLOCATIONS
+    cout << "MemoryBlock:     freed " << setw(8) << length_
+         << " at " << ((void *)dataBlockAddress_) << endl;
+#endif
+
+            delete [] dataBlockAddress_;
+        }
+    }
+
+    void          addReference()
+    { 
+        ++references_; 
+
+#ifdef BZ_DEBUG_LOG_REFERENCES
+    cout << "MemoryBlock:    reffed " << setw(8) << length_ 
+         << " at " << ((void *)dataBlockAddress_) << " (r=" 
+         << references_ << ")" << endl;
+#endif
+
+    }
+
+    T_type* _bz_restrict      data() 
+    { 
+        return data_; 
+    }
+
+    const T_type* _bz_restrict data()      const
+    { 
+        return data_; 
+    }
+
+    size_t        length()    const
+    { 
+        return length_; 
+    }
+
+    void          removeReference()
+    {
+        --references_;
+
+#ifdef BZ_DEBUG_LOG_REFERENCES
+    cout << "MemoryBlock: dereffed  " << setw(8) << length_
+         << " at " << ((void *)dataBlockAddress_) << " (r=" << references_ 
+         << ")" << endl;
+#endif
+
+        if (!references_)
+            delete this;
+    }
+
+    int references() const
+    {
+        return references_;
+    }
+
+protected:
+    inline void allocate(int length);
+
+private:   // Disabled member functions
+    MemoryBlock(const MemoryBlock<T_type>&)
+    { }
+
+    void operator=(const MemoryBlock<T_type>&)
+    { }
+
+private:   // Data members
+    T_type * _bz_restrict data_;
+    T_type * _bz_restrict dataBlockAddress_;
+    int     references_;
+    size_t  length_;
+    int     ownData_;
+};
+
+template<class P_type>
+class NullMemoryBlock : public MemoryBlock<P_type> {
+public:
+    NullMemoryBlock()
+    { 
+        // This ensures that the delete operator will not be invoked
+        // on an instance of NullMemoryBlock in removeReference().
+        this->addReference();        
+    }
+
+    virtual ~NullMemoryBlock()  
+    { }
+};
+
+template<class P_type>
+class MemoryBlockReference {
+
+public:
+    typedef P_type T_type;
+
+    MemoryBlockReference()
+    {
+        block_ = &nullBlock_;
+        block_->addReference();
+
+#ifndef BZ_TEMPLATE_STATIC_INIT
+        // This compiler doesn't handle static initialization
+        // and templates properly.  Give the NullMemoryBlock
+        // another reference to make sure it doesn't delete
+        // itself and cause a seg fault when we dereference it.
+        block_->addReference();
+#endif
+
+        data_ = 0;
+    }
+
+    MemoryBlockReference(MemoryBlockReference<T_type>& ref)
+    {
+        block_ = ref.block_;
+        block_->addReference();
+        data_ = block_->data();
+    }
+
+    MemoryBlockReference(MemoryBlockReference<T_type>& ref, size_t offset)
+    {
+        block_ = ref.block_;
+        block_->addReference();
+        data_ = block_->data() + offset;
+    }
+
+    MemoryBlockReference(size_t length, T_type* data)
+    {
+        // Create a memory block using already allocated memory.  Note
+        // that the memory will not be freed when no longer being
+        // referenced.
+        block_ = new MemoryBlock<T_type>(length, data);
+        block_->addReference();
+
+        // This extra reference indicates that another object somewhere
+        // has a pointer to the data.  This is necessary so that makeUnique()
+        // will create a copy of the data.   -- TV 19980615
+        block_->addReference();
+        data_ = data;
+    }
+
+    _bz_explicit MemoryBlockReference(size_t items)
+    {
+        block_ = new MemoryBlock<T_type>(items);
+        block_->addReference();
+        data_ = block_->data();
+    }
+
+   ~MemoryBlockReference()
+    {
+        block_->removeReference();
+    }
+
+    int numReferences() const
+    {
+        return block_->references();
+    }
+
+protected:
+
+    void changeToNullBlock()
+    {
+        block_->removeReference();
+        block_ = &nullBlock_;
+        block_->addReference();
+        data_ = 0;
+    }
+
+    void changeBlock(MemoryBlockReference<T_type>& ref, size_t offset)
+    {
+        block_->removeReference();
+        block_ = ref.block_;
+        block_->addReference();
+        data_ = block_->data() + offset;
+    }
+
+    void newBlock(size_t items)
+    {
+        block_->removeReference();
+        block_ = new MemoryBlock<T_type>(items);
+        block_->addReference();
+        data_ = block_->data();
+    }
+
+private:
+    void operator=(const MemoryBlockReference<T_type>&)
+    { }
+
+private:
+    MemoryBlock<T_type>* block_;
+    static NullMemoryBlock<T_type> nullBlock_;
+    
+protected:
+    T_type * _bz_restrict data_;
+};
+
+
+BZ_NAMESPACE_END
+
+#include <blitz/memblock.cc>
+
+#endif // __BZ_MEMBLOCK_H__
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/dot.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/dot.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/dot.h	(revision 1307)
@@ -0,0 +1,112 @@
+/***************************************************************************
+ * blitz/meta/dot.h      Tiny vector dot product metaprogram
+ *
+ * $Id: dot.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:08:44  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_META_DOT_H
+#define BZ_META_DOT_H
+
+#ifndef BZ_PROMOTE_H
+ #include <blitz/promote.h>
+#endif
+
+#ifndef BZ_METAPROG_H
+ #include <blitz/meta/metaprog.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<int N, int I>
+class _bz_meta_vectorDot {
+public:
+    enum { loopFlag = (I < N-1) ? 1 : 0 };
+
+    template<class T_expr1, class T_expr2>
+    static inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype,
+        _bz_typename T_expr2::T_numtype)
+    f(const T_expr1& a, const T_expr2& b)
+    {
+        return a[I] * b[I]
+            + _bz_meta_vectorDot<loopFlag * N, loopFlag * (I+1)>::f(a,b);
+    }
+
+    template<class T_expr1, class T_expr2>
+    static inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype,
+        _bz_typename T_expr2::T_numtype)
+    f_value_ref(T_expr1 a, const T_expr2& b)
+    {
+        return a[I] * b[I]
+            + _bz_meta_vectorDot<loopFlag * N, loopFlag * (I+1)>::f(a,b);
+    }
+
+    template<class T_expr1, class T_expr2>
+    static inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype,
+        _bz_typename T_expr2::T_numtype)
+    f_ref_value(const T_expr1& a, T_expr2 b)
+    {
+        return a[I] * b[I]
+            + _bz_meta_vectorDot<loopFlag * N, loopFlag * (I+1)>::f(a,b);
+    }
+
+    template<class T_expr1, class P_numtype2>
+    static inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype,
+        P_numtype2)
+    dotWithArgs(const T_expr1& a, P_numtype2 i1, P_numtype2 i2=0,
+        P_numtype2 i3=0, P_numtype2 i4=0, P_numtype2 i5=0, P_numtype2 i6=0,
+        P_numtype2 i7=0, P_numtype2 i8=0, P_numtype2 i9=0, P_numtype2 i10=0)
+    {
+        return a[I] * i1  
+            + _bz_meta_vectorDot<loopFlag * N, loopFlag * (I+1)>::dotWithArgs
+                 (a, i2, i3, i4, i5, i6, i7, i8, i9);
+    }
+};
+
+template<>
+class _bz_meta_vectorDot<0,0> {
+public:
+    template<class T_expr1, class T_expr2>
+    static inline _bz_meta_nullOperand f(const T_expr1&, const T_expr2&)
+    { return _bz_meta_nullOperand(); }
+
+    template<class T_expr1, class P_numtype2>
+    static inline _bz_meta_nullOperand 
+    dotWithArgs(const T_expr1& a, P_numtype2 i1, P_numtype2 i2=0,
+        P_numtype2 i3=0, P_numtype2 i4=0, P_numtype2 i5=0, P_numtype2 i6=0,
+        P_numtype2 i7=0, P_numtype2 i8=0, P_numtype2 i9=0, P_numtype2 i10=0)
+    {
+        return _bz_meta_nullOperand(); 
+    }
+
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_META_DOT_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/matassign.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/matassign.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/matassign.h	(revision 1307)
@@ -0,0 +1,87 @@
+/***************************************************************************
+ * blitz/meta/matassign.h   TinyMatrix assignment metaprogram
+ *
+ * $Id: matassign.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:08:44  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+
+#ifndef BZ_META_MATASSIGN_H
+#define BZ_META_MATASSIGN_H
+
+BZ_NAMESPACE(blitz)
+
+template<int N_rows, int N_columns, int I, int J>
+class _bz_meta_matAssign2 {
+public:
+    enum { go = (J < N_columns - 1) ? 1 : 0 };
+
+    template<class T_matrix, class T_expr, class T_updater>
+    static inline void f(T_matrix& mat, T_expr expr, T_updater u)
+    {
+        u.update(mat(I,J), expr(I,J));
+        _bz_meta_matAssign2<N_rows * go, N_columns * go, I * go, (J+1) * go>
+            ::f(mat, expr, u);
+    }
+};
+
+template<>
+class _bz_meta_matAssign2<0,0,0,0> {
+public:
+    template<class T_matrix, class T_expr, class T_updater>
+    static inline void f(T_matrix& mat, T_expr expr, T_updater u)
+    { }
+};
+
+template<int N_rows, int N_columns, int I> 
+class _bz_meta_matAssign {
+public:
+    enum { go = (I < N_rows-1) ? 1 : 0 };
+
+    template<class T_matrix, class T_expr, class T_updater>
+    static inline void f(T_matrix& mat, T_expr expr, T_updater u)
+    {
+        _bz_meta_matAssign2<N_rows, N_columns, I, 0>::f(mat, expr, u);
+        _bz_meta_matAssign<N_rows * go, N_columns * go, (I+1) * go>
+            ::f(mat, expr, u);
+    }
+};
+
+template<>
+class _bz_meta_matAssign<0,0,0> {
+public:
+    template<class T_matrix, class T_expr, class T_updater>
+    static inline void f(T_matrix& mat, T_expr expr, T_updater u)
+    { }
+};
+
+
+BZ_NAMESPACE_END
+
+#endif // BZ_META_ASSIGN_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/matmat.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/matmat.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/matmat.h	(revision 1307)
@@ -0,0 +1,133 @@
+/***************************************************************************
+ * blitz/meta/matmat.h   TinyMatrix matrix-matrix product metaprogram
+ *
+ * $Id: matmat.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:08:44  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_META_MATMAT_H
+#define BZ_META_MATMAT_H
+
+#ifndef BZ_TINYMAT_H
+ #error <blitz/meta/matmat.h> must be included via <blitz/tinymat.h>
+#endif
+
+#include <blitz/meta/metaprog.h>
+#include <blitz/tinymatexpr.h>
+
+BZ_NAMESPACE(blitz)
+
+// Template metaprogram for matrix-matrix multiplication
+template<int N_rows1, int N_columns, int N_columns2, int N_rowStride1,
+    int N_colStride1, int N_rowStride2, int N_colStride2, int K>
+class _bz_meta_matrixMatrixProduct {
+public:
+    enum { go = (K != N_columns - 1) };
+
+    template<class T_numtype1, class T_numtype2>
+    static inline BZ_PROMOTE(T_numtype1, T_numtype2)
+    f(const T_numtype1* matrix1, const T_numtype2* matrix2, int i, int j)
+    {
+        return matrix1[i * N_rowStride1 + K * N_colStride1]
+            * matrix2[K * N_rowStride2 + j * N_colStride2]
+            + _bz_meta_matrixMatrixProduct<N_rows1 * go, N_columns * go,
+                N_columns2 * go, N_rowStride1 * go, N_colStride1 * go,
+                N_rowStride2 * go, N_colStride2 * go, (K+1) * go>
+              ::f(matrix1, matrix2, i, j);
+    }
+};
+
+template<>
+class _bz_meta_matrixMatrixProduct<0,0,0,0,0,0,0,0> {
+public:
+    static inline _bz_meta_nullOperand f(const void*, const void*, int, int)
+    { return _bz_meta_nullOperand(); }
+};
+
+
+
+
+template<class T_numtype1, class T_numtype2, int N_rows1, int N_columns,
+    int N_columns2, int N_rowStride1, int N_colStride1,
+    int N_rowStride2, int N_colStride2>
+class _bz_tinyMatrixMatrixProduct {
+public:
+    typedef BZ_PROMOTE(T_numtype1, T_numtype2) T_numtype;
+
+    enum { rows = N_rows1, columns = N_columns2 };
+
+    _bz_tinyMatrixMatrixProduct(const T_numtype1* matrix1,
+        const T_numtype2* matrix2)
+        : matrix1_(matrix1), matrix2_(matrix2)
+    { }
+
+    _bz_tinyMatrixMatrixProduct(const _bz_tinyMatrixMatrixProduct<T_numtype1,
+        T_numtype2, N_rows1, N_columns, N_columns2, N_rowStride1, N_colStride1,
+        N_rowStride2, N_colStride2>& x)
+        : matrix1_(x.matrix1_), matrix2_(x.matrix2_)
+    { }
+
+    const T_numtype1* matrix1() const
+    { return matrix1_; }
+
+    const T_numtype2* matrix2() const
+    { return matrix2_; }
+
+    T_numtype operator()(int i, int j) const
+    {
+        return _bz_meta_matrixMatrixProduct<N_rows1, N_columns,
+            N_columns2, N_rowStride1, N_colStride1, N_rowStride2,
+            N_colStride2, 0>::f(matrix1_, matrix2_, i, j);
+    }
+
+protected:
+    const T_numtype1* matrix1_;
+    const T_numtype2* matrix2_;    
+};
+
+template<class T_numtype1, class T_numtype2, int N_rows1, int N_columns1,
+    int N_columns2>
+inline
+_bz_tinyMatExpr<_bz_tinyMatrixMatrixProduct<T_numtype1, T_numtype2, N_rows1, 
+    N_columns1, N_columns2, N_columns1, 1, N_columns2, 1> >
+product(const TinyMatrix<T_numtype1, N_rows1, N_columns1>& a,
+    const TinyMatrix<T_numtype2, N_columns1, N_columns2>& b)
+{
+    typedef _bz_tinyMatrixMatrixProduct<T_numtype1, T_numtype2,
+        N_rows1, N_columns1, N_columns2, N_columns1, 1, N_columns2, 1> T_expr;
+    return _bz_tinyMatExpr<T_expr>(T_expr(a.data(), b.data()));
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_META_MATMAT_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/matvec.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/matvec.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/matvec.h	(revision 1307)
@@ -0,0 +1,200 @@
+/***************************************************************************
+ * blitz/tiny/matvec.h   TinyMatrix/TinyVector product metaprogram
+ *
+ * $Id: matvec.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:08:44  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_META_MATVEC_H
+#define BZ_META_MATVEC_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_VECEXPRWRAP_H
+ #include <blitz/vecexprwrap.h>
+#endif
+
+#ifndef BZ_METAPROG_H
+ #include <blitz/meta/metaprog.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Forward declarations
+template<int N_rows, int N_columns, int N_rowStride, int N_colStride,
+    int N_vecStride, int J>
+class _bz_meta_matrixVectorProduct2;
+
+
+template<class T_numtype1, class T_numtype2, int N_rows, int N_columns, 
+    int N_rowStride, int N_colStride, int N_vecStride>
+class _bz_tinyMatrixVectorProduct {
+public:
+    typedef BZ_PROMOTE(T_numtype1, T_numtype2) T_numtype;
+    
+    _bz_tinyMatrixVectorProduct(const _bz_tinyMatrixVectorProduct<T_numtype1,
+        T_numtype2, N_rows, N_columns, N_rowStride, N_colStride, 
+        N_vecStride>& z)
+            : matrix_(z.matrix_), vector_(z.vector_)
+    { }
+
+    _bz_tinyMatrixVectorProduct(const T_numtype1* matrix, 
+        const T_numtype2* vector)
+        : matrix_(matrix), vector_(vector)
+    { }
+
+    T_numtype operator[](unsigned i) const
+    {
+        return _bz_meta_matrixVectorProduct2<N_rows, N_columns, N_rowStride,
+            N_colStride, N_vecStride, 0>::f(matrix_, vector_, i);
+    }
+
+    T_numtype operator()(unsigned i) const
+    {
+        return _bz_meta_matrixVectorProduct2<N_rows, N_columns, N_rowStride,
+            N_colStride, N_vecStride, 0>::f(matrix_, vector_, i);
+    }
+
+    enum {
+        _bz_staticLengthCount = 1,
+        _bz_dynamicLengthCount = 0,
+        _bz_staticLength = N_rows
+
+#ifdef BZ_HAVE_COSTS
+     ,
+        _bz_costPerEval = 2 * N_columns * costs::memoryAccess
+            + (N_columns-1) * costs::add
+#endif
+
+    };
+
+    unsigned _bz_suggestLength() const
+    {
+        return N_rows;
+    }
+
+    _bz_bool _bz_hasFastAccess() const
+    { return _bz_true; }
+
+    T_numtype _bz_fastAccess(unsigned i) const
+    {
+        return _bz_meta_matrixVectorProduct2<N_rows, N_columns, N_rowStride,
+            N_colStride, N_vecStride, 0>::f(matrix_, vector_, i);
+    }
+
+    unsigned length(unsigned recommendedLength) const
+    { return N_rows; }
+
+    const T_numtype1* matrix() const
+    { return matrix_; }
+
+    const T_numtype2* vector() const
+    { return vector_; }
+
+protected:
+    const T_numtype1* matrix_;
+    const T_numtype2* vector_;
+};
+
+template<class T_numtype1, class T_numtype2, int N_rows, int N_columns>
+inline _bz_VecExpr<_bz_tinyMatrixVectorProduct<T_numtype1, T_numtype2, 
+    N_rows, N_columns, N_columns, 1, 1> >
+product(const TinyMatrix<T_numtype1, N_rows, N_columns>& matrix,
+    const TinyVector<T_numtype2, N_columns>& vector)
+{
+    typedef _bz_tinyMatrixVectorProduct<T_numtype1, T_numtype2, N_rows, 
+        N_columns, N_columns, 1, 1> T_expr;
+    return _bz_VecExpr<T_expr>(T_expr(matrix.data(), vector.data()));
+}
+
+// Template metaprogram for matrix-vector multiplication
+
+template<int N_rows, int N_columns, int N_rowStride, int N_colStride,
+    int N_vecStride, int J>
+class _bz_meta_matrixVectorProduct2 {
+
+public:
+    enum { go = J < (N_columns-1) };
+   
+    template<class T_numtype1, class T_numtype2> 
+    static inline BZ_PROMOTE(T_numtype1, T_numtype2)
+    f(const T_numtype1* matrix, const T_numtype2* vector, int i)
+    {
+        return matrix[i * N_rowStride + J * N_colStride]
+            * vector[J * N_vecStride]
+
+            + _bz_meta_matrixVectorProduct2<N_rows * go, N_columns * go,
+                N_rowStride * go, N_colStride * go, N_vecStride * go, (J+1)*go>
+                ::f(matrix, vector, i);
+    }
+    
+};
+
+template<>
+class _bz_meta_matrixVectorProduct2<0,0,0,0,0,0> {
+public:
+    static inline _bz_meta_nullOperand f(const void*, const void*, int)
+    { return _bz_meta_nullOperand(); }
+};
+
+template<int N_rows, int N_columns, int N_rowStride, int N_colStride,
+    int N_vecStride, int I>
+class _bz_meta_matrixVectorProduct {
+public:
+    enum { go = I < (N_rows - 1) };
+
+    template<class T_numtype1, class T_numtype2, class T_numtype3>
+    static inline void f(TinyVector<T_numtype3, N_rows>& result,
+        const T_numtype1* matrix, const T_numtype2* vector)
+    {
+        result[I] = _bz_meta_matrixVectorProduct2<N_rows, N_columns,
+            N_rowStride, N_colStride, N_vecStride, 0>::f(matrix,vector, I);
+
+        _bz_meta_matrixVectorProduct<N_rows * go, N_columns * go,
+            N_rowStride * go, N_colStride * go, N_vecStride * go, (I+1)*go>
+              ::f(result, matrix, vector);
+    }
+};
+
+template<>
+class _bz_meta_matrixVectorProduct<0,0,0,0,0,0> {
+public:
+    static inline void f(const _bz_tinyBase&, const void*, const void*)
+    { }
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_META_MATVEC_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/metaprog.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/metaprog.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/metaprog.h	(revision 1307)
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * blitz/meta/metaprog.h   Useful metaprogram declarations
+ *
+ * $Id: metaprog.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:08:44  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_META_METAPROG_H
+#define BZ_META_METAPROG_H
+
+BZ_NAMESPACE(blitz)
+
+// Null Operand
+
+class _bz_meta_nullOperand {
+public:
+    _bz_meta_nullOperand() { }
+};
+
+template<class T> inline T operator+(const T& a, _bz_meta_nullOperand)
+{ return a; }
+template<class T> inline T operator*(const T& a, _bz_meta_nullOperand)
+{ return a; }
+
+
+// MetaMax
+
+template<int N1, int N2>
+class _bz_meta_max {
+public:
+    enum { max = (N1 > N2) ? N1 : N2 };
+};
+
+// MetaMin
+
+template<int N1, int N2>
+class _bz_meta_min {
+public:
+    enum { min = (N1 < N2) ? N1 : N2 };
+};
+
+BZ_NAMESPACE_END 
+
+#endif // BZ_META_METAPROG_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/product.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/product.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/product.h	(revision 1307)
@@ -0,0 +1,71 @@
+/***************************************************************************
+ * blitz/meta/product.h  TinyVector product metaprogram
+ *
+ * $Id: product.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:08:44  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_META_PRODUCT_H
+#define BZ_META_PRODUCT_H
+
+#ifndef BZ_PROMOTE_H
+ #include <blitz/promote.h>
+#endif
+
+#ifndef BZ_METAPROG_H
+ #include <blitz/meta/metaprog.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<int N, int I>
+class _bz_meta_vectorProduct {
+public:
+    enum { loopFlag = (I < N-1) ? 1 : 0 };
+
+    template<class T_expr1>
+    static inline BZ_SUMTYPE(_bz_typename T_expr1::T_numtype)
+    f(const T_expr1& a)
+    {
+        return a[I] * _bz_meta_vectorProduct<loopFlag * N, 
+            loopFlag * (I+1)>::f(a);
+    }
+};
+
+template<>
+class _bz_meta_vectorProduct<0,0> {
+public:
+    template<class T_expr1>
+    static inline _bz_meta_nullOperand f(const T_expr1&)
+    { return _bz_meta_nullOperand(); }
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_META_PRODUCT_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/sum.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/sum.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/sum.h	(revision 1307)
@@ -0,0 +1,68 @@
+/***************************************************************************
+ * blitz/meta/sum.h      TinyVector sum metaprogram
+ *
+ * $Id: sum.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:08:44  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_META_SUM_H
+#define BZ_META_SUM_H
+
+#ifndef BZ_METAPROG_H
+ #include <blitz/meta/metaprog.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<int N, int I>
+class _bz_meta_vectorSum {
+public:
+    enum { loopFlag = (I < N-1) ? 1 : 0 };
+
+    template<class T_expr1>
+    static inline _bz_typename T_expr1::T_numtype
+    f(const T_expr1& a)
+    {
+        return a[I] +
+            + _bz_meta_vectorSum<loopFlag * N, loopFlag * (I+1)>::f(a);
+    }
+};
+
+template<>
+class _bz_meta_vectorSum<0,0> {
+public:
+    template<class T_expr1>
+    static inline _bz_meta_nullOperand f(const T_expr1&)
+    { return _bz_meta_nullOperand(); }
+
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_META_SUM_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/vecassign.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/vecassign.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/meta/vecassign.h	(revision 1307)
@@ -0,0 +1,95 @@
+/***************************************************************************
+ * blitz/meta/vecassign.h   TinyVector assignment metaprogram
+ *
+ * $Id: vecassign.h,v 1.1.1.1 1999-04-09 17:59:03 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:08:44  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_META_VECASSIGN_H
+#define BZ_META_VECASSIGN_H
+
+BZ_NAMESPACE(blitz)
+
+template<int N, int I> 
+class _bz_meta_vecAssign {
+public:
+    enum { loopFlag = (I < N-1) ? 1 : 0 };
+
+    template<class T_vector, class T_expr, class T_updater>
+    static inline void fastAssign(T_vector& vec, T_expr expr, T_updater u)
+    {
+        u.update(vec[I], expr._bz_fastAccess(I));
+        _bz_meta_vecAssign<N * loopFlag, (I+1) * loopFlag>
+           ::fastAssign(vec,expr,u);
+    }
+
+    template<class T_vector, class T_expr, class T_updater>
+    static inline void assign(T_vector& vec, T_expr expr, T_updater u)
+    {
+        u.update(vec[I], expr[I]);
+        _bz_meta_vecAssign<N * loopFlag, (I+1) * loopFlag>
+           ::assign(vec,expr,u);
+    }
+
+    template<class T_vector, class T_numtype, class T_updater>
+    static inline void assignWithArgs(T_vector& vec, T_updater u,
+        T_numtype x0, T_numtype x1=0, T_numtype x2=0, T_numtype x3=0,
+        T_numtype x4=0, T_numtype x5=0, T_numtype x6=0, T_numtype x7=0,
+        T_numtype x8=0, T_numtype x9=0)
+    {
+        u.update(vec[I], x0);
+        _bz_meta_vecAssign<N * loopFlag, (I+1) * loopFlag>
+            ::assignWithArgs(vec, u, x1, x2, x3, x4, x5, x6, x7, x8, x9);
+    }
+        
+};
+
+template<>
+class _bz_meta_vecAssign<0,0> {
+public:
+    template<class T_vector, class T_expr, class T_updater>
+    static inline void fastAssign(T_vector& vec, T_expr expr, T_updater u)
+    { }
+
+    template<class T_vector, class T_expr, class T_updater>
+    static inline void assign(T_vector& vec, T_expr expr, T_updater u)
+    { }
+
+    template<class T_vector, class T_numtype, class T_updater>
+    static inline void assignWithArgs(T_vector& vec, T_updater u,
+        T_numtype x0, T_numtype x1=0, T_numtype x2=0, T_numtype x3=0,
+        T_numtype x4=0, T_numtype x5=0, T_numtype x6=0, T_numtype x7=0,
+        T_numtype x8=0, T_numtype x9=0)
+    {
+    }
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_META_ASSIGN_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/minmax.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/minmax.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/minmax.h	(revision 1307)
@@ -0,0 +1,32 @@
+#ifndef BZ_MINMAX_H
+#define BZ_MINMAX_H
+
+#include <blitz/promote.h>
+
+BZ_NAMESPACE(blitz)
+
+template<class T1, class T2>
+BZ_PROMOTE(T1,T2) min(const T1& a, const T2& b)
+{
+    typedef BZ_PROMOTE(T1,T2) T_promote;
+
+    if (a <= b)
+        return T_promote(a);
+    else
+        return T_promote(b);
+}
+
+template<class T1, class T2>
+BZ_PROMOTE(T1,T2) max(const T1& a, const T2& b)
+{
+    typedef BZ_PROMOTE(T1,T2) T_promote;
+
+    if (a >= b)
+        return T_promote(a);
+    else
+        return T_promote(b);
+}
+
+BZ_NAMESPACE_END
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/mstruct.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/mstruct.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/mstruct.h	(revision 1307)
@@ -0,0 +1,149 @@
+/***************************************************************************
+ * blitz/mstruct.h      Matrix structure classes
+ *
+ * $Id: mstruct.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_MSTRUCT_H
+#define BZ_MSTRUCT_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_ZERO_H
+ #include <blitz/zero.h>
+#endif
+
+/*
+ * Each matrix structure class encapsulates a storage format for matrix
+ * data.  It is responsible for:
+ * - Storing the size of the matrix
+ * - Calculating how many unique elements the matrix will have
+ * - Mapping indices (i,j) onto memory locations
+ * - Performing any sign reversals or conjugations when matrix
+ *   elements are retrieved (e.g. in a Hermitian or Skew symmetric
+ *   matrix)
+ *
+ * Every matrix structure class must provide these methods:
+ *
+ * ctor()
+ * ctor(unsigned rows, unsigned cols)
+ * unsigned columns() const;
+ * unsigned cols()    const;
+ * unsigned firstInRow() const;
+ * unsigned firstInCol() const;
+ * template<class T> T& get(T* data, unsigned i, unsigned j);
+ * template<class T> T  get(const T* data, unsigned i, unsigned j) const;
+ * bool inRange(unsigned i, unsigned j) const
+ * unsigned lastInRow() const;
+ * unsigned lastInCol() const;
+ * unsigned numElements() const;
+ * void resize(unsigned rows, unsigned cols);
+ * unsigned rows()    const;
+ *
+ * Each matrix structure class must declare a public type
+ * T_iterator which is an iterator to scan through the unique
+ * entries of the matrix.  The iterator class must provide
+ * these methods:
+ *
+ * ctor(unsigned rows, unsigned cols)
+ * unsigned offset() const
+ * operator bool() const
+ * unsigned row() const
+ * unsigned col() const
+ */
+
+BZ_NAMESPACE(blitz)
+
+class MatrixStructure { };
+
+class AsymmetricMatrix : public MatrixStructure {
+public:
+    AsymmetricMatrix()
+        : rows_(0), cols_(0)
+    { }
+
+    AsymmetricMatrix(unsigned rows, unsigned cols)
+        : rows_(rows), cols_(cols)
+    { }
+
+    unsigned columns() const
+    { return cols_; }
+
+    unsigned cols() const
+    { return cols_; }
+
+    _bz_bool inRange(unsigned i, unsigned j) const
+    {
+        return (i < rows_) && (j < cols_);
+    }
+
+    void resize(unsigned rows, unsigned cols)
+    {
+        rows_ = rows;
+        cols_ = cols;
+    }
+
+    unsigned rows() const
+    { return rows_; }
+
+protected:
+    unsigned rows_, cols_;
+};
+
+// Still to be implemented:
+// SkewSymmetric
+// Hermitian
+// Tridiagonal
+// Banded<L,H>
+// Upper bidiagonal
+// Lower bidiagonal
+// Upper Hessenberg
+// Lower Hessenberg
+
+BZ_NAMESPACE_END
+
+#include <blitz/matgen.h>         // RowMajor and ColumnMajor general matrices
+#include <blitz/matsymm.h>        // Symmetric
+#include <blitz/matdiag.h>        // Diagonal
+#include <blitz/mattoep.h>        // Toeplitz
+#include <blitz/matltri.h>        // Lower triangular
+#include <blitz/matutri.h>        // Upper triangular
+
+#endif // BZ_MSTRUCT_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/numinquire.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/numinquire.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/numinquire.h	(revision 1307)
@@ -0,0 +1,315 @@
+/***************************************************************************
+ * blitz/numinquire.h    Numeric inquiry functions
+ *
+ * $Id: numinquire.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+/*
+ * These numeric inquiry functions are provided as an alternative
+ * to the somewhat klunky numeric_limits<T>::yadda_yadda syntax.
+ * Where a similar Fortran 90 function exists, the same name has
+ * been used.
+ *
+ * The argument in all cases is a dummy of the appropriate type
+ * (double, int, etc.)
+ *
+ * These functions assume that numeric_limits<T> has been specialized
+ * for the appropriate case.  If not, the results are not useful.
+ */
+
+#ifndef BZ_NUMINQUIRE_H
+#define BZ_NUMINQUIRE_H
+
+#ifndef BZ_HAVE_NUMERIC_LIMITS
+ #error <blitz/numinquire.h> requires <limits> from the ISO/ANSI C++ standard (you may need to rerun the compiler/bzconfig script)
+#endif
+
+#include <limits>
+
+#ifndef BZ_RANGE_H
+ #include <blitz/range.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * This traits class provides zero and one values for numeric
+ * types.  This was previously a template function with specializations,
+ * but the specializations were causing multiply-defined symbols
+ * at link time.  TV 980226
+ */
+
+template<class T_numtype>
+struct _bz_OneZeroTraits {
+    static inline T_numtype zero() { return 0; }
+    static inline T_numtype one()  { return 1; }
+};
+
+#ifdef BZ_HAVE_COMPLEX
+
+template<>
+struct _bz_OneZeroTraits<complex<float> > {
+    static inline complex<float> zero() { return complex<float>(0.0f,0.0f); }
+    static inline complex<float> one()  { return complex<float>(1.0f,0.0f); }
+};
+
+template<>
+struct _bz_OneZeroTraits<complex<double> > {
+    static inline complex<double> zero() { return complex<double>(0.0,0.0); }
+    static inline complex<double> one()  { return complex<double>(1.0,0.0); }
+};
+
+template<>
+struct _bz_OneZeroTraits<complex<long double> > {
+    static inline complex<long double> zero() 
+    { return complex<long double>(0.0,0.0); }
+
+    static inline complex<long double> one()  
+    { return complex<long double>(1.0,0.0); }
+};
+
+#endif // BZ_HAVE_COMPLEX
+
+template<class T>
+inline T zero(T)
+{
+    return _bz_OneZeroTraits<T>::zero();
+}
+
+template<class T>
+inline T one(T)
+{
+    return _bz_OneZeroTraits<T>::one();
+}
+
+template<class T>
+inline int digits(T)
+{
+    return numeric_limits<T>::digits;
+}
+
+template<class T>
+inline int digits10(T)
+{
+    return numeric_limits<T>::digits10;
+}
+
+template<class T>
+inline T epsilon(T) BZ_THROW
+{
+    return numeric_limits<T>::epsilon();
+}
+
+template<class T>
+inline T huge(T) BZ_THROW
+{
+    return numeric_limits<T>::max();
+}
+
+template<class T>
+inline T tiny(T) BZ_THROW
+{
+    return numeric_limits<T>::min();
+}
+
+template<class T>
+inline int max_exponent(T)
+{
+    return numeric_limits<T>::max_exponent;
+}
+
+template<class T>
+inline int min_exponent(T)
+{
+    return numeric_limits<T>::min_exponent;
+}
+
+template<class T>
+inline int min_exponent10(T)
+{
+    return numeric_limits<T>::min_exponent10;
+}
+
+template<class T>
+inline int max_exponent10(T)
+{
+    return numeric_limits<T>::max_exponent10;
+}
+
+template<class T>
+inline int precision(T)
+{
+    return numeric_limits<T>::digits10;
+}
+
+template<class T>
+inline int radix(T)
+{
+    return numeric_limits<T>::radix;
+}
+
+template<class T>
+inline Range range(T)
+{
+    return Range(numeric_limits<T>::min_exponent10, 
+        numeric_limits<T>::max_exponent10);
+}
+
+template<class T>
+inline bool is_signed(T)
+{
+    return numeric_limits<T>::is_signed;
+}
+
+template<class T>
+inline bool is_integer(T)
+{
+    return numeric_limits<T>::is_integer;
+}
+
+template<class T>
+inline bool is_exact(T)
+{
+    return numeric_limits<T>::is_exact;
+}
+
+template<class T>
+inline T round_error(T) BZ_THROW
+{
+    return numeric_limits<T>::round_error();
+}
+
+template<class T>
+inline bool has_infinity(T) 
+{
+    return numeric_limits<T>::has_infinity;
+}
+
+template<class T>
+inline bool has_quiet_NaN(T)
+{
+    return numeric_limits<T>::has_quiet_NaN;
+}
+
+template<class T>
+inline bool has_signaling_NaN(T)
+{
+    return numeric_limits<T>::has_signaling_NaN;
+}
+
+// Provided for non-US english users
+template<class T>
+inline bool has_signalling_NaN(T)
+{
+    return numeric_limits<T>::has_signaling_NaN;
+}
+
+template<class T>
+inline bool has_denorm(T)
+{
+    return numeric_limits<T>::has_denorm;
+}
+
+template<class T>
+inline bool has_denorm_loss(T)
+{
+    return numeric_limits<T>::has_denorm_loss;
+}
+
+template<class T>
+inline T infinity(T) BZ_THROW
+{
+    return numeric_limits<T>::infinity();
+}
+
+template<class T>
+inline T quiet_NaN(T) BZ_THROW
+{
+    return numeric_limits<T>::quiet_NaN();
+}
+
+template<class T>
+inline T signaling_NaN(T) BZ_THROW
+{
+    return numeric_limits<T>::signaling_NaN();
+}
+
+template<class T>
+inline T signalling_NaN(T) BZ_THROW
+{
+    return numeric_limits<T>::signaling_NaN();
+}
+
+template<class T>
+inline T denorm_min(T) BZ_THROW
+{
+    return numeric_limits<T>::denorm_min();
+}
+
+template<class T>
+inline bool is_iec559(T)
+{
+    return numeric_limits<T>::is_iec559;
+}
+
+template<class T>
+inline bool is_bounded(T)
+{
+    return numeric_limits<T>::is_bounded;
+}
+
+template<class T>
+inline bool is_modulo(T)
+{
+    return numeric_limits<T>::is_modulo;
+}
+
+template<class T>
+inline bool traps(T)
+{
+    return numeric_limits<T>::traps;
+}
+
+template<class T>
+inline bool tinyness_before(T)
+{
+    return numeric_limits<T>::tinyness_before;
+}
+
+template<class T>
+inline std::float_round_style round_style(T)
+{
+    return numeric_limits<T>::round_style;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_NUMINQUIRE_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/numtrait.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/numtrait.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/numtrait.h	(revision 1307)
@@ -0,0 +1,109 @@
+/***************************************************************************
+ * blitz/numtrait.h      Declaration of the NumericTypeTraits class
+ *
+ * $Id: numtrait.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_NUMTRAIT_H
+#define BZ_NUMTRAIT_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+#ifndef BZ_USE_NUMTRAIT
+  #define BZ_SUMTYPE(X)    X
+  #define BZ_DIFFTYPE(X)   X
+  #define BZ_FLOATTYPE(X)  X
+  #define BZ_SIGNEDTYPE(X) X
+#else
+
+#define BZ_SUMTYPE(X)   _bz_typename NumericTypeTraits<X>::T_sumtype
+#define BZ_DIFFTYPE(X)  _bz_typename NumericTypeTraits<X>::T_difftype
+#define BZ_FLOATTYPE(X) _bz_typename NumericTypeTraits<X>::T_floattype
+#define BZ_SIGNEDTYPE(X) _bz_typename NumericTypeTraits<X>::T_signedtype
+
+template<class P_numtype>
+class NumericTypeTraits {
+public:
+    typedef P_numtype T_sumtype;    // Type to be used for summing
+    typedef P_numtype T_difftype;   // Type to be used for difference
+    typedef P_numtype T_floattype;  // Type to be used for floating-point
+                                    // calculations
+    typedef P_numtype T_signedtype; // Type to be used for signed calculations
+};
+
+#define BZDECLNUMTRAIT(X,Y,Z,W,U)                                   \
+    template<>                                                      \
+    class NumericTypeTraits<X> {                                    \
+    public:                                                         \
+        typedef Y T_sumtype;                                        \
+        typedef Z T_difftype;                                       \
+        typedef W T_floattype;                                      \
+        typedef U T_signedtype;                                     \
+    }                                                               
+
+#ifdef BZ_BOOL
+    BZDECLNUMTRAIT(bool,unsigned,int,float,int);
+#endif
+
+BZDECLNUMTRAIT(char,int,int,float,char);
+BZDECLNUMTRAIT(unsigned char, unsigned, int, float,int);
+BZDECLNUMTRAIT(short int, int, int, float, short int);
+BZDECLNUMTRAIT(short unsigned int, unsigned int, int, float, int);
+BZDECLNUMTRAIT(int, long, int, float, int);
+BZDECLNUMTRAIT(unsigned int, unsigned long, int, float, long);
+BZDECLNUMTRAIT(long, long, long, double, long);
+BZDECLNUMTRAIT(unsigned long, unsigned long, long, double, long);
+BZDECLNUMTRAIT(float, double, float, float, float);
+BZDECLNUMTRAIT(double, double, double, double, double);
+
+#ifdef BZ_HAVE_COMPLEX
+// BZDECLNUMTRAIT(complex<float>, complex<double>, complex<float>, complex<float>);
+// BZDECLNUMTRAIT(complex<double>, complex<long double>, complex<double>, complex<double>);
+#endif // BZ_HAVE_COMPLEX
+
+#endif // BZ_USE_NUMTRAIT
+
+BZ_NAMESPACE_END
+
+#endif // BZ_NUMTRAIT_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/ops.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/ops.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/ops.h	(revision 1307)
@@ -0,0 +1,211 @@
+/***************************************************************************
+ * blitz/ops.h           Function objects for operators
+ *
+ * $Id: ops.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ *************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_OPS_H
+#define BZ_OPS_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_PROMOTE_H
+ #include <blitz/promote.h>
+#endif
+
+#ifndef BZ_MATHFUNC_H
+ #include <blitz/mathfunc.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * Originally these function objects had no template arguments, e.g.
+ *
+ * struct Add {
+ *     template<class T_numtype1, class T_numtype2>
+ *     static inline BZ_PROMOTE(T_numtype1, T_numtype2)
+ *     apply(T_numtype1 a, T_numtype2 b)
+ *     { return a + b; }
+ * };
+ *
+ * This made for neater expression templates syntax.  However, there are
+ * some situations in which users may want to override type promotion
+ * for certain operations.  For example, in theoretical physics, there
+ * are U1 objects which when multiplied yield U1 objects, but when added
+ * yield a different type.  To allow for this kind of behaviour, function
+ * objects have been changed to take template parameters:
+ *
+ * template<class T_numtype1, class T_numtype2>
+ * struct Add {
+ *     typedef BZ_PROMOTE(T_numtype1, T_numtype2) T_numtype;
+ *
+ *     static inline T_numtype apply(T_numtype1 a, T_numtype2 b)
+ *     { return a + b; }
+ * };
+ *
+ * Type promotion is performed inside the function object.  The expression
+ * templates code always looks inside the function object to determine
+ * the type promotion, e.g. Add<int,float>::T_numtype
+ *
+ * Users are free to specialize these function objects for their own types.
+ */
+
+#define BZ_DEFINE_OP(name,op,symbol)                        \
+template<class T_numtype1, class T_numtype2>                \
+struct name {                                               \
+    typedef BZ_PROMOTE(T_numtype1, T_numtype2) T_numtype;   \
+                                                            \
+    static inline T_numtype                                 \
+    apply(T_numtype1 a, T_numtype2 b)                       \
+    { return a op b; }                                      \
+							    \
+    template<class T1, class T2>                            \
+    static inline void prettyPrint(string& str,             \
+        prettyPrintFormat& format, const T1& t1,            \
+        const T2& t2)                                       \
+    {                                                       \
+        str += "(";                                         \
+        t1.prettyPrint(str, format);                        \
+        str += symbol;                                      \
+        t2.prettyPrint(str, format);                        \
+        str += ")";                                         \
+    }                                                       \
+}
+
+BZ_DEFINE_OP(Add,+,"+");
+BZ_DEFINE_OP(Subtract,-,"-");
+BZ_DEFINE_OP(Multiply,*,"*");
+BZ_DEFINE_OP(Divide,/,"/");
+BZ_DEFINE_OP(Modulo,%,"%");
+BZ_DEFINE_OP(BitwiseXor,^,"^");
+BZ_DEFINE_OP(BitwiseAnd,&,"&");
+BZ_DEFINE_OP(BitwiseOr,|,"|");
+BZ_DEFINE_OP(ShiftRight,>>,">>");
+BZ_DEFINE_OP(ShiftLeft,<<,"<<");
+
+#define BZ_DEFINE_BOOL_OP(name,op,symbol)                   \
+template<class T_numtype1, class T_numtype2>                \
+struct name {                                               \
+    typedef bool T_numtype;                                 \
+    static inline bool                                      \
+    apply(T_numtype1 a, T_numtype2 b)                       \
+    { return a op b; }                                      \
+                                                            \
+    template<class T1, class T2>                            \
+    static inline void prettyPrint(string& str,             \
+        prettyPrintFormat& format, const T1& t1,            \
+        const T2& t2)                                       \
+    {                                                       \
+        str += "(";                                         \
+        t1.prettyPrint(str, format);                        \
+        str += symbol;                                      \
+        t2.prettyPrint(str, format);                        \
+        str += ")";                                         \
+    }                                                       \
+}
+
+BZ_DEFINE_BOOL_OP(Greater,>,">");
+BZ_DEFINE_BOOL_OP(Less,<,"<");
+BZ_DEFINE_BOOL_OP(GreaterOrEqual,>=,">=");
+BZ_DEFINE_BOOL_OP(LessOrEqual,<=,"<=");
+BZ_DEFINE_BOOL_OP(Equal,==,"==");
+BZ_DEFINE_BOOL_OP(NotEqual,!=,"!=");
+BZ_DEFINE_BOOL_OP(LogicalAnd,&&,"&&");
+BZ_DEFINE_BOOL_OP(LogicalOr,||,"||");
+
+template<class T_numtype1, class T_cast>
+struct Cast {
+    typedef T_cast T_numtype;
+    static inline T_cast apply(T_numtype1 a)
+    { return a; }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(T_cast);
+        str += "(";
+        a.prettyPrint(str, format);
+        str += ")";
+    }
+};
+
+template<class T_numtype1>
+struct LogicalNot {
+    typedef bool T_numtype;
+    static inline bool apply(T_numtype1 a)
+    { return !a; }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "!";
+        a.prettyPrint(str, format);
+    }
+};
+
+template<class T_numtype1>
+struct BitwiseNot {
+    typedef T_numtype1 T_numtype;
+    static inline T_numtype apply(T_numtype1 a)
+    { return ~a; }
+
+    template<class T1>
+    static void prettyPrint(string& os, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "~";
+        a.prettyPrint(os,format);
+    }
+};
+
+template<class T_numtype1>
+struct Negate {
+    typedef T_numtype1 T_numtype;
+    static inline T_numtype apply(T_numtype1 a)
+    { return -a; }
+
+    template<class T1>
+    static void prettyPrint(string& str, prettyPrintFormat& format,
+        const T1& a)
+    {
+        str += "-";
+        a.prettyPrint(str, format);
+    }
+};
+BZ_NAMESPACE_END
+
+#endif
+
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/peida_config_cxx.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/peida_config_cxx.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/peida_config_cxx.h	(revision 1307)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * config.h           Compiler language support flags
+ *
+ * This file was generated automatically by the script bzconfig.
+ * You should rerun bzconfig each time you switch compilers, install new
+ * standard libraries, or change compiler versions.
+ *
+ */
+
+ 
+#ifndef BZ_CONFIG_H
+#define BZ_CONFIG_H
+ 
+#define BZ_COMPILER_NAME   "cxx"
+#define BZ_COMPILER_OPTIONS ""
+#define BZ_OS_NAME         "OSF1 V4.0"
+#define BZ_BZCONFIG_DATE   "Wed Apr  7 13:12:07 MET DST 1999"
+#define BZ_PLATFORM        "alphaev6-dec-osf4.0e"
+ 
+#define BZ_NAMESPACES
+#define BZ_EXCEPTIONS
+#define BZ_RTTI
+#define BZ_MEMBER_CONSTANTS
+#undef  BZ_OLD_FOR_SCOPING
+#define BZ_EXPLICIT
+#define BZ_MUTABLE
+#define BZ_TYPENAME
+#undef  BZ_NCEG_RESTRICT
+#define BZ_BOOL
+#define BZ_CONST_CAST
+#define BZ_STATIC_CAST
+#define BZ_REINTERPRET_CAST
+#define BZ_DYNAMIC_CAST
+#define BZ_TEMPLATES
+#define BZ_PARTIAL_SPECIALIZATION
+#define BZ_PARTIAL_ORDERING
+#define BZ_DEFAULT_TEMPLATE_PARAMETERS
+#define BZ_MEMBER_TEMPLATES
+#define BZ_MEMBER_TEMPLATES_OUTSIDE_CLASS
+#define BZ_FULL_SPECIALIZATION_SYNTAX
+#define BZ_FUNCTION_NONTYPE_PARAMETERS
+#define BZ_TEMPLATE_QUALIFIED_BASE_CLASS
+#define BZ_TEMPLATE_QUALIFIED_RETURN_TYPE
+#undef  BZ_EXPLICIT_TEMPLATE_FUNCTION_QUALIFICATION
+#undef  BZ_TEMPLATES_AS_TEMPLATE_ARGUMENTS
+#undef  BZ_TEMPLATE_KEYWORD_QUALIFIER
+#define BZ_TEMPLATE_SCOPED_ARGUMENT_MATCHING
+#define BZ_TYPE_PROMOTION
+#define BZ_USE_NUMTRAIT
+#define BZ_ENUM_COMPUTATIONS
+#define BZ_ENUM_COMPUTATIONS_WITH_CAST
+#define BZ_TEMPLATE_STATIC_INIT
+#define BZ_HAVE_COMPLEX
+#define BZ_HAVE_NUMERIC_LIMITS
+#define BZ_HAVE_VALARRAY
+#define BZ_HAVE_COMPLEX_MATH1
+#undef  BZ_HAVE_COMPLEX_MATH2
+#undef  BZ_HAVE_IEEE_MATH
+#undef  BZ_HAVE_SYSTEM_V_MATH
+#undef  BZ_MATH_FN_IN_NAMESPACE_STD
+#define BZ_COMPLEX_MATH_IN_NAMESPACE_STD
+#undef  BZ_HAVE_STD
+#define BZ_HAVE_STL
+#define BZ_HAVE_RUSAGE
+ 
+#endif // BZ_CONFIG_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/peida_config_egcs.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/peida_config_egcs.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/peida_config_egcs.h	(revision 1307)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * config.h           Compiler language support flags
+ *
+ * This file was generated automatically by the script bzconfig.
+ * You should rerun bzconfig each time you switch compilers, install new
+ * standard libraries, or change compiler versions.
+ *
+ */
+
+ 
+#ifndef BZ_CONFIG_H
+#define BZ_CONFIG_H
+ 
+#define BZ_COMPILER_NAME   "g++"
+#define BZ_COMPILER_OPTIONS "-ftemplate-depth-30"
+#define BZ_OS_NAME         "Linux 2.2.2"
+#define BZ_BZCONFIG_DATE   "Thu Apr  8 13:48:37 CEST 1999"
+#define BZ_PLATFORM        "i686-pc-linux-gnu"
+ 
+#define BZ_NAMESPACES
+#define BZ_EXCEPTIONS
+#define BZ_RTTI
+#define BZ_MEMBER_CONSTANTS
+#define BZ_OLD_FOR_SCOPING
+#define BZ_EXPLICIT
+#define BZ_MUTABLE
+#define BZ_TYPENAME
+#undef  BZ_NCEG_RESTRICT
+#define BZ_BOOL
+#define BZ_CONST_CAST
+#define BZ_STATIC_CAST
+#define BZ_REINTERPRET_CAST
+#define BZ_DYNAMIC_CAST
+#define BZ_TEMPLATES
+#define BZ_PARTIAL_SPECIALIZATION
+#define BZ_PARTIAL_ORDERING
+#define BZ_DEFAULT_TEMPLATE_PARAMETERS
+#define BZ_MEMBER_TEMPLATES
+#define BZ_MEMBER_TEMPLATES_OUTSIDE_CLASS
+#define BZ_FULL_SPECIALIZATION_SYNTAX
+#define BZ_FUNCTION_NONTYPE_PARAMETERS
+#define BZ_TEMPLATE_QUALIFIED_BASE_CLASS
+#define BZ_TEMPLATE_QUALIFIED_RETURN_TYPE
+#define BZ_EXPLICIT_TEMPLATE_FUNCTION_QUALIFICATION
+#define BZ_TEMPLATES_AS_TEMPLATE_ARGUMENTS
+#define BZ_TEMPLATE_KEYWORD_QUALIFIER
+#define BZ_TEMPLATE_SCOPED_ARGUMENT_MATCHING
+#define BZ_TYPE_PROMOTION
+#define BZ_USE_NUMTRAIT
+#define BZ_ENUM_COMPUTATIONS
+#define BZ_ENUM_COMPUTATIONS_WITH_CAST
+#undef  BZ_TEMPLATE_STATIC_INIT
+#define BZ_HAVE_COMPLEX
+#undef  BZ_HAVE_NUMERIC_LIMITS
+#undef  BZ_HAVE_VALARRAY
+#undef  BZ_HAVE_COMPLEX_MATH1
+#undef  BZ_HAVE_COMPLEX_MATH2
+#undef  BZ_HAVE_IEEE_MATH
+#undef  BZ_HAVE_SYSTEM_V_MATH
+#define BZ_MATH_FN_IN_NAMESPACE_STD
+#define BZ_COMPLEX_MATH_IN_NAMESPACE_STD
+#define BZ_HAVE_STD
+#define BZ_HAVE_STL
+#define BZ_HAVE_RUSAGE
+ 
+#endif // BZ_CONFIG_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/prettyprint.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/prettyprint.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/prettyprint.h	(revision 1307)
@@ -0,0 +1,82 @@
+/***************************************************************************
+ * blitz/prettyprint.h      Format object for pretty-printing of
+ *                          array expressions
+ *
+ * $Id: prettyprint.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ */
+
+#ifndef BZ_PRETTYPRINT_H
+#define BZ_PRETTYPRINT_H
+
+BZ_NAMESPACE(blitz)
+
+class prettyPrintFormat {
+
+public:
+    prettyPrintFormat(_bz_bool terse = _bz_false)
+      : tersePrintingSelected_(terse)
+    {
+        arrayOperandCounter_ = 0;
+        scalarOperandCounter_ = 0;
+        dumpArrayShapes_ = _bz_false;
+    }
+
+    void setDumpArrayShapesMode()
+    {
+        dumpArrayShapes_ = _bz_true;
+    }
+
+    char nextArrayOperandSymbol()
+    {
+        return 'A' + ((arrayOperandCounter_++) % 26);
+    }
+
+    char nextScalarOperandSymbol()
+    {
+        return 's' + ((scalarOperandCounter_++) % 26);
+    }
+
+    _bz_bool tersePrintingSelected() const
+    { 
+        return tersePrintingSelected_;
+    }
+
+    _bz_bool dumpArrayShapesMode() const
+    {
+        return dumpArrayShapes_;
+    }
+
+private:
+    _bz_bool tersePrintingSelected_;
+    _bz_bool dumpArrayShapes_;
+    int arrayOperandCounter_;
+    int scalarOperandCounter_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_PRETTYPRINT_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/promote-old.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/promote-old.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/promote-old.h	(revision 1307)
@@ -0,0 +1,1360 @@
+/***********************************************************************
+ * promote.h   Arithmetic type promotion trait class
+ * Author: Todd Veldhuizen         (tveldhui@seurat.uwaterloo.ca)
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ */
+
+// Generated: genpromote.cpp Aug  7 1997 14:59:32
+
+template<class A, class B>
+class promote_trait {
+public:
+        typedef A   T_promote;
+};
+
+
+template<>
+class promote_trait<char, char> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<char, unsigned char> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<char, short int> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<char, short unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<char, int> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<char, unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<char, long> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<char, unsigned long> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<char, float> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<char, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<char, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<char, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<char, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<char, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<unsigned char, char> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, unsigned char> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, short int> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, short unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, int> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, long> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, unsigned long> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, float> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<unsigned char, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<unsigned char, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<unsigned char, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<unsigned char, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<short int, char> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<short int, unsigned char> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<short int, short int> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<short int, short unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<short int, int> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<short int, unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<short int, long> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<short int, unsigned long> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<short int, float> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<short int, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<short int, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<short int, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<short int, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<short int, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<short unsigned int, char> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, unsigned char> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, short int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, short unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, long> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, unsigned long> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, float> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<short unsigned int, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<short unsigned int, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<short unsigned int, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<short unsigned int, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<int, char> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<int, unsigned char> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<int, short int> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<int, short unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<int, int> {
+public:
+	typedef int T_promote;
+};
+
+template<>
+class promote_trait<int, unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<int, long> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<int, unsigned long> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<int, float> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<int, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<int, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<int, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<int, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<int, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<unsigned int, char> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, unsigned char> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, short int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, short unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, unsigned int> {
+public:
+	typedef unsigned int T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, long> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, unsigned long> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, float> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<unsigned int, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<unsigned int, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<unsigned int, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<unsigned int, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<long, char> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<long, unsigned char> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<long, short int> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<long, short unsigned int> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<long, int> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<long, unsigned int> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<long, long> {
+public:
+	typedef long T_promote;
+};
+
+template<>
+class promote_trait<long, unsigned long> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<long, float> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<long, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<long, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<long, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<long, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<long, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<unsigned long, char> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, unsigned char> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, short int> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, short unsigned int> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, int> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, unsigned int> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, long> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, unsigned long> {
+public:
+	typedef unsigned long T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, float> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<unsigned long, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<unsigned long, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<unsigned long, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<unsigned long, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<float, char> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<float, unsigned char> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<float, short int> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<float, short unsigned int> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<float, int> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<float, unsigned int> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<float, long> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<float, unsigned long> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<float, float> {
+public:
+	typedef float T_promote;
+};
+
+template<>
+class promote_trait<float, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<float, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<float, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<float, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<float, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<double, char> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, unsigned char> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, short int> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, short unsigned int> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, int> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, unsigned int> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, long> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, unsigned long> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, float> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, double> {
+public:
+	typedef double T_promote;
+};
+
+template<>
+class promote_trait<double, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<double, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<double, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<double, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+template<>
+class promote_trait<long double, char> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, unsigned char> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, short int> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, short unsigned int> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, int> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, unsigned int> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, long> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, unsigned long> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, float> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, double> {
+public:
+	typedef long double T_promote;
+};
+
+template<>
+class promote_trait<long double, long double> {
+public:
+	typedef long double T_promote;
+};
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<long double, complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<long double, complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<long double, complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , char> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , unsigned char> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , short int> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , short unsigned int> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , int> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , unsigned int> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , long> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , unsigned long> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , float> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , double> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , long double> {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , complex<float> > {
+public:
+	typedef complex<float>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<float> , complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , char> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , unsigned char> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , short int> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , short unsigned int> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , int> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , unsigned int> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , long> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , unsigned long> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , float> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , double> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , long double> {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , complex<float> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , complex<double> > {
+public:
+	typedef complex<double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<double> , complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , char> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , unsigned char> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , short int> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , short unsigned int> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , int> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , unsigned int> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , long> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , unsigned long> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , float> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , double> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , long double> {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , complex<float> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , complex<double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
+#ifdef BZ_HAVE_COMPLEX
+template<>
+class promote_trait<complex<long double> , complex<long double> > {
+public:
+	typedef complex<long double>  T_promote;
+};
+#endif
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/promote.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/promote.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/promote.h	(revision 1307)
@@ -0,0 +1,160 @@
+/***********************************************************************
+ * promote.h   Arithmetic type promotion trait class
+ * Author: Todd Veldhuizen         (tveldhui@seurat.uwaterloo.ca)
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ */
+
+#ifndef BZ_PROMOTE_H
+#define BZ_PROMOTE_H
+
+#include <blitz/blitz.h>
+
+BZ_NAMESPACE(blitz)
+
+#ifdef BZ_TEMPLATE_QUALIFIED_RETURN_TYPE
+    #define BZ_PROMOTE(A,B) _bz_typename promote_trait<A,B>::T_promote
+#else
+    #define BZ_PROMOTE(A,B) A
+#endif
+
+#if defined(BZ_PARTIAL_SPECIALIZATION) && !defined(BZ_DISABLE_NEW_PROMOTE)
+
+/*
+ * This compiler supports partial specialization, so type promotion
+ * can be done the elegant way.  This implementation is after ideas
+ * by Jean-Louis Leroy.
+ */
+
+template<class T>
+struct precision_trait {
+    enum { precisionRank = 0,
+           knowPrecisionRank = 0 };
+};
+
+#define BZ_DECLARE_PRECISION(T,rank)          \
+    template<>                                \
+    struct precision_trait<T> {               \
+        enum { precisionRank = rank,          \
+           knowPrecisionRank = 1 };           \
+    };
+
+BZ_DECLARE_PRECISION(int,100)
+BZ_DECLARE_PRECISION(unsigned int,200)
+BZ_DECLARE_PRECISION(long,300)
+BZ_DECLARE_PRECISION(unsigned long,400)
+BZ_DECLARE_PRECISION(float,500)
+BZ_DECLARE_PRECISION(double,600)
+BZ_DECLARE_PRECISION(long double,700)
+
+#ifdef BZ_HAVE_COMPLEX
+BZ_DECLARE_PRECISION(complex<float>,800)
+BZ_DECLARE_PRECISION(complex<double>,900)
+BZ_DECLARE_PRECISION(complex<long double>,1000)
+#endif
+
+template<class T>
+struct autopromote_trait {
+    typedef T T_numtype;
+};
+
+#define BZ_DECLARE_AUTOPROMOTE(T1,T2)     \
+    template<>                            \
+    struct autopromote_trait<T1> {        \
+      typedef T2 T_numtype;               \
+    };
+
+// These are the odd cases where small integer types
+// are automatically promoted to int or unsigned int for
+// arithmetic.
+BZ_DECLARE_AUTOPROMOTE(bool, int)
+BZ_DECLARE_AUTOPROMOTE(char, int)
+BZ_DECLARE_AUTOPROMOTE(unsigned char, int)
+BZ_DECLARE_AUTOPROMOTE(short int, int)
+BZ_DECLARE_AUTOPROMOTE(short unsigned int, unsigned int)
+
+template<class T1, class T2, int promoteToT1>
+struct _bz_promote2 {
+    typedef T1 T_promote;
+};
+
+template<class T1, class T2>
+struct _bz_promote2<T1,T2,0> {
+    typedef T2 T_promote;
+};
+
+template<class T1_orig, class T2_orig>
+struct promote_trait {
+    // Handle promotion of small integers to int/unsigned int
+    typedef _bz_typename autopromote_trait<T1_orig>::T_numtype T1;
+    typedef _bz_typename autopromote_trait<T2_orig>::T_numtype T2;
+
+    // True if T1 is higher ranked
+    enum {
+      T1IsBetter =
+        BZ_ENUM_CAST(precision_trait<T1>::precisionRank) >
+          BZ_ENUM_CAST(precision_trait<T2>::precisionRank),
+
+    // True if we know ranks for both T1 and T2
+      knowBothRanks =
+        BZ_ENUM_CAST(precision_trait<T1>::knowPrecisionRank)
+      && BZ_ENUM_CAST(precision_trait<T2>::knowPrecisionRank),
+
+    // True if we know T1 but not T2
+      knowT1butNotT2 =  BZ_ENUM_CAST(precision_trait<T1>::knowPrecisionRank)
+        && !(BZ_ENUM_CAST(precision_trait<T2>::knowPrecisionRank)),
+
+    // True if we know T2 but not T1
+      knowT2butNotT1 =  BZ_ENUM_CAST(precision_trait<T2>::knowPrecisionRank)
+        && !(BZ_ENUM_CAST(precision_trait<T1>::knowPrecisionRank)),
+
+    // True if T1 is bigger than T2
+      T1IsLarger = sizeof(T1) >= sizeof(T2),
+
+    // We know T1 but not T2: true
+    // We know T2 but not T1: false
+    // Otherwise, if T1 is bigger than T2: true
+      defaultPromotion = knowT1butNotT2 ? _bz_false : 
+         (knowT2butNotT1 ? _bz_true : T1IsLarger)
+    };
+
+    // If we have both ranks, then use them.
+    // If we have only one rank, then use the unknown type.
+    // If we have neither rank, then promote to the larger type.
+
+    enum {
+      promoteToT1 = (BZ_ENUM_CAST(knowBothRanks) ? BZ_ENUM_CAST(T1IsBetter)
+        : BZ_ENUM_CAST(defaultPromotion)) ? 1 : 0
+    };
+
+    typedef typename _bz_promote2<T1,T2,promoteToT1>::T_promote T_promote;
+};
+
+#else  // !BZ_PARTIAL_SPECIALIZATION
+
+  // No partial specialization -- have to do it the ugly way.
+  #include <blitz/promote-old.h>
+
+#endif // !BZ_PARTIAL_SPECIALIZATION
+
+BZ_NAMESPACE_END
+
+#endif // BZ_PROMOTE_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-dunif.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-dunif.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-dunif.h	(revision 1307)
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * blitz/rand-dunif.h    Discrete uniform generator
+ *
+ * $Id: rand-dunif.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_RAND_DUNIF_H
+#define BZ_RAND_DUNIF_H
+
+#ifndef BZ_RANDOM_H
+ #include <blitz/random.h>
+#endif
+
+#ifndef BZ_RAND_UNIFORM_H
+ #include <blitz/rand-uniform.h>
+#endif
+
+#include <math.h>
+
+BZ_NAMESPACE(blitz)
+
+template<class P_uniform BZ_TEMPLATE_DEFAULT(Uniform)>
+class DiscreteUniform {
+
+public:
+    typedef int T_numtype;
+    typedef P_uniform T_uniform;
+
+    DiscreteUniform(int low, int high, double=0)
+        : low_(low), range_(high-low+1)
+    { 
+    }
+
+    void randomize() 
+    { 
+        uniform_.randomize();
+    }
+  
+    int random()
+    { 
+        return int(uniform_.random() * range_ + low_);
+    } 
+
+private:
+    int low_, range_;
+    T_uniform uniform_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_RAND_DUNIF_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-normal.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-normal.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-normal.h	(revision 1307)
@@ -0,0 +1,101 @@
+/***************************************************************************
+ * blitz/rand-normal.h    Random Gaussian (Normal) generator
+ *
+ * $Id: rand-normal.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ *
+ * This generator transforms a (0,1] uniform distribution into
+ * a Normal distribution.  Let u,v be (0,1] random variables. Then
+ *
+ *    x = sqrt(-2 ln v) cos(pi (2u-1))
+ *
+ * is N(0,1) distributed.
+ *
+ * Reference: Athanasios Papoulis, "Probability, random variables,
+ * and stochastic processes," McGraw-Hill : Toronto, 1991.
+ *
+ ***************************************************************************
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_RAND_NORMAL_H
+#define BZ_RAND_NORMAL_H
+
+#ifndef BZ_RANDOM_H
+ #include <blitz/random.h>
+#endif
+
+#ifndef BZ_RAND_UNIFORM_H
+ #include <blitz/rand-uniform.h>
+#endif
+
+#include <math.h>
+
+BZ_NAMESPACE(blitz)
+
+template<class P_uniform BZ_TEMPLATE_DEFAULT(Uniform)>
+class Normal {
+
+public:
+    typedef double T_numtype;
+
+    Normal(double mean = 0.0, double variance = 1.0, double = 0.0)
+        : mean_(mean), sigma_(::sqrt(variance))
+    { 
+    }
+
+    void randomize() 
+    { 
+        uniform_.randomize();
+    }
+  
+    double random()
+    { 
+        double u, v;
+
+        do {
+            u = uniform_.random();
+            v = uniform_.random();    
+        } while (v == 0);
+
+        return mean_ + sigma_ * ::sqrt(-2*::log(v)) * ::cos(M_PI * (2*u - 1));
+    } 
+
+private:
+    double mean_, sigma_;
+    P_uniform uniform_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_RAND_NORMAL_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-tt800.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-tt800.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-tt800.h	(revision 1307)
@@ -0,0 +1,122 @@
+/***************************************************************************
+ * blitz/rand-tt800.h      Matsumoto and Kurita's TT800 uniform random 
+ *                         number generator.
+ *
+ * $Id: rand-tt800.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ ***************************************************************************
+ *
+ * The class TT800 encapsulates Makoto Matsumoto and Yoshiharu Kurita's 
+ * TT800 twisted generalized feedback shift register (TGFSR) random number 
+ * generator.  The generator has period 2^800 - 1.
+ *
+ * Contact: M. Matsumoto <matumoto@math.keio.ac.jp>
+ *
+ * See: M. Matsumoto and Y. Kurita, Twisted GFSR Generators II, 
+ *      ACM Transactions on Modelling and Computer Simulation,
+ *      Vol. 4, No. 3, 1994, pages 254-266.
+ *
+ * (c) 1994 Association for Computing Machinery.  
+ *
+ * Distributed with consent of the authors.
+ *
+ ***************************************************************************
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.1  1997/02/28 13:39:51  tveldhui
+ * Initial revision
+ *
+ */
+
+#ifndef BZ_RAND_TT800_H
+#define BZ_RAND_TT800_H
+
+#ifndef BZ_RANDOM_H
+ #include <blitz/random.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+class TT800 {
+
+public:
+    typedef double T_numtype;
+
+    TT800(double low = 0.0, double high = 1.0, double = 0.0)
+        : low_(low), length_(high-low)
+    { 
+        // Initial 25 seeds
+        x[0] = 0x95f24dab; x[1] = 0x0b685215; x[2] = 0xe76ccae7;
+        x[3] = 0xaf3ec239; x[4] = 0x715fad23; x[5] = 0x24a590ad;
+        x[6] = 0x69e4b5ef; x[7] = 0xbf456141; x[8] = 0x96bc1b7b;
+        x[9] = 0xa7bdf825; x[10] = 0xc1de75b7; x[11] = 0x8858a9c9;
+        x[12] = 0x2da87693; x[13] = 0xb657f9dd; x[14] = 0xffdc8a9f;
+        x[15] = 0x8121da71; x[16] = 0x8b823ecb; x[17] = 0x885d05f5;
+        x[18] = 0x4e20cd47; x[19] = 0x5a9ad5d9; x[20] = 0x512c0c03;
+        x[21] = 0xea857ccd; x[22] = 0x4cc1d30f; x[23] = 0x8891a8a1;
+        x[24] = 0xa6b7aadb;
+
+        // Magic vector 'a', don't change
+        mag01[0] = 0;
+        mag01[1] = 0x8ebfd028;
+
+        k = 0;
+    }
+
+    void randomize() 
+    { 
+        BZ_NOT_IMPLEMENTED();            // NEEDS_WORK
+    }
+  
+    double random()
+    { 
+        if (k==N) 
+            generate();
+
+        unsigned long y = x[k];
+        y ^= (y << 7) & 0x2b5b2500; /* s and b, magic vectors */
+        y ^= (y << 15) & 0xdb8b0000; /* t and c, magic vectors */
+        y &= 0xffffffff; /* you may delete this line if word size = 32 */
+
+        // the following line was added by Makoto Matsumoto in the 1996 version
+        // to improve lower bit's corellation.
+        // Delete this line to use the code published in 1994.
+
+        y ^= (y >> 16); /* added to the 1994 version */
+        k++;
+
+        // NEEDS_WORK: this only generates a random number with
+        // 15 bits of precision.  Need 48 bits for double.
+        return low_ + length_ * ( (double) y / (unsigned long) 0xffffffff);
+    } 
+
+protected:
+    void generate()
+    {
+        /* generate N words at one time */
+        int kk;
+        for (kk=0;kk<N-M;kk++) {
+            x[kk] = x[kk+M] ^ (x[kk] >> 1) ^ mag01[x[kk] % 2];
+        }
+        for (; kk<N;kk++) {
+            x[kk] = x[kk+(M-N)] ^ (x[kk] >> 1) ^ mag01[x[kk] % 2];
+        }
+        k=0;
+    }
+
+private:
+    enum { N = 25, M = 7 };
+
+    double low_, length_;
+    int k;
+    unsigned long x[N];
+    unsigned long mag01[2];
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_RAND_TT800_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-uniform.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-uniform.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/rand-uniform.h	(revision 1307)
@@ -0,0 +1,128 @@
+/***************************************************************************
+ * blitz/rand-uniform.h    Uniform class, which provides uniformly
+ *                         distributed random numbers.
+ *
+ * $Id: rand-uniform.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ *
+ * This random number generator is based on the LAPACK auxilliary
+ * routine DLARAN by Jack Dongarra.  It's a multiplicative congruential 
+ * generator with modulus 2^48 and multiplier 33952834046453. 
+ *
+ * See also: G. S. Fishman, Multiplicative congruential random number
+ * generators with modulus 2^b: an exhaustive analysis for b=32 and
+ * a partial analysis for b=48, Math. Comp. 189, pp 331-344, 1990.
+ * 
+ * This routine requires 32-bit integers.
+ *
+ * The generated number lies in the open interval (low,high).  i.e. low and
+ * high themselves will never be generated.
+ *
+ ***************************************************************************
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_RAND_UNIFORM_H
+#define BZ_RAND_UNIFORM_H
+
+#ifndef BZ_RANDOM_H
+ #include <blitz/random.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+class Uniform {
+
+public:
+    typedef double T_numtype;
+
+    Uniform(double low = 0.0, double high = 1.0, double = 0.0)
+        : low_(low), length_(high-low)
+    { 
+        BZPRECONDITION(sizeof(int) >= 4);   // Need 32 bit integers!
+
+        seed[0] = 24;       // All seeds in the range [0,4095]
+        seed[1] = 711;
+        seed[2] = 3;
+        seed[3] = 3721;     // The last seed must be odd
+    }
+
+    void randomize() 
+    { 
+        BZ_NOT_IMPLEMENTED();            // NEEDS_WORK
+
+        BZPOSTCONDITION(seed[3] % 2 == 1);
+    }
+  
+    // I'm trying to avoid having a compiled 
+    // portion of the library, so this is inline until I
+    // figure out a better way to do this or I change my mind.
+    // -- TV
+    // NEEDS_WORK
+    double random()
+    { 
+        BZPRECONDITION(seed[3] % 2 == 1);
+
+        int it0, it1, it2, it3;
+        it3 = seed[3] * 2549;
+        it2 = it3 / 4096;
+        it3 -= it2 << 12;
+        it2 += seed[2] * 2549 + seed[3] * 2508;
+        it1 = it2 / 4096;
+        it2 -= it1 << 12;
+        it1 += seed[1] * 2549 + seed[2] * 2508 + seed[3] * 322;
+        it0 = it1 / 4096;
+        it1 -= it0 << 12;
+        it0 += seed[0] * 2549 + seed[1] * 2508 + seed[2] * 322 + seed[3] * 494;
+        it0 %= 4096;
+        seed[0] = it0;
+        seed[1] = it1;
+        seed[2] = it2;
+        seed[3] = it3;
+      
+        const double z = 1 / 4096.;
+        return low_ + length_ * (it0 + (it1 + (it2 + it3 * z) * z) * z) * z;
+    } 
+
+    operator double() 
+    { return random(); }
+
+private:
+    double low_, length_;
+
+    int seed[4];
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_RAND_UNIFORM_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/random.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/random.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/random.h	(revision 1307)
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * blitz/random.h       Random number generator wrapper class
+ *
+ * $Id: random.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_RANDOM_H
+#define BZ_RANDOM_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_distribution>
+class Random {
+
+public:
+    typedef P_distribution T_distribution;
+    typedef _bz_typename T_distribution::T_numtype T_numtype;
+
+    Random(double parm1=0.0, double parm2=1.0, double parm3=0.0)
+        : generator_(parm1, parm2, parm3)
+    { }
+
+    void randomize()
+    { generator_.randomize(); }
+   
+    T_numtype random()
+    { return generator_.random(); }
+
+    operator T_numtype()
+    { return generator_.random(); }
+
+protected: 
+    T_distribution generator_;
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/randref.h>
+
+#endif // BZ_RANDOM_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/randref.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/randref.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/randref.h	(revision 1307)
@@ -0,0 +1,87 @@
+/***************************************************************************
+ * blitz/randref.h      Random number generators, expression templates
+ *                      wrapper
+ *
+ * $Id: randref.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_RANDREF_H
+#define BZ_RANDREF_H
+
+#ifndef BZ_RANDOM_H
+ #error <blitz/randref.h> must be included via <blitz/random.h>
+#endif // BZ_RANDOM_H
+
+BZ_NAMESPACE(blitz)
+
+template<class P_distribution>
+class _bz_VecExprRandom {
+
+public:
+    typedef _bz_typename Random<P_distribution>::T_numtype T_numtype;
+
+    _bz_VecExprRandom(Random<P_distribution>& random)
+        : random_(random)
+    { }
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    _bz_VecExprRandom(_bz_VecExprRandom<P_distribution>& x)
+        : random_(x.random_)
+    { }
+#endif
+
+    T_numtype operator[](unsigned) const
+    { return random_.random(); }
+
+    T_numtype operator()(unsigned) const
+    { return random_.random(); }
+
+    unsigned length(unsigned recommendedLength) const
+    { return recommendedLength; }
+
+    unsigned _bz_suggestLength() const
+    { return 0; }
+
+    _bz_bool _bz_hasFastAccess() const
+    { return 1; }
+
+    T_numtype _bz_fastAccess(unsigned) const
+    { return random_.random(); }
+
+private:
+    _bz_VecExprRandom() { }
+
+    Random<P_distribution>& random_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_RANDREF_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/range.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/range.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/range.h	(revision 1307)
@@ -0,0 +1,229 @@
+/***************************************************************************
+ * blitz/range.h      Declaration of the Range class
+ *
+ * $Id: range.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.6  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.5  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.4  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1996/11/11 17:29:13  tveldhui
+ * Initial revision
+ *
+ *
+ */
+
+#ifndef BZ_RANGE_H
+#define BZ_RANGE_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_VECEXPRWRAP_H
+ #include <blitz/vecexprwrap.h>      // _bz_VecExpr wrapper
+#endif
+
+#include <limits.h>                  // for INT_MIN
+
+BZ_NAMESPACE(blitz)
+
+// Examples: 
+// Vector<double> x(7);
+// Range::all()                    [0,1,2,3,4,5,6]
+// Range(3,5)                      [3,4,5]
+// Range(3,Range::toEnd)           [3,4,5,6]
+// Range(Range::fromStart,3)       [0,1,2,3]
+// Range(1,5,2);                   [1,3,5]
+
+enum { fromStart = INT_MIN, toEnd = INT_MIN };
+
+// Class Range
+class Range {
+
+public:
+    // This declaration not yet supported by all compilers
+    // const int fromStart = INT_MIN;
+    // const int toEnd = INT_MIN;
+
+    typedef int T_numtype;
+
+    enum { fromStart = INT_MIN, toEnd = INT_MIN };
+
+    Range()
+    {
+        first_ = fromStart;
+        last_ = toEnd;
+        stride_ = 1;
+    }
+
+    // Range(Range r): allow default copy constructor to be used
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    Range(const Range& r)
+    {
+        first_ = r.first_;
+        last_ = r.last_;
+        stride_ = r.stride_;
+    }
+#endif
+
+    _bz_explicit Range(int slicePosition)
+    {
+        first_ = slicePosition;
+        last_ = slicePosition;
+        stride_ = 1;
+    }
+
+    Range(int first, int last, int stride=1)
+        : first_(first), last_(last), stride_(stride)
+    { 
+        BZPRECHECK((first == fromStart) || (last == toEnd) ||
+                       (first < last) && (stride > 0) ||
+                       (first > last) && (stride < 0) ||
+                       (first == last), (*this) << " is an invalid range.");
+        BZPRECHECK((last-first) % stride == 0,
+            (*this) << ": the stride must evenly divide the range");
+    }
+
+    int first(int lowRange = 0) const
+    { 
+        if (first_ == fromStart)
+            return lowRange;
+        return first_; 
+    }
+
+    int last(int highRange = 0) const
+    {
+        if (last_ == toEnd)
+            return highRange;
+        return last_;
+    }
+
+    unsigned length(int recommendedLength = 0) const
+    {
+        BZPRECONDITION(first_ != fromStart);
+        BZPRECONDITION(last_ != toEnd);
+        BZPRECONDITION((last_ - first_) % stride_ == 0);
+        return (last_ - first_) / stride_ + 1;
+    }
+
+    int stride() const
+    { return stride_; }
+
+    _bz_bool isAscendingContiguous() const
+    {
+        return (first_ < last_) && (stride_ == 1);
+    }
+
+    void setRange(int first, int last, int stride=1)
+    {
+        BZPRECONDITION((first < last) && (stride > 0) ||
+                       (first > last) && (stride < 0) ||
+                       (first == last));
+        BZPRECONDITION((last-first) % stride == 0);
+        first_ = first;
+        last_ = last;
+        stride_ = stride;
+    }
+
+    static Range all() 
+    { return Range(fromStart,toEnd,1); }
+
+    bool isUnitStride() const
+    { return stride_ == 1; }
+
+    // Operators
+    Range operator-(int shift) const
+    { 
+        BZPRECONDITION(first_ != fromStart);
+        BZPRECONDITION(last_ != toEnd);
+        return Range(first_ - shift, last_ - shift, stride_); 
+    }
+
+    Range operator+(int shift) const
+    { 
+        BZPRECONDITION(first_ != fromStart);
+        BZPRECONDITION(last_ != toEnd);
+        return Range(first_ + shift, last_ + shift, stride_); 
+    }
+
+    int operator[](unsigned i) const
+    {
+        return first_ + i * stride_;
+    }
+
+    int operator()(unsigned i) const
+    {
+        return first_ + i * stride_;
+    }
+
+    friend inline ostream& operator<<(ostream& os, const Range& range)
+    {
+        os << "Range(" << range.first() << "," << range.last() << ","
+           << range.stride() << ")";
+
+        return os;
+    }
+
+    /////////////////////////////////////////////
+    // Library-internal member functions
+    // These are undocumented and may change or
+    // disappear in future releases.
+    /////////////////////////////////////////////
+
+    enum { _bz_staticLengthCount = 0,
+           _bz_dynamicLengthCount = 0,
+           _bz_staticLength = 0 };
+
+    _bz_bool _bz_hasFastAccess() const
+    { return stride_ == 1; }
+
+    T_numtype _bz_fastAccess(unsigned i) const
+    { return first_ + i; }
+
+    unsigned _bz_suggestLength() const
+    { 
+        return length();
+    }
+
+    _bz_VecExpr<Range> _bz_asVecExpr() const
+    { return _bz_VecExpr<Range>(*this); }
+
+private:
+    int first_, last_, stride_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_RANGE_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/reduce.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/reduce.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/reduce.h	(revision 1307)
@@ -0,0 +1,687 @@
+/***************************************************************************
+ * blitz/reduce.h        Reduction operators: sum, mean, min, max,
+ *                       minIndex, maxIndex, product, count, any, all
+ *
+ * $Id: reduce.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_REDUCE_H
+#define BZ_REDUCE_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_NUMTRAIT_H
+ #include <blitz/numtrait.h>
+#endif
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+#ifndef BZ_NUMINQUIRE_H
+ #include <blitz/numinquire.h>
+#endif
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_sourcetype, class P_resulttype = BZ_SUMTYPE(P_sourcetype)>
+class ReduceSum {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef P_resulttype T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 0, canProvideInitialValue = 1 };
+
+    ReduceSum()
+    { reset(); }
+
+    ReduceSum(T_resulttype initialValue)
+    { sum_ = initialValue; }
+
+    bool operator()(T_sourcetype x)
+    { 
+        sum_ += x; 
+        return true;
+    }
+
+    bool operator()(T_sourcetype x, int)
+    { 
+        sum_ += x; 
+        return true;
+    }
+
+    T_resulttype result(int)
+    { return sum_; }
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    void reset()
+    { sum_ = zero(T_resulttype()); }
+#else
+    void reset()
+    { sum_ = 0; }
+#endif
+
+    void reset(T_resulttype initialValue)
+    { sum_ = initialValue; }
+ 
+    static const char* name()
+    { return "sum"; }
+ 
+protected:
+    T_resulttype sum_;
+};
+
+template<class P_sourcetype, class P_resulttype = BZ_FLOATTYPE(P_sourcetype)>
+class ReduceMean {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef P_resulttype T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 0, canProvideInitialValue = 0 };
+
+    ReduceMean()
+    { reset(); }
+
+    ReduceMean(T_resulttype)
+    { 
+        BZPRECHECK(0, "Provided an initial value for ReduceMean");
+        reset();
+    }
+
+    bool operator()(T_sourcetype x)
+    { 
+        sum_ += x; 
+        return true;
+    }
+
+    bool operator()(T_sourcetype x, int)
+    { 
+        sum_ += x; 
+        return true;
+    }
+
+    T_resulttype result(int count)
+    { return sum_ / count; }
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    void reset()
+    { sum_ = zero(T_resulttype()); }
+#else
+    void reset()
+    { sum_ = 0; }
+#endif
+
+    void reset(T_resulttype)
+    { 
+        BZPRECHECK(0, "Provided an initial value for ReduceMean");
+        reset();
+    }
+
+    static const char* name() 
+    { return "mean"; }
+
+protected:
+    T_resulttype sum_;
+};
+
+template<class P_sourcetype>
+class ReduceMin {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef P_sourcetype T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 0, canProvideInitialValue = 1 };
+
+    ReduceMin()
+    { reset(); }
+
+    ReduceMin(T_resulttype min)
+    {
+        min_ = min;
+    }
+
+    bool operator()(T_sourcetype x)
+    { 
+        if (x < min_)
+            min_ = x;
+        return true;
+    }
+
+    bool operator()(T_sourcetype x, int)
+    {
+        if (x < min_)
+            min_ = x;
+        return true;
+    }
+
+    T_resulttype result(int)
+    { return min_; }
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    void reset()
+    { min_ = huge(P_sourcetype()); }
+#else
+    void reset()
+    {
+        BZPRECHECK(0, "ReduceMin requires <limits> from the ISO/ANSI C++ standard");
+    }
+#endif
+
+    void reset(T_resulttype initialValue)
+    { min_ = initialValue; }
+
+    static const char* name()
+    { return "min"; }
+
+protected:
+    T_resulttype min_;
+};
+
+template<class P_sourcetype>
+class ReduceMax {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef P_sourcetype T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 0, canProvideInitialValue = 1 };
+
+    ReduceMax()
+    { reset(); }
+
+    ReduceMax(T_resulttype max)
+    {
+        max_ = max;
+    }
+
+    bool operator()(T_sourcetype x)
+    {
+        if (x > max_)
+            max_ = x;
+        return true;
+    }
+
+    bool operator()(T_sourcetype x, int)
+    {
+        if (x > max_)
+            max_ = x;
+        return true;
+    }
+
+    T_resulttype result(int)
+    { return max_; }
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    void reset()
+    { max_ = tiny(P_sourcetype()); }
+#else
+    void reset()
+    { 
+        BZPRECHECK(0, "ReduceMax requires <limits> from the ISO/ANSI C++ standard");
+    }
+#endif
+
+    void reset(T_resulttype initialValue)
+    { max_ = initialValue; }
+
+    static const char* name()
+    { return "max"; }
+
+protected:
+    T_resulttype max_;
+};
+
+template<class P_sourcetype>
+class ReduceMinIndex {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef int          T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 1, canProvideInitialValue = 0 };
+
+    ReduceMinIndex()
+    { reset(); }
+
+    ReduceMinIndex(T_resulttype min)
+    {
+        reset(min);
+    }
+
+    bool operator()(T_sourcetype x)
+    {
+        BZPRECONDITION(0);
+        return false;
+    }
+
+    bool operator()(T_sourcetype x, int index)
+    {
+        if (x < min_)
+        {
+            min_ = x;
+            index_ = index;
+        }
+        return true;
+    }
+
+    T_resulttype result(int)
+    { return index_; }
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    void reset()
+    { 
+        min_ = huge(T_sourcetype());
+        index_ = tiny(int());        
+    }
+#else
+    void reset()
+    {
+        BZPRECHECK(0, "ReduceMinIndex requires <limits> from the ISO/ANSI C++ standard");
+    }
+#endif
+
+    void reset(T_resulttype)
+    { 
+        BZPRECHECK(0, "Provided initial value for ReduceMinIndex");
+        reset();
+    }
+
+    static const char* name()
+    { return "minIndex"; }
+
+protected:
+    T_sourcetype min_;
+    int index_;
+};
+
+template<class P_sourcetype>
+class ReduceMaxIndex {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef int          T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 1, canProvideInitialValue = 0 };
+
+    ReduceMaxIndex()
+    { reset(); }
+
+    ReduceMaxIndex(T_resulttype max)
+    {
+        reset(max);
+    }
+
+    bool operator()(T_sourcetype x)
+    {
+        BZPRECONDITION(0);
+        return false;
+    }
+
+    bool operator()(T_sourcetype x, int index)
+    {
+        if (x > max_)
+        {
+            max_ = x;
+            index_ = index;
+        }
+        return true;
+    }
+
+    T_resulttype result(int)
+    { return index_; }
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    void reset()
+    {
+        max_ = tiny(T_sourcetype());
+        index_ = tiny(int());
+    }
+#else
+    void reset()
+    {
+        BZPRECHECK(0, "ReduceMaxIndex requires <limits> from the ISO/ANSI C++ standard");
+    }
+#endif
+
+    void reset(T_resulttype)
+    {
+        BZPRECHECK(0, "Provided initial value for ReduceMaxIndex");
+        reset();
+    }
+
+    static const char* name()
+    { return "maxIndex"; }
+
+protected:
+    T_sourcetype max_;
+    int index_;
+};
+
+template<class P_sourcetype>
+class ReduceFirst {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef int          T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 1, canProvideInitialValue = 0 };
+
+    ReduceFirst()
+    { reset(); }
+
+    ReduceFirst(T_resulttype)
+    {
+        BZPRECONDITION(0);
+    }
+
+    bool operator()(T_sourcetype x)
+    {
+        BZPRECONDITION(0);
+        return false;
+    }
+
+    bool operator()(T_sourcetype x, int index)
+    {
+        if (x)
+        {
+            index_ = index;
+            return false;
+        }
+        else
+            return true;
+    }
+
+    T_resulttype result(int)
+    { return index_; }
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    void reset()
+    {
+        index_ = tiny(int());
+    }
+#else
+    void reset()
+    {
+        index_ = INT_MIN;
+    }
+#endif
+
+    void reset(T_resulttype)
+    {
+        BZPRECHECK(0, "Provided initial value for ReduceFirst");
+        reset();
+    }
+
+    static const char* name()
+    { return "first"; }
+
+protected:
+    int index_;
+};
+
+
+template<class P_sourcetype, class P_resulttype = BZ_SUMTYPE(P_sourcetype)>
+class ReduceProduct {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef P_resulttype T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 0, canProvideInitialValue = 1 };
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    ReduceProduct()
+    { product_ = one(T_resulttype()); }
+#else
+    ReduceProduct()
+    { product_ = 1; }
+#endif
+
+    ReduceProduct(T_resulttype initialValue)
+    { product_ = initialValue; }
+
+    bool operator()(T_sourcetype x)
+    { 
+        product_ *= x; 
+        return true;
+    }
+
+    bool operator()(T_sourcetype x, int)
+    { 
+        product_ *= x; 
+        return true;
+    }
+
+    T_resulttype result(int)
+    { return product_; }
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    void reset()
+    { product_ = one(T_resulttype()); }
+#else
+    void reset()
+    { product_ = T_resulttype(1.0); }
+#endif
+
+    void reset(T_resulttype initialValue)
+    { product_ = initialValue; }
+
+    static const char* name()
+    { return "product"; }
+
+protected:
+    T_resulttype product_;
+};
+
+template<class P_sourcetype>
+class ReduceCount {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef int          T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 0, canProvideInitialValue = 1 };
+
+    ReduceCount()
+    { reset(); }
+
+    ReduceCount(T_resulttype count)
+    {
+        count_ = count;
+    }
+
+    bool operator()(T_sourcetype x)
+    {
+        if (x)
+            ++count_;
+        return true;
+    }
+
+    bool operator()(T_sourcetype x, int)
+    {
+        if (x)
+            ++count_;
+        return true;
+    }
+
+    T_resulttype result(int)
+    { return count_; }
+
+#ifdef BZ_HAVE_NUMERIC_LIMITS
+    void reset()
+    { count_ = zero(T_resulttype()); }
+#else
+    void reset()
+    { count_ = 0; }
+#endif
+
+    void reset(T_resulttype initialValue)
+    { count_ = initialValue; }
+
+    static const char* name()
+    { return "count"; }
+
+protected:
+    T_resulttype count_;
+};
+
+template<class P_sourcetype>
+class ReduceAny {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef _bz_bool     T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 0, canProvideInitialValue = 0 };
+
+    ReduceAny()
+    { reset(); }
+
+    ReduceAny(T_resulttype initialValue)
+    {
+        reset(initialValue);
+    }
+
+    bool operator()(T_sourcetype x)
+    {
+        if (x)
+        {
+            any_ = _bz_true;
+            return false;
+        }
+
+        return true;
+    }
+
+    bool operator()(T_sourcetype x, int)
+    {
+        if (x)
+        {
+            any_ = _bz_true;
+            return false;
+        }
+
+        return true;
+    }
+
+    T_resulttype result(int)
+    { return any_; }
+
+    void reset()
+    { any_ = _bz_false; }
+
+    void reset(T_resulttype)
+    { 
+        BZPRECHECK(0, "Provided initial value for ReduceAny");
+        reset();
+    }
+
+    static const char* name()
+    { return "any"; }
+
+protected:
+    T_resulttype any_;
+};
+
+template<class P_sourcetype>
+class ReduceAll {
+
+public:
+    typedef P_sourcetype T_sourcetype;
+    typedef _bz_bool     T_resulttype;
+    typedef T_resulttype T_numtype;
+
+    enum { needIndex = 0, canProvideInitialValue = 0 };
+
+    ReduceAll()
+    { reset(); }
+
+    ReduceAll(T_resulttype initialValue)
+    {
+        reset(initialValue);
+    }
+
+    bool operator()(T_sourcetype x)
+    {
+        if (!_bz_bool(x))
+        {
+            all_ = _bz_false;
+            return false;
+        }
+        else
+            return true;
+    }
+
+    bool operator()(T_sourcetype x, int)
+    {
+        if (!_bz_bool(x))
+        {
+            all_ = _bz_false;
+            return false;
+        }
+        else
+            return true;
+    }
+
+    T_resulttype result(int)
+    { return all_; }
+
+    void reset()
+    { all_ = _bz_true; }
+
+    void reset(T_resulttype)
+    {
+        BZPRECHECK(0, "Provided initial value for ReduceAll");
+        reset();
+    }
+
+    static const char* name()
+    { return "all"; }
+
+protected:
+    T_resulttype all_;
+}; 
+
+BZ_NAMESPACE_END
+
+#endif // BZ_REDUCE_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/shapecheck.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/shapecheck.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/shapecheck.h	(revision 1307)
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * blitz/shapecheck.h    Functions for checking conformability of arrays
+ *
+ * $Id: shapecheck.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.1  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ */
+
+#ifndef BZ_SHAPECHECK_H
+#define BZ_SHAPECHECK_H
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * The function areShapesConformable(A,B) checks that the shapes 
+ * A and B are conformable (i.e. the same size/geometry).  Typically 
+ * the A and B parameters are of type TinyVector<int,N_rank> and represent 
+ * the extent of the arrays.  It's possible that in the future jagged-edged
+ * arrays will be supported, in which case shapes may be lists
+ * of subdomains.
+ */
+
+template<class T_shape1, class T_shape2>
+inline _bz_bool areShapesConformable(const T_shape1&, const T_shape2&)
+{
+    // If the shape objects are different types, this means
+    // that the arrays are different ranks, or one is jagged
+    // edged, etc.  In this case the two arrays are not
+    // conformable.
+    return _bz_false;
+}
+
+template<class T_shape>
+inline _bz_bool areShapesConformable(const T_shape& a, const T_shape& b)
+{
+    // The shape objects are the same type, so compare them.
+
+    // NEEDS_WORK-- once the "all" reduction is implemented, should
+    // use it.
+    // return all(a == b);
+
+    for (int i=0; i < a.length(); ++i)
+    {
+        if (a[i] != b[i])
+        {
+            BZ_DEBUG_MESSAGE("Incompatible shapes detected: " << endl 
+                 << a << endl << b << endl);
+            return _bz_false;
+        }
+    }
+
+    return _bz_true;
+}
+
+BZ_NAMESPACE_END
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tau.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tau.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tau.h	(revision 1307)
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * blitz/tau.h       Integration with the Tau profiling package.
+ *                   See http://www.acl.lanl.gov/tau/
+ *
+ * $Id: tau.h,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ */
+
+#ifndef BZ_TAU_H
+#define BZ_TAU_H
+
+#ifdef BZ_TAU_PROFILING
+ #define TAU_BLITZ  TAU_USER1
+ #include <Profile/Profiler.h>
+
+#else
+ #define TYPE_STRING(profileString, str)
+ #define PROFILED_BLOCK(name, type)
+ #define TAU_TYPE_STRING(profileString, str)
+ #define TAU_PROFILE(name, type, group)
+ #define TAU_PROFILE_TIMER(var, name, type, group)
+ #define TAU_PROFILE_START(var)
+ #define TAU_PROFILE_STOP(var)
+ #define TAU_PROFILE_STMT(stmt)
+ #define TAU_PROFILE_EXIT(msg)
+ #define TAU_PROFILE_INIT(argc, argv)
+ #define TAU_PROFILE_SET_NODE(node)
+ #define CT(obj)
+#endif // ! BZ_TAU_PROFILING
+
+#endif // BZ_TAU_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/timer.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/timer.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/timer.h	(revision 1307)
@@ -0,0 +1,113 @@
+/***************************************************************************
+ * blitz/Timer.h        Timer class, for use in benchmarking
+ *
+ * $Id: timer.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+// This class is not portable to non System V platforms.
+// It will need to be rewritten for Windows, NT, Mac.
+// NEEDS_WORK
+
+#ifndef BZ_TIMER_H
+#define BZ_TIMER_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifdef BZ_HAVE_RUSAGE
+ #include <sys/resource.h>
+#else
+ #include <time.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+class Timer {
+
+public:
+    Timer() 
+    { 
+        state_ = uninitialized;
+    }
+
+    void start()
+    { 
+        state_ = running;
+        t1_ = systemTime();
+    }
+
+    void stop()
+    {
+        t2_ = systemTime();
+        BZPRECONDITION(state_ == running);
+        state_ = stopped;
+    }
+
+    long double elapsedSeconds()
+    {
+        BZPRECONDITION(state_ == stopped);
+        return t2_ - t1_;
+    }
+
+private:
+    Timer(Timer&) { }
+    void operator=(Timer&) { }
+
+    long double systemTime()
+    {
+#ifdef BZ_HAVE_RUSAGE
+        getrusage(RUSAGE_SELF, &resourceUsage_);
+        double seconds = resourceUsage_.ru_utime.tv_sec 
+            + resourceUsage_.ru_stime.tv_sec;
+        double micros  = resourceUsage_.ru_utime.tv_usec 
+            + resourceUsage_.ru_stime.tv_usec;
+        return seconds + micros/1.0e6;
+#else
+        return clock() / (long double) CLOCKS_PER_SEC;
+#endif
+    }
+
+    enum { uninitialized, running, stopped } state_;
+
+#ifdef BZ_HAVE_RUSAGE
+    struct rusage resourceUsage_;
+#endif
+
+    long double t1_, t2_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_TIMER_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tiny.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tiny.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tiny.h	(revision 1307)
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * blitz/tiny.h          Tiny base class; now defunct; delete?
+ *
+ * $Id: tiny.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+
+#ifndef BZ_TINY_H
+#define BZ_TINY_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+class _bz_tinyBase {
+};
+
+BZ_NAMESPACE_END
+
+#endif
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tinymat.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tinymat.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tinymat.h	(revision 1307)
@@ -0,0 +1,149 @@
+/***************************************************************************
+ * blitz/tinymat.h       Declaration of TinyMatrix<T, N, M>
+ *
+ * $Id: tinymat.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_TINYMAT_H
+#define BZ_TINYMAT_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_TINYVEC_H
+ #include <blitz/tinyvec.h>
+#endif
+
+#ifndef BZ_LISTINIT_H
+ #include <blitz/listinit.h>
+#endif
+
+#include <blitz/tinymatexpr.h>
+#include <blitz/meta/matassign.h>
+
+BZ_NAMESPACE(blitz)
+
+// Forward declarations
+template<class T_expr>
+class _bz_tinyMatExpr;
+
+template<class T_numtype, int N_rows, int N_columns, int N_rowStride,
+    int N_colStride>
+class _bz_tinyMatrixRef {
+
+public:
+    _bz_tinyMatrixRef(T_numtype* _bz_restrict const data)
+        : data_(data)
+    { }
+
+    T_numtype * _bz_restrict data()
+    { return (T_numtype * _bz_restrict)data_; }
+
+    T_numtype& _bz_restrict operator()(int i, int j)
+    { return data_[i * N_rowStride + j * N_colStride]; }
+
+    T_numtype operator()(int i, int j) const
+    { return data_[i * N_rowStride + j * N_colStride]; }
+
+protected:
+    T_numtype * _bz_restrict const data_;
+};
+
+template<class P_numtype, int N_rows, int N_columns>
+class TinyMatrix {
+
+public:
+    typedef P_numtype T_numtype;
+    typedef _bz_tinyMatrixRef<T_numtype, N_rows, N_columns, N_columns, 1> 
+        T_reference;
+    typedef TinyMatrix<T_numtype, N_rows, N_columns> T_matrix;
+
+    TinyMatrix() { }
+
+    T_numtype* _bz_restrict data()
+    { return data_; }
+
+    const T_numtype* _bz_restrict data() const
+    { return data_; }
+
+    T_numtype* _bz_restrict dataFirst()
+    { return data_; }
+
+    const T_numtype* _bz_restrict dataFirst() const
+    { return data_; }
+
+    // NEEDS_WORK -- precondition checks
+    T_numtype& _bz_restrict operator()(int i, int j)
+    { return data_[i*N_columns + j]; }
+
+    T_numtype operator()(int i, int j) const
+    { return data_[i*N_columns + j]; }
+
+    T_reference getRef()
+    { return T_reference((T_numtype*)data_); }
+
+    const T_reference getRef() const
+    { return T_reference((T_numtype*)data_); }
+
+    // Scalar operand
+    ListInitializationSwitch<T_matrix>
+    operator=(T_numtype x)
+    {
+        return ListInitializationSwitch<T_matrix>(*this, x);
+    }
+
+    template<class T_expr>
+    TinyMatrix<T_numtype, N_rows, N_columns>&
+    operator=(_bz_tinyMatExpr<T_expr> expr)
+    {
+        _bz_meta_matAssign<N_rows, N_columns, 0>::f(*this, expr,
+            _bz_update<T_numtype, _bz_typename T_expr::T_numtype>());
+        return *this;
+    }
+
+    // NEEDS_WORK -- not implemented
+    void initialize(T_numtype x)
+    { BZ_NOT_IMPLEMENTED(); }
+
+    T_numtype* _bz_restrict getInitializationIterator()
+    { return dataFirst(); }
+
+protected:
+    T_numtype data_[N_rows * N_columns];
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/meta/matvec.h>     // Matrix-vector product metaprogram
+#include <blitz/meta/matmat.h>     // Matrix-matrix products
+
+#endif // BZ_TINYMAT_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tinymatexpr.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tinymatexpr.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tinymatexpr.h	(revision 1307)
@@ -0,0 +1,71 @@
+/***************************************************************************
+ * blitz/tinymatexpr.h   Tiny Matrix Expressions
+ *
+ * $Id: tinymatexpr.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_TINYMATEXPR_H
+#define BZ_TINYMATEXPR_H
+
+#ifndef BZ_TINYMAT_H
+ #error <blitz/tinymatexpr.h> must be included via <blitz/tinymat.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class T_expr>
+class _bz_tinyMatExpr {
+public:
+    typedef _bz_typename T_expr::T_numtype T_numtype;
+
+    enum {
+        rows = T_expr::rows,
+        columns = T_expr::columns
+    };
+
+    _bz_tinyMatExpr(T_expr expr)
+        : expr_(expr)
+    { }
+
+    _bz_tinyMatExpr(const _bz_tinyMatExpr<T_expr>& x)
+        : expr_(x.expr_)
+    { }
+
+    T_numtype operator()(int i, int j) const
+    { return expr_(i,j); }
+
+protected:
+    T_expr expr_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_TINYMATEXPR_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyvec.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyvec.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyvec.cc	(revision 1307)
@@ -0,0 +1,654 @@
+#ifndef BZ_TINYVEC_CC
+#define BZ_TINYVEC_CC
+
+#ifndef BZ_TINYVEC_H
+ #include <blitz/tinyvec.h>
+#endif
+
+#ifndef BZ_VECTOR_H
+ #include <blitz/vector.h>
+#endif
+
+#ifndef BZ_VECPICK_H
+ #include <blitz/vecpick.h>
+#endif
+
+#ifndef BZ_RANGE_H
+ #include <blitz/range.h>
+#endif
+
+#include <blitz/meta/vecassign.h>
+
+BZ_NAMESPACE(blitz)
+
+template<class T_numtype, int N_length>
+inline TinyVector<T_numtype, N_length>::TinyVector(T_numtype initValue)
+{
+    for (int i=0; i < N_length; ++i)
+        data_[i] = initValue;
+}
+
+template<class T_numtype, int N_length>
+inline TinyVector<T_numtype, N_length>::TinyVector(const 
+    TinyVector<T_numtype, N_length>& x)
+{
+    for (int i=0; i < N_length; ++i)
+        data_[i] = x.data_[i];
+}
+
+template<class T_numtype, int N_length> template<class P_expr, class P_updater>
+inline
+void TinyVector<T_numtype, N_length>::_bz_assign(P_expr expr, P_updater up)
+{
+    BZPRECHECK(expr.length(N_length) == N_length,
+        "An expression with length " << expr.length(N_length)
+        << " was assigned to a TinyVector<"
+        << BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(T_numtype)
+        << "," << N_length << ">");
+
+    if (expr._bz_hasFastAccess())
+    {
+        _bz_meta_vecAssign<N_length, 0>::fastAssign(*this, expr, up);
+    }
+    else {
+        _bz_meta_vecAssign<N_length, 0>::assign(*this, expr, up);
+    }
+}
+
+/*****************************************************************************
+ * Assignment operators with vector expression operand
+ */
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>& 
+TinyVector<P_numtype, N_length>::operator=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_update<P_numtype, _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator+=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_plus_update<P_numtype, 
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator-=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_minus_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator*=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_multiply_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator/=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_divide_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator%=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_mod_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator^=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_xor_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator&=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_bitand_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator|=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_bitor_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator<<=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_shiftl_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_expr>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator>>=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_shiftr_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with scalar operand
+ */
+
+template<class P_numtype, int N_length> 
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::initialize(P_numtype x)
+{
+#ifndef BZ_KCC_COPY_PROPAGATION_KLUDGE
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) = _bz_VecExpr<T_expr>(T_expr(x));
+#else
+    // Avoid using the copy propagation kludge for this simple
+    // operation.
+    for (int i=0; i < N_length; ++i)
+        data_[i] = x;
+#endif
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator+=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) += _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator-=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) -= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator*=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) *= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator/=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) /= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator%=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) %= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator^=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) ^= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator&=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) &= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator|=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) |= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator<<=(int x)
+{
+    typedef _bz_VecExprConstant<int> T_expr;
+    (*this) <<= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator>>=(int x)
+{
+    typedef _bz_VecExprConstant<int> T_expr;
+    (*this) >>= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with TinyVector operand
+ */
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator=(const 
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) = _bz_VecExpr<_bz_typename 
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator+=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) += _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator-=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) -= _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator*=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) *= _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator/=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) /= _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator%=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) %= _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator^=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) ^= _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator&=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) &= _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator|=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) |= _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator<<=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) <<= _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator>>=(const
+    TinyVector<P_numtype2, N_length>& x)
+{
+    (*this) >>= _bz_VecExpr<_bz_typename
+        TinyVector<P_numtype2, N_length>::T_constIterator>(x.begin());
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with Vector operand
+ */
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator=(const Vector<P_numtype2>& x)
+{
+    (*this) = x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator+=(const Vector<P_numtype2>& x)
+{
+    (*this) += x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator-=(const Vector<P_numtype2>& x)
+{
+    (*this) -= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator*=(const Vector<P_numtype2>& x)
+{
+    (*this) *= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator/=(const Vector<P_numtype2>& x)
+{
+    (*this) /= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator%=(const Vector<P_numtype2>& x)
+{
+    (*this) %= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator^=(const Vector<P_numtype2>& x)
+{
+    (*this) ^= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator&=(const Vector<P_numtype2>& x)
+{
+    (*this) &= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator|=(const Vector<P_numtype2>& x)
+{
+    (*this) |= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator<<=(const Vector<P_numtype2>& x)
+{
+    (*this) <<= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator>>=(const Vector<P_numtype2>& x)
+{
+    (*this) >>= x._bz_asVecExpr();
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with Range operand
+ */
+
+template<class P_numtype, int N_length> 
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator=(Range r)
+{
+    (*this) = r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator+=(Range r)
+{
+    (*this) += r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator-=(Range r)
+{
+    (*this) -= r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator*=(Range r)
+{
+    (*this) *= r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator/=(Range r)
+{
+    (*this) /= r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator%=(Range r)
+{
+    (*this) %= r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator^=(Range r)
+{
+    (*this) ^= r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator&=(Range r)
+{
+    (*this) &= r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator|=(Range r)
+{
+    (*this) |= r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator<<=(Range r)
+{
+    (*this) <<= r._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator>>=(Range r)
+{
+    (*this) >>= r._bz_asVecExpr();
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with VectorPick operand
+ */
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator=(const VectorPick<P_numtype2>& x)
+{
+    (*this) = x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator+=(const VectorPick<P_numtype2>& x)
+{
+    (*this) += x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator-=(const VectorPick<P_numtype2>& x)
+{
+    (*this) -= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator*=(const VectorPick<P_numtype2>& x)
+{
+    (*this) *= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator/=(const VectorPick<P_numtype2>& x)
+{
+    (*this) /= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator%=(const VectorPick<P_numtype2>& x)
+{
+    (*this) %= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator^=(const VectorPick<P_numtype2>& x)
+{
+    (*this) ^= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator&=(const VectorPick<P_numtype2>& x)
+{
+    (*this) &= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator|=(const VectorPick<P_numtype2>& x)
+{
+    (*this) |= x._bz_asVecExpr();
+    return *this;
+}
+
+template<class P_numtype, int N_length> template<class P_numtype2>
+inline TinyVector<P_numtype, N_length>&
+TinyVector<P_numtype, N_length>::operator>>=(const VectorPick<P_numtype2>& x)
+{
+    (*this) <<= x._bz_asVecExpr();
+    return *this;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_TINYVEC_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyvec.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyvec.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyvec.h	(revision 1307)
@@ -0,0 +1,433 @@
+/***************************************************************************
+ * blitz/tinyvec.h      Declaration of the TinyVector<T, N> class
+ *
+ * $Id: tinyvec.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_TINYVEC_H
+#define BZ_TINYVEC_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_RANGE_H
+ #include <blitz/range.h>
+#endif
+
+#ifndef BZ_LISTINIT_H
+ #include <blitz/listinit.h>
+#endif
+
+#include <blitz/tiny.h>
+
+BZ_NAMESPACE(blitz)
+
+/*****************************************************************************
+ * Forward declarations
+ */
+
+template<class P_numtype, int N_length, int N_stride BZ_TEMPLATE_DEFAULT(1) >
+class TinyVectorIter;
+
+template<class P_numtype, int N_length, int N_stride BZ_TEMPLATE_DEFAULT(1) >
+class TinyVectorIterConst;
+
+template<class P_numtype>
+class Vector;
+
+template<class P_expr>
+class _bz_VecExpr;
+
+template<class P_distribution>
+class Random;
+
+template<class P_numtype>
+class VectorPick;
+
+template<class T_numtype1, class T_numtype2, int N_rows, int N_columns,
+    int N_vecStride>
+class _bz_matrixVectorProduct;
+
+
+
+/*****************************************************************************
+ * Declaration of class TinyVector
+ */
+
+template<class P_numtype, int N_length>
+class TinyVector {
+
+public:
+    //////////////////////////////////////////////
+    // Public Types
+    //////////////////////////////////////////////
+
+    typedef P_numtype                                    T_numtype;
+    typedef TinyVector<T_numtype,N_length>               T_vector;
+    typedef TinyVectorIter<T_numtype,N_length,1>         T_iterator;
+    typedef TinyVectorIterConst<T_numtype,N_length,1>    T_constIterator;
+    enum { numElements = N_length };
+
+    TinyVector()
+    { }
+
+    ~TinyVector() 
+    { }
+
+    inline TinyVector(const TinyVector<P_numtype,N_length>& x);
+
+    inline TinyVector(T_numtype initValue);
+
+    TinyVector(T_numtype x0, T_numtype x1)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+    }
+
+    TinyVector(T_numtype x0, T_numtype x1, T_numtype x2)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+        data_[2] = x2;
+    }
+
+    TinyVector(T_numtype x0, T_numtype x1, T_numtype x2,
+        T_numtype x3)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+        data_[2] = x2;
+        data_[3] = x3;
+    }
+
+    TinyVector(T_numtype x0, T_numtype x1, T_numtype x2,
+        T_numtype x3, T_numtype x4)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+        data_[2] = x2;
+        data_[3] = x3;
+        data_[4] = x4;
+    }
+
+    TinyVector(T_numtype x0, T_numtype x1, T_numtype x2,
+        T_numtype x3, T_numtype x4, T_numtype x5)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+        data_[2] = x2;
+        data_[3] = x3;
+        data_[4] = x4;
+        data_[5] = x5;
+    }
+
+    TinyVector(T_numtype x0, T_numtype x1, T_numtype x2,
+        T_numtype x3, T_numtype x4, T_numtype x5, T_numtype x6)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+        data_[2] = x2;
+        data_[3] = x3;
+        data_[4] = x4;
+        data_[5] = x5;
+        data_[6] = x6;
+    }
+
+    TinyVector(T_numtype x0, T_numtype x1, T_numtype x2,
+        T_numtype x3, T_numtype x4, T_numtype x5, T_numtype x6,
+        T_numtype x7)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+        data_[2] = x2;
+        data_[3] = x3;
+        data_[4] = x4;
+        data_[5] = x5;
+        data_[6] = x6;
+        data_[7] = x7;
+    }
+
+    TinyVector(T_numtype x0, T_numtype x1, T_numtype x2,
+        T_numtype x3, T_numtype x4, T_numtype x5, T_numtype x6,
+        T_numtype x7, T_numtype x8)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+        data_[2] = x2;
+        data_[3] = x3;
+        data_[4] = x4;
+        data_[5] = x5;
+        data_[6] = x6;
+        data_[7] = x7;
+        data_[8] = x8;
+    }
+
+    TinyVector(T_numtype x0, T_numtype x1, T_numtype x2,
+        T_numtype x3, T_numtype x4, T_numtype x5, T_numtype x6,
+        T_numtype x7, T_numtype x8, T_numtype x9)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+        data_[2] = x2;
+        data_[3] = x3;
+        data_[4] = x4;
+        data_[5] = x5;
+        data_[6] = x6;
+        data_[7] = x7;
+        data_[8] = x8;
+        data_[9] = x9;
+    }
+
+    TinyVector(T_numtype x0, T_numtype x1, T_numtype x2,
+        T_numtype x3, T_numtype x4, T_numtype x5, T_numtype x6,
+        T_numtype x7, T_numtype x8, T_numtype x9, T_numtype x10)
+    {
+        data_[0] = x0;
+        data_[1] = x1;
+        data_[2] = x2;
+        data_[3] = x3;
+        data_[4] = x4;
+        data_[5] = x5;
+        data_[6] = x6;
+        data_[7] = x7;
+        data_[8] = x8;
+        data_[9] = x9;
+        data_[10] = x10;
+    }
+
+    T_iterator begin()
+    { return T_iterator(*this); }
+
+    T_constIterator begin() const
+    { return T_constIterator(*this); }
+
+    // T_iterator end();
+    // T_constIterator end() const;
+
+    T_numtype * _bz_restrict data()
+    { return data_; }
+
+    const T_numtype * _bz_restrict data() const
+    { return data_; }
+
+    T_numtype * _bz_restrict dataFirst()
+    { return data_; }
+
+    const T_numtype * _bz_restrict dataFirst() const
+    { return data_; }
+
+    unsigned length() const
+    { return N_length; }
+
+    /////////////////////////////////////////////
+    // Library-internal member functions
+    // These are undocumented and may change or
+    // disappear in future releases.
+    /////////////////////////////////////////////
+
+    unsigned        _bz_suggestLength() const
+    { return N_length; }
+
+    _bz_bool        _bz_hasFastAccess() const
+    { return _bz_true; }
+
+    T_numtype& _bz_restrict     _bz_fastAccess(unsigned i)
+    { return data_[i]; }
+
+    T_numtype       _bz_fastAccess(unsigned i) const
+    { return data_[i]; }
+
+    template<class P_expr, class P_updater>
+    void _bz_assign(P_expr, P_updater);
+
+    _bz_VecExpr<T_constIterator> _bz_asVecExpr() const
+    { return _bz_VecExpr<T_constIterator>(begin()); }
+   
+    //////////////////////////////////////////////
+    // Subscripting operators
+    //////////////////////////////////////////////
+
+    int lengthCheck(unsigned i) const
+    {
+        BZPRECHECK(i < N_length, 
+            "TinyVector<" << BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(T_numtype) 
+            << "," << N_length << "> index out of bounds: " << i);
+        return 1;
+    }
+
+    T_numtype operator()(unsigned i) const
+    {
+        BZPRECONDITION(lengthCheck(i));
+        return data_[i];
+    }
+
+    T_numtype& _bz_restrict operator()(unsigned i)
+    { 
+        BZPRECONDITION(lengthCheck(i));
+        return data_[i];
+    }
+
+    T_numtype operator[](unsigned i) const
+    {
+        BZPRECONDITION(lengthCheck(i));
+        return data_[i];
+    }
+
+    T_numtype& _bz_restrict operator[](unsigned i)
+    {
+        BZPRECONDITION(lengthCheck(i));
+        return data_[i];
+    }
+
+    //////////////////////////////////////////////
+    // Assignment operators
+    //////////////////////////////////////////////
+
+    // Scalar operand
+    ListInitializationSwitch<T_vector> operator=(T_numtype x)
+    {
+        return ListInitializationSwitch<T_vector>(*this, x);
+    }
+
+    T_vector& initialize(T_numtype);
+    T_vector& operator+=(T_numtype);
+    T_vector& operator-=(T_numtype);
+    T_vector& operator*=(T_numtype);
+    T_vector& operator/=(T_numtype);
+    T_vector& operator%=(T_numtype);
+    T_vector& operator^=(T_numtype);
+    T_vector& operator&=(T_numtype);
+    T_vector& operator|=(T_numtype);
+    T_vector& operator>>=(int);
+    T_vector& operator<<=(int);
+
+    template<class P_numtype2> 
+    T_vector& operator=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator+=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator-=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator*=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator/=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator%=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator^=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator&=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator|=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator>>=(const TinyVector<P_numtype2, N_length> &);
+    template<class P_numtype2>
+    T_vector& operator<<=(const TinyVector<P_numtype2, N_length> &);
+
+    template<class P_numtype2> T_vector& operator=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator+=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator-=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator*=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator/=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator%=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator^=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator&=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator|=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator>>=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator<<=(const Vector<P_numtype2> &);
+
+    // Vector expression operand
+    template<class P_expr> T_vector& operator=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator+=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator-=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator*=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator/=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator%=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator^=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator&=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator|=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator>>=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator<<=(_bz_VecExpr<P_expr>);
+
+    // VectorPick operand
+    template<class P_numtype2>
+    T_vector& operator=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator+=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator-=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator*=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator/=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator%=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator^=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator&=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator|=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator>>=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator<<=(const VectorPick<P_numtype2> &);
+
+    // Range operand
+    T_vector& operator=(Range);
+    T_vector& operator+=(Range);
+    T_vector& operator-=(Range);
+    T_vector& operator*=(Range);
+    T_vector& operator/=(Range);
+    T_vector& operator%=(Range);
+    T_vector& operator^=(Range);
+    T_vector& operator&=(Range);
+    T_vector& operator|=(Range);
+    T_vector& operator>>=(Range);
+    T_vector& operator<<=(Range);
+
+    T_numtype* _bz_restrict getInitializationIterator()
+    { return dataFirst(); }
+
+private:
+    T_numtype data_[N_length];
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/tinyveciter.h>  // Iterators
+#include <blitz/tvecglobs.h>    // Global functions
+#include <blitz/vector.h>       // Expression templates
+#include <blitz/tinyvec.cc>     // Member functions
+#include <blitz/tinyvecio.cc>   // I/O functions
+
+#endif // BZ_TINYVEC_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyvecio.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyvecio.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyvecio.cc	(revision 1307)
@@ -0,0 +1,44 @@
+/*
+ * $Id: tinyvecio.cc,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_TINYVECIO_CC
+#define BZ_TINYVECIO_CC
+
+#ifndef BZ_TINYVEC_H
+ #include <blitz/tinyvec.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// NEEDS_WORK
+
+template<class P_numtype, int N_length>
+ostream& operator<<(ostream& os, const TinyVector<P_numtype, N_length>& x)
+{
+    os << "[ ";
+    for (int i=0; i < N_length; ++i)
+    {
+        os << setw(10) << x[i];
+        if (!((i+1)%7))
+            os << endl << "  ";
+    }
+    os << " ]";
+    return os;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_TINYVECIO_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyveciter.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyveciter.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tinyveciter.h	(revision 1307)
@@ -0,0 +1,170 @@
+/***************************************************************************
+ * blitz/tinyveciter.h   Declaration of TinyVectorIter<T,N,stride>
+ *
+ * $Id: tinyveciter.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+
+#ifndef BZ_TINYVECITER_H
+#define BZ_TINYVECITER_H
+
+#ifndef BZ_TINYVEC_H
+ #include <blitz/tinyvec.h>
+#endif
+
+#ifndef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+ #error "Debug in tinyveciter.h (this line shouldn't be here)"
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// N_stride has default 1, in forward declaration in <blitz/tinyvec.h>
+template<class P_numtype, int N_length, int N_stride>
+class TinyVectorIter {
+public:
+    typedef P_numtype T_numtype;
+
+    _bz_explicit TinyVectorIter(TinyVector<T_numtype, N_length>& x)
+        : data_(x.data())
+    { }
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    TinyVectorIter(const TinyVectorIter<T_numtype, N_length, N_stride>& iter)
+        : data_(iter.data_)
+    {
+    }
+#endif
+
+    T_numtype operator[](unsigned i) const
+    {
+        BZPRECONDITION(i < N_length);
+        return data_[i * N_stride];
+    }
+
+    T_numtype& _bz_restrict operator[](unsigned i)
+    {
+        BZPRECONDITION(i < N_length);
+        return data_[i * N_stride];
+    }
+
+    T_numtype operator()(unsigned i) const
+    {
+        BZPRECONDITION(i < N_length);
+        return data_[i * N_stride];
+    }
+
+    T_numtype& _bz_restrict operator()(unsigned i)
+    {
+        BZPRECONDITION(i < N_length);
+        return data_[i * N_stride];
+    }
+
+    unsigned length(unsigned) const
+    { return N_length; }
+
+    enum { _bz_staticLengthCount = 1,
+           _bz_dynamicLengthCount = 0,
+           _bz_staticLength = 0 };
+
+    _bz_bool _bz_hasFastAccess() const
+    { return _bz_true; }
+
+    T_numtype _bz_fastAccess(unsigned i) const
+    { return data_[i * N_stride]; }
+
+    T_numtype& _bz_fastAccess(unsigned i)
+    { return data_[i * N_stride]; }
+
+    unsigned _bz_suggestLength() const
+    { return N_length; }
+
+private:
+    T_numtype * _bz_restrict data_;
+};
+
+// N_stride has default 1, in forward declaration in <blitz/tinyvec.h>
+template<class P_numtype, int N_length, int N_stride>
+class TinyVectorIterConst {
+public:
+    typedef P_numtype T_numtype;
+
+    _bz_explicit TinyVectorIterConst(const TinyVector<T_numtype, N_length>& x)
+        : data_(x.data())
+    { }
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    TinyVectorIterConst(const TinyVectorIterConst<T_numtype, N_length, 
+        N_stride>& iter)
+        : data_(iter.data_)
+    {
+    }
+
+    void operator=(const TinyVectorIterConst<T_numtype, N_length, N_stride>& 
+        iter)
+    {
+        data_ = iter.data_;
+    }
+#endif
+
+    T_numtype operator[](unsigned i) const
+    {
+        BZPRECONDITION(i < N_length);
+        return data_[i * N_stride];
+    }
+
+    T_numtype operator()(unsigned i) const
+    {
+        BZPRECONDITION(i < N_length);
+        return data_[i * N_stride];
+    }
+
+    unsigned length(unsigned) const
+    { return N_length; }
+
+    enum { _bz_staticLengthCount = 1,
+           _bz_dynamicLengthCount = 0,
+           _bz_staticLength = 0 };
+
+    _bz_bool _bz_hasFastAccess() const
+    { return _bz_true; }
+
+    T_numtype _bz_fastAccess(unsigned i) const
+    { return data_[i * N_stride]; }
+
+    unsigned _bz_suggestLength() const
+    { return N_length; }
+
+private:
+    const T_numtype * _bz_restrict data_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_TINYVECITER_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/traversal.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/traversal.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/traversal.cc	(revision 1307)
@@ -0,0 +1,100 @@
+#ifndef BZ_TRAVERSAL_CC
+#define BZ_TRAVERSAL_CC
+
+#ifndef BZ_TRAVERSAL_H
+ #error <blitz/traversal.cc> must be included via <blitz/traversal.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<int N_dimensions>
+_bz_typename TraversalOrderCollection<N_dimensions>::T_set
+    TraversalOrderCollection<N_dimensions>::traversals_;
+
+template<int N>
+void makeHilbert(Vector<TinyVector<int,N> >& coord, 
+    int x0, int y0, int xis, int xjs,
+    int yis, int yjs, int n, int& i)
+{
+    // N != 2 is not yet implemented.
+    BZPRECONDITION(N == 2);
+
+    if (!n)
+    {
+        if (i > coord.length())
+        {
+            cerr << "makeHilbert: vector not long enough" << endl;
+            exit(1);
+        }
+        coord[i][0] = x0 + (xis+yis)/2;
+        coord[i][1] = y0 + (xjs+yjs)/2;
+        ++i;
+    }
+    else {
+        makeHilbert(coord,x0,y0,yis/2, yjs/2, xis/2, xjs/2, n-1, i);
+        makeHilbert(coord,x0+xis/2,y0+xjs/2,xis/2,xjs/2,yis/2,yjs/2,n-1,i);
+        makeHilbert(coord,x0+xis/2+yis/2,y0+xjs/2+yjs/2,xis/2,xjs/2,yis/2,
+            yjs/2,n-1,i);
+        makeHilbert(coord,x0+xis/2+yis, y0+xjs/2+yjs, -yis/2,-yjs/2,-xis/2,
+            -xjs/2,n-1,i);
+    }
+}
+
+template<int N_dimensions>
+void MakeHilbertTraversal(Vector<TinyVector<int,N_dimensions> >& coord, 
+    int length)
+{
+    // N_dimensions != 2 not yet implemented
+    BZPRECONDITION(N_dimensions == 2);
+
+    // The constant on the next line is ln(2)
+    int d = (int)(::ceil(::log((double)length) / 0.693147180559945309417));  
+
+    int N = 1 << d;
+    const int Npoints = N*N;
+    Vector<TinyVector<int,2> > coord2(Npoints);
+
+    int i=0;
+    makeHilbert(coord2,0,0,32768,0,0,32768,d,i);
+
+    int xp0 = coord2[0][0];
+    int yp0 = coord2[0][1];
+
+    int j=0;
+
+    coord.resize(length * length);
+
+    for (int i=0; i < Npoints; ++i)
+    {
+        coord2[i][0] = (coord2[i][0]-xp0)/(2*xp0);
+        coord2[i][1] = (coord2[i][1]-yp0)/(2*yp0);
+
+        if ((coord2[i][0] < length) && (coord2[i][1] < length) 
+            && (coord2[i][0] >= 0) && (coord2[i][1] >= 0))
+        {
+            coord[j][0] = coord2[i][0];
+            coord[j][1] = coord2[i][1];
+            ++j;
+        }
+    }
+}
+
+template<int N_dimensions>
+void generateFastTraversalOrder(const TinyVector<int,N_dimensions>& size)
+{
+    BZPRECONDITION(N_dimensions == 2);
+    BZPRECONDITION(size[0] == size[1]);
+
+    TraversalOrderCollection<2> travCol;
+    if (travCol.find(size))
+        return;
+
+    Vector<TinyVector<int,2> > ordering(size[0]);
+
+    MakeHilbertTraversal(ordering, size[0]);
+    travCol.insert(TraversalOrder<2>(size, ordering));
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_TRAVERSAL_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/traversal.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/traversal.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/traversal.h	(revision 1307)
@@ -0,0 +1,167 @@
+/***************************************************************************
+ * blitz/traversal.h      Declaration of the TraversalOrder classes
+ *
+ * $Id: traversal.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+// Fast traversal orders require the ISO/ANSI C++ standard library
+// (particularly set).
+#ifdef BZ_HAVE_STD
+
+#ifndef BZ_TRAVERSAL_H
+#define BZ_TRAVERSAL_H
+
+#ifndef BZ_TINYVEC_H
+ #include <blitz/tinyvec.h>
+#endif
+
+#ifndef BZ_VECTOR_H
+ #include <blitz/vector.h>
+#endif
+
+#include <set>
+
+BZ_NAMESPACE(blitz)
+
+template<int N_dimensions>
+class TraversalOrder {
+
+public:
+    typedef TinyVector<int, N_dimensions> T_coord;
+    typedef Vector<T_coord>               T_traversal;
+
+    TraversalOrder()
+    {
+        size_ = 0;
+    }
+
+    TraversalOrder(const T_coord& size, T_traversal& order)
+        : size_(size), order_(order)
+    { }
+
+    TraversalOrder(const T_coord& size)
+        : size_(size)
+    { }
+
+    T_coord operator[](int i) const
+    { return order_[i]; }
+
+    T_coord& operator[](int i)
+    { return order_[i]; }
+
+    int length() const
+    { return order_.length(); }
+
+    bool operator<(const TraversalOrder<N_dimensions>& x) const
+    {
+        for (int i=0; i < N_dimensions; ++i)
+        {
+            if (size_[i] < x.size_[i])
+                return true;
+            else if (size_[i] > x.size_[i])
+                return false;
+        }
+        return false;
+    }
+
+    bool operator==(const TraversalOrder<N_dimensions>& x) const
+    {
+        for (int i=0; i < N_dimensions; ++i)
+        {
+            if (size_[i] != x.size_[i])
+                return false;
+        }
+
+        return true;
+    }
+
+protected:
+    T_traversal order_;
+    T_coord     size_;
+};
+
+/*
+ * This specialization is provided to avoid problems with zero-length
+ * vectors.
+ */
+template<>
+class TraversalOrder<0> {
+};
+
+template<int N_dimensions>
+class TraversalOrderCollection {
+public:
+    typedef TraversalOrder<N_dimensions>        T_traversal;
+    typedef _bz_typename T_traversal::T_coord   T_coord;
+    typedef set<T_traversal>                    T_set;
+    typedef _bz_typename set<T_traversal>::const_iterator T_iterator;
+
+    const T_traversal* find(const T_coord& size)
+    {
+        T_iterator iter = traversals_.find(T_traversal(size));
+        if (iter != traversals_.end())
+            return &(*iter);
+        return 0;
+    }
+
+    void insert(T_traversal x)
+    {
+        traversals_.insert(x);
+    }
+
+protected:
+    static T_set traversals_;
+};
+
+/*
+ * This specialization is provided to avoid problems with zero-length
+ * vectors.
+ */
+
+template<>
+class TraversalOrderCollection<0> {
+public:
+    typedef int T_traversal;
+    typedef int T_coord;
+    typedef int T_set;
+    typedef int T_iterator;
+
+    const T_traversal* find(const T_coord& size)
+    { return 0; }
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/traversal.cc>
+
+#endif // BZ_TRAVERSAL_H
+
+#endif // BZ_HAVE_STD
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tuning.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tuning.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tuning.h	(revision 1307)
@@ -0,0 +1,140 @@
+/***************************************************************************
+ * blitz/tuning.h      Platform-specific code tuning
+ *
+ * $Id: tuning.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.6  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.5  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.4  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1996/11/11 17:29:13  tveldhui
+ * Initial revision
+ *
+ *
+ */
+
+#ifndef BZ_TUNING_H
+#define BZ_TUNING_H
+
+// These estimates should be conservative (i.e. underestimate the
+// cache sizes).
+#define BZ_L1_CACHE_ESTIMATED_SIZE    8192
+#define BZ_L2_CACHE_ESTIMATED_SIZE    65536
+
+
+#undef  BZ_PARTIAL_LOOP_UNROLL
+#define BZ_PASS_EXPR_BY_VALUE
+#undef  BZ_PTR_INC_FASTER_THAN_INDIRECTION
+#define BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+#undef  BZ_KCC_COPY_PROPAGATION_KLUDGE
+#undef  BZ_ALTERNATE_FORWARD_BACKWARD_TRAVERSALS
+#undef  BZ_ARRAY_EXPR_PASS_INDEX_BY_VALUE
+#define BZ_INLINE_GROUP1
+#define BZ_INLINE_GROUP2
+#define BZ_COLLAPSE_LOOPS
+#define BZ_USE_FAST_READ_ARRAY_EXPR
+#define BZ_ARRAY_EXPR_USE_COMMON_STRIDE
+#undef  BZ_ARRAY_FAST_TRAVERSAL_UNROLL
+#undef  BZ_ARRAY_STACK_TRAVERSAL_CSE_AND_ANTIALIAS
+#undef  BZ_ARRAY_STACK_TRAVERSAL_UNROLL
+#define BZ_ARRAY_2D_STENCIL_TILING
+#define BZ_ARRAY_2D_STENCIL_TILE_SIZE       128
+#undef  BZ_INTERLACE_ARRAYS
+
+
+/*
+ * Platform-specific tuning
+ */
+
+#ifdef _CRAYT3E
+ // The backend compiler on the T3E does a better job of
+ // loop unrolling.
+ #undef BZ_PARTIAL_LOOP_UNROLL
+ #undef BZ_ARRAY_FAST_TRAVERSAL_UNROLL
+ #undef BZ_ARRAY_STACK_TRAVERSAL_UNROLL
+#endif
+
+#ifdef __GNUC__
+ // The egcs compiler does a good job of loop unrolling, if
+ // -funroll-loops is used.
+ #undef BZ_PARTIAL_LOOP_UNROLL
+ #undef BZ_ARRAY_FAST_TRAVERSAL_UNROLL
+ #undef BZ_ARRAY_STACK_TRAVERSAL_UNROLL
+#endif
+
+#ifdef  BZ_DISABLE_KCC_COPY_PROPAGATION_KLUDGE
+ #undef BZ_KCC_COPY_PROPAGATION_KLUDGE
+#endif
+
+#ifdef  BZ_INLINE_GROUP1
+ #define _bz_inline1 inline
+#else
+ #define _bz_inline1
+#endif
+
+#ifdef  BZ_INLINE_GROUP2
+ #define _bz_inline2 inline
+#else
+ #define _bz_inline2
+#endif
+
+#ifdef __DECCXX
+ // The DEC cxx compiler has problems with loop unrolling
+ // because of aliasing.  Loop unrolling and anti-aliasing
+ // is done by Blitz++.
+
+  #define  BZ_PARTIAL_LOOP_UNROLL
+  #define  BZ_ARRAY_STACK_TRAVERSAL_CSE_AND_ANTIALIAS
+  #define  BZ_ARRAY_STACK_TRAVERSAL_UNROLL
+#endif
+
+/*
+ * BZ_NO_PROPAGATE(X) prevents the compiler from performing
+ * copy propagation on a variable.  This is used for loop
+ * unrolling to prevent KAI C++ from rearranging the
+ * ordering of memory accesses.
+ */
+
+#define BZ_NO_PROPAGATE(X)   X
+
+#ifdef __KCC
+#ifdef BZ_USE_NO_PROPAGATE
+    extern "C" int __kai_apply(const char*, ...);
+
+    #undef  BZ_NO_PROPAGATE(X)
+    #define BZ_NO_PROPAGATE(X)  __kai_apply("(%a)",&X)
+#endif
+#endif
+
+#endif // BZ_TUNING_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tvcross.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tvcross.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tvcross.h	(revision 1307)
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * blitz/tvcross.h      Cross product of TinyVector<N,3>'s
+ *
+ * $Id: tvcross.h,v 1.1.1.1 1999-04-09 17:59:02 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.1  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ */
+
+#ifndef BZ_TVCROSS_H
+#define BZ_TVCROSS_H
+
+#ifndef BZ_TINYVEC_H
+ #error <blitz/tvcross.h> must be included via <blitz/tinyvec.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/*
+ * cross product.
+ *
+ * NEEDS_WORK: - cross product of two different vector types
+ *             - cross product involving expressions
+ */
+
+template<class T_numtype>
+TinyVector<T_numtype,3> cross(const TinyVector<T_numtype,3>& x, 
+    const TinyVector<T_numtype,3>& y)
+{
+    return TinyVector<T_numtype,3>(x[1]*y[2] - y[1]*x[2],
+        y[0]*x[2] - x[0]*y[2], x[0]*y[1] - y[0]*x[1]);
+}
+
+
+BZ_NAMESPACE_END
+
+#endif // BZ_TVCROSS_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/tvecglobs.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/tvecglobs.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/tvecglobs.h	(revision 1307)
@@ -0,0 +1,89 @@
+/***************************************************************************
+ * blitz/tvecglobs.h     TinyVector global functions
+ *
+ * $Id: tvecglobs.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_TVECGLOBS_H
+#define BZ_TVECGLOBS_H
+
+#ifndef BZ_META_METAPROG_H
+ #include <blitz/meta/metaprog.h>
+#endif
+
+#ifndef BZ_NUMTRAIT_H
+ #include <blitz/numtrait.h>
+#endif
+
+#include <blitz/tvcross.h>       // Cross products
+#include <blitz/meta/dot.h>
+#include <blitz/meta/product.h>
+#include <blitz/meta/sum.h>
+
+BZ_NAMESPACE(blitz)
+
+template<class T_numtype1, class T_numtype2, int N_length>
+inline BZ_PROMOTE(T_numtype1, T_numtype2)
+dot(const TinyVector<T_numtype1, N_length>& a, 
+    const TinyVector<T_numtype2, N_length>& b)
+{
+    return _bz_meta_vectorDot<N_length, 0>::f(a,b);
+}
+
+template<class T_expr1, class T_numtype2, int N_length>
+inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype, T_numtype2)
+dot(_bz_VecExpr<T_expr1> a, const TinyVector<T_numtype2, N_length>& b)
+{
+    return _bz_meta_vectorDot<N_length, 0>::f_value_ref(a,b);
+}
+
+template<class T_numtype1, class T_expr2, int N_length>
+inline BZ_PROMOTE(T_numtype1, _bz_typename T_expr2::T_numtype)
+dot(const TinyVector<T_numtype1, N_length>& a, _bz_VecExpr<T_expr2> b)
+{
+    return _bz_meta_vectorDot<N_length, 0>::f_ref_value(a,b);
+}
+
+template<class T_numtype1, int N_length>
+inline BZ_SUMTYPE(T_numtype1)
+product(const TinyVector<T_numtype1, N_length>& a)
+{
+    return _bz_meta_vectorProduct<N_length, 0>::f(a);
+}
+
+template<class T_numtype, int N_length>
+inline T_numtype
+sum(const TinyVector<T_numtype, N_length>& a)
+{
+    return _bz_meta_vectorSum<N_length, 0>::f(a);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_TVECGLOBS_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/update.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/update.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/update.h	(revision 1307)
@@ -0,0 +1,80 @@
+/***************************************************************************
+ * blitz/update.h      Declaration of the _bz_XXXX updater classes
+ *
+ * $Id: update.h,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_UPDATE_H
+#define BZ_UPDATE_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+class _bz_updater_base { };
+
+#define BZ_DECL_UPDATER(name,op,symbol)               \
+  template<class X, class Y>                          \
+  class name : public _bz_updater_base {              \
+  public:                                             \
+    static inline void update(X& _bz_restrict x, Y y) \
+    { x op y; }                                       \
+    static void prettyPrint(string& str)              \
+    { str += symbol; }                                \
+  }
+
+BZ_DECL_UPDATER(_bz_update, =, "=");
+BZ_DECL_UPDATER(_bz_plus_update, +=, "+=");
+BZ_DECL_UPDATER(_bz_minus_update, -=, "-=");
+BZ_DECL_UPDATER(_bz_multiply_update, *=, "*=");
+BZ_DECL_UPDATER(_bz_divide_update, /=, "/=");
+BZ_DECL_UPDATER(_bz_mod_update, %=, "%=");
+BZ_DECL_UPDATER(_bz_xor_update, ^=, "^=");
+BZ_DECL_UPDATER(_bz_bitand_update, &=, "&=");
+BZ_DECL_UPDATER(_bz_bitor_update, |=, "|=");
+BZ_DECL_UPDATER(_bz_shiftl_update, <<=, "<<=");
+BZ_DECL_UPDATER(_bz_shiftr_update, >>=, ">>=");
+
+BZ_NAMESPACE_END
+
+#endif // BZ_UPDATE_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecaccum.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecaccum.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecaccum.cc	(revision 1307)
@@ -0,0 +1,78 @@
+/*
+ * $Id: vecaccum.cc,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECACCUM_CC
+#define BZ_VECACCUM_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecaccum.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P>
+inline
+Vector<BZ_SUMTYPE(_bz_typename P::T_numtype)> _bz_vec_accumulate(P expr)
+{
+    typedef BZ_SUMTYPE(_bz_typename P::T_numtype) T_sumtype;
+    int length = expr._bz_suggestLength();
+    Vector<T_sumtype> z(length);
+    T_sumtype sum = 0;
+
+    if (expr._bz_hasFastAccess())
+    {
+        for (int i=0; i < length; ++i)
+        {
+            sum += expr._bz_fastAccess(i);
+            z[i] = sum;
+        }
+    }
+    else {
+        for (int i=0; i < length; ++i)
+        {
+            sum += expr(i);
+            z[i] = sum;
+        }
+    }
+
+    return z;
+}
+template<class P_numtype>
+Vector<BZ_SUMTYPE(P_numtype)> accumulate(const Vector<P_numtype>& x)
+{
+    return _bz_vec_accumulate(x);
+}
+
+template<class P_expr>
+Vector<BZ_SUMTYPE(_bz_typename P_expr::T_numtype)>
+accumulate(_bz_VecExpr<P_expr> x)
+{
+    return _bz_vec_accumulate(x);
+}
+
+template<class P_numtype>
+Vector<BZ_SUMTYPE(P_numtype)> accumulate(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_accumulate(x);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECACCUM_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecall.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecall.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecall.cc	(revision 1307)
@@ -0,0 +1,76 @@
+/*
+ * $Id: vecall.cc,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECALL_CC
+#define BZ_VECALL_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecall.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr>
+inline _bz_bool _bz_vec_all(P_expr vector)
+{
+    int length = vector._bz_suggestLength();
+
+    if (vector._bz_hasFastAccess())
+    {
+        for (int i=0; i < length; ++i)
+            if (!vector._bz_fastAccess(i))
+                return _bz_false;
+    }
+    else {
+        for (int i=0; i < length; ++i)
+            if (!vector[i])
+                return _bz_false;
+    }
+
+    return _bz_true;
+}
+
+template<class P_numtype>
+inline _bz_bool all(const Vector<P_numtype>& x)
+{
+    return _bz_vec_all(x._bz_asVecExpr());
+}
+
+template<class P_expr>
+inline _bz_bool all(_bz_VecExpr<P_expr> expr)
+{
+    return _bz_vec_all(expr);
+}
+
+template<class P_numtype>
+inline _bz_bool all(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_all(x._bz_asVecExpr());
+}
+
+template<class P_numtype, int N_dimensions>
+inline _bz_bool all(const TinyVector<P_numtype, N_dimensions>& x)
+{
+    return _bz_vec_all(x._bz_asVecExpr());
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECALL_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecany.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecany.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecany.cc	(revision 1307)
@@ -0,0 +1,76 @@
+/*
+ * $Id: vecany.cc,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECANY_CC
+#define BZ_VECANY_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecany.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr>
+inline _bz_bool _bz_vec_any(P_expr vector)
+{
+    int length = vector._bz_suggestLength();
+
+    if (vector._bz_hasFastAccess())
+    {
+        for (int i=0; i < length; ++i)
+            if (vector._bz_fastAccess(i))
+                return _bz_true;
+    }
+    else {
+        for (int i=0; i < length; ++i)
+            if (vector[i])
+                return _bz_true;
+    }
+
+    return _bz_false;
+}
+
+template<class P_numtype>
+inline _bz_bool any(const Vector<P_numtype>& x)
+{
+    return _bz_vec_any(x._bz_asVecExpr());
+}
+
+template<class P_expr>
+inline _bz_bool any(_bz_VecExpr<P_expr> expr)
+{
+    return _bz_vec_any(expr);
+}
+
+template<class P_numtype>
+inline _bz_bool any(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_any(x._bz_asVecExpr());
+}
+
+template<class P_numtype, int N_dimensions>
+inline _bz_bool any(const TinyVector<P_numtype, N_dimensions>& x)
+{
+    return _bz_vec_any(x._bz_asVecExpr());
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECANY_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecbfn.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecbfn.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecbfn.cc	(revision 1307)
@@ -0,0 +1,15 @@
+#ifndef BZ_VECBFN_H
+#define BZ_VECBFN_H
+
+#ifndef BZ_VECEXPR_H
+ #error <blitz/vecbfn.h> must be included via <blitz/vecexpr.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Math functions with 2 operands have not yet been implemented.
+
+BZ_NAMESPACE_END
+
+#endif
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecbops.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecbops.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecbops.cc	(revision 1307)
@@ -0,0 +1,17290 @@
+/***************************************************************************
+ * blitz/vecbops.cc	Vector expression templates (2 operands)
+ *
+ * $Id: vecbops.cc,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.   Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ * Licensing inquiries:  blitz-licenses@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ */ 
+
+// Generated source file.  Do not edit. 
+// genvecbops.cpp Aug  7 1997 15:15:07
+
+#ifndef BZ_VECBOPS_CC
+#define BZ_VECBOPS_CC
+
+#ifndef BZ_VECEXPR_H
+ #error <blitz/vecbops.cc> must be included via <blitz/vecexpr.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+/****************************************************************************
+ * Addition Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> + Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<P_numtype1, P_numtype2 > > >
+operator+(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> + _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator+(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> + VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<P_numtype1, P_numtype2 > > >
+operator+(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> + Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_Add<P_numtype1, int > > >
+operator+(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_Add<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> + TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<P_numtype1, P_numtype2 > > >
+operator+(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> + int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Add<P_numtype1, int > > >
+operator+(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Add<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> + float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Add<P_numtype1, float > > >
+operator+(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Add<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> + double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Add<P_numtype1, double > > >
+operator+(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Add<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> + long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Add<P_numtype1, long double > > >
+operator+(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Add<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> + complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Add<P_numtype1, complex<T2>  > > >
+operator+(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Add<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> + Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> + _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> + VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> + Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_Add<_bz_typename P_expr1::T_numtype, int > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> + TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> + int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Add<_bz_typename P_expr1::T_numtype, int > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> + float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Add<_bz_typename P_expr1::T_numtype, float > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> + double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Add<_bz_typename P_expr1::T_numtype, double > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> + long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Add<_bz_typename P_expr1::T_numtype, long double > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Add<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> + complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Add<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator+(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Add<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> + Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<P_numtype1, P_numtype2 > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> + _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> + VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<P_numtype1, P_numtype2 > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> + Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_Add<P_numtype1, int > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_Add<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> + TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<P_numtype1, P_numtype2 > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> + int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Add<P_numtype1, int > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Add<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> + float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Add<P_numtype1, float > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Add<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> + double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Add<P_numtype1, double > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Add<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> + long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Add<P_numtype1, long double > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Add<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> + complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Add<P_numtype1, complex<T2>  > > >
+operator+(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Add<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range + Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<int, P_numtype2 > > >
+operator+(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range + _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<int, _bz_typename P_expr2::T_numtype > > >
+operator+(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range + VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<int, P_numtype2 > > >
+operator+(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range + Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_Add<int, int > > >
+operator+(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_Add<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range + TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<int, P_numtype2 > > >
+operator+(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range + float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_Add<int, float > > >
+operator+(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_Add<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range + double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_Add<int, double > > >
+operator+(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_Add<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range + long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_Add<int, long double > > >
+operator+(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Add<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range + complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Add<int, complex<T2>  > > >
+operator+(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Add<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> + Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<P_numtype1, P_numtype2 > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> + _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> + VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<P_numtype1, P_numtype2 > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> + Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_Add<P_numtype1, int > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_Add<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> + TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<P_numtype1, P_numtype2 > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> + int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Add<P_numtype1, int > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Add<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> + float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Add<P_numtype1, float > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Add<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> + double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Add<P_numtype1, double > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Add<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> + long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Add<P_numtype1, long double > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Add<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> + complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Add<P_numtype1, complex<T2>  > > >
+operator+(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Add<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int + Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<int, P_numtype2 > > >
+operator+(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int + _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<int, _bz_typename P_expr2::T_numtype > > >
+operator+(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int + VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<int, P_numtype2 > > >
+operator+(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int + TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<int, P_numtype2 > > >
+operator+(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float + Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<float, P_numtype2 > > >
+operator+(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float + _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<float, _bz_typename P_expr2::T_numtype > > >
+operator+(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float + VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<float, P_numtype2 > > >
+operator+(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float + Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_Add<float, int > > >
+operator+(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_Add<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float + TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<float, P_numtype2 > > >
+operator+(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double + Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<double, P_numtype2 > > >
+operator+(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double + _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<double, _bz_typename P_expr2::T_numtype > > >
+operator+(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double + VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<double, P_numtype2 > > >
+operator+(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double + Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_Add<double, int > > >
+operator+(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_Add<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double + TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<double, P_numtype2 > > >
+operator+(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double + Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<long double, P_numtype2 > > >
+operator+(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double + _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<long double, _bz_typename P_expr2::T_numtype > > >
+operator+(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double + VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<long double, P_numtype2 > > >
+operator+(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double + Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_Add<long double, int > > >
+operator+(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_Add<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double + TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<long double, P_numtype2 > > >
+operator+(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> + Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_Add<complex<T1> , P_numtype2 > > >
+operator+(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_Add<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> + _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_Add<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator+(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Add<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> + VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Add<complex<T1> , P_numtype2 > > >
+operator+(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Add<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> + Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_Add<complex<T1> , int > > >
+operator+(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_Add<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> + TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Add<complex<T1> , P_numtype2 > > >
+operator+(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Add<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Subtraction Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> - Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<P_numtype1, P_numtype2 > > >
+operator-(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> - _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator-(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> - VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<P_numtype1, P_numtype2 > > >
+operator-(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> - Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_Subtract<P_numtype1, int > > >
+operator-(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_Subtract<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> - TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<P_numtype1, P_numtype2 > > >
+operator-(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> - int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Subtract<P_numtype1, int > > >
+operator-(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Subtract<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> - float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Subtract<P_numtype1, float > > >
+operator-(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Subtract<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> - double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Subtract<P_numtype1, double > > >
+operator-(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Subtract<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> - long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Subtract<P_numtype1, long double > > >
+operator-(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Subtract<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> - complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Subtract<P_numtype1, complex<T2>  > > >
+operator-(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Subtract<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> - Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> - _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> - VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> - Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, int > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> - TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> - int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, int > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> - float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, float > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> - double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, double > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> - long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, long double > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> - complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator-(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Subtract<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> - Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<P_numtype1, P_numtype2 > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> - _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> - VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<P_numtype1, P_numtype2 > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> - Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_Subtract<P_numtype1, int > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_Subtract<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> - TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<P_numtype1, P_numtype2 > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> - int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Subtract<P_numtype1, int > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Subtract<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> - float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Subtract<P_numtype1, float > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Subtract<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> - double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Subtract<P_numtype1, double > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Subtract<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> - long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Subtract<P_numtype1, long double > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Subtract<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> - complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Subtract<P_numtype1, complex<T2>  > > >
+operator-(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Subtract<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range - Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<int, P_numtype2 > > >
+operator-(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range - _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<int, _bz_typename P_expr2::T_numtype > > >
+operator-(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range - VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<int, P_numtype2 > > >
+operator-(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range - Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_Subtract<int, int > > >
+operator-(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_Subtract<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range - TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<int, P_numtype2 > > >
+operator-(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range - float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_Subtract<int, float > > >
+operator-(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_Subtract<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range - double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_Subtract<int, double > > >
+operator-(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_Subtract<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range - long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_Subtract<int, long double > > >
+operator-(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Subtract<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range - complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Subtract<int, complex<T2>  > > >
+operator-(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Subtract<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> - Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<P_numtype1, P_numtype2 > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> - _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> - VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<P_numtype1, P_numtype2 > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> - Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_Subtract<P_numtype1, int > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_Subtract<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> - TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<P_numtype1, P_numtype2 > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> - int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Subtract<P_numtype1, int > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Subtract<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> - float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Subtract<P_numtype1, float > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Subtract<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> - double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Subtract<P_numtype1, double > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Subtract<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> - long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Subtract<P_numtype1, long double > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Subtract<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> - complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Subtract<P_numtype1, complex<T2>  > > >
+operator-(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Subtract<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int - Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<int, P_numtype2 > > >
+operator-(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int - _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<int, _bz_typename P_expr2::T_numtype > > >
+operator-(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int - VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<int, P_numtype2 > > >
+operator-(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int - TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<int, P_numtype2 > > >
+operator-(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float - Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<float, P_numtype2 > > >
+operator-(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float - _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<float, _bz_typename P_expr2::T_numtype > > >
+operator-(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float - VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<float, P_numtype2 > > >
+operator-(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float - Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_Subtract<float, int > > >
+operator-(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_Subtract<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float - TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<float, P_numtype2 > > >
+operator-(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double - Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<double, P_numtype2 > > >
+operator-(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double - _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<double, _bz_typename P_expr2::T_numtype > > >
+operator-(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double - VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<double, P_numtype2 > > >
+operator-(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double - Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_Subtract<double, int > > >
+operator-(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_Subtract<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double - TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<double, P_numtype2 > > >
+operator-(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double - Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<long double, P_numtype2 > > >
+operator-(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double - _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<long double, _bz_typename P_expr2::T_numtype > > >
+operator-(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double - VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<long double, P_numtype2 > > >
+operator-(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double - Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_Subtract<long double, int > > >
+operator-(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_Subtract<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double - TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<long double, P_numtype2 > > >
+operator-(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> - Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_Subtract<complex<T1> , P_numtype2 > > >
+operator-(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_Subtract<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> - _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_Subtract<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator-(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Subtract<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> - VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Subtract<complex<T1> , P_numtype2 > > >
+operator-(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Subtract<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> - Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_Subtract<complex<T1> , int > > >
+operator-(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_Subtract<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> - TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Subtract<complex<T1> , P_numtype2 > > >
+operator-(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Subtract<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Multiplication Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> * Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<P_numtype1, P_numtype2 > > >
+operator*(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> * _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator*(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> * VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<P_numtype1, P_numtype2 > > >
+operator*(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> * Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_Multiply<P_numtype1, int > > >
+operator*(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_Multiply<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> * TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<P_numtype1, P_numtype2 > > >
+operator*(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> * int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Multiply<P_numtype1, int > > >
+operator*(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Multiply<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> * float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Multiply<P_numtype1, float > > >
+operator*(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Multiply<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> * double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Multiply<P_numtype1, double > > >
+operator*(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Multiply<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> * long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Multiply<P_numtype1, long double > > >
+operator*(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Multiply<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> * complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Multiply<P_numtype1, complex<T2>  > > >
+operator*(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Multiply<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> * Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> * _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> * VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> * Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, int > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> * TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> * int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, int > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> * float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, float > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> * double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, double > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> * long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, long double > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> * complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator*(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Multiply<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> * Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<P_numtype1, P_numtype2 > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> * _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> * VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<P_numtype1, P_numtype2 > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> * Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_Multiply<P_numtype1, int > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_Multiply<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> * TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<P_numtype1, P_numtype2 > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> * int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Multiply<P_numtype1, int > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Multiply<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> * float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Multiply<P_numtype1, float > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Multiply<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> * double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Multiply<P_numtype1, double > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Multiply<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> * long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Multiply<P_numtype1, long double > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Multiply<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> * complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Multiply<P_numtype1, complex<T2>  > > >
+operator*(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Multiply<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range * Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<int, P_numtype2 > > >
+operator*(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range * _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<int, _bz_typename P_expr2::T_numtype > > >
+operator*(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range * VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<int, P_numtype2 > > >
+operator*(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range * Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_Multiply<int, int > > >
+operator*(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_Multiply<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range * TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<int, P_numtype2 > > >
+operator*(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range * float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_Multiply<int, float > > >
+operator*(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_Multiply<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range * double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_Multiply<int, double > > >
+operator*(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_Multiply<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range * long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_Multiply<int, long double > > >
+operator*(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Multiply<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range * complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Multiply<int, complex<T2>  > > >
+operator*(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Multiply<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> * Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<P_numtype1, P_numtype2 > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> * _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> * VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<P_numtype1, P_numtype2 > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> * Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_Multiply<P_numtype1, int > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_Multiply<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> * TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<P_numtype1, P_numtype2 > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> * int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Multiply<P_numtype1, int > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Multiply<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> * float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Multiply<P_numtype1, float > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Multiply<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> * double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Multiply<P_numtype1, double > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Multiply<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> * long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Multiply<P_numtype1, long double > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Multiply<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> * complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Multiply<P_numtype1, complex<T2>  > > >
+operator*(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Multiply<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int * Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<int, P_numtype2 > > >
+operator*(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int * _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<int, _bz_typename P_expr2::T_numtype > > >
+operator*(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int * VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<int, P_numtype2 > > >
+operator*(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int * TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<int, P_numtype2 > > >
+operator*(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float * Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<float, P_numtype2 > > >
+operator*(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float * _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<float, _bz_typename P_expr2::T_numtype > > >
+operator*(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float * VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<float, P_numtype2 > > >
+operator*(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float * Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_Multiply<float, int > > >
+operator*(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_Multiply<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float * TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<float, P_numtype2 > > >
+operator*(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double * Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<double, P_numtype2 > > >
+operator*(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double * _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<double, _bz_typename P_expr2::T_numtype > > >
+operator*(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double * VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<double, P_numtype2 > > >
+operator*(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double * Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_Multiply<double, int > > >
+operator*(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_Multiply<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double * TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<double, P_numtype2 > > >
+operator*(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double * Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<long double, P_numtype2 > > >
+operator*(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double * _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<long double, _bz_typename P_expr2::T_numtype > > >
+operator*(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double * VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<long double, P_numtype2 > > >
+operator*(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double * Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_Multiply<long double, int > > >
+operator*(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_Multiply<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double * TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<long double, P_numtype2 > > >
+operator*(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> * Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_Multiply<complex<T1> , P_numtype2 > > >
+operator*(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_Multiply<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> * _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_Multiply<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator*(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Multiply<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> * VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Multiply<complex<T1> , P_numtype2 > > >
+operator*(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Multiply<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> * Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_Multiply<complex<T1> , int > > >
+operator*(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_Multiply<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> * TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Multiply<complex<T1> , P_numtype2 > > >
+operator*(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Multiply<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Division Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> / Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<P_numtype1, P_numtype2 > > >
+operator/(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> / _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator/(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> / VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<P_numtype1, P_numtype2 > > >
+operator/(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> / Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_Divide<P_numtype1, int > > >
+operator/(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_Divide<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> / TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<P_numtype1, P_numtype2 > > >
+operator/(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> / int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Divide<P_numtype1, int > > >
+operator/(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Divide<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> / float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Divide<P_numtype1, float > > >
+operator/(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Divide<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> / double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Divide<P_numtype1, double > > >
+operator/(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Divide<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> / long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Divide<P_numtype1, long double > > >
+operator/(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Divide<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> / complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Divide<P_numtype1, complex<T2>  > > >
+operator/(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Divide<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> / Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> / _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> / VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> / Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, int > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> / TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> / int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, int > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> / float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, float > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> / double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, double > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> / long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, long double > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> / complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Divide<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator/(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Divide<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> / Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<P_numtype1, P_numtype2 > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> / _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> / VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<P_numtype1, P_numtype2 > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> / Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_Divide<P_numtype1, int > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_Divide<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> / TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<P_numtype1, P_numtype2 > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> / int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Divide<P_numtype1, int > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Divide<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> / float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Divide<P_numtype1, float > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Divide<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> / double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Divide<P_numtype1, double > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Divide<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> / long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Divide<P_numtype1, long double > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Divide<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> / complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Divide<P_numtype1, complex<T2>  > > >
+operator/(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Divide<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range / Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<int, P_numtype2 > > >
+operator/(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range / _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<int, _bz_typename P_expr2::T_numtype > > >
+operator/(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range / VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<int, P_numtype2 > > >
+operator/(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range / Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_Divide<int, int > > >
+operator/(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_Divide<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range / TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<int, P_numtype2 > > >
+operator/(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range / float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_Divide<int, float > > >
+operator/(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_Divide<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range / double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_Divide<int, double > > >
+operator/(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_Divide<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range / long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_Divide<int, long double > > >
+operator/(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Divide<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range / complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Divide<int, complex<T2>  > > >
+operator/(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Divide<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> / Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<P_numtype1, P_numtype2 > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> / _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> / VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<P_numtype1, P_numtype2 > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> / Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_Divide<P_numtype1, int > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_Divide<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> / TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<P_numtype1, P_numtype2 > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> / int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Divide<P_numtype1, int > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Divide<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> / float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Divide<P_numtype1, float > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Divide<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> / double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Divide<P_numtype1, double > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Divide<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> / long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Divide<P_numtype1, long double > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Divide<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> / complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Divide<P_numtype1, complex<T2>  > > >
+operator/(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Divide<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int / Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<int, P_numtype2 > > >
+operator/(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int / _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<int, _bz_typename P_expr2::T_numtype > > >
+operator/(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int / VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<int, P_numtype2 > > >
+operator/(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int / TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<int, P_numtype2 > > >
+operator/(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float / Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<float, P_numtype2 > > >
+operator/(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float / _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<float, _bz_typename P_expr2::T_numtype > > >
+operator/(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float / VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<float, P_numtype2 > > >
+operator/(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float / Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_Divide<float, int > > >
+operator/(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_Divide<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float / TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<float, P_numtype2 > > >
+operator/(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double / Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<double, P_numtype2 > > >
+operator/(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double / _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<double, _bz_typename P_expr2::T_numtype > > >
+operator/(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double / VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<double, P_numtype2 > > >
+operator/(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double / Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_Divide<double, int > > >
+operator/(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_Divide<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double / TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<double, P_numtype2 > > >
+operator/(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double / Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<long double, P_numtype2 > > >
+operator/(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double / _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<long double, _bz_typename P_expr2::T_numtype > > >
+operator/(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double / VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<long double, P_numtype2 > > >
+operator/(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double / Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_Divide<long double, int > > >
+operator/(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_Divide<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double / TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<long double, P_numtype2 > > >
+operator/(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> / Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_Divide<complex<T1> , P_numtype2 > > >
+operator/(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_Divide<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> / _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_Divide<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator/(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Divide<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> / VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Divide<complex<T1> , P_numtype2 > > >
+operator/(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Divide<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> / Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_Divide<complex<T1> , int > > >
+operator/(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_Divide<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> / TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Divide<complex<T1> , P_numtype2 > > >
+operator/(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Divide<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Modulus Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> % Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Mod<P_numtype1, P_numtype2 > > >
+operator%(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> % _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Mod<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator%(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Mod<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> % VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Mod<P_numtype1, P_numtype2 > > >
+operator%(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> % Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_Mod<P_numtype1, int > > >
+operator%(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_Mod<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> % TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Mod<P_numtype1, P_numtype2 > > >
+operator%(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> % int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Mod<P_numtype1, int > > >
+operator%(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Mod<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> % Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Mod<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator%(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Mod<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> % _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Mod<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator%(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Mod<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> % VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Mod<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator%(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Mod<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> % Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_Mod<_bz_typename P_expr1::T_numtype, int > > >
+operator%(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_Mod<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> % TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Mod<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator%(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Mod<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> % int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Mod<_bz_typename P_expr1::T_numtype, int > > >
+operator%(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Mod<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> % Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Mod<P_numtype1, P_numtype2 > > >
+operator%(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> % _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Mod<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator%(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Mod<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> % VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Mod<P_numtype1, P_numtype2 > > >
+operator%(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> % Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_Mod<P_numtype1, int > > >
+operator%(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_Mod<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> % TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Mod<P_numtype1, P_numtype2 > > >
+operator%(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> % int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Mod<P_numtype1, int > > >
+operator%(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Mod<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Range % Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_Mod<int, P_numtype2 > > >
+operator%(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Mod<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range % _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Mod<int, _bz_typename P_expr2::T_numtype > > >
+operator%(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Mod<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range % VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Mod<int, P_numtype2 > > >
+operator%(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Mod<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range % Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_Mod<int, int > > >
+operator%(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_Mod<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range % TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Mod<int, P_numtype2 > > >
+operator%(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Mod<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> % Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Mod<P_numtype1, P_numtype2 > > >
+operator%(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> % _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Mod<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator%(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Mod<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> % VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Mod<P_numtype1, P_numtype2 > > >
+operator%(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> % Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_Mod<P_numtype1, int > > >
+operator%(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_Mod<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> % TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Mod<P_numtype1, P_numtype2 > > >
+operator%(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Mod<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> % int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Mod<P_numtype1, int > > >
+operator%(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Mod<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// int % Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Mod<int, P_numtype2 > > >
+operator%(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Mod<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int % _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Mod<int, _bz_typename P_expr2::T_numtype > > >
+operator%(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Mod<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int % VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Mod<int, P_numtype2 > > >
+operator%(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Mod<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int % TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Mod<int, P_numtype2 > > >
+operator%(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Mod<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+/****************************************************************************
+ * Bitwise XOR Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> ^ Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseXOR<P_numtype1, P_numtype2 > > >
+operator^(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> ^ _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseXOR<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator^(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseXOR<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> ^ VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseXOR<P_numtype1, P_numtype2 > > >
+operator^(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> ^ Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_BitwiseXOR<P_numtype1, int > > >
+operator^(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_BitwiseXOR<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> ^ TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseXOR<P_numtype1, P_numtype2 > > >
+operator^(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> ^ int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseXOR<P_numtype1, int > > >
+operator^(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseXOR<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> ^ Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator^(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> ^ _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator^(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> ^ VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator^(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> ^ Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, int > > >
+operator^(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> ^ TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator^(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> ^ int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, int > > >
+operator^(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseXOR<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> ^ Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseXOR<P_numtype1, P_numtype2 > > >
+operator^(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> ^ _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseXOR<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator^(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseXOR<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> ^ VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseXOR<P_numtype1, P_numtype2 > > >
+operator^(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> ^ Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_BitwiseXOR<P_numtype1, int > > >
+operator^(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_BitwiseXOR<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> ^ TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseXOR<P_numtype1, P_numtype2 > > >
+operator^(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> ^ int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseXOR<P_numtype1, int > > >
+operator^(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseXOR<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Range ^ Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseXOR<int, P_numtype2 > > >
+operator^(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range ^ _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseXOR<int, _bz_typename P_expr2::T_numtype > > >
+operator^(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseXOR<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range ^ VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseXOR<int, P_numtype2 > > >
+operator^(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range ^ Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_BitwiseXOR<int, int > > >
+operator^(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_BitwiseXOR<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range ^ TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseXOR<int, P_numtype2 > > >
+operator^(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseXOR<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> ^ Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseXOR<P_numtype1, P_numtype2 > > >
+operator^(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> ^ _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseXOR<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator^(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseXOR<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> ^ VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseXOR<P_numtype1, P_numtype2 > > >
+operator^(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> ^ Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_BitwiseXOR<P_numtype1, int > > >
+operator^(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_BitwiseXOR<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> ^ TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseXOR<P_numtype1, P_numtype2 > > >
+operator^(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseXOR<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> ^ int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseXOR<P_numtype1, int > > >
+operator^(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseXOR<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// int ^ Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseXOR<int, P_numtype2 > > >
+operator^(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int ^ _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseXOR<int, _bz_typename P_expr2::T_numtype > > >
+operator^(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseXOR<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int ^ VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseXOR<int, P_numtype2 > > >
+operator^(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseXOR<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int ^ TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseXOR<int, P_numtype2 > > >
+operator^(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseXOR<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+/****************************************************************************
+ * Bitwise And Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> & Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseAnd<P_numtype1, P_numtype2 > > >
+operator&(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> & _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseAnd<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator&(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> & VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseAnd<P_numtype1, P_numtype2 > > >
+operator&(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> & Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_BitwiseAnd<P_numtype1, int > > >
+operator&(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_BitwiseAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> & TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseAnd<P_numtype1, P_numtype2 > > >
+operator&(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> & int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseAnd<P_numtype1, int > > >
+operator&(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> & Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator&(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> & _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator&(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> & VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator&(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> & Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, int > > >
+operator&(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> & TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator&(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> & int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, int > > >
+operator&(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseAnd<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> & Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseAnd<P_numtype1, P_numtype2 > > >
+operator&(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> & _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseAnd<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator&(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> & VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseAnd<P_numtype1, P_numtype2 > > >
+operator&(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> & Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_BitwiseAnd<P_numtype1, int > > >
+operator&(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_BitwiseAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> & TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseAnd<P_numtype1, P_numtype2 > > >
+operator&(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> & int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseAnd<P_numtype1, int > > >
+operator&(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Range & Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseAnd<int, P_numtype2 > > >
+operator&(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range & _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseAnd<int, _bz_typename P_expr2::T_numtype > > >
+operator&(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseAnd<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range & VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseAnd<int, P_numtype2 > > >
+operator&(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range & Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_BitwiseAnd<int, int > > >
+operator&(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_BitwiseAnd<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range & TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseAnd<int, P_numtype2 > > >
+operator&(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> & Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseAnd<P_numtype1, P_numtype2 > > >
+operator&(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> & _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseAnd<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator&(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> & VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseAnd<P_numtype1, P_numtype2 > > >
+operator&(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> & Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_BitwiseAnd<P_numtype1, int > > >
+operator&(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_BitwiseAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> & TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseAnd<P_numtype1, P_numtype2 > > >
+operator&(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> & int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseAnd<P_numtype1, int > > >
+operator&(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// int & Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseAnd<int, P_numtype2 > > >
+operator&(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int & _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseAnd<int, _bz_typename P_expr2::T_numtype > > >
+operator&(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseAnd<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int & VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseAnd<int, P_numtype2 > > >
+operator&(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int & TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseAnd<int, P_numtype2 > > >
+operator&(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+/****************************************************************************
+ * Bitwise Or Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> | Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseOr<P_numtype1, P_numtype2 > > >
+operator|(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> | _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseOr<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator|(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseOr<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> | VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseOr<P_numtype1, P_numtype2 > > >
+operator|(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> | Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_BitwiseOr<P_numtype1, int > > >
+operator|(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_BitwiseOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> | TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseOr<P_numtype1, P_numtype2 > > >
+operator|(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> | int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseOr<P_numtype1, int > > >
+operator|(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> | Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator|(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> | _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator|(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> | VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator|(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> | Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, int > > >
+operator|(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> | TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator|(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> | int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, int > > >
+operator|(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseOr<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> | Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseOr<P_numtype1, P_numtype2 > > >
+operator|(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> | _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseOr<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator|(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseOr<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> | VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseOr<P_numtype1, P_numtype2 > > >
+operator|(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> | Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_BitwiseOr<P_numtype1, int > > >
+operator|(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_BitwiseOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> | TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseOr<P_numtype1, P_numtype2 > > >
+operator|(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> | int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseOr<P_numtype1, int > > >
+operator|(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Range | Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseOr<int, P_numtype2 > > >
+operator|(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range | _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseOr<int, _bz_typename P_expr2::T_numtype > > >
+operator|(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseOr<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range | VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseOr<int, P_numtype2 > > >
+operator|(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range | Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_BitwiseOr<int, int > > >
+operator|(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_BitwiseOr<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range | TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseOr<int, P_numtype2 > > >
+operator|(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> | Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseOr<P_numtype1, P_numtype2 > > >
+operator|(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> | _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseOr<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator|(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseOr<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> | VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseOr<P_numtype1, P_numtype2 > > >
+operator|(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> | Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_BitwiseOr<P_numtype1, int > > >
+operator|(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_BitwiseOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> | TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseOr<P_numtype1, P_numtype2 > > >
+operator|(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> | int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_BitwiseOr<P_numtype1, int > > >
+operator|(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_BitwiseOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// int | Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_BitwiseOr<int, P_numtype2 > > >
+operator|(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_BitwiseOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int | _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_BitwiseOr<int, _bz_typename P_expr2::T_numtype > > >
+operator|(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_BitwiseOr<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int | VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_BitwiseOr<int, P_numtype2 > > >
+operator|(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_BitwiseOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int | TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_BitwiseOr<int, P_numtype2 > > >
+operator|(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_BitwiseOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+/****************************************************************************
+ * Shift right Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> >> Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftRight<P_numtype1, P_numtype2 > > >
+operator>>(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> >> _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftRight<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>>(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftRight<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> >> VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftRight<P_numtype1, P_numtype2 > > >
+operator>>(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> >> Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_ShiftRight<P_numtype1, int > > >
+operator>>(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_ShiftRight<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> >> TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftRight<P_numtype1, P_numtype2 > > >
+operator>>(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> >> int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_ShiftRight<P_numtype1, int > > >
+operator>>(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_ShiftRight<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> >> Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator>>(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> >> _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator>>(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> >> VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator>>(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> >> Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, int > > >
+operator>>(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> >> TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator>>(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> >> int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, int > > >
+operator>>(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_ShiftRight<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> >> Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftRight<P_numtype1, P_numtype2 > > >
+operator>>(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> >> _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftRight<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>>(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftRight<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> >> VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftRight<P_numtype1, P_numtype2 > > >
+operator>>(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> >> Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_ShiftRight<P_numtype1, int > > >
+operator>>(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_ShiftRight<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> >> TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftRight<P_numtype1, P_numtype2 > > >
+operator>>(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> >> int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_ShiftRight<P_numtype1, int > > >
+operator>>(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_ShiftRight<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Range >> Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftRight<int, P_numtype2 > > >
+operator>>(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftRight<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range >> _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftRight<int, _bz_typename P_expr2::T_numtype > > >
+operator>>(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftRight<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range >> VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftRight<int, P_numtype2 > > >
+operator>>(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftRight<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range >> Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_ShiftRight<int, int > > >
+operator>>(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_ShiftRight<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range >> TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftRight<int, P_numtype2 > > >
+operator>>(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftRight<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> >> Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftRight<P_numtype1, P_numtype2 > > >
+operator>>(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> >> _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftRight<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>>(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftRight<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> >> VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftRight<P_numtype1, P_numtype2 > > >
+operator>>(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> >> Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_ShiftRight<P_numtype1, int > > >
+operator>>(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_ShiftRight<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> >> TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftRight<P_numtype1, P_numtype2 > > >
+operator>>(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftRight<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> >> int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_ShiftRight<P_numtype1, int > > >
+operator>>(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_ShiftRight<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// int >> Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftRight<int, P_numtype2 > > >
+operator>>(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftRight<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int >> _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftRight<int, _bz_typename P_expr2::T_numtype > > >
+operator>>(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftRight<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int >> VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftRight<int, P_numtype2 > > >
+operator>>(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftRight<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int >> TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftRight<int, P_numtype2 > > >
+operator>>(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftRight<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+/****************************************************************************
+ * Shift left Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> << Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftLeft<P_numtype1, P_numtype2 > > >
+operator<<(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> << _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftLeft<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<<(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftLeft<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> << VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftLeft<P_numtype1, P_numtype2 > > >
+operator<<(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> << Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_ShiftLeft<P_numtype1, int > > >
+operator<<(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_ShiftLeft<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> << TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftLeft<P_numtype1, P_numtype2 > > >
+operator<<(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> << int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_ShiftLeft<P_numtype1, int > > >
+operator<<(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_ShiftLeft<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> << Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator<<(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> << _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator<<(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> << VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator<<(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> << Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, int > > >
+operator<<(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> << TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator<<(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> << int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, int > > >
+operator<<(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_ShiftLeft<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> << Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftLeft<P_numtype1, P_numtype2 > > >
+operator<<(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> << _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftLeft<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<<(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftLeft<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> << VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftLeft<P_numtype1, P_numtype2 > > >
+operator<<(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> << Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_ShiftLeft<P_numtype1, int > > >
+operator<<(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_ShiftLeft<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> << TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftLeft<P_numtype1, P_numtype2 > > >
+operator<<(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> << int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_ShiftLeft<P_numtype1, int > > >
+operator<<(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_ShiftLeft<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Range << Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftLeft<int, P_numtype2 > > >
+operator<<(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftLeft<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range << _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftLeft<int, _bz_typename P_expr2::T_numtype > > >
+operator<<(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftLeft<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range << VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftLeft<int, P_numtype2 > > >
+operator<<(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftLeft<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range << Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_ShiftLeft<int, int > > >
+operator<<(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_ShiftLeft<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range << TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftLeft<int, P_numtype2 > > >
+operator<<(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftLeft<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> << Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftLeft<P_numtype1, P_numtype2 > > >
+operator<<(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> << _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftLeft<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<<(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftLeft<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> << VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftLeft<P_numtype1, P_numtype2 > > >
+operator<<(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> << Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_ShiftLeft<P_numtype1, int > > >
+operator<<(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_ShiftLeft<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> << TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftLeft<P_numtype1, P_numtype2 > > >
+operator<<(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftLeft<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> << int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_ShiftLeft<P_numtype1, int > > >
+operator<<(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_ShiftLeft<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// int << Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_ShiftLeft<int, P_numtype2 > > >
+operator<<(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_ShiftLeft<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int << _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_ShiftLeft<int, _bz_typename P_expr2::T_numtype > > >
+operator<<(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_ShiftLeft<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int << VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_ShiftLeft<int, P_numtype2 > > >
+operator<<(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_ShiftLeft<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int << TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_ShiftLeft<int, P_numtype2 > > >
+operator<<(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_ShiftLeft<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+/****************************************************************************
+ * Greater-than Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> > Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<P_numtype1, P_numtype2 > > >
+operator>(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> > _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> > VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<P_numtype1, P_numtype2 > > >
+operator>(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> > Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_Greater<P_numtype1, int > > >
+operator>(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_Greater<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> > TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<P_numtype1, P_numtype2 > > >
+operator>(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> > int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Greater<P_numtype1, int > > >
+operator>(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Greater<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> > float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Greater<P_numtype1, float > > >
+operator>(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Greater<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> > double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Greater<P_numtype1, double > > >
+operator>(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Greater<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> > long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Greater<P_numtype1, long double > > >
+operator>(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Greater<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> > complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Greater<P_numtype1, complex<T2>  > > >
+operator>(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Greater<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> > Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> > _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> > VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> > Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, int > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> > TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> > int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, int > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> > float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, float > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> > double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, double > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> > long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, long double > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> > complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Greater<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator>(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Greater<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> > Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<P_numtype1, P_numtype2 > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> > _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> > VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<P_numtype1, P_numtype2 > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> > Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_Greater<P_numtype1, int > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_Greater<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> > TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<P_numtype1, P_numtype2 > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> > int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Greater<P_numtype1, int > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Greater<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> > float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Greater<P_numtype1, float > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Greater<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> > double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Greater<P_numtype1, double > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Greater<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> > long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Greater<P_numtype1, long double > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Greater<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> > complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Greater<P_numtype1, complex<T2>  > > >
+operator>(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Greater<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range > Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<int, P_numtype2 > > >
+operator>(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range > _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<int, _bz_typename P_expr2::T_numtype > > >
+operator>(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range > VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<int, P_numtype2 > > >
+operator>(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range > Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_Greater<int, int > > >
+operator>(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_Greater<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range > TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<int, P_numtype2 > > >
+operator>(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range > float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_Greater<int, float > > >
+operator>(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_Greater<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range > double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_Greater<int, double > > >
+operator>(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_Greater<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range > long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_Greater<int, long double > > >
+operator>(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Greater<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range > complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Greater<int, complex<T2>  > > >
+operator>(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Greater<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> > Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<P_numtype1, P_numtype2 > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> > _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> > VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<P_numtype1, P_numtype2 > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> > Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_Greater<P_numtype1, int > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_Greater<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> > TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<P_numtype1, P_numtype2 > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> > int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Greater<P_numtype1, int > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Greater<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> > float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Greater<P_numtype1, float > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Greater<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> > double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Greater<P_numtype1, double > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Greater<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> > long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Greater<P_numtype1, long double > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Greater<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> > complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Greater<P_numtype1, complex<T2>  > > >
+operator>(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Greater<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int > Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<int, P_numtype2 > > >
+operator>(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int > _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<int, _bz_typename P_expr2::T_numtype > > >
+operator>(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int > VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<int, P_numtype2 > > >
+operator>(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int > TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<int, P_numtype2 > > >
+operator>(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float > Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<float, P_numtype2 > > >
+operator>(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float > _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<float, _bz_typename P_expr2::T_numtype > > >
+operator>(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float > VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<float, P_numtype2 > > >
+operator>(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float > Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_Greater<float, int > > >
+operator>(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_Greater<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float > TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<float, P_numtype2 > > >
+operator>(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double > Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<double, P_numtype2 > > >
+operator>(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double > _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<double, _bz_typename P_expr2::T_numtype > > >
+operator>(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double > VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<double, P_numtype2 > > >
+operator>(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double > Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_Greater<double, int > > >
+operator>(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_Greater<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double > TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<double, P_numtype2 > > >
+operator>(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double > Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<long double, P_numtype2 > > >
+operator>(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double > _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<long double, _bz_typename P_expr2::T_numtype > > >
+operator>(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double > VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<long double, P_numtype2 > > >
+operator>(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double > Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_Greater<long double, int > > >
+operator>(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_Greater<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double > TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<long double, P_numtype2 > > >
+operator>(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> > Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_Greater<complex<T1> , P_numtype2 > > >
+operator>(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_Greater<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> > _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_Greater<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator>(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Greater<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> > VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Greater<complex<T1> , P_numtype2 > > >
+operator>(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Greater<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> > Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_Greater<complex<T1> , int > > >
+operator>(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_Greater<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> > TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Greater<complex<T1> , P_numtype2 > > >
+operator>(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Greater<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Less-than Operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> < Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<P_numtype1, P_numtype2 > > >
+operator<(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> < _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> < VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<P_numtype1, P_numtype2 > > >
+operator<(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> < Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_Less<P_numtype1, int > > >
+operator<(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_Less<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> < TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<P_numtype1, P_numtype2 > > >
+operator<(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> < int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Less<P_numtype1, int > > >
+operator<(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Less<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> < float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Less<P_numtype1, float > > >
+operator<(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Less<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> < double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Less<P_numtype1, double > > >
+operator<(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Less<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> < long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Less<P_numtype1, long double > > >
+operator<(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Less<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> < complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Less<P_numtype1, complex<T2>  > > >
+operator<(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Less<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> < Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> < _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> < VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> < Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_Less<_bz_typename P_expr1::T_numtype, int > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> < TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> < int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Less<_bz_typename P_expr1::T_numtype, int > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> < float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Less<_bz_typename P_expr1::T_numtype, float > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> < double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Less<_bz_typename P_expr1::T_numtype, double > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> < long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Less<_bz_typename P_expr1::T_numtype, long double > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Less<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> < complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Less<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator<(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Less<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> < Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<P_numtype1, P_numtype2 > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> < _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> < VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<P_numtype1, P_numtype2 > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> < Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_Less<P_numtype1, int > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_Less<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> < TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<P_numtype1, P_numtype2 > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> < int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Less<P_numtype1, int > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Less<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> < float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Less<P_numtype1, float > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Less<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> < double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Less<P_numtype1, double > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Less<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> < long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Less<P_numtype1, long double > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Less<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> < complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Less<P_numtype1, complex<T2>  > > >
+operator<(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Less<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range < Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<int, P_numtype2 > > >
+operator<(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range < _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<int, _bz_typename P_expr2::T_numtype > > >
+operator<(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range < VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<int, P_numtype2 > > >
+operator<(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range < Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_Less<int, int > > >
+operator<(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_Less<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range < TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<int, P_numtype2 > > >
+operator<(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range < float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_Less<int, float > > >
+operator<(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_Less<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range < double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_Less<int, double > > >
+operator<(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_Less<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range < long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_Less<int, long double > > >
+operator<(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Less<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range < complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Less<int, complex<T2>  > > >
+operator<(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Less<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> < Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<P_numtype1, P_numtype2 > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> < _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> < VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<P_numtype1, P_numtype2 > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> < Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_Less<P_numtype1, int > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_Less<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> < TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<P_numtype1, P_numtype2 > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> < int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Less<P_numtype1, int > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Less<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> < float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Less<P_numtype1, float > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Less<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> < double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Less<P_numtype1, double > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Less<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> < long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Less<P_numtype1, long double > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Less<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> < complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Less<P_numtype1, complex<T2>  > > >
+operator<(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Less<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int < Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<int, P_numtype2 > > >
+operator<(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int < _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<int, _bz_typename P_expr2::T_numtype > > >
+operator<(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int < VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<int, P_numtype2 > > >
+operator<(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int < TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<int, P_numtype2 > > >
+operator<(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float < Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<float, P_numtype2 > > >
+operator<(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float < _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<float, _bz_typename P_expr2::T_numtype > > >
+operator<(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float < VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<float, P_numtype2 > > >
+operator<(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float < Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_Less<float, int > > >
+operator<(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_Less<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float < TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<float, P_numtype2 > > >
+operator<(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double < Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<double, P_numtype2 > > >
+operator<(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double < _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<double, _bz_typename P_expr2::T_numtype > > >
+operator<(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double < VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<double, P_numtype2 > > >
+operator<(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double < Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_Less<double, int > > >
+operator<(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_Less<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double < TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<double, P_numtype2 > > >
+operator<(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double < Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<long double, P_numtype2 > > >
+operator<(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double < _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<long double, _bz_typename P_expr2::T_numtype > > >
+operator<(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double < VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<long double, P_numtype2 > > >
+operator<(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double < Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_Less<long double, int > > >
+operator<(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_Less<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double < TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<long double, P_numtype2 > > >
+operator<(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> < Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_Less<complex<T1> , P_numtype2 > > >
+operator<(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_Less<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> < _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_Less<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator<(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Less<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> < VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Less<complex<T1> , P_numtype2 > > >
+operator<(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Less<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> < Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_Less<complex<T1> , int > > >
+operator<(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_Less<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> < TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Less<complex<T1> , P_numtype2 > > >
+operator<(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Less<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Greater or equal (>=) operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> >= Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2 > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> >= _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> >= VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2 > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> >= Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_GreaterOrEqual<P_numtype1, int > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_GreaterOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> >= TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2 > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> >= int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_GreaterOrEqual<P_numtype1, int > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_GreaterOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> >= float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_GreaterOrEqual<P_numtype1, float > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_GreaterOrEqual<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> >= double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_GreaterOrEqual<P_numtype1, double > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_GreaterOrEqual<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> >= long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_GreaterOrEqual<P_numtype1, long double > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_GreaterOrEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> >= complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_GreaterOrEqual<P_numtype1, complex<T2>  > > >
+operator>=(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_GreaterOrEqual<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> >= Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> >= _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> >= VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> >= Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> >= TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> >= int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> >= float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, float > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> >= double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, double > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> >= long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, long double > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> >= complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator>=(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_GreaterOrEqual<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> >= Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2 > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> >= _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> >= VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2 > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> >= Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_GreaterOrEqual<P_numtype1, int > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_GreaterOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> >= TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2 > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> >= int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_GreaterOrEqual<P_numtype1, int > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_GreaterOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> >= float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_GreaterOrEqual<P_numtype1, float > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_GreaterOrEqual<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> >= double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_GreaterOrEqual<P_numtype1, double > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_GreaterOrEqual<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> >= long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_GreaterOrEqual<P_numtype1, long double > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_GreaterOrEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> >= complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_GreaterOrEqual<P_numtype1, complex<T2>  > > >
+operator>=(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_GreaterOrEqual<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range >= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<int, P_numtype2 > > >
+operator>=(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range >= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator>=(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range >= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<int, P_numtype2 > > >
+operator>=(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range >= Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_GreaterOrEqual<int, int > > >
+operator>=(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_GreaterOrEqual<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range >= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<int, P_numtype2 > > >
+operator>=(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range >= float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_GreaterOrEqual<int, float > > >
+operator>=(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_GreaterOrEqual<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range >= double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_GreaterOrEqual<int, double > > >
+operator>=(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_GreaterOrEqual<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range >= long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_GreaterOrEqual<int, long double > > >
+operator>=(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_GreaterOrEqual<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range >= complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_GreaterOrEqual<int, complex<T2>  > > >
+operator>=(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_GreaterOrEqual<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> >= Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2 > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> >= _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> >= VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2 > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> >= Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_GreaterOrEqual<P_numtype1, int > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_GreaterOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> >= TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2 > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> >= int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_GreaterOrEqual<P_numtype1, int > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_GreaterOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> >= float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_GreaterOrEqual<P_numtype1, float > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_GreaterOrEqual<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> >= double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_GreaterOrEqual<P_numtype1, double > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_GreaterOrEqual<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> >= long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_GreaterOrEqual<P_numtype1, long double > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_GreaterOrEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> >= complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_GreaterOrEqual<P_numtype1, complex<T2>  > > >
+operator>=(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_GreaterOrEqual<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int >= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<int, P_numtype2 > > >
+operator>=(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int >= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator>=(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int >= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<int, P_numtype2 > > >
+operator>=(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int >= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<int, P_numtype2 > > >
+operator>=(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float >= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<float, P_numtype2 > > >
+operator>=(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float >= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<float, _bz_typename P_expr2::T_numtype > > >
+operator>=(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float >= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<float, P_numtype2 > > >
+operator>=(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float >= Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_GreaterOrEqual<float, int > > >
+operator>=(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_GreaterOrEqual<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float >= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<float, P_numtype2 > > >
+operator>=(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double >= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<double, P_numtype2 > > >
+operator>=(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double >= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<double, _bz_typename P_expr2::T_numtype > > >
+operator>=(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double >= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<double, P_numtype2 > > >
+operator>=(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double >= Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_GreaterOrEqual<double, int > > >
+operator>=(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_GreaterOrEqual<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double >= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<double, P_numtype2 > > >
+operator>=(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double >= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<long double, P_numtype2 > > >
+operator>=(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double >= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<long double, _bz_typename P_expr2::T_numtype > > >
+operator>=(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double >= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<long double, P_numtype2 > > >
+operator>=(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double >= Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_GreaterOrEqual<long double, int > > >
+operator>=(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_GreaterOrEqual<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double >= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<long double, P_numtype2 > > >
+operator>=(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> >= Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<complex<T1> , P_numtype2 > > >
+operator>=(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> >= _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_GreaterOrEqual<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator>=(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_GreaterOrEqual<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> >= VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_GreaterOrEqual<complex<T1> , P_numtype2 > > >
+operator>=(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_GreaterOrEqual<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> >= Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_GreaterOrEqual<complex<T1> , int > > >
+operator>=(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_GreaterOrEqual<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> >= TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_GreaterOrEqual<complex<T1> , P_numtype2 > > >
+operator>=(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_GreaterOrEqual<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Less or equal (<=) operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> <= Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<P_numtype1, P_numtype2 > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> <= _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> <= VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<P_numtype1, P_numtype2 > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> <= Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_LessOrEqual<P_numtype1, int > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_LessOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> <= TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<P_numtype1, P_numtype2 > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> <= int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LessOrEqual<P_numtype1, int > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LessOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> <= float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_LessOrEqual<P_numtype1, float > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_LessOrEqual<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> <= double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_LessOrEqual<P_numtype1, double > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_LessOrEqual<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> <= long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_LessOrEqual<P_numtype1, long double > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_LessOrEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> <= complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_LessOrEqual<P_numtype1, complex<T2>  > > >
+operator<=(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_LessOrEqual<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> <= Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> <= _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> <= VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> <= Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> <= TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> <= int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> <= float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, float > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> <= double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, double > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> <= long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, long double > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> <= complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator<=(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_LessOrEqual<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> <= Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<P_numtype1, P_numtype2 > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> <= _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> <= VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<P_numtype1, P_numtype2 > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> <= Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_LessOrEqual<P_numtype1, int > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_LessOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> <= TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<P_numtype1, P_numtype2 > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> <= int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LessOrEqual<P_numtype1, int > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LessOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> <= float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_LessOrEqual<P_numtype1, float > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_LessOrEqual<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> <= double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_LessOrEqual<P_numtype1, double > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_LessOrEqual<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> <= long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_LessOrEqual<P_numtype1, long double > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_LessOrEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> <= complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_LessOrEqual<P_numtype1, complex<T2>  > > >
+operator<=(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_LessOrEqual<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range <= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<int, P_numtype2 > > >
+operator<=(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range <= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator<=(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range <= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<int, P_numtype2 > > >
+operator<=(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range <= Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_LessOrEqual<int, int > > >
+operator<=(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_LessOrEqual<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range <= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<int, P_numtype2 > > >
+operator<=(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range <= float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_LessOrEqual<int, float > > >
+operator<=(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_LessOrEqual<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range <= double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_LessOrEqual<int, double > > >
+operator<=(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_LessOrEqual<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range <= long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_LessOrEqual<int, long double > > >
+operator<=(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_LessOrEqual<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range <= complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_LessOrEqual<int, complex<T2>  > > >
+operator<=(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_LessOrEqual<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> <= Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<P_numtype1, P_numtype2 > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> <= _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> <= VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<P_numtype1, P_numtype2 > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> <= Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_LessOrEqual<P_numtype1, int > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_LessOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> <= TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<P_numtype1, P_numtype2 > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> <= int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LessOrEqual<P_numtype1, int > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LessOrEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> <= float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_LessOrEqual<P_numtype1, float > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_LessOrEqual<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> <= double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_LessOrEqual<P_numtype1, double > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_LessOrEqual<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> <= long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_LessOrEqual<P_numtype1, long double > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_LessOrEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> <= complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_LessOrEqual<P_numtype1, complex<T2>  > > >
+operator<=(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_LessOrEqual<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int <= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<int, P_numtype2 > > >
+operator<=(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int <= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator<=(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int <= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<int, P_numtype2 > > >
+operator<=(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int <= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<int, P_numtype2 > > >
+operator<=(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float <= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<float, P_numtype2 > > >
+operator<=(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float <= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<float, _bz_typename P_expr2::T_numtype > > >
+operator<=(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float <= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<float, P_numtype2 > > >
+operator<=(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float <= Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_LessOrEqual<float, int > > >
+operator<=(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_LessOrEqual<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float <= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<float, P_numtype2 > > >
+operator<=(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double <= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<double, P_numtype2 > > >
+operator<=(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double <= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<double, _bz_typename P_expr2::T_numtype > > >
+operator<=(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double <= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<double, P_numtype2 > > >
+operator<=(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double <= Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_LessOrEqual<double, int > > >
+operator<=(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_LessOrEqual<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double <= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<double, P_numtype2 > > >
+operator<=(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double <= Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<long double, P_numtype2 > > >
+operator<=(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double <= _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<long double, _bz_typename P_expr2::T_numtype > > >
+operator<=(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double <= VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<long double, P_numtype2 > > >
+operator<=(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double <= Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_LessOrEqual<long double, int > > >
+operator<=(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_LessOrEqual<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double <= TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<long double, P_numtype2 > > >
+operator<=(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> <= Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_LessOrEqual<complex<T1> , P_numtype2 > > >
+operator<=(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_LessOrEqual<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> <= _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_LessOrEqual<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator<=(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LessOrEqual<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> <= VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LessOrEqual<complex<T1> , P_numtype2 > > >
+operator<=(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LessOrEqual<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> <= Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_LessOrEqual<complex<T1> , int > > >
+operator<=(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_LessOrEqual<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> <= TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LessOrEqual<complex<T1> , P_numtype2 > > >
+operator<=(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LessOrEqual<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Equality operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> == Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<P_numtype1, P_numtype2 > > >
+operator==(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> == _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator==(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> == VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<P_numtype1, P_numtype2 > > >
+operator==(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> == Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_Equal<P_numtype1, int > > >
+operator==(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_Equal<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> == TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<P_numtype1, P_numtype2 > > >
+operator==(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> == int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Equal<P_numtype1, int > > >
+operator==(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Equal<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> == float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Equal<P_numtype1, float > > >
+operator==(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Equal<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> == double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Equal<P_numtype1, double > > >
+operator==(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Equal<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> == long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Equal<P_numtype1, long double > > >
+operator==(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Equal<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> == complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Equal<P_numtype1, complex<T2>  > > >
+operator==(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Equal<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> == Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> == _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> == VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> == Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, int > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> == TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> == int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, int > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> == float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, float > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> == double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, double > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> == long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, long double > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> == complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Equal<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator==(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Equal<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> == Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<P_numtype1, P_numtype2 > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> == _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> == VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<P_numtype1, P_numtype2 > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> == Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_Equal<P_numtype1, int > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_Equal<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> == TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<P_numtype1, P_numtype2 > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> == int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Equal<P_numtype1, int > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Equal<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> == float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Equal<P_numtype1, float > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Equal<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> == double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Equal<P_numtype1, double > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Equal<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> == long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Equal<P_numtype1, long double > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Equal<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> == complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Equal<P_numtype1, complex<T2>  > > >
+operator==(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Equal<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range == Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<int, P_numtype2 > > >
+operator==(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range == _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<int, _bz_typename P_expr2::T_numtype > > >
+operator==(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range == VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<int, P_numtype2 > > >
+operator==(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range == Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_Equal<int, int > > >
+operator==(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_Equal<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range == TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<int, P_numtype2 > > >
+operator==(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range == float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_Equal<int, float > > >
+operator==(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_Equal<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range == double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_Equal<int, double > > >
+operator==(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_Equal<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range == long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_Equal<int, long double > > >
+operator==(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Equal<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range == complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Equal<int, complex<T2>  > > >
+operator==(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Equal<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> == Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<P_numtype1, P_numtype2 > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> == _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> == VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<P_numtype1, P_numtype2 > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> == Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_Equal<P_numtype1, int > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_Equal<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> == TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<P_numtype1, P_numtype2 > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> == int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_Equal<P_numtype1, int > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_Equal<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> == float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_Equal<P_numtype1, float > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_Equal<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> == double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_Equal<P_numtype1, double > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_Equal<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> == long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_Equal<P_numtype1, long double > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_Equal<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> == complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_Equal<P_numtype1, complex<T2>  > > >
+operator==(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_Equal<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int == Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<int, P_numtype2 > > >
+operator==(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int == _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<int, _bz_typename P_expr2::T_numtype > > >
+operator==(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int == VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<int, P_numtype2 > > >
+operator==(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int == TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<int, P_numtype2 > > >
+operator==(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float == Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<float, P_numtype2 > > >
+operator==(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float == _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<float, _bz_typename P_expr2::T_numtype > > >
+operator==(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float == VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<float, P_numtype2 > > >
+operator==(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float == Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_Equal<float, int > > >
+operator==(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_Equal<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float == TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<float, P_numtype2 > > >
+operator==(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double == Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<double, P_numtype2 > > >
+operator==(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double == _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<double, _bz_typename P_expr2::T_numtype > > >
+operator==(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double == VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<double, P_numtype2 > > >
+operator==(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double == Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_Equal<double, int > > >
+operator==(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_Equal<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double == TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<double, P_numtype2 > > >
+operator==(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double == Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<long double, P_numtype2 > > >
+operator==(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double == _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<long double, _bz_typename P_expr2::T_numtype > > >
+operator==(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double == VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<long double, P_numtype2 > > >
+operator==(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double == Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_Equal<long double, int > > >
+operator==(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_Equal<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double == TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<long double, P_numtype2 > > >
+operator==(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> == Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_Equal<complex<T1> , P_numtype2 > > >
+operator==(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_Equal<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> == _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_Equal<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator==(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_Equal<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> == VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_Equal<complex<T1> , P_numtype2 > > >
+operator==(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_Equal<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> == Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_Equal<complex<T1> , int > > >
+operator==(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_Equal<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> == TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_Equal<complex<T1> , P_numtype2 > > >
+operator==(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_Equal<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Not-equal operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> != Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<P_numtype1, P_numtype2 > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> != _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> != VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<P_numtype1, P_numtype2 > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> != Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_NotEqual<P_numtype1, int > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_NotEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> != TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<P_numtype1, P_numtype2 > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> != int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_NotEqual<P_numtype1, int > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_NotEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Vector<P_numtype1> != float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_NotEqual<P_numtype1, float > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_NotEqual<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Vector<P_numtype1> != double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_NotEqual<P_numtype1, double > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_NotEqual<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Vector<P_numtype1> != long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_NotEqual<P_numtype1, long double > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_NotEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Vector<P_numtype1> != complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_NotEqual<P_numtype1, complex<T2>  > > >
+operator!=(const Vector<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_NotEqual<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// _bz_VecExpr<P_expr1> != Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> != _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> != VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> != Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> != TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> != int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, int > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> != float
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, float > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> != double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, double > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> != long double
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, long double > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// _bz_VecExpr<P_expr1> != complex<T2>
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, complex<T2>  > > >
+operator!=(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_NotEqual<_bz_typename P_expr1::T_numtype, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// VectorPick<P_numtype1> != Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<P_numtype1, P_numtype2 > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> != _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> != VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<P_numtype1, P_numtype2 > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> != Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_NotEqual<P_numtype1, int > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_NotEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> != TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<P_numtype1, P_numtype2 > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> != int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_NotEqual<P_numtype1, int > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_NotEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> != float
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>,
+      _bz_NotEqual<P_numtype1, float > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_NotEqual<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// VectorPick<P_numtype1> != double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>,
+      _bz_NotEqual<P_numtype1, double > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_NotEqual<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// VectorPick<P_numtype1> != long double
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_NotEqual<P_numtype1, long double > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_NotEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// VectorPick<P_numtype1> != complex<T2>
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_NotEqual<P_numtype1, complex<T2>  > > >
+operator!=(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_NotEqual<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// Range != Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<int, P_numtype2 > > >
+operator!=(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range != _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator!=(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range != VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<int, P_numtype2 > > >
+operator!=(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range != Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_NotEqual<int, int > > >
+operator!=(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_NotEqual<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range != TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<int, P_numtype2 > > >
+operator!=(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range != float
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>,
+      _bz_NotEqual<int, float > > >
+operator!=(Range d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_NotEqual<int, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// Range != double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>,
+      _bz_NotEqual<int, double > > >
+operator!=(Range d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_NotEqual<int, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// Range != long double
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>,
+      _bz_NotEqual<int, long double > > >
+operator!=(Range d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_NotEqual<int, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// Range != complex<T2>
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_NotEqual<int, complex<T2>  > > >
+operator!=(Range d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_NotEqual<int, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// TinyVector<P_numtype1, N_length1> != Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<P_numtype1, P_numtype2 > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> != _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> != VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<P_numtype1, P_numtype2 > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> != Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_NotEqual<P_numtype1, int > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_NotEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> != TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<P_numtype1, P_numtype2 > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> != int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_NotEqual<P_numtype1, int > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_NotEqual<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> != float
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>,
+      _bz_NotEqual<P_numtype1, float > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_NotEqual<P_numtype1, float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> != double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>,
+      _bz_NotEqual<P_numtype1, double > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_NotEqual<P_numtype1, double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2)));
+}
+
+// TinyVector<P_numtype1, N_length1> != long double
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>,
+      _bz_NotEqual<P_numtype1, long double > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_NotEqual<P_numtype1, long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2)));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// TinyVector<P_numtype1, N_length1> != complex<T2>
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > ,
+      _bz_NotEqual<P_numtype1, complex<T2>  > > >
+operator!=(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_NotEqual<P_numtype1, complex<T2> > > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+
+// int != Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<int, P_numtype2 > > >
+operator!=(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int != _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<int, _bz_typename P_expr2::T_numtype > > >
+operator!=(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int != VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<int, P_numtype2 > > >
+operator!=(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int != TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<int, P_numtype2 > > >
+operator!=(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// float != Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<float, P_numtype2 > > >
+operator!=(float d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float != _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<float, _bz_typename P_expr2::T_numtype > > >
+operator!=(float d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<float, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float != VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<float, P_numtype2 > > >
+operator!=(float d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// float != Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range,
+      _bz_NotEqual<float, int > > >
+operator!=(float d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      Range, 
+      _bz_NotEqual<float, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2));
+}
+
+// float != TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<float, P_numtype2 > > >
+operator!=(float d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<float, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<float>(d1), 
+      d2.begin()));
+}
+
+// double != Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<double, P_numtype2 > > >
+operator!=(double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double != _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<double, _bz_typename P_expr2::T_numtype > > >
+operator!=(double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double != VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<double, P_numtype2 > > >
+operator!=(double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// double != Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range,
+      _bz_NotEqual<double, int > > >
+operator!=(double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      Range, 
+      _bz_NotEqual<double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2));
+}
+
+// double != TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<double, P_numtype2 > > >
+operator!=(double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<double>(d1), 
+      d2.begin()));
+}
+
+// long double != Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<long double, P_numtype2 > > >
+operator!=(long double d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double != _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<long double, _bz_typename P_expr2::T_numtype > > >
+operator!=(long double d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<long double, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double != VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<long double, P_numtype2 > > >
+operator!=(long double d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+
+// long double != Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range,
+      _bz_NotEqual<long double, int > > >
+operator!=(long double d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      Range, 
+      _bz_NotEqual<long double, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2));
+}
+
+// long double != TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<long double, P_numtype2 > > >
+operator!=(long double d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<long double, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<long double>(d1), 
+      d2.begin()));
+}
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> != Vector<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>,
+      _bz_NotEqual<complex<T1> , P_numtype2 > > >
+operator!=(complex<T1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorIterConst<P_numtype2>, 
+      _bz_NotEqual<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> != _bz_VecExpr<P_expr2>
+template<class T1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>,
+      _bz_NotEqual<complex<T1> , _bz_typename P_expr2::T_numtype > > >
+operator!=(complex<T1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      _bz_VecExpr<P_expr2>, 
+      _bz_NotEqual<complex<T1> , _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> != VectorPick<P_numtype2>
+template<class T1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>,
+      _bz_NotEqual<complex<T1> , P_numtype2 > > >
+operator!=(complex<T1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_NotEqual<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> != Range
+template<class T1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range,
+      _bz_NotEqual<complex<T1> , int > > >
+operator!=(complex<T1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      Range, 
+      _bz_NotEqual<complex<T1> , int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2));
+}
+#endif // BZ_HAVE_COMPLEX
+
+#ifdef BZ_HAVE_COMPLEX
+
+// complex<T1> != TinyVector<P_numtype2, N_length2>
+template<class T1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_NotEqual<complex<T1> , P_numtype2 > > >
+operator!=(complex<T1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<complex<T1> > , 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_NotEqual<complex<T1> , P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<complex<T1> > (d1), 
+      d2.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+/****************************************************************************
+ * Logical AND operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> && Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalAnd<P_numtype1, P_numtype2 > > >
+operator&&(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> && _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalAnd<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator&&(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> && VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalAnd<P_numtype1, P_numtype2 > > >
+operator&&(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> && Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_LogicalAnd<P_numtype1, int > > >
+operator&&(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_LogicalAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> && TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalAnd<P_numtype1, P_numtype2 > > >
+operator&&(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> && int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LogicalAnd<P_numtype1, int > > >
+operator&&(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LogicalAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> && Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator&&(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> && _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator&&(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> && VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator&&(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> && Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, int > > >
+operator&&(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> && TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator&&(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> && int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, int > > >
+operator&&(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LogicalAnd<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> && Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalAnd<P_numtype1, P_numtype2 > > >
+operator&&(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> && _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalAnd<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator&&(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> && VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalAnd<P_numtype1, P_numtype2 > > >
+operator&&(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> && Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_LogicalAnd<P_numtype1, int > > >
+operator&&(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_LogicalAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> && TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalAnd<P_numtype1, P_numtype2 > > >
+operator&&(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> && int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LogicalAnd<P_numtype1, int > > >
+operator&&(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LogicalAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Range && Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalAnd<int, P_numtype2 > > >
+operator&&(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range && _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalAnd<int, _bz_typename P_expr2::T_numtype > > >
+operator&&(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalAnd<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range && VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalAnd<int, P_numtype2 > > >
+operator&&(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range && Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_LogicalAnd<int, int > > >
+operator&&(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_LogicalAnd<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range && TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalAnd<int, P_numtype2 > > >
+operator&&(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> && Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalAnd<P_numtype1, P_numtype2 > > >
+operator&&(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> && _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalAnd<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator&&(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalAnd<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> && VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalAnd<P_numtype1, P_numtype2 > > >
+operator&&(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> && Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_LogicalAnd<P_numtype1, int > > >
+operator&&(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_LogicalAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> && TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalAnd<P_numtype1, P_numtype2 > > >
+operator&&(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalAnd<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> && int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LogicalAnd<P_numtype1, int > > >
+operator&&(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LogicalAnd<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// int && Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalAnd<int, P_numtype2 > > >
+operator&&(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int && _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalAnd<int, _bz_typename P_expr2::T_numtype > > >
+operator&&(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalAnd<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int && VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalAnd<int, P_numtype2 > > >
+operator&&(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int && TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalAnd<int, P_numtype2 > > >
+operator&&(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalAnd<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+/****************************************************************************
+ * Logical OR operators
+ ****************************************************************************/
+
+// Vector<P_numtype1> || Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalOr<P_numtype1, P_numtype2 > > >
+operator||(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> || _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalOr<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator||(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalOr<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> || VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalOr<P_numtype1, P_numtype2 > > >
+operator||(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> || Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range,
+      _bz_LogicalOr<P_numtype1, int > > >
+operator||(const Vector<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_LogicalOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// Vector<P_numtype1> || TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalOr<P_numtype1, P_numtype2 > > >
+operator||(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// Vector<P_numtype1> || int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LogicalOr<P_numtype1, int > > >
+operator||(const Vector<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LogicalOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// _bz_VecExpr<P_expr1> || Vector<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator||(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> || _bz_VecExpr<P_expr2>
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype > > >
+operator||(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> || VectorPick<P_numtype2>
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator||(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> || Range
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range,
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, int > > >
+operator||(_bz_VecExpr<P_expr1> d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// _bz_VecExpr<P_expr1> || TinyVector<P_numtype2, N_length2>
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, P_numtype2 > > >
+operator||(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// _bz_VecExpr<P_expr1> || int
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, int > > >
+operator||(_bz_VecExpr<P_expr1> d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LogicalOr<_bz_typename P_expr1::T_numtype, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// VectorPick<P_numtype1> || Vector<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalOr<P_numtype1, P_numtype2 > > >
+operator||(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> || _bz_VecExpr<P_expr2>
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalOr<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator||(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalOr<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> || VectorPick<P_numtype2>
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalOr<P_numtype1, P_numtype2 > > >
+operator||(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> || Range
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range,
+      _bz_LogicalOr<P_numtype1, int > > >
+operator||(const VectorPick<P_numtype1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_LogicalOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// VectorPick<P_numtype1> || TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalOr<P_numtype1, P_numtype2 > > >
+operator||(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// VectorPick<P_numtype1> || int
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LogicalOr<P_numtype1, int > > >
+operator||(const VectorPick<P_numtype1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LogicalOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// Range || Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalOr<int, P_numtype2 > > >
+operator||(Range d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range || _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalOr<int, _bz_typename P_expr2::T_numtype > > >
+operator||(Range d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalOr<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range || VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalOr<int, P_numtype2 > > >
+operator||(Range d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// Range || Range
+
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      Range,
+      _bz_LogicalOr<int, int > > >
+operator||(Range d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      Range, 
+      _bz_LogicalOr<int, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2));
+}
+
+// Range || TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalOr<int, P_numtype2 > > >
+operator||(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> || Vector<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalOr<P_numtype1, P_numtype2 > > >
+operator||(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> || _bz_VecExpr<P_expr2>
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalOr<P_numtype1, _bz_typename P_expr2::T_numtype > > >
+operator||(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalOr<P_numtype1, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> || VectorPick<P_numtype2>
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalOr<P_numtype1, P_numtype2 > > >
+operator||(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> || Range
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range,
+      _bz_LogicalOr<P_numtype1, int > > >
+operator||(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_LogicalOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2));
+}
+
+// TinyVector<P_numtype1, N_length1> || TinyVector<P_numtype2, N_length2>
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalOr<P_numtype1, P_numtype2 > > >
+operator||(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalOr<P_numtype1, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin()));
+}
+
+// TinyVector<P_numtype1, N_length1> || int
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>,
+      _bz_LogicalOr<P_numtype1, int > > >
+operator||(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2)
+{
+    typedef _bz_VecExprOp<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_LogicalOr<P_numtype1, int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2)));
+}
+
+// int || Vector<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>,
+      _bz_LogicalOr<int, P_numtype2 > > >
+operator||(int d1, 
+      const Vector<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_LogicalOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int || _bz_VecExpr<P_expr2>
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>,
+      _bz_LogicalOr<int, _bz_typename P_expr2::T_numtype > > >
+operator||(int d1, 
+      _bz_VecExpr<P_expr2> d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_LogicalOr<int, _bz_typename P_expr2::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2));
+}
+
+// int || VectorPick<P_numtype2>
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>,
+      _bz_LogicalOr<int, P_numtype2 > > >
+operator||(int d1, 
+      const VectorPick<P_numtype2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_LogicalOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+
+// int || TinyVector<P_numtype2, N_length2>
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>,
+      _bz_LogicalOr<int, P_numtype2 > > >
+operator||(int d1, 
+      const TinyVector<P_numtype2, N_length2>& d2)
+{
+    typedef _bz_VecExprOp<_bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_LogicalOr<int, P_numtype2> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(_bz_VecExprConstant<int>(d1), 
+      d2.begin()));
+}
+BZ_NAMESPACE_END
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/veccount.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/veccount.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/veccount.cc	(revision 1307)
@@ -0,0 +1,74 @@
+/*
+ * $Id: veccount.cc,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_VECCOUNT_CC
+#define BZ_VECCOUNT_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/veccount.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr>
+inline int _bz_vec_count(P_expr vector)
+{
+    int length = vector._bz_suggestLength();
+    int count = 0;
+
+    if (vector._bz_hasFastAccess())
+    {
+        for (int i=0; i < length; ++i)
+            if (vector._bz_fastAccess(i))
+                ++count;
+    }
+    else {
+        for (int i=0; i < length; ++i)
+            if (vector[i])
+                ++count;
+    }
+
+    return count;
+}
+
+template<class P_numtype>
+inline int count(const Vector<P_numtype>& x)
+{
+    return _bz_vec_count(x._bz_asVecExpr());
+}
+
+template<class P_expr>
+inline int count(_bz_VecExpr<P_expr> expr)
+{
+    return _bz_vec_count(expr);
+}
+
+template<class P_numtype>
+inline int count(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_count(x._bz_asVecExpr());
+}
+
+template<class P_numtype, int N_dimensions>
+inline int count(const TinyVector<P_numtype, N_dimensions>& x)
+{
+    return _bz_vec_count(x._bz_asVecExpr());
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECCOUNT_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecdelta.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecdelta.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecdelta.cc	(revision 1307)
@@ -0,0 +1,85 @@
+/*
+ * $Id: vecdelta.cc,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECDELTA_CC
+#define BZ_VECDELTA_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecdelta.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P>
+inline
+Vector<BZ_DIFFTYPE(_bz_typename P::T_numtype)> _bz_vec_delta(P expr)
+{
+    typedef _bz_typename P::T_numtype   T_numtype;
+    typedef BZ_DIFFTYPE(T_numtype)      T_difftype;
+
+    int length = expr._bz_suggestLength();
+    Vector<T_difftype> z(length);
+    T_numtype currentElement = 0;
+    T_numtype previousElement = 0;
+
+    if (expr._bz_hasFastAccess())
+    {
+        for (int i=0; i < length; ++i)
+        {
+            currentElement = expr._bz_fastAccess(i);
+            z[i] = currentElement - previousElement;
+            previousElement = currentElement;
+        }
+    }
+    else {
+        for (int i=1; i < length; ++i)
+        {
+            currentElement = expr(i);
+            z[i] = currentElement - previousElement;
+            previousElement = currentElement;
+        }
+    }
+
+    return z;
+}
+
+template<class P_numtype>
+Vector<BZ_DIFFTYPE(P_numtype)> delta(const Vector<P_numtype>& x)
+{
+    return _bz_vec_delta(x);
+}
+
+// delta(expr)
+template<class P_expr>
+Vector<BZ_DIFFTYPE(_bz_typename P_expr::T_numtype)> delta(_bz_VecExpr<P_expr> x)
+{
+    return _bz_vec_delta(x);
+}
+
+// delta(vecpick)
+template<class P_numtype>
+Vector<BZ_DIFFTYPE(P_numtype)> delta(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_delta(x);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECDELTA_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecdot.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecdot.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecdot.cc	(revision 1307)
@@ -0,0 +1,142 @@
+/*
+ * $Id: vecdot.cc,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECDOT_CC
+#define BZ_VECDOT_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecdot.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P1, class P2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(_bz_typename P1::T_numtype, _bz_typename P2::T_numtype))
+_bz_dot(P1 vector1, P2 vector2)
+{
+    BZPRECONDITION(vector1._bz_suggestLength() == vector2._bz_suggestLength());
+
+    typedef BZ_SUMTYPE(BZ_PROMOTE(_bz_typename P1::T_numtype,
+        _bz_typename P2::T_numtype))  T_sumtype;
+
+    T_sumtype sum = 0;
+    int length = vector1._bz_suggestLength();
+
+    if (vector1._bz_hasFastAccess() && vector2._bz_hasFastAccess())
+    {
+        for (int i=0; i < length; ++i)
+            sum += vector1._bz_fastAccess(i) 
+                * vector2._bz_fastAccess(i);
+    }
+    else {
+        for (int i=0; i < length; ++i)
+            sum += vector1[i] * vector2[i];
+    }
+
+    return sum;
+}
+
+
+// dot()
+template<class P_numtype1, class P_numtype2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(P_numtype1,P_numtype2))
+dot(const Vector<P_numtype1>& a, const Vector<P_numtype2>& b)
+{
+    return _bz_dot(a, b);
+}
+
+// dot(expr,expr)
+template<class P_expr1, class P_expr2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(_bz_typename P_expr1::T_numtype,
+    _bz_typename P_expr2::T_numtype))
+dot(_bz_VecExpr<P_expr1> expr1, _bz_VecExpr<P_expr2> expr2)
+{
+    return _bz_dot(expr1, expr2);
+}
+
+// dot(expr,vec)
+template<class P_expr1, class P_numtype2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(_bz_typename P_expr1::T_numtype, P_numtype2))
+dot(_bz_VecExpr<P_expr1> expr1, const Vector<P_numtype2>& vector2)
+{
+    return _bz_dot(vector2, expr1);
+}
+
+// dot(vec,expr)
+template<class P_numtype1, class P_expr2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(P_numtype1, _bz_typename P_expr2::T_numtype))
+dot(const Vector<P_numtype1>& vector1, _bz_VecExpr<P_expr2> expr2)
+{
+    return _bz_dot(vector1, expr2);
+}
+
+// dot(vec,vecpick)
+template<class P_numtype1, class P_numtype2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(P_numtype1, P_numtype2))
+dot(const Vector<P_numtype1>& vector1, const VectorPick<P_numtype2>& vector2)
+{
+    return _bz_dot(vector1, vector2);
+}
+
+// dot(vecpick,vec)
+template<class P_numtype1, class P_numtype2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(P_numtype1, P_numtype2))
+dot(const VectorPick<P_numtype1>& vector1, const Vector<P_numtype2>& vector2)
+{
+    return _bz_dot(vector1, vector2);
+}
+
+// dot(vecpick,vecpick)
+template<class P_numtype1, class P_numtype2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(P_numtype1, P_numtype2))
+dot(const VectorPick<P_numtype1>& vector1, const VectorPick<P_numtype2>& vector2)
+{
+    return _bz_dot(vector1, vector2);
+}
+
+// dot(expr, vecpick)
+template<class P_expr1, class P_numtype2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(_bz_typename P_expr1::T_numtype, P_numtype2))
+dot(_bz_VecExpr<P_expr1> expr1, const VectorPick<P_numtype2>& vector2)
+{
+    return _bz_dot(expr1, vector2);
+}
+
+// dot(vecpick, expr)
+template<class P_numtype1, class P_expr2>
+inline
+BZ_SUMTYPE(BZ_PROMOTE(P_numtype1, _bz_typename P_expr2::T_numtype))
+dot(const VectorPick<P_numtype1>& vector1, _bz_VecExpr<P_expr2> expr2)
+{
+    return _bz_dot(vector1, expr2);
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECDOT_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecexpr.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecexpr.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecexpr.h	(revision 1307)
@@ -0,0 +1,289 @@
+/***************************************************************************
+ * blitz/vecexpr.h      Vector<P_numtype> expression templates
+ *
+ * $Id: vecexpr.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.6  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.5  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.4  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+
+#ifndef BZ_VECEXPR_H
+#define BZ_VECEXPR_H
+
+#ifndef BZ_VECTOR_H
+ #include <blitz/vector.h>
+#endif
+
+#ifndef BZ_APPLICS_H
+ #include <blitz/applics.h>
+#endif
+
+#ifndef BZ_META_METAPROG_H
+ #include <blitz/meta/metaprog.h>
+#endif
+
+#ifndef BZ_VECEXPRWRAP_H
+ #include <blitz/vecexprwrap.h>           // _bz_VecExpr wrapper class
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr1, class P_expr2, class P_op>
+class _bz_VecExprOp {
+
+public:
+    typedef P_expr1 T_expr1;
+    typedef P_expr2 T_expr2;
+    typedef _bz_typename T_expr1::T_numtype T_numtype1;
+    typedef _bz_typename T_expr2::T_numtype T_numtype2;
+    typedef BZ_PROMOTE(T_numtype1, T_numtype2) T_numtype;
+    typedef P_op    T_op;
+
+#ifdef BZ_PASS_EXPR_BY_VALUE
+    _bz_VecExprOp(T_expr1 a, T_expr2 b)
+        : iter1_(a), iter2_(b)
+    { }
+#else
+    _bz_VecExprOp(const T_expr1& a, const T_expr2& b)
+        : iter1_(a), iter2_(b)
+    { }
+#endif
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    _bz_VecExprOp(const _bz_VecExprOp<P_expr1, P_expr2, P_op>& x)
+        : iter1_(x.iter1_), iter2_(x.iter2_)
+    { }
+#endif
+
+    T_numtype operator[](int i) const
+    { return T_op::apply(iter1_[i], iter2_[i]); }
+
+    T_numtype operator()(int i) const
+    { return T_op::apply(iter1_(i), iter2_(i)); }
+
+    int length(int recommendedLength) const
+    { 
+        BZPRECONDITION(iter2_.length(recommendedLength) == 
+            iter1_.length(recommendedLength));
+        return iter1_.length(recommendedLength); 
+    }
+
+    enum { 
+           _bz_staticLengthCount = 
+      BZ_ENUM_CAST(P_expr1::_bz_staticLengthCount) 
+         + BZ_ENUM_CAST(P_expr2::_bz_staticLengthCount),
+
+           _bz_dynamicLengthCount = 
+      BZ_ENUM_CAST(P_expr1::_bz_dynamicLengthCount) 
+        + BZ_ENUM_CAST(P_expr2::_bz_dynamicLengthCount),
+
+           _bz_staticLength = (BZ_ENUM_CAST(P_expr1::_bz_staticLength) > BZ_ENUM_CAST(P_expr2::_bz_staticLength)) ? BZ_ENUM_CAST(P_expr1::_bz_staticLength) : BZ_ENUM_CAST(P_expr2::_bz_staticLength)
+
+//      _bz_meta_max<P_expr1::_bz_staticLength, P_expr2::_bz_staticLength>::max 
+    };
+
+    int _bz_suggestLength() const
+    {
+        int length1 = iter1_._bz_suggestLength();
+        if (length1 != 0)
+            return length1;
+        return iter2_._bz_suggestLength();
+    }
+
+    _bz_bool  _bz_hasFastAccess() const
+    { return iter1_._bz_hasFastAccess() && iter2_._bz_hasFastAccess(); }
+
+    T_numtype _bz_fastAccess(int i) const
+    { 
+        return T_op::apply(iter1_._bz_fastAccess(i),
+            iter2_._bz_fastAccess(i)); 
+    }
+    
+private:
+    _bz_VecExprOp();
+
+    T_expr1 iter1_;
+    T_expr2 iter2_;
+};
+
+template<class P_expr, class P_unaryOp>
+class _bz_VecExprUnaryOp {
+
+public:
+    typedef P_expr T_expr;
+    typedef P_unaryOp T_unaryOp;
+    typedef _bz_typename T_unaryOp::T_numtype T_numtype;
+
+#ifdef BZ_PASS_EXPR_BY_VALUE
+    _bz_VecExprUnaryOp(T_expr iter)
+        : iter_(iter)
+    { }
+#else
+    _bz_VecExprUnaryOp(const T_expr& iter)
+        : iter_(iter)
+    { }
+#endif
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    _bz_VecExprUnaryOp(const _bz_VecExprUnaryOp<P_expr, P_unaryOp>& x)
+        : iter_(x.iter_)
+    { }
+#endif
+
+    T_numtype operator[](int i) const
+    { return T_unaryOp::apply(iter_[i]); }
+
+    T_numtype operator()(int i) const
+    { return T_unaryOp::apply(iter_(i)); }
+
+    int length(int recommendedLength) const
+    { return iter_.length(recommendedLength); }
+
+    enum { _bz_staticLengthCount = BZ_ENUM_CAST(P_expr::_bz_staticLengthCount),
+           _bz_dynamicLengthCount =BZ_ENUM_CAST(P_expr::_bz_dynamicLengthCount),
+           _bz_staticLength = BZ_ENUM_CAST(P_expr::_bz_staticLength) };
+
+    int _bz_suggestLength() const
+    { return iter_._bz_suggestLength(); }
+
+    _bz_bool _bz_hasFastAccess() const
+    { return iter_._bz_hasFastAccess(); }
+
+    T_numtype _bz_fastAccess(int i) const
+    { return T_unaryOp::apply(iter_._bz_fastAccess(i)); }
+
+private:
+    _bz_VecExprUnaryOp() { }
+
+    T_expr iter_;    
+};
+
+template<class P_numtype>
+class _bz_VecExprConstant {
+public:
+    typedef P_numtype T_numtype;
+
+    _bz_VecExprConstant(P_numtype value)
+        : value_(BZ_NO_PROPAGATE(value))
+    { 
+    }
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    _bz_VecExprConstant(const _bz_VecExprConstant<P_numtype>& x)
+        : value_(x.value_)
+    { }
+#endif
+
+    T_numtype operator[](int) const
+    { return value_; }
+
+    T_numtype operator()(int) const
+    { return value_; }
+
+    int length(int recommendedLength) const
+    { return recommendedLength; }
+
+    enum { _bz_staticLengthCount = 0,
+           _bz_dynamicLengthCount = 0,
+           _bz_staticLength = 0
+    };
+
+    int _bz_suggestLength() const
+    { return 0; }
+
+    _bz_bool _bz_hasFastAccess() const
+    { return 1; }
+
+    T_numtype _bz_fastAccess(int) const
+    { return value_; }
+
+private:
+
+    _bz_VecExprConstant() { }
+
+    T_numtype value_;
+};
+
+// Some miscellaneous operators that don't seem to belong anywhere else.
+
+template<class P_expr>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr>, 
+    _bz_negate<_bz_typename P_expr::T_numtype> > >
+operator-(_bz_VecExpr<P_expr> a)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr>,
+        _bz_negate<_bz_typename P_expr::T_numtype> > T_expr;
+    return _bz_VecExpr<T_expr>(T_expr(a));
+}
+
+template<class P_numtype>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype>,
+    _bz_negate<P_numtype> > >
+operator-(const Vector<P_numtype>& a)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype>,
+        _bz_negate<P_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(a.begin()));
+}
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range, _bz_negate<Range::T_numtype> > >
+operator-(Range r)
+{
+    typedef _bz_VecExprUnaryOp<Range, _bz_negate<Range::T_numtype> > T_expr;
+    
+    return _bz_VecExpr<T_expr>(T_expr(r));
+}
+
+
+// NEEDS_WORK: implement operator- for Range, VectorPick, TinyVector
+
+BZ_NAMESPACE_END
+
+#ifndef BZ_TINYVEC_H
+ #include <blitz/tinyvec.h>
+#endif
+
+#include <blitz/vecbops.cc>       // Operators with two operands
+#include <blitz/vecuops.cc>       // Functions with one argument
+#include <blitz/vecbfn.cc>        // Functions with two arguments
+
+#endif // BZ_VECEXPR_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecexprwrap.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecexprwrap.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecexprwrap.h	(revision 1307)
@@ -0,0 +1,96 @@
+/***************************************************************************
+ * blitz/vecexprwrap.h   Vector expression templates wrapper class
+ *
+ * $Id: vecexprwrap.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */
+
+#ifndef BZ_VECEXPRWRAP_H
+#define BZ_VECEXPRWRAP_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr>
+class _bz_VecExpr {
+
+public:
+    typedef P_expr T_expr;
+    typedef _bz_typename T_expr::T_numtype T_numtype;
+
+#ifdef BZ_PASS_EXPR_BY_VALUE
+    _bz_VecExpr(T_expr a)
+        : iter_(a)
+    { }
+#else
+    _bz_VecExpr(const T_expr& a)
+        : iter_(a)
+    { }
+#endif
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    _bz_VecExpr(const _bz_VecExpr<T_expr>& a)
+        : iter_(a.iter_)
+    { }
+#endif
+
+    T_numtype operator[](int i) const
+    { return iter_[i]; }
+
+    T_numtype operator()(int i) const
+    { return iter_(i); }
+
+    int length(int recommendedLength) const
+    { return iter_.length(recommendedLength); }
+
+    enum { _bz_staticLengthCount = BZ_ENUM_CAST(P_expr::_bz_staticLengthCount),
+           _bz_dynamicLengthCount = BZ_ENUM_CAST(P_expr::_bz_dynamicLengthCount),
+           _bz_staticLength = BZ_ENUM_CAST(P_expr::_bz_staticLength) };
+
+    int _bz_suggestLength() const
+    { return iter_._bz_suggestLength(); }
+
+    _bz_bool _bz_hasFastAccess() const
+    { return iter_._bz_hasFastAccess(); }
+
+    T_numtype _bz_fastAccess(int i) const
+    { return iter_._bz_fastAccess(i); }
+
+private:
+    _bz_VecExpr();
+
+    T_expr iter_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECEXPRWRAP_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecglobs.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecglobs.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecglobs.cc	(revision 1307)
@@ -0,0 +1,36 @@
+/*
+ * $Id: vecglobs.cc,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECGLOBS_CC
+#define BZ_VECGLOBS_CC
+
+#ifndef BZ_VECGLOBS_H
+ #include <blitz/vecglobs.h>
+#endif
+
+#include <blitz/vecaccum.cc>    // accumulate()
+#include <blitz/vecdelta.cc>    // delta()
+#include <blitz/vecmin.cc>      // min(), minValue(), minIndex()
+#include <blitz/vecmax.cc>      // max(), maxValue(), maxIndex()
+#include <blitz/vecsum.cc>      // sum(), mean()
+#include <blitz/vecdot.cc>      // dot()
+#include <blitz/vecnorm.cc>     // norm()
+#include <blitz/vecnorm1.cc>    // norm1()
+#include <blitz/vecany.cc>      // any()
+#include <blitz/vecall.cc>      // all()
+#include <blitz/veccount.cc>    // count()
+
+#endif // BZ_VECGLOBS_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecglobs.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecglobs.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecglobs.h	(revision 1307)
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * blitz/vecglobs.h      Global vector functions
+ *
+ * $Id: vecglobs.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_VECGLOBS_H
+#define BZ_VECGLOBS_H
+
+#ifndef BZ_VECTOR_H
+ #include <blitz/vector.h>
+#endif
+
+#ifndef BZ_NUMTRAIT_H
+ #include <blitz/numtrait.h>
+#endif
+
+#ifndef BZ_PROMOTE_H
+ #include <blitz/promote.h>
+#endif
+
+#ifndef BZ_EXTREMUM_H
+ #include <blitz/extremum.h>
+#endif
+
+
+BZ_NAMESPACE(blitz)
+
+BZ_NAMESPACE_END
+
+#include <blitz/vecglobs.cc>
+
+#endif // BZ_VECGLOBS_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecio.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecio.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecio.cc	(revision 1307)
@@ -0,0 +1,57 @@
+/*
+ * $Id: vecio.cc,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECIO_CC
+#define BZ_VECIO_CC
+
+#ifndef BZ_VECTOR_H
+ #include <blitz/vector.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// This version of operator<< is provided as a temporary measure
+// only.  It will be revised in a future release.
+// NEEDS_WORK
+
+template<class P_numtype>
+ostream& operator<<(ostream& os, const Vector<P_numtype>& x)
+{
+    os << "[ ";
+    for (int i=0; i < x.length(); ++i)
+    {
+        os << setw(10) << x[i];
+        if (!((i+1)%7))
+            os << endl << "  ";
+    }
+    os << " ]";
+    return os;
+}
+
+template<class P_expr>
+ostream& operator<<(ostream& os, _bz_VecExpr<P_expr> expr)
+{
+    Vector<_bz_typename P_expr::T_numtype> result(expr);
+    os << result;
+    return os;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECIO_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/veciter.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/veciter.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/veciter.h	(revision 1307)
@@ -0,0 +1,220 @@
+/***************************************************************************
+ * blitz/veciter.h      Iterator classes for Vector<P_numtype>
+ *
+ * $Id: veciter.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.6  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.5  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.4  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+
+#ifndef BZ_VECITER_H
+#define BZ_VECITER_H
+
+#ifndef BZ_VECTOR_H
+ #error <blitz/veciter.h> should be included via <blitz/vector.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Declaration of class VectorIter
+template<class P_numtype>
+class VectorIter {
+public:
+    typedef P_numtype T_numtype;
+
+    _bz_explicit VectorIter(Vector<P_numtype>& x)
+        : data_(x.data())
+    {
+        stride_ = x.stride();
+        length_ = x.length();
+    }
+
+    VectorIter(P_numtype* _bz_restrict data, int stride, int length)
+        : data_(data), stride_(stride), length_(length)
+    { }
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    VectorIter(const VectorIter<P_numtype>& x)
+    {
+        data_ = x.data_;
+        stride_ = x.stride_;
+        length_ = x.length_;
+    }
+#endif
+
+    P_numtype operator[](int i) const
+    { 
+        BZPRECONDITION(i < length_);
+        return data_[i*stride_]; 
+    }
+
+    P_numtype& _bz_restrict operator[](int i)
+    { 
+        BZPRECONDITION(i < length_);
+        return data_[i*stride_]; 
+    }
+
+    P_numtype operator()(int i) const
+    {
+        BZPRECONDITION(i < length_);
+        return data_[i*stride_];
+    }
+
+    P_numtype& _bz_restrict operator()(int i) 
+    {
+        BZPRECONDITION(i < length_);
+        return data_[i*stride_];
+    }
+
+    P_numtype operator*() const
+    { return *data_; }
+
+    P_numtype& operator*()
+    { return *data_; }
+
+    VectorIter<P_numtype> operator+(int i)
+    {
+        // NEEDS_WORK -- precondition checking?
+        return VectorIter<P_numtype>(data_+i*stride_, stride_, length_-i);
+    }
+
+    int length(int) const
+    { return length_; }
+
+    _bz_bool isUnitStride() const
+    { return (stride_ == 1); }
+
+    /////////////////////////////////////////////
+    // Library-internal member functions
+    // These are undocumented and may change or
+    // disappear in future releases.
+    /////////////////////////////////////////////
+
+    enum { _bz_staticLengthCount = 0,
+           _bz_dynamicLengthCount = 1,
+           _bz_staticLength = 0 };
+
+    _bz_bool _bz_hasFastAccess() const
+    { return isUnitStride(); }
+
+    P_numtype _bz_fastAccess(int i) const
+    { return data_[i]; }
+
+    P_numtype& _bz_restrict _bz_fastAccess(int i)
+    { return data_[i]; }
+
+    int _bz_suggestLength() const
+    { return length_; }
+
+private:
+    VectorIter() { }
+    P_numtype * _bz_restrict data_;
+    int stride_;
+    int length_;
+};
+
+
+template<class P_numtype>
+class VectorIterConst {
+public:
+    typedef P_numtype T_numtype;
+
+    _bz_explicit VectorIterConst(const Vector<P_numtype>& x)
+        : data_(x.data())
+    {
+        stride_ = x.stride();
+        length_ = x.length();
+    }
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    VectorIterConst(const VectorIterConst<P_numtype>& x)
+    {
+        data_ = x.data_;
+        stride_ = x.stride_;
+        length_ = x.length_;
+    }
+#endif
+
+    P_numtype operator[](int i) const
+    { 
+        BZPRECONDITION(i < length_);
+        return data_[i*stride_]; 
+    }
+
+    P_numtype operator()(int i) const
+    {
+        BZPRECONDITION(i < length_);
+        return data_[i*stride_];
+    }
+
+    int length(int) const
+    { return length_; }
+
+    _bz_bool isUnitStride() const
+    { return (stride_ == 1); }
+
+    /////////////////////////////////////////////
+    // Library-internal member functions
+    // These are undocumented and may change or
+    // disappear in future releases.
+    /////////////////////////////////////////////
+
+    enum { _bz_staticLengthCount = 0,
+           _bz_dynamicLengthCount = 1,
+           _bz_staticLength = 0 };
+
+    _bz_bool  _bz_hasFastAccess() const
+    { return isUnitStride(); }
+
+    P_numtype _bz_fastAccess(int i) const
+    {
+        return data_[i];
+    }
+
+    int _bz_suggestLength() const
+    { return length_; }
+
+private:
+    const P_numtype * _bz_restrict data_;
+    int stride_;
+    int length_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECITER_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecmax.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecmax.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecmax.cc	(revision 1307)
@@ -0,0 +1,163 @@
+/*
+ * $Id: vecmax.cc,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECMAX_CC
+#define BZ_VECMAX_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecmax.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr>
+inline
+Extremum<_bz_typename P_expr::T_numtype, int> _bz_vec_max(P_expr vector)
+{
+    typedef _bz_typename P_expr::T_numtype T_numtype;
+
+    T_numtype maxValue = vector(0);
+    int maxIndex = 0;
+    int length = vector._bz_suggestLength();
+
+    if (vector._bz_hasFastAccess())
+    {
+        for (int i=1; i < length; ++i)
+        {
+            T_numtype value = vector._bz_fastAccess(i);
+            if (value > maxValue)
+            {
+                maxValue = value;
+                maxIndex = i;
+            }
+        }
+    }
+    else {
+        for (int i=1; i < length; ++i)
+        {
+            T_numtype value = vector(i);
+            if (value > maxValue)
+            {
+                maxValue = value;
+                maxIndex = i;
+            }
+        }
+    }
+
+    return Extremum<T_numtype, int>(maxValue, maxIndex);
+}
+
+// max(vector)
+template<class P_numtype>
+inline
+Extremum<P_numtype, int> max(const Vector<P_numtype>& x)
+{
+    return _bz_vec_max(x._bz_asVecExpr());
+}
+
+// max(expr)
+template<class P_expr>
+inline
+Extremum<_bz_typename P_expr::T_numtype,int> max(_bz_VecExpr<P_expr> x)
+{
+    return _bz_vec_max(x);
+}
+
+// max(vecpick)
+template<class P_numtype>
+inline
+Extremum<P_numtype, int> max(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_max(x._bz_asVecExpr());
+}
+
+// max(TinyVector)
+template<class P_numtype, int N_length>
+inline
+Extremum<P_numtype, int>
+max(const TinyVector<P_numtype, N_length>& x)
+{
+    return _bz_vec_max(x._bz_asVecExpr());
+}
+
+
+// maxIndex(vector)
+template<class P_numtype>
+inline
+int  maxIndex(const Vector<P_numtype>& x)
+{
+    return _bz_vec_max(x).index();
+}
+
+// maxIndex(expr)
+template<class P_expr>
+inline
+int maxIndex(_bz_VecExpr<P_expr> x)
+{
+    return _bz_vec_max(x._bz_asVecExpr()).index();
+}
+
+// maxIndex(vecpick)
+template<class P_numtype>
+int  maxIndex(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_max(x._bz_asVecExpr()).index();
+}
+
+// maxIndex(TinyVector)
+template<class P_numtype, int N_length>
+int  maxIndex(const TinyVector<P_numtype, N_length>& x)
+{
+    return _bz_vec_max(x._bz_asVecExpr()).index();
+}
+
+// maxValue(vector)
+template<class P_numtype>
+inline
+int  maxValue(const Vector<P_numtype>& x)
+{
+    return _bz_vec_max(x._bz_asVecExpr()).value();
+}
+
+// maxValue(expr)
+template<class P_expr>
+inline
+int  maxValue(_bz_VecExpr<P_expr> x)
+{
+    return _bz_vec_max(x).value();
+}
+
+// maxValue(vecpick)
+template<class P_numtype>
+int  maxValue(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_max(x._bz_asVecExpr()).value();
+}
+
+// maxValue(TinyVector)
+template<class P_numtype, int N_length>
+int  maxValue(const TinyVector<P_numtype, N_length>& x)
+{
+    return _bz_vec_max(x._bz_asVecExpr()).value();
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECMAX_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecmin.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecmin.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecmin.cc	(revision 1307)
@@ -0,0 +1,161 @@
+/*
+ * $Id: vecmin.cc,v 1.1.1.1 1999-04-09 17:58:58 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECMIN_CC
+#define BZ_VECMIN_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecmin.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr>
+inline
+Extremum<_bz_typename P_expr::T_numtype, int> _bz_vec_min(P_expr vector)
+{
+    typedef _bz_typename P_expr::T_numtype T_numtype;
+
+    T_numtype minValue = vector(0);
+    int minIndex = 0;
+    int length = vector._bz_suggestLength();
+
+    if (vector._bz_hasFastAccess())
+    {
+        for (int i=1; i < length; ++i)
+        {
+            T_numtype value = vector._bz_fastAccess(i);
+            if (value < minValue)
+            {
+                minValue = value;
+                minIndex = i;
+            }
+        }
+    }
+    else {
+        for (int i=1; i < length; ++i)
+        {
+            T_numtype value = vector(i);
+            if (value < minValue)
+            {
+                minValue = value;
+                minIndex = i;
+            }
+        }
+    }
+
+    return Extremum<T_numtype, int>(minValue, minIndex);
+}
+
+// min(vector)
+template<class P_numtype>
+inline
+Extremum<P_numtype,int> min(const Vector<P_numtype>& x)
+{
+    return _bz_vec_min(x._bz_asVecExpr());
+}
+
+// min(expr)
+template<class P_expr>
+inline
+Extremum<_bz_typename P_expr::T_numtype,int> min(_bz_VecExpr<P_expr> x)
+{
+    return _bz_vec_min(x);
+}
+
+// min(vecpick)
+template<class P_numtype>
+inline
+Extremum<P_numtype, int> min(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_min(x._bz_asVecExpr());
+}
+
+// min(TinyVector)
+template<class P_numtype, int N_length>
+inline
+Extremum<P_numtype, int> min(const TinyVector<P_numtype, N_length>& x)
+{
+    return _bz_vec_min(x._bz_asVecExpr());
+}
+
+// minIndex(vector)
+template<class P_numtype>
+inline
+int  minIndex(const Vector<P_numtype>& x)
+{
+    return _bz_vec_min(x._bz_asVecExpr()).index();
+}
+
+// maxIndex(expr)
+template<class P_expr>
+inline
+int  minIndex(_bz_VecExpr<P_expr> x)
+{
+    return _bz_vec_min(x).index();
+}
+
+// minIndex(vecpick)
+template<class P_numtype>
+int  minIndex(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_min(x._bz_asVecExpr()).index();
+}
+
+// minIndex(TinyVector)
+template<class P_numtype, int N_length>
+int minIndex(const TinyVector<P_numtype, N_length>& x)
+{
+    return _bz_vec_min(x._bz_asVecExpr()).index();
+}
+
+// minValue(vector)
+template<class P_numtype>
+inline
+int  minValue(const Vector<P_numtype>& x)
+{
+    return _bz_vec_min(x._bz_asVecExpr()).value();
+}
+
+// minValue(expr)
+template<class P_expr>
+inline
+int  minValue(_bz_VecExpr<P_expr> x)
+{
+    return _bz_vec_min(x).value();
+}
+
+// minValue(vecpick)
+template<class P_numtype>
+int  minValue(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_min(x._bz_asVecExpr()).value();
+}
+
+// minValue(TinyVector)
+template<class P_numtype, int N_length>
+int  minValue(const TinyVector<P_numtype, N_length>& x)
+{
+    return _bz_vec_min(x._bz_asVecExpr()).value();
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECMIN_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecnorm.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecnorm.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecnorm.cc	(revision 1307)
@@ -0,0 +1,102 @@
+/*
+ * $Id: vecnorm.cc,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECNORM_CC
+#define BZ_VECNORM_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecnorm.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr>
+inline
+BZ_FLOATTYPE(BZ_SUMTYPE(_bz_typename P_expr::T_numtype))
+_bz_vec_norm(P_expr vector)
+{
+    // An extreme use of traits here.  It's necessary to
+    // handle odd cases such as the norm of a Vector<char>.
+    // To avoid overflow, BZ_SUMTYPE(char) is int.
+    // To take the sqrt of the sum, BZ_FLOATTYPE(char) is float.
+    // So float is returned for Vector<char>.
+    typedef _bz_typename P_expr::T_numtype T_numtype;
+    typedef BZ_SUMTYPE(T_numtype)          T_sumtype;
+    typedef BZ_FLOATTYPE(T_sumtype)        T_floattype;
+
+    T_sumtype sum = 0;
+    int length = vector._bz_suggestLength();
+
+    if (vector._bz_hasFastAccess())
+    {
+        for (int i=0; i < length; ++i)
+        {
+            T_numtype value = vector._bz_fastAccess(i);
+            sum += value * T_sumtype(value);
+        }
+    }
+    else {
+        for (int i=0; i < length; ++i)
+        {
+            T_numtype value = vector(i);
+            sum += value * T_sumtype(value);
+        }
+    }
+
+    return _bz_sqrt<T_floattype>::apply(sum);
+}
+
+template<class P_numtype>
+inline
+BZ_FLOATTYPE(BZ_SUMTYPE(P_numtype)) norm(const Vector<P_numtype>& x)
+{
+    return _bz_vec_norm(x._bz_asVecExpr());
+}
+
+// norm(expr)
+template<class P_expr>
+inline
+BZ_FLOATTYPE(BZ_SUMTYPE(_bz_typename P_expr::T_numtype))
+norm(_bz_VecExpr<P_expr> expr)
+{
+    return _bz_vec_norm(expr);
+}
+
+// norm(vecpick)
+template<class P_numtype>
+inline
+BZ_FLOATTYPE(BZ_SUMTYPE(P_numtype))
+norm(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_norm(x._bz_asVecExpr());
+}
+
+// norm(TinyVector)
+template<class P_numtype, int N_dimensions>
+inline
+BZ_FLOATTYPE(BZ_SUMTYPE(P_numtype))
+norm(const TinyVector<P_numtype, N_dimensions>& x)
+{
+    return _bz_vec_norm(x._bz_asVecExpr());
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECNORM_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecnorm1.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecnorm1.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecnorm1.cc	(revision 1307)
@@ -0,0 +1,87 @@
+/*
+ * $Id: vecnorm1.cc,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECNORM1_CC
+#define BZ_VECNORM1_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecnorm1.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+#include <blitz/applics.h>
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr>
+inline
+BZ_SUMTYPE(_bz_typename P_expr::T_numtype)
+_bz_vec_norm1(P_expr vector)
+{
+    typedef _bz_typename P_expr::T_numtype T_numtype;
+    typedef BZ_SUMTYPE(T_numtype)          T_sumtype;
+
+    T_sumtype sum = 0;
+    int length = vector._bz_suggestLength();
+
+    if (vector._bz_hasFastAccess())
+    {
+        for (int i=0; i < length; ++i)
+            sum += _bz_abs<T_numtype>::apply(vector._bz_fastAccess(i));
+    }
+    else {
+        for (int i=0; i < length; ++i)
+            sum += _bz_abs<T_numtype>::apply(vector(i));
+    }
+
+    return sum;
+}
+
+// norm1(vector)
+template<class P_numtype>
+BZ_SUMTYPE(P_numtype) norm1(const Vector<P_numtype>& x)
+{
+    return _bz_vec_norm1(x._bz_asVecExpr());
+}
+
+// norm1(expr)
+template<class P_expr>
+BZ_SUMTYPE(_bz_typename P_expr::T_numtype) norm1(_bz_VecExpr<P_expr> expr)
+{
+    return _bz_vec_norm1(expr);
+}
+
+// norm1(vecpick)
+template<class P_numtype>
+BZ_SUMTYPE(P_numtype) norm1(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_norm1(x._bz_asVecExpr());
+}
+
+// norm1(TinyVector)
+template<class P_numtype, int N_dimensions>
+BZ_SUMTYPE(P_numtype) norm1(const TinyVector<P_numtype, N_dimensions>& x)
+{
+    return _bz_vec_norm1(x._bz_asVecExpr());
+}
+
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECNORM1_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpick.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpick.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpick.cc	(revision 1307)
@@ -0,0 +1,658 @@
+/*
+ * $Id: vecpick.cc,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECPICK_CC
+#define BZ_VECPICK_CC
+
+#ifndef BZ_VECPICK_H
+ #include <blitz/vecpick.h>
+#endif
+
+#ifndef BZ_UPDATE_H
+ #include <blitz/update.h>
+#endif
+
+#ifndef BZ_RANDOM_H
+ #include <blitz/random.h>
+#endif
+
+#ifndef BZ_VECEXPR_H
+ #include <blitz/vecexpr.h>
+#endif
+
+#ifndef BZ_RANDOM_H
+ #include <blitz/random.h>
+#endif
+BZ_NAMESPACE(blitz)
+
+/*****************************************************************************
+ * Assignment operators with vector expression operand
+ */
+
+template<class P_numtype> template<class P_expr, class P_updater>
+inline
+void VectorPick<P_numtype>::_bz_assign(P_expr expr, P_updater)
+{
+    BZPRECONDITION(expr.length(length()) == length());
+
+    // If all vectors in the expression, plus the vector to which the
+    // result is being assigned have unit stride, then avoid stride
+    // calculations.
+    if (_bz_hasFastAccess() && expr._bz_hasFastAccess())
+    {
+#ifndef BZ_PARTIAL_LOOP_UNROLL
+        for (int i=0; i < length(); ++i)
+            P_updater::update(vector_(index_(i)), expr._bz_fastAccess(i));
+#else
+        // Unwind the inner loop, five elements at a time.
+        int leftover = length() % 5;
+
+        int i=0;
+        for (; i < leftover; ++i)
+            P_updater::update(vector_(index_(i)), expr._bz_fastAccess(i));
+
+        for (; i < length(); i += 5)
+        {
+            P_updater::update(vector_(index_(i)), expr._bz_fastAccess(i));
+            P_updater::update(vector_(index_(i+1)), expr._bz_fastAccess(i+1));
+            P_updater::update(vector_(index_(i+2)), expr._bz_fastAccess(i+2));
+            P_updater::update(vector_(index_(i+3)), expr._bz_fastAccess(i+3));
+            P_updater::update(vector_(index_(i+4)), expr._bz_fastAccess(i+4));
+        }
+#endif
+    }
+    else {
+        // Not all unit strides -- have to access all the vector elements
+        // as data_[i*stride_], which is slower.
+        for (int i=0; i < length(); ++i)
+            P_updater::update(vector_[index_[i]], expr[i]);
+    }
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator=(_bz_VecExpr<P_expr> expr)
+{
+    BZPRECONDITION(expr.length(length()) == length());
+
+    // If all vectors in the expression, plus the vector to which the
+    // result is being assigned have unit stride, then avoid stride
+    // calculations.
+    if (_bz_hasFastAccess() && expr._bz_hasFastAccess())
+    {
+#ifndef BZ_PARTIAL_LOOP_UNROLL
+        for (int i=0; i < length(); ++i)
+            (*this)(i) = expr._bz_fastAccess(i);
+#else
+        // Unwind the inner loop, five elements at a time.
+        int leftover = length() % 5;
+
+        int i=0;
+        for (; i < leftover; ++i)
+            (*this)(i) = expr._bz_fastAccess(i);
+
+        for (; i < length(); i += 5)
+        {
+            (*this)(i) = expr._bz_fastAccess(i);
+            (*this)(i+1) = expr._bz_fastAccess(i+1);
+            (*this)(i+2) = expr._bz_fastAccess(i+2);
+            (*this)(i+3) = expr._bz_fastAccess(i+3);
+            (*this)(i+4) = expr._bz_fastAccess(i+4);
+        }
+#endif
+    }
+    else {
+        // Not all unit strides -- have to access all the vector elements
+        // as data_[i*stride_], which is slower.
+        for (int i=0; i < length(); ++i)
+            (*this)[i] = expr[i];
+    }
+    return *this;
+}
+
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator+=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_plus_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator-=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_minus_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator*=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_multiply_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator/=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_divide_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator%=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_mod_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator^=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_xor_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator&=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_bitand_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator|=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_bitor_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator>>=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_shiftr_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator<<=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_shiftl_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with scalar operand
+ */
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) = _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator+=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) += _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator-=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) -= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator*=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) *= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator/=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) /= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator%=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) %= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator^=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) ^= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator&=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) &= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator|=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) |= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator>>=(int x)
+{
+    typedef _bz_VecExprConstant<int> T_expr;
+    (*this) >>= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator<<=(int x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) <<= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with vector operand
+ */
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator=(const Vector<P_numtype2>& x)
+{
+    (*this) = _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator+=(const Vector<P_numtype2>& x)
+{
+    (*this) += _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator-=(const Vector<P_numtype2>& x)
+{
+    (*this) -= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator*=(const Vector<P_numtype2>& x)
+{
+    (*this) *= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator/=(const Vector<P_numtype2>& x)
+{
+    (*this) /= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator%=(const Vector<P_numtype2>& x)
+{
+    (*this) %= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator^=(const Vector<P_numtype2>& x)
+{
+    (*this) ^= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator&=(const Vector<P_numtype2>& x)
+{
+    (*this) &= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator|=(const Vector<P_numtype2>& x)
+{
+    (*this) |= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator<<=(const Vector<P_numtype2>& x)
+{
+    (*this) <<= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>&
+VectorPick<P_numtype>::operator>>=(const Vector<P_numtype2>& x)
+{
+    (*this) >>= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with Range operand
+ */
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator=(Range r)
+{
+    (*this) = _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator+=(Range r)
+{
+    (*this) += _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator-=(Range r)
+{
+    (*this) -= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator*=(Range r)
+{
+    (*this) *= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator/=(Range r)
+{
+    (*this) /= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator%=(Range r)
+{
+    (*this) %= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator^=(Range r)
+{
+    (*this) ^= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator&=(Range r)
+{
+    (*this) &= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator|=(Range r)
+{
+    (*this) |= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator>>=(Range r)
+{
+    (*this) >>= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator<<=(Range r)
+{
+    (*this) <<= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with VectorPick operand
+ */
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator=(const 
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) = _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator+=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) += _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator-=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) -= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator*=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) *= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator/=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) /= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator%=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) %= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator^=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) ^= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator&=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) &= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator|=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) |= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with Random operand
+ */
+
+template<class P_numtype> template<class P_distribution>
+VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator=(Random<P_distribution>& rand)
+{
+    (*this) = _bz_VecExpr<_bz_VecExprRandom<P_distribution> > 
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator+=(Random<P_distribution>& rand)
+{
+    (*this) += _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator-=(Random<P_distribution>& rand)
+{
+    (*this) -= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator*=(Random<P_distribution>& rand)
+{
+    (*this) *= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator/=(Random<P_distribution>& rand)
+{
+    (*this) /= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator%=(Random<P_distribution>& rand)
+{
+    (*this) %= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator^=(Random<P_distribution>& rand)
+{
+    (*this) ^= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator&=(Random<P_distribution>& rand)
+{
+    (*this) &= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+VectorPick<P_numtype>& 
+VectorPick<P_numtype>::operator|=(Random<P_distribution>& rand)
+{
+    (*this) |= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECPICK_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpick.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpick.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpick.h	(revision 1307)
@@ -0,0 +1,317 @@
+/***************************************************************************
+ * blitz/vecpick.h      Declaration of the VectorPick<T_numtype> class
+ *
+ * $Id: vecpick.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_VECPICK_H
+#define BZ_VECPICK_H
+
+#ifndef BZ_VECTOR_H
+ #include <blitz/vector.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Forward declarations
+
+template<class P_numtype> class VectorPickIter;
+template<class P_numtype> class VectorPickIterConst;
+
+// Declaration of class VectorPick<P_numtype>
+
+template<class P_numtype>
+class VectorPick {
+
+public:
+    //////////////////////////////////////////////
+    // Public Types
+    //////////////////////////////////////////////
+
+    typedef P_numtype                      T_numtype;
+    typedef Vector<T_numtype>              T_vector;
+    typedef Vector<int>                    T_indexVector;
+    typedef VectorPick<T_numtype>          T_pick;
+    typedef VectorPickIter<T_numtype>      T_iterator;
+    typedef VectorPickIterConst<T_numtype> T_constIterator;
+
+    //////////////////////////////////////////////
+    // Constructors                             //
+    //////////////////////////////////////////////
+
+    VectorPick(T_vector& vector, T_indexVector& indexarg)
+        : vector_(vector), index_(indexarg)
+    { }
+
+    VectorPick(const T_pick& vecpick)
+        : vector_(const_cast<T_vector&>(vecpick.vector_)), 
+          index_(const_cast<T_indexVector&>(vecpick.index_))
+    { }
+
+    VectorPick(T_pick& vecpick, Range r)
+        : vector_(vecpick.vector_), index_(vecpick.index_[r])
+    { }
+ 
+    //////////////////////////////////////////////
+    // Member functions
+    //////////////////////////////////////////////
+
+    T_iterator         begin()
+    { return VectorPickIter<T_numtype>(*this); }
+
+    T_constIterator    begin()      const
+    { return VectorPickIterConst<T_numtype>(*this); }
+
+    // T_vector           copy()       const;
+
+    // T_iterator         end();
+
+    // T_constIterator    end()        const;
+
+    T_indexVector&     indexSet()
+    { return index_; }
+ 
+    const T_indexVector& indexSet()      const
+    { return index_; }
+
+    int           length()     const
+    { return index_.length(); }
+
+    void               setVector(Vector<T_numtype>& x)
+    { vector_.reference(x); }
+
+    void               setIndex(Vector<int>& index)
+    { index_.reference(index); }
+
+    T_vector&          vector()
+    { return vector_; }
+
+    const T_vector&    vector()     const
+    { return vector_; }
+
+    /////////////////////////////////////////////
+    // Library-internal member functions
+    // These are undocumented and may change or
+    // disappear in future releases.
+    /////////////////////////////////////////////
+
+    int        _bz_suggestLength() const
+    { return index_.length(); }
+
+    _bz_bool        _bz_hasFastAccess() const
+    { return vector_._bz_hasFastAccess() && index_._bz_hasFastAccess(); }
+
+    T_numtype&      _bz_fastAccess(int i)
+    { return vector_._bz_fastAccess(index_._bz_fastAccess(i)); }
+
+    T_numtype       _bz_fastAccess(int i) const
+    { return vector_._bz_fastAccess(index_._bz_fastAccess(i)); }
+
+    _bz_VecExpr<T_constIterator> _bz_asVecExpr() const
+    { return _bz_VecExpr<T_constIterator>(begin()); }
+
+    //////////////////////////////////////////////
+    // Subscripting operators
+    //////////////////////////////////////////////
+
+    T_numtype       operator()(int i) const
+    { 
+        BZPRECONDITION(index_.stride() == 1);
+        BZPRECONDITION(vector_.stride() == 1);
+        BZPRECONDITION(i < index_.length());
+        BZPRECONDITION(index_[i] < vector_.length());
+        return vector_(index_(i));
+    }
+
+    T_numtype&      operator()(int i)
+    {
+        BZPRECONDITION(index_.stride() == 1);
+        BZPRECONDITION(vector_.stride() == 1);
+        BZPRECONDITION(i < index_.length());
+        BZPRECONDITION(index_[i] < vector_.length());
+        return vector_(index_(i));
+    }
+
+    T_numtype       operator[](int i) const
+    {
+        BZPRECONDITION(index_.stride() == 1);
+        BZPRECONDITION(vector_.stride() == 1);
+        BZPRECONDITION(i < index_.length());
+        BZPRECONDITION(index_[i] < vector_.length());
+        return vector_[index_[i]];
+    }
+
+    T_numtype&      operator[](int i)
+    {
+        BZPRECONDITION(index_.stride() == 1);
+        BZPRECONDITION(vector_.stride() == 1);
+        BZPRECONDITION(i < index_.length());
+        BZPRECONDITION(index_[i] < vector_.length());
+        return vector_[index_[i]];
+    }
+
+    T_pick          operator()(Range r)
+    {
+        return T_pick(*this, index_[r]);
+    }
+
+    T_pick          operator[](Range r)
+    {
+        return T_pick(*this, index_[r]);
+    }
+
+    //////////////////////////////////////////////
+    // Assignment operators
+    //////////////////////////////////////////////
+
+    // Scalar operand
+    T_pick& operator=(T_numtype);
+    T_pick& operator+=(T_numtype);
+    T_pick& operator-=(T_numtype);
+    T_pick& operator*=(T_numtype);
+    T_pick& operator/=(T_numtype);
+    T_pick& operator%=(T_numtype);
+    T_pick& operator^=(T_numtype);
+    T_pick& operator&=(T_numtype);
+    T_pick& operator|=(T_numtype);
+    T_pick& operator>>=(int);
+    T_pick& operator<<=(int);
+
+    // Vector operand
+    template<class P_numtype2> T_pick& operator=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator+=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator-=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator*=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator/=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator%=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator^=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator&=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator|=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator>>=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_pick& operator<<=(const Vector<P_numtype2> &);
+
+    // Vector expression operand
+    template<class P_expr> T_pick& operator=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator+=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator-=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator*=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator/=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator%=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator^=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator&=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator|=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator>>=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_pick& operator<<=(_bz_VecExpr<P_expr>);
+
+    // Range operand
+    T_pick& operator=(Range);
+    T_pick& operator+=(Range);
+    T_pick& operator-=(Range);
+    T_pick& operator*=(Range);
+    T_pick& operator/=(Range);
+    T_pick& operator%=(Range);
+    T_pick& operator^=(Range);
+    T_pick& operator&=(Range);
+    T_pick& operator|=(Range);
+    T_pick& operator>>=(Range);
+    T_pick& operator<<=(Range);
+
+    // Vector pick operand
+    template<class P_numtype2> 
+    T_pick& operator=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator+=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator-=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator*=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator/=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator%=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator^=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator&=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator|=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator>>=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_pick& operator<<=(const VectorPick<P_numtype2> &);
+
+    // Random operand
+    template<class P_distribution>
+    T_pick& operator=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_pick& operator+=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_pick& operator-=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_pick& operator*=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_pick& operator/=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_pick& operator%=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_pick& operator^=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_pick& operator&=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_pick& operator|=(Random<P_distribution>& random);
+
+private:
+    VectorPick() { }
+
+    template<class P_expr, class P_updater>
+    inline void _bz_assign(P_expr, P_updater);
+
+private:
+    T_vector vector_;
+    T_indexVector index_;
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/vecpick.cc>
+#include <blitz/vecpickio.cc>
+#include <blitz/vecpickiter.h>
+
+#endif // BZ_VECPICK_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpickio.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpickio.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpickio.cc	(revision 1307)
@@ -0,0 +1,34 @@
+/*
+ * $Id: vecpickio.cc,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECPICKIO_CC
+#define BZ_VECPICKIO_CC
+
+#ifndef BZ_VECPICK_H
+ #error <blitz/vecpickio.cc> must be included via <blitz/vecpick.h>
+#endif // BZ_VECPICK_H
+
+BZ_NAMESPACE(blitz)
+
+template<class P_numtype>
+ostream& operator<<(ostream& os, const VectorPick<P_numtype>& x)
+{
+    Vector<P_numtype> y(x.length());
+    y = x;
+    os << y;
+    return os;
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECPICKIO_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpickiter.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpickiter.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecpickiter.h	(revision 1307)
@@ -0,0 +1,188 @@
+/***************************************************************************
+ * blitz/vecpickiter.h      Declaration of VectorPickIter<T_numtype> and
+ *                          VectorPickIterConst<T_numtype> classes
+ *
+ * $Id: vecpickiter.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.5  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.4  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.3  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ */
+
+#ifndef BZ_VECPICKITER_H
+#define BZ_VECPICKITER_H
+
+#ifndef BZ_VECPICK_H
+ #include <blitz/vecpick.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_numtype>
+class VectorPickIter {
+
+public:
+    typedef P_numtype  T_numtype;
+
+    _bz_explicit VectorPickIter(VectorPick<T_numtype>& x)
+        : data_(x.vector().data()), index_(x.indexSet().data())
+    {
+        dataStride_  = x.vector().stride();
+        indexStride_ = x.indexSet().stride();
+        length_ = x.indexSet().length();
+    }
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    VectorPickIter(const VectorPickIter<T_numtype>& x)
+    {
+        data_ = x.data_;
+        index_ = x.index_;
+        dataStride_ = x.dataStride_;
+        indexStride_ = x.indexStride_;
+        length_ = x.length_;
+    }
+#endif
+
+    T_numtype operator[](int i) const
+    {
+        BZPRECONDITION(i < length_);
+        return data_[dataStride_ * index_[i * indexStride_]];
+    }
+
+    T_numtype& operator[](int i)
+    {
+        BZPRECONDITION(i < length_);
+        return data_[dataStride_ * index_[i * indexStride_]];
+    }
+
+    int length(int) const
+    { return length_; }
+
+    int _bz_suggestLength() const
+    { return length_; }
+
+    _bz_bool isUnitStride() const
+    { return (dataStride_  == 1) && (indexStride_ == 1); }
+
+    _bz_bool _bz_hasFastAccess() const
+    { return isUnitStride(); }
+
+    T_numtype _bz_fastAccess(int i) const
+    {    
+         return data_[index_[i]];
+    }
+
+    T_numtype&  _bz_fastAccess(int i)
+    {
+         return data_[index_[i]];
+    }
+
+    enum { _bz_staticLengthCount = 0,
+           _bz_dynamicLengthCount = 1,
+           _bz_staticLength = 0 };
+
+private:
+    T_numtype * _bz_restrict data_;
+    int dataStride_;
+    const int * _bz_restrict index_;
+    int indexStride_;
+    int length_;
+};
+
+template<class P_numtype>
+class VectorPickIterConst {
+
+public:
+    typedef P_numtype  T_numtype;
+
+    _bz_explicit VectorPickIterConst(const VectorPick<T_numtype>& x)
+        : data_(x.vector().data()), index_(x.indexSet().data())
+    {
+        dataStride_  = x.vector().stride();
+        indexStride_ = x.indexSet().stride();
+        length_ = x.indexSet().length();
+    }
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    VectorPickIterConst(const VectorPickIterConst<T_numtype>& x)
+    {
+        data_ = x.data_;
+        index_ = x.index_;
+        dataStride_ = x.dataStride_;
+        indexStride_ = x.indexStride_;
+        length_ = x.length_;
+    }
+#endif
+
+    T_numtype operator[](int i) const
+    {
+        BZPRECONDITION(i < length_);
+        return data_[dataStride_ * index_[i * indexStride_]];
+    }
+
+    int length(int) const
+    { return length_; }
+
+    int _bz_suggestLength() const
+    { return length_; }
+
+    _bz_bool isUnitStride() const
+    { return (dataStride_  == 1) && (indexStride_ == 1); }
+
+    _bz_bool _bz_hasFastAccess() const
+    { return isUnitStride(); }
+
+    T_numtype _bz_fastAccess(int i) const
+    {
+         return data_[index_[i]];
+    }
+
+    enum { _bz_staticLengthCount = 0,
+           _bz_dynamicLengthCount = 1,
+           _bz_staticLength = 0 };
+
+private:
+    const T_numtype * _bz_restrict data_;
+    int dataStride_;
+    const int * _bz_restrict index_;
+    int indexStride_;
+    int length_;
+};
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECPICKITER_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecsum.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecsum.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecsum.cc	(revision 1307)
@@ -0,0 +1,117 @@
+/*
+ * $Id: vecsum.cc,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECSUM_CC
+#define BZ_VECSUM_CC
+
+#ifndef BZ_VECGLOBS_H
+ #error <blitz/vecsum.cc> must be included via <blitz/vecglobs.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr>
+inline
+BZ_SUMTYPE(_bz_typename P_expr::T_numtype)
+_bz_vec_sum(P_expr vector)
+{
+    typedef _bz_typename P_expr::T_numtype T_numtype;
+    typedef BZ_SUMTYPE(T_numtype)          T_sumtype;
+
+    T_sumtype sum = 0;
+    int length = vector._bz_suggestLength();
+
+    if (vector._bz_hasFastAccess())
+    {
+        for (int i=0; i < length; ++i)
+            sum += vector._bz_fastAccess(i);
+    }
+    else {
+        for (int i=0; i < length; ++i)
+            sum += vector(i);
+    }
+
+    return sum;
+}
+
+template<class P_numtype>
+inline
+BZ_SUMTYPE(P_numtype) sum(const Vector<P_numtype>& x)
+{
+    return _bz_vec_sum(x._bz_asVecExpr());
+}
+
+// sum(expr)
+template<class P_expr>
+inline
+BZ_SUMTYPE(_bz_typename P_expr::T_numtype)
+sum(_bz_VecExpr<P_expr> expr)
+{
+    return _bz_vec_sum(expr);
+}
+
+// sum(vecpick)
+template<class P_numtype>
+inline
+BZ_SUMTYPE(P_numtype)
+sum(const VectorPick<P_numtype>& x)
+{
+    return _bz_vec_sum(x._bz_asVecExpr());
+}
+
+// mean(vector)
+template<class P_numtype>
+inline
+BZ_FLOATTYPE(BZ_SUMTYPE(P_numtype)) mean(const Vector<P_numtype>& x)
+{
+    BZPRECONDITION(x.length() > 0);
+
+    typedef BZ_FLOATTYPE(BZ_SUMTYPE(P_numtype)) T_floattype;
+    return _bz_vec_sum(x._bz_asVecExpr()) / (T_floattype) x.length();
+}
+
+// mean(expr)
+template<class P_expr>
+inline
+BZ_FLOATTYPE(BZ_SUMTYPE(_bz_typename P_expr::T_numtype))
+mean(_bz_VecExpr<P_expr> expr)
+{
+    BZPRECONDITION(expr._bz_suggestLength() > 0);
+
+    typedef BZ_FLOATTYPE(BZ_SUMTYPE(_bz_typename P_expr::T_numtype)) 
+        T_floattype;
+    return _bz_vec_sum(expr) / (T_floattype) expr._bz_suggestLength();
+}
+
+// mean(vecpick)
+template<class P_numtype>
+inline
+BZ_FLOATTYPE(BZ_SUMTYPE(P_numtype))
+mean(const VectorPick<P_numtype>& x)
+{
+    BZPRECONDITION(x.length() > 0);
+
+    typedef BZ_FLOATTYPE(BZ_SUMTYPE(P_numtype)) T_floattype;
+    return _bz_vec_sum(x._bz_asVecExpr()) / (T_floattype) x.length();
+}
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECSUM_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vector.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vector.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vector.cc	(revision 1307)
@@ -0,0 +1,862 @@
+/*
+ * $Id: vector.cc,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.6  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.5  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.4  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECTOR_CC
+#define BZ_VECTOR_CC
+
+#ifndef BZ_VECTOR_H
+ #include <blitz/vector.h>
+#endif
+
+#ifndef BZ_UPDATE_H
+ #include <blitz/update.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_numtype>
+Vector<P_numtype> Vector<P_numtype>::copy() const
+{
+    Vector<P_numtype> newCopy(length_);
+
+    if (stride_ == 1)
+    {
+        memcpy(newCopy.data(), data(), length_ * sizeof(P_numtype));
+    }
+    else {
+        for (int i=0; i < length_; ++i)
+        {
+            // Can assume that newCopy has unit stride, and hence use
+            // the operator(), which assumes unit stride.  Since this
+            // vector doesn't have unit stride, use [].
+            newCopy(i) = (*this)[i];
+        }
+    }
+
+    return newCopy;
+}
+
+template<class P_numtype>
+void Vector<P_numtype>::makeUnique()
+{
+    if ((stride_ != 1) || (numReferences() > 1))
+    {
+        Vector<P_numtype> tmp = copy();
+        reference(tmp);
+    }
+}
+
+template<class P_numtype>
+void Vector<P_numtype>::reference(Vector<P_numtype>& x)
+{
+    MemoryBlockReference<P_numtype>::changeBlock(x, 0);
+    length_ = x.length_;
+    stride_ = x.stride_;
+}
+
+template<class P_numtype>
+void Vector<P_numtype>::resize(int length)
+{
+    if (length != length_)
+    {
+        MemoryBlockReference<P_numtype>::newBlock(length);
+        length_ = length;
+        stride_ = 1;
+    }
+}
+
+template<class P_numtype>
+void Vector<P_numtype>::resizeAndPreserve(int newLength)
+{
+    Vector<P_numtype> newVector(newLength);
+
+    if (newLength > length_)
+        newVector(Range(0,length_-1)) = (*this);
+    else 
+        newVector(Range(0,newLength-1)) = (*this);
+
+    reference(newVector);
+}
+
+/*****************************************************************************
+ * Assignment operators with vector expression operand
+ */
+
+template<class P_numtype> template<class P_expr, class P_updater>
+inline
+void Vector<P_numtype>::_bz_assign(P_expr expr, P_updater)
+{
+    BZPRECONDITION(expr.length(length_) == length_);
+
+    // If all vectors in the expression, plus the vector to which the
+    // result is being assigned have unit stride, then avoid stride
+    // calculations.
+    if ((stride_ == 1) && (expr._bz_hasFastAccess()))
+    {
+#ifndef BZ_PARTIAL_LOOP_UNROLL
+        for (int i=0; i < length_; ++i)
+            P_updater::update(data_[i], expr._bz_fastAccess(i));
+#else
+        // Unwind the inner loop, four elements at a time.
+        int leftover = length_ & 0x03;
+
+        int i=0;
+        for (; i < leftover; ++i)
+            P_updater::update(data_[i], expr._bz_fastAccess(i));
+
+        for (; i < length_; i += 4)
+        {
+            // Common subexpression elimination: avoid doing i+1, i+2, i+3
+            // multiple times (compilers *won't* do this cse automatically)
+            int t1 = i+1;
+            int t2 = i+2;
+            int t3 = i+3;
+    
+            _bz_typename P_expr::T_numtype tmp1, tmp2, tmp3, tmp4;
+
+            // Reading all the results first avoids aliasing
+            // ambiguities, and provides more flexibility in
+            // register allocation & instruction scheduling
+            tmp1 = expr._bz_fastAccess(i);
+            tmp2 = expr._bz_fastAccess(BZ_NO_PROPAGATE(t1));
+            tmp3 = expr._bz_fastAccess(BZ_NO_PROPAGATE(t2));
+            tmp4 = expr._bz_fastAccess(BZ_NO_PROPAGATE(t3));
+
+            P_updater::update(data_[i], BZ_NO_PROPAGATE(tmp1));
+            P_updater::update(data_[t1], tmp2);
+            P_updater::update(data_[t2], tmp3);
+            P_updater::update(data_[t3], tmp4);
+        }
+#endif
+    }
+    else {
+        // Not all unit strides -- have to access all the vector elements
+        // as data_[i*stride_], which is slower.
+        for (int i=0; i < length_; ++i)
+            P_updater::update((*this)[i], expr[i]);
+    }
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator=(_bz_VecExpr<P_expr> expr)
+{
+    BZPRECONDITION(expr.length(length_) == length_);
+
+    // If all vectors in the expression, plus the vector to which the
+    // result is being assigned have unit stride, then avoid stride
+    // calculations.
+    if ((stride_ == 1) && (expr._bz_hasFastAccess()))
+    {
+#ifndef BZ_PARTIAL_LOOP_UNROLL
+        for (int i=0; i < length_; ++i)
+            data_[i] = (P_numtype)expr._bz_fastAccess(i);
+#else
+        // Unwind the inner loop, four elements at a time.
+        int leftover = length_ & 3;
+
+        int i=0;
+        for (; i < leftover; ++i)
+            data_[i] = (P_numtype)expr._bz_fastAccess(i);
+
+        for (; i < length_; i += 4)
+        {
+            // Common subexpression elimination: avoid doing i+1, i+2, i+3
+            // multiple times (compilers *won't* do this cse automatically)
+            int t1 = i+1;
+            int t2 = i+2;
+            int t3 = i+3;
+
+            _bz_typename P_expr::T_numtype tmp1, tmp2, tmp3, tmp4;
+
+            // Reading all the results first avoids aliasing
+            // ambiguities, and provides more flexibility in
+            // register allocation & instruction scheduling
+            tmp1 = expr._bz_fastAccess(i);
+            tmp2 = expr._bz_fastAccess(BZ_NO_PROPAGATE(t1));
+            tmp3 = expr._bz_fastAccess(BZ_NO_PROPAGATE(t2));
+            tmp4 = expr._bz_fastAccess(BZ_NO_PROPAGATE(t3));
+
+            data_[i] = (P_numtype)BZ_NO_PROPAGATE(tmp1);
+            data_[t1] = (P_numtype)tmp2;
+            data_[t2] = (P_numtype)tmp3;
+            data_[t3] = (P_numtype)tmp4;
+        }
+#endif
+    }
+    else {
+        // Not all unit strides -- have to access all the vector elements
+        // as data_[i*stride_], which is slower.
+        for (int i=0; i < length_; ++i)
+            (*this)[i] = (P_numtype)expr[i];
+    }
+    return *this;
+}
+
+#ifdef BZ_PARTIAL_LOOP_UNROLL
+ 
+#define BZ_VECTOR_ASSIGN(op)                                            \
+template<class P_numtype> template<class P_expr>                        \
+inline Vector<P_numtype>& Vector<P_numtype>::                           \
+    operator op (_bz_VecExpr<P_expr> expr)                              \
+{                                                                       \
+    BZPRECONDITION(expr.length(length_) == length_);                    \
+    if ((stride_ == 1) && (expr._bz_hasFastAccess()))                   \
+    {                                                                   \
+        int leftover = length_ & 0x03;                                  \
+                                                                        \
+        int i=0;                                                        \
+        for (; i < leftover; ++i)                                       \
+            data_[i] op expr._bz_fastAccess(i);                         \
+                                                                        \
+        for (; i < length_; i += 4)                                     \
+        {                                                               \
+            int t1 = i+1;                                               \
+            int t2 = i+2;                                               \
+            int t3 = i+3;                                               \
+                                                                        \
+            _bz_typename P_expr::T_numtype tmp1, tmp2, tmp3, tmp4;      \
+                                                                        \
+            tmp1 = expr._bz_fastAccess(i);                              \
+            tmp2 = expr._bz_fastAccess(t1);                             \
+            tmp3 = expr._bz_fastAccess(t2);                             \
+            tmp4 = expr._bz_fastAccess(t3);                             \
+                                                                        \
+            data_[i] op tmp1;                                           \
+            data_[t1] op tmp2;                                          \
+            data_[t2] op tmp3;                                          \
+            data_[t3] op tmp4;                                          \
+        }                                                               \
+    }                                                                   \
+    else {                                                              \
+        for (int i=0; i < length_; ++i)                               \
+            (*this)[i] op expr[i];                                      \
+    }                                                                   \
+    return *this;                                                       \
+}
+
+#else   // not BZ_PARTIAL_LOOP_UNROLL
+
+#ifdef BZ_ALTERNATE_FORWARD_BACKWARD_TRAVERSALS
+
+/*
+ * NEEDS_WORK: need to incorporate BZ_NO_PROPAGATE here.  This
+ * will require doing away with the macro BZ_VECTOR_ASSIGN, and
+ * adopting an approach similar to that used in arrayeval.cc.
+ */
+
+#define BZ_VECTOR_ASSIGN(op)                                            \
+template<class P_numtype> template<class P_expr>                        \
+inline Vector<P_numtype>& Vector<P_numtype>::                           \
+    operator op (_bz_VecExpr<P_expr> expr)                              \
+{                                                                       \
+    BZPRECONDITION(expr.length(length_) == length_);                    \
+    static int traversalOrder = 0;                                      \
+    if ((stride_ == 1) && (expr._bz_hasFastAccess()))                   \
+    {                                                                   \
+        if (traversalOrder & 0x01)                                      \
+            for (int i=length_-1; i >= 0; --i)                        \
+                data_[i] op expr._bz_fastAccess(i);                     \
+        else                                                            \
+            for (int i=0; i < length_; ++i)                           \
+                data_[i] op expr._bz_fastAccess(i);                     \
+    }                                                                   \
+    else {                                                              \
+        for (int i=0; i < length_; ++i)                               \
+            (*this)[i] op expr[i];                                      \
+    }                                                                   \
+    traversalOrder ^= 0x01;                                             \
+    return *this;                                                       \
+}
+
+#else   // not BZ_ALTERNATE_FORWARD_BACKWARD_TRAVERSALS
+
+#define BZ_VECTOR_ASSIGN(op)                                            \
+template<class P_numtype> template<class P_expr>                        \
+inline Vector<P_numtype>& Vector<P_numtype>::                           \
+    operator op (_bz_VecExpr<P_expr> expr)                              \
+{                                                                       \
+    BZPRECONDITION(expr.length(length_) == length_);                    \
+    if ((stride_ == 1) && (expr._bz_hasFastAccess()))                   \
+    {                                                                   \
+        for (int i=0; i < length_; ++i)                               \
+            data_[i] op expr._bz_fastAccess(i);                         \
+    }                                                                   \
+    else {                                                              \
+        for (int i=0; i < length_; ++i)                               \
+            (*this)[i] op expr[i];                                      \
+    }                                                                   \
+    return *this;                                                       \
+}                 
+#endif // BZ_ALTERNATE_FORWARD_BACKWARD_TRAVERSALS
+#endif // BZ_PARTIAL_LOOP_UNROLL
+
+BZ_VECTOR_ASSIGN(+=)
+BZ_VECTOR_ASSIGN(-=)
+BZ_VECTOR_ASSIGN(*=)
+BZ_VECTOR_ASSIGN(/=)
+BZ_VECTOR_ASSIGN(%=)
+BZ_VECTOR_ASSIGN(^=)
+BZ_VECTOR_ASSIGN(&=)
+BZ_VECTOR_ASSIGN(|=)
+BZ_VECTOR_ASSIGN(>>=)
+BZ_VECTOR_ASSIGN(<<=)
+
+#if NOT_DEFINED
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator+=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_plus_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator-=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_minus_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator*=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_multiply_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator/=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_divide_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator%=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_mod_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator^=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_xor_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator&=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_bitand_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator|=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_bitor_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator>>=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_shiftr_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+
+template<class P_numtype> template<class P_expr>
+inline Vector<P_numtype>& Vector<P_numtype>::operator<<=(_bz_VecExpr<P_expr> expr)
+{
+    _bz_assign(expr, _bz_shiftl_update<P_numtype,
+        _bz_typename P_expr::T_numtype>());
+    return *this;
+}
+#endif   // NOT_DEFINED
+
+/*****************************************************************************
+ * Assignment operators with scalar operand
+ */
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::initialize(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) = _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator+=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) += _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator-=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) -= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator*=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) *= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator/=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) /= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator%=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) %= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator^=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) ^= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator&=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) &= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator|=(P_numtype x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) |= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator>>=(int x)
+{
+    typedef _bz_VecExprConstant<int> T_expr;
+    (*this) >>= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator<<=(int x)
+{
+    typedef _bz_VecExprConstant<P_numtype> T_expr;
+    (*this) <<= _bz_VecExpr<T_expr>(T_expr(x));
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with vector operand
+ */
+
+// This version is for two vectors with the same template parameter.
+// Does not appear to be supported by the current C++ standard; or
+// is it?
+#if 0
+template<class P_numtype> template<>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator=(const Vector<P_numtype>& x)
+{
+    // NEEDS_WORK: if unit strides, use memcpy or something similar.
+
+    typedef VectorIterConst<P_numtype> T_expr;
+    (*this) = _bz_VecExpr<T_expr>(T_expr(*this));
+    return *this;
+}
+#endif
+
+// This version is for two vectors with *different* template
+// parameters.
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& 
+Vector<P_numtype>::operator=(const Vector<P_numtype2>& x)
+{
+    (*this) = _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator+=(const Vector<P_numtype2>& x)
+{
+    (*this) += _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator-=(const Vector<P_numtype2>& x)
+{
+    (*this) -= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator*=(const Vector<P_numtype2>& x)
+{
+    (*this) *= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator/=(const Vector<P_numtype2>& x)
+{
+    (*this) /= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator%=(const Vector<P_numtype2>& x)
+{
+    (*this) %= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator^=(const Vector<P_numtype2>& x)
+{
+    (*this) ^= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator&=(const Vector<P_numtype2>& x)
+{
+    (*this) &= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator|=(const Vector<P_numtype2>& x)
+{
+    (*this) |= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator<<=(const Vector<P_numtype2>& x)
+{
+    (*this) <<= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>&
+Vector<P_numtype>::operator>>=(const Vector<P_numtype2>& x)
+{
+    (*this) >>= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with Range operand
+ */
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator=(Range r)
+{
+    (*this) = _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator+=(Range r)
+{
+    (*this) += _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator-=(Range r)
+{
+    (*this) -= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator*=(Range r)
+{
+    (*this) *= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator/=(Range r)
+{
+    (*this) /= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator%=(Range r)
+{
+    (*this) %= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator^=(Range r)
+{
+    (*this) ^= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator&=(Range r)
+{
+    (*this) &= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator|=(Range r)
+{
+    (*this) |= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator>>=(Range r)
+{
+    (*this) >>= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+template<class P_numtype>
+inline Vector<P_numtype>& Vector<P_numtype>::operator<<=(Range r)
+{
+    (*this) <<= _bz_VecExpr<Range>(r);
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with VectorPick operand
+ */
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& Vector<P_numtype>::operator=(const 
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) = _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& Vector<P_numtype>::operator+=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) += _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& Vector<P_numtype>::operator-=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) -= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& Vector<P_numtype>::operator*=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) *= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& Vector<P_numtype>::operator/=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) /= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& Vector<P_numtype>::operator%=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) %= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& Vector<P_numtype>::operator^=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) ^= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& Vector<P_numtype>::operator&=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) &= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+template<class P_numtype> template<class P_numtype2>
+inline Vector<P_numtype>& Vector<P_numtype>::operator|=(const
+    VectorPick<P_numtype2>& x)
+{
+    typedef VectorPickIterConst<P_numtype2> T_expr;
+    (*this) |= _bz_VecExpr<T_expr>(x.begin());
+    return *this;
+}
+
+/*****************************************************************************
+ * Assignment operators with Random operand
+ */
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator=(Random<P_distribution>& rand)
+{
+    for (int i=0; i < length_; ++i) 
+        (*this)[i] = rand.random();
+    return *this;
+}
+
+#ifdef BZ_PECULIAR_RANDOM_VECTOR_ASSIGN_BUG
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator=(Random<P_distribution>& rand)
+{
+    (*this) = _bz_VecExpr<_bz_VecExprRandom<P_distribution> > 
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator+=(Random<P_distribution>& rand)
+{
+    (*this) += _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator-=(Random<P_distribution>& rand)
+{
+    (*this) -= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator*=(Random<P_distribution>& rand)
+{
+    (*this) *= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator/=(Random<P_distribution>& rand)
+{
+    (*this) /= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator%=(Random<P_distribution>& rand)
+{
+    (*this) %= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator^=(Random<P_distribution>& rand)
+{
+    (*this) ^= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator&=(Random<P_distribution>& rand)
+{
+    (*this) &= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+template<class P_numtype> template<class P_distribution>
+Vector<P_numtype>& Vector<P_numtype>::operator|=(Random<P_distribution>& rand)
+{
+    (*this) |= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
+        (_bz_VecExprRandom<P_distribution>(rand));
+    return *this;
+}
+
+#endif // BZ_PECULIAR_RANDOM_VECTOR_ASSIGN_BUG
+
+BZ_NAMESPACE_END
+
+#endif // BZ_VECTOR_CC
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vector.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vector.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vector.h	(revision 1307)
@@ -0,0 +1,495 @@
+/***************************************************************************
+ * blitz/vector.h      Declaration of the Vector<P_numtype> class
+ *
+ * $Id: vector.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.8  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.7  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.6  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.5  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.4  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.3  1996/11/11 17:29:13  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.2  1996/10/31 21:06:54  tveldhui
+ * Did away with multiple template parameters.
+ */
+
+/*
+ * KNOWN BUGS
+ *
+ * 1. operator[](Vector<int>) won't match; compiler complains of no
+ *       suitable copy constructor for VectorPick<T>
+ * 2. Vector<T>(_bz_VecExpr<E>) constructor generates warning
+ * 3. operator+=,-=,..etc.(Random<D>) won't match; compiler complains of
+ *       no suitable copy constructor for _bz_VecExpr(...).
+ */
+
+#ifndef BZ_VECTOR_H
+#define BZ_VECTOR_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+#ifndef BZ_MEMBLOCK_H
+ #include <blitz/memblock.h>
+#endif
+
+#ifndef BZ_RANGE_H
+ #include <blitz/range.h>
+#endif
+
+#ifndef BZ_LISTINIT_H
+ #include <blitz/listinit.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+// Forward declarations
+template<class P_numtype> class VectorIter;
+template<class P_numtype> class VectorIterConst;
+template<class P_expr>    class _bz_VecExpr;       
+template<class P_numtype> class VectorPick;
+template<class P_numtype> class Random;
+
+// Declaration of class Vector<P_numtype>
+
+template<class P_numtype>
+class Vector : protected MemoryBlockReference<P_numtype> {
+
+public:
+    //////////////////////////////////////////////
+    // Public Types
+    //////////////////////////////////////////////
+
+    typedef P_numtype                  T_numtype;
+    typedef Vector<T_numtype>          T_vector;
+    typedef VectorIter<T_numtype>      T_iterator;
+    typedef VectorIterConst<T_numtype> T_constIterator;
+    typedef VectorPick<T_numtype>      T_pick;
+    typedef Vector<int>                T_indexVector;
+
+    //////////////////////////////////////////////
+    // Constructors                             //
+    //////////////////////////////////////////////
+    // Most of the constructors are inlined so that
+    // the setting of the stride_ data member will
+    // be visible to the optimizer.
+
+    Vector()
+    { 
+        length_ = 0;
+        stride_ = 0;
+    }
+
+    // This constructor is provided inline because it involves
+    // no memory allocation.
+    Vector(Vector<T_numtype>& vec)
+        : MemoryBlockReference<T_numtype>(vec)
+    {
+        length_ = vec.length_;
+        stride_ = vec.stride_;
+    }
+
+    // Slightly unsafe cast-away-const version
+    Vector(const Vector<T_numtype>& vec)
+        : MemoryBlockReference<T_numtype>
+           (const_cast<Vector<T_numtype>& >(vec))
+    {
+        length_ = vec.length_;
+        stride_ = vec.stride_;
+    }
+
+    _bz_explicit Vector(int length)
+        : MemoryBlockReference<T_numtype>(length)
+    {
+        length_ = length;
+        stride_ = 1;
+    }
+
+    Vector(Vector<T_numtype>& vec, Range r)
+        : MemoryBlockReference<T_numtype>(vec, 
+            r.first() * vec.stride())
+    {
+        BZPRECONDITION((r.first() >= 0) && (r.first() < vec.length()));
+        BZPRECONDITION((r.last(vec.length()-1) >= 0) 
+            && (r.last(vec.length()-1) < vec.length()));
+        length_ = (r.last(vec.length()-1) - r.first()) / r.stride() + 1;
+        stride_ = vec.stride_ * r.stride();
+    }
+
+    Vector(int length, T_numtype initValue)
+        : MemoryBlockReference<T_numtype>(length)
+    {
+        length_ = length;
+        stride_ = 1;
+        (*this) = initValue;
+    }
+
+    Vector(int length, T_numtype firstValue, T_numtype delta)
+        : MemoryBlockReference<T_numtype>(length)
+    {
+        length_ = length;
+        stride_ = 1;
+        for (int i=0; i < length; ++i)
+            data_[i] = firstValue + i * delta;
+    }
+
+    template<class P_distribution>
+    Vector(int length, Random<P_distribution>& random)
+        : MemoryBlockReference<T_numtype>(length)
+    {
+        length_ = length;
+        stride_ = 1;
+        (*this) = random;
+    }
+
+    template<class P_expr>
+    Vector(_bz_VecExpr<P_expr> expr)
+        : MemoryBlockReference<T_numtype>(expr._bz_suggestLength())
+    {
+        length_ = expr._bz_suggestLength();
+        stride_ = 1;
+        (*this) = expr;
+    }
+
+    // Create a vector view of an already allocated block of memory.
+    // Note that the memory will not be freed when this vector is
+    // destroyed.
+    Vector(int length, T_numtype* _bz_restrict data, int stride = 1)
+        : MemoryBlockReference<T_numtype>(length, data)
+    {
+        length_ = length;
+        stride_ = stride;
+    }
+
+    // Create a vector containing a range of numbers
+    Vector(Range r)
+        : MemoryBlockReference<T_numtype>(r._bz_suggestLength())
+    {
+        length_ = r._bz_suggestLength();
+        stride_ = 1;
+        (*this) = _bz_VecExpr<Range>(r);
+    }
+    
+    //////////////////////////////////////////////
+    // Member functions
+    //////////////////////////////////////////////
+
+    // assertUnitStride() is provided as an optimizing trick.  When
+    // vectors are constructed outside the function scope, the optimizer
+    // is unaware that they have unit stride.  This function sets the
+    // stride to 1 in the local scope so the optimizer can do copy
+    // propagation & dead code elimination.  Obviously, you don't
+    // want to use this routine unless you are certain that the
+    // vectors have unit stride.
+    void            assertUnitStride()
+    {
+        BZPRECONDITION(stride_ == 1);
+        stride_ = 1;
+    }
+
+    T_iterator      begin()
+    { return T_iterator(*this); }
+
+    T_constIterator begin()  const
+    { return T_constIterator(*this); }
+
+    T_vector        copy()   const;
+
+    // T_iterator      end();
+    // T_constIterator end()    const;
+
+    T_numtype * _bz_restrict data()  
+    { return data_; }
+
+    const T_numtype * _bz_restrict data() const
+    { return data_; }
+
+    _bz_bool        isUnitStride() const
+    { return stride_ == 1; }
+
+    int        length() const
+    { return length_; }
+
+    void            makeUnique();
+
+    // int        storageSize() const;
+
+    // void            storeToBuffer(void* buffer, int bufferLength) const;
+
+    void            reference(T_vector&);
+
+    void            resize(int length);
+
+    void            resizeAndPreserve(int newLength);
+
+    // int             restoreFromBuffer(void* buffer, int bufferLength);
+
+    T_vector        reverse()
+    { return T_vector(*this,Range(length()-1,0,-1)); }
+
+    int             stride() const
+    { return stride_; }
+
+    operator _bz_VecExpr<VectorIterConst<T_numtype> > () const
+    { return _bz_VecExpr<VectorIterConst<T_numtype> >(begin()); }
+
+    /////////////////////////////////////////////
+    // Library-internal member functions
+    // These are undocumented and may change or
+    // disappear in future releases.
+    /////////////////////////////////////////////
+
+    int        _bz_suggestLength() const
+    { return length_; }
+
+    _bz_bool        _bz_hasFastAccess() const
+    { return stride_ == 1; }
+
+    T_numtype&      _bz_fastAccess(int i)
+    { return data_[i]; }
+
+    T_numtype       _bz_fastAccess(int i) const
+    { return data_[i]; }
+
+    template<class P_expr, class P_updater>
+    void            _bz_assign(P_expr, P_updater);
+
+    _bz_VecExpr<T_constIterator> _bz_asVecExpr() const
+    { return _bz_VecExpr<T_constIterator>(begin()); }
+
+    //////////////////////////////////////////////
+    // Subscripting operators
+    //////////////////////////////////////////////
+
+    // operator()(int) may be used only when the vector has unit
+    // stride.  Otherwise, use operator[].
+    T_numtype        operator()(int i) const
+    {
+        BZPRECONDITION(i < length_);
+        BZPRECONDITION(stride_ == 1);
+        return data_[i];
+    }
+
+    // operator()(int) may be used only when the vector has unit
+    // stride.  Otherwise, use operator[].
+    T_numtype& _bz_restrict operator()(int i) 
+    {
+        BZPRECONDITION(i < length_);
+        BZPRECONDITION(stride_ == 1);
+        return data_[i];
+    }
+
+    T_numtype        operator[](int i) const
+    {
+        BZPRECONDITION(i < length_);
+        return data_[i * stride_];
+    }
+
+    T_numtype& _bz_restrict operator[](int i)
+    {
+        BZPRECONDITION(i < length_);
+        return data_[i * stride_];
+    }
+
+    T_vector      operator()(Range r)
+    {
+        return T_vector(*this, r);
+    }
+
+    T_vector      operator[](Range r)
+    {
+        return T_vector(*this, r);
+    }
+
+    T_pick        operator()(T_indexVector i)
+    {
+        return T_pick(*this, i);
+    }
+
+    T_pick        operator[](T_indexVector i)
+    {
+        return T_pick(*this, i);
+    }
+
+    // T_vector      operator()(difference-equation-expression)
+
+    //////////////////////////////////////////////
+    // Assignment operators
+    //////////////////////////////////////////////
+
+    // Scalar operand
+    ListInitializationSwitch<T_vector,T_iterator> operator=(T_numtype x)
+    {
+        return ListInitializationSwitch<T_vector,T_iterator>(*this, x);
+    }
+
+    T_iterator getInitializationIterator()
+    { return begin(); }
+
+    T_vector& initialize(T_numtype);
+    T_vector& operator+=(T_numtype);
+    T_vector& operator-=(T_numtype);
+    T_vector& operator*=(T_numtype);
+    T_vector& operator/=(T_numtype);
+    T_vector& operator%=(T_numtype);
+    T_vector& operator^=(T_numtype);
+    T_vector& operator&=(T_numtype);
+    T_vector& operator|=(T_numtype);
+    T_vector& operator>>=(int);
+    T_vector& operator<<=(int); 
+
+    // Vector operand
+   
+    template<class P_numtype2> T_vector& operator=(const Vector<P_numtype2> &);
+
+    // Specialization uses memcpy instead of element-by-element cast and
+    // copy
+    // NEEDS_WORK -- KCC won't accept this syntax; standard??
+    // template<> T_vector& operator=(const T_vector&);
+
+    template<class P_numtype2> T_vector& operator+=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator-=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator*=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator/=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator%=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator^=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator&=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator|=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator>>=(const Vector<P_numtype2> &);
+    template<class P_numtype2> T_vector& operator<<=(const Vector<P_numtype2> &);
+
+    // Vector expression operand
+    template<class P_expr> T_vector& operator=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator+=(_bz_VecExpr<P_expr>); 
+    template<class P_expr> T_vector& operator-=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator*=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator/=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator%=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator^=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator&=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator|=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator>>=(_bz_VecExpr<P_expr>);
+    template<class P_expr> T_vector& operator<<=(_bz_VecExpr<P_expr>);
+    
+    // VectorPick operand
+    template<class P_numtype2> 
+    T_vector& operator=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_vector& operator+=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_vector& operator-=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_vector& operator*=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2> 
+    T_vector& operator/=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator%=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator^=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator&=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator|=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator>>=(const VectorPick<P_numtype2> &);
+    template<class P_numtype2>
+    T_vector& operator<<=(const VectorPick<P_numtype2> &);
+
+    // Range operand
+    T_vector& operator=(Range);
+    T_vector& operator+=(Range);
+    T_vector& operator-=(Range);
+    T_vector& operator*=(Range);
+    T_vector& operator/=(Range);
+    T_vector& operator%=(Range);
+    T_vector& operator^=(Range);
+    T_vector& operator&=(Range);
+    T_vector& operator|=(Range);
+    T_vector& operator>>=(Range);
+    T_vector& operator<<=(Range);
+
+    // Random operand
+    template<class P_distribution>
+    T_vector& operator=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_vector& operator+=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_vector& operator-=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_vector& operator*=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_vector& operator/=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_vector& operator%=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_vector& operator^=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_vector& operator&=(Random<P_distribution>& random);
+    template<class P_distribution>
+    T_vector& operator|=(Random<P_distribution>& random);
+
+    //////////////////////////////////////////////
+    // Unary operators
+    //////////////////////////////////////////////
+
+//    T_vector& operator++();
+//    void operator++(int);
+//    T_vector& operator--();
+//    void operator--(int);
+    
+private:
+    int      length_;
+    int      stride_;
+};
+
+// Global I/O functions
+
+template<class P_numtype>
+ostream& operator<<(ostream& os, const Vector<P_numtype>& x);
+
+template<class P_expr>
+ostream& operator<<(ostream& os, _bz_VecExpr<P_expr> expr);
+
+BZ_NAMESPACE_END
+
+#include <blitz/veciter.h>          // Iterators
+#include <blitz/vecpick.h>          // VectorPick
+#include <blitz/vecexpr.h>          // Expression templates
+#include <blitz/vecglobs.h>         // Global functions
+#include <blitz/vector.cc>          // Member functions
+#include <blitz/vecio.cc>           // IO functions
+
+#endif // BZ_VECTOR_H
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecuops.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecuops.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecuops.cc	(revision 1307)
@@ -0,0 +1,2818 @@
+/***************************************************************************
+ * blitz/vecuops.cc	Expression templates for vectors, unary functions
+ *
+ * $Id: vecuops.cc,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ */ 
+
+// Generated source file.  Do not edit. 
+// genvecuops.cpp Jun 10 1998 16:03:50
+
+#ifndef BZ_VECUOPS_CC
+#define BZ_VECUOPS_CC
+
+#ifndef BZ_VECEXPR_H
+ #error <blitz/vecuops.cc> must be included via <blitz/vecexpr.h>
+#endif // BZ_VECEXPR_H
+
+BZ_NAMESPACE(blitz)
+
+/****************************************************************************
+ * abs
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_abs<P_numtype1> > >
+abs(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_abs<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_abs<_bz_typename P_expr1::T_numtype> > >
+abs(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_abs<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_abs<P_numtype1> > >
+abs(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_abs<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_abs<int> > >
+abs(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_abs<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_abs<P_numtype1> > >
+abs(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_abs<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * acos
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_acos<P_numtype1> > >
+acos(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_acos<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_acos<_bz_typename P_expr1::T_numtype> > >
+acos(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_acos<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_acos<P_numtype1> > >
+acos(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_acos<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_acos<int> > >
+acos(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_acos<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_acos<P_numtype1> > >
+acos(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_acos<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * acosh
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_acosh<P_numtype1> > >
+acosh(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_acosh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_acosh<_bz_typename P_expr1::T_numtype> > >
+acosh(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_acosh<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_acosh<P_numtype1> > >
+acosh(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_acosh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_acosh<int> > >
+acosh(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_acosh<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_acosh<P_numtype1> > >
+acosh(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_acosh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * asin
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_asin<P_numtype1> > >
+asin(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_asin<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_asin<_bz_typename P_expr1::T_numtype> > >
+asin(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_asin<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_asin<P_numtype1> > >
+asin(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_asin<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_asin<int> > >
+asin(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_asin<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_asin<P_numtype1> > >
+asin(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_asin<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * asinh
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_asinh<P_numtype1> > >
+asinh(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_asinh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_asinh<_bz_typename P_expr1::T_numtype> > >
+asinh(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_asinh<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_asinh<P_numtype1> > >
+asinh(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_asinh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_asinh<int> > >
+asinh(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_asinh<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_asinh<P_numtype1> > >
+asinh(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_asinh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * atan
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_atan<P_numtype1> > >
+atan(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_atan<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_atan<_bz_typename P_expr1::T_numtype> > >
+atan(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_atan<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_atan<P_numtype1> > >
+atan(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_atan<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_atan<int> > >
+atan(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_atan<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_atan<P_numtype1> > >
+atan(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_atan<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * atanh
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_atanh<P_numtype1> > >
+atanh(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_atanh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_atanh<_bz_typename P_expr1::T_numtype> > >
+atanh(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_atanh<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_atanh<P_numtype1> > >
+atanh(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_atanh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_atanh<int> > >
+atanh(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_atanh<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_atanh<P_numtype1> > >
+atanh(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_atanh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * _class
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSV_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz__class<P_numtype1> > >
+_class(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz__class<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz__class<_bz_typename P_expr1::T_numtype> > >
+_class(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz__class<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz__class<P_numtype1> > >
+_class(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz__class<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz__class<int> > >
+_class(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz__class<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz__class<P_numtype1> > >
+_class(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz__class<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * cbrt
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_cbrt<P_numtype1> > >
+cbrt(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_cbrt<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_cbrt<_bz_typename P_expr1::T_numtype> > >
+cbrt(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_cbrt<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_cbrt<P_numtype1> > >
+cbrt(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_cbrt<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_cbrt<int> > >
+cbrt(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_cbrt<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_cbrt<P_numtype1> > >
+cbrt(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_cbrt<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * ceil
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_ceil<P_numtype1> > >
+ceil(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_ceil<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_ceil<_bz_typename P_expr1::T_numtype> > >
+ceil(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_ceil<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_ceil<P_numtype1> > >
+ceil(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_ceil<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_ceil<int> > >
+ceil(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_ceil<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_ceil<P_numtype1> > >
+ceil(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_ceil<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * cos
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_cos<P_numtype1> > >
+cos(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_cos<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_cos<_bz_typename P_expr1::T_numtype> > >
+cos(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_cos<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_cos<P_numtype1> > >
+cos(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_cos<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_cos<int> > >
+cos(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_cos<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_cos<P_numtype1> > >
+cos(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_cos<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * cosh
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_cosh<P_numtype1> > >
+cosh(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_cosh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_cosh<_bz_typename P_expr1::T_numtype> > >
+cosh(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_cosh<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_cosh<P_numtype1> > >
+cosh(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_cosh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_cosh<int> > >
+cosh(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_cosh<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_cosh<P_numtype1> > >
+cosh(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_cosh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * exp
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_exp<P_numtype1> > >
+exp(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_exp<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_exp<_bz_typename P_expr1::T_numtype> > >
+exp(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_exp<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_exp<P_numtype1> > >
+exp(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_exp<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_exp<int> > >
+exp(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_exp<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_exp<P_numtype1> > >
+exp(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_exp<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * expm1
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_expm1<P_numtype1> > >
+expm1(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_expm1<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_expm1<_bz_typename P_expr1::T_numtype> > >
+expm1(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_expm1<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_expm1<P_numtype1> > >
+expm1(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_expm1<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_expm1<int> > >
+expm1(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_expm1<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_expm1<P_numtype1> > >
+expm1(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_expm1<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * erf
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_erf<P_numtype1> > >
+erf(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_erf<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_erf<_bz_typename P_expr1::T_numtype> > >
+erf(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_erf<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_erf<P_numtype1> > >
+erf(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_erf<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_erf<int> > >
+erf(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_erf<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_erf<P_numtype1> > >
+erf(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_erf<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * erfc
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_erfc<P_numtype1> > >
+erfc(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_erfc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_erfc<_bz_typename P_expr1::T_numtype> > >
+erfc(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_erfc<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_erfc<P_numtype1> > >
+erfc(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_erfc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_erfc<int> > >
+erfc(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_erfc<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_erfc<P_numtype1> > >
+erfc(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_erfc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * fabs
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_abs<P_numtype1> > >
+fabs(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_abs<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_abs<_bz_typename P_expr1::T_numtype> > >
+fabs(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_abs<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_abs<P_numtype1> > >
+fabs(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_abs<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_abs<int> > >
+fabs(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_abs<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_abs<P_numtype1> > >
+fabs(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_abs<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * finite
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_finite<P_numtype1> > >
+finite(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_finite<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_finite<_bz_typename P_expr1::T_numtype> > >
+finite(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_finite<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_finite<P_numtype1> > >
+finite(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_finite<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_finite<int> > >
+finite(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_finite<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_finite<P_numtype1> > >
+finite(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_finite<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * floor
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_floor<P_numtype1> > >
+floor(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_floor<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_floor<_bz_typename P_expr1::T_numtype> > >
+floor(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_floor<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_floor<P_numtype1> > >
+floor(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_floor<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_floor<int> > >
+floor(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_floor<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_floor<P_numtype1> > >
+floor(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_floor<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * ilogb
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSV_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_ilogb<P_numtype1> > >
+ilogb(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_ilogb<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_ilogb<_bz_typename P_expr1::T_numtype> > >
+ilogb(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_ilogb<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_ilogb<P_numtype1> > >
+ilogb(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_ilogb<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_ilogb<int> > >
+ilogb(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_ilogb<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_ilogb<P_numtype1> > >
+ilogb(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_ilogb<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * isnan
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_isnan<P_numtype1> > >
+isnan(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_isnan<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_isnan<_bz_typename P_expr1::T_numtype> > >
+isnan(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_isnan<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_isnan<P_numtype1> > >
+isnan(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_isnan<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_isnan<int> > >
+isnan(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_isnan<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_isnan<P_numtype1> > >
+isnan(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_isnan<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * itrunc
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSV_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_itrunc<P_numtype1> > >
+itrunc(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_itrunc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_itrunc<_bz_typename P_expr1::T_numtype> > >
+itrunc(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_itrunc<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_itrunc<P_numtype1> > >
+itrunc(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_itrunc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_itrunc<int> > >
+itrunc(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_itrunc<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_itrunc<P_numtype1> > >
+itrunc(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_itrunc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * j0
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_j0<P_numtype1> > >
+j0(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_j0<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_j0<_bz_typename P_expr1::T_numtype> > >
+j0(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_j0<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_j0<P_numtype1> > >
+j0(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_j0<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_j0<int> > >
+j0(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_j0<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_j0<P_numtype1> > >
+j0(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_j0<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * j1
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_j1<P_numtype1> > >
+j1(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_j1<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_j1<_bz_typename P_expr1::T_numtype> > >
+j1(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_j1<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_j1<P_numtype1> > >
+j1(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_j1<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_j1<int> > >
+j1(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_j1<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_j1<P_numtype1> > >
+j1(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_j1<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * lgamma
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_lgamma<P_numtype1> > >
+lgamma(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_lgamma<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_lgamma<_bz_typename P_expr1::T_numtype> > >
+lgamma(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_lgamma<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_lgamma<P_numtype1> > >
+lgamma(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_lgamma<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_lgamma<int> > >
+lgamma(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_lgamma<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_lgamma<P_numtype1> > >
+lgamma(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_lgamma<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * log
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_log<P_numtype1> > >
+log(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_log<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_log<_bz_typename P_expr1::T_numtype> > >
+log(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_log<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_log<P_numtype1> > >
+log(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_log<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_log<int> > >
+log(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_log<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_log<P_numtype1> > >
+log(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_log<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * logb
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_logb<P_numtype1> > >
+logb(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_logb<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_logb<_bz_typename P_expr1::T_numtype> > >
+logb(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_logb<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_logb<P_numtype1> > >
+logb(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_logb<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_logb<int> > >
+logb(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_logb<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_logb<P_numtype1> > >
+logb(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_logb<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * log1p
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_log1p<P_numtype1> > >
+log1p(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_log1p<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_log1p<_bz_typename P_expr1::T_numtype> > >
+log1p(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_log1p<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_log1p<P_numtype1> > >
+log1p(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_log1p<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_log1p<int> > >
+log1p(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_log1p<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_log1p<P_numtype1> > >
+log1p(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_log1p<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * log10
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_log10<P_numtype1> > >
+log10(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_log10<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_log10<_bz_typename P_expr1::T_numtype> > >
+log10(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_log10<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_log10<P_numtype1> > >
+log10(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_log10<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_log10<int> > >
+log10(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_log10<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_log10<P_numtype1> > >
+log10(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_log10<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * nearest
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSV_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_nearest<P_numtype1> > >
+nearest(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_nearest<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_nearest<_bz_typename P_expr1::T_numtype> > >
+nearest(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_nearest<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_nearest<P_numtype1> > >
+nearest(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_nearest<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_nearest<int> > >
+nearest(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_nearest<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_nearest<P_numtype1> > >
+nearest(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_nearest<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * rint
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_rint<P_numtype1> > >
+rint(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_rint<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_rint<_bz_typename P_expr1::T_numtype> > >
+rint(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_rint<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_rint<P_numtype1> > >
+rint(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_rint<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_rint<int> > >
+rint(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_rint<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_rint<P_numtype1> > >
+rint(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_rint<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * rsqrt
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSV_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_rsqrt<P_numtype1> > >
+rsqrt(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_rsqrt<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_rsqrt<_bz_typename P_expr1::T_numtype> > >
+rsqrt(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_rsqrt<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_rsqrt<P_numtype1> > >
+rsqrt(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_rsqrt<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_rsqrt<int> > >
+rsqrt(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_rsqrt<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_rsqrt<P_numtype1> > >
+rsqrt(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_rsqrt<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * sin
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_sin<P_numtype1> > >
+sin(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_sin<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_sin<_bz_typename P_expr1::T_numtype> > >
+sin(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_sin<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_sin<P_numtype1> > >
+sin(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_sin<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_sin<int> > >
+sin(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_sin<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_sin<P_numtype1> > >
+sin(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_sin<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * sinh
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_sinh<P_numtype1> > >
+sinh(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_sinh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_sinh<_bz_typename P_expr1::T_numtype> > >
+sinh(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_sinh<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_sinh<P_numtype1> > >
+sinh(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_sinh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_sinh<int> > >
+sinh(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_sinh<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_sinh<P_numtype1> > >
+sinh(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_sinh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * sqr
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_sqr<P_numtype1> > >
+sqr(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_sqr<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_sqr<_bz_typename P_expr1::T_numtype> > >
+sqr(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_sqr<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_sqr<P_numtype1> > >
+sqr(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_sqr<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_sqr<int> > >
+sqr(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_sqr<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_sqr<P_numtype1> > >
+sqr(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_sqr<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * sqrt
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_sqrt<P_numtype1> > >
+sqrt(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_sqrt<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_sqrt<_bz_typename P_expr1::T_numtype> > >
+sqrt(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_sqrt<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_sqrt<P_numtype1> > >
+sqrt(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_sqrt<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_sqrt<int> > >
+sqrt(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_sqrt<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_sqrt<P_numtype1> > >
+sqrt(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_sqrt<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * tan
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_tan<P_numtype1> > >
+tan(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_tan<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_tan<_bz_typename P_expr1::T_numtype> > >
+tan(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_tan<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_tan<P_numtype1> > >
+tan(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_tan<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_tan<int> > >
+tan(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_tan<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_tan<P_numtype1> > >
+tan(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_tan<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * tanh
+ ****************************************************************************/
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_tanh<P_numtype1> > >
+tanh(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_tanh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_tanh<_bz_typename P_expr1::T_numtype> > >
+tanh(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_tanh<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_tanh<P_numtype1> > >
+tanh(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_tanh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_tanh<int> > >
+tanh(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_tanh<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_tanh<P_numtype1> > >
+tanh(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_tanh<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+/****************************************************************************
+ * trunc
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_trunc<P_numtype1> > >
+trunc(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_trunc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_trunc<_bz_typename P_expr1::T_numtype> > >
+trunc(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_trunc<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_trunc<P_numtype1> > >
+trunc(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_trunc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_trunc<int> > >
+trunc(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_trunc<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_trunc<P_numtype1> > >
+trunc(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_trunc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * uitrunc
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_SYSV_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_uitrunc<P_numtype1> > >
+uitrunc(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_uitrunc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_uitrunc<_bz_typename P_expr1::T_numtype> > >
+uitrunc(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_uitrunc<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_uitrunc<P_numtype1> > >
+uitrunc(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_uitrunc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_uitrunc<int> > >
+uitrunc(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_uitrunc<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_uitrunc<P_numtype1> > >
+uitrunc(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_uitrunc<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * y0
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_y0<P_numtype1> > >
+y0(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_y0<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_y0<_bz_typename P_expr1::T_numtype> > >
+y0(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_y0<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_y0<P_numtype1> > >
+y0(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_y0<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_y0<int> > >
+y0(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_y0<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_y0<P_numtype1> > >
+y0(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_y0<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+/****************************************************************************
+ * y1
+ ****************************************************************************/
+
+#ifdef BZ_HAVE_IEEE_MATH
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+    _bz_y1<P_numtype1> > >
+y1(const Vector<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorIterConst<P_numtype1>,
+        _bz_y1<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+    _bz_y1<_bz_typename P_expr1::T_numtype> > >
+y1(_bz_VecExpr<P_expr1> d1)
+{
+    typedef _bz_VecExprUnaryOp<_bz_VecExpr<P_expr1>,
+        _bz_y1<_bz_typename P_expr1::T_numtype> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+    _bz_y1<P_numtype1> > >
+y1(const VectorPick<P_numtype1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<VectorPickIterConst<P_numtype1>,
+        _bz_y1<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<Range,
+    _bz_y1<int> > >
+y1(Range d1)
+{
+    typedef _bz_VecExprUnaryOp<Range,
+        _bz_y1<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1));
+}
+
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+    _bz_y1<P_numtype1> > >
+y1(const TinyVector<P_numtype1, N_length1>& d1)
+{
+    typedef _bz_VecExprUnaryOp<TinyVectorIterConst<P_numtype1, N_length1>,
+        _bz_y1<P_numtype1> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin()));
+}
+
+#endif
+
+BZ_NAMESPACE_END
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecwhere.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecwhere.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecwhere.cc	(revision 1307)
@@ -0,0 +1,7744 @@
+/***************************************************************************
+ * blitz/vecwhere.cc	where(X,Y,Z) function for vectors
+ *
+ * $Id: vecwhere.cc,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.   Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ * Licensing inquiries:  blitz-licenses@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.1  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ */ 
+
+// Generated source file.  Do not edit. 
+// genvecwhere.cpp Feb  5 1997 09:52:29
+
+#ifndef BZ_VECWHERE_CC
+#define BZ_VECWHERE_CC
+
+BZ_NAMESPACE(blitz)
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, Range)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, int)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, float)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, double)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, long double)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Vector<P_numtype1>, Vector<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const Vector<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, Vector<P_numtype3>)
+template<class P_numtype1, class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, Range)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_expr2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, int)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, float)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, double)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, long double)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Vector<P_numtype1>, _bz_VecExpr<P_expr2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class P_expr2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const Vector<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, Range)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, int)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, float)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, double)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, long double)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Vector<P_numtype1>, VectorPick<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const Vector<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, Range, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, Range, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(Vector<P_numtype1>, Range, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, Range, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(Vector<P_numtype1>, Range, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, Range, int)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<int> > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Vector<P_numtype1>, Range, float)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<float> > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Vector<P_numtype1>, Range, double)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<double> > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Vector<P_numtype1>, Range, long double)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<long double> > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Vector<P_numtype1>, Range, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const Vector<P_numtype1>& d1, 
+      Range d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_numtype2, int N_length2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, Range)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype2, int N_length2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, int)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, float)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, double)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, long double)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Vector<P_numtype1>, TinyVector<P_numtype2, N_length2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class P_numtype2, int N_length2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const Vector<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, int, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      int d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, int, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      int d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, int, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      int d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, int, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      int d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, int, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      int d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, int, int)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > >
+where(const Vector<P_numtype1>& d1, 
+      int d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Vector<P_numtype1>, float, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      float d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, float, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      float d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, float, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      float d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, float, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      float d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, float, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      float d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, float, float)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > >
+where(const Vector<P_numtype1>& d1, 
+      float d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Vector<P_numtype1>, double, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, double, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, double, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, double, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, double, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, double, double)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > >
+where(const Vector<P_numtype1>& d1, 
+      double d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Vector<P_numtype1>, long double, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      long double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, long double, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      long double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, long double, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      long double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, long double, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      long double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(Vector<P_numtype1>, long double, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      long double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(Vector<P_numtype1>, long double, long double)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > >
+where(const Vector<P_numtype1>& d1, 
+      long double d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Vector<P_numtype1>, complex<T2>, Vector<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      complex<T2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, complex<T2>, _bz_VecExpr<P_expr3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > >
+where(const Vector<P_numtype1>& d1, 
+      complex<T2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, complex<T2>, VectorPick<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > >
+where(const Vector<P_numtype1>& d1, 
+      complex<T2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, complex<T2>, Range)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > >
+where(const Vector<P_numtype1>& d1, 
+      complex<T2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, complex<T2>, TinyVector<P_numtype3, N_length3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const Vector<P_numtype1>& d1, 
+      complex<T2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Vector<P_numtype1>, complex<T2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const Vector<P_numtype1>& d1, 
+      complex<T2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, Vector<P_numtype3>)
+template<class P_expr1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_expr1, class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_expr1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, Range)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_expr1, class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, int)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, float)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, double)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, long double)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, Vector<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const Vector<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, Vector<P_numtype3>)
+template<class P_expr1, class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, _bz_VecExpr<P_expr3>)
+template<class P_expr1, class P_expr2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, VectorPick<P_numtype3>)
+template<class P_expr1, class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, Range)
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, TinyVector<P_numtype3, N_length3>)
+template<class P_expr1, class P_expr2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, int)
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, float)
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, double)
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, long double)
+template<class P_expr1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, _bz_VecExpr<P_expr2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class P_expr2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(_bz_VecExpr<P_expr1> d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, Vector<P_numtype3>)
+template<class P_expr1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_expr1, class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_expr1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, Range)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_expr1, class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, int)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, float)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, double)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, long double)
+template<class P_expr1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, VectorPick<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const VectorPick<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, Range, Vector<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, Range, _bz_VecExpr<P_expr3>)
+template<class P_expr1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, Range, VectorPick<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, Range, Range)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, Range, TinyVector<P_numtype3, N_length3>)
+template<class P_expr1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, Range, int)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<int> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, Range, float)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<float> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, Range, double)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, Range, long double)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<long double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, Range, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(_bz_VecExpr<P_expr1> d1, 
+      Range d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, Vector<P_numtype3>)
+template<class P_expr1, class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, _bz_VecExpr<P_expr3>)
+template<class P_expr1, class P_numtype2, int N_length2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, VectorPick<P_numtype3>)
+template<class P_expr1, class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, Range)
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, TinyVector<P_numtype3, N_length3>)
+template<class P_expr1, class P_numtype2, int N_length2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, int)
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, float)
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, double)
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, long double)
+template<class P_expr1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, TinyVector<P_numtype2, N_length2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class P_numtype2, int N_length2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(_bz_VecExpr<P_expr1> d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, int, Vector<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      int d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, int, _bz_VecExpr<P_expr3>)
+template<class P_expr1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      int d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, int, VectorPick<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      int d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, int, Range)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      int d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, int, TinyVector<P_numtype3, N_length3>)
+template<class P_expr1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      int d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, int, int)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      int d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, float, Vector<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      float d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, float, _bz_VecExpr<P_expr3>)
+template<class P_expr1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      float d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, float, VectorPick<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      float d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, float, Range)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      float d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, float, TinyVector<P_numtype3, N_length3>)
+template<class P_expr1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      float d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, float, float)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      float d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, double, Vector<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, double, _bz_VecExpr<P_expr3>)
+template<class P_expr1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, double, VectorPick<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, double, Range)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, double, TinyVector<P_numtype3, N_length3>)
+template<class P_expr1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, double, double)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      double d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, long double, Vector<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      long double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, long double, _bz_VecExpr<P_expr3>)
+template<class P_expr1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      long double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, long double, VectorPick<P_numtype3>)
+template<class P_expr1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      long double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, long double, Range)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      long double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(_bz_VecExpr<P_expr1>, long double, TinyVector<P_numtype3, N_length3>)
+template<class P_expr1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      long double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(_bz_VecExpr<P_expr1>, long double, long double)
+template<class P_expr1>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      long double d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(_bz_VecExpr<P_expr1>, complex<T2>, Vector<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, complex<T2>, _bz_VecExpr<P_expr3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, complex<T2>, VectorPick<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, complex<T2>, Range)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > >
+where(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, complex<T2>, TinyVector<P_numtype3, N_length3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(_bz_VecExpr<P_expr1>, complex<T2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr1, class T2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(_bz_VecExpr<P_expr1> d1, 
+      complex<T2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<_bz_VecExpr<P_expr1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, Range)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, int)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, float)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, double)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, long double)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, Vector<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const VectorPick<P_numtype1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, Vector<P_numtype3>)
+template<class P_numtype1, class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, Range)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_expr2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, int)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, float)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, double)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, long double)
+template<class P_numtype1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, _bz_VecExpr<P_expr2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class P_expr2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const VectorPick<P_numtype1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, Range)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, int)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, float)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, double)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, long double)
+template<class P_numtype1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, VectorPick<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const VectorPick<P_numtype1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, Range, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, Range, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, Range, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, Range, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, Range, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, Range, int)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<int> > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, Range, float)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<float> > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, Range, double)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, Range, long double)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<long double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, Range, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const VectorPick<P_numtype1>& d1, 
+      Range d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_numtype2, int N_length2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, Range)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype2, int N_length2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, int)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, float)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, double)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, long double)
+template<class P_numtype1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, TinyVector<P_numtype2, N_length2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class P_numtype2, int N_length2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const VectorPick<P_numtype1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, int, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      int d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, int, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      int d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, int, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      int d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, int, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      int d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, int, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      int d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, int, int)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > >
+where(const VectorPick<P_numtype1>& d1, 
+      int d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, float, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      float d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, float, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      float d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, float, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      float d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, float, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      float d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, float, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      float d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, float, float)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > >
+where(const VectorPick<P_numtype1>& d1, 
+      float d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, double, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, double, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, double, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, double, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, double, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, double, double)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      double d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, long double, Vector<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      long double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, long double, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      long double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, long double, VectorPick<P_numtype3>)
+template<class P_numtype1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      long double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, long double, Range)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      long double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(VectorPick<P_numtype1>, long double, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      long double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(VectorPick<P_numtype1>, long double, long double)
+template<class P_numtype1>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > >
+where(const VectorPick<P_numtype1>& d1, 
+      long double d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(VectorPick<P_numtype1>, complex<T2>, Vector<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, complex<T2>, _bz_VecExpr<P_expr3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, complex<T2>, VectorPick<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, complex<T2>, Range)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > >
+where(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, complex<T2>, TinyVector<P_numtype3, N_length3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(VectorPick<P_numtype1>, complex<T2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, class T2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const VectorPick<P_numtype1>& d1, 
+      complex<T2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<VectorPickIterConst<P_numtype1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, Vector<P_numtype2>, Vector<P_numtype3>)
+template<class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Range, Vector<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(Range, Vector<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Range, Vector<P_numtype2>, Range)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      Range > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(Range, Vector<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Range, Vector<P_numtype2>, int)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Range, Vector<P_numtype2>, float)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Range, Vector<P_numtype2>, double)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Range, Vector<P_numtype2>, long double)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Range, Vector<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(Range d1, 
+      const Vector<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, _bz_VecExpr<P_expr2>, Vector<P_numtype3>)
+template<class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(Range, _bz_VecExpr<P_expr2>, _bz_VecExpr<P_expr3>)
+template<class P_expr2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3));
+}
+
+// where(Range, _bz_VecExpr<P_expr2>, VectorPick<P_numtype3>)
+template<class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(Range, _bz_VecExpr<P_expr2>, Range)
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      Range > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3));
+}
+
+// where(Range, _bz_VecExpr<P_expr2>, TinyVector<P_numtype3, N_length3>)
+template<class P_expr2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(Range, _bz_VecExpr<P_expr2>, int)
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Range, _bz_VecExpr<P_expr2>, float)
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Range, _bz_VecExpr<P_expr2>, double)
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Range, _bz_VecExpr<P_expr2>, long double)
+template<class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Range, _bz_VecExpr<P_expr2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_expr2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(Range d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, VectorPick<P_numtype2>, Vector<P_numtype3>)
+template<class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Range, VectorPick<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(Range, VectorPick<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Range, VectorPick<P_numtype2>, Range)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(Range, VectorPick<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Range, VectorPick<P_numtype2>, int)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Range, VectorPick<P_numtype2>, float)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Range, VectorPick<P_numtype2>, double)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Range, VectorPick<P_numtype2>, long double)
+template<class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Range, VectorPick<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(Range d1, 
+      const VectorPick<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, Range, Vector<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      Range d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(Range, Range, _bz_VecExpr<P_expr3>)
+template<class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      Range d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3));
+}
+
+// where(Range, Range, VectorPick<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      Range d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(Range, Range, Range)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      Range > >
+where(Range d1, 
+      Range d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3));
+}
+
+// where(Range, Range, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      Range d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      d3.begin()));
+}
+
+// where(Range, Range, int)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<int> > >
+where(Range d1, 
+      Range d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Range, Range, float)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<float> > >
+where(Range d1, 
+      Range d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Range, Range, double)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<double> > >
+where(Range d1, 
+      Range d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Range, Range, long double)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<long double> > >
+where(Range d1, 
+      Range d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Range, Range, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(Range d1, 
+      Range d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, TinyVector<P_numtype2, N_length2>, Vector<P_numtype3>)
+template<class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Range, TinyVector<P_numtype2, N_length2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype2, int N_length2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(Range, TinyVector<P_numtype2, N_length2>, VectorPick<P_numtype3>)
+template<class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Range, TinyVector<P_numtype2, N_length2>, Range)
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3));
+}
+
+// where(Range, TinyVector<P_numtype2, N_length2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype2, int N_length2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(Range, TinyVector<P_numtype2, N_length2>, int)
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Range, TinyVector<P_numtype2, N_length2>, float)
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Range, TinyVector<P_numtype2, N_length2>, double)
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Range, TinyVector<P_numtype2, N_length2>, long double)
+template<class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Range, TinyVector<P_numtype2, N_length2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype2, int N_length2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(Range d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, int, Vector<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      int d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(Range, int, _bz_VecExpr<P_expr3>)
+template<class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      int d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(Range, int, VectorPick<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      int d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(Range, int, Range)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      Range > >
+where(Range d1, 
+      int d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(Range, int, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      int d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(Range, int, int)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > >
+where(Range d1, 
+      int d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<int>(d2), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(Range, float, Vector<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      float d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(Range, float, _bz_VecExpr<P_expr3>)
+template<class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      float d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(Range, float, VectorPick<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      float d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(Range, float, Range)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      Range > >
+where(Range d1, 
+      float d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(Range, float, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      float d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(Range, float, float)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > >
+where(Range d1, 
+      float d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<float>(d2), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(Range, double, Vector<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(Range, double, _bz_VecExpr<P_expr3>)
+template<class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(Range, double, VectorPick<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(Range, double, Range)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      Range > >
+where(Range d1, 
+      double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(Range, double, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(Range, double, double)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > >
+where(Range d1, 
+      double d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<double>(d2), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(Range, long double, Vector<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      long double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(Range, long double, _bz_VecExpr<P_expr3>)
+template<class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      long double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(Range, long double, VectorPick<P_numtype3>)
+template<class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      long double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(Range, long double, Range)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      Range > >
+where(Range d1, 
+      long double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(Range, long double, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      long double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(Range, long double, long double)
+
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > >
+where(Range d1, 
+      long double d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<long double>(d2), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(Range, complex<T2>, Vector<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > >
+where(Range d1, 
+      complex<T2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, complex<T2>, _bz_VecExpr<P_expr3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class T2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > >
+where(Range d1, 
+      complex<T2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, complex<T2>, VectorPick<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > >
+where(Range d1, 
+      complex<T2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, complex<T2>, Range)
+#ifdef BZ_HAVE_COMPLEX
+template<class T2>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > >
+where(Range d1, 
+      complex<T2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, complex<T2>, TinyVector<P_numtype3, N_length3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class T2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(Range d1, 
+      complex<T2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(Range, complex<T2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class T2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(Range d1, 
+      complex<T2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<Range, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1, 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, Vector<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, int N_length1, class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, Range)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, int N_length1, class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, int)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, float)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, double)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, long double)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Vector<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const Vector<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, Vector<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, int N_length1, class P_expr2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, VectorPick<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_expr2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, Range)
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, int N_length1, class P_expr2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, int)
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, float)
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, double)
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, long double)
+template<class P_numtype1, int N_length1, class P_expr2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, _bz_VecExpr<P_expr2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class P_expr2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      _bz_VecExpr<P_expr2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExpr<P_expr2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, Vector<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, int N_length1, class P_numtype2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, VectorPick<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, Range)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, int N_length1, class P_numtype2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, int)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, float)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, double)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, long double)
+template<class P_numtype1, int N_length1, class P_numtype2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, VectorPick<P_numtype2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class P_numtype2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const VectorPick<P_numtype2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      VectorPickIterConst<P_numtype2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, Range, Vector<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Range, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, int N_length1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Range, VectorPick<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Range, Range)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Range, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, int N_length1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Range, int)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<int> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Range, float)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<float> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Range, double)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Range, long double)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<long double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, Range, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      Range d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      Range, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2, 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, Vector<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, VectorPick<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, Range)
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, int)
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, float)
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, double)
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, long double)
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, TinyVector<P_numtype2, N_length2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class P_numtype2, int N_length2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      const TinyVector<P_numtype2, N_length2>& d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      TinyVectorIterConst<P_numtype2, N_length2>, 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      d2.begin(), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, int, Vector<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, int, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, int N_length1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, int, VectorPick<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, int, Range)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, int, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, int N_length1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, int, int)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      int d2, 
+      int d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<int>, 
+      _bz_VecExprConstant<int> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<int>(d2), 
+      _bz_VecExprConstant<int>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, float, Vector<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, float, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, int N_length1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, float, VectorPick<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, float, Range)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, float, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, int N_length1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, float, float)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      float d2, 
+      float d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<float>, 
+      _bz_VecExprConstant<float> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<float>(d2), 
+      _bz_VecExprConstant<float>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, double, Vector<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, double, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, int N_length1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, double, VectorPick<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, double, Range)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, double, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, int N_length1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, double, double)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      double d2, 
+      double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<double>, 
+      _bz_VecExprConstant<double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<double>(d2), 
+      _bz_VecExprConstant<double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, long double, Vector<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, long double, _bz_VecExpr<P_expr3>)
+template<class P_numtype1, int N_length1, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, long double, VectorPick<P_numtype3>)
+template<class P_numtype1, int N_length1, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, long double, Range)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, long double, TinyVector<P_numtype3, N_length3>)
+template<class P_numtype1, int N_length1, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      d3.begin()));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, long double, long double)
+template<class P_numtype1, int N_length1>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      long double d2, 
+      long double d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<long double>, 
+      _bz_VecExprConstant<long double> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<long double>(d2), 
+      _bz_VecExprConstant<long double>(d3)));
+}
+
+// where(TinyVector<P_numtype1, N_length1>, complex<T2>, Vector<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2, 
+      const Vector<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, complex<T2>, _bz_VecExpr<P_expr3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class T2, class P_expr3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2, 
+      _bz_VecExpr<P_expr3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExpr<P_expr3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, complex<T2>, VectorPick<P_numtype3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class T2, class P_numtype3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2, 
+      const VectorPick<P_numtype3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      VectorPickIterConst<P_numtype3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, complex<T2>, Range)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class T2>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2, 
+      Range d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      Range > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, complex<T2>, TinyVector<P_numtype3, N_length3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class T2, class P_numtype3, int N_length3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2, 
+      const TinyVector<P_numtype3, N_length3>& d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      TinyVectorIterConst<P_numtype3, N_length3> > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      d3.begin()));
+}
+#endif // BZ_HAVE_COMPLEX
+
+// where(TinyVector<P_numtype1, N_length1>, complex<T2>, complex<T3>)
+#ifdef BZ_HAVE_COMPLEX
+template<class P_numtype1, int N_length1, class T2, class T3>
+inline
+_bz_VecExpr<_bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > >
+where(const TinyVector<P_numtype1, N_length1>& d1, 
+      complex<T2> d2, 
+      complex<T3> d3)
+{ 
+    typedef _bz_VecWhere<TinyVectorIterConst<P_numtype1, N_length1>, 
+      _bz_VecExprConstant<complex<T2> > , 
+      _bz_VecExprConstant<complex<T3> >  > T_expr;
+
+    return _bz_VecExpr<T_expr>(T_expr(d1.begin(), 
+      _bz_VecExprConstant<complex<T2> > (d2), 
+      _bz_VecExprConstant<complex<T3> > (d3)));
+}
+#endif // BZ_HAVE_COMPLEX
+
+BZ_NAMESPACE_END
+
+#endif
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/vecwhere.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/vecwhere.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/vecwhere.h	(revision 1307)
@@ -0,0 +1,136 @@
+/***************************************************************************
+ * blitz/vecwhere.h      where(X,Y,Z) function for vectors
+ *
+ * $Id: vecwhere.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/23 03:28:28  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_VECWHERE_H 
+#define BZ_VECWHERE_H
+
+#ifndef BZ_VECEXPR_H
+ #error <blitz/vecwhere.h> must be included via <blitz/vector.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_expr1, class P_expr2, class P_expr3>
+class _bz_VecWhere {
+
+public:
+    typedef P_expr1 T_expr1;
+    typedef P_expr2 T_expr2;
+    typedef P_expr3 T_expr3;
+    typedef _bz_typename T_expr2::T_numtype T_numtype2;
+    typedef _bz_typename T_expr3::T_numtype T_numtype3;
+    typedef BZ_PROMOTE(T_numtype2, T_numtype3) T_numtype;
+
+#ifdef BZ_PASS_EXPR_BY_VALUE
+    _bz_VecWhere(T_expr1 a, T_expr2 b, T_expr3 c)
+        : iter1_(a), iter2_(b), iter3_(c)
+    { }
+#else
+    _bz_VecWhere(const T_expr1& a, const T_expr2& b, const T_expr3& c)
+        : iter1_(a), iter2_(b), iter3_(c)
+    { }
+#endif
+
+#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
+    _bz_VecWhere(const _bz_VecWhere<T_expr1, T_expr2, T_expr3>& x)
+        : iter1_(x.iter1_), iter2_(x.iter2_), iter3_(x.iter3_)
+    { }
+#endif
+
+    T_numtype operator[](int i) const
+    { 
+        return iter1_[i] ? iter2_[i] : iter3_[i];
+    }
+
+    enum {
+           _bz_staticLengthCount =
+      P_expr1::_bz_staticLengthCount + P_expr2::_bz_staticLengthCount
+         + P_expr3::_bz_staticLengthCount,
+
+           _bz_dynamicLengthCount =
+      P_expr1::_bz_dynamicLengthCount + P_expr2::_bz_dynamicLengthCount
+         + P_expr3::_bz_dynamicLengthCount,
+
+           _bz_staticLength =
+      _bz_meta_max<_bz_meta_max<P_expr1::_bz_staticLength, 
+            P_expr2::_bz_staticLength>::max, P_expr3::_bz_staticLength>::max
+    };
+
+    T_numtype _bz_fastAccess(int i) const
+    { 
+        return iter1_._bz_fastAccess(i) 
+            ? iter2_._bz_fastAccess(i) 
+            : iter3_._bz_fastAccess(i); 
+    }
+
+    _bz_bool _bz_hasFastAccess() const
+    {
+        return iter1_._bz_hasFastAccess() &&
+            iter2_._bz_hasFastAccess() &&
+            iter3_._bz_hasFastAccess();
+    }
+
+    int length(int recommendedLength) const
+    {
+        return iter1_.length(recommendedLength);
+    }
+
+    int _bz_suggestLength() const
+    {
+        BZPRECONDITION(
+            (iter1_._bz_suggestLength() == iter2_._bz_suggestLength())
+         && (iter2_._bz_suggestLength() == iter3_._bz_suggestLength()));
+
+        return iter1_._bz_suggestLength();
+    }
+
+private:
+    _bz_VecWhere() { }
+
+    T_expr1 iter1_;
+    T_expr2 iter2_;
+    T_expr3 iter3_;
+};
+
+BZ_NAMESPACE_END
+
+#include <blitz/vecwhere.cc>        // Expression templates
+
+#endif // BZ_VECWHERE_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/zero.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/zero.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/zero.cc	(revision 1307)
@@ -0,0 +1,45 @@
+/*
+ * $Id: zero.cc,v 1.1.1.1 1999-04-09 17:58:59 ansari Exp $
+ *
+ * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ * All rights reserved.  Please see <blitz/blitz.h> for terms and
+ * conditions of use.
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ */
+
+#ifndef BZ_ZERO_H
+ #include <blitz/zero.h>
+#endif
+
+#ifndef BZ_ZERO_CC
+#define BZ_ZERO_CC
+
+BZ_NAMESPACE(blitz)
+
+template<class P_numtype>
+P_numtype ZeroElement<P_numtype>::zero_ = 0;
+
+#ifdef BZ_HAVE_COMPLEX
+
+complex<float>  ZeroElement<complex<float> >::zero_ = 
+    complex<float>(0.0f, 0.0f);
+
+complex<double> ZeroElement<complex<double> >::zero_ =
+    complex<double>(0.,0.);
+
+complex<long double> ZeroElement<complex<long double> >::zero_ =
+    complex<long double>(0.0L, 0.0L);
+
+#endif // BZ_HAVE_COMPLEX
+
+BZ_NAMESPACE_END
+
+#endif // BZ_ZERO_CC
+
Index: /tags/DPC_V0/SophyaExt/Blitz/blitz/zero.h
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/blitz/zero.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/blitz/zero.h	(revision 1307)
@@ -0,0 +1,115 @@
+/***************************************************************************
+ * blitz/zero.h          Zero elements
+ *
+ * $Id: zero.h,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
+ *
+ * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
+ *
+ * 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.
+ *
+ * Suggestions:          blitz-suggest@cybervision.com
+ * Bugs:                 blitz-bugs@cybervision.com
+ *
+ * For more information, please see the Blitz++ Home Page:
+ *    http://seurat.uwaterloo.ca/blitz/
+ *
+ ***************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.4  1998/03/14 00:04:47  tveldhui
+ * 0.2-alpha-05
+ *
+ * Revision 1.3  1997/07/16 14:51:20  tveldhui
+ * Update: Alpha release 0.2 (Arrays)
+ *
+ * Revision 1.2  1997/01/24 14:42:00  tveldhui
+ * Periodic RCS update
+ *
+ * Revision 1.1  1997/01/13 22:19:58  tveldhui
+ * Periodic RCS update
+ *
+ *
+ ***************************************************************************
+ *
+ * The purpose of the ZeroElement class is to provide an lvalue for
+ * non-const element access of matrices with zero elements.  For
+ * example, a tridiagonal matrix has many elements which are
+ * always zero:
+ *
+ * [ x x 0 0 ]
+ * [ x x x 0 ]
+ * [ 0 x x x ]
+ * [ 0 0 x x ]
+ *
+ * To implement an operator()(int i, int j) for a tridiagonal
+ * matrix which may be used as an lvalue
+ *
+ * e.g. Matrix<double, Tridiagonal> M(4,4);
+ *      M(1,2) = 3.0L;
+ *
+ * some way of returning an lvalue for the zero elements is needed.
+ * (Either that, or an intermediate class must be returned -- but
+ * this is less efficient).  The solution used for the Blitz++
+ * library is to have a unique zero element for each numeric
+ * type (float, double, etc.).  This zero element is then
+ * returned as an lvalue when needed.
+ *
+ * The disadvantage is the possibility of setting the global
+ * zero-element to something non-zero.  
+ */
+
+#ifndef BZ_ZERO_H
+#define BZ_ZERO_H
+
+#ifndef BZ_BLITZ_H
+ #include <blitz/blitz.h>
+#endif
+
+BZ_NAMESPACE(blitz)
+
+template<class P_numtype>
+class ZeroElement {
+public:
+    typedef P_numtype T_numtype;
+
+    static T_numtype& zero()
+    { 
+        return zero_; 
+    }
+
+private:
+    static T_numtype zero_;
+};
+
+// Specialization of ZeroElement for complex<float>, complex<double>,
+// and complex<long double>
+
+#define BZZERO_DECLARE(T)            \
+  template<>                         \
+  class ZeroElement<T> {             \
+  public:                            \
+    static T& getZero()              \
+    { return zero_; }                \
+  private:                           \
+    static T zero_;                  \
+  }
+
+#ifdef BZ_HAVE_COMPLEX
+  BZZERO_DECLARE(complex<float>);
+  BZZERO_DECLARE(complex<double>);
+  BZZERO_DECLARE(complex<long double>);
+#endif // BZ_HAVE_COMPLEX
+
+BZ_NAMESPACE_END
+
+#include <blitz/zero.cc>
+
+#endif // BZ_ZERO_H
+
Index: /tags/DPC_V0/SophyaExt/Blitz/globals.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/Blitz/globals.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/Blitz/globals.cc	(revision 1307)
@@ -0,0 +1,44 @@
+#define BZ_GENERATE_GLOBAL_INSTANCES
+
+/*
+ * This module contains instances of global variables and objects.
+ * The preprocessor symbol _bz_global normally expands to "extern",
+ * but the declaration of BZ_GENERATE_GLOBAL_INSTANCES causes it
+ * to expand to "" for this source file.  This ensures that globals
+ * will have one unique instance, in libblitz.a.
+ */
+
+#include <blitz/indexexpr.h>      // Tensor index objects
+#include <blitz/bzdebug.h>        // Test suite globals
+#include <blitz/array.h>          // Dummy array object (_dummyArray)
+
+// NEEDS_WORK: after switch from RCS to CVS, get a version identifier.
+char* _blitz_id = "@(#) Blitz++ class library";
+
+// Instatiation explicite de vecteurs et matrices
+
+using namespace blitz ;
+
+void tst_instance_arrays_forlibs()
+{
+Array<int,1> iv(3), iv2(3);
+Array<long,1> lv(3), lv2(3);
+Array<float,1> fv(3), fv2(3);
+Array<double,1> dv(3), dv2(3);
+Array<int,2> im(3,3);
+Array<long,2> lm(3,3);
+Array<float,2> fm(3,3);
+Array<double,2> dm(3,3);
+dv = 1.5, 22.66, 333.777;
+dm = 9.1, 88.22, 777.333,
+     8.2, 77.33, 666.444,
+     7.3, 66.44, 555.333;
+firstIndex i;
+secondIndex j;
+dv2 = sum(dm(i,j)*dv(j),j);
+iv = lv = fv = dv;
+im = lm = fm = dm;
+fv2 = sum(fm(i,j)*fv(j),j);
+iv2 = sum(im(i,j)*iv(j),j);
+lv2 = sum(lm(i,j)*lv(j),j);
+}
Index: /tags/DPC_V0/SophyaExt/LinAlg/intflapack.cc
===================================================================
--- /tags/DPC_V0/SophyaExt/LinAlg/intflapack.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/LinAlg/intflapack.cc	(revision 1307)
@@ -0,0 +1,33 @@
+#include "intflapack.h"
+
+extern "C" {
+void sgesv_(int_4* n, int_4* nrhs, r_4* a, int_4* lda, 
+            int_4* ipiv, r_4* b, int_4* ldb, int_4* info);
+void dgesv_(int_4* n, int_4* nrhs, r_8* a, int_4* lda, 
+            int_4* ipiv, r_8* b, int_4* ldb, int_4* info);
+void cgesv_(int_4* n, int_4* nrhs, complex<r_4>* a, int_4* lda, 
+            int_4* ipiv, complex<r_4>* b, int_4* ldb, int_4* info);
+void zgesv_(int_4* n, int_4* nrhs, complex<r_8>* a, int_4* lda, 
+            int_4* ipiv, complex<r_8>* b, int_4* ldb, int_4* info);
+}
+
+void rztest_lapack(TArray<r_4>& aa, TArray<r_4>& bb)
+{
+  if ( aa.NbDimensions() != 2 ) throw(SzMismatchError("rztest_lapack(TMatrix<r_4> A Not a Matrix"));
+  if ( aa.SizeX() !=  aa.SizeY()) throw(SzMismatchError("rztest_lapack(TMatrix<r_4> A Not a square Matrix"));
+  if ( bb.NbDimensions() != 2 ) throw(SzMismatchError("rztest_lapack(TMatrix<r_4> A Not a Matrix"));
+  if ( bb.SizeY() !=  aa.SizeY() ) throw(SzMismatchError("rztest_lapack(TMatrix<r_4> A <> B "));
+  if ( !bb.IsPacked() || !bb.IsPacked() ) 
+    throw(SzMismatchError("rztest_lapack(TMatrix<r_4> Not packed A or B "));
+  
+  int_4 n = aa.SizeY();
+  int_4 nrhs = bb.SizeX();
+  int_4 lda = n;
+  int_4 ldb = bb.SizeY();
+  int_4 info;
+  int_4* ipiv = new int_4[n];
+  sgesv_(&n, &nrhs, aa.Data(), &lda, ipiv, bb.Data(), &ldb, &info);
+  cout << "rztest_lapack/Info= " << info << endl;
+  cout << aa << "\n" << bb << endl;
+  return;
+}
Index: /tags/DPC_V0/SophyaExt/LinAlg/intflapack.h
===================================================================
--- /tags/DPC_V0/SophyaExt/LinAlg/intflapack.h	(revision 1307)
+++ /tags/DPC_V0/SophyaExt/LinAlg/intflapack.h	(revision 1307)
@@ -0,0 +1,11 @@
+#ifndef  IntfLapack_H_SEEN
+#define  IntfLapack_H_SEEN
+
+#include "machdefs.h"
+#include "tarray.h"
+
+
+void rztest_lapack(TArray<r_4>& a, TArray<r_4>& b);
+// void rztest_lapack(TMatrix<r_8>& a, TMatrix<r_8>& b);
+
+#endif
Index: /tags/DPC_V0/SophyaLib/BaseTools/Makefile
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/Makefile	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/Makefile	(revision 1307)
@@ -0,0 +1,27 @@
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libSysTools.a
+clean:
+	rm -f $(OBJ)ctimer.o $(OBJ)exceptions.o $(OBJ)pdlmgr.o $(OBJ)periodic.o $(OBJ)ppersist.o $(OBJ)psighand.o $(OBJ)timing.o
+	rm $(LIB)libSysTools.a
+$(LIB)libSysTools.a : $(OBJ)ctimer.o $(OBJ)exceptions.o $(OBJ)pdlmgr.o $(OBJ)periodic.o $(OBJ)ppersist.o $(OBJ)psighand.o $(OBJ)timing.o
+	$(AR) $(ARFLAGS) $@ $?
+ifeq ($(CXX),cxx)
+	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS) -L$(LIB) -lSysTools -o $(OBJ)xx.x -Hf
+endif 
+ 
+$(OBJ)ctimer.o: ctimer.cc defs.h ctimer.h /home/ansari/DPC/Include/peida.h \
+ /home/ansari/DPC/Include/defs.h /home/ansari/DPC/Include/utils.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h /home/ansari/DPC/Include/fmath.h
+$(OBJ)exceptions.o: exceptions.cc defs.h exceptions.h peidainit.h perrors.h
+$(OBJ)pdlmgr.o: pdlmgr.cc pdlmgr.h defs.h
+$(OBJ)periodic.o: periodic.cc defs.h periodic.h
+$(OBJ)ppersist.o: ppersist.cc defs.h peidainit.h ppersist.h machine.h \
+ perrors.h exceptions.h /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/dates.h \
+ /home/ansari/DPC/Include/exceptions.h
+$(OBJ)psighand.o: psighand.cc psighand.h defs.h perrors.h exceptions.h \
+ peidainit.h
+$(OBJ)timing.o: timing.c
Index: /tags/DPC_V0/SophyaLib/BaseTools/SysTools.o.list
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/SysTools.o.list	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/SysTools.o.list	(revision 1307)
@@ -0,0 +1,7 @@
+ctimer.o
+exceptions.o
+pdlmgr.o
+periodic.o
+ppersist.o
+psighand.o
+timing.o
Index: /tags/DPC_V0/SophyaLib/BaseTools/defs.h
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/defs.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/defs.h	(revision 1307)
@@ -0,0 +1,263 @@
+#ifndef DEFS_SEEN
+#define DEFS_SEEN
+
+/*#define DEBUG*/
+
+#ifdef DEBUG
+#define IMGRGCHECK
+#define IMGVOIDCHECK
+#endif
+
+/* Sur mac, PP utilise fp.h plutot que math.h, et les deux sont incompatibles... */
+#ifdef __MWERKS__
+/* 
+  #include <fp.h>
+  #define __MATH__
+*/
+#endif
+
+
+/********************************************************/
+/* Outil d'impressions pour debug */
+#define PR(_data_)  {cout<<" "<<#_data_<<" "<<_data_;}
+#define CR {cout<<"\n"<<flush;}
+/* ********************************************************/
+
+/* Sur quelle machine sommes-nous ?                                       */
+/* Il faudrait uniformiser tous les sources avec les memes conventions... */
+
+#if defined(__alpha) || defined(__alpha__) || defined(OSF1) || defined(DECALPHA)
+#undef OSF1
+#define OSF1
+#undef DECALPHA
+#define DECALPHA 
+#undef __alpha__
+#define __alpha__
+#endif
+
+
+#if defined(_AIX) && !defined(AIX)
+#define AIX 1
+#endif
+
+#if defined(__hpux__) && !defined(HPUX)
+#define HPUX  1
+#endif
+
+
+#ifdef ultrix
+#define DECULTRIX 1
+#endif
+
+#ifdef __ultrix__
+#define DECULTRIX 1
+#endif
+
+#ifdef THINK_CPLUS
+#define __mac__
+#endif
+
+#ifdef __MWERKS__
+#define __mac__
+#endif
+
+/* Quelques variantes du C++ selon le compilateur */
+
+#define USESTRING
+
+#define HAS_VEC_NEW
+
+#ifdef __MWERKS__
+#define __ANSI_TEMPLATES__
+#undef HAS_VEC_NEW
+#define COMPILER_EXCEPTIONS
+#define NO_STRSTREAM
+#define STREAMPOS_IS_CLASS
+#define ITER_TAG
+#endif
+
+#ifdef __GNUG__
+#define __GNU_TEMPLATES__
+#endif
+
+#ifdef __DECCXX
+#if __DECCXX_VER > 60000000
+#define CXX6 1
+#define ITER_TAG
+/*  #define __GNU_TEMPLATES__ */
+#define __CXX_PRAGMA_TEMPLATES__
+#else
+#define CXX5 1
+#define __CXX_PRAGMA_TEMPLATES__
+/*  Pour definir bool   Reza 20/05/97  */
+#include <stl_macros>
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#endif
+#endif
+
+#endif
+
+/* GCC 2.8.0 : exception, string::npos */
+#ifdef __GNUC__
+#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+#undef  COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#define NPOS string::npos
+#endif
+#endif
+
+
+#ifndef __GNUG__
+/*typedef int bool;*/
+#define __PRETTY_FUNCTION__ __FILE__ " __LINE__ "
+#ifndef __FUNCTION__
+#define __FUNCTION__ __FILE__ " __LINE__ "
+#endif
+#ifndef __KCC__
+#define __attribute__(_x_)
+#endif
+#endif
+
+#ifdef __GNUG__
+#define HAS_NAMED_RETURN 0
+#else
+#define HAS_NAMED_RETURN 0
+#endif
+
+#ifdef THINK_CPLUS
+#define ARG_FUNC_CPP_C 0
+#else
+#define ARG_FUNC_CPP_C 1
+#endif
+
+#ifdef __GNUG__
+#define HAS_EXPLICIT
+#endif
+
+#ifdef HAS_EXPLICIT
+#define EXPLICIT explicit
+#else
+#define EXPLICIT
+#endif
+/* Quelques variantes de la librairie C++.                 */
+/* La librairie est AT&T par defaut, sauf si __ANSI_IO__   */
+
+/* $CHECK$ EA : a uniformiser */
+/* remplacer HAS_IOS_BIN par un selecteur qui indique si c'est ios::binary ou */
+/* ios::bin */
+
+#ifdef __MWERKS__
+/* #define __ANSI_IO__ */
+#endif
+
+#if defined(THINK_CPLUS)
+#define HAS_IOS_BIN 0
+#define HAS_IOS_NOCREATE 1
+#define FITS_IOS_IN_OPT  ios::in | ios::nocreate
+#define FITS_IOS_OUT_OPT ios::out
+
+#elif defined(__MWERKS__)
+#define HAS_IOS_BIN 1
+#define HAS_IOS_NOCREATE 1
+#define NPOS string::npos
+
+#elif defined(__GNUG__)
+#define HAS_IOS_BIN 1
+#define HAS_IOS_NOCREATE 1
+#define FITS_IOS_IN_OPT  ios::in | ios::bin | ios::nocreate
+#define FITS_IOS_OUT_OPT ios::out | ios::bin
+
+#else
+#define HAS_IOS_BIN 0
+#define HAS_IOS_NOCREATE 0
+#endif
+
+#ifdef __ANSI_IO__
+#define seekg(p_, m_) rdbuf()->pubseekoff(p_,m_)
+#define seekp(p_, m_) rdbuf()->pubseekoff(p_,m_)
+#endif
+
+
+#define STR2CH(x) ((string(x)).c_str())
+
+/* Des fonctions qui manquent sur certaines machines  */
+
+#if defined(__DECCXX) 
+/* a cause des exceptions dans math.h */
+#define exception math_exception
+#include <math.h>
+#undef exception
+#else
+#include <math.h>
+#endif
+
+#if defined(__DECCXX) 
+/*  Pour definir bool   Reza 20/05/97  */
+#include <stl_macros>
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#endif
+#endif
+
+#if defined(__xlC)  && defined (__cplusplus) 
+#include <bool.h>
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+// NPOS - On utilise la STL de g++ 2.7.2 
+#endif
+#endif
+
+#if defined( __DECCXX ) || defined (__aCC__)  
+/* en fait si c'est RogueWave */
+/*  Remis par Reza  20/05/97  */
+#define NPOS (size_t)-1
+#endif
+
+#if defined (__aCC__)  
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#endif
+#ifndef  __ANSI_TEMPLATES__
+#define __ANSI_TEMPLATES__
+#endif
+#endif
+
+#if defined(__KCC__)
+/* KCC V 3.2 ne compile pas  i/ostream s ; long p = s.tellg();  OK en  V 3.3 */
+#define STREAMPOS_IS_CLASS
+#define NPOS string::npos
+
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#endif
+#ifndef  __ANSI_TEMPLATES__
+#define __ANSI_TEMPLATES__
+#endif
+#endif
+
+#ifndef M_PI
+#define M_PI 3.1415926535
+#endif
+
+#ifdef __mac__
+#define hypot(_x_,_y_) sqrt((_x_)*(_x_) + (_y_)*(_y_))
+/* #define nintf(x) ((int) (x))  */
+#define random() (rand()*65538.0 + rand()*2. + rand())
+#define srandom srand
+#define initstate(seed, tab, n) srand(seed)
+#define nice(_x)
+/*#define getpid() 1 */
+
+#ifdef __cplusplus
+#include <string.h>
+#include <string>
+inline bool operator< (string const& s1, string const& s2)
+{ return (strcmp(s1.c_str(), s2.c_str()) < 0); }
+#endif
+#endif
+
+
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/BaseTools/exceptions.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/exceptions.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/exceptions.cc	(revision 1307)
@@ -0,0 +1,235 @@
+#include "defs.h"
+#include "exceptions.h"
+#include <iostream.h>
+#include <new.h>
+#ifndef __mac__
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#include "perrors.h"
+
+#ifdef __mac__
+#include "unixmac.h"
+#include <SIOUX.h>
+#endif
+
+//#define LAL
+
+#ifndef EXC_MSG
+#define EXC_MSG(i) "Exception " << i
+#endif
+
+#define kDynAllocBlock 10
+
+void EAFailHandler(void); 
+
+#ifndef COMPILER_EXCEPTIONS
+
+#ifndef NO_EXCEPTIONS
+
+ExcHndl::ExcHndl(ExcHndl* up)
+: nextHandler(up), 
+  theExc(0), hadExc(0),
+  nObj(0), nObjAlloc(kDynAllocBlock), objects((ExcAwareObject**)malloc(kDynAllocBlock*sizeof(void*))), 
+  nDyn(0), nDynAlloc(kDynAllocBlock), dynObjs((ExcAwareObject**)malloc(kDynAllocBlock*sizeof(void*))),
+  nDynTab(0), nDynTabAlloc(kDynAllocBlock), 
+  dynTabObjs((ExcAwareObject**)malloc(kDynAllocBlock*sizeof(void*))),
+  dynTabSz((size_t*)malloc(kDynAllocBlock*sizeof(size_t)))
+{
+ //  cerr << "TRY : " << hex << this << "  <-  " << nextHandler << dec << endl;
+}
+
+ExcHndl::~ExcHndl()
+{
+  free(objects);
+  free(dynObjs);
+  free(dynTabObjs);
+  free(dynTabSz);
+ // cerr << "~TRY: " << hex << this << "  <-  " << nextHandler << dec << endl;
+}
+
+void ExcHndl::Add(ExcAwareObject* obj)
+{
+  // on verifie s'il est dans la liste a ignorer
+  int trouve=0;
+  int i;
+  for (i=0; i<nDyn; i++)
+    if (dynObjs[i] == obj) {
+      trouve = true;
+      break;
+    }
+  if (trouve) {   // On le vire de la table des news.
+    nDyn--;
+    for (int j=i; j<nDyn; j++)
+      dynObjs[j] = dynObjs[j+1];
+    return;
+  }
+  
+  // Dans les tableaux ?
+  for (i=0; i<nDynTab; i++)
+    if ((dynTabObjs[i] <= obj) && ((char*)(dynTabObjs[i]) + dynTabSz[i] >= (char*)obj)) {
+      return;
+    }
+
+  // on l'ajoute a la liste des objets
+  nObj++;
+  if (nObj>nObjAlloc) {
+    nObjAlloc += kDynAllocBlock;
+    objects = (ExcAwareObject**) realloc(objects, nObjAlloc*sizeof(void*));
+  }
+
+  objects[nObj-1] = obj;
+}
+
+void ExcHndl::Forget(ExcAwareObject* obj)
+{
+  // on verifie s'il est dans la liste
+  int trouve=0;
+  int i=0;
+  for (i=0; i<nObj; i++)
+    if (objects[i] == obj) {
+      trouve = true;
+      break;
+    }
+  if (trouve) {
+    nObj--;
+    for (int j=i; j<nObj; j++)
+      objects[j] = objects[j+1];
+  }
+}
+
+void ExcHndl::Ignore(ExcAwareObject* obj)
+{
+  // on l'ajoute a la liste des objets
+  nDyn++;
+  if (nDyn>nDynAlloc) {
+    nDynAlloc += kDynAllocBlock;
+    dynObjs = (ExcAwareObject**) realloc(dynObjs, nDynAlloc*sizeof(void*));
+  }
+
+  dynObjs[nDyn-1] = obj;
+}
+
+void ExcHndl::IgnoreTab(ExcAwareObject* obj, size_t sz)
+{
+  // on l'ajoute a la liste des objets
+  nDynTab++;
+  if (nDynTab>nDynTabAlloc) {
+    nDynTabAlloc += kDynAllocBlock;
+    dynTabObjs =(ExcAwareObject**) realloc(dynTabObjs, nDynTabAlloc*sizeof(void*));
+    dynTabSz   = (size_t*) realloc(dynTabSz,   nDynTabAlloc*sizeof(size_t));
+  }
+
+  dynTabObjs[nDynTab-1] = obj;
+  dynTabSz  [nDynTab-1] = sz;
+}
+
+void ExcHndl::DelTab(ExcAwareObject* obj)
+{
+  // on le supprime
+
+  int trouve=0;
+  int i=0;
+  for (i=0; i<nDynTab; i++)
+    if (dynTabObjs[i] == obj) {
+      trouve = true;
+      break;
+    }
+  if (trouve) {
+    nDynTab--;
+    for (int j=i; j<nDynTab; j++) {
+      dynTabObjs[j] = dynTabObjs[j+1];
+      dynTabSz  [j] = dynTabSz  [j+1];
+    }
+  }
+}
+
+
+
+// End Constructor : ne pas se preoccuper des objets qui sont
+// a l'interieur de cet objet.
+void ExcHndl::EndConstructor(void* obj, size_t s)
+{
+  for (int i=0; i<nObj; i++)
+    if ((char*)objects[i] > (char*)obj && (char*)objects[i] < (char*)obj + s) {
+      nObj--;
+      for (int j=i; j<nObj; j++)
+	objects[j] = objects[j+1];
+      i--;
+    }
+}
+
+#undef DEBUG
+
+void ExcHndl::Throw(int i, char* file, int line)
+{
+  if (_ExcAbortAll || (i<0 && _ExcAbortNeg)) {
+    cerr << EXC_MSG(i);
+    if (file) cerr << " file " << file << " line " << line;
+    cerr << endl;
+    abort();
+  } else {
+    #ifdef DEBUG
+    cerr << "caught " << EXC_MSG(i);
+    if (file) cerr << " file " << file << " line " << line;
+    cerr << endl;
+    #endif
+    theExc = i;
+    hadExc = 1;
+    
+    // On detruit tous les objets crees depuis le TRY
+    // ExcAwareObject a un destructeur virtuel...
+    // Le tableau est dans l'ordre de creation. donc i--
+    
+    for (int i=nObj-1; i>=0; i--)
+      objects[i]->~ExcAwareObject();
+    
+    // et maintenant on saute...
+    
+    longjmp(env, 1);
+  }
+}
+
+
+void ExcHndl::NoHandler(int i, char* file, int line)
+{
+  cerr << "No handler : ";
+  cerr << EXC_MSG(i);
+  if (file) cerr << " file " << file << " line " << line;
+  cerr << endl;
+  terminate();
+}
+
+ExcHndl* topExcHndl = 0;
+int      _ExcAbortNeg = 1;
+int      _ExcAbortAll = 0;
+
+#endif
+#endif
+
+
+void EAFailHandler(void)
+{
+        set_new_handler(NULL);
+	cerr << "Allocation exception -- out of memory" << endl;
+        THROW(allocationErr);
+}
+
+void InitFailNewHandler()
+{
+        set_new_handler(EAFailHandler);
+}
+
+
+#ifdef THINK_CPLUS
+void terminate()
+{
+	DebugStr("\pTerminate...");
+	abort();
+}
+#endif
+
+#ifdef x__GNUG__
+void terminate()
+{ abort(); }
+#endif
Index: /tags/DPC_V0/SophyaLib/BaseTools/exceptions.h
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/exceptions.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/exceptions.h	(revision 1307)
@@ -0,0 +1,267 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef EXCEPTIONS_SEEN
+#define EXCEPTIONS_SEEN
+
+// Gestion des exceptions, conformemnt au manuel de reference C++
+// en attendant que les compilateurs le fassent tous seuls
+//
+// Eric Aubourg, la Silla fevrier 95
+// Pour le moment, on ne sait gerer qu'un seul type d'exception, int.
+// 
+// La syntaxe est
+//    TRY {
+//          ....
+//        }
+//    CATCH(i) {
+//        ...
+//    }
+//    ENDTRY
+
+// ou bien CATCHALL a la place de CATCH.
+//
+
+// On peut faire THROW_ tout court, qui est pareil que THROW(0)
+// ou bien THROW(n)
+// ou bien THROW_SAME dans un bloc CATCH
+
+// IMPORTANT
+// Tout objet susceptible d'etre cree automatiquement au cours d'un bloc
+// try doit etre declare EXC_AWARE (class x EXC_AWARE {...};) ou bien
+// deriver d'une telle classe.
+
+// Tout constructeur d'une classe qui contient d'autres objets parmi ses
+// champs doit se terminer par END_CONSTRUCTOR.
+
+#include "defs.h"
+
+#include <iostream.h>
+#include "peidainit.h"
+
+//#define NO_EXCEPTIONS
+#ifdef NO_EXCEPTIONS
+
+#define EXC_ABORT_NEG(_x)
+#define EXC_ABORT_ALL(_x)
+
+#define EXC_AWARE
+
+#define END_CONSTRUCTOR
+
+#define TRY if (1) {
+#define CATCH(_var) } else { long _var;
+#define CATCHALL } else {
+#define ENDTRY }
+
+#define THROW(_i) \
+      {cerr << "Throw " << _i << " file " << __FILE__ << " line " << __LINE__;	\
+       cerr << endl;											\
+       abort();}
+
+#define THROW_ THROW(0)
+
+#define THROW_SAME THROW(0)
+
+#define ASSERT(_a_) if (!(_a_)) { \
+     cerr << "Assertion failed " #_a_ " file " __FILE__ " line " << __LINE__ \
+          << endl; \
+     THROW_ }
+
+#define RETURN(x) return(x)
+#define RETURN_ return
+
+#else
+#ifdef COMPILER_EXCEPTIONS
+
+#define EXC_ABORT_NEG(_x)
+#define EXC_ABORT_ALL(_x)
+
+#define EXC_AWARE
+
+#define END_CONSTRUCTOR
+
+#define TRY try
+#define CATCH(_var) catch(long _var)
+#define CATCHALL catch(...)
+#define ENDTRY
+
+#define THROW(_i) throw((long) _i);
+
+#define THROW_ THROW(0)
+
+#define THROW_SAME throw;
+
+#define ASSERT(_a_) if (!(_a_)) { \
+     cerr << "Assertion failed " #_a_ " file " __FILE__ " line " << __LINE__ \
+          << endl; \
+     THROW_ }
+
+#define RETURN(x) return(x)
+#define RETURN_ return
+
+void InitFailNewHandler();
+#else
+
+#include <setjmp.h>
+#include <stdlib.h>
+
+class ExcAwareObject;
+
+class ExcHndl {
+public:
+  ExcHndl(ExcHndl* up);
+  ~ExcHndl();
+
+  void SetEnv(jmp_buf& theEnv)
+#ifndef __GNUG__
+	{memcpy(env, theEnv, sizeof(jmp_buf));}
+#else
+  	{env = theEnv;}
+#endif
+  void Throw(int exc=0, char* file=0, int line=0);
+  void Add(ExcAwareObject*);
+  void Forget(ExcAwareObject*);
+  void Ignore(ExcAwareObject*);
+  void IgnoreTab(ExcAwareObject*, size_t);
+  void DelTab(ExcAwareObject*);
+  void EndConstructor(void*, size_t);
+  static void NoHandler(int exc=0, char* file=0, int line=0);
+
+  ExcHndl*         nextHandler;
+  
+  int              theExc;
+  int              hadExc;
+
+private:
+  jmp_buf          env;
+  int              nObj, nObjAlloc;
+  ExcAwareObject** objects;
+  int              nDyn, nDynAlloc;
+  ExcAwareObject** dynObjs;
+  int              nDynTab, nDynTabAlloc;
+  ExcAwareObject** dynTabObjs;
+  size_t*          dynTabSz;
+};
+
+extern ExcHndl* topExcHndl;
+extern int      _ExcAbortNeg;
+extern int      _ExcAbortAll;
+
+class ExcAwareObject {
+friend class ExcHndl;
+public:
+  ExcAwareObject() {
+    if (topExcHndl) topExcHndl->Add(this);
+  }
+  
+  virtual ~ExcAwareObject() {
+    if (topExcHndl) topExcHndl->Forget(this);
+  }
+  
+#ifdef HAS_VEC_NEW
+  void* operator new(size_t s) {
+    void* p = ::operator new(s);
+    if (topExcHndl) topExcHndl->Ignore((ExcAwareObject*)p);
+    return p;
+  }
+
+  void* operator new(size_t /*s*/, void* p) {
+    if (topExcHndl) topExcHndl->Ignore((ExcAwareObject*)p);
+    return p;
+  }
+  
+  void* operator new[](size_t s) {
+    void* p = ::operator new[](s);
+    if (topExcHndl) topExcHndl->IgnoreTab((ExcAwareObject*)p,s);
+    return p;
+  }
+
+  void operator delete[](void* p) {
+    if (topExcHndl) topExcHndl->DelTab((ExcAwareObject*)p);
+    ::operator delete[](p);
+  }
+#else
+  void* operator new(size_t s) {
+    void* p = ::operator new(s);
+    if (topExcHndl) topExcHndl->IgnoreTab((ExcAwareObject*)p,s);
+    return p;
+  }
+
+  void* operator new(size_t s, void* p) {
+    if (topExcHndl) topExcHndl->IgnoreTab((ExcAwareObject*)p,s);
+    return p;
+  }
+
+  void operator delete(void* p) {
+    if (topExcHndl) topExcHndl->DelTab((ExcAwareObject*)p);
+    ::operator delete(p);
+  }
+#endif
+};
+
+//extern "C" void terminate();
+
+void InitFailNewHandler();
+
+// Et maintenant les macros!
+
+// TRY cree un nouveau handler, et fait le setjmp
+
+#define _UPHANDLER \
+    { ExcHndl* tmp = topExcHndl->nextHandler; \
+      delete topExcHndl;                      \
+      topExcHndl = tmp; }
+
+#define EXC_ABORT_NEG(_x) _ExcAbortNeg = _x;
+#define EXC_ABORT_ALL(_x) _ExcAbortAll = _x;
+
+#define EXC_AWARE : public virtual ExcAwareObject
+
+#define END_CONSTRUCTOR \
+if (topExcHndl) topExcHndl->EndConstructor(this, sizeof(*this));
+
+#define TRY \
+    {  topExcHndl = new ExcHndl(topExcHndl); \
+       jmp_buf _jmpBuffer;                   \
+       volatile int _excCaught = 0;          \
+       if (!setjmp(_jmpBuffer)) {            \
+	  topExcHndl->SetEnv(_jmpBuffer);
+
+#define CATCH(_var)                          \
+         _UPHANDLER                          \
+       } else if (topExcHndl->hadExc) {      \
+	  int _caughtException = topExcHndl->theExc; \
+          int _var = _caughtException;       \
+          _excCaught = 1;                    \
+	  _UPHANDLER
+
+#define CATCHALL \
+         _UPHANDLER \
+       } else if (topExcHndl->hadExc) {       \
+	  int _caughtException = topExcHndl->theExc;\
+          _excCaught = _caughtException;                 \
+          _excCaught = 1;                    \
+	  _UPHANDLER
+
+#define ENDTRY \
+       } else _UPHANDLER\
+     }
+
+#define THROW(_i) \
+      {if (!topExcHndl) ExcHndl::NoHandler(_i,__FILE__,__LINE__); \
+       topExcHndl->Throw(_i,__FILE__,__LINE__);}
+
+#define THROW_ THROW(0)
+
+#define THROW_SAME THROW(_caughtException)
+
+#define ASSERT(_a_) if (!(_a_)) { \
+     cerr << "Assertion failed " #_a_ " file " __FILE__ " line " << __LINE__ \
+          << endl; \
+     THROW_ }
+
+#define RETURN(x) { _UPHANDLER; return(x); }
+#define RETURN_ { _UPHANDLER; return; }
+
+#endif
+#endif
+#endif
Index: /tags/DPC_V0/SophyaLib/BaseTools/machine.h
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/machine.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/machine.h	(revision 1307)
@@ -0,0 +1,124 @@
+#ifndef MACHINE_H_SEEN
+#define MACHINE_H_SEEN
+
+#include "defs.h"
+
+#if defined(DECULTRIX)  || defined(ULTRIX)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef long int_4;
+  typedef unsigned long uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 1
+#define  SWAPDEFAUT 1
+
+#elif defined(DECALPHA) || defined(OSF1)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 1
+#define  SWAPDEFAUT 1
+
+#elif  defined(HPUX)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4 ;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 0
+#define  SWAPDEFAUT   0
+
+
+#elif  defined( AIX )
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 0
+#define  SWAPDEFAUT   0
+
+#elif  defined( sun )
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 0
+#define  SWAPDEFAUT   0
+
+#elif defined(Linux)  || defined(linux)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 1
+#define  SWAPDEFAUT   1
+
+#elif defined(__mac__)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef long int_4;
+  typedef unsigned long uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 0
+#define  SWAPDEFAUT   0
+
+#else
+#error  Undefined Machine type in machine.h
+#endif
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/BaseTools/peidainit.h
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/peidainit.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/peidainit.h	(revision 1307)
@@ -0,0 +1,26 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe d'initialiseur de module de PEIDA 
+
+#ifndef PEIDAINIT_H_SEEN
+#define PEIDAINIT_H_SEEN
+
+#include "defs.h"
+
+void PrintPeidaVersion(void);
+double PeidaVersion(void); /* Version + (Revision/1000) */
+
+// Classe d''initialisation pour les modules de PEIDA++
+
+class PeidaInitiator {
+private:
+  static int FgInit;
+public:
+  			PeidaInitiator();
+  virtual		~PeidaInitiator();
+  virtual double 	Version(bool fgprt=true);
+};
+
+#define PeidaInit() PeidaInitiator peidainitiator
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/BaseTools/perrors.h
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/perrors.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/perrors.h	(revision 1307)
@@ -0,0 +1,105 @@
+#ifndef PERRORS_SEEN
+#define PERRORS_SEEN
+
+// Erreurs PEIDA
+// Les erreurs graves sont negatives. Par defaut elles causent
+// un abort, alors que les erreurs positives propagent une
+// exception.
+// voir les macros EXC_ABORT_NEG(flag) et EXC_ABORT_ALL(flag)
+
+#include "exceptions.h"
+enum {
+  allocationErr    = -1,
+  nullPtrErr       = -2,
+  sizeMismatchErr  = -3,
+  rangeCheckErr    = -4,
+  parmErr          = -5,
+  forbiddenErr     = -6,
+  assertionFailErr = -7,
+
+  typeMismatchErr  = 1,
+  fileErr             ,
+  fitsImageErr        ,
+  endOfFileErr        ,
+  tapeErr             ,
+  tapeNoLogErr        ,
+  tapeNoLabelErr      ,
+  tapeEndMediaErr     ,
+  tapeNotReadyErr     ,
+  acqTapeErr          ,
+  acqRobotErr         ,
+  tarFileErr          ,
+  tarFileNoHeaderErr  ,
+  noStarsErr          ,
+  transfoErr          ,
+  fitsHeaderErr       ,
+  singMatxErr         ,
+  noCvgErr            ,
+  notFoundErr         ,
+  dupIdErr            ,
+  getEnvErr           ,
+  catchedSIGFPE       ,
+  catchedSIGSEGV      ,
+  catchedSIGINT       ,
+  catchedSIGQUIT      ,
+  catchedSIGUSR1      ,
+  catchedSIGUSR2      ,
+  inconsistentErr
+};
+
+static inline char* PeidaExc(int i) {
+  switch (i) {
+  case allocationErr:       return "Allocation Exception";
+  case nullPtrErr:          return "Null Pointer Exception";
+  case sizeMismatchErr:     return "Size Mismatch Exception";
+  case rangeCheckErr:       return "Range Check Exception";
+  case parmErr:             return "Invalid Parameter Exception";
+  case forbiddenErr:        return "Forbidden Function Exception";
+  case assertionFailErr:    return "Assertion Failed Exception";
+  case typeMismatchErr:     return "Type Mismatch Exception";
+  case fileErr:             return "File Error Exception";
+  case fitsImageErr:        return "FitsImage Error Exception";
+  case endOfFileErr:        return "End of File Error Exception";
+  case tapeErr:             return "Tape Error Exception";
+  case tapeNoLogErr:        return "Tape No Log File Exception";
+  case tapeNoLabelErr:      return "Tape No label Exception";
+  case tapeEndMediaErr:     return "Tape end data Exception";
+  case tapeNotReadyErr:     return "Tape not ready Exception";
+  case acqTapeErr:          return "Acq Tape Error Exception";
+  case acqRobotErr:         return "Acq Robot Error Exception";
+  case tarFileErr:          return "TarFile Error Exception";
+  case tarFileNoHeaderErr:  return "TarFile No Header Error Exception";
+  case noStarsErr:          return "No/Not Enough Stars Exception";
+  case transfoErr:          return "Transformation finding Exception";
+  case fitsHeaderErr:       return "Fits Header Exception";
+  case singMatxErr:         return "Singular Matrix Exception";
+  case noCvgErr:            return "No Convergence Exception";
+  case notFoundErr:         return "Not Found Exception";
+  case dupIdErr:            return "Duplicate Id Exception";
+  case getEnvErr:           return "GetEnv no var Exception";
+  case inconsistentErr:     return "Inconsistent Data Exception";
+  case catchedSIGFPE:       return "catched SIGFPE (floating point exception) Exception";
+  case catchedSIGSEGV:      return "catched SIGSEGV (segmentation fault) Exception";
+  case catchedSIGINT:       return "catched SIGINT (Interrupt signal) Exception";
+  case catchedSIGQUIT:      return "catched SIGQUIT (Quit signal) Exception";
+  case catchedSIGUSR1:      return "catched SIGUSR1 (User1 signal) Exception";
+  case catchedSIGUSR2:      return "catched SIGUSR2 (User2 signal) Exception";
+  }
+  return "Unkown Exception";
+}
+
+
+#define FAILNIL(_x_) \
+       if (!(_x_)) THROW(nullPtrErr)
+
+#define EXC_MSG(i) PeidaExc(i) << "(" << i << ")"
+
+#ifdef DEBUG
+#define DBFAILNIL(_x_) FAILNIL(_x_)
+#define DBASSERT(_x_) ASSERT(_x_)
+#else
+#define DBFAILNIL(_x_)
+#define DBASSERT(_x_)
+#endif
+
+#endif
Index: /tags/DPC_V0/SophyaLib/BaseTools/ppersist.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/ppersist.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/ppersist.cc	(revision 1307)
@@ -0,0 +1,1220 @@
+#include "defs.h"
+#include <stdio.h>
+#include "peidainit.h"
+#include "ppersist.h"
+#include "dates.h"
+
+#ifndef RFIO
+#include <fstream.h>
+#endif
+
+
+#ifdef __mac__
+#include "unixmac.h"
+#include <SIOUX.h>
+#endif
+
+#if SWAP==1
+#define IS_BIG_ENDIAN 0
+#else
+#define IS_BIG_ENDIAN 1
+#endif
+
+//++
+// Class	PPersistMgr
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Classe gestionnaire d'objets persistants. Les méthodes statiques
+//	de cette classe permettent d'enregistrer des classes persistantes,
+//	et de relire automatiquement des objets.
+//--
+
+//++
+// Links	Voir
+// PPersist
+// PShPersist
+//--
+
+PPersistMgr::ClassList* PPersistMgr::classList = NULL;
+PShPersist::ObjList*    PShPersist::objList = NULL;
+
+//++
+void
+PPersistMgr::RegisterClass(int_4 classId, ClassCreatorFunc f, bool shared)
+//
+//	Enregistre une nouvelle classe auprès du gestionnaire. classId doit
+//	identifier de façon unique la classe. f doit créer un nouvel objet
+//	de cette classe (qui doit hériter de PPersist), non initialisé, et qui
+//	sera relu à partir du fichier d'objets persistants.
+//
+//	Si shared est true, la classe doit hériter de PShPersist, et la persistance
+//	gère le fait que plusieurs objets Xi puissent faire référence à un même objet A.
+//	A, qui hérite donc de PShPersist, ne sera écrit qu'une seule fois dans le fichier
+//	lorsque les Xi sont écrits, et la référence à A sera mise à jour lors de la lecture
+//	des Xi...
+//--
+{
+  DBASSERT(classList);
+  if (classList->size() && (classList->find(classId) != classList->end())) {
+      cerr << "RegisterClass : Error, " << hex << classId << dec 
+           << " already registered." << endl;
+      THROW(dupIdErr);
+    }
+  
+  ClassListEntry entry = {shared, f};
+  (*classList)[classId] = entry;
+}
+
+
+PPersistMgr::ClassCreatorFunc
+PPersistMgr::FindCreatorFunc(int_4 classId)
+{
+  DBASSERT(classList);
+  return (*classList)[classId].f;
+}
+
+PPersistMgr::ClassCreatorFunc
+PPersistMgr::FindCreatorFunc(int_4 classId, bool& isShared)
+{
+  DBASSERT(classList);
+  ClassListEntry entry = (*classList)[classId];
+  isShared = entry.shared;
+  return entry.f;
+}
+
+//++
+PPersist*
+PPersistMgr::ReadObject(PInPersist& s)
+//
+//	Lit un objet dans le stream s, en créant automatiquement un
+//	objet du bon type.
+//--
+{
+  DBASSERT(classList);
+  DBASSERT(PShPersist::objList);
+  // On commence par lire le type de l'objet
+  int_4 classId;
+  s >> classId;
+
+  // On recupere le createur, et on regarde si l'objet est partage
+  bool shared;
+  if (!classList->size() || (classList->find(classId) == classList->end())) {
+    cerr << "PPersistMgr::ReadObject Error : Class " << classId << " not registered" << endl;
+    THROW(notFoundErr);
+  }
+  PPersistMgr::ClassCreatorFunc f = FindCreatorFunc(classId, shared);
+  
+  if (!f) THROW(notFoundErr);
+  
+  PPersist* object;
+  if (shared) {
+    // Si l'objet est partage, ce qui suit est son identificateur, sur 4 octets
+    // et un octet ensuite qui dit si l'objet est present.
+  
+    int_4 objectId;
+    char objectSaved;
+    
+    s >> objectId >> objectSaved;
+
+#if 0
+    // On regarde si l'objet est deja en memoire
+    object = PShPersist::FindObject(objectId);
+    
+    // On verifie qu'on est dans une situation coherente...
+    if ((!objectSaved) == (!object)) THROW(inconsistentErr);
+#else
+    if (!objectSaved) {
+      object = PShPersist::FindObject(objectId);
+      if (!object) THROW(inconsistentErr);
+    }
+#endif
+    if (objectSaved) {
+      object = f();
+      object->ReadSelf(s);
+      ((PShPersist*)object)->mObjectID = objectId;
+      (*PShPersist::objList)[objectId] = (PShPersist*)object; 
+    }
+  } else {
+    object = f();
+    object->ReadSelf(s);
+  }
+  
+  return object;
+}
+
+//++
+// Class	PPersist
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Classe de base pour des objets persistants. Pour créer un objet
+//	persistant :
+//	- Hériter de PPersist.
+//	- Définir un numéro d'identification de la classe, unique dans Peida
+//	- Implémenter "ClassId()"
+//	- Implémenter "WriteSelf" et "ReadSelf", qui doivent écrire toutes les variables
+//	  membres que l'on souhaite écrire, et les relire dans le même ordre.
+//	  Pour écrire une référence à un objet : l'objet doit être un PPersist,
+//	  et il suffit d'appeler "Write" sur cet objet, et "PPersistMgr::ReadObject".
+//	  Si plusieurs objets font référence au même, pour éviter de l'écrire plusieurs
+//	  fois, il faut que cet objet soit un PShPersist.
+//	- Pour que le fichier soit portable, écrire et lire les variables membres en utilisant
+//	  les fonctions PutXX/GetXX de PInPersist/POutPersist.
+//
+//	Attention: les méthodes à redéfinir sont WriteSelf et ReadSelf, mais il ne faut jamais
+//	les appeler directement. Seuls Write et Read peuvent être appelées par l'utilisateur.
+//--
+
+//++
+// Links	Voir
+// PInPersist
+// POutPersist
+// PPersistMgr
+// PShPersist
+//--
+
+PShPersist*
+PShPersist::FindObject(int_4 objId)
+{
+  DBASSERT(objList);
+  return (*objList)[objId];
+}
+  
+//++
+void
+PPersist::Write(string const& fn) const
+//
+//	Ecrit l'objet dans un nouveau fichier ppersist "fn".
+//--
+{
+  POutPersist of(fn);
+  Write(of);
+}
+
+//++
+void
+PPersist::Read(string const& fn) 
+//
+//	Relit l'objet dans le fichier ppersist "fn". Il faut connaître a priori
+//	le type de l'objet. Pour une relecture avec création automatique du bon
+//	objet, utiliser PPersistMgr::ReadObject.
+//--
+{
+  PInPersist inf(fn);
+  Read(inf);
+}
+
+//++
+void
+PPersist::Write(POutPersist& s) const
+//
+//	Ecrit l'objet dans le fichier PPersist.
+//--
+{
+   // On doit tout d'abord ecrire notre type
+   s << ClassId();
+   // Puis on s'ecrit, tout betement...
+   WriteSelf(s);
+}
+
+
+//++
+void
+PPersist::Read(PInPersist& s)
+//
+//	Relit l'objet dans le fichier ppersist. Il faut connaître a priori
+//	le type de l'objet. Pour une relecture avec création automatique du bon
+//	objet, utiliser PPersistMgr::ReadObject.
+//--
+{
+   // A n'utiliser que si on connait a priori
+   // le vrai type de l'objet.
+
+   // On doit tout d'abord lire notre type
+   int_4 classId;
+   s >> classId;
+   if (classId != ClassId()) {
+    cerr << "PPersist::Read() Object type (=" << ClassId() << ") mismatch (type in file="  
+         << classId << ")" << endl;
+    THROW(typeMismatchErr); }
+   // Puis on se lit, tout betement...
+   
+   ReadSelf(s);
+}
+
+//++
+int_4
+PPersist::Write(POutPersist& s, int_4 key) const
+//
+//	Ecrit l'objet dans le fichier PPersist avec un tag ayant "key" comme 
+//	valeur du champ clé du tag.
+//--
+{
+  int_4 rc;
+  // On ecrit le tag de positionnement et on recupere le numero de tag
+  rc = s.WriteTag(key, NULL);
+  // avant d'ecrire l'objet lui-meme
+  Write(s);
+  return(rc);
+}
+
+//++
+int_4
+PPersist::Write(POutPersist& s, int_4 key, string& nom) const
+//
+//	Ecrit l'objet dans le fichier PPersist avec un tag ayant "key", nom comme 
+//	valeurs des champs clé et nom  du tag.
+//--
+{
+  int_4 rc;
+  // On ecrit le tag de positionnement et on recupere le numero de tag
+  rc = s.WriteTag(key, nom.c_str());
+  // avant d'ecrire l'objet lui-meme
+  Write(s);
+  return(rc);
+}
+
+//++
+void
+PPersist::ReadAtTag(PInPersist& s, int_4 tagid)
+//
+//	Lit l'objet à la position du tag numéro "tagid".
+//--
+{
+  if (s.GotoTag(tagid))  Read(s);
+  else {
+    cerr << "PInPersist::GotoTag()  Error ! \n" << 
+	    "From PPersist::ReadAtTag(PInPersist, tag= " << tagid << ") " << endl; 
+    THROW(fileErr);
+  }
+  return;    
+}
+
+//++
+void
+PPersist::ReadAtKey(PInPersist& s, int_4 key)
+//
+//	Lit l'objet à la position du tag contenant la clé "key".
+//--
+{
+  if (s.GotoKey(key))  Read(s);
+  else {
+    cerr << "PInPersist::GotoKey()  Error ! \n" << 
+	    "From PPersist::ReadAtKey(PInPersist, key= " << key << ") " << endl; 
+    THROW(fileErr);
+  }
+  return;    
+}
+
+//++
+//  virtual void PPersist::ReadSelf(PInPersist&)=0
+//	Méthode virtuelle pure à redéfinir. Elle est appelée par Read
+//	et PPersistMgr::ReadObject. Il faut relire les variables membres,
+//	dans l'ordre où elles ont été écrites par WriteSelf.
+//  virtual void PPersist::WriteSelf(POutPersist&) const=0
+//	Méthode virtuelle pure à redéfinir. Elle est appelée par Write.
+//	Il faut écrire les variables membres,
+//	dans l'ordre où elles seront relues par ReadSelf.
+//--
+
+
+//++
+// Class	PShPersist
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Classe de base pour des objets persistants partagés.
+//	Un tel objet ne sera écrit qu'une seule fois dans un fichier
+//	donné. Les tentatives suivantes d'écriture n'écrivent qu'une
+//	référence à la première écriture.
+//
+//	Lors de la lecture, l'objet est créé lors de la première lecture,
+//	puis l'adresse de cet objet est retournée lors des lectures suivantes.
+//--
+
+//++
+// Links	Parents
+// PPersist
+//--
+
+//++
+void
+PShPersist::Write(POutPersist& s) const
+//
+//	Ecrit l'objet dans le fichier s.
+//
+//	En fait, l'objet est physiquement écrit une seule fois.
+//--
+{
+  DBASSERT(objList);
+   // On doit tout d'abord ecrire notre type
+   
+   s << ClassId();
+
+   // On doit ensuite ecrire notre identificateur et le flag d'ecriture
+   
+   char write = (mObjectID == 0) ? 255 : 0;
+   if (mObjectID == 0) {
+     (int_4&)mObjectID = (*objList).size() ? (*((*objList).rbegin())).first+1 : 1;
+     (*objList)[mObjectID] = (PShPersist*)this; 
+   }
+
+   s << mObjectID << write ;
+   
+   // Puis, si necessaire, on s'ecrit
+   
+   if (write)
+     WriteSelf(s);
+}
+
+PShPersist::~PShPersist()  // Une securite peut-etre facultative
+{
+  DBASSERT(objList);
+  if (mObjectID) {
+    DBASSERT(!objList->size() && (objList->find(mObjectID) != objList->end()));
+    objList->erase(mObjectID);
+  }
+}
+
+void
+PPersistMgr::Reset()
+{
+  DBASSERT(PShPersist::objList);
+  for (PShPersist::ObjList::iterator i = PShPersist::objList->begin(); 
+       i != PShPersist::objList->end(); i++)
+    (*i).second->mObjectID = 0; // Une securite peut-etre facultative
+
+  PShPersist::objList->erase(PShPersist::objList->begin(), PShPersist::objList->end());
+}
+
+#define PIOP_Delim  '\n'   // Delimiteur de ligne 
+//  Les noms ne peuvent depasser 255 caracteres  
+#define MAXTAGNAMELEN  255   
+
+//++
+// Class	PInPersist
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Fichier d'objets persistants, en lecture.
+//--
+
+//++
+PInPersist::PInPersist(string const& flnm, bool scan)
+//
+//	Constructeur. Ouvre le fichier.
+//--
+{
+  mSbsz = 0;     // Pour conserver les noms des tags ( V4 et au dela )
+  mSbuf = NULL;
+  mTags = NULL;
+  mNTags = 0;    //    "        "        "           "
+  fName = flnm;
+#ifdef RFIO
+  s = new erosifstream(flnm.c_str(),"rb");
+#else
+// $CHECK$ EA  ios::binary (ou ios::bin) doit exister PARTOUT.
+// Voir note dans defs.h pres de HAS_IOS_BIN
+#if defined(__MWERKS__)
+  s = new ifstream(flnm.c_str(),ios::in | ios::binary); // ios::binary pas connnu partout - $CHECK$ Reza 13/02/98
+#else
+  s = new ifstream(flnm.c_str(),ios::in );
+#endif
+#endif
+  PPersistMgr::Reset();
+  char rbuf[36];
+  GetBytes(rbuf, 32);
+  if (strncmp(rbuf,"PEIDA-PPersistFile", 18) != 0)  {
+    cerr << "PInPersist::PInPersist Error : File " << flnm << " (empty file or bad header)" 
+         << endl;
+    THROW(fileErr); }
+  version = atoi(rbuf+20);
+  bigEndian = IS_BIG_ENDIAN; // Les V2 sont relus en mode natif
+  if (version >= 3) {
+    GetBytes(rbuf, 32);
+    if (strncmp(rbuf,"BIG-ENDIAN",10) == 0)
+      bigEndian = true;
+    else if (strncmp(rbuf,"LITTLE-ENDIAN",13) == 0)
+      bigEndian = false;
+    else {
+      cerr << "PInPersist::PInPersist Error : File" << flnm;
+      cerr << " (V>=3 et ni BIG-ENDIAN, ni LITTLE-ENDIAN" << endl;
+      THROW(fileErr);
+    }
+  }
+  if (version >= 5) {   // On lit la date de creation (V5 et au-dela)
+    GetBytes(rbuf, 32);
+    rbuf[32] = '\0'; 
+    for(int k=0; k<32; k++) 
+      if (rbuf[k] == ' ') { rbuf[k] = '\0';  break; }
+    creationdate = rbuf;
+    }  // Fin de lecture de date
+  else creationdate = "??/??/??" ;
+  // Le fichier peut contenir des tag  (V4 et au dela)
+  if ( (version >= 4) && scan )  Scan();
+}
+
+
+
+PInPersist::~PInPersist()
+{
+  list<char*>::iterator it;
+  for(it = mSbuffs.begin(); it != mSbuffs.end(); it++)  delete[] (*it);
+  if (mTags)  delete[] mTags;
+  delete s;
+  PPersistMgr::Reset();
+}
+
+// A cause de aCC qui ne veut pas char* b = ""
+static char ChaineVide[2] = {'\0', '\0'};
+
+void
+PInPersist::Scan()
+{
+// On parcourt le fichier depuis la fin pour identifier tous les tags
+  int_8 debut, prev, premier;
+  int_4 ntag, ntc, ll;
+  uint_2 ln;
+  char pad[4];
+
+  #if defined(STREAMPOS_IS_CLASS) && !defined(RFIO)
+  debut = s->tellg().offset();
+  #else
+  debut = s->tellg();
+  #endif
+
+  premier = 0;
+  s->seekg(-(sizeof(int_8)+sizeof(int_4)), ios::end);
+  GetI8(prev);
+  GetI4(ntag);
+  if ( (ntag <= 0) || (prev < 0) )  
+    { s->seekg(debut,ios::beg); return; }
+
+  mNTags = ntag;
+  mTags = new PPFTag[ntag];
+
+  PPFTag* tag;
+  while( (prev > 0)  && (ntag > 0) ) {
+    s->seekg(prev);
+    if (ntag == 1)   premier = prev;
+    GetI8(prev);
+    GetI4(ntc);
+    ntag--;
+    if (ntc != ntag) {
+      cerr << "PInPersist::Scan() / Error: NTag,TC= " << ntag << "," << ntc << endl;
+      THROW(fileErr);
+    }
+    tag = mTags+ntag;
+    GetI4(tag->key);
+    GetU2(ln);  
+    if (ln > 0) {
+      tag->lnom = ln;
+      tag->nom = GetCStr(ln);
+      GetBytes(tag->nom, ln+1); 
+      ll = 3-((ln+2)%4);
+      GetBytes(pad, ll);
+    }
+    else { 
+      GetU2(ln);
+      tag->lnom = 0;
+      tag->nom = ChaineVide;
+    }
+// On recupere la position pour l'objet qui suit
+  #ifdef STREAMPOS_IS_CLASS
+  tag->popos = s->tellg().offset();
+  #else
+  tag->popos = s->tellg();
+  #endif
+
+  GetI4(tag->cid); 
+  }
+
+  if ( (ntag != 0) || (prev >= 0) ) {  // En principe , ca ne doit pas arriver
+    cerr << "PInPersist::Scan() / Error: (End: ntag=" << ntag <<
+            " prev=" << (int_4)prev << endl;
+    THROW(fileErr);
+  }
+// on se repositionne au debut du 1er objet du fichier 
+  if (premier == debut)  GotoTag(0); 
+  else s->seekg(debut);
+  return;
+}
+
+char*
+PInPersist::GetCStr(uint_2 sz)
+{
+char* rs;
+sz += 1;  // Pour le 0 de la fin
+if (sz > mSbsz)
+  { mSbsz = (sz > (MAXTAGNAMELEN+1)) ? sz : (MAXTAGNAMELEN+1);
+  mSbuf = new char[mSbsz];  mSbuffs.push_back(mSbuf); }
+
+rs = mSbuf;
+mSbuf += sz;
+mSbsz -= sz;
+return(rs);
+}
+
+bool 
+PInPersist::GotoTag(int_4 num)
+{
+  if ( (num < 0) || (num >= mNTags) )  return(false);
+  s->seekg(mTags[num].popos);
+  return(true); 
+}
+
+bool 
+PInPersist::GotoKey(int_4 key, int rang)
+{
+  if (rang < 0)  return(false);
+  int n = 0, i; 
+  int fnd = -1;
+  for(i=0; i<mNTags; i++) 
+    if (mTags[i].key == key) { 
+      if (n == rang) { fnd = i;   break; }
+      n++; }
+    
+  if (fnd >= 0) return(GotoTag(fnd));
+  else return(false);
+}
+
+int 
+PInPersist::NbKey(int_4 key)
+{
+  int n = 0, i;
+  for(i=0; i<mNTags; i++) 
+    if (mTags[i].key == key)  n++;
+  return(n);
+}
+
+void
+PInPersist::ListTags()
+{
+  cout << "PInPersist/ File " << fName << "\n";
+  cout << "Nb Tags in file : " << mNTags << "\n";
+  string str;
+  int i;
+  for(i=0; i<mNTags; i++) {
+    str = mTags[i].nom;
+    cout << i << "- CId= " << mTags[i].cid << " Key= " 
+         << mTags[i].key << " ( " << str << " )\n" ;
+  }
+  cout << endl;
+  return;  
+}
+
+int_4
+PInPersist::TagKey(int_4 num, int_4& cid, int_4& ln)
+{
+  if ( (num < 0) || (num >= mNTags) )  return(0);
+  cid = mTags[num].cid; ln = mTags[num].lnom; 
+  return(mTags[num].key);
+}
+
+string
+PInPersist::TagName(int_4 num)
+{
+  if ( (num < 0) || (num >= mNTags) )  return("");
+  return((string)mTags[num].nom);
+}
+
+//++
+// void PInPersist::GetByte(char& c)
+// void PInPersist::GetBytes(void* ptr, size_t bytes)
+// void PInPersist::GetR4   (r_4& result)
+// void PInPersist::GetR4s  (r_4* tab, size_t n)
+// void PInPersist::GetR8   (r_8& result)
+// void PInPersist::GetR8s  (r_8* tab, size_t n)
+// void PInPersist::GetI2   (int_2& result)
+// void PInPersist::GetI2s  (int_2* tab, size_t n)
+// void PInPersist::GetU2   (uint_2& result)
+// void PInPersist::GetU2s  (uint_2* tab, size_t n)
+// void PInPersist::GetI4   (int_4& result)
+// void PInPersist::GetI4s  (int_4* tab, size_t n)
+// void PInPersist::GetU4   (uint_4& result)
+// void PInPersist::GetU4s  (uint_4* tab, size_t n)
+// void PInPersist::GetI8   (int_8& result)
+// void PInPersist::GetI8s  (int_8* tab, size_t n)
+// void PInPersist::GetU8   (uint_8& result)
+// void PInPersist::GetU8s  (uint_8* tab, size_t n)
+//	Lecture de données portables depuis le fichier PPersist. Pour chaque type
+//	de données, on peut lire une valeur, ou un tableau de valeurs.
+// void PInPersist::GetLine(char* ptr, size_t len)
+//	Lecture d'une ligne de texte depuis le fichier PPersist.
+//--
+
+void
+PInPersist::GetByte(char& c)
+{
+  GetBytes(&c, 1);
+}
+
+void
+PInPersist::GetBytes(void* ptr, size_t bytes)
+{
+  s->read((char*)ptr, bytes);
+}
+
+static inline void bswap8(void* p)
+{
+  uint_8 tmp = *(uint_8*)p;
+  *(uint_8*)p = ((tmp >> (7*8)) & 0x000000FF) | 
+                ((tmp >> (5*8)) & 0x0000FF00) |
+                ((tmp >> (3*8)) & 0x00FF0000) |
+                ((tmp >> (1*8)) & 0xFF000000) |
+                ((tmp & 0xFF000000) << (1*8))  |
+                ((tmp & 0x00FF0000) << (3*8))  |
+                ((tmp & 0x0000FF00) << (5*8))  |
+                ((tmp & 0x000000FF) << (7*8));
+}
+
+static inline void bswap4(void* p)
+{
+  uint_4 tmp = *(uint_4*)p;
+  *(uint_4*)p = ((tmp >> 24) & 0x000000FF) | 
+                ((tmp >> 8)  & 0x0000FF00) |
+                ((tmp & 0x0000FF00) << 8)  |
+                ((tmp & 0x000000FF) << 24);
+}
+
+static inline void bswap2(void* p)
+{
+  uint_2 tmp = *(uint_2*)p;
+  *(uint_2*)p = ((tmp >> 8) & 0x00FF) | 
+                ((tmp & 0x00FF) << 8);
+}
+
+void
+PInPersist::GetR4   (r_4& result)
+{
+  GetBytes(&result, sizeof(r_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+
+void
+PInPersist::GetR4s  (r_4* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(r_4));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap4(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetR8   (r_8& result)
+{
+  GetBytes(&result, sizeof(r_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PInPersist::GetR8s  (r_8* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(r_8));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap8(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetI2   (int_2& result)
+{
+  GetBytes(&result, sizeof(int_2));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&result);
+}
+
+void
+PInPersist::GetI2s  (int_2* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(int_2));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap2(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetU2   (uint_2& result)
+{
+  GetBytes(&result, sizeof(uint_2));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&result);
+}
+
+void
+PInPersist::GetU2s  (uint_2* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(uint_2));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap2(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetI4   (int_4& result)
+{
+  GetBytes(&result, sizeof(int_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+void
+PInPersist::GetI4s  (int_4* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(int_4));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap4(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetU4   (uint_4& result)
+{
+  GetBytes(&result, sizeof(uint_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+void
+PInPersist::GetU4s  (uint_4* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(uint_4));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap4(tab+i);
+
+  return;
+}
+
+
+void
+PInPersist::GetI8   (int_8& result)
+{
+  GetBytes(&result, sizeof(int_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PInPersist::GetI8s  (int_8* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(int_8));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap8(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetU8   (uint_8& result)
+{
+  GetBytes(&result, sizeof(uint_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PInPersist::GetU8s  (uint_8* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(uint_8));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap8(tab+i);
+
+  return;
+}
+
+
+void
+PInPersist::GetLine(char* ptr, size_t len)
+{
+  s->getline(ptr, len, PIOP_Delim);
+}
+
+
+//++
+// Class	POutPersist
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Fichier d'objets persistants, en écriture.
+//--
+
+
+//++
+//  POutPersist(string const& flnm, int endianness = PPersist::PPS_NATIVE)
+//
+//	Crée un nouveau fichier ppersist. Par défaut, il est petit=boutien
+//	sur machines petit-boutiennes, et gros-boutien sur machines
+//	gros-boutiennes. On peut explicitement spécifier PPersist::PPS_LITTLE_ENDIAN
+//	ou PPersist::PPS_BIG_ENDIAN.
+//--
+POutPersist::POutPersist(string const& flnm, int endianness)
+{
+  if (endianness == -1)
+    bigEndian = IS_BIG_ENDIAN;
+  else
+    bigEndian = endianness;
+
+#ifdef RFIO
+  s = new erosofstream(flnm.c_str(),"wb");
+#else
+#if defined(__MWERKS__)
+  s = new ofstream(flnm.c_str(),ios::out | ios::binary);   // ios::binary pas connnu partout - $CHECK$ Reza 13/02/98
+#else
+  s = new ofstream(flnm.c_str(),ios::out );
+#endif
+#endif
+  PPersistMgr::Reset();
+  PutBytes("PEIDA-PPersistFile V5           ",32);
+  PutBytes(bigEndian 
+	   ? "BIG-ENDIAN                      "
+	   : "LITTLE-ENDIAN                   ",32);
+// ---- On ecrit la date de creation a partir de V5 
+  Date today;
+  string stod = today.DateStr(Date::kLocalTime) + "#" + today.TimeStr(Date::kLocalTime);
+  char buff[36];
+  int l = stod.length();
+  if (l < 33) strcpy(buff, stod.c_str()); 
+  else strncpy(buff, stod.c_str(), 33);
+  for(int i=l+1; i<32; i++)  buff[i] = ' ';
+  buff[32] = '\0'; 
+  PutBytes(buff, 32);
+//  Fin d'ecriture de date --------
+  previous = -1;  // Pas de Tag precedant
+  numTag = 0;
+}
+
+POutPersist::~POutPersist()
+{
+  PutI8(previous);
+  PutI4(numTag);
+  delete s;
+  PPersistMgr::Reset();
+}
+
+
+int_4 
+POutPersist::WriteTag(int_4 key, char const * nom)
+{
+  int_8 nexprev;
+  uint_2 l;
+  int ll;
+  char pad[4] = {'\0', '\0', '\0', '\0'};
+
+  #ifdef STREAMPOS_IS_CLASS
+  nexprev = s->tellp().offset();
+  #else
+  nexprev = s->tellp();
+  #endif
+// On ecrit dans l'ordre 
+//  - La position du tag precedant (-1 s'il n'y en a pas)
+//  - Le numero de tag ( qui s incremete automatiquement )
+//  - La cle utilisateur  (key)
+//  - La longueur du nom 
+//  - le nom lui-meme    (Avec un pad afin de faire nom+longueur=multiple de 4)
+  PutI8(previous);
+  PutI4(numTag);
+  PutI4(key);
+  if (nom==NULL)   { 
+    PutU2(0);  PutU2(0);
+  }  
+  else {
+    ll = strlen(nom);
+    if (ll <= 0) {
+      PutU2(0);  PutU2(0);
+    } 
+    l = (ll <=  MAXTAGNAMELEN) ? ll : MAXTAGNAMELEN ; 
+    PutU2(l);
+    PutBytes(nom,l+1); 
+    ll = 3-((ll+2)%4);
+    PutBytes(pad, ll);
+  }
+  previous = nexprev;
+  numTag++;
+  return((numTag-1));
+}
+
+//++
+// void POutPersist::PutByte(char& c)
+// void POutPersist::PutBytes(void const* ptr, size_t bytes)
+// void POutPersist::PutR4   (r_4 result)
+// void POutPersist::PutR4s  (r_4 const* tab, size_t n)
+// void POutPersist::PutR8   (r_8 result)
+// void POutPersist::PutR8s  (r_8 const* tab, size_t n)
+// void POutPersist::PutI2   (int_2 result)
+// void POutPersist::PutI2s  (int_2 const* tab, size_t n)
+// void POutPersist::PutU2   (uint_2 result)
+// void POutPersist::PutU2s  (uint_2 const* tab, size_t n)
+// void POutPersist::PutI4   (int_4 result)
+// void POutPersist::PutI4s  (int_4 const* tab, size_t n)
+// void POutPersist::PutU4   (uint_4 result)
+// void POutPersist::PutU4s  (uint_4 const* tab, size_t n)
+// void POutPersist::PutI8   (int_8 result)
+// void POutPersist::PutI8s  (int_8 const* tab, size_t n)
+// void POutPersist::PutU8   (uint_8 result)
+// void POutPersist::PutU8s  (uint_8 const* tab, size_t n)
+//	Ecriture de données portables.. Pour chaque type
+//	de données, on peut écrire une valeur, ou un tableau de valeurs.
+// void POutPersist::PutLine(char const* ptr, size_t len)
+//	Ecriture d'une ligne de texte dans le fichier PPersist.
+//--
+
+
+
+
+void
+POutPersist::PutByte(char c)
+{
+  PutBytes(&c, 1);
+}
+
+void
+POutPersist::PutBytes(void const* ptr, size_t bytes)
+{
+  s->write((char const*)ptr, bytes);
+}
+
+void
+POutPersist::PutR4   (r_4 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutBytes(&val, sizeof(r_4));
+}
+
+void
+POutPersist::PutR4s  (r_4 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(r_4));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutR4(tab[i]);
+}
+
+void
+POutPersist::PutR8   (r_8 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutBytes(&val, sizeof(r_8));
+}
+
+void
+POutPersist::PutR8s  (r_8 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(r_8));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutR8(tab[i]);
+}
+
+void
+POutPersist::PutI2   (int_2 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&val);
+
+  PutBytes(&val, sizeof(int_2));
+}
+
+void
+POutPersist::PutI2s  (int_2 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(int_2));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutI2(tab[i]);
+}
+
+void
+POutPersist::PutU2   (uint_2 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&val);
+
+  PutBytes(&val, sizeof(uint_2));
+}
+
+void
+POutPersist::PutU2s  (uint_2 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(uint_2));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutU2(tab[i]);
+}
+
+void
+POutPersist::PutI4   (int_4 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutBytes(&val, sizeof(int_4));
+}
+
+void
+POutPersist::PutI4s  (int_4 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(int_4));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutI4(tab[i]);
+}
+
+void
+POutPersist::PutU4   (uint_4 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutBytes(&val, sizeof(uint_4));
+}
+
+void
+POutPersist::PutU4s  (uint_4 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(uint_4));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutU4(tab[i]);
+}
+
+void
+POutPersist::PutI8   (int_8 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutBytes(&val, sizeof(int_8));
+}
+
+void
+POutPersist::PutI8s  (int_8 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(int_8));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutI8(tab[i]);
+}
+
+void
+POutPersist::PutU8   (uint_8 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutBytes(&val, sizeof(uint_8));
+}
+
+void
+POutPersist::PutU8s  (uint_8 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(uint_8));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutU8(tab[i]);
+}
+
+void
+POutPersist::PutLine(char const* ptr, size_t len)
+{
+  if (len == 0)  len = strlen(ptr);
+  s->write(ptr, len);
+#ifdef RFIO
+  char cd = PIOP_Delim;
+  s->write(&cd, 1);
+#else
+  s->put(PIOP_Delim);
+#endif  
+  
+}
+
+
+// ---  Classe d'initialisation de PEIDA++, (PPersistMgr en particulier)
+int PeidaInitiator::FgInit = 0;
+
+PeidaInitiator::PeidaInitiator()
+{
+  FgInit++;
+  if (FgInit > 1)  return;
+
+  InitFailNewHandler();
+
+  #ifdef xx__mac__
+  //InitToolBox();
+  //SIOUXSettings.initializeTB = FALSE;
+  SIOUXSettings.autocloseonquit = FALSE;
+  SIOUXSettings.asktosaveonclose = FALSE;
+  SIOUXSettings.showstatusline = TRUE;
+  #endif
+
+  PPersistMgr::classList = new PPersistMgr::ClassList;
+  PShPersist::objList    = new PShPersist::ObjList;
+  
+
+#if (!defined(__GNUG__) && !defined(__MWERKS__) && !defined(HPUX))
+  // pas de bufferisation pour printf   cmv 18/3/97 selon E.A.
+  // setvbuf(stdout,NULL,_IOLBF,0); setvbuf(stderr,NULL,_IOLBF,0);
+  setlinebuf(stdout);
+  setlinebuf(stderr);
+#endif
+
+  // si var env PEIDA_NOPRTVER definie pas de print
+  if(!getenv("PEIDA_NOPRTVER")) PrintPeidaVersion();
+}
+
+PeidaInitiator::~PeidaInitiator()
+{
+  FgInit--;
+  if (FgInit == 0)
+    {
+    delete PPersistMgr::classList; PPersistMgr::classList = NULL;
+    delete PShPersist::objList;    PShPersist::objList = NULL;
+    }
+}
+
+double PeidaInitiator::Version(bool fgprt)
+{
+if (fgprt)  PrintPeidaVersion();
+return(PeidaVersion());
+}
+ 
+// On met un objet initiator en statique, pour les loaders qui savent 
+// appeler le constructeur des objets statiques   Reza 08/98
+static PeidaInitiator ppeidainit;
+
Index: /tags/DPC_V0/SophyaLib/BaseTools/ppersist.h
===================================================================
--- /tags/DPC_V0/SophyaLib/BaseTools/ppersist.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/BaseTools/ppersist.h	(revision 1307)
@@ -0,0 +1,326 @@
+#ifndef PPERSIST_H_SEEN
+#define PPERSIST_H_SEEN
+
+// Classe mixin pour implementer une persistance pas trop bete.
+
+#include "defs.h"
+#include "machine.h"
+#include "perrors.h"
+#include "pclassids.h"
+
+#include <string>
+#include <list>
+#include <map>
+#include <functional>
+
+#if defined(__KCC__)
+using std::string ;
+#include <list.h>
+#include <map.h>
+#include <functional.h>
+#endif
+
+#ifdef RFIO
+#include "erostream.h"
+#else
+#include <iostream.h>
+#endif
+
+
+class PPersistMgr;
+class PPersist;
+class PShPersist;
+class PInPersist;
+class POutPersist;
+
+typedef less<int_4> Int4Compare;
+
+class PPersistMgr {
+public:
+  typedef PPersist*           (*ClassCreatorFunc)();
+  
+  static void                  RegisterClass(int_4 classId, ClassCreatorFunc f,
+                                             bool shared=false);
+  static PPersist*             ReadObject(PInPersist&);
+  
+  static ClassCreatorFunc      FindCreatorFunc(int_4 classId);
+  static ClassCreatorFunc      FindCreatorFunc(int_4 classId, bool& isShared);
+  
+  static void                  Reset();  // Nouveau fichier, on oublie les objets partages.
+
+#ifndef __DECCXX
+private:
+#endif
+  struct  ClassListEntry {
+    bool             shared;
+    ClassCreatorFunc f;
+  };
+#ifdef __DECCXX
+private:
+#endif
+
+  typedef map<int_4, ClassListEntry, Int4Compare> ClassList;
+
+
+  static ClassList*            classList;
+  friend class                 PeidaInitiator;
+};
+
+
+
+class PPersist EXC_AWARE {
+public:
+  enum {PPS_NATIVE = -1, PPS_LITTLE_ENDIAN = 0, PPS_BIG_ENDIAN = 1};
+  virtual                   ~PPersist() {}
+  virtual int_4              ClassId() const=0;
+
+          void               Write(string const& fn) const;
+          void               Read(string const& fn);
+
+  virtual void               Write(POutPersist&) const;
+          void               Read(PInPersist& s);  // Se lit, y compris le tag de type.
+          int_4              Write(POutPersist&, int_4 key) const; 
+          int_4              Write(POutPersist&, int_4 key, string& nom) const; 
+          void               ReadAtTag(PInPersist& s, int_4 tagid);
+          void               ReadAtKey(PInPersist& s, int_4 key);
+protected:  
+  virtual void               ReadSelf(PInPersist&)=0;        // A redefinir...
+  virtual void               WriteSelf(POutPersist&) const=0; // A redefinir...
+
+  friend class               PPersistMgr;
+};
+
+class PShPersist : public PPersist{
+public:
+                             PShPersist() :mObjectID(0) {}
+  virtual                   ~PShPersist();
+  virtual void               Write(POutPersist&) const;
+  static PShPersist*         FindObject(int_4 objId);
+  
+private:
+  typedef map<int_4, PShPersist*, Int4Compare> ObjList;
+
+  static ObjList*            objList;
+  /*mutable*/ int_4          mObjectID;
+  friend class               PPersistMgr;
+  friend class               PeidaInitiator;
+};
+
+
+
+class PInPersist {
+public:
+  PInPersist(string const& flnm, bool scan=true);
+  ~PInPersist();
+
+  bool   GotoTag(int_4 num);
+  bool   GotoKey(int_4 key, int rang=0);
+  int    NbKey(int_4 key);
+  void   ListTags();
+  inline int_4   NbTags() { return(mNTags); } 
+  int_4  TagKey(int_4 num, int_4& cid, int_4& ln);
+  string TagName(int_4 num);
+
+  void   GetByte (char& c);
+  void   GetBytes(void* ptr, size_t bytes);
+  void   GetR4   (r_4&);
+  void   GetR4s  (r_4*, size_t);
+  void   GetR8   (r_8&);
+  void   GetR8s  (r_8*, size_t);
+  void   GetI2   (int_2&);
+  void   GetI2s  (int_2*, size_t);
+  void   GetU2   (uint_2&);
+  void   GetU2s  (uint_2*, size_t);
+  void   GetI4   (int_4&);
+  void   GetI4s  (int_4*, size_t);
+  void   GetU4   (uint_4&);
+  void   GetU4s  (uint_4*, size_t);
+  void   GetI8   (int_8&);
+  void   GetI8s  (int_8*, size_t);
+  void   GetU8   (uint_8&);
+  void   GetU8s  (uint_8*, size_t);
+  void   GetLine (char* ptr, size_t len);
+
+  void   Get(char&   c) {GetByte(c);}
+  void   Get(r_4&    x) {GetR4(x);}
+  void   Get(r_8&    x) {GetR8(x);}
+  void   Get(uint_2& x) {GetU2(x);}
+  void   Get(int_2&  x) {GetI2(x);}
+  void   Get(uint_4& x) {GetU4(x);}
+  void   Get(int_4&  x) {GetI4(x);}
+  void   Get(uint_8& x) {GetU8(x);}
+  void   Get(int_8&  x) {GetI8(x);}
+  void   Get(r_4*    x, size_t n) {GetR4s(x,n);}
+  void   Get(r_8*    x, size_t n) {GetR8s(x,n);}
+  void   Get(uint_2* x, size_t n) {GetU2s(x,n);}
+  void   Get(int_2*  x, size_t n) {GetI2s(x,n);}
+  void   Get(uint_4* x, size_t n) {GetU4s(x,n);}
+  void   Get(int_4*  x, size_t n) {GetI4s(x,n);}
+  void   Get(uint_8* x, size_t n) {GetU8s(x,n);}
+  void   Get(int_8*  x, size_t n) {GetI8s(x,n);}
+
+  int    Version() {return version;}
+  string CreationDate() { return creationdate; }
+
+protected:
+  void      Scan();
+  char*     GetCStr(uint_2 l);
+#ifdef RFIO
+  erosifstream *s;
+#else
+  istream* s;
+#endif
+  int bigEndian;
+  int version;
+
+  string fName;
+  string creationdate;
+
+  struct PPFTag {
+    int_8 popos;
+    int_4 cid;
+    int_4 key;
+    uint_2 lnom;
+    char* nom;
+  };    
+  PPFTag* mTags;
+  int_4 mNTags;
+  list<char*> mSbuffs;
+  char* mSbuf;
+  int mSbsz;
+};
+
+class POutPersist {
+public:
+  POutPersist(string const& flnm, int endianness = PPersist::PPS_NATIVE);
+  ~POutPersist();
+
+  int_4 WriteTag(int_4 key, char const * name=NULL);
+  void PutByte (char c);
+  void PutBytes(void const* ptr, size_t bytes);
+  void PutR4   (r_4);
+  void PutR4s  (r_4 const*, size_t);
+  void PutR8   (r_8);
+  void PutR8s  (r_8 const*, size_t);
+  void PutI2   (int_2);
+  void PutI2s  (int_2 const*, size_t);
+  void PutU2   (uint_2);
+  void PutU2s  (uint_2 const*, size_t);
+  void PutI4   (int_4);
+  void PutI4s  (int_4 const*, size_t);
+  void PutU4   (uint_4);
+  void PutU4s  (uint_4 const*, size_t);
+  void PutI8   (int_8);
+  void PutI8s  (int_8 const*, size_t);
+  void PutU8   (uint_8);
+  void PutU8s  (uint_8 const*, size_t);
+  void PutLine (char const* ptr, size_t len=0);
+
+  void   Put(char   c) {PutByte(c);}
+  void   Put(r_4    x) {PutR4(x);}
+  void   Put(r_8    x) {PutR8(x);}
+  void   Put(uint_2 x) {PutU2(x);}
+  void   Put(int_2  x) {PutI2(x);}
+  void   Put(uint_4 x) {PutU4(x);}
+  void   Put(int_4  x) {PutI4(x);}
+  void   Put(uint_8 x) {PutU8(x);}
+  void   Put(int_8  x) {PutI8(x);}
+  void   Put(r_4 const*    x, size_t n) {PutR4s(x,n);}
+  void   Put(r_8 const*    x, size_t n) {PutR8s(x,n);}
+  void   Put(uint_2 const* x, size_t n) {PutU2s(x,n);}
+  void   Put(int_2 const*  x, size_t n) {PutI2s(x,n);}
+  void   Put(uint_4 const* x, size_t n) {PutU4s(x,n);}
+  void   Put(int_4 const*  x, size_t n) {PutI4s(x,n);}
+  void   Put(uint_8 const* x, size_t n) {PutU8s(x,n);}
+  void   Put(int_8 const*  x, size_t n) {PutI8s(x,n);}
+
+
+protected:
+#ifdef RFIO
+  erosofstream *s;
+#else
+  ostream* s;
+#endif
+  int bigEndian;
+  int_4 numTag;
+  int_8 previous;
+};
+
+/* 
+// Ceci est dangereux car un template a priorite sur un changement de type, meme trivial...
+
+template <class T>
+POutPersist& operator << (POutPersist& c, T const& data)
+{
+  c.PutBytes(&data, sizeof(T));
+  return c;
+}
+
+template <class T>
+PInPersist& operator >> (PInPersist& c, T& data)
+{
+  c.GetBytes(&data, sizeof(T));
+  return c;
+}
+*/
+
+#define RAWPERSISTIO(_Type_,_xtyp_)                                             \
+inline POutPersist& operator << (POutPersist& c, _Type_ const& data)            \
+{                                                                               \
+  c.Put##_xtyp_(data);                                                        \
+  return c;                                                                     \
+}                                                                               \
+                                                                                \
+inline PInPersist& operator >> (PInPersist& c, _Type_& data)                    \
+{                                                                               \
+  c.Get##_xtyp_(data);                                                        \
+  return c;                                                                     \
+}                                                                               
+
+RAWPERSISTIO(int_4,I4)
+RAWPERSISTIO(uint_4,U4)
+RAWPERSISTIO(int_2,I2)
+RAWPERSISTIO(uint_2,U2)
+RAWPERSISTIO(char,Byte)
+RAWPERSISTIO(r_4,R4)
+RAWPERSISTIO(r_8,R8)
+
+#if 0
+#define STRUCTPERSISTIO(_Type_, _field_, _size_)                                \
+inline POutPersist& operator << (POutPersist& c, _Type_ const& data)            \
+{                                                                               \
+  c.PutBytes(&data._field_, _size_);                                            \
+  return c;                                                                     \
+}                                                                               \
+                                                                                \
+inline PInPersist& operator >> (PInPersist& c, _Type_& data)                    \
+{                                                                               \
+  c.GetBytes(&data._field_, _size_);                                            \
+  return c;                                                                     \
+}                                                                               
+
+#endif
+
+inline POutPersist& operator << (POutPersist& c, PPersist const& obj)
+{
+  obj.Write(c);
+  return c;
+}
+
+inline PInPersist& operator >> (PInPersist& c, PPersist& obj)
+{
+  obj.Read(c);
+  return c;
+}
+
+// Fabrication de fonction Create automatique, et enregistrement...
+template <class T>
+class PPersistRegistrar {
+public:
+  static PPersist* Create() {return new T();}
+  static void Register() {PPersistMgr::RegisterClass(T::classId,Create);}
+};
+
+#define PPRegister(className) PPersistRegistrar<className>::Register();
+
+#endif
Index: /tags/DPC_V0/SophyaLib/Mgr/Makefile
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/Makefile	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/Makefile	(revision 1307)
@@ -0,0 +1,168 @@
+include Mgr/Makefile.h
+LIBF =  $(LIB)libOutils++.a $(LIB)libImages++.a $(LIB)libStarReco++.a $(LIB)libNeuralNet.a $(LIB)libAcq.a
+LIBS = -L$(LIB) -lOutils++ -lImages++ -lStarReco++ -lNeuralNet -lAcq -lm
+LIBG = -L$(GLB) -lg++ -lstdc++
+
+defaut: prog
+
+all: acq pi prog
+
+acq: ProgAcq
+pi:  ProgPI
+prog: Prog
+
+ProgAcq: Db++ Db Acq libs slb slbacq
+ProgPI:  PI libs slb slbpi
+Prog: libs slb
+
+libs: clibs cxxlibs
+clibs:
+	cd LibsUtil ; $(MAKE)
+	cd ImagFSuiv ; $(MAKE)
+	cd NR ; $(MAKE)
+
+# Dans cet ordre pour les templates de cxx, a cause des dependances
+# pour instantiation automatique/manuels
+
+cxxlibs: NeuralNet Outils++ Images++ StarReco++ 
+
+.PHONY:  Acq
+Acq:
+	if [ -d Acq ] ; then cd  Acq ; $(MAKE) ; fi
+ 
+.PHONY:  StarReco++
+StarReco++:
+	if [ -d StarReco++ ] ; then cd  StarReco++ ; $(MAKE) ; fi
+ 
+.PHONY:  Images++
+Images++:
+	if [ -d Images++ ] ; then cd  Images++ ; $(MAKE) ; fi
+ 
+.PHONY:  Outils++
+Outils++:
+	if [ -d Outils++ ] ; then cd  Outils++ ; $(MAKE) ; fi
+ 
+.PHONY:  NeuralNet
+NeuralNet:
+	if [ -d NeuralNet ] ; then cd  NeuralNet ; $(MAKE) ; fi
+ 
+.PHONY: PI
+PI:
+	if [ -d PI ] ; then cd PI ; $(MAKE) ; fi
+	if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi
+.PHONY:  Db
+Db:
+	if [ -d Db ] ; then cd Db ; $(MAKE); fi
+ 
+.PHONY:  Db++
+Db++:
+	if [ -d Db++ ] ; then cd Db++ ; $(MAKE); fi
+ 
+.PHONY: Prog
+Prog:
+	if [ -d Prog ]; then cd  Prog ; $(MAKE); fi
+ 
+.PHONY: ProgAcq
+ProgAcq:
+	if [ -d ProgAcq ]; then cd  ProgAcq ; $(MAKE); fi
+ 
+.PHONY: ProgPI
+ProgPI:
+	if [ -d ProgPI ]; then cd  ProgPI ; $(MAKE); fi
+ 
+ifndef NOSHLIB
+
+PSLB = $(LIB)libStarReco++.a $(LIB)libNeuralNet.a $(LIB)libImages++.a $(LIB)libOutils++.a
+slb : $(SLB)libnr.so $(SLB)liberosc.so $(SLB)libpeida.so
+slbpi: slb $(SLB)libPI.so
+slbacq: slb $(SLB)libAcq.so
+
+#  Commande de construction de shared-lib 
+CMDSHL := ld -partage
+#  Flag d'inclusion/fin d'inclusion de tous les points  d'entree
+FGSHLA := -tout
+FGSHLN := -rien
+#  Librairies specifiques 
+LIBLSHL := 
+#  Librairie d'instanciation des templates 
+TILSHL := 
+TILSHLPI := 
+#   Commande de construction de la librairie d'instanciation des templates 
+CMDTILSHL := echo 'Cas Non Prevu'
+CMDTILSHLPI := echo 'Cas Non Prevu'
+
+# Construction de shared-libs sous OSF1
+ifeq ($(MACHEROS),OSF1)
+  override CMDSHL := ld -shared -update_registry $(SLB)so_locations
+  override FGSHLA := -all
+  override FGSHLN := -none 
+  override LIBLSHL := -lcxxstd -lcxx -lexc -lm -lc -lrt
+  override TILSHL := $(LIB)libertcxx.a
+  override CMDTILSHL := rm -f $(LIB)libertcxx.a ; cd $(REP); $(AR) $(ARFLAGS) $(LIB)libertcxx.a *.o
+  override TILSHLPI := $(LIB)libertcxxpi.a
+  override CMDTILSHLPI := rm -f $(LIB)libertcxxpi.a ; cd $(REPPI); $(AR) $(ARFLAGS) $(LIB)libertcxxpi.a *.o
+  ifeq ($(CXX),g++)
+    override LIBLSHL := $(LIBG) -lm -lc
+    override TILSHL := 
+    override CMDTILSHL := echo 'No Template instanciation library'
+    override TILSHLPI := 
+    override CMDTILSHLPI := echo 'No Template instanciation library'
+  endif
+endif
+
+# Construction de shared-libs sous Linux
+ifeq ($(MACHEROS),Linux)
+  override CMDSHL := ld -shared 
+  override FGSHLA := --whole-archive
+  override FGSHLN := --no-whole-archiv
+  override LIBLSHL := $(LIBG) -lm -lc
+  override TILSHL := 
+  override CMDTILSHL := echo 'No Template instanciation library'
+endif
+
+
+$(SLB)libnr.so : $(LIB)libnra.a
+	$(CMDSHL) -o $(SLB)libnr.so \
+	$(FGSHLA) $(LIB)libnra.a \
+	$(FGSHLN) $(LIBLSHL)
+
+$(SLB)liberosc.so : $(LIB)libdiv.a $(LIB)libmath.a \
+                    $(LIB)libfsv.a $(LIB)libimage.a
+	$(CMDSHL) -o $(SLB)liberosc.so \
+	$(FGSHLA) $(LIB)libdiv.a $(LIB)libmath.a \
+	$(LIB)libfsv.a $(LIB)libimage.a \
+	$(FGSHLN) $(LIBLSHL)
+
+$(SLB)libpeida.so : $(PSLB) $(SLB)liberosc.so $(SLB)libnr.so
+	$(CMDTILSHL)
+	$(CMDSHL) -o $(SLB)libpeida.so \
+	$(FGSHLA) $(PSLB) $(TILSHL) \
+	$(FGSHLN) -L$(SLB) -lerosc -lnr $(LIBLSHL)
+
+$(SLB)libAcq.so : $(LIB)libAcq.a $(SLB)libpeida.so
+	$(CMDSHL) -o $(SLB)libAcq.so \
+	$(FGSHLA) $(LIB)libDb++.a $(LIB)libErosDb.a $(LIB)libAcq.a \
+	$(FGSHLN) -L$(SLB) -lpeida -lerosc -L$(ORACLE_HOME)/lib -lclntsh $(LIBLSHL)
+
+$(SLB)libPI.so : $(LIB)libPI.a $(LIB)libPIext.a  
+	$(CMDTILSHLPI)
+	$(CMDSHL) -o $(SLB)libPI.so \
+	$(FGSHLA) $(LIB)libPI.a $(LIB)libPIext.a $(TILSHLPI) \
+	$(FGSHLN) -L$(SLB) -lpeida -lerosc \
+	-lXm -lXt -lX11 $(LIBLSHL)
+
+else
+slb :
+endif
+
+clean:
+	if [ -d $(LIB) ] ; then cd $(LIB)/. ; rm -f *.a  ; fi
+	if [ -d $(SLB) ] ; then cd $(SLB)/. ; rm -f *.so ; fi
+	if [ -d $(OBJ) ] ; then cd $(OBJ)/. ; rm -f *.o  ; fi
+	if [ -d $(OBJ)/cxxrep ] ; then cd $(OBJ)/cxxrep/. ; rm -f *.o  ; fi
+	if [ -d NR ]     ; then cd NR/.     ; make -f Makefile clean ; fi
+	if [ -d PI ]     ; then cd PI/.     ; $(MAKE) clean ; fi
+	if [ -d Prog ]   ; then cd Prog/.   ; $(MAKE) clean ; fi
+	if [ -d ProgPI ] ; then cd ProgPI/. ; $(MAKE) clean ; fi
+	if [ -d ProgAcq ]; then cd ProgAcq/.; $(MAKE) clean ; fi
+
Index: /tags/DPC_V0/SophyaLib/Mgr/Makefile.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/Makefile.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/Makefile.h	(revision 1307)
@@ -0,0 +1,363 @@
+#  -*- makefile -*-
+# ######################### PEIDA++ ############################# 
+# ##### LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA #####
+# ############################################################### 
+# General setup GNU Makefile for EROS. To be included in all makefiles.  
+# Define  makefile variables according to CPU 
+# MACHEROSD = `uname | sed 's/-//'`   i.e. { AIX HPUX OSF1 Linux ... }
+# and compilers {g++, cxx, KCC, xlC, aCC, ...}
+# 
+# Makefile variables set are:
+# - Path to Exec, Include, Libs, Obj directories (from DPCDEVREP env. var.)
+#     i.e. variables LIB, OBJ, EXE, INC 
+#---------------------------------------------------------------------------
+
+# define MACHEROS from uname
+MACHEROS := $(shell echo `uname`)
+# define the -D option
+MACHEROSD := $(shell echo `uname | sed 's/-//'`)
+# Le sous-repertoire des objets specifique machine-compilo
+#   OSF1 : Alpha avec gcc
+#   OSF1-cxx : Alpha avec cxx
+
+#### C++
+ifdef EROSCXX
+  CXX := $(EROSCXX)
+endif
+
+ifeq ($(CXX),gcc)
+  override CXX := g++
+endif
+
+ifeq ($(EROSCXX),egcs++)
+  # en fait de compilo de egcs++ s'appelle g++ !
+  # comme il faut bien differentier ln -s /usr/bin/g++ /usr/bin/egcs++
+  override CXX := egcs++
+endif
+
+ifeq ($(CC),xlC)
+  override CXX := xlC
+endif
+
+#### C
+ifeq ($(CXX), xlC)
+  override CC := xlC
+endif
+
+ifeq ($(CXX), g++)
+  CC := gcc
+endif
+
+ifeq ($(EROSCXX), egcs++)
+  CC := egcs
+endif
+
+#### Fortran (tout ce qui est lie au Fortran est defini ici #############
+FC = f77
+ifeq ($(SITE),CCIN2P3)
+  ifeq ($(MACHEROS),AIX)
+    override FC := xlf
+  endif
+endif
+ifeq (${MACHEROS},Linux)
+#  override FC := f77
+  override FC := g77
+endif
+
+ifeq (${MACHEROS},OSF1)
+  LIBFORT = -lfor -lFutil -lots -lUfor
+endif
+ifeq (${MACHEROS},Linux)
+  LIBFORT = -lf2c
+endif
+#########################################################################
+
+
+MACHDIR := $(MACHEROS)-$(CXX)
+
+
+#-
+#-   Define Makefile paths
+#-  (NE PAS TOUCHER CES LIGNES: generation automatique de MakefileUser.h)
+#-  
+PP  := ${DPCDEVREP}/${MACHDIR}/
+LIB := ${PP}/Libs/
+SLB := ${PP}/ShLibs/
+OBJ := ${PP}/Objs/
+EXE := ${PP}/Exec/
+INC := ${DPCDEVREP}/Include/
+CCI := ${INC}/CInc/
+GLB := ${GNU}/${MACHEROS}/lib/
+#--
+
+#-   Flag for optimisation/ debug
+# Pour forcer sans debug, DBGFLAG = -g0
+ifndef OPTFLAG
+  OPTFLAG  := -O
+endif
+
+ifndef DBGFLAG
+  DBGFLAG  := -g
+endif
+
+# DBGFLAG a -g0 veut dire pas de debug. Tout le monde a ca par defaut...
+ifeq ($(DBGFLAG), -g0)
+  override DBGFLAG :=
+endif
+
+# xlC ne connait pas -O0, par defaut il n'optimise pas.
+ifeq ($(OPTFLAG), -O0)
+  ifeq ($(CC), xlC)
+    override OPTFLAG :=
+  endif
+endif
+
+AR       := ar
+ARFLAGS  := -rcs
+
+# le gnu ar ne fonctionne pas bien sur OSF...
+ifeq (${MACHEROS},OSF1)
+AR       := /usr/bin/ar
+endif
+# et sur AIX il nous sort des tas de warnings inutiles
+ifeq ($(MACHEROS),AIX)
+AR := /usr/bin/ar
+endif
+
+#   Avec certains compilateurs C++ (KCC, aCC) , il faut fabriquer les librairies et 
+# les shared libs avec la meme commande 
+override ARCXX := 
+ifeq ($(CXX),KCC)
+ARCXX  := KCC
+endif
+ifeq ($(CXX),aCC)
+ARCXX  := aCC
+endif
+
+# Les chemins speciaux pour includes systemes et bibliotheques
+ifeq (${MACHEROS},HP-UX)
+  XLDLIBS := -L.
+  XCFLAGS := -I.
+endif
+
+#  Pour compiler PI, sous Linux, les includes et libs se trouve souvent ds /usr/X11/include /usr/X11/lib/
+ifeq (${MACHEROS},Linux)
+  XLDLIBS := -L/usr/X11/lib 
+  XCFLAGS := -I/usr/X11/include
+  LDLIBS := -ldl
+endif
+
+# Pour RFIO
+ifeq ($(SITE),CCIN2P3)
+  XCFLAGS := $(XCFLAGS) -D RFIO -I/usr/local/include/shift
+  XLDLIBS := $(XLDLIBS) -L/usr/local/lib -lshift
+endif
+
+# Les bibliotheques gnu C pour le fort du CCPN
+ifeq ($(SITE),CCIN2P3)
+ ifeq ($(CC), gcc)
+  ifeq ($(MACHEROS),HP-UX)
+     FGLIB := -L/usr/local/lib/gcc-lib/hppa1.1-hp-hpux9.05/2.7.2.1 -lgcc
+  endif
+  ifeq ($(MACHEROS),AIX)
+     FGLIB := -L/usr/local/lib/gcc-lib/rs6000-ibm-aix3.2.5/2.7.2.1 -lgcc
+  endif
+ endif
+endif
+
+#  S'il y a des flags particulier pour un module de compilation
+#ifndef MODULECPPFLAGS
+  override MODULECPPFLAGS :=
+#endif
+
+CPPFLAGS     :=  -I${INC} -D${MACHEROSD} -I$(INC)/tnt $(MODULECPPFLAGS)
+
+# Les options selon les divers compilateurs
+# GNU
+ifeq ($(CC), gcc)
+  CFLAGS       := -Wall -Wpointer-arith \
+                  -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \
+                  $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS)
+  LDLIBS       := $(LDLIBS) $(XLDLIBS)
+endif
+ifeq ($(CC), egcs)
+  CFLAGS       := -Wall -Wpointer-arith \
+                  -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \
+                  $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS)
+  LDLIBS       := $(LDLIBS) $(XLDLIBS)
+endif
+
+ifeq ($(CXX), g++)
+  CXXFLAGS       := -Wall -Wpointer-arith \
+                    -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \
+                    $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) 
+  LDLIBS      := $(LDLIBS) $(XLDLIBS)
+#  Il faut trouver un moyen d'automatiser ca $CHECK$  Reza 23/12/98
+  ifdef GCCV28
+    CXXFLAGS := $(CXXFLAGS) -fguiding-decls -fname-mangling-version-1 -DCOMPILER_EXCEPTIONS
+  endif
+  ifdef NOSHLIB 
+    LDFLAGS := -static
+  endif
+endif
+ifeq ($(CXX), egcs++)
+  CXXFLAGS       := -Wall -Wpointer-arith \
+                    -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \
+                    $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) 
+  LDLIBS      := $(LDLIBS) $(XLDLIBS)
+  ifdef NOSHLIB 
+    LDFLAGS := -static
+  endif
+endif
+
+# Compilateur C natif HP-UX
+ifeq (${MACHEROS},HP-UX)
+ifeq ($(CC),cc)                                    
+  CFLAGS       :=  +Z -Aa -Ae $(XCFLAGS) $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) 
+  FFLAGS       :=  -Aa -I${INC}   -D${MACHEROSD}  
+  CPPFLAGS     :=  -I${INC}  -I$(INC)/tnt -D${MACHEROSD} \
+               -D_HPUX_SOURCE $(MODULECPPFLAGS)
+  LDLIBS      := $(XLDLIBS)
+  override NOSHLIB := Y
+
+endif
+ifeq ($(CXX),aCC)
+  CXXFLAGS := $(XCFLAGS) $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) +Z -D__aCC__
+#  -DCOMPILER_EXCEPTIONS -D__ANSI_TEMPLATES__  definis ds defs.h
+endif
+endif
+
+# AIX, xlC comme compilateur C et C++
+ifeq ($(CXX), xlC)
+  CFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) $(XCFLAGS)
+  CPPFLAGS := -I$(INC)/Syst -I${INC}  -I$(INC)/tnt -D${MACHEROSD} $(MODULECPPFLAGS)
+  CXXFLAGS     := $(CFLAGS) -D__xlC -DCOMPILER_EXCEPTIONS
+# -DCOMPILER_EXCEPTIONS defini ds defs.h
+  LDLIBS      := $(XLDLIBS)
+
+# Pour faire des bibliotheques partagees, il faut faire un truc du
+# style 
+#ld -o shrsub.o subs1.o subs2.o -bE:shrsub.exp -bM:SRE -lc
+
+# Pour le moment on ne se fatigue pas, tant pis
+  override NOSHLIB := Y
+
+# Et puis 1540-293: (W) est un FAUX warning, on supprime les warnings
+  CXXFLAGS := -qflag=e $(CXXFLAGS)
+endif
+
+#gcc sur Solaris
+ifeq ($(MACHEROS),SunOS)
+ override NOSHLIB := Y
+endif
+
+ifeq ($(CXX), cxx)
+  ifeq ($(DBGFLAG), -g)
+    ifdef OPTFLAG
+      override DBGFLAG := -g1
+    endif
+#    ifdef XOPT
+#      override DBGFLAG := -g1
+#    endif
+  endif
+
+# chemin pour repository CXX
+ REP := $(OBJ)/cxxrep/
+ REPPI := $(OBJ)/cxxrep_PI/
+ REPCXX := -ptr $(OBJ)/cxxrep/
+ ifdef MODULECXXREPNAME
+   REPCXX := -ptr $(OBJ)/cxxrep_$(MODULECXXREPNAME)/  -ptr $(OBJ)/cxxrep/
+   REPM := $(OBJ)/cxxrep_$(MODULECXXREPNAME)/
+ endif
+
+  LDLIBS      := $(XLDLIBS) -lrt
+
+  CXXFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS  \
+              $(REPCXX) -no_implicit_include 
+  CFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS)
+#  CXXFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \
+#	      -nopt -define_templates
+  ifeq ($(XOPT), 1)
+    override DBGFLAG :=
+    CXXFLAGS := $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \
+	        $(REPCXX) -fp_reorder \
+	        -O5 -inline speed -tune host
+  endif
+  ifeq ($(XOPT), 2)
+    override DBGFLAG :=
+    CXXFLAGS := $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \
+	      $(REPCXX) -fp_reorder \
+	      -O5 -inline speed -tune host \
+	      -assume trusted_short_alignment
+  endif
+  ifeq ($(XOPT), 3)
+    override DBGFLAG :=
+    CXXFLAGS := $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \
+	      $(REPCXX) -fp_reorder \
+	      -O5 -inline speed -tune host \
+	      -assume trusted_short_alignment \
+	      -non_shared -om
+    override NOSHLIB := Y
+  endif
+
+# le fichier X11/Xlib.h contient des declarations de fonctions sans type
+# Cela genere un grand nombre de warning avec cxx V6
+# La variable MODULEDECCXXFLAGS permet de specifier des options de compilation 
+# pour un module donne  
+  ifdef MODULEDECCXXFLAGS
+    CXXFLAGS := $(CXXFLAGS) $(MODULEDECCXXFLAGS)
+  endif
+endif
+ifeq ($(CC),cc)
+  ifeq ($(MACHEROS),OSF1)
+  ifeq ($(XOPT), 1)
+    CFLAGS :=  $(DBGFLAG) $(MYCFLAGS) -fp_reorder \
+	      -O4 -inline speed -tune host
+  endif
+  ifeq ($(XOPT), 2)
+    CFLAGS :=  $(DBGFLAG) $(MYCFLAGS) -fp_reorder \
+	      -O4 -inline speed -tune host \
+	      -assume trusted_short_alignment -fast
+  endif
+  ifeq ($(XOPT), 3)
+    CFLAGS :=  $(DBGFLAG) $(MYCFLAGS) -fp_reorder \
+	      -O4 -inline speed -tune host \
+	      -assume trusted_short_alignment -fast \
+	      -non_shared -om
+  endif
+  endif
+endif
+
+
+#  Compilateur KAI 
+ifeq ($(CXX), KCC)
+  CXXFLAGS     :=  --exceptions --rtti  --auto_instantiation --one_instantiation_per_object -D__KCC__
+# Flag --one_instantiation_per_object mis - Reza 02/03/99
+# -DCOMPILER_EXCEPTIONS -D__ANSI_TEMPLATES__  definis ds defs.h 
+endif
+
+# Autres compilateurs natifs.
+
+#  CFLAGS       :=  -I$(INC) $(XCFLAGS) $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS)
+#  CXXFLAGS     := $(CFLAGS)
+#  LDLIBS      := $(XLDLIBS)
+
+#- redefine implicit rule. Les .o sont dans $(OBJ).
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -o $@ $<
+
+$(OBJ)%.o:%.cc
+	$(COMPILE.cc) -o $@ $<
+
+$(OBJ)%.o:%.f
+	$(COMPILE.f) -o $@ $< 
+
+#OSF1
+#LDFC est f77
+#LDFCFLAGS est rien
+
+#parfois
+#LDFC est cc
+#LDFCFLAGS est -ltruc
+
+#------------------------------------------------- End of Makefile.h ------- 
Index: /tags/DPC_V0/SophyaLib/Mgr/Makefile.slb
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/Makefile.slb	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/Makefile.slb	(revision 1307)
@@ -0,0 +1,87 @@
+
+ifndef NOSHLIB
+
+PSLB = $(LIB)libSysTools.a $(LIB)libNTools.a $(LIB)libBlitz.a 
+slb : $(SLB)libtools.so
+slbpi: slb $(SLB)libPI.so
+
+#  Commande de construction de shared-lib 
+CMDSHL := ld -partage
+#  Flag d'inclusion/fin d'inclusion de tous les points  d'entree
+FGSHLA := -tout
+FGSHLN := -rien
+#  Librairies specifiques 
+LIBLSHL := 
+#  Librairie d'instanciation des templates 
+TILSHL := 
+TILSHLPI := 
+#   Commande de construction de la librairie d'instanciation des templates 
+CMDTILSHL := echo 'Cas Non Prevu'
+CMDTILSHLPI := echo 'Cas Non Prevu'
+#  Chemin des librairies Motifs / X11 (pour chemin non standard)
+LIBXPATH :=
+
+# Construction de shared-libs sous OSF1
+ifeq ($(MACHEROS),OSF1)
+  override CMDSHL := ld -shared -update_registry $(SLB)so_locations
+  override FGSHLA := -all
+  override FGSHLN := -none 
+  override LIBLSHL := -lcxxstd -lcxx -lexc -lm -lc -lrt
+  override TILSHL := $(LIB)libertcxx.a
+  override CMDTILSHL := rm -f $(LIB)libertcxx.a ; cd $(REP); $(AR) $(ARFLAGS) $(LIB)libertcxx.a *.o
+  override TILSHLPI := $(LIB)libertcxxpi.a
+  override CMDTILSHLPI := rm -f $(LIB)libertcxxpi.a ; cd $(REPPI); $(AR) $(ARFLAGS) $(LIB)libertcxxpi.a *.o
+  ifeq ($(CXX),g++)
+    override LIBLSHL := $(LIBG) -lm -lc
+    override TILSHL := 
+    override CMDTILSHL := echo 'No Template instanciation library'
+    override TILSHLPI := 
+    override CMDTILSHLPI := echo 'No Template instanciation library'
+  endif
+endif
+
+# Construction de shared-libs sous Linux
+ifeq ($(MACHEROS),Linux)
+  override CMDSHL := ld -shared 
+  override FGSHLA := --whole-archive
+  override FGSHLN := --no-whole-archiv
+  override CMDSHLCXX := $(LINK.cc) -shared 
+  override FGSHLACXX := 
+  override FGSHLNCXX := 
+  override LIBLSHL := $(LIBG) -lm -ldl
+  override TILSHL := 
+  override CMDTILSHL := echo 'No Template instanciation library'
+  override LIBXPATH := -L/usr/X11/lib
+endif
+
+# Liste des .o associes a une librairie
+OBJSysTools = $(shell echo `cat ./SysTools/SysTools.o.list`)
+OBJNTools = $(shell echo `cat ./NTools/NTools.o.list`)
+OBJBlitz = $(shell echo `cat ./Blitz/Blitz.o.list`)
+OBJPI         = $(shell echo `cat ./PI/PI.o.list`)
+OBJPIext      = $(shell echo `cat ./PIext/PIext.o.list`)
+
+# Creation des librairies partagees
+
+
+#------------------------------------------------------------
+$(SLB)libtools.so : $(PSLB) 
+	$(CMDTILSHL)
+	cd $(OBJ); \
+	$(CMDSHLCXX) -o $(SLB)libtools.so \
+	$(FGSHLACXX) $(OBJSysTools) $(OBJNTools) $(OBJBlitz) $(TILSHL) \
+	$(FGSHLNCXX) -L$(SLB) $(LIBLSHL)
+
+
+$(SLB)libPI.so : $(LIB)libPI.a $(LIB)libPIext.a
+	$(CMDTILSHLPI)
+	cd $(OBJ); \
+	$(CMDSHLCXX) -o $(SLB)libPI.so \
+	$(FGSHLACXX) $(OBJPI) $(OBJPIext) $(TILSHLPI) \
+	$(FGSHLN) -L$(SLB) -ltools \
+	$(LIBXPATH) -lXm -lXt -lX11 $(LIBLSHL)
+
+else
+slb :
+endif
+
Index: /tags/DPC_V0/SophyaLib/Mgr/MakefileUser.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/MakefileUser.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/MakefileUser.h	(revision 1307)
@@ -0,0 +1,365 @@
+#  -*- makefile -*-
+# ######################### PEIDA++ ############################# 
+# ##### LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA #####
+# ############################################################### 
+# General setup GNU Makefile for EROS. To be included in all makefiles.  
+# Define  makefile variables according to CPU 
+# MACHEROSD = `uname | sed 's/-//'`   i.e. { AIX HPUX OSF1 Linux ... }
+# and compilers {g++, cxx, KCC, xlC, aCC, ...}
+# 
+# Makefile variables set are:
+# - Path to Exec, Include, Libs, Obj directories (from DPCDEVREP env. var.)
+#     i.e. variables LIB, OBJ, EXE, INC 
+#---------------------------------------------------------------------------
+
+# define MACHEROS from uname
+MACHEROS := $(shell echo `uname`)
+# define the -D option
+MACHEROSD := $(shell echo `uname | sed 's/-//'`)
+# Le sous-repertoire des objets specifique machine-compilo
+#   OSF1 : Alpha avec gcc
+#   OSF1-cxx : Alpha avec cxx
+
+#### C++
+ifdef EROSCXX
+  CXX := $(EROSCXX)
+endif
+
+ifeq ($(CXX),gcc)
+  override CXX := g++
+endif
+
+ifeq ($(EROSCXX),egcs++)
+  # en fait de compilo de egcs++ s'appelle g++ !
+  # comme il faut bien differentier ln -s /usr/bin/g++ /usr/bin/egcs++
+  override CXX := egcs++
+endif
+
+ifeq ($(CC),xlC)
+  override CXX := xlC
+endif
+
+#### C
+ifeq ($(CXX), xlC)
+  override CC := xlC
+endif
+
+ifeq ($(CXX), g++)
+  CC := gcc
+endif
+
+ifeq ($(EROSCXX), egcs++)
+  CC := egcs
+endif
+
+#### Fortran (tout ce qui est lie au Fortran est defini ici #############
+FC = f77
+ifeq ($(SITE),CCIN2P3)
+  ifeq ($(MACHEROS),AIX)
+    override FC := xlf
+  endif
+endif
+ifeq (${MACHEROS},Linux)
+#  override FC := f77
+  override FC := g77
+endif
+
+ifeq (${MACHEROS},OSF1)
+  LIBFORT = -lfor -lFutil -lots -lUfor
+endif
+ifeq (${MACHEROS},Linux)
+  LIBFORT = -lf2c
+endif
+#########################################################################
+
+
+MACHDIR := $(MACHEROS)-$(CXX)
+
+
+#-
+#-   Define Makefile paths
+#-  (NE PAS TOUCHER CES LIGNES: generation automatique de MakefileUser.h)
+#-  
+PP  := ${DPCBASEREP}/${MACHDIR}/
+PPH := ${HOME}/${MACHDIR}/
+LIB := ${PP}/Libs/
+SLB := ${PP}/ShLibs/
+OBJ := ${PPH}/Objs/
+EXE := ${PPH}/Exec/
+INC := ${DPCBASEREP}/Include/
+CCI := ${INC}/CInc/
+GLB := ${GNU}/${MACHEROS}/lib/
+#--
+
+#-   Flag for optimisation/ debug
+# Pour forcer sans debug, DBGFLAG = -g0
+ifndef OPTFLAG
+  OPTFLAG  := -O
+endif
+
+ifndef DBGFLAG
+  DBGFLAG  := -g
+endif
+
+# DBGFLAG a -g0 veut dire pas de debug. Tout le monde a ca par defaut...
+ifeq ($(DBGFLAG), -g0)
+  override DBGFLAG :=
+endif
+
+# xlC ne connait pas -O0, par defaut il n'optimise pas.
+ifeq ($(OPTFLAG), -O0)
+  ifeq ($(CC), xlC)
+    override OPTFLAG :=
+  endif
+endif
+
+AR       := ar
+ARFLAGS  := -rcs
+
+# le gnu ar ne fonctionne pas bien sur OSF...
+ifeq (${MACHEROS},OSF1)
+AR       := /usr/bin/ar
+endif
+# et sur AIX il nous sort des tas de warnings inutiles
+ifeq ($(MACHEROS),AIX)
+AR := /usr/bin/ar
+endif
+
+#   Avec certains compilateurs C++ (KCC, aCC) , il faut fabriquer les librairies et 
+# les shared libs avec la meme commande 
+override ARCXX := 
+ifeq ($(CXX),KCC)
+ARCXX  := KCC
+endif
+ifeq ($(CXX),aCC)
+ARCXX  := aCC
+endif
+
+# Les chemins speciaux pour includes systemes et bibliotheques
+ifeq (${MACHEROS},HP-UX)
+  XLDLIBS := -L.
+  XCFLAGS := -I.
+endif
+
+#  Pour compiler PI, sous Linux, les includes et libs se trouve souvent ds /usr/X11/include /usr/X11/lib/
+ifeq (${MACHEROS},Linux)
+  XLDLIBS := -L/usr/X11/lib 
+  XCFLAGS := -I/usr/X11/include
+  LDLIBS := -ldl
+endif
+
+# Pour RFIO
+ifeq ($(SITE),CCIN2P3)
+  XCFLAGS := $(XCFLAGS) -D RFIO -I/usr/local/include/shift
+  XLDLIBS := $(XLDLIBS) -L/usr/local/lib -lshift
+endif
+
+# Les bibliotheques gnu C pour le fort du CCPN
+ifeq ($(SITE),CCIN2P3)
+ ifeq ($(CC), gcc)
+  ifeq ($(MACHEROS),HP-UX)
+     FGLIB := -L/usr/local/lib/gcc-lib/hppa1.1-hp-hpux9.05/2.7.2.1 -lgcc
+  endif
+  ifeq ($(MACHEROS),AIX)
+     FGLIB := -L/usr/local/lib/gcc-lib/rs6000-ibm-aix3.2.5/2.7.2.1 -lgcc
+  endif
+ endif
+endif
+
+#  S'il y a des flags particulier pour un module de compilation
+#ifndef MODULECPPFLAGS
+  override MODULECPPFLAGS :=
+#endif
+
+CPPFLAGS     :=  -I${INC} -D${MACHEROSD} -I$(INC)/tnt $(MODULECPPFLAGS)
+
+# Les options selon les divers compilateurs
+# GNU
+ifeq ($(CC), gcc)
+  CFLAGS       := -Wall -Wpointer-arith \
+                  -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \
+                  $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS)
+  LDLIBS       := $(LDLIBS) $(XLDLIBS)
+endif
+ifeq ($(CC), egcs)
+  CFLAGS       := -Wall -Wpointer-arith \
+                  -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \
+                  $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS)
+  LDLIBS       := $(LDLIBS) $(XLDLIBS)
+endif
+
+ifeq ($(CXX), g++)
+  CXXFLAGS       := -Wall -Wpointer-arith \
+                    -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \
+                    $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) 
+  LDLIBS      := $(LDLIBS) $(XLDLIBS)
+#  Il faut trouver un moyen d'automatiser ca $CHECK$  Reza 23/12/98
+  ifdef GCCV28
+    CXXFLAGS := $(CXXFLAGS) -fguiding-decls -fname-mangling-version-1 -DCOMPILER_EXCEPTIONS
+  endif
+  ifdef NOSHLIB 
+    LDFLAGS := -static
+  endif
+endif
+ifeq ($(CXX), egcs++)
+  CXXFLAGS       := -Wall -Wpointer-arith \
+                    -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \
+                    $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) 
+  LDLIBS      := $(LDLIBS) $(XLDLIBS)
+  ifdef NOSHLIB 
+    LDFLAGS := -static
+  endif
+endif
+
+# Compilateur C natif HP-UX
+ifeq (${MACHEROS},HP-UX)
+ifeq ($(CC),cc)                                    
+  CFLAGS       :=  +Z -Aa -Ae $(XCFLAGS) $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) 
+  FFLAGS       :=  -Aa -I${INC}   -D${MACHEROSD}  
+  CPPFLAGS     :=  -I${INC}  -I$(INC)/tnt -D${MACHEROSD} \
+               -D_HPUX_SOURCE $(MODULECPPFLAGS)
+  LDLIBS      := $(XLDLIBS)
+  override NOSHLIB := Y
+
+endif
+ifeq ($(CXX),aCC)
+  CXXFLAGS := $(XCFLAGS) $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) +Z -D__aCC__
+#  -DCOMPILER_EXCEPTIONS -D__ANSI_TEMPLATES__  definis ds defs.h
+endif
+endif
+
+# AIX, xlC comme compilateur C et C++
+ifeq ($(CXX), xlC)
+  CFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) $(XCFLAGS)
+  CPPFLAGS := -I$(INC)/Syst -I${INC}  -I$(INC)/tnt -D${MACHEROSD} $(MODULECPPFLAGS)
+  CXXFLAGS     := $(CFLAGS) -D__xlC -DCOMPILER_EXCEPTIONS
+# -DCOMPILER_EXCEPTIONS defini ds defs.h
+  LDLIBS      := $(XLDLIBS)
+
+# Pour faire des bibliotheques partagees, il faut faire un truc du
+# style 
+#ld -o shrsub.o subs1.o subs2.o -bE:shrsub.exp -bM:SRE -lc
+
+# Pour le moment on ne se fatigue pas, tant pis
+  override NOSHLIB := Y
+
+# Et puis 1540-293: (W) est un FAUX warning, on supprime les warnings
+  CXXFLAGS := -qflag=e $(CXXFLAGS)
+endif
+
+#gcc sur Solaris
+ifeq ($(MACHEROS),SunOS)
+ override NOSHLIB := Y
+endif
+
+ifeq ($(CXX), cxx)
+  ifeq ($(DBGFLAG), -g)
+    ifdef OPTFLAG
+      override DBGFLAG := -g1
+    endif
+#    ifdef XOPT
+#      override DBGFLAG := -g1
+#    endif
+  endif
+
+# chemin pour repository CXX
+ REP := $(OBJ)/cxxrep/
+ REPPI := $(OBJ)/cxxrep_PI/
+ REPCXX := -ptr $(OBJ)/cxxrep/
+ ifdef MODULECXXREPNAME
+   REPCXX := -ptr $(OBJ)/cxxrep_$(MODULECXXREPNAME)/  -ptr $(OBJ)/cxxrep/
+   REPM := $(OBJ)/cxxrep_$(MODULECXXREPNAME)/
+ endif
+
+  LDLIBS      := $(XLDLIBS) -lrt
+
+  CXXFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS  \
+              $(REPCXX) -no_implicit_include 
+  CFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS)
+#  CXXFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \
+#	      -nopt -define_templates
+  ifeq ($(XOPT), 1)
+    override DBGFLAG :=
+    CXXFLAGS := $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \
+	        $(REPCXX) -fp_reorder \
+	        -O5 -inline speed -tune host
+  endif
+  ifeq ($(XOPT), 2)
+    override DBGFLAG :=
+    CXXFLAGS := $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \
+	      $(REPCXX) -fp_reorder \
+	      -O5 -inline speed -tune host \
+	      -assume trusted_short_alignment
+  endif
+  ifeq ($(XOPT), 3)
+    override DBGFLAG :=
+    CXXFLAGS := $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \
+	      $(REPCXX) -fp_reorder \
+	      -O5 -inline speed -tune host \
+	      -assume trusted_short_alignment \
+	      -non_shared -om
+    override NOSHLIB := Y
+  endif
+
+# le fichier X11/Xlib.h contient des declarations de fonctions sans type
+# Cela genere un grand nombre de warning avec cxx V6
+# La variable MODULEDECCXXFLAGS permet de specifier des options de compilation 
+# pour un module donne  
+  ifdef MODULEDECCXXFLAGS
+    CXXFLAGS := $(CXXFLAGS) $(MODULEDECCXXFLAGS)
+  endif
+endif
+ifeq ($(CC),cc)
+  ifeq ($(MACHEROS),OSF1)
+  ifeq ($(XOPT), 1)
+    CFLAGS :=  $(DBGFLAG) $(MYCFLAGS) -fp_reorder \
+	      -O4 -inline speed -tune host
+  endif
+  ifeq ($(XOPT), 2)
+    CFLAGS :=  $(DBGFLAG) $(MYCFLAGS) -fp_reorder \
+	      -O4 -inline speed -tune host \
+	      -assume trusted_short_alignment -fast
+  endif
+  ifeq ($(XOPT), 3)
+    CFLAGS :=  $(DBGFLAG) $(MYCFLAGS) -fp_reorder \
+	      -O4 -inline speed -tune host \
+	      -assume trusted_short_alignment -fast \
+	      -non_shared -om
+  endif
+  endif
+endif
+
+
+#  Compilateur KAI 
+ifeq ($(CXX), KCC)
+  CXXFLAGS     :=  --exceptions --rtti  --auto_instantiation --one_instantiation_per_object -D__KCC__
+# Flag --one_instantiation_per_object mis - Reza 02/03/99
+# -DCOMPILER_EXCEPTIONS -D__ANSI_TEMPLATES__  definis ds defs.h 
+endif
+
+# Autres compilateurs natifs.
+
+#  CFLAGS       :=  -I$(INC) $(XCFLAGS) $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS)
+#  CXXFLAGS     := $(CFLAGS)
+#  LDLIBS      := $(XLDLIBS)
+
+#- redefine implicit rule. Les .o sont dans $(OBJ).
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -o $@ $<
+
+$(OBJ)%.o:%.cc
+	$(COMPILE.cc) -o $@ $<
+
+$(OBJ)%.o:%.f
+	$(COMPILE.f) -o $@ $< 
+
+#OSF1
+#LDFC est f77
+#LDFCFLAGS est rien
+
+#parfois
+#LDFC est cc
+#LDFCFLAGS est -ltruc
+
+#------------------------------------------------- End of Makefile.h ------- 
+# fin gene auto MakefileUser.h
Index: /tags/DPC_V0/SophyaLib/Mgr/chk_cvs.csh
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/chk_cvs.csh	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/chk_cvs.csh	(revision 1307)
@@ -0,0 +1,61 @@
+#!/bin/csh
+
+unset A
+unset U
+unset NOS
+unset R
+if( "$1" == '-h' ) then
+  echo "usage chk_cvs.csh [-a] [-all] [-nos] [-u] [r]"
+  echo "    -nos : pas de cvs status demande"
+  echo "      -a   : cvs status reduit  pour tous les fichiers"
+  echo "      -all : cvs status complet pour tous les fichiers"
+  echo "    -u   : update demande"
+  echo "    -r   : chmod a+r demande"
+  exit -1
+else
+  while( $#argv>0 )
+    if( "$1" == "-a") set A = 1
+    if( "$1" == "-all") set A = 2
+    if( "$1" == "-nos") set NOS
+    if( "$1" == "-u") set U
+    if( "$1" == "-r") set R
+    shift
+  end
+endif
+if( $?U || $?R ) set NOS
+
+set fall = (`ls -1`)
+set dcvs = ( )
+foreach f ( $fall )
+  if( -e $f/CVS ) set dcvs = ( $dcvs $f )
+end
+
+set CURDIR = `pwd`
+if( $?U ) echo "attention...... UPDATE demande"
+
+foreach d ( $dcvs )
+  if (-e $CURDIR/$d)  then
+    echo " " ; echo " "
+    echo "******************************************"
+    echo "   --- $d ---" ; echo " "
+    cd $CURDIR/$d
+    if( ! $?NOS ) then
+      if( $?A ) then
+        if( $A == 1 ) then
+          cvs status | grep Status
+        else if( $A == 2 ) then
+          cvs status
+        endif
+      else
+        cvs status | grep Status | grep -v "Up-to-date"
+      endif
+    endif
+    if( $?U ) cvs update
+    if( $?R ) then
+      chmod -R a+r *
+    endif
+  endif
+end
+
+cd $CURDIR
+exit 0
Index: /tags/DPC_V0/SophyaLib/Mgr/crecxx.file
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/crecxx.file	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/crecxx.file	(revision 1307)
@@ -0,0 +1,16 @@
+cimage.h
+circrfix.h
+daofind.h
+deflat.h
+dynccd.h
+fitsimage.h
+imageop.h
+killbad.h
+photfitpsf.h
+photfixedap.h
+pixeliter.h
+psf2dfit.h
+qualite.h
+rebinimage.h
+rzimage.h
+sharedimage.h
Index: /tags/DPC_V0/SophyaLib/Mgr/crerep_peida
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/crerep_peida	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/crerep_peida	(revision 1307)
@@ -0,0 +1,50 @@
+#!/bin/csh
+
+if( $#argv < 1 ) then
+  echo "crerep_peida <nom des repertoires> [nom_machine-compilateur]"
+  echo " - ex: crerep_peida "\$"GROUP_DIR/PeidaWork HP-UX"
+  echo " - possibilites nom_machine-compilateur"
+  echo "    [AIX-xlC AIX-g++ HP-UX-aCC HP-UX-g++ OSF1-cxx OSF1-g++ Linux-g++ ...]"
+  if($?EROSCXX) then
+    echo "    defaut: `uname`-$EROSCXX"
+  else
+    echo "    pas de defaut donnez explicitement nom_machine-compilateur"
+  endif
+  exit -1
+endif
+
+set dirl = $1
+if ( ! -e ${dirl} ) then
+  echo ATTENTION REPERTOIRE INEXISTANT:
+  echo ${dirl}
+  exit -1
+endif
+echo "rep. de base: ${dirl}"
+
+shift
+if( $#argv > 0 ) then
+  set diru = $1
+  echo "machine-compilateur: ${diru}"
+else if ($?EROSCXX) then
+  echo uname=`uname` EROSCXX = $EROSCXX
+  set diru = `uname`-$EROSCXX
+  echo "AUTOMATIQUE machine-compilateur: ${diru}"
+else
+  echo "precisez nom_machine-compilateur ou EROSCXX"
+  exit -1
+endif
+
+foreach d ( ${dirl}/${diru} \
+            ${dirl}/Include ${dirl}/Include/tnt \
+            ${dirl}/${diru}/Exec \
+            ${dirl}/${diru}/Libs ${dirl}/${diru}/ShLibs \
+            ${dirl}/${diru}/Objs )
+  if ( -e $d ) then
+    echo "rep. existant: $d"
+  else
+    echo "rep. cree: $d"
+    mkdir $d
+  endif
+end
+
+exit 0
Index: /tags/DPC_V0/SophyaLib/Mgr/install_peida
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/install_peida	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/install_peida	(revision 1307)
@@ -0,0 +1,117 @@
+#!/bin/csh
+#  Script d'installation PEIDA 
+#  Version preliminaire - Reza 27/11/97 +cmv
+
+if( "$1" == "-h" ) then
+  echo "install_peida <-s repertoire source> <-d repertoire destination>"
+  echo "              [-m nom_machine-compilateur]"
+  if($?DPCDEVREP) then
+    echo " - defaut repertoire source: $DPCDEVREP"
+  else
+    echo "   pas de defaut donnez explicitement le repertoire source"
+  endif
+  if($?DPCBASEREP) then
+    echo " - defaut repertoire destination: $DPCBASEREP"
+  else
+    echo "   pas de defaut donnez explicitement le repertoire destination"
+  endif
+  echo " - possibilites nom_machine-compilateur"
+  echo "    [AIX-xlC AIX-g++ HP-UX-aCC HP-UX-g++ OSF1-cxx OSF1-g++  Linux-g++ ...]"
+  if($?EROSCXX) then
+    echo "    defaut: `uname`-$EROSCXX"
+  else
+    echo "    pas de defaut donnez explicitement nom_machine-compilateur"
+  endif
+  exit -1
+endif
+
+unset srcdir
+unset dstdir
+unset macomp
+
+while( $#argv > 1 )
+  if( "$1" == "-s" ) then
+    set srcdir = $2
+  endif
+  if( "$1" == "-d" ) then
+    set dstdir = $2
+  endif
+  if( "$1" == "-m" ) then
+    set macomp = $2
+  endif
+  shift
+  shift
+end
+
+if( ! $?srcdir && $?DPCDEVREP ) then
+  echo "defaut srcdir set to DPCDEVREP"
+  set srcdir = $DPCDEVREP
+endif
+if( ! $?dstdir && $?DPCBASEREP ) then
+  echo "defaut dstdir set to DPCBASEREP"
+  set dstdir = $DPCBASEREP
+endif
+if( ! $?macomp && $?EROSCXX ) then
+  echo "defaut macomp set to uname-EROSCXX"
+  set macomp = `uname`-$EROSCXX
+endif
+
+if( ! $?srcdir || ! $?dstdir || ! $?macomp ) then
+  echo "precisez ce que vous voulez:"
+  echo srcdir=$?srcdir dstdir=$?dstdir macomp=$?macomp
+  exit -1
+else
+  set SRC = $srcdir/$macomp
+  set DST = $dstdir/$macomp
+  echo "************** PEIDA_Install script : ****************** "
+  echo "copie de $srcdir"
+  echo "      vers $dstdir pour $macomp"
+  echo "      pour $macomp"
+  # echo "SRC= $SRC , DST= $DST"
+  echo "********************************************************"
+endif
+
+#set DO = echo
+set DO =
+
+# d'abord les includes
+#foreach d ( Include Include/tnt Include/CInc Include/SystCxx Include/Syst )
+foreach d ( Include Include/tnt Include/CInc Include/Syst )
+  echo "PEIDA_Install: Installing $d ... "
+  if( ! -e $srcdir/$d ) then
+    echo "rep. inexistant: $SRC/$d"
+  else if( ! -e $dstdir/$d ) then
+    echo "rep. inexistant: $DST/$d"
+  else
+    cd $srcdir/$d
+    $DO cp * $dstdir/$d/.
+    $DO chmod -R a+r $dstdir/$d/
+  endif
+end
+
+# puis le reste
+foreach d ( Libs ShLibs Exec )
+  echo "PEIDA_Install: Installing $d ... "
+  if( ! -e $SRC/$d ) then
+    echo "rep. inexistant: $SRC/$d"
+  else if( ! -e $DST/$d ) then
+    echo "rep. inexistant: $DST/$d"
+  else
+    if( "$d" == "Exec" ) then
+      foreach f ( stars++ assocbr++ synth++ spiapp piapp )
+        if( -e $SRC/$d/$f ) then
+          $DO cp $SRC/$d/$f $DST/$d/.
+        endif
+      end
+      $DO chmod -R a+x $DST/$d/
+    else
+      cd $SRC/$d/.
+      $DO cp * $DST/$d/.
+    endif
+    $DO chmod -R a+r $DST/$d/
+  endif
+end
+
+echo 'PEIDA_Install complete'
+
+exit 0
Index: /tags/DPC_V0/SophyaLib/Mgr/libdirs
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/libdirs	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/libdirs	(revision 1307)
@@ -0,0 +1,2 @@
+SysTools
+NTools
Index: /tags/DPC_V0/SophyaLib/Mgr/libdirs_ccpn
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/libdirs_ccpn	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/libdirs_ccpn	(revision 1307)
@@ -0,0 +1,3 @@
+Outils++
+Images++
+StarReco++
Index: /tags/DPC_V0/SophyaLib/Mgr/lnktofftw.csh
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/lnktofftw.csh	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/lnktofftw.csh	(revision 1307)
@@ -0,0 +1,10 @@
+#! /bin/csh 
+#  Pour creer des liens sur libFFTW et creer le shared-lib correspondant
+#        Reza 04/99
+#
+cd ~/DPC/Linux-g++/Libs/
+ln -s /usr/local/lib/libfftw.a libfftw.a
+ln -s /usr/local/lib/librfftw.a librfftw.a
+ln -s /usr/local/include/fftw.h ../../Include/
+ln -s /usr/local/include/rfftw.h ../../Include/
+ld -shared -o ../ShLibs/libfftw.so -L. --whole-archive -lfftw -lrfftw --no-whole-archive -lm -lc
Index: /tags/DPC_V0/SophyaLib/Mgr/makefileuser.awk
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/makefileuser.awk	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/makefileuser.awk	(revision 1307)
@@ -0,0 +1,25 @@
+BEGIN {change=0;}
+/^PP  := \$\{DPCDEVREP\}\/\$\{MACHDIR\}\// {
+  print "PP  := \$\{DPCBASEREP\}\/\$\{MACHDIR\}\/";
+  print "PPH := \$\{HOME\}\/\$\{MACHDIR\}\/";
+  change=1;
+}
+/^OBJ := \$\{PP\}\/Objs\// {
+  print "OBJ := \$\{PPH\}\/Objs\/";
+  change=1;
+}
+/^EXE := \$\{PP\}\/Exec\// {
+  print "EXE := \$\{PPH\}\/Exec\/";
+  change=1;
+}
+/^INC := \$\{DPCDEVREP\}\/Include\// {
+  print "INC := \$\{DPCBASEREP\}\/Include\/";
+  change=1;
+}
+{
+  if(change==0) print $0
+  change=0;
+}
+END {
+print "# fin gene auto MakefileUser.h"
+}
Index: /tags/DPC_V0/SophyaLib/Mgr/mkmf
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/mkmf	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/mkmf	(revision 1307)
@@ -0,0 +1,91 @@
+#!/bin/csh 
+# $Id: mkmf,v 1.1.1.1 1999-04-09 17:55:32 ansari Exp $
+
+# creation de MakefileUser.h a partir de Makefile.h
+echo 'mkmf: Creation de MakefileUser.h'
+cat Makefile.h | awk -f makefileuser.awk >! MakefileUser.h
+
+# creation des liens pour les includes
+echo 'mkmf: Creation des liens (appel mkmflien)'
+./mkmflien
+
+echo 'mkmf: Creation makefile global :'
+rm -f GNUmakefile
+
+echo 'include Mgr/Makefile.h' >> GNUmakefile
+
+echo 'LIBF = ' `sed -e 's/.*/$(LIB)lib&.a/' libdirs` >> GNUmakefile
+echo 'LIBS = -L$(LIB)' `sed -e 's/.*/-l&/' libdirs` '-lm' >> GNUmakefile
+echo 'LIBG = -L$(GLB) -lstdc++' >> GNUmakefile
+
+cat >> GNUmakefile <<EOF
+
+defaut: libs
+
+all: libs PI
+
+
+libs: cxxlibs
+# Dans cet ordre pour les templates de cxx, a cause des dependances
+# pour instantiation automatique/manuels
+
+cxxlibs: Blitz SysTools NTools 
+
+EOF
+
+
+#  Attention, ne pas changer l'ordre de libnames dependances cxx
+set libnames = (Blitz SysTools NTools)
+set i = 1
+set j = $#libnames ; @ j--
+while ($i <= $#libnames)
+  set f = $libnames[$i]
+  set k = $i ; @ k++
+  if ( -d ../$f ) then 
+    set cmd = "./mkmflib $f $libnames[$k-$j]"
+    echo "mkmf: Creation makefile lib $f"
+    echo "   execution $cmd"
+    $cmd
+  endif
+  echo '.PHONY: ' $f >> GNUmakefile
+  echo $f':' >> GNUmakefile
+  echo '	if [ -d '$f' ] ; then cd ' $f '; $(MAKE) ; fi' >> GNUmakefile
+  echo ' ' >> GNUmakefile
+  @ i++
+end
+
+
+if ( -d ../PI ) then 
+  set cmd = './mkmfPI PI SysTools'
+  echo "mkmf: Creation makefile lib PI"
+  echo "   execution $cmd"
+  $cmd
+endif
+if ( -d ../PIext ) then 
+  set cmd = './mkmfPI PIext SysTools NTools PI'
+  echo "mkmf: Creation makefile lib PIext"
+  echo "   execution $cmd"
+  $cmd
+endif
+echo '.PHONY: PI' >> GNUmakefile
+echo 'PI:' >> GNUmakefile
+echo '	if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile
+echo '	if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile
+
+cat Makefile.slb >> GNUmakefile
+
+cat >> GNUmakefile << __END__
+
+clean:
+	if [ -d \$(LIB) ] ; then cd \$(LIB)/. ; rm -f *.a  ; fi
+	if [ -d \$(SLB) ] ; then cd \$(SLB)/. ; rm -f *.so ; fi
+	if [ -d \$(OBJ) ] ; then cd \$(OBJ)/. ; rm -f *.o  ; fi
+	if [ -d \$(OBJ)/cxxrep ] ; then cd \$(OBJ)/cxxrep/. ; rm -f *.o  ; fi
+	if [ -d PI ]     ; then cd PI/.     ; \$(MAKE) clean ; fi
+
+__END__
+
+mv GNUmakefile ../GNUmakefile
+
+echo '*** mkmf done ***'
+
Index: /tags/DPC_V0/SophyaLib/Mgr/mkmfPI
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/mkmfPI	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/mkmfPI	(revision 1307)
@@ -0,0 +1,85 @@
+#!/bin/csh
+# $Id: mkmfPI,v 1.1.1.1 1999-04-09 17:55:32 ansari Exp $
+
+set makefname = 'GNUmakefile'
+
+cd ../$1
+
+if ( ! -f exclude ) touch exclude
+if ( ! $?TMPDIR ) set TMPDIR = /tmp
+sort exclude >! $TMPDIR/exclude.sort
+
+##############################################
+########### fichier de la liste des .o #######
+##############################################
+
+set liblist = $1.o.list
+rm -f $liblist
+ls *.{c,cc} | comm -3 -1 $TMPDIR/exclude.sort - | sed -e 's/\.cc/.o/' | sed -e 's/\.c/.o/' >> $liblist
+unset liblist
+
+##############################################
+########### Creation de GNUmakefile ##########
+##############################################
+
+set libf='$(LIB)lib'$1'.a'
+
+rm -f $makefname
+
+echo "MODULECXXREPNAME := PI" >>  $makefname
+
+set hfcxxlibs = '-L$(LIB)' 
+set i = 1
+while ($i <= $#argv)
+  set hfcxxlibs = "$hfcxxlibs -l$argv[$i]"
+  @ i++
+end
+
+
+
+# 04/98: le fichier X11/Xlib.h contient des declarations de fonctions sans type  
+# Cela genere un grand nombre de warning avec cxx V6 
+# On specifie donc -msg_quiet pour PI, ProgPI, ...
+echo 'MODULEDECCXXFLAGS := -msg_quiet' >> $makefname
+echo 'include ../Mgr/Makefile.h' >> $makefname
+
+echo " " >> $makefname
+
+set ccfiles  = `ls *.cc  | comm -3 -1 $TMPDIR/exclude.sort -`
+set objfiles = `ls *.cc  | comm -3 -1 $TMPDIR/exclude.sort - | sed -e 's/\.cc/.o/g' | sed -e 's/^/$(OBJ)/'`
+
+rm -f $TMPDIR/exclude.sort
+
+echo 'all:' $libf >> $makefname 
+
+echo $libf ':' $objfiles  >> $makefname
+echo '	$(AR) $(ARFLAGS)  $@ $? ' >> $makefname
+echo 'ifeq ($(CXX),cxx)' >> $makefname
+echo '	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS)' $hfcxxlibs '-o $(OBJ)xx.x -Hf' >> $makefname
+echo 'endif ' >> $makefname
+
+echo " " >> $makefname
+
+echo 'clean:' >> $makefname 
+echo '	rm -f '$objfiles >> $makefname
+echo 'ifeq ($(CXX),cxx)' >> $makefname
+echo '	cd $(REPM); rm -f *.o'  >> $makefname
+echo 'endif ' >> $makefname
+
+echo " " >> $makefname
+
+set inc = $DPCDEVREP/Include
+set incxx = $inc/CxxInc
+
+foreach f ( $ccfiles )
+  gcc -MM -I$inc -I$incxx $f  \
+       | sed -e 's/.*\.o/\$(OBJ)&/'  \
+       | sed -e 's?'$incxx/'?$(CXI)?g' \
+       | sed -e 's?'$inc/'?$(INC)?g' >> $makefname
+end
+
+
+
+
+
+
Index: /tags/DPC_V0/SophyaLib/Mgr/mkmflib
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/mkmflib	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/mkmflib	(revision 1307)
@@ -0,0 +1,81 @@
+#!/bin/csh
+# $Id: mkmflib,v 1.1.1.1 1999-04-09 17:55:32 ansari Exp $
+
+cd ../$1
+
+if ( ! -f exclude ) touch exclude
+if ( ! $?TMPDIR ) set TMPDIR = /tmp
+sort exclude >! $TMPDIR/exclude.sort
+
+##############################################
+########### fichier de la liste des .o #######
+##############################################
+
+set liblist = $1.o.list
+rm -f $liblist
+ls *.{c,cc} | comm -3 -1 $TMPDIR/exclude.sort - | sed -e 's/\.cc/.o/' | sed -e 's/\.c/.o/' >> $liblist
+unset liblist
+
+##############################################
+########### Creation de GNUmakefile ##########
+##############################################
+
+set libf='$(LIB)lib'$1'.a'
+
+set hfcxxlibs = '-L$(LIB)' 
+set i = 1
+while ($i <= $#argv)
+  set hfcxxlibs = "$hfcxxlibs -l$argv[$i]"
+  @ i++
+end
+
+
+rm -f GNUmakefile
+
+echo 'include ../Mgr/Makefile.h' >> GNUmakefile 
+
+echo " " >> GNUmakefile
+echo 'all:' $libf  >> GNUmakefile 
+
+echo 'clean:' >> GNUmakefile
+set toto='rm -f'
+foreach f (*.cc *.c) 
+  set toto= ( $toto '$(OBJ)'$f:r.o )
+end
+echo '	'$toto >> GNUmakefile
+echo '	rm '$libf >> GNUmakefile
+
+echo $libf ':' \
+ `ls *.{c,cc} | comm -3 -1 $TMPDIR/exclude.sort - | sed -e 's/\.cc/.o/' | sed -e 's/\.c/.o/' | sed -e 's/^/$(OBJ)/'` >> GNUmakefile
+echo '	$(AR) $(ARFLAGS) $@ $?' >> GNUmakefile
+#  Pour faire compiler les instantiations automatique de cxx (DEC)
+echo 'ifeq ($(CXX),cxx)' >> GNUmakefile
+echo '	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS)' $hfcxxlibs '-o $(OBJ)xx.x -Hf' >> GNUmakefile
+echo 'endif ' >> GNUmakefile
+
+rm -f $TMPDIR/exclude.sort
+
+echo " " >> GNUmakefile
+
+set inc = $DPCDEVREP/Include
+set incxx = $inc/CxxInc
+
+foreach f ( *.cc )
+  grep -q '^'$f'$' exclude && continue
+  gcc -MM -I$inc -I$incxx $f  \
+       | sed -e 's/.*\.o/\$(OBJ)&/'  \
+       | sed -e 's?'$incxx/'?$(CXI)?g' \
+       | sed -e 's?'$inc/'?$(INC)?g' >> GNUmakefile
+end
+
+foreach f ( *.c )
+  grep -q '^'$f'$' exclude && continue
+  gcc -MM -I$inc -I$incxx $f  \
+       | sed -e 's/.*\.o/\$(OBJ)&/'  \
+       | sed -e 's?'$incxx/'?$(CXI)?g' \
+       | sed -e 's?'$inc/'?$(INC)?g' >> GNUmakefile
+end 
+
+
+
+
Index: /tags/DPC_V0/SophyaLib/Mgr/mkmflib_save
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/mkmflib_save	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/mkmflib_save	(revision 1307)
@@ -0,0 +1,67 @@
+#!/bin/csh
+# $Id: mkmflib_save,v 1.1.1.1 1999-04-09 17:55:32 ansari Exp $
+
+cd ../$1
+set libf='$(LIB)lib'$1'.a'
+
+set hfcxxlibs = '-L$(LIB)' 
+set i = 1
+while ($i <= $#argv)
+  set hfcxxlibs = "$hfcxxlibs -l$argv[$i]"
+  @ i++
+end
+
+
+rm -f GNUmakefile
+
+echo 'include ../Mgr/Makefile.h' >> GNUmakefile 
+
+echo " " >> GNUmakefile
+echo 'all:' $libf  >> GNUmakefile 
+
+echo 'clean:' >> GNUmakefile
+set toto='rm -f'
+foreach f (*.cc *.c) 
+  set toto= ( $toto '$(OBJ)'$f:r.o )
+end
+echo '	'$toto >> GNUmakefile
+echo '	rm '$libf >> GNUmakefile
+
+if ( ! -f exclude ) touch exclude
+if ( ! $?TMPDIR ) set TMPDIR = /tmp
+sort exclude >! $TMPDIR/exclude.sort
+
+echo $libf ':' \
+ `ls *.{c,cc} | comm -3 -1 $TMPDIR/exclude.sort - | sed -e 's/\.cc/.o/' | sed -e 's/\.c/.o/' | sed -e 's/^/$(OBJ)/'` >> GNUmakefile
+echo '	$(AR) $(ARFLAGS) $@ $?' >> GNUmakefile
+#  Pour faire compiler les instantiations automatique de cxx (DEC)
+echo 'ifeq ($(CXX),cxx)' >> GNUmakefile
+echo '	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS)' $hfcxxlibs '-o $(OBJ)xx.x -Hf' >> GNUmakefile
+echo 'endif ' >> GNUmakefile
+
+rm -f $TMPDIR/exclude.sort
+
+echo " " >> GNUmakefile
+
+set inc = $DPCDEVREP/Include
+set incxx = $inc/CxxInc
+
+foreach f ( *.cc )
+  grep -q '^'$f'$' exclude && continue
+  gcc -MM -I$inc -I$incxx $f  \
+       | sed -e 's/.*\.o/\$(OBJ)&/'  \
+       | sed -e 's?'$incxx/'?$(CXI)?g' \
+       | sed -e 's?'$inc/'?$(INC)?g' >> GNUmakefile
+end
+
+foreach f ( *.c )
+  grep -q '^'$f'$' exclude && continue
+  gcc -MM -I$inc -I$incxx $f  \
+       | sed -e 's/.*\.o/\$(OBJ)&/'  \
+       | sed -e 's?'$incxx/'?$(CXI)?g' \
+       | sed -e 's?'$inc/'?$(INC)?g' >> GNUmakefile
+end 
+
+
+
+
Index: /tags/DPC_V0/SophyaLib/Mgr/mkmflien
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/mkmflien	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/mkmflien	(revision 1307)
@@ -0,0 +1,67 @@
+#!/bin/csh 
+# $Id: mkmflien,v 1.1.1.1 1999-04-09 17:55:31 ansari Exp $
+
+#########################################################
+#### repertoire contenant les repertoires du code+include
+#########################################################
+pushd ../.      > /dev/null
+set src = ` pwd | sed 's?/tmp_mnt??' `
+popd            > /dev/null
+
+#############################################################
+#### repertoire contenant les liens a creer pour les includes
+#############################################################
+if( $#argv >= 1 ) then
+  set dst = $1
+else
+  set dst = $DPCDEVREP/Include
+endif
+if ( ! -d $dst/ ) then
+  echo repertoire $dst inconnu
+  exit -1
+endif
+
+#########################################################
+### Les includes a mettre dans Include pour les Makefiles
+#########################################################
+foreach f ( $src/Mgr/Makefile.h $src/Mgr/MakefileUser.h )
+  if( -e $f ) then
+    ln -sf $f $dst/
+  endif
+end
+
+
+###################################################
+####  Les includes de tnt a mettre dans Include/tnt
+###################################################
+if( -d $dst/tnt ) then
+  if( -d $src/tnt ) then
+    foreach f ( $src/tnt/*.h )
+      ln -sf $f $dst/tnt/
+    end
+  endif
+endif
+
+
+###################################################
+####  Les includes de Blitz++ lien ds Include
+###################################################
+if( -e $src/Blitz ) then
+  ln -sf $src/Blitz/blitz $dst/blitz
+endif
+
+
+####################################################
+####  Les includes du code C++ a mettre dans Include
+####################################################
+foreach d (`cat libdirs` PI PIext  )
+  if ( -d $src/$d ) then
+    echo $src/$d
+    foreach f ( $src/$d/*.h )
+      ln -sf $f $dst/
+    end
+  endif
+end
+
+
+exit 0
Index: /tags/DPC_V0/SophyaLib/Mgr/mkmfprog
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/mkmfprog	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/mkmfprog	(revision 1307)
@@ -0,0 +1,91 @@
+#!/bin/csh 
+# $Id: mkmfprog,v 1.1.1.1 1999-04-09 17:55:32 ansari Exp $
+
+# $1 : nom du repertoire
+# dans le repertoire, programs : liste des programs
+#                     usedlibs : liste des -L -l utilises
+#                     usedslibs : idem pour shlibs
+
+cd ../$1
+
+rm -f GNUmakefile
+
+
+echo 'MODULECXXREPNAME := ' $1  >> GNUmakefile
+# 04/98 : le fichier X11/Xlib.h contient des declarations de fonctions sans type
+# Cela genere un grand nombre de warning avec cxx V6 
+# On specifie donc -msg_quiet pour ProgPI
+if ($1 == 'ProgPI')  then
+  echo 'MODULEDECCXXFLAGS := -msg_quiet' >> GNUmakefile 
+endif
+echo 'include ../Mgr/Makefile.h' >> GNUmakefile
+
+echo ' ' >> GNUmakefile
+
+echo 'ifdef NOSHLIB'                                        >> GNUmakefile
+echo 'LIBF = ' `sed -e 's/.*/$(LIB)lib&.a/' usedlibs`       >> GNUmakefile
+echo 'LIBS = -L$(LIB)' `sed -e 's/.*/-l&/' usedlibs` ' -lm' >> GNUmakefile
+echo 'ifeq ($(CXX),cxx)'                                    >> GNUmakefile
+echo '# librairie des instances de templates cxx'           >> GNUmakefile
+echo 'LIBS := $(LIBS) -lertcxx'                             >> GNUmakefile
+echo 'endif' >> GNUmakefile 
+echo 'else'                                                 >> GNUmakefile
+echo 'LIBF = ' `sed -e 's/.*/$(SLB)lib&.so/' usedslibs`     >> GNUmakefile
+echo 'LIBS = -L$(SLB)' `sed -e 's/.*/-l&/' usedslibs` ' -lm'>> GNUmakefile
+echo 'endif'                                                >> GNUmakefile
+
+echo 'LIBSORA := $(LIBS)' >> GNUmakefile
+echo 'ifdef ORACLE_HOME' >> GNUmakefile
+echo 'LIBSORA := -L$(LIB) -lDb++ $(LIBS) -lErosDb -L$(ORACLE_HOME)/lib -lclntsh' >> GNUmakefile
+echo 'endif' >> GNUmakefile
+
+echo 'LDLIBS := $(LIBS) $(LDLIBS)' >> GNUmakefile
+
+set progaexe = programs
+if( -e programs_exe ) set progaexe = programs_exe
+echo 'PROGS = '`cut -d \  -f1 $progaexe | awk '{if(length($1)>0) print $1}' | sed -e 's/^/\$(EXE)/'` >> GNUmakefile
+unset progaexe
+
+echo " " >> GNUmakefile
+echo 'all: $(PROGS)' >> GNUmakefile 
+
+set cxxrepname = cxxrep_$1
+
+cat >> GNUmakefile << __END__
+
+clean:
+	rm -f \$(PROGS)
+	if [ -d \$(OBJ)$cxxrepname ] ; then cd \$(OBJ)$cxxrepname ; rm -f *.o ; fi
+
+__END__
+
+awk -f ../Mgr/mkmfprog.awk programs >> GNUmakefile
+
+#foreach f (`cat programs`)
+#  echo $f ': $(EXE)'$f >> GNUmakefile
+#  echo '	' >> GNUmakefile
+#  echo '$(EXE)'$f ':' '$(OBJ)'$f.o '$(LIBF)' >> GNUmakefile
+#  echo '	g++ $(LDFLAGS) -o $@ $< $(LIBS)' >> GNUmakefile
+#  echo " ">> GNUmakefile
+#end
+
+#foreach f (`cat ../Mgr/programs_db`)
+#  echo $f ': $(EXE)'$f >> GNUmakefile
+#  echo '	' >> GNUmakefile
+#  echo '$(EXE)'$f ':' '$(OBJ)'$f.o '$(LIBF)' >> GNUmakefile
+#  echo '	g++ $(LDFLAGS) -o $@ $< $(LIBSORA)' >> GNUmakefile
+#  echo " ">> GNUmakefile
+#end
+
+set inc = $DPCDEVREP/Include
+
+
+foreach f ( *.cc )
+  gcc -MM -I$inc $f  \
+       | sed -e 's/.*\.o/\$(OBJ)&/' \
+       | sed -e 's?'$inc/'?$(INC)?g' >> GNUmakefile
+end 
+
+
+
+
Index: /tags/DPC_V0/SophyaLib/Mgr/mkmfprog.awk
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/mkmfprog.awk	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/mkmfprog.awk	(revision 1307)
@@ -0,0 +1,22 @@
+{ print $1 ": $(EXE)"$1 ;
+  print "	" ;
+  xlib = ""
+  if (NF == 1) 
+     obj = "$(OBJ)"$1".o";
+  else if (NF == 2 && $2 == "DB") {
+     obj = "$(OBJ)"$1".o";
+     xlib = "$(LIBSORA)";
+  }
+  else {
+    obj = "";
+    for (i=2;i<=NF;i++) {
+      if ($i == "DB")
+       xlib = "$(LIBSORA)"
+      else
+       obj = obj " $(OBJ)"$i;
+     }
+  }
+  print "$(EXE)"$1 ":" obj;
+  print "	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ " xlib
+  print "  "  
+}
Index: /tags/DPC_V0/SophyaLib/Mgr/progdirs
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/progdirs	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/progdirs	(revision 1307)
@@ -0,0 +1,3 @@
+Prog
+ProgAcq
+ProgPI
Index: /tags/DPC_V0/SophyaLib/Mgr/progdirs_ccpn
===================================================================
--- /tags/DPC_V0/SophyaLib/Mgr/progdirs_ccpn	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Mgr/progdirs_ccpn	(revision 1307)
@@ -0,0 +1,1 @@
+Prog
Index: /tags/DPC_V0/SophyaLib/NTools/Makefile
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/Makefile	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/Makefile	(revision 1307)
@@ -0,0 +1,215 @@
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libNTools.a
+clean:
+	rm -f $(OBJ)cimage.o $(OBJ)cspline.o $(OBJ)cvector.o $(OBJ)datacards.o $(OBJ)datatypes.o $(OBJ)dates.o $(OBJ)difeq.o $(OBJ)dvlist.o $(OBJ)dynccd.o $(OBJ)fct1dfit.o $(OBJ)fct2dfit.o $(OBJ)generaldata.o $(OBJ)generalfit.o $(OBJ)hisprof.o $(OBJ)histos.o $(OBJ)histos2.o $(OBJ)imageop.o $(OBJ)integ.o $(OBJ)linfit.o $(OBJ)matrix.o $(OBJ)median.o $(OBJ)ntuple.o $(OBJ)outilsinit.o $(OBJ)perandom.o $(OBJ)poly.o $(OBJ)pversion.o $(OBJ)rk4cdifeq.o $(OBJ)rzimage.o $(OBJ)simplesort.o $(OBJ)tabmath.o $(OBJ)utils.o $(OBJ)datime.o $(OBJ)matxop.o $(OBJ)nbmath.o $(OBJ)nbrandom.o $(OBJ)nbtri.o $(OBJ)strutil.o
+	rm $(LIB)libNTools.a
+$(LIB)libNTools.a : $(OBJ)cimage.o $(OBJ)cspline.o $(OBJ)cvector.o $(OBJ)datacards.o $(OBJ)datatypes.o $(OBJ)dates.o $(OBJ)datime.o $(OBJ)difeq.o $(OBJ)dvlist.o $(OBJ)dynccd.o $(OBJ)fct1dfit.o $(OBJ)fct2dfit.o $(OBJ)generaldata.o $(OBJ)generalfit.o $(OBJ)hisprof.o $(OBJ)histos.o $(OBJ)histos2.o $(OBJ)imageop.o $(OBJ)integ.o $(OBJ)linfit.o $(OBJ)matrix.o $(OBJ)matxop.o $(OBJ)median.o $(OBJ)nbmath.o $(OBJ)nbrandom.o $(OBJ)nbtri.o $(OBJ)ntuple.o $(OBJ)outilsinit.o $(OBJ)perandom.o $(OBJ)poly.o $(OBJ)pversion.o $(OBJ)rk4cdifeq.o $(OBJ)rzimage.o $(OBJ)simplesort.o $(OBJ)strutil.o $(OBJ)tabmath.o $(OBJ)utils.o
+	$(AR) $(ARFLAGS) $@ $?
+ifeq ($(CXX),cxx)
+	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS) -L$(LIB) -lNTools -o $(OBJ)xx.x -Hf
+endif 
+ 
+$(OBJ)cimage.o: cimage.cc /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h cimage.h rzimage.h rzvect.h \
+ /home/ansari/DPC/Include/machine.h datatypes.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h dvlist.h fct1dfit.h generalfit.h \
+ matrix.h peida.h utils.h fmath.h cvector.h generaldata.h poly.h \
+ histos.h nbconst.h
+$(OBJ)cspline.o: cspline.cc /home/ansari/DPC/Include/defs.h nbtri.h \
+ cspline.h cvector.h matrix.h peida.h utils.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h
+$(OBJ)cvector.o: cvector.cc /home/ansari/DPC/Include/defs.h cvector.h \
+ matrix.h peida.h utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h generalfit.h generaldata.h \
+ poly.h
+$(OBJ)datacards.o: datacards.cc /home/ansari/DPC/Include/defs.h datacards.h \
+ peida.h utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h
+$(OBJ)datatypes.o: datatypes.cc /home/ansari/DPC/Include/defs.h datatypes.h \
+ /home/ansari/DPC/Include/machine.h
+$(OBJ)dates.o: dates.cc /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h dates.h
+$(OBJ)difeq.o: difeq.cc /home/ansari/DPC/Include/defs.h difeq.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h cvector.h matrix.h peida.h \
+ utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h fmath.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/ctimer.h /home/ansari/DPC/Include/peida.h
+$(OBJ)dvlist.o: dvlist.cc /home/ansari/DPC/Include/defs.h dvlist.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/pclassids.h strutil.h
+$(OBJ)dynccd.o: dynccd.cc /home/ansari/DPC/Include/defs.h fmath.h perandom.h \
+ /home/ansari/DPC/Include/machine.h histos.h peida.h utils.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h cvector.h matrix.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h nbrandom.h cimage.h rzimage.h \
+ rzvect.h datatypes.h dvlist.h dynccd.h
+$(OBJ)fct1dfit.o: fct1dfit.cc /home/ansari/DPC/Include/defs.h fct1dfit.h \
+ generalfit.h /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h matrix.h peida.h utils.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ fmath.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h cvector.h generaldata.h poly.h \
+ nbconst.h tabmath.h
+$(OBJ)fct2dfit.o: fct2dfit.cc /home/ansari/DPC/Include/defs.h fct2dfit.h \
+ generalfit.h /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h matrix.h peida.h utils.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ fmath.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h cvector.h generaldata.h poly.h \
+ nbconst.h tabmath.h simps2d.h
+$(OBJ)generaldata.o: generaldata.cc /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h nbtri.h generalfit.h matrix.h \
+ peida.h utils.h fmath.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h cvector.h generaldata.h poly.h
+$(OBJ)generalfit.o: generalfit.cc /home/ansari/DPC/Include/defs.h \
+ generalfit.h /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h matrix.h peida.h utils.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ fmath.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h cvector.h generaldata.h poly.h \
+ nbconst.h tabmath.h
+$(OBJ)hisprof.o: hisprof.cc /home/ansari/DPC/Include/defs.h hisprof.h \
+ peida.h utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h cvector.h matrix.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h histos.h
+$(OBJ)histos.o: histos.cc /home/ansari/DPC/Include/defs.h histos.h peida.h \
+ utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h cvector.h matrix.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h poly.h strutil.h generalfit.h \
+ generaldata.h
+$(OBJ)histos2.o: histos2.cc /home/ansari/DPC/Include/defs.h histos2.h \
+ peida.h utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h histos.h cvector.h \
+ matrix.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h generalfit.h generaldata.h \
+ poly.h
+$(OBJ)imageop.o: imageop.cc /home/ansari/DPC/Include/defs.h simplesort.h \
+ peida.h utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h nbmath.h histos.h \
+ cvector.h matrix.h /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h datatypes.h imageop.h cimage.h \
+ rzimage.h rzvect.h dvlist.h cspline.h nbtri.h
+$(OBJ)integ.o: integ.cc /home/ansari/DPC/Include/defs.h integ.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h generalfit.h matrix.h peida.h \
+ utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h fmath.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h cvector.h generaldata.h poly.h
+$(OBJ)linfit.o: linfit.cc /home/ansari/DPC/Include/defs.h peida.h utils.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h linfit.h matrix.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h cvector.h
+$(OBJ)matrix.o: matrix.cc /home/ansari/DPC/Include/defs.h peida.h utils.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h matrix.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h cvector.h generalfit.h \
+ generaldata.h poly.h
+$(OBJ)median.o: median.cc
+$(OBJ)ntuple.o: ntuple.cc /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/peidainit.h ntuple.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/pclassids.h dvlist.h
+$(OBJ)outilsinit.o: outilsinit.cc outilsinit.h \
+ /home/ansari/DPC/Include/peidainit.h /home/ansari/DPC/Include/defs.h \
+ matrix.h peida.h utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h fmath.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h cvector.h poly.h dvlist.h \
+ histos.h histos2.h hisprof.h ntuple.h generaldata.h cimage.h \
+ rzimage.h rzvect.h datatypes.h tabmath.h nbconst.h dates.h datime.h
+$(OBJ)perandom.o: perandom.cc /home/ansari/DPC/Include/defs.h perandom.h \
+ /home/ansari/DPC/Include/machine.h histos.h peida.h utils.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h cvector.h matrix.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h nbrandom.h pemath.h
+$(OBJ)poly.o: poly.cc /home/ansari/DPC/Include/defs.h poly.h peida.h utils.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h cvector.h matrix.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h linfit.h
+$(OBJ)pversion.o: pversion.cc pversion.h \
+ /home/ansari/DPC/Include/peidainit.h /home/ansari/DPC/Include/defs.h
+$(OBJ)rk4cdifeq.o: rk4cdifeq.cc /home/ansari/DPC/Include/defs.h rk4cdifeq.h \
+ difeq.h /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h cvector.h matrix.h peida.h \
+ utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h fmath.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/ctimer.h /home/ansari/DPC/Include/peida.h
+$(OBJ)rzimage.o: rzimage.cc /home/ansari/DPC/Include/defs.h rzimage.h \
+ rzvect.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h \
+ /home/ansari/DPC/Include/perrors.h datatypes.h \
+ /home/ansari/DPC/Include/ppersist.h \
+ /home/ansari/DPC/Include/pclassids.h dvlist.h generalfit.h matrix.h \
+ peida.h utils.h fmath.h cvector.h generaldata.h poly.h
+$(OBJ)simplesort.o: simplesort.cc /home/ansari/DPC/Include/defs.h \
+ simplesort.h peida.h utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h
+$(OBJ)tabmath.o: tabmath.cc /home/ansari/DPC/Include/defs.h tabmath.h \
+ peida.h utils.h /home/ansari/DPC/Include/machine.h \
+ /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h fmath.h nbconst.h
+$(OBJ)utils.o: utils.cc /home/ansari/DPC/Include/defs.h utils.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h
+$(OBJ)datime.o: datime.c /home/ansari/DPC/Include/defs.h strutil.h nbconst.h \
+ datime.h
+$(OBJ)matxop.o: matxop.c matxop.h nbmath.h
+$(OBJ)nbmath.o: nbmath.c nbmath.h matxop.h nbinteg.h nbtri.h
+$(OBJ)nbrandom.o: nbrandom.c /home/ansari/DPC/Include/defs.h \
+ /home/ansari/DPC/Include/machine.h nbmath.h nbrandom.h
+$(OBJ)nbtri.o: nbtri.c nbtri.h
+$(OBJ)strutil.o: strutil.c strutil.h
Index: /tags/DPC_V0/SophyaLib/NTools/NTools.o.list
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/NTools.o.list	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/NTools.o.list	(revision 1307)
@@ -0,0 +1,37 @@
+cimage.o
+cspline.o
+cvector.o
+datacards.o
+datatypes.o
+dates.o
+datime.o
+difeq.o
+dvlist.o
+dynccd.o
+fct1dfit.o
+fct2dfit.o
+generaldata.o
+generalfit.o
+hisprof.o
+histos.o
+histos2.o
+imageop.o
+integ.o
+linfit.o
+matrix.o
+matxop.o
+median.o
+nbmath.o
+nbrandom.o
+nbtri.o
+ntuple.o
+outilsinit.o
+perandom.o
+poly.o
+pversion.o
+rk4cdifeq.o
+rzimage.o
+simplesort.o
+strutil.o
+tabmath.o
+utils.o
Index: /tags/DPC_V0/SophyaLib/NTools/cimage.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/cimage.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/cimage.cc	(revision 1307)
@@ -0,0 +1,1971 @@
+//  Classes image typee      
+//                    E.Aubourg , E. Lesquoy  01-03/95   
+//                    Modifs R. Ansari   04/95
+
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+// $Id: cimage.cc,v 1.1.1.1 1999-04-09 17:57:57 ansari Exp $        
+
+
+#include "defs.h"
+#include <string.h>
+#include <stdio.h>
+
+#include "perrors.h"
+#include "cimage.h"
+#include "fct1dfit.h"
+#include "histos.h"
+#include "nbconst.h"
+#include "utils.h"
+
+/* ..............   Classe  Image<T>    ...............   */
+
+//++
+// Class 	Image<T>
+// Lib 		Images++
+// include	cimage.h
+//
+//
+//	Classe descendant (heritier) de la classe *RzImage*, permettant
+//	l'instantiation d'objets image avec un typage fort (entier, reel, ...)
+//
+//	Des objets de type "Image<uint_1>, Image<uint_2>, Image<int_2>, Image<int_4>"
+//	(entier) et "Image<r_4>" (flottant) peuvent etre crees.
+//	Des typedef (*ImageU1*, *ImageU2*, *ImageI2*, *ImageI4*, *ImageR4*) 
+//	facilite l'utilisation de ces classes.
+//--
+//++
+// Links	Parents
+// RzImage
+//--
+//++
+// Links	Descendants
+// FitsImage<T>
+//--
+//++
+// Links	Voir aussi
+// DVList
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+// Image<T>(int sizx, sizy, int zero)
+//	Creation d'une image de type "T", de taille "sizx*sizy" pixels.
+//	Si "zero" non nul, tous les pixels de l'image sont mis a zero.
+// Image<T>(char* flnm)
+//	Cree une image a partir du fichier "flnm". Celui-ci doit etre 
+//	au format "PPF" et cree par la methode "Save() ou "Write()".
+//--
+
+template <class T>
+Image<T>::Image(int sizx, int sizy, int zero)
+: RzImage(DataType((T)0), sizx, sizy), imagePtr( (T*) voidP )
+{
+  if (zero) Zero();
+  END_CONSTRUCTOR
+}
+
+/* --Methode-- */
+template <class T>
+Image<T>::Image()
+: RzImage(DataType((T)0)), imagePtr(0)
+{
+  END_CONSTRUCTOR
+}
+
+
+/* --Methode-- */
+template <class T>
+void Image<T>::Allocate(int sizx, int sizy, int zero, ImgVectP* pvpsh)
+{
+  RzImage::Allocate(DataType((T)0), sizx, sizy, pvpsh);
+  imagePtr = (T*) voidP;
+  if (!imagePtr) THROW(allocationErr);
+  if (zero) Zero();
+}
+
+template <class T>
+void Image<T>::SetPixels(int szx, int szy, T* pim)
+{
+  RzImage::SetPixels(DataType((T)0), szx, szy, pim);
+  imagePtr = pim;
+}
+
+/* --Methode-- */
+template <class T>
+Image<T>::~Image()
+{}
+
+
+//++
+// Image<T>(const Image<T>& src, int sharePixels)
+//	Constructeur par copie. Fabrique une image identique a l'image "src".
+//	Si "sharePixels" est non nul, le tableau des pixels est commun 
+//	aux deux images ("src" et celle creee)
+// Image<T>(const Image<T>& src, int orgx, int orgy, int sizx, int sizy)
+//	Construit une image de type "T", a partir des pixels de l'image
+//	"src" (du meme type), de taille "sizx*sizy" et de l'origine
+//	"orgx, orgy" dans "src". Si "orgx" et/ou "orgy" sont negatifs,
+//	la taille de la nouvelle image est automatiquement calculee 
+//	pour contenir toute l'image source a partir de l'origine specifiee.
+//	Genere l'exception "sizeMismatchErr" en cas d'incompatibilite 
+//	taille/origine. 
+//--
+
+/* --Methode-- */
+template <class T> 
+Image<T>::Image(const Image<T>& src, int sharePixels)
+: RzImage(src, sharePixels)
+{
+  imagePtr = (T*) voidP;
+  if (!imagePtr) THROW(allocationErr);
+  END_CONSTRUCTOR
+}
+
+/* --Methode-- */
+template <class T> 
+Image<T>::Image(const Image<T>& src, int orgx, int orgy, int sizx, int sizy)
+:RzImage()
+{
+  // A optimiser...
+  if (sizx < 0) sizx = src.XSize()-orgx;
+  if (sizy < 0) sizy = src.YSize()-orgy;
+  if (orgx+sizx > src.XSize() || orgy+sizy > src.YSize())
+    THROW(sizeMismatchErr);
+
+  Allocate(sizx, sizy);
+  for (int i=0; i<sizx; i++)
+    for (int j=0; j<sizy; j++)
+      (*this)(i,j) = src(i+orgx, j+orgy);
+
+  SetOrg(src.XOrg()+orgx, src.YOrg()+orgy);
+  SetPxSize(src.XPxSize(), src.YPxSize());    
+  END_CONSTRUCTOR
+}
+
+//++
+// LaTeX 	Pour contrer un mauvais espacement des paragraphes de LaTeX
+// \newpage
+//--
+//++
+// Image<T>()
+//	Creation d'une image de type "T" sans allocation du tableau des pixels.
+//	Le tableau des pixels devra etre ensuite alloue par la methode "Allocate()"
+//--
+
+//++
+// Image<T>(const RzImage& rzimg)
+//	Permet de construire une image typee a partir d'une RzImage ("rzimg")
+//	Le tableau des pixels est commun aux deux images.
+//	Les pixels de l'image "rzimg" doivent etre du type "T", sinon 
+//	l'exception "typeMismatchErr" est generee.
+//--
+/* --Methode-- */
+template <class T>
+Image<T>::Image(const RzImage& rzimg)
+:RzImage(rzimg,1)
+{
+
+  if (rzimg.PixelType() != DataType((T)0))
+    THROW(typeMismatchErr);
+  imagePtr = (T*) voidP;
+  if (!imagePtr) THROW(allocationErr);
+
+  END_CONSTRUCTOR
+}
+
+//++
+// void Allocate(int sizx, int sizy, int zero=1, ImgVectP* pvpsh=NULL)
+//	Alloue le tableau des pixels.
+//--
+//++
+// ~Image<T>
+//	Destructeur. supprime le tableau des pixels en memoire si celui-ci
+//	n'est pas utilise par d'autres objets image.
+//--
+
+/* --Methode-- */
+template <class T> 
+Image<T>::Image(char *flnm)
+:RzImage(flnm)
+{
+  imagePtr = (T*) voidP;
+  if (!imagePtr) THROW(allocationErr);
+
+  END_CONSTRUCTOR
+}
+
+
+/* --Methode-- */
+template <class T> 
+void  Image<T>::ReadSelf(PInPersist& s)
+{
+  RzImage::ReadSelf(s);
+  imagePtr = (T*) voidP;
+}
+
+//++
+// Titre	Operateurs
+//	Un grand nombre des operations pouvant etre effectuees sur un 
+//	tableau de nombre ont ete defini pour les objets "Image<T>"
+//	Dans les operations faisant intervenir deux images, l'exception
+//	"sizeMismatchErr" est generee si les tailles (en X ou en Y) des 
+//	deux images ne sont pas identiques.
+//--
+
+//++
+// Image<T>& operator= (const Image<T>& rhs)
+//	Copie le contenu (valeurs des pixels) de l'image "rhs".
+//	Si l'image destination (membre gauche de =) n'a pas son 
+//	tableau de pixels alloue, celui-ci est cree a une taille
+//	identique a celle de "rhs"
+// Image<T>& operator= (T val)
+//	Met tous les pixels de l'image a la valeur "val"
+//--
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator = (const Image<T>& src)
+{
+  if (imagePtr) {
+    if (siz_x != src.siz_x || siz_y != src.siz_y)
+      THROW(sizeMismatchErr);
+  } else
+    Allocate(src.siz_x, src.siz_y);
+  
+  (RzImage)(*this) = (RzImage)src;
+  return *this;
+}
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator = (T a)
+{
+  T* pDst = imagePtr;
+  int nPix = siz_x * siz_y;
+
+  for (int i=0; i<nPix; i++, pDst++)
+    *pDst = a;
+
+  return *this;
+}
+
+/* --Methode-- */
+template <class T>
+void Image<T>::Zero()
+{
+  memset(imagePtr,0,siz_x * siz_y * sizeof(T));
+}
+
+/* --Methode-- */
+#if 0 // a la mort de RzImage
+template <class T>
+void Image<T>::Clear()
+{
+  if (imagePtr) {
+    delete[] imagePtr;
+    imagePtr = 0;
+    siz_x = 0;
+    siz_y = 0;
+  }
+}
+#endif
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator+= (Image<T> const& a)
+{
+  if (siz_x != a.siz_x || siz_y != a.siz_y)
+    THROW(sizeMismatchErr);
+  T* pSrc = a.imagePtr;
+  T* pDst = imagePtr;
+  int nPix = siz_x * siz_y;
+
+  for (int i=0; i<nPix; i++, pSrc++, pDst++)
+    *pDst = PutInRange((double)*pSrc + (double)*pDst, *pDst);
+
+  return *this;
+}
+
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator-= (Image<T> const& a)
+{
+  if (siz_x != a.siz_x || siz_y != a.siz_y)
+    THROW(sizeMismatchErr);
+  T* pSrc = a.imagePtr;
+  T* pDst = imagePtr;
+  int nPix = siz_x * siz_y;
+
+  for (int i=0; i<nPix; i++, pSrc++, pDst++)
+    *pDst = PutInRange((double)*pDst - (double)*pSrc, *pDst);
+
+  return *this;
+}
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator*= (Image<T> const& a)
+{
+  if (siz_x != a.siz_x || siz_y != a.siz_y)
+    THROW(sizeMismatchErr);
+  T* pSrc = a.imagePtr;
+  T* pDst = imagePtr;
+  int nPix = siz_x * siz_y;
+
+  for (int i=0; i<nPix; i++, pSrc++, pDst++)
+    *pDst = PutInRange((double)*pDst * (double)*pSrc, *pDst);
+
+  return *this;
+}
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator/= (Image<T> const& a)
+{
+  if (siz_x != a.siz_x || siz_y != a.siz_y)
+    THROW(sizeMismatchErr);
+  T* pSrc = a.imagePtr;
+  T* pDst = imagePtr;
+  int nPix = siz_x * siz_y;
+
+  for (int i=0; i<nPix; i++, pSrc++, pDst++)
+    if (*pSrc)
+      *pDst = PutInRange((double)*pDst / (double)*pSrc, *pDst);
+    else *pDst = (T) MaxRange(*pDst);
+
+  return *this;
+}
+
+//++
+//  Image<T>& operator += -= *= /= (Image<T> const& rhs)
+//	Ajoute (+=), soustrait(-=), multiplie(*=), divise(/=) les valeurs des pixels 
+//	de l'image a gauche de l'operateur par les pixels correspondants
+//	de l'image a droite de l'operateur ("rhs")
+//  Image<T>& operator += -= *= /= (double crhs)
+//	Ajoute (+=), soustrait(-=), multiplie(*=), divise(/=) les valeurs des pixels 
+//	de l'image a gauche de l'operateur par la constante "crhs"
+//--
+
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator+= (double a)
+{
+  T* pDst = imagePtr;
+  int nPix = siz_x * siz_y;
+
+  for (int i=0; i<nPix; i++, pDst++)
+    *pDst = PutInRange((double)*pDst + a, *pDst);
+
+  return *this;
+}
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator-= (double a)
+{
+  T* pDst = imagePtr;
+  int nPix = siz_x * siz_y;
+
+  for (int i=0; i<nPix; i++, pDst++)
+    *pDst = PutInRange((double)*pDst - a, *pDst);
+
+  return *this;
+}
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator*= (double a)
+{
+  T* pDst = imagePtr;
+  int nPix = siz_x * siz_y;
+
+  for (int i=0; i<nPix; i++, pDst++)
+    *pDst = PutInRange((double)*pDst * a, *pDst);
+
+  return *this;
+}
+
+
+/* --Methode-- */
+template <class T> 
+Image<T>& Image<T>::operator/= (double a)
+{
+  T* pDst = imagePtr;
+  int nPix = siz_x * siz_y;
+  
+  for (int i=0; i<nPix; i++, pDst++)
+    *pDst = PutInRange((double)*pDst / a, *pDst);
+  
+  return *this;
+}
+
+
+
+//++
+// Image<T> operator + - * / (Image<T> const& a, Image<T> const& b)
+//	Ajoute, soustrait, multiplie, divise les pixels des deux 
+//	images "a" et "b" et l'affecte a gauche de l'operateur egal.
+// operator + - * / (Image<T> const& a, double cb)
+//	Ajoute, soustrait, multiplie, divise le contenu de l'image "a"
+//	par la constante "cb" et l'affecte a l'image a gauche de l'operateur = .
+// 
+//	Il est preferable d'utiliser dans la mesure du possible, les 
+//	operateurs "+=", "-=", "*=", "/=" afin d'eviter des copies 
+//	inutiles.
+//
+//	*Exemples:*
+//| // Creation des images
+//| ImageR4  ai(200,300), bi, ci;
+//| // Tous les pixels a 238.5
+//| ai = 238.5;
+//| // Image bi meme taille, meme valeurs de pixels que ai
+//| bi = ai;    
+//| // On soustrait 13.2 a tous les pixels de ai
+//| ai -= 13.2;
+//| // Je divise bi par ai (pixel par pixel) qu'on affecte a bi
+//| bi /= ai;
+//| // On somme ai et bi (pixel par pixel) qu'on affecte a ci
+//| ci = ai + bi; 
+//--
+
+
+/* --Methode-- */
+template <class T>
+Image<T> Image<T>::WhereNonZero()
+{
+  Image<T> c(*this);
+  for (int i=0; i<XSize(); i++)
+    for (int j=0; j<YSize(); j++)
+      c(i,j) = c(i,j) ? 1 : 0;
+  return c;
+}
+
+//++
+// void PrintImage(ostream& os) const
+//	Envoie le contenu de l'image (formatte, texte) sur le 
+//	flot (stream) de sortie "os".
+//	Attention: Ca peut faire beaucoup de ligne !
+// void PrintImage() const
+//	Appel a PrintImage(cout) - Sortie sur cout .
+//--
+
+
+/* --Methode-- */
+template <class T>
+void Image<T>::PrintImage(ostream& os) const
+//  Impression de tout le contenu de l'image
+{
+#define PrPvLn 10
+#define PrSize 6
+int i,j,k,ido,ideb,ifin;
+int siz_x,siz_y;
+
+siz_x= XSize();
+siz_y= YSize();
+
+os << " Image::PrintImage: type pixel " ;
+os << DataName(dataType) ;  
+os << ", NbPix=("<<siz_x<<","<<siz_y<<") \n";  
+
+
+/* segmentation avec des lignes de PrPvLn valeurs */
+
+ido = (siz_x-1) / PrPvLn + 1;
+
+char buff[256];
+
+for(k=0;k<ido;k++)
+  {
+  ideb = k*PrPvLn;
+  ifin = ideb + PrPvLn;
+  if ( ifin >siz_x ) ifin =  siz_x ;
+  sprintf(buff, "    ---- colonnes   %d   a   %d  ----\n",ideb,ifin-1);
+  os << buff ;
+  for(j=0; j<siz_y; j++)
+    {
+    sprintf(buff, "%3d - ",j);
+    os << buff;
+    for (i=ideb; i<ifin; i++)
+      {
+        os.width(PrSize);
+// les uint_1 sont traites comme characteres par les ostream ...
+        if (PixelType() == kuint_1) os << ((int)((*this)(i,j))) << " ";
+        else os << (*this)(i,j) << " ";
+      }
+     os << endl;
+     }
+   }
+
+ return;
+}
+
+
+//++
+// Titre	Acces aux pixels
+//--
+//++
+// T&  operator() (int x, int y)
+//	Acces au pixel "(x,y)" de l'image (lecture/ecriture)
+// T&  operator[] (int i)
+//	Acces au pixel numero "i" de l'image (lecture/ecriture)
+//
+//| ImageU2 img(100,100);
+//| int i,j,k;
+//| // Remplissage de la moitie de l'image
+//| for(k=0; k<100*50; k++)  img[k] = k%500;
+//| img(50, 10); // Valeur du pixel (50, 10)
+//
+// T*  ImagePtr()
+//	Renvoie un pointeur du type "T (uint_2, r_4, ...)" sur le
+//	tableau des pixels de l'image. A n'utiliser que si un reelle
+//	optimisation de l'acces aux pixels peut etre effectuee.
+//--
+
+
+
+//++
+// Titre	Traitements simples
+//--
+//++
+// int  CheckDyn(double min=-9.e19, double max=9.e19)
+//	Cette methode retourne le nombre de pixels hors dynamique "( <min ou >max )"
+//	Met a jour les donnees membres "min/maxPix nbNul/Sat".
+//	Calcule aussi la moyenne et le sigma des pixels -> "moyPix, sigPix"
+//	Implementation plus efficace de la methode "RzImage::CheckDyn()"
+//--
+
+/* --Methode-- */
+template <class T>
+int Image<T>::CheckDyn(double min, double max)
+
+/*  Cette methode retourne le nombre de pixels hors dynamique    */
+/* ds le pave ( <min ou >max )                                   */
+/* Met a jour la structure image Min/MaxPix nbNul/Sat            */
+/* Calcule aussi la moyenne et le sigma des pixels, met a jour   */
+/* moypix et sigpix dans la structure                            */
+
+{
+T pixv=0;
+double dv;
+
+T minadu = PutInRange(min, pixv);
+T maxadu = PutInRange(max, pixv);
+T minpix = PutInRange(maxadu+1, pixv);
+T maxpix = PutInRange(minadu-1, pixv);
+
+double m = 0.;
+double s = 0.;
+int n9 = 0;
+int n0 = 0;
+int n = XSize()*YSize();
+for(int i=0; i<n; i++) 
+  {
+  pixv = imagePtr[i];
+  if (pixv <= maxadu && pixv >= minadu) 
+    {  
+    if (pixv < minpix)  minpix = pixv;
+    else if (pixv > maxpix)  maxpix = pixv;  
+    dv = (double)pixv;
+    m += dv;  s += (dv*dv);
+    }
+  else 
+    {  
+    if (pixv > maxadu)  n9++;
+    if (pixv < minadu)  n0++; 
+    }
+  }
+
+nbNul = n0;
+nbSat = n9;
+minPix = minpix;
+maxPix = maxpix;
+
+n -= (n0+n9);
+if (n > 0)
+  { dv = (double)n;  m /= dv;  s = s/dv - m*m;
+  if (s>0.)  s = sqrt(s);  else s = 0.;
+  moyPix = m;  sigPix = s; }
+else { moyPix = 0.;  sigPix = -1.; }
+
+return(n0+n9);
+}
+
+//++
+// SeuilBas(double seuil, double val)
+//	Met les pixels en dessous du "seuil" (< seuil) a la valeur "val".
+// SeuilBas(double seuil)
+//	Met les pixels en dessous du "seuil" (< seuil) a zero
+// SeuilHaut(double seuil, double val)
+//	Met les pixels au dessus du "seuil" (> seuil) a la valeur "val".
+// SeuilHaut(double seuil)
+//	Met les pixels au dessus du "seuil" (> seuil) a zero
+//--
+
+/* --Methode-- */
+template <class T>
+void Image<T>::SeuilBas(double seuil, double val)
+
+/*   Met a une valeur definie tous les pixels    */
+/*   en dessous du seuil                         */
+
+{
+  if (!ImagePtr())   THROW(nullPtrErr);
+  T* PtPix=ImagePtr();
+  int nPix=XSize()*YSize();
+  for(int i=0 ; i<nPix;i++,PtPix++) {if(*PtPix < (T) seuil) *PtPix = (T) val;};
+}
+
+/* --Methode-- */
+template <class T>
+void Image<T>::SeuilHaut(double seuil, double val)
+
+/*   Met a une valeur definie tous les pixels    */
+/*   en dessus du seuil                         */
+
+{
+  if (!ImagePtr())   THROW(nullPtrErr);
+  T* PtPix=ImagePtr();
+  int nPix=XSize()*YSize();
+  for(int i=0 ; i<nPix;i++,PtPix++) {if(*PtPix > (T) seuil) *PtPix = (T) val;};
+}
+
+/* --Methode-- */
+template <class T>
+void Image<T>::SeuilBas(double seuil)
+{
+  SeuilBas(seuil,seuil);
+}
+
+/* --Methode-- */
+template <class T>
+void Image<T>::SeuilHaut(double seuil)
+{
+  SeuilHaut(seuil,seuil);
+}
+
+/* --Methode-- (cmv 23/09/96) */
+template <class T>
+//++
+void Image<T>::HBinInt(int& nbin,float& xmin,float& xmax)
+//
+//	Valeur pour avoir un bin entier quand on fait un
+//	histogramme 1D des pixels (pour les images entieres).
+//--
+{
+if( PixelType()<kuint_2 || PixelType()>kint_4 ) return;
+double binw = (xmax-xmin)/nbin;
+binw = (double) ( (int)(binw+0.5) );
+if( binw <= 0. ) binw = 1.;
+xmin = (float) ( (int) xmin );
+xmax = (float) ( (int) (xmax + binw) );
+nbin = (int)( (xmax-xmin)/binw + 0.1 );
+}
+
+/* --Methode-- (cmv 23/09/96) */
+template <class T>
+//++
+int Image<T>::EstimeFdSg(float& xbmax,float& sgbmax
+             ,float nbsig,float frac,float lowbad,float highbad,int deb)
+//
+//	Pour donner une estimation  du fond de ciel et du sigma ciel.
+//	Il est conseille de faire ceci sur une image partielle.
+//	Une premiere estimation du fond et du sigma est faite en nettoyant
+//	iterativement (cf MoySigmaIter).
+//	Puis un histogramme est rempli et rebinne jusqu'a ce que son maximum
+//	soit statistiquement significatif. Le fond et le sigma sont ensuite
+//	calcules par les methodes `FitMax' et `EstimeWidthS' de la classe Histo.
+//| xbmax = position du maximum
+//| sgbmax = valeur du sigma
+//| nbsig = dimensionnement de l'histo de depart en nombre
+//|         de sigma autour de la valeur maximum
+//| frac = valeur maximum principale / maximum secondaire a partir
+//|        de laquelle on considere qu'elle a une signification
+//|        statistique. 
+//| lowbad,highbad = dynamique utile de l'image traitee
+//| deb = niveau de debug
+//| Return : 0 = OK, -1 = echec MoySigmaIter, -2 = echec FitMax,
+//|                  -3 = echec FindWidth
+//--
+{
+T pixv=0;
+T minadu = PutInRange((double) lowbad , pixv);
+T maxadu = PutInRange((double) highbad, pixv);
+bool testl = (lowbad<highbad) ? true : false;
+lowbad  = (float) minadu;  highbad = (float) maxadu;
+
+if(deb<0) deb=0;
+int envd = 0;
+GetIntEnv("PDEBUG_FOND", envd);
+if (deb < envd) deb = envd;
+
+// moyenne et sigma bruts (iteratifs)
+int rc;
+float fd,sg;
+rc = MoySigmaIter(fd,sg,lowbad,highbad,1,5,0.1,3.5,deb-1);
+if(deb>0) cout<<"EstimeFdSg: MoySigmaIter rc="<<rc<<" fd="<<fd<<" sg="<<sg<<endl;
+if(rc<=0) return -1;
+
+// remplissage histogramme avec beaucoup de bins
+int nbin;
+float xmin,xmax;
+xmin = fd - nbsig*sg; if(testl && xmin<lowbad ) xmin = lowbad;
+xmax = fd + nbsig*sg; if(testl && xmax>highbad) xmax = highbad;
+nbin = XSize()*YSize()/20; if(nbin>2000) nbin=2000;
+Histo H(xmin,xmax,nbin);
+for(int i=0;i<XSize()*YSize();i++) H.Add((float) (*this)[i],1.);
+
+// redimensionnement de l'histo pour avoir une bonne signification stat.
+for(;;) {
+  float max1,max2;
+  int imax1,imax2;
+  rc = H.MaxiLocal(max1,imax1,max2,imax2);
+  float rap = 1.;
+  if( max1 != 0. ) rap = max2/max1;
+  // if(nbin<100) H.Print(80);
+  if(deb>1)
+     cout<<"nbin="<<nbin
+         <<"   maxloc="<<rc
+         <<"   maxi="<<max1<<" imax="<<imax1<<" xmax="<<H.BinCenter(imax1)
+         <<"   maxn="<<max2<<" imaxn="<<imax2<<" xmaxn="<<H.BinCenter(imax2)
+         <<" -> "<<rap<<endl;
+  if( rap<frac || nbin<=10 ) break;
+  nbin = (int)(nbin/1.5);
+  H.HRebin(nbin);
+}
+if(deb>1) { if(nbin<250) H.Print(80); else H.Print(80,-1.,1.,-1);}
+
+TRY {
+  xbmax = H.FitMax(2,0.5f,deb-2);
+  if(deb>1) cout<<"H.FitMax = "<<xbmax<<endl;
+} CATCHALL {
+   if(deb) cout<< "Echec H.FitMax"<< endl;
+   return(-2);
+} ENDTRY
+
+TRY {
+  float sdroit = -2.;
+  H.EstimeWidthS(0.5f,sgbmax,sdroit);
+  if(sgbmax<=0.) sgbmax = H.FindWidth(0.5f,deb-2);
+  sgbmax /= 2.36;
+  if(deb>1) cout<<"H.FindWidth = "<<sgbmax<<" (droit="<<sdroit<<")"<<endl;
+} CATCHALL {
+   cout<< "Echec H.FindWidth"<< endl;
+   return(-3);
+} ENDTRY
+
+return 0;
+}
+
+/* --Methode--  (cmv 23/09/96) */
+template <class T>
+//++
+float Image<T>::FondCiel(int nbin,float bin_low,float bin_high
+                         ,int degre,float frac,int modu,int deb)
+//
+//	Calcul du fond de ciel:
+//	Remplissage d'un histogramme avec le contenu des pixels du pave,
+//	recherche du bin contenant le maximum,
+//	recheche des limites a frac% de chaque cote du maximum
+//	et fit d'un polynome du 2sd ou 3ieme degre dans cette zone.
+//| Input:
+//|   nbin,bin_low,bin_high : definition de l'histogramme
+//|   degre : degre du fit (2 ou 3)
+//|   frac : definition de la zone de fit a frac% du maximum
+//|   modu : on prend 1 px sur modu
+//|   deb : debug flag
+//| Output: renvoie le maximum de l'histogramme (fond de ciel)
+//|         et update le membre protected fond (si succes)
+//--
+{
+T pixv;
+
+if(modu<=0) modu = 1;
+if(frac<=0.) frac = 0.5;
+if(degre<2 || degre>3) degre = 2;
+if(deb>0)
+  printf("Image::FondCiel: nbin=%d dyn=%g,%g deg=%d frac=%g modu=%d\n"
+        ,nbin,bin_low,bin_high,degre,frac,modu);
+if(nbin<=degre) THROW(inconsistentErr);
+
+TRY {
+
+  Histo tab(bin_low,bin_high,nbin);
+  double sum = 0.;
+  volatile int n = 0, nsum = 0;
+  for(int i=0;i<XSize()*YSize();i++) {
+    n++;
+    if( n%modu != 0 ) continue;
+    pixv = imagePtr[i];
+    tab.Add( (float) pixv );
+    sum += (double) pixv;
+    nsum++;
+  }
+  if(deb>1) { int im = tab.IMax();
+              tab.Print(80,1.,-1.,0,im-50,im+50); }
+
+  float xf = 0.;
+  // tout dans moins de degre bins
+  if( tab.BinNonNul() <= degre ) {
+    if(nsum<=0) THROW(inconsistentErr);
+    xf = sum / (double) nsum;
+    if(deb>0) printf("%d bins <= %d -> Succes Mean = %g\n"
+                    ,tab.BinNonNul(),degre,xf);
+    fond = xf;
+    RETURN(xf);
+  }
+
+  TRY {
+    xf = tab.FitMax(degre,frac,deb-1);
+    if(deb>0) printf("Succes tab.FitMax = %g\n",xf);
+    fond = xf;
+    RETURN(xf);
+  } CATCHALL {
+    if(deb>0)
+       printf("Echec tab.FitMax BinNonNul=%d\n",tab.BinNonNul());
+    THROW(inconsistentErr);
+  } ENDTRY
+
+} CATCHALL {
+   THROW_SAME;
+} ENDTRY
+}
+
+/* --Methode-- (cmv 23/09/96) */
+template <class T>
+//++
+float Image<T>::SigmaCiel(int nbin,float bin_low,float bin_high
+                         ,float& means,float lowbad,float highbad
+                         ,float nsig,int modu,int deb)
+//
+//	Calcul du sigma du fond de ciel:
+//	Remplissage d'un histogramme avec px-<px8> pour les pixels
+//	entre lowbad et highbad (px=valeur du pixel etudie,
+//	<px8>=moyenne des 8 pixels qui lui sont contigus).
+//	Une premiere estimation du sigma (s1) et realisee en cherchant
+//	la largeur a mi-hauteur de cet histogramme. Puis un fit non-lineaire
+//	d'une gaussienne est effectue dans +/- nsig*s1
+//| Input:
+//|   nbin,bin_low,bin_high : definition de l'histogramme
+//|   lowbad,highbad : limites des pixels a utiliser
+//|   nsig : la zone de fit est definie a +/- nsig*sigma du maximum
+//|   modu : on prend 1 px sur modu
+//|   deb : debug flag
+//| Output:
+//|   means = moyenne fittee de l'histogramme (normalement -> 0)
+//|   renvoie le sigma du fond de ciel
+//|     et update le membre protected sigmaFond (si succes)
+//--
+{
+T pixv=0;
+T minadu = PutInRange((double) lowbad , pixv);
+T maxadu = PutInRange((double) highbad, pixv);
+volatile bool testl = (lowbad<highbad) ? true : false;
+
+if(nbin<5) THROW(inconsistentErr);
+if(nsig<=0.) nsig = 4.;
+if(modu<=0) modu = 1;
+means = 0.;
+if(deb>0)
+  cout << "SigmaCiel( nbin=" << nbin
+       << ", bin_low=" << bin_low
+       << ", bin_high=" << bin_high
+       << ", lowbad=" << lowbad
+       << ", highbad=" << highbad
+       << ", nsig=" << nsig
+       << ", modu=" << modu
+       << ", deb=" << deb << endl;
+
+// coeff pour corriger le sigma de (S-<S8>) par rapport au sigma de S
+// sigma(S) = sigma(S-<S8>) * 1/sqrt(1+1/8) = 2*sqrt(2)/3
+double coeff = 2.*Rac2/3.;
+
+TRY {
+
+  Histo tab(bin_low,bin_high,nbin);
+  tab.Errors();
+
+  int nmod = 0, nsum = 0;
+  double sum= 0., sum2 = 0.;
+  for(int j=1;j<YSize()-1;j++) for(int i=1;i<XSize()-1;i++) {
+    nmod++;
+    if( nmod%modu != 0 ) continue;
+    pixv = (*this)(i,j);
+    if ( testl && (pixv < minadu || pixv > maxadu) ) continue;
+    double vp = (double) pixv;
+    double pxv = 0.;
+    volatile int n = 0;
+    for(int j1=j-1;j1<=j+1;j1++) for(int i1=i-1;i1<=i+1;i1++) {
+      if ( i1 == i && j1 == j ) continue;
+      pixv = (*this)(i1,j1);
+      if ( testl && (pixv < minadu || pixv > maxadu) ) continue;
+      pxv += (double) pixv;
+      n++;
+    }
+    if ( n != 8 ) continue;
+    vp = vp - pxv/(double) n;
+    tab.Add( (float) vp );
+    nsum++;
+    sum += vp;
+    sum2 += vp*vp;
+  }
+
+  float ms = tab.BinCenter( tab.IMax() );
+  volatile float sg = 0.;
+  if( tab.BinNonNul() == 1 ) {
+    if(deb>0) cout << tab.BinNonNul()
+                   << " bins non nul dans l'histogramme" << endl;
+    if(nsum<=1) THROW(inconsistentErr);
+    sum /= (double) nsum;
+    sum2 = sum2/(double) nsum - sum*sum;
+    if(sum2<0.) THROW(inconsistentErr);
+    means = sum;
+    sum2 = sqrt(sum2) * coeff;
+    sigmaFond = sum2;
+    RETURN((float) sum2);
+  } else {
+    TRY {
+      sg = tab.FindWidth(0.5,deb-1) / 2.36;
+    } CATCHALL {
+      THROW_SAME;
+    } ENDTRY
+  }
+  double h = tab.VMax();
+  if(deb>0) cout << "from histo: ms=" << ms 
+                           << "  sg=" << sg
+                           << "  h=" << h << endl;
+
+  float xmin = ms - nsig*sg;
+  float xmax = ms + nsig*sg;
+  int imin = tab.FindBin(xmin);
+  int imax = tab.FindBin(xmax);
+  if( imax-imin+1 < 4 ) {imax++; imin--;}
+  if(imin<0) imin=0;
+  if(imax>=tab.NBins()) imax=tab.NBins()-1;
+  int nb = imax-imin+1;
+  if( nb < 4 ) THROW(inconsistentErr);
+  if(deb>0) printf("xrange=[%g,%g] irange=[%d,%d] nb=%d\n"
+                  ,xmin,xmax,imin,imax,nb);
+  if(deb>2) tab.Print(80,1.,-1.,0,imin,imax);
+
+  Gauss1DPol     myfunc;
+  GeneralFit     myfit(&myfunc);
+  GeneralFitData mydata(1,nb);
+  for(int i=imin;i<=imax;i++) {
+     float e = tab.Error(i);
+     if( e <= 0. ) e = 1.;
+     mydata.AddData1(tab.BinCenter(i),tab(i),e);
+   }
+
+  myfit.SetData(&mydata);
+  myfit.SetParam(0,h,h/50.);
+  myfit.SetParam(1,ms,sg/10.);
+  myfit.SetParam(2,sg,sg/10.);
+  myfit.SetBound(2,0.,sg*5.);
+  int rc = myfit.Fit();
+  if(rc<0) THROW(inconsistentErr);
+  if(deb>1) myfit.PrintFit();
+
+  means = myfit.GetParm(1);
+  sum2 = myfit.GetParm(2) * coeff;
+  sigmaFond = sum2;
+  RETURN((float) sum2);
+
+} CATCHALL {
+   THROW_SAME;
+} ENDTRY
+
+}
+
+
+/* --Methode-- (cmv 23/09/96) */
+template <class T>
+//++
+int Image<T>::MoySigma(float& mean,float& sigma,float lowbad,float highbad,int modu)
+//
+//	Calcul de la moyenne (mean) et du sigma (sigma) dans un pave
+//	en ne considerant que les pixels compris entre lowbad et highbad.
+//	Seul 1 px sur modu est utilise.
+//	La fonction retourne le nombre de pixels utilises pour le calcul.
+//--
+{
+T pixv=0;
+T minadu = PutInRange((double) lowbad , pixv);
+T maxadu = PutInRange((double) highbad, pixv);
+bool testl = (lowbad<highbad) ? true : false;
+
+if(modu<=0) modu = 1;
+mean = sigma = 0.;
+
+int rc = 0, n = 0;
+double m = 0., s = 0., mm, ss, v;
+
+for(int j=0;j<YSize();j++) {
+  mm = ss = 0.;
+  for(int i=0;i<XSize();i++) {
+    n++;
+    if( n%modu != 0 ) continue;
+    pixv = (*this)(i,j);
+    if( testl && (pixv < minadu || pixv > maxadu) ) continue;
+    v = (double) pixv;
+    rc++;
+    mm += v;
+    ss += v*v;
+  }
+  m += mm;
+  s += ss;
+}
+
+if(rc==0) return(-1);
+
+m /= (double) rc;
+s = s/(double) rc - m*m;
+if(s<0.) return(-2);
+
+mean  = (float) m;
+sigma = (float) sqrt(s);
+
+moyPix = mean;     // Mise a jour de la structure
+sigPix = sigma;
+
+return rc;
+}
+
+/* --Methode-- (cmv 23/09/96) */
+template <class T>
+//++
+int Image<T>::MoySigmaIter(float& mean,float& sigma,float lowbad,float highbad
+                          ,int modu,int nitermx,float perdiff,float scut,int deb)
+//
+//	Calcul de moyenne et sigma iterativement:
+//| lowbad,highbad = dynamique permise pour la valeur
+//|                  des pixels en ADU
+//| modu = 1 px sur modu est utilise
+//| nitermx = nombre maximum d'iterations permises
+//| perdiff = condition d'arret en pourcent sur la variation du sigma
+//| scut = coupure en nombre de sigma courant pour l'iteration suivante
+//| mean = moyenne retournee
+//| sigma = sigma retourne
+//| return <= 0 probleme, sinon (>0) nombre de pixels utilises
+//--
+{
+if( scut<=0. || nitermx<=0 || perdiff<=0. ) return 0;
+if(modu<=0) modu = 1;
+bool testl = (lowbad<highbad) ? true : false;
+
+mean = sigma = 0.;
+float sigmaold = 0;
+float xmin = lowbad;
+float xmax = highbad;
+int rc = 0;
+
+for(int it=0;it<nitermx;it++) {
+  rc = MoySigma(mean,sigma,xmin,xmax,modu);
+  if(deb>0) cout<<"MoySigmaIter mean="<<mean<<" sigma="<<sigma
+                <<" npix="<<rc<<" entre "<<xmin<<","<<xmax<<endl;
+  if( rc <= 0 ) return rc;
+  if( it>=1 && fabs((double)(sigma-sigmaold))/sigma < perdiff ) break;
+  xmin = mean - scut*sigma; if(testl && xmin<lowbad ) xmin = lowbad;
+  xmax = mean + scut*sigma; if(testl && xmax>highbad) xmax = highbad;
+  sigmaold = sigma;
+}
+
+return rc;
+}
+
+/* --Methode-- (cmv 23/09/96) */
+template <class T>
+//++
+int Image<T>::FondSigmaCiel(float lowbad,float highbad,int pvsz
+              ,float nbsig1,float nbsig2,float nbsig3
+              ,float binsg,float frac,int modu,int deb)
+//
+//	Calcul automatique du fond de ciel et du sigma ciel en utilisant
+//	les methodes precedentes et en calculant au mieux le binning.
+//| lowbad,highbad: dynamoque utile de l'image (ADU)
+//| pvsz : taille du pave a traiter (centre au milieu de l'image)
+//| nbsig1 : pour EstimeFdSg  -> calcul sgbmax (def=3.5).
+//| nbsig2 : pour FondCiel (histo entre X maxi +/- nbsig2*sgbmax
+//|                        nbin = 2.*nbsig2*binsg) (def=5).
+//| nbsig3 : pour SigmaCiel (histo entre 0 +/- nbsig3*sgbmax
+//|                         nbin = 2.*nbsig3*binsg) (def=5).
+//| binsg : taille du bin pour les histos de FondCiel et SigmaCiel
+//|                        (def=0.33)
+//| frac : pour EstimeFdSg(...,frac,...)  (def=0.33)
+//--
+{
+if(pvsz<=0) pvsz = 100;
+if(nbsig1<=0) nbsig1 = 3.5;
+if(nbsig2<=0) nbsig2 = 5.0;
+if(nbsig3<=0) nbsig3 = 5.0;
+if(binsg<=0) binsg = 0.33; binsg = 1./binsg;
+if(frac<=0.) frac = 0.33;
+if(deb<0) deb=0;
+int lpdb = (deb>=3) ? deb-2 : 0;
+int envd = 0;
+GetIntEnv("PDEBUG_FOND", envd);
+if (lpdb < envd) lpdb = envd;
+if (deb < envd) deb = envd;
+float xbmax = 0., sgbmax = 0.;
+int nbin,rc;
+float xmin,xmax,binw,means;
+
+// creation sous image
+int pvsx = pvsz, pvsy = pvsz;
+if( pvsx > XSize() ) pvsx = XSize();
+if( pvsy > YSize() ) pvsy = YSize();
+Image<T> *ssima = NULL;
+bool cree = false;
+if( pvsx == XSize() && pvsy == YSize() ) {
+  ssima = this;
+} else {
+  int orgx = XSize()/2 - pvsx/2;  if( orgx < 0 ) orgx = 0;
+  int orgy = YSize()/2 - pvsy/2;  if( orgy < 0 ) orgy = 0;
+  if( orgx + pvsx > XSize() ) pvsx = XSize() - orgx;
+  if( orgy + pvsy > YSize() ) pvsy = YSize() - orgy;
+  ssima = new Image<T>(pvsx,pvsy);
+  cree = true;
+  CopieImageF(*ssima,*this,orgx,orgy,pvsx,pvsy,0,0,0.,0.);
+}
+
+// moyenne et sigma approches sur sous-image
+rc = ssima->EstimeFdSg(xbmax,sgbmax,nbsig1,frac,lowbad,highbad,deb-1);
+if( cree ) delete ssima;
+if(rc<0) return -2;
+fond = xbmax;
+sigmaFond = sgbmax;
+
+// bin entier... pas forcement necessaire.
+xmin = xbmax - nbsig2*sgbmax;
+xmax = xbmax + nbsig2*sgbmax;
+nbin = (int)(2.*nbsig2*binsg); if(nbin<5) nbin=5;
+binw = (xmax-xmin)/nbin;
+if(deb>0) cout<<"bin auto: xmin="<<xmin<<" xmax="<<xmax
+              <<" nbin="<<nbin<<" binw="<<binw<<endl;
+HBinInt(nbin,xmin,xmax);
+binw = (xmax-xmin)/nbin;
+if(deb>0) cout<<"bin auto entier:  nbin="<<nbin<<" binw="<<binw
+              <<" entre "<<xmin<<","<<xmax<<endl;
+
+// Optimisation de modu
+if( modu <= 0 ) {
+  // 4 fois plus de pixels que dans le pre-pave
+  int npv = 4*pvsz*pvsz;
+  int nima = XSize()*YSize();
+  if( npv >= nima || nima < 10000 ) modu = 1;
+      else modu = (int)( (float) nima / (float) npv );
+  if(deb) cout<<"modulo choisi a "<<modu<<endl;
+}
+
+// moyenne evoluee
+TRY {
+  fond = FondCiel(nbin,xmin,xmax,3,0.5,modu,lpdb);
+  if(deb>0) cout <<"Fond de ciel = "<<fond<< endl;
+} CATCHALL {
+  if(deb>0) cout << "Echec FondCiel" << endl;
+  return(-3);
+} ENDTRY
+  
+// sigma evolue
+TRY {
+  float dyn = nbsig3*sgbmax;
+  int nbins = (int) (2.*nbsig3*binsg);
+  float binws = (2.*dyn)/nbins;
+  sigmaFond = SigmaCiel(nbins,-dyn,dyn,means,lowbad,highbad,4.,modu,lpdb);
+  if(deb>0) cout <<"Sigma fond de ciel = "<<sigmaFond
+                <<" (ms="<<means<<") sur "<<nbins
+                <<" bins de largeur "<<binws<< endl;
+} CATCHALL {
+  if(deb>0) cout << "Echec SigmaCiel" << endl;
+  return(-4);
+} ENDTRY
+
+// Impression finale
+if(deb) cout <<"ImgSigmaCiel: fond= "<<xbmax<<" / "<< fond
+             <<"   sigma= "<<sgbmax<<" / "<<sigmaFond<<endl;
+
+return 0;
+}
+
+
+
+/*  .......................................................  */
+/*         Fonctions de copie d'images et de paves           */
+/*  .......................................................  */
+
+
+/* Nouvelle-Fonction */ 
+template <class T2, class T1>
+void CopieImageF(Image<T2>& copie, Image<T1> const& pim,
+         int org_pim_x, int org_pim_y,            /* origine pave a copier */
+         int pim_lpav_x, int pim_lpav_y,          /* largeur pave a copier */
+         int org_copie_x, int org_copie_y,        /* origine copie         */
+         double cutmin, double cutmax)            /* coupure pour max range*/
+
+/* Copie d'une image (pim) ds l'autre (copie) a partir d'un  */
+/* offset specifie en pixel                                  */
+/* attention: pas d'offset -> org_x = org_y = 0              */
+{
+int i,j;
+int x,y;
+const T1* pt_pim;
+T2* pt_copie;
+double pim_pix;
+int l_copie_x,l_copie_y;
+int step_copie_x;
+int step_pim_x;
+int pim_siz_x, pim_siz_y;
+int copie_siz_x, copie_siz_y;
+int switch_copie;
+
+pim_siz_x=pim.XSize();
+pim_siz_y=pim.YSize();
+if((org_pim_x < 0) || (org_pim_x > pim_siz_x))
+  { cout<< "CopieImage_erreure : org_pim_x: " <<org_pim_x<<" < 0 ou > a "<<pim_siz_x<<"\n\n";
+    THROW(rangeCheckErr);}
+if((org_pim_y < 0) || (org_pim_y > pim_siz_y))
+  { cout<< "CopieImage_erreure : org_pim_y: " <<org_pim_y<<" < 0 ou > a "<<pim_siz_y<<"\n\n";
+    THROW(rangeCheckErr);}
+
+copie_siz_x=copie.XSize();
+copie_siz_y=copie.YSize();
+if((org_copie_x < 0) || (org_copie_x > copie_siz_x))
+  { cout<< "CopieImage_erreure : org_copie_x: " <<org_copie_x<<" < 0 ou > a "<<copie_siz_x<<"\n\n";
+    THROW(rangeCheckErr);}
+if((org_copie_y < 0) || (org_copie_y > copie_siz_y))
+  { cout<< "CopieImage_erreure : org_copie_y: " <<org_copie_y<<" < 0 ou > a "<<copie_siz_y<<"\n\n";
+    THROW(rangeCheckErr);}
+
+x=pim_lpav_x;
+if(x > (pim_siz_x-org_pim_x)) x=pim_siz_x-org_pim_x;
+step_pim_x = pim_siz_x-x;
+
+if(x < copie_siz_x)
+  {
+   l_copie_x=x;
+   step_copie_x=copie_siz_x-x;
+  }
+else
+  {
+   l_copie_x=copie_siz_x;
+   step_copie_x=0;
+   step_pim_x=step_pim_x+x-copie_siz_x;
+   }
+
+if(org_copie_x  > 0 )
+  {
+  int x=copie_siz_x-org_copie_x;
+  if(x < l_copie_x )
+    {
+     step_pim_x=step_pim_x+l_copie_x-x;
+     l_copie_x=x;
+     step_copie_x=org_copie_x;
+    }
+  else
+    {
+     step_copie_x=copie_siz_x-l_copie_x;
+    }
+  }
+
+y=pim_lpav_y;
+if(y > (pim_siz_y-org_pim_y)) y=pim_siz_y-org_pim_y;
+
+if(y < copie_siz_y)
+  {
+   l_copie_y=y;
+  }
+else
+  {
+   l_copie_y=copie_siz_y;
+   }
+
+pt_pim  = pim.ImagePtr()+org_pim_y*pim_siz_x+org_pim_x;
+pt_copie=copie.ImagePtr()+org_copie_y*copie_siz_x+org_copie_x;
+
+switch((int)ConvType(*pt_pim,*pt_copie)) {
+  case t_same: case t_up:
+    switch_copie=0;
+  break;
+  case t_spe: case t_down:
+    switch_copie=1;
+  break;
+}
+
+if(cutmin < cutmax) switch_copie *= 2;
+
+switch(switch_copie) {
+  case 0:
+    for (j=0; j< l_copie_y; j++)
+      {
+      for(i=0; i< l_copie_x; i++)
+        {
+        *pt_copie++ =(T2)*pt_pim++;
+        }
+      pt_pim   += step_pim_x;
+      pt_copie += step_copie_x;
+      }
+  break;
+  case 1:
+    for (j=0; j< l_copie_y; j++)
+      {
+      for(i=0; i< l_copie_x; i++)
+        {
+        pim_pix = *pt_pim++;
+        *pt_copie++ = PutInRange(pim_pix, *pt_copie);
+        }
+      pt_pim   += step_pim_x;
+      pt_copie += step_copie_x;
+      }
+  break;
+  case 2:
+    for (j=0; j< l_copie_y; j++)
+      {
+      for(i=0; i< l_copie_x; i++)
+        {
+        pim_pix = *pt_pim++;
+        *pt_copie++ = (T2)SharePix(pim_pix,*pt_copie,cutmin,cutmax);
+        }
+      pt_pim   += step_pim_x;
+      pt_copie += step_copie_x;
+      }
+  break;
+}
+
+copie.SetOrg( pim.XOrg()+org_pim_x-org_copie_x, pim.YOrg()+org_pim_y-org_copie_y);
+}
+
+
+/* Nouvelle-Fonction */ 
+template <class T2, class T1>
+void CopieImage(Image<T2>& copie , Image<T1> const& pim)
+{
+if (!pim.ImagePtr())   THROW(nullPtrErr);
+if (!copie.ImagePtr()) copie.Allocate(pim.XSize(),pim.YSize());
+
+CopieImageF(copie, pim,0,0,pim.XSize(),pim.YSize(),0,0,0., 0.);
+}
+
+/* Nouvelle-Fonction */ 
+template <class T2, class T1>
+void CopieImage(Image<T2>& copie , Image<T1> const& pim,
+                int org_pim_x    , int org_pim_y,
+                int pim_lpav_x   , int pim_lpav_y,
+                int org_copie_x  , int org_copie_y,
+                double cutmin    , double cutmax )
+{
+if (!pim.ImagePtr())   THROW(nullPtrErr);
+if (!copie.ImagePtr()) THROW(nullPtrErr);
+copie.SetOrg(org_pim_x,org_pim_y);
+
+/* $CHECK$ Reza 28/04/95 : Je protege pour le moment contre les pave en
+dehors de l'image, mais je veux pouvoir copier des paves decale par
+rapport aux bornes de l'image source  Re- $CHECK$ CMV+Reza 30/09/96 */
+if ( (org_pim_x < 0) || (org_pim_y < 0) ||
+     (org_pim_x >= pim.XSize() ) || (org_pim_y >= pim.YSize() ) ||
+     ((org_pim_x+copie.XSize()) > pim.XSize()) ||
+     ((org_pim_y+copie.YSize()) > pim.YSize()) ) copie.Zero();
+if ( (org_pim_x < 0) || (org_pim_y < 0) ||
+     (org_pim_x >= pim.XSize() ) || (org_pim_y >= pim.YSize() )) return;
+/*  Fin de $CHECK$  */
+
+if((pim_lpav_x <= 0) || (pim_lpav_x > pim.XSize())) pim_lpav_x=pim.XSize();
+if((pim_lpav_y <= 0) || (pim_lpav_y > pim.YSize())) pim_lpav_y=pim.YSize();
+TRY {
+  CopieImageF(copie, pim,org_pim_x,org_pim_y,
+              pim_lpav_x, pim_lpav_y,
+              org_copie_x,org_copie_y,cutmin,cutmax);
+  }  CATCH(merr) {
+    if (merr != rangeCheckErr) THROW(merr);  // Re- $CHECK$ CMV+Reza 30/09/96
+  } ENDTRY
+}
+
+
+/* Nouvelle-Fonction */ 
+template <class T2, class T1>
+void CopiePave ( Image<T2>& pave , Image<T1> const& pim,
+                 float xc, float yc,
+                 double cutmin, double cutmax) 
+{
+int ix, iy;
+
+xc -= 0.5 * (float)(pave.XSize()-1);
+yc -= 0.5 * (float)(pave.YSize()-1);
+//  CopiePave tient compte de l'origine de l'image de depart   Reza 18/9/96
+xc -= pim.XOrg();     yc -= pim.YOrg();
+
+if ( xc >= 0.)  ix = (int)xc;
+else ix = (int)(xc-1.0);
+if ( yc >= 0.)  iy = (int)yc;
+else iy = (int)(yc-1.0);
+CopieImage(pave, pim, ix, iy, 0, 0, 0, 0, cutmin, cutmax ) ;
+}
+
+
+/* Nouvelle-Fonction */ 
+template <class T>
+void RzCopieImage(Image<T>& copie, RzImage const& pim,
+                  int org_pim_x , int org_pim_y,
+                  int pim_lpav_x, int pim_lpav_y,
+                  int org_copie_x, int org_copie_y,
+                  double cutmin , double cutmax)
+{
+  switch (pim.PixelType()) {
+  case kuint_2: {
+    ImageU2 src((RzImage&)pim);
+    CopieImage(copie, src, org_pim_x , org_pim_y,
+               pim_lpav_x, pim_lpav_y, org_copie_x, 
+               org_copie_y, cutmin, cutmax );
+    break;
+    }
+  case kint_2: {
+    ImageI2 src((RzImage&)pim);
+    CopieImage(copie, src, org_pim_x , org_pim_y,
+               pim_lpav_x, pim_lpav_y, org_copie_x, 
+               org_copie_y, cutmin, cutmax );
+    break;
+    }
+  case kint_4: {
+    ImageI4 src((RzImage&)pim);
+    CopieImage(copie, src, org_pim_x , org_pim_y,
+               pim_lpav_x, pim_lpav_y, org_copie_x, 
+               org_copie_y, cutmin, cutmax );
+    break;
+    }
+  case kr_4: {
+    ImageR4 src((RzImage&)pim);
+    CopieImage(copie, src, org_pim_x , org_pim_y,
+               pim_lpav_x, pim_lpav_y, org_copie_x, 
+               org_copie_y, cutmin, cutmax );
+    break;
+    }
+  case kr_8:
+  case kuint_4:
+  case kuint_1:
+  case kint_1:
+    cerr << " RzCopieImage(...) / Error, Unsupported image type (kr_8/ kuint_4/ kuint_1/ kint_1) " 
+         << (int)pim.PixelType() << "\n";
+    break;
+  default:
+    cerr << " RzCopieImage(...) / Error, Unknown image type !" <<  (int)pim.PixelType() << "\n";
+    break;
+  } 
+}
+
+
+/* Nouvelle-Fonction */ 
+template <class T>
+void RzCopieImage(Image<T>& copie, RzImage const& pim)
+{
+  switch (pim.PixelType()) {
+  case kuint_2: {
+    ImageU2 src((RzImage&)pim);
+    CopieImage(copie, src);
+    break;
+    }
+  case kint_2: {
+    ImageI2 src((RzImage&)pim);
+    CopieImage(copie, src);
+    break;
+    }
+  case kint_4: {
+    ImageI4 src((RzImage&)pim);
+    CopieImage(copie, src);
+    break;
+    }
+  case kr_4: {
+    ImageR4 src((RzImage&)pim);
+    CopieImage(copie, src);
+    break;
+    }
+  case kr_8:
+  case kuint_4:
+  case kuint_1:
+  case kint_1:
+    cerr << " RzCopieImage() / Error, Unsupported image type (kr_8/ kuint_4/ kuint_1/ kint_1) " 
+         << (int)pim.PixelType() << "\n";
+    break;
+  default:
+    cerr << " RzCopieImage() / Error, Unknown image type ! " <<  (int)pim.PixelType() << "\n";
+    break;
+  } 
+}
+
+/* Nouvelle-Fonction */ 
+template <class T>
+void RzCopiePave(Image<T> & pave, RzImage const & pim,
+                 float xc, float yc, 
+                 double cutmin, double cutmax) 
+{
+int ix, iy;
+
+xc -= 0.5 * (float)(pave.XSize()-1);
+yc -= 0.5 * (float)(pave.YSize()-1);
+//  RzCopiePave tient compte de l'origine de l'image de depart   Reza 18/9/96
+xc -= pim.XOrg();     yc -= pim.YOrg();
+
+if ( xc >= 0.)  ix = (int)xc;
+else ix = (int)(xc-1.0);
+if ( yc >= 0.)  iy = (int)yc;
+else iy = (int)(yc-1.0);
+
+RzCopieImage(pave, pim, ix, iy, 0, 0, 0, 0, cutmin, cutmax) ;
+}
+
+
+/* Nouvelle-Fonction */ 
+void RzPrintImage(RzImage & img)
+{
+switch (img.PixelType()) 
+  {
+  case kuint_1: 
+    {
+    ImageU1 src((RzImage&)img);
+    cout << src ;
+    break;
+    }
+  case kuint_2: 
+    {
+    ImageU2 src((RzImage&)img);
+    cout << src ;
+    break;
+    }
+  case kint_2: 
+    {
+    ImageI2 src((RzImage&)img);
+    cout << src ;
+    break;
+    }
+  case kint_4: 
+    {
+    ImageI4 src((RzImage&)img);
+    cout << src ;
+    break;
+    }
+  case kr_4: 
+    {
+    ImageR4 src((RzImage&)img);
+    cout << src ;
+    break;
+    }
+  case kr_8:
+  case kuint_4:
+  case kint_1:
+    cerr << " RzPrintImage() / Error, Unsupported image type (kr_8/kuint_4/ kint_1) " 
+         << (int)img.PixelType() << "\n";
+    break;
+  default:
+    cerr << " RzPrintImage() / Error, Unknown image type " <<  (int)img.PixelType() << "\n";
+    break;
+  } 
+}
+
+
+// ********** INSTANCES
+#if defined(__xlC) || defined(__aCC__)
+void instancetempcimage(int n)
+{
+// #pragma define_template
+/* Cette fonction sert uniquement a forcer le compilo a instancier les
+  classes/fonctions template   */
+
+int m = n-50;
+ImageU1  iu1(n,n), xiu1(m,m);
+ImageU2  iu2(n,n), xiu2(m,m);
+ImageI2  ii2(n,n), xii2(m,m);
+ImageI4  ii4(n,n), xii4(m,m);
+ImageR4  ir4(n,n), xir4(m,m);
+RzImage  rzi(kr_4, n, n);
+
+cout << iu1;
+cout << iu2;
+cout << ii2;
+cout << ii4;
+cout << ir4;
+
+CopieImageF(iu2, xiu2, 50, 50);
+CopieImageF(iu2, xii2, 50, 50);
+CopieImageF(iu2, xii4, 50, 50);
+CopieImageF(iu2, xir4, 50, 50);
+CopieImageF(ii2, xiu2, 50, 50);
+CopieImageF(ii2, xii2, 50, 50);
+CopieImageF(ii2, xii4, 50, 50);
+CopieImageF(ii2, xir4, 50, 50);
+CopieImageF(ii4, xiu2, 50, 50);
+CopieImageF(ii4, xii2, 50, 50);
+CopieImageF(ii4, xii4, 50, 50);
+CopieImageF(ii4, xir4, 50, 50);
+CopieImageF(ir4, xiu2, 50, 50);
+CopieImageF(ir4, xii2, 50, 50);
+CopieImageF(ir4, xii4, 50, 50);
+CopieImageF(ir4, xir4, 50, 50);
+
+CopieImage(iu2, xiu2);
+CopieImage(iu2, xii2);
+CopieImage(iu2, xii4);
+CopieImage(iu2, xir4);
+CopieImage(ii2, xiu2);
+CopieImage(ii2, xii2);
+CopieImage(ii2, xii4);
+CopieImage(ii2, xir4);
+CopieImage(ii4, xiu2);
+CopieImage(ii4, xii2);
+CopieImage(ii4, xii4);
+CopieImage(ii4, xir4);
+CopieImage(ir4, xiu2);
+CopieImage(ir4, xii2);
+CopieImage(ir4, xii4);
+CopieImage(ir4, xir4);
+
+CopieImage(iu2, xiu2, 50, 50);
+CopieImage(iu2, xii2, 50, 50);
+CopieImage(iu2, xii4, 50, 50);
+CopieImage(iu2, xir4, 50, 50);
+CopieImage(ii2, xiu2, 50, 50);
+CopieImage(ii2, xii2, 50, 50);
+CopieImage(ii2, xii4, 50, 50);
+CopieImage(ii2, xir4, 50, 50);
+CopieImage(ii4, xiu2, 50, 50);
+CopieImage(ii4, xii2, 50, 50);
+CopieImage(ii4, xii4, 50, 50);
+CopieImage(ii4, xir4, 50, 50);
+CopieImage(ir4, xiu2, 50, 50);
+CopieImage(ir4, xii2, 50, 50);
+CopieImage(ir4, xii4, 50, 50);
+CopieImage(ir4, xir4, 50, 50);
+
+CopiePave(iu2, xiu2, (float)25., (float)25.);
+CopiePave(iu2, xii2, (float)25., (float)25.);
+CopiePave(iu2, xii4, (float)25., (float)25.);
+CopiePave(iu2, xir4, (float)25., (float)25.);
+CopiePave(ii2, xiu2, (float)25., (float)25.);
+CopiePave(ii2, xii2, (float)25., (float)25.);
+CopiePave(ii2, xii4, (float)25., (float)25.);
+CopiePave(ii2, xir4, (float)25., (float)25.);
+CopiePave(ii4, xiu2, (float)25., (float)25.);
+CopiePave(ii4, xii2, (float)25., (float)25.);
+CopiePave(ii4, xii4, (float)25.,(float) 25.);
+CopiePave(ii4, xir4, (float)25., (float)25.);
+CopiePave(ir4, xiu2, (float)25., (float)25.);
+CopiePave(ir4, xii2, (float)25., (float)25.);
+CopiePave(ir4, xii4, (float)25., (float)25.);
+CopiePave(ir4, xir4, (float)25., (float)25.);
+
+RzCopieImage(iu2, rzi, 50, 50);
+RzCopieImage(ii2, rzi, 50, 50);
+RzCopieImage(ii4, rzi, 50, 50);
+RzCopieImage(ir4, rzi, 50, 50);
+
+RzCopieImage(iu2, rzi);
+RzCopieImage(ii2, rzi);
+RzCopieImage(ii4, rzi);
+RzCopieImage(ir4, rzi);
+
+RzCopiePave(iu2, rzi, (float)25., (float)25.);
+RzCopiePave(ii2, rzi, (float)25., (float)25.);
+RzCopiePave(ii4, rzi, (float)25., (float)25.);
+RzCopiePave(ir4, rzi, (float)25., (float)25.);
+
+return;
+}
+
+#endif
+
+#ifdef __CXX_PRAGMA_TEMPLATES__
+#pragma define_template Image<uint_1>
+#pragma define_template Image<uint_2>
+#pragma define_template Image<int_2>
+#pragma define_template Image<int_4>
+#pragma define_template Image<r_4>
+
+// pour supprimer les message Warning: Unresolved:
+//                                     __ls__XR7ostreamRC10Image__TUc
+
+ostream& operator << (ostream& s, ImageU1 const& pim)
+{
+cout << "operator << (ostream, ImageU1) Not implemented ..." << endl;
+return(s);
+}
+
+// CopieImageF
+#pragma define_template CopieImageF < uint_1 , uint_1 >
+#pragma define_template CopieImageF < uint_1 , uint_2 >
+#pragma define_template CopieImageF < uint_1 , int_2 >
+#pragma define_template CopieImageF < uint_1 , int_4 >
+#pragma define_template CopieImageF < uint_1 , r_4 >
+
+#pragma define_template CopieImageF < uint_2 , uint_2 >
+#pragma define_template CopieImageF < uint_2 , int_2 >
+#pragma define_template CopieImageF < uint_2 , int_4 >
+#pragma define_template CopieImageF < uint_2 , r_4 >
+
+#pragma define_template CopieImageF < int_2 , uint_2 >
+#pragma define_template CopieImageF < int_2 , int_2 >
+#pragma define_template CopieImageF < int_2 , int_4 >
+#pragma define_template CopieImageF < int_2 , r_4 >
+
+#pragma define_template CopieImageF < int_4 , uint_2 >
+#pragma define_template CopieImageF < int_4 , int_2 >
+#pragma define_template CopieImageF < int_4 , int_4 >
+#pragma define_template CopieImageF < int_4 , r_4 >
+
+#pragma define_template CopieImageF < r_4 , uint_2 >
+#pragma define_template CopieImageF < r_4 , int_2 >
+#pragma define_template CopieImageF < r_4 , int_4 >
+#pragma define_template CopieImageF < r_4 , r_4 >
+
+// CopieImage
+#pragma define_template CopieImage < uint_2 , uint_2 >
+#pragma define_template CopieImage < uint_2 , int_2 >
+#pragma define_template CopieImage < uint_2 , int_4 >
+#pragma define_template CopieImage < uint_2 , r_4 >
+
+#pragma define_template CopieImage < int_2 , uint_2 >
+#pragma define_template CopieImage < int_2 , int_2 >
+#pragma define_template CopieImage < int_2 , int_4 >
+#pragma define_template CopieImage < int_2 , r_4 >
+
+#pragma define_template CopieImage < int_4 , uint_2 >
+#pragma define_template CopieImage < int_4 , int_2 >
+#pragma define_template CopieImage < int_4 , int_4 >
+#pragma define_template CopieImage < int_4 , r_4 >
+
+#pragma define_template CopieImage < r_4 , uint_2 >
+#pragma define_template CopieImage < r_4 , int_2 >
+#pragma define_template CopieImage < r_4 , int_4 >
+#pragma define_template CopieImage < r_4 , r_4 >
+
+// CopiePave
+#pragma define_template CopiePave < uint_2 , uint_2 >
+#pragma define_template CopiePave < uint_2 , int_2 >
+#pragma define_template CopiePave < uint_2 , int_4 >
+#pragma define_template CopiePave < uint_2 , r_4 >
+
+#pragma define_template CopiePave < int_2 , uint_2 >
+#pragma define_template CopiePave < int_2 , int_2 >
+#pragma define_template CopiePave < int_2 , int_4 >
+#pragma define_template CopiePave < int_2 , r_4 >
+
+#pragma define_template CopiePave < int_4 , uint_2 >
+#pragma define_template CopiePave < int_4 , int_2 >
+#pragma define_template CopiePave < int_4 , int_4 >
+#pragma define_template CopiePave < int_4 , r_4 >
+
+#pragma define_template CopiePave < r_4 , uint_2 >
+#pragma define_template CopiePave < r_4 , int_2 >
+#pragma define_template CopiePave < r_4 , int_4 >
+#pragma define_template CopiePave < r_4 , r_4 >
+
+//RzCopieImage
+#pragma define_template RzCopieImage < uint_2 >
+#pragma define_template RzCopieImage < int_2 >
+#pragma define_template RzCopieImage < int_4 >
+#pragma define_template RzCopieImage < r_4 >
+
+//RzCopiePave
+#pragma define_template RzCopiePave < uint_2 >
+#pragma define_template RzCopiePave < int_2 >
+#pragma define_template RzCopiePave < int_4 >
+#pragma define_template RzCopiePave < r_4 >
+
+
+#endif
+
+
+#if defined(__ANSI_TEMPLATES__) 
+template class Image<uint_1>;
+template class Image<uint_2>;
+template class Image<int_2>;
+template class Image<int_4>;
+template class Image<r_4>;
+
+#if !defined(__aCC__)     // HP - aCC a du mal avec les fonctions templates 
+
+template void CopieImageF<uint_2, uint_2>(Image<uint_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF<uint_2,  int_2>(Image<uint_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF<uint_2,  int_4>(Image<uint_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF<uint_2,    r_4>(Image<uint_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF< int_2, uint_2>(Image< int_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF< int_2,  int_2>(Image< int_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF< int_2,  int_4>(Image< int_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF< int_2,    r_4>(Image< int_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF< int_4, uint_2>(Image< int_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF< int_4,  int_2>(Image< int_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF< int_4,  int_4>(Image< int_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF< int_4,    r_4>(Image< int_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF<   r_4, uint_2>(Image<   r_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF<   r_4,  int_2>(Image<   r_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF<   r_4,  int_4>(Image<   r_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF<   r_4,    r_4>(Image<   r_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+
+template void CopieImage<uint_2, uint_2>(Image<uint_2>&, Image<uint_2> const&);
+template void CopieImage<uint_2,  int_2>(Image<uint_2>&, Image< int_2> const&);
+template void CopieImage<uint_2,  int_4>(Image<uint_2>&, Image< int_4> const&);
+template void CopieImage<uint_2,    r_4>(Image<uint_2>&, Image<   r_4> const&);
+template void CopieImage< int_2, uint_2>(Image< int_2>&, Image<uint_2> const&);
+template void CopieImage< int_2,  int_2>(Image< int_2>&, Image< int_2> const&);
+template void CopieImage< int_2,  int_4>(Image< int_2>&, Image< int_4> const&);
+template void CopieImage< int_2,    r_4>(Image< int_2>&, Image<   r_4> const&);
+template void CopieImage< int_4, uint_2>(Image< int_4>&, Image<uint_2> const&);
+template void CopieImage< int_4,  int_2>(Image< int_4>&, Image< int_2> const&);
+template void CopieImage< int_4,  int_4>(Image< int_4>&, Image< int_4> const&);
+template void CopieImage< int_4,    r_4>(Image< int_4>&, Image<   r_4> const&);
+template void CopieImage<   r_4, uint_2>(Image<   r_4>&, Image<uint_2> const&);
+template void CopieImage<   r_4,  int_2>(Image<   r_4>&, Image< int_2> const&);
+template void CopieImage<   r_4,  int_4>(Image<   r_4>&, Image< int_4> const&);
+template void CopieImage<   r_4,    r_4>(Image<   r_4>&, Image<   r_4> const&);
+
+template void CopieImage<uint_2, uint_2>(Image<uint_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage<uint_2,  int_2>(Image<uint_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage<uint_2,  int_4>(Image<uint_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage<uint_2,    r_4>(Image<uint_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage< int_2, uint_2>(Image< int_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage< int_2,  int_2>(Image< int_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage< int_2,  int_4>(Image< int_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage< int_2,    r_4>(Image< int_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage< int_4, uint_2>(Image< int_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage< int_4,  int_2>(Image< int_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage< int_4,  int_4>(Image< int_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage< int_4,    r_4>(Image< int_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage<   r_4, uint_2>(Image<   r_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage<   r_4,  int_2>(Image<   r_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage<   r_4,  int_4>(Image<   r_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage<   r_4,    r_4>(Image<   r_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+
+template void CopiePave<uint_2, uint_2>(Image<uint_2>&, Image<uint_2> const&, float, float, double, double);
+template void CopiePave<uint_2,  int_2>(Image<uint_2>&, Image< int_2> const&, float, float, double, double);
+template void CopiePave<uint_2,  int_4>(Image<uint_2>&, Image< int_4> const&, float, float, double, double);
+template void CopiePave<uint_2,    r_4>(Image<uint_2>&, Image<   r_4> const&, float, float, double, double);
+template void CopiePave< int_2, uint_2>(Image< int_2>&, Image<uint_2> const&, float, float, double, double);
+template void CopiePave< int_2,  int_2>(Image< int_2>&, Image< int_2> const&, float, float, double, double);
+template void CopiePave< int_2,  int_4>(Image< int_2>&, Image< int_4> const&, float, float, double, double);
+template void CopiePave< int_2,    r_4>(Image< int_2>&, Image<   r_4> const&, float, float, double, double);
+template void CopiePave< int_4, uint_2>(Image< int_4>&, Image<uint_2> const&, float, float, double, double);
+template void CopiePave< int_4,  int_2>(Image< int_4>&, Image< int_2> const&, float, float, double, double);
+template void CopiePave< int_4,  int_4>(Image< int_4>&, Image< int_4> const&, float, float, double, double);
+template void CopiePave< int_4,    r_4>(Image< int_4>&, Image<   r_4> const&, float, float, double, double);
+template void CopiePave<   r_4, uint_2>(Image<   r_4>&, Image<uint_2> const&, float, float, double, double);
+template void CopiePave<   r_4,  int_2>(Image<   r_4>&, Image< int_2> const&, float, float, double, double);
+template void CopiePave<   r_4,  int_4>(Image<   r_4>&, Image< int_4> const&, float, float, double, double);
+template void CopiePave<   r_4,    r_4>(Image<   r_4>&, Image<   r_4> const&, float, float, double, double);
+
+
+template void RzCopieImage<uint_2>(Image<uint_2> &, RzImage const &, int, int, int, int, int, int, double, double);
+template void RzCopieImage< int_2>(Image< int_2> &, RzImage const &, int, int, int, int, int, int, double, double);
+template void RzCopieImage< int_4>(Image< int_4> &, RzImage const &, int, int, int, int, int, int, double, double);
+template void RzCopieImage<   r_4>(Image<   r_4> &, RzImage const &, int, int, int, int, int, int, double, double);
+
+template void RzCopieImage<uint_2>(Image<uint_2> &, RzImage const &);
+template void RzCopieImage< int_2>(Image< int_2> &, RzImage const &);
+template void RzCopieImage< int_4>(Image< int_4> &, RzImage const &);
+template void RzCopieImage<   r_4>(Image<   r_4> &, RzImage const &);
+
+template void RzCopiePave<uint_2>(Image<uint_2> &, RzImage const &, float, float, double, double);
+template void RzCopiePave< int_2>(Image< int_2> &, RzImage const &, float, float, double, double);
+template void RzCopiePave< int_4>(Image< int_4> &, RzImage const &, float, float, double, double);
+template void RzCopiePave<   r_4>(Image<   r_4> &, RzImage const &, float, float, double, double);
+
+#endif   // Pb avec HP aCC
+
+#endif
+
+
+#ifdef __GNU_TEMPLATES__
+template class Image<bool>;
+template class Image<uint_1>;
+template class Image<uint_2>;
+template class Image<int_2>;
+template class Image<int_4>;
+template class Image<r_4>;
+
+
+template void CopieImageF(Image<uint_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image<uint_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image<uint_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image<uint_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image< int_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image< int_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image< int_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image< int_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image< int_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image< int_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image< int_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image< int_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image<   r_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image<   r_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image<   r_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImageF(Image<   r_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+
+template void CopieImage(Image<uint_2>&, Image<uint_2> const&);
+template void CopieImage(Image<uint_2>&, Image< int_2> const&);
+template void CopieImage(Image<uint_2>&, Image< int_4> const&);
+template void CopieImage(Image<uint_2>&, Image<   r_4> const&);
+template void CopieImage(Image< int_2>&, Image<uint_2> const&);
+template void CopieImage(Image< int_2>&, Image< int_2> const&);
+template void CopieImage(Image< int_2>&, Image< int_4> const&);
+template void CopieImage(Image< int_2>&, Image<   r_4> const&);
+template void CopieImage(Image< int_4>&, Image<uint_2> const&);
+template void CopieImage(Image< int_4>&, Image< int_2> const&);
+template void CopieImage(Image< int_4>&, Image< int_4> const&);
+template void CopieImage(Image< int_4>&, Image<   r_4> const&);
+template void CopieImage(Image<   r_4>&, Image<uint_2> const&);
+template void CopieImage(Image<   r_4>&, Image< int_2> const&);
+template void CopieImage(Image<   r_4>&, Image< int_4> const&);
+template void CopieImage(Image<   r_4>&, Image<   r_4> const&);
+
+template void CopieImage(Image<uint_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image<uint_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image<uint_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image<uint_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image< int_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image< int_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image< int_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image< int_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image< int_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image< int_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image< int_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image< int_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image<   r_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image<   r_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image<   r_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double);
+template void CopieImage(Image<   r_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double);
+
+template void CopiePave(Image<uint_2>&, Image<uint_2> const&, float, float, double, double);
+template void CopiePave(Image<uint_2>&, Image< int_2> const&, float, float, double, double);
+template void CopiePave(Image<uint_2>&, Image< int_4> const&, float, float, double, double);
+template void CopiePave(Image<uint_2>&, Image<   r_4> const&, float, float, double, double);
+template void CopiePave(Image< int_2>&, Image<uint_2> const&, float, float, double, double);
+template void CopiePave(Image< int_2>&, Image< int_2> const&, float, float, double, double);
+template void CopiePave(Image< int_2>&, Image< int_4> const&, float, float, double, double);
+template void CopiePave(Image< int_2>&, Image<   r_4> const&, float, float, double, double);
+template void CopiePave(Image< int_4>&, Image<uint_2> const&, float, float, double, double);
+template void CopiePave(Image< int_4>&, Image< int_2> const&, float, float, double, double);
+template void CopiePave(Image< int_4>&, Image< int_4> const&, float, float, double, double);
+template void CopiePave(Image< int_4>&, Image<   r_4> const&, float, float, double, double);
+template void CopiePave(Image<   r_4>&, Image<uint_2> const&, float, float, double, double);
+template void CopiePave(Image<   r_4>&, Image< int_2> const&, float, float, double, double);
+template void CopiePave(Image<   r_4>&, Image< int_4> const&, float, float, double, double);
+template void CopiePave(Image<   r_4>&, Image<   r_4> const&, float, float, double, double);
+
+
+template void RzCopieImage(Image<uint_2> &, RzImage const &, int, int, int, int, int, int, double, double);
+template void RzCopieImage(Image< int_2> &, RzImage const &, int, int, int, int, int, int, double, double);
+template void RzCopieImage(Image< int_4> &, RzImage const &, int, int, int, int, int, int, double, double);
+template void RzCopieImage(Image<   r_4> &, RzImage const &, int, int, int, int, int, int, double, double);
+
+template void RzCopieImage(Image<uint_2> &, RzImage const &);
+template void RzCopieImage(Image< int_2> &, RzImage const &);
+template void RzCopieImage(Image< int_4> &, RzImage const &);
+template void RzCopieImage(Image<   r_4> &, RzImage const &);
+
+template void RzCopiePave(Image<uint_2> &, RzImage const &, float, float, double, double);
+template void RzCopiePave(Image< int_2> &, RzImage const &, float, float, double, double);
+template void RzCopiePave(Image< int_4> &, RzImage const &, float, float, double, double);
+template void RzCopiePave(Image<   r_4> &, RzImage const &, float, float, double, double);
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/NTools/cimage.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/cimage.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/cimage.h	(revision 1307)
@@ -0,0 +1,299 @@
+// This may look like C code, but it is really -*- C++ -*-
+//  Classes image typee      E.Aubourg , E. Lesquoy     
+//                           Modifs R. Ansari   04/95
+
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef CIMAGE_SEEN
+#define CIMAGE_SEEN
+
+#include <iostream.h>
+#include <iomanip.h>
+#include "rzimage.h"
+
+// Flags de verifications sur les indices  dans rzimage.h 
+
+//#define IMGRGCHECK
+//#define IMGVOIDCHECK
+
+
+// **********************************************************
+// Classe Image
+
+
+template <class T>
+class Image : public RzImage {
+
+public:
+  Image(int sizx, int sizy, int zero=1);
+  Image();
+  Image(const Image<T>&, int sharePixels=0);
+  Image(const Image<T>&, int orgx, int orgy, int sizx=-1, int sizy=-1);
+  EXPLICIT Image(const RzImage&); // Pour Reza. Partage les pixels
+  Image(char *flnm);
+  virtual ~Image();
+
+  int_4                 ClassId() const       { return (ClassId_Image+DataType((T)0)); }
+  static PPersist*      Create()              { return new Image<T>;}
+
+  virtual void    ReadSelf(PInPersist&);
+
+  Image<T>&       operator= (const Image<T> &);
+  Image<T>&       operator= (T);
+
+  Image<T>&       operator+= (Image<T> const&);
+  Image<T>&       operator-= (Image<T> const&);
+  Image<T>&       operator*= (Image<T> const&);
+  Image<T>&       operator/= (Image<T> const&);
+
+  Image<T>&       operator+= (double);
+  Image<T>&       operator-= (double);
+  Image<T>&       operator*= (double);
+  Image<T>&       operator/= (double);
+
+  Image<T>        WhereNonZero();
+
+
+//   Impression de tout le contenu de l'image 
+  virtual void    PrintImage(ostream& os) const;
+  inline void     PrintImage() const  { PrintImage(cout); }
+
+  void            Zero();
+  void            Allocate(int sizx, int sizy, int zero=1, ImgVectP* pvpsh=NULL);
+
+  inline T&       operator() (int x, int y);
+  inline T        operator() (int x, int y) const;
+  inline T&       operator[] (int i);
+  inline T        operator[] (int i) const;
+  T*              ImagePtr()         {return imagePtr;}
+  const T*        ImagePtr() const   {return imagePtr;}
+                                            
+  int             CheckDyn(double min=-9.e19, double max=9.e19);
+
+  void            SeuilBas(double seuil, double val);
+  void            SeuilHaut(double seuil, double val);
+  void            SeuilBas(double seuil);
+  void            SeuilHaut(double seuil);
+  void            SetPixels(int szx, int szy, T* pim);
+
+  int EstimeFdSg(float& xbmax,float& sgbmax,float nbsig=3.5,float frac=0.33
+                ,float lowbad=1.,float highbad=-1.,int deb=0);
+  float FondCiel(int nbin,float bin_low,float bin_high
+                ,int degre=2,float frac=0.5f,int modu=1,int deb=0);
+  float SigmaCiel(int nbin,float bin_low,float bin_high,float& means
+                 ,float lowbad=1.,float highbad=-1.
+                 ,float nsig=4.f,int modu=1,int deb=0);
+  int   MoySigma(float& mean,float& sigma
+                ,float lowbad=1.,float highbad=-1.,int modu=1);
+  int   MoySigmaIter(float& mean,float& sigma,float lowbad=1.,float highbad=-1.
+                    ,int modu=1,int nitermx=10
+                    ,float perdiff=0.1f,float scut=3.5f, int deb=0);
+  int   FondSigmaCiel(float lowbad,float highbad,int pvsz=100
+              ,float nbsig1=3.5f,float nbsig2=7.f,float nbsig3=5.f
+              ,float binsg=0.5f,float frac=0.33f,int modu=1,int deb=0);
+
+
+protected:
+
+  void HBinInt(int& nbin,float& xmin,float& xmax);
+
+  T*              imagePtr;
+};
+
+// Definition de l'operateur << 
+//template <class T> 
+//ostream& operator << (ostream& s, Image<T> const& img)
+//  {  img.Print(s);  return(s);  }
+
+
+/*  .......................................................  */
+/*          Implementation inline des acces pixels           */
+/*  .......................................................  */
+
+// ----- Macro de verification des indices  ------ 
+
+#ifdef IMGRGCHECK
+#define CHECKIMG(_x_,_y_)                                  \
+      if ((_x_ >= siz_x) || (_y_ >= siz_y) ||              \
+          (_x_ < 0) || (_y_ < 0)) THROW(rangeCheckErr);  \
+      if (!imagePtr) THROW(nullPtrErr)
+#else
+#if defined(IMGVOIDCHECK)
+#define CHECKIMG(_x_,_y_) \
+      if (!imagePtr) THROW(NullPtrErr)
+#else
+#define CHECKIMG(_x_,_y_)
+#endif
+#endif /* IMGRGCHECK */
+
+#define INRANGE(_x_,_y_) ((_x_ < siz_x) && (_y_ < siz_y) && \
+                          (_x_ >= 0) && (_y_ >= 0))
+
+
+// Fin des macros  ------ 
+
+
+template <class T>
+inline T & Image<T>::operator() (int x, int y)
+{
+  CHECKIMG(x,y);
+  return imagePtr[x+y*siz_x];
+}
+
+template <class T>
+inline T Image<T>::operator() (int x, int y) const
+{
+  CHECKIMG(x,y);
+  return imagePtr[x+y*siz_x];
+}
+
+template <class T>
+inline T & Image<T>::operator[] (int i)
+{
+  CHECKIMG(0,0);
+  return imagePtr[i];
+}
+
+template <class T>
+inline T Image<T>::operator[] (int i) const
+{
+  CHECKIMG(0,0);
+  return imagePtr[i];
+}
+
+// Operateurs addition, multiplication, ... (+ - * / ) avec des doubles 
+
+template <class T> 
+Image<T> operator+ (Image<T> const& a, double b) 
+{
+  Image<T> c(a);
+  c += b;
+  return c;
+}
+
+template <class T> 
+Image<T> operator- (Image<T> const& a, double b) 
+{
+  Image<T> c(a);
+  c -= b;
+  return c;
+}
+
+template <class T> 
+Image<T> operator* (Image<T> const& a, double b) 
+{
+  Image<T> c(a);
+  c *= b;
+  return c;
+}
+
+template <class T> 
+Image<T> operator/ (Image<T> const& a, double b) 
+{
+  Image<T> c(a);
+  c /= b;
+  return c;
+}
+
+// Operateurs addition, multiplication, ... (+ - * / ) entre images
+template <class T> 
+Image<T> operator+ (Image<T> const& a, Image<T> const& b)
+{
+  Image<T> c(a);
+  c += b;
+  return c;
+}
+
+template <class T> 
+Image<T> operator- (Image<T> const& a, Image<T> const& b) 
+{
+  Image<T> c(a);
+  c -= b;
+  return c;
+}
+
+template <class T> 
+Image<T> operator* (Image<T> const& a, Image<T> const& b) 
+{
+  Image<T> c(a);
+  c *= b;
+  return c;
+}
+
+template <class T> 
+Image<T> operator/ (Image<T> const& a, Image<T> const& b) 
+{
+  Image<T> c(a);
+  c /= b;
+  return c;
+}
+
+/*  .......................................................  */
+/*         Fonctions de copie d'images et de paves           */
+/*  .......................................................  */
+
+template <class T2, class T1>
+void CopieImageF(Image<T2>& copie, Image<T1> const& pim,
+                 int org_pim_x=0, int org_pim_y=0,
+                 int pim_lpav_x=0, int pim_lpav_y=0,
+                 int org_copie_x=0, int org_copie_y=0,
+                 double cutmin=0., double cutmax=0.);
+                
+template <class T2, class T1>
+void CopieImage(Image<T2>& copie, Image<T1> const& pim);
+
+template <class T2, class T1>
+void CopieImage(Image<T2>& copie, Image<T1> const& pim,
+                int org_pim_x, int org_pim_y,
+                int pim_lpav_x=0, int pim_lpav_y=0,
+                int org_copie_x=0, int org_copie_y=0,
+                double cutmin=0, double cutmax=0);
+
+
+template <class T2, class T1>
+void 
+CopiePave(Image<T2>& pave, Image<T1> const& pim,
+	  float xc, float yc, 
+	  double cutmin=0, double cutmax=0);
+
+
+template <class T>
+void 
+RzCopieImage(Image<T>& copie, RzImage const& pim,
+	     int org_pim_x, int org_pim_y,
+	     int pim_lpav_x=0, int pim_lpav_y=0,
+	     int org_copie_x=0, int org_copie_y=0,
+	     double cutmin=0, double cutmax=0);
+
+template <class T>
+void 
+RzCopieImage(Image<T>& copie, RzImage const& pim);
+
+template <class T>
+void 
+RzCopiePave(Image<T> & pave, RzImage const & pim,
+	    float xc, float yc,
+	    double cutmin=0, double cutmax=0);
+/*  .......................................................  */
+/*         Autres fonctions utilitaires pour RzImage         */
+/*  .......................................................  */
+
+void RzPrintImage(RzImage & img);
+
+/*  Images de types usuels   */
+
+typedef Image<uint_1> ImageU1;
+typedef Image<uint_2> ImageU2;
+typedef Image<int_2>  ImageI2;
+typedef Image<int_4>  ImageI4;
+typedef Image<r_4>    ImageR4;
+
+
+#ifdef __MWERKS__
+template <class T>
+ostream& operator << (ostream& s, Image<T> const& pim);
+#endif
+
+#endif
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/cspline.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/cspline.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/cspline.cc	(revision 1307)
@@ -0,0 +1,478 @@
+#include "defs.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "nbtri.h"
+#include "cspline.h"
+
+//++
+// Class	CSpline
+// Lib	Outils++ 
+// include	cspline.h
+//
+//	Classe de spline 1D
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+CSpline::CSpline(int n,double* x,double* y,double yp1,double ypn
+                ,int natural,bool order)
+//
+//	Createur pour spline 3 sur "x[0->n],y[0->n]" avec "yp1,ypn" derivees
+//	au premier et dernier points et "natural" indiquant les types de
+//	contraintes sur les derivees 2sd au premier et dernier point.
+//	"order" doit etre mis a "true" si le tableau de "x[]" n'est pas ordonne
+//	dans l'ordre des "x" croissants ("x[i]<x[i+1]"): cette option
+//	realloue la place pour les tableaux "x,y" autrement seule une
+//	connection aux tableaux "x,y" externes est realisee.
+//--
+  : Nel(0), corrupt_Y2(true), XY_Created(false), Natural(natural)
+  , YP1(yp1), YPn(ypn), X(NULL), Y(NULL), Y2(NULL), tmp(NULL)
+{
+SetNewTab(n,x,y,order,true);
+if( x != NULL && y != NULL) ComputeCSpline();
+
+END_CONSTRUCTOR
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+CSpline::CSpline(double yp1,double ypn,int natural)
+//
+//	Createur par defaut.
+//--
+  : Nel(0), corrupt_Y2(true), XY_Created(false), Natural(natural)
+  , YP1(yp1), YPn(ypn), X(NULL), Y(NULL), Y2(NULL), tmp(NULL)
+{
+END_CONSTRUCTOR
+}
+
+//////////////////////////////////////////////////////////////////////////////
+CSpline::~CSpline()
+// destructeur
+{
+DelTab();
+}
+
+//++
+// Titre	Methodes
+//--
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+void CSpline::SetNewTab(int n,double* x,double* y,bool order,bool force)
+//
+//	Pour changer les tableaux sans recreer la classe,
+//	memes arguments que dans le createur.
+//	Pour connecter les tableaux "x[n],y[n]" aux pointeurs internes "X,Y"
+//	Si "order=true", on considere que x n'est pas range par ordre
+//	des "x" croissants. La methode alloue de la place pour des tableaux
+//	internes "X,Y" qu'elle re-ordonne par "x" croissant.
+//	"force=true" impose la reallocation des divers buffers, sinon
+//	la reallocation n'a lieu que si le nombre de points augmente.
+//--
+{
+ASSERT( n>3 );
+
+// allocation des buffers Y2 et tmp
+if( n>Nel || force ) {
+  if( Y2  != NULL ) delete [] Y2;
+  if( tmp != NULL ) delete [] tmp;
+  Y2   = new double[n];
+  tmp  = new double[n];
+}
+// des-allocation eventuelle de X,Y
+if( XY_Created ) {
+  if( !order || n>Nel || force ) {
+    if( X != NULL ) delete [] X;  X = NULL;
+    if( Y != NULL ) delete [] Y;  Y = NULL;
+    XY_Created = false;
+  }
+}
+// allocation eventuelle de X,Y
+if( order ) {
+  if( !XY_Created || n>Nel || force ) {
+    X = new double[n];
+    Y = new double[n];
+    XY_Created = true;
+  }
+}
+Nel = n;
+corrupt_Y2 = true;
+
+if( x==NULL || y==NULL ) return;
+
+// Classement eventuel par ordre des x croissants
+if( order ) {
+  if( tmp == NULL ) tmp = new double[n];
+  ind = (int_4 *) tmp;
+  tri_double(x,ind,(int_4) Nel);
+  for(int i=0;i<Nel;i++) {
+    X[i] = x[ind[i]];
+    Y[i] = y[ind[i]];
+    if( i>0 ) if( X[i-1]>= X[i] ) {
+      printf("CSpline::SetNewTab_Erreur: X[%d]>=X[%d] (%g>=%g)\n"
+            ,i-1,i,X[i-1],X[i]);
+      THROW(inconsistentErr);
+    }
+  }
+} else { X = x; Y = y; }
+
+}
+
+//////////////////////////////////////////////////////////////////////////////
+void CSpline::DelTab()
+// destruction des divers tableaux en tenant compte des allocations/connections
+{
+if( X   != NULL && XY_Created ) delete [] X;    X   = NULL;
+if( Y   != NULL && XY_Created ) delete [] Y;    Y   = NULL;
+if( Y2  != NULL ) delete [] Y2;   Y2  = NULL;
+if( tmp != NULL ) delete [] tmp;  tmp = NULL;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+void CSpline::SetBound1er(double yp1,double ypn)
+//
+//	Pour changer les valeurs des derivees 1ere au 1er et dernier points
+//	Valeurs imposees des derivees 1ere au points "X[0]" et "X[Nel-1]".
+//--
+{
+if( yp1 == YP1 && ypn == YPn ) return;
+
+YP1 = yp1;
+YPn = ypn;
+
+corrupt_Y2 = true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+void CSpline::ComputeCSpline()
+//
+//	Pour calculer les tableaux de coeff permettant le calcul
+//	des interpolations spline.
+//--
+{
+// on ne fait rien si les tableaux ne sont pas connectes
+if( X == NULL || Y == NULL ) {
+  printf("CSpline::ComputeCSpline()_Erreur: tableaux non connectes X=%p Y=%p\n"
+        ,X,Y);
+  return;
+}
+// On ne fait rien si rien n'a change!
+if( ! corrupt_Y2 ) return;
+// protection si tmp a ete desalloue pour gain de place (ex: CSpline2)
+if( tmp == NULL ) tmp = new double[Nel];
+
+double p,qn,sig,un;
+
+if (Natural & Natural1)
+  Y2[0] = tmp[0] = 0.0;
+else {
+  Y2[0] = -0.5;
+  tmp[0] = (3.0/(X[1]-X[0]))*((Y[1]-Y[0])/(X[1]-X[0])-YP1);
+}
+
+for (int i=1;i<Nel-1;i++) {
+  sig = (X[i]-X[i-1])/(X[i+1]-X[i-1]);
+  p = sig * Y2[i-1] + 2.0;
+  Y2[i] = (sig-1.0)/p;
+  tmp[i]= (Y[i+1]-Y[i])/(X[i+1]-X[i]) - (Y[i]-Y[i-1])/(X[i]-X[i-1]);
+  tmp[i]= (6.0*tmp[i]/(X[i+1]-X[i-1])-sig*tmp[i-1])/p;
+}
+
+if (Natural & NaturalN)
+   qn = un = 0.0;
+else {
+   qn = 0.5;
+   un = (3.0/(X[Nel-1]-X[Nel-2]))
+       *(YPn-(Y[Nel-1]-Y[Nel-2])/(X[Nel-1]-X[Nel-2]));
+}
+Y2[Nel-1] = (un-qn*tmp[Nel-2])/(qn*Y2[Nel-2]+1.0);
+for (int k=Nel-2;k>=0;k--) Y2[k] = Y2[k]*Y2[k+1] + tmp[k];
+
+corrupt_Y2 = false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+double CSpline::CSplineInt(double x)
+//
+//	Interpolation spline en "x"
+//--
+{
+int klo,khi,k;
+double h,b,a,y = 0.;
+
+if( corrupt_Y2 ) {
+  cout<<"CSpline::CSplineInt: calcul des coef du spline corrupted"<<endl;
+  THROW(inconsistentErr);
+}
+
+klo = 0;
+khi = Nel-1;
+while (khi-klo > 1) {
+  k = (khi+klo) >> 1;
+  if (X[k] > x) khi=k;
+    else klo=k;
+}
+h=X[khi]-X[klo];
+
+if (h == 0.0) {
+  cout<<"CSpline::CSplineInt: pout khi="<<khi<<" klo="<<klo
+      <<" memes valeurs de X[]: "<<X[khi]<<endl;
+  THROW(inconsistentErr);
+}
+
+a = (X[khi]-x)/h;
+b = (x-X[klo])/h;
+y = a*Y[klo]+b*Y[khi]+((a*a*a-a)*Y2[klo]+(b*b*b-b)*Y2[khi])*(h*h)/6.0;
+
+return y;
+}
+
+///////////////////////////////////////////////////////////////
+///////// rappel des inlines pour commentaires ////////////////
+///////////////////////////////////////////////////////////////
+
+//++
+// inline void SetNaturalCSpline(int type = NaturalAll)
+//	Pour changer le type de contraintes sur les derivees 2sd
+//--
+//++
+// inline void Free_Tmp()
+//	Pour liberer la place tampon qui ne sert que
+//	dans ComputeCSpline() et pas dans CSplineInt
+//--
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+//++
+// Class	CSpline2
+// Lib	Outils++ 
+// include	cspline.h
+//
+//	Classe de spline 2D
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+CSpline2::CSpline2(int n1,double* x1,int n2,double* x2,double* y
+                  ,int natural,bool order)
+//
+//	Meme commentaire que pour CSpline avec:
+//| x1[n1]: liste des coordonnees selon l axe 1
+//| x2[n2]: liste des coordonnees selon l axe 2
+//| y[n1*n2]: liste des valeurs avec le rangement suivant
+//| x1[0]......x1[n1-1]  x1[0]......x1[n1-1]  ... x1[0]......x1[n1-1]
+//| |    0<=i<n1      |  |    0<=i<n1      |  ... |    0<=i<n1      |
+//|      j=0 X2[0]            j=1 X2[1]              j=n2-1 X2[n2-1]
+//--
+  : Nel1(0), Nel2(0), corrupt_Y2(true), XY_Created(false), Natural(natural)
+  , X1(NULL), X2(NULL), Y(NULL), Y2(NULL)
+  , Nel_S(0), S(NULL), Sint(NULL), tmp(NULL)
+{
+SetNewTab(n1,x1,n2,x2,y,order,true);
+if( x1 != NULL && x2 != NULL && y != NULL) ComputeCSpline();
+
+END_CONSTRUCTOR
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+CSpline2::CSpline2(int natural)
+//
+//	Createur par defaut.
+//--
+  : Nel1(0), Nel2(0), corrupt_Y2(true), XY_Created(false), Natural(natural)
+  , X1(NULL), X2(NULL), Y(NULL), Y2(NULL)
+  , Nel_S(0), S(NULL), Sint(NULL), tmp(NULL)
+{
+END_CONSTRUCTOR
+}
+
+//////////////////////////////////////////////////////////////////////////////
+CSpline2::~CSpline2()
+{
+DelTab();
+}
+
+//++
+// Titre	Methodes
+//--
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+void CSpline2::SetNewTab(int n1,double* x1,int n2,double* x2,double* y
+                        ,bool order,bool force)
+//
+//	Voir commentaire meme methode de CSpline
+//--
+{
+ASSERT( n1>3 && n2>3 );
+
+int n = ( n1 < n2 ) ? n2 : n1;
+
+// allocation des buffers Y2 et tmp et des CSpline 1D
+if( n1>Nel1 || n2>Nel2 || force ) {
+  if( Y2  != NULL ) delete [] Y2;
+  if( tmp != NULL ) delete [] tmp;
+  Y2   = new double[n1*n2];
+  tmp  = new double[n];
+
+  // et les CSpline[n1] pour memoriser les interpolations sur x1(0->n1)
+  if( S != NULL ) {
+    for(int i=0;i<Nel_S;i++) if(S[i] != NULL) { delete S[i]; S[i]=NULL;}
+    delete S; S = NULL;
+  }
+  S = new CSpline * [n2];
+  for(int j=0;j<n2;j++) {
+    S[j] = new CSpline(n1,NULL,NULL,0.,0.,Natural);
+    S[j]->Free_Tmp();
+  }
+  Nel_S = n2;
+
+  if( S != NULL ) { delete Sint; Sint = NULL;}
+  Sint = new CSpline(n2,NULL,NULL,0.,0.,Natural);
+
+}
+// des-allocation eventuelle de X1,X2,Y
+if( XY_Created ) {
+  if( !order || n1>Nel1 || n2>Nel2 || force ) {
+    if( X1 != NULL ) delete [] X1; X1 = NULL;
+    if( X2 != NULL ) delete [] X2; X2 = NULL;
+    if( Y != NULL )  delete [] Y;  Y  = NULL;
+    XY_Created = false;
+  }
+}
+// allocation eventuelle de X1,X2,Y
+if( order ) {
+  if( !XY_Created || n1>Nel1 || n2>Nel1 || force ) {
+    X1 = new double[n1];
+    X2 = new double[n2];
+    Y  = new double[n1*n2];
+    XY_Created = true;
+  }
+}
+Nel1 = n1;  Nel2 = n2;
+corrupt_Y2 = true;
+
+if( x1==NULL || x2==NULL || y==NULL ) return;
+
+// Classement eventuel par ordre des x1 et x2 croissants
+if( order ) {
+
+  if( tmp == NULL ) tmp = new double[n];
+  ind = (int_4 *) tmp;
+  double* Ytmp = new double[n1*n2];
+
+  // tri par valeur croissantes de x1
+  tri_double(x1,ind,(int_4) Nel1);
+  for(int i=0;i<Nel1;i++) {
+    X1[i] = x1[ind[i]];
+    if( i>0 ) if( X1[i-1] >= X1[i] )
+      { printf("CSpline::SetNewTab_Erreur: X1[%d]>=X1[%d] (%g>=%g)\n"
+              ,i-1,i,X1[i-1],X1[i]);
+        THROW(inconsistentErr); }
+    for(int j=0;j<Nel2;j++) Ytmp[j*Nel1+i]  = y[j*Nel1+ind[i]];
+  }
+
+  // tri par valeur croissantes de x2
+  tri_double(x2,ind,(int_4) Nel2);
+  for(int j=0;j<Nel2;j++) {
+    X2[j] = x2[ind[j]];
+    if( j>0 ) if( X2[j-1] >= X2[j] )
+      { printf("CSpline::SetNewTab_Erreur: X2[%d]>=X2[%d] (%g>=%g)\n"
+              ,j-1,j,X2[j-1],X2[j]);
+        THROW(inconsistentErr); }
+    for(int i=0;i<Nel1;i++) Y[j*Nel1+i] = Ytmp[j*Nel1+ind[i]];
+  }
+  delete [] Ytmp;
+
+} else {
+
+  X1 = x1;
+  X2 = x2;
+  Y  = y;
+
+}
+
+}
+
+//////////////////////////////////////////////////////////////////////////////
+void CSpline2::DelTab()
+{
+if( X1  != NULL && XY_Created ) delete [] X1;  X1   = NULL;
+if( X2  != NULL && XY_Created ) delete [] X2;  X2   = NULL;
+if( Y   != NULL && XY_Created ) delete [] Y;   Y   = NULL;
+if( Y2  != NULL ) delete [] Y2;   Y2  = NULL;
+if( tmp != NULL ) delete [] tmp;  tmp = NULL;
+if( S != NULL ) {
+  for(int i=0;i<Nel_S;i++) if(S[i] != NULL) { delete S[i]; S[i]=NULL;}
+  delete S; S = NULL;
+}
+if( Sint != NULL ) { delete Sint; Sint=NULL;}
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+void CSpline2::ComputeCSpline()
+//
+//	Voir commentaire meme methode de CSpline
+//--
+{
+// on ne fait rien si X1 ou X2 ou Y non connectes
+if( X1 == NULL || X2 == NULL || Y == NULL ) return;
+// On ne fait rien si rien n'a change
+if( ! corrupt_Y2 ) return;
+
+for(int j=0; j<Nel2; j++) {
+  // on n'alloue pas de place nouvelle, on utilise CSpline2::tmp
+  S[j]->tmp = tmp;
+  // connection de X1,Y au spline 1D sans ordre demande
+  S[j]->SetNewTab(Nel1,X1,&Y[j*Nel1],false,false);
+  // calcul des coeff splien pour l'interpolation future
+  S[j]->ComputeCSpline();
+}
+
+corrupt_Y2 = false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//++
+double CSpline2::CSplineInt(double x1,double x2)
+//
+//	Voir commentaire meme methode de CSpline
+//--
+{
+// calcul de la valeur Y pour x=x1 et remplissage du tampon tmp
+for(int j=0;j<Nel2;j++) tmp[j] = S[j]->CSplineInt(x1);
+
+// connection X2,tmp pour interpolation selon x=x2
+Sint->SetNewTab(Nel2,X2,tmp,false,false);
+// calcul des coeff pour interpolation selon X2
+Sint->ComputeCSpline();
+// Interpolation finale
+return Sint->CSplineInt(x2);
+}
+
+///////////////////////////////////////////////////////////////
+///////// rappel des inlines pour commenatires ////////////////
+///////////////////////////////////////////////////////////////
+
+//++
+// inline void SetNaturalCSpline(int type = NaturalAll)
+//	Voir commentaire meme methode de CSpline
+//--
Index: /tags/DPC_V0/SophyaLib/NTools/cspline.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/cspline.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/cspline.h	(revision 1307)
@@ -0,0 +1,119 @@
+#ifndef CSPLINE_H_SEEN
+#define CSPLINE_H_SEEN
+
+#include "defs.h"
+#include "machine.h"
+#include "cvector.h"
+
+///////////////////////////////////////////////////////////////////
+// Class CSpline et CSpline2 selon Numerical Receipes (cmv 17/02/97)
+///////////////////////////////////////////////////////////////////
+class CSpline EXC_AWARE {
+
+public:
+
+  friend class CSpline2;
+
+  enum { NaturalAll = 3, NoNatural = 0, Natural1 = 1, NaturalN = 2 };
+
+  CSpline(int n,double* x,double* y,double yp1=0.,double ypn=0.
+         ,int natural=NaturalAll,bool order=true);
+
+  CSpline(double yp1=0.,double ypn=0.,int natural=NaturalAll);
+
+  virtual ~CSpline();
+
+  void SetNewTab(int n,double* x,double* y
+                ,bool order=true,bool force=false);
+
+  void SetBound1er(double yp1 = 0.,double yp2 = 0.);
+
+  inline void SetNaturalCSpline(int type = NaturalAll)
+                 { Natural = type;}
+
+  inline void Free_Tmp()
+                { if(tmp != NULL) delete [] tmp; tmp=NULL;}
+
+  void ComputeCSpline();
+
+  double CSplineInt(double x);
+
+protected:
+
+  void DelTab();
+
+  // nombre d elements dans les tableaux X et Y
+  int Nel;
+  // true si les tableaux ont ete changes
+  // et qu il faut recalculer ComputeCSpline()
+  bool corrupt_Y2;
+  // true si les tableaux X,Y ont ete alloues
+  bool XY_Created;
+  // type de contraintes sur la derivee 2sd
+  int Natural;
+  // valeurs imposees de la derivee 1ere aux limites
+  double YP1, YPn;
+
+  // tableaux rellement alloues si "order=true" ou seulement
+  // connectes aux tableaux externes si "order=false"
+  double* X;
+  double* Y;
+
+  // tableau des coeff permettant l interpolation,
+  // remplis par ComputeCSpline()
+  double* Y2;
+
+  // tableau tampon utilise dans ComputeCSpline()
+  double* tmp;
+  int_4*  ind;
+
+};
+
+
+///////////////////////////////////////////////////////////////////
+class CSpline2 EXC_AWARE {
+
+public:
+  CSpline2(int n1,double* x1,int n2,double* x2,double* y
+          ,int natural=CSpline::NaturalAll,bool order=true);
+
+  CSpline2(int natural=CSpline::NaturalAll);
+
+  virtual ~CSpline2();
+
+  void SetNewTab(int n1,double* x1,int n2,double* x2,double* y
+                ,bool order=true,bool force=false);
+
+  inline void SetNaturalCSpline(int type = CSpline::NaturalAll)
+                 { Natural = type;}
+
+  void ComputeCSpline();
+
+  double CSplineInt(double x1,double x2);
+
+protected:
+  void DelTab();
+
+  int Nel1, Nel2;
+  bool corrupt_Y2;
+  bool XY_Created;
+  int Natural;
+
+  double* X1;
+  double* X2;
+  double* Y;
+  double* Y2;
+
+  // nombre d elements alloues dans S
+  int Nel_S;
+  // tableau de CSpline pour interpolation selon X1
+  CSpline** S;       // S[0->n2]
+  CSpline*  Sint;
+
+  // tableau tampon utilise dans CSplineInt()
+  double* tmp;  // tmp[max(n1,n2)]
+  int_4*  ind;
+
+};
+
+#endif /* CSPLINE_H_SEEN */
Index: /tags/DPC_V0/SophyaLib/NTools/cvector.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/cvector.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/cvector.cc	(revision 1307)
@@ -0,0 +1,197 @@
+#include "defs.h"
+#include <string.h>
+#include "cvector.h"
+#include "generalfit.h"
+
+//++
+// Class	Vector
+// Lib	Outils++
+// include	cvector.h
+//
+//    Vecteur colonne, en fait une matrice avec une seule colonne, pour faire
+//    des opérations matricielles.      
+//--
+
+//++
+// Links	Parents
+// Matrix
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+Vector::Vector(int n)
+//
+//	Constructeur, n = nombre d'éléments.
+//--
+: Matrix(n, 1)
+{END_CONSTRUCTOR}
+
+
+//++
+Vector::Vector(int n, double* values)
+//
+//	Constructeur, à partir des valeurs. Pas d'allocation.
+//--
+: Matrix(n, 1, values)
+{END_CONSTRUCTOR}
+
+
+//++
+Vector::Vector(const Vector& v)
+//
+//	Constructeur par copie.
+//--
+: Matrix(v)
+{END_CONSTRUCTOR}
+
+
+//++
+Vector::Vector(const Matrix& a)
+//
+//	Constructeur par "copie" à partir d'une matrice, qui doit avoir une seule colonne.
+//
+//	*Exceptions :*
+//	sizeMismatchErr    si la matrice a plus d'une colonne
+//--
+: Matrix(a.nr,1)      // Matrix(a) ne marche pas, pourquoi ???? bug gcc ???
+{
+  if (a.nc != 1) THROW(sizeMismatchErr);
+  memcpy(data, a.data, a.nr * sizeof(double));
+  END_CONSTRUCTOR
+}
+
+//++
+// Titre	Opérateurs
+//--
+
+//++
+// double& operator()(int n)
+// double const& operator()(int n) const
+//	Accès aux éléments.
+//--
+
+
+//++
+Vector& Vector::operator = (double x)
+//
+//	Affectation à partir d'un scalaire. Tous les éléments prennent cette valeur.
+//--
+{
+  for (int i=0; i<nr; i++)
+    (*this)(i) = x ;
+  return *this;
+}
+
+//++
+double operator* (const Vector& v1, const Vector& v2)
+//
+//	Produit scalaire entre deux vecteurs.
+//--
+{
+  if (v1.nr != v2.nr) THROW(sizeMismatchErr);
+  double *p    = v1.data;
+  double *pEnd = v1.data + v1.ndata;
+  double *q    = v2.data;
+
+  double r = 0;
+
+  while (p<pEnd)
+    r += *p++ * *q++;
+
+  return r;
+}
+
+//++
+// Vector operator* (const Vector& v, double b)
+//	multiplication par un scalaire.
+//--
+
+//++
+// Vector operator* (const Matrix& a, const Vector& b)
+//	produit matrice*vecteur.
+//--
+
+//++
+// Titres	Méthodes
+//--
+
+//++
+// int NElts() const
+//
+//	Nombre de lignes du vecteur.
+//--
+
+//++
+// void Realloc(int n, bool force=false)
+//
+//	Change la taille du vecteur. Réallocation physique seulement si
+//	pas assez de place, ou forcée si force=true.
+//--
+
+//++
+double LinSolveInPlace(Matrix& a, Vector& b)
+//
+//	Résolution du système A*C = B
+//--
+{
+  if (a.NCol() != b.NRows()) THROW(sizeMismatchErr);
+  if (a.NCol() != a.NRows()) THROW(sizeMismatchErr);
+
+  return Matrix::GausPiv(a,b);
+}
+
+
+//++
+double LinSolve(const Matrix& a, const Vector& b, Vector& c)
+//
+//	Résolution du système A*C = B, avec C retourné dans B
+//--
+{ 
+  if (a.NCol() != b.NRows()) THROW(sizeMismatchErr);
+  if (a.NCol() != a.NRows()) THROW(sizeMismatchErr);
+  c = b;
+  Matrix a1(a);
+  return Matrix::GausPiv(a1,c);
+}
+
+//////////////////////////////////////////////////////////
+//++
+Vector* Vector::FitResidus(GeneralFit& gfit)
+//
+//	Retourne une classe contenant les residus du fit ``gfit''.
+//	On suppose que x=i.
+//--
+{
+if(NElts()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+Vector* v = new Vector(*this);
+for(int i=0;i<NElts();i++) {
+  double x = (double)i;
+  (*v)(i) -= f->Value(&x,par.Data());
+}
+return v;
+}
+
+//++
+Vector* Vector::FitFunction(GeneralFit& gfit)
+//
+//	Retourne une classe contenant la fonction du fit ``gfit''.
+//	On suppose que x=i.
+//--
+{
+if(NElts()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+Vector* v = new Vector(*this);
+for(int i=0;i<NElts();i++) {
+  double x = (double)i;
+  (*v)(i) = f->Value(&x,par.Data());
+}
+return v;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/cvector.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/cvector.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/cvector.h	(revision 1307)
@@ -0,0 +1,98 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+#ifndef VECTOR_SEEN
+#define VECTOR_SEEN
+#include "matrix.h"
+
+class GeneralFit;
+
+// <summary> Vecteur colonne pour operations matricielles </summary>
+// Vecteur colonne, en fait une matrice avec une seule colonne, pour faire
+// des operations matricielles.
+class Vector : public Matrix {
+public:
+  // Constructeur, n = nombre d'elements.
+  EXPLICIT Vector(int n=1);
+  // Constructeur, a partir des valeurs. Pas d'allocation.
+  Vector(int n, double* values);
+  // Constructeur par copie
+  Vector(const Vector& v);
+  // Constructeur par "copie" a partir d'une matrice, qui doit avoir une colonne
+  // <thrown> sizeMismatchErr </thrown>
+  Vector(const Matrix& a);
+
+  // Construction automatique pour PPF
+  // <group>
+  enum {classId = ClassId_Vector};
+  int_4                 ClassId() const         { return classId; }
+  static PPersist*      Create() {return new Vector(1);}
+  // </group>
+  
+  // Change la taille du vecteur. Reallocation physique seulement si
+  // pas assez de place, ou forcee si force=true
+  void Realloc(int n, bool force=false);
+
+  Vector& operator = (const Vector& v);
+  Vector& operator = (double x);
+
+  // Acces aux elements
+  // <group>
+  double& operator()(int n);
+  double const& operator()(int n) const;
+  // </group>
+
+  // produit scalaire
+  // <group>
+  friend double operator* (const Vector& v1, const Vector& v2);
+  friend Vector operator* (const Vector& v, double b)
+  {return Vector(((Matrix const&)v) * b);}
+  // </group>
+  // produit matrice*vecteur
+  friend Vector operator* (const Matrix& a, const Vector& b)
+  {return Vector(a * ((Matrix const&) (b)));}
+
+  // Nombre de lignes du vecteur
+  int NElts() const {return nr;}
+
+  // Resolution du systeme A*C = B
+  friend double LinSolve(const Matrix& a, const Vector& b, Vector& c);
+  
+  // Resolution du systeme A*C = B, avec C retourne dans B
+  friend double LinSolveInPlace(Matrix& a, Vector& b);
+
+  // Residus et fonction fittees.
+  Vector* FitResidus(GeneralFit& gfit);
+  Vector* FitFunction(GeneralFit& gfit);
+
+};
+
+
+inline Vector& Vector::operator = (const Vector& v)
+{ Matrix::operator =(v); return *this; }
+
+
+inline double const& Vector::operator()(int n) const
+{
+#ifdef RGCHECK
+  if (n<0 || n>=ndata) THROW(rangeCheckErr);
+#endif
+  return data[n];
+}
+
+
+inline double& Vector::operator()(int n)
+{ 
+#ifdef RGCHECK
+  if (n<0 || n>=ndata) THROW(rangeCheckErr);
+#endif
+  return data[n];
+}
+
+inline void Vector::Realloc(int n, bool force)
+{ Matrix::Realloc(n,1,force);}
+
+
+#endif /* VECTOR_SEEN */
+
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/datacards.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/datacards.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/datacards.cc	(revision 1307)
@@ -0,0 +1,311 @@
+// $Id: datacards.cc,v 1.1.1.1 1999-04-09 17:57:55 ansari Exp $
+//
+// Datacards, acquisition EROS II
+//
+//
+// Eric Aubourg, Decembre 95
+//
+// DAPNIA/SPP (Saclay) / CEA
+
+#include "defs.h"
+#include "datacards.h"
+#include <algorithm>
+#include <iostream.h>
+#include <iomanip.h>
+#include <stdio.h>
+
+//++
+// Class	DataCards
+// Lib		Outils++ 
+// include	datacards.h
+//
+//   	Cette classe permet la gestion des parametres d'un programme a partir 
+//   	de mot-cle (lecture d'un fichier par exemple)
+//--
+
+//++
+// Titre	Constructeurs
+//--
+//++
+//
+// DataCards()
+// DataCards(string const& fn)
+//    Createur avec lecture des parametres ds le fichier de nom "fn"
+//--
+
+DataCards::DataCards()
+{
+}
+
+DataCards::DataCards(string const& fn)
+{
+  ReadFile(fn);
+}
+
+//++
+// Titre	Methodes
+//--
+//++
+// AddProcF(ProcCard f, string const& mtch="*")
+//	Ajoute une fonction de traitement a la liste pour les mots cle
+//      compatibles avec la chaine "mtch" ("mtch" peut contenir "*" en debut 
+//      fin de mot) 
+//
+// Clear()
+//	Supprime les cartes existantes
+//
+// ReadFile(string const& fn) 
+//      Lit le contenu du fichiers "fn" et ajoute les cartes a la liste
+//
+// AppendCard(string const& line)
+//	Rajoute la carte "line" a la liste
+//--
+
+void
+DataCards::AddProcF(ProcCard f, string const& mtch)
+{
+CrdPF mpf;
+if (f == NULL)  return;
+mpf.pf = f;
+if (mtch.length() <= 0)  mpf.patt = "*";
+else  mpf.patt = mtch;
+cpfs.push_back(mpf);
+
+// On applique cette nouvelle fonction aux cartes existantes
+CardList::iterator  ic;
+for(ic = cards.begin(); ic != cards.end(); ic ++)
+  {
+  vector<string>::iterator ik;
+  string tks;
+  for(ik = (*ic).tokens.begin(); ik != (*ic).tokens.end(); ik++)
+    tks = tks + " " + (*ik);
+  ApplyPF(mpf, (*ic).kw, tks);
+  }
+}
+
+void
+DataCards::Clear()
+{
+cards.erase(cards.begin(), cards.end());
+}
+
+void
+DataCards::ReadFile(string const& fn)
+{
+  string file = fn;
+  if (file == "") {
+    char * efn = getenv("PEIDA_DATACARDS");
+    if (efn != NULL)    file = efn;  
+  }
+  if (file == "")  return;
+
+  TRY {
+    DoReadFile(file);
+  } CATCHALL {
+    char* wdp = getenv("PEIDA_WORK");
+    if (wdp) {
+      cerr << "DataCards::ReadFile() Error reading file " << fn << " (Trying with PEIDA_WORK) \n";
+      file = wdp + file;
+      DoReadFile(file);
+    }
+    else cerr << "DataCards::ReadFile() Error reading file " << fn << "\n";
+    THROW(fileErr);
+  
+  } ENDTRY
+}
+
+void
+DataCards::AppendCard(string const& crd)
+{
+Card c;
+size_t p = 1;
+size_t q = crd.find_first_of(" \t");
+size_t l = crd.length();
+
+string toks;
+if (l < 2)  return;
+if (crd[0] != '@')  return;
+
+if (q < l)
+  {  c.kw = crd.substr(p,q-p);  toks = crd.substr(q, l-q); }
+else { c.kw = crd.substr(p,l-p);  toks = ""; }
+//  On applique les ProcFunc's
+ApplyPFL(c.kw, toks);
+while (q < l) 
+  {
+  p = crd.find_first_not_of(" \t",q+1); // au debut d'un token
+  if (p>=l) break;
+  q = crd.find_first_of(" \t",p); // la fin du token;
+  string token = crd.substr(p,q-p);
+  c.tokens.push_back(token);
+  }
+// On supprime la carte de la liste, si elle existe deja ...
+RemoveCard(c.kw);
+cards.push_back(c);
+}
+
+void
+DataCards::DoReadFile(string const& fn)
+{
+char line_buff[512];
+FILE *fip;
+
+if ( (fip = fopen(fn.c_str(),"r")) == NULL )  THROW(fileErr);
+while (fgets(line_buff,511,fip) != NULL)
+  {
+  line_buff[strlen(line_buff)-1] = '\0';   /*  LF/CR de la fin */
+  string line(line_buff);
+  AppendCard(line);
+  }
+}
+
+int
+DataCards::ApplyPF(CrdPF & cpf, string const& key, string const& toks)
+{
+int l,lk;
+int rc = 0;
+// On verifie si le "pattern" correspond
+bool mtch = false;
+l = cpf.patt.length(); 
+if (cpf.patt == "*")  mtch = true;
+else if (cpf.patt[0] == '*')   
+  {
+  lk = key.length();
+  if (cpf.patt[l-1] != '*')
+    {
+    if (strcmp(key.c_str()+(lk-l+1), cpf.patt.c_str()+1) == 0)   mtch = true;
+    }
+  else if  (key.find(cpf.patt.substr(1,l-2)) < lk)  mtch = true;
+  }
+else if (cpf.patt[l-1] == '*')
+  {
+  if ( strncmp(key.c_str(), cpf.patt.c_str(),l-1) == 0)  mtch = true;
+  }
+else if (key == cpf.patt)  mtch = true;
+
+// Si oui, on appelle la fonction correspondante
+if (mtch)  rc = cpf.pf(key, toks); 
+
+return(rc);
+}
+
+
+int
+DataCards::ApplyPFL(string const& key, string const& toks)
+{
+int rc = 0;
+CrdPFList::iterator icf;
+for(icf = cpfs.begin(); icf != cpfs.end(); icf++)
+  rc += ApplyPF((*icf), key, toks);
+return(rc);
+}
+
+void  
+DataCards::RemoveCard(string const& key)
+{
+CardList::iterator i;
+for(i=cards.begin(); i != cards.end(); i++)
+  if ((*i).kw == key) { cards.erase(i);  break;  }
+}
+
+DataCards::Card *
+DataCards::FindKey(string const& key)
+{
+/*
+  CardList::iterator i = find_if(cards.begin(), cards.end(), bind2nd(KeyEq(),key));
+  if (i == cards.end() ) return NULL;
+*/
+  CardList::iterator i;
+  for(i=cards.begin(); i != cards.end(); i++)
+    if ((*i).kw == key) return &*i;
+
+  return NULL;
+}
+
+//++
+// Titre	Acces aux parametres
+//--
+//++
+// int   NbCards()
+//	Renvoie le nombre de cartes data
+// bool	 HasKey(string const& key) 
+//	Indique l'existence d'une carte avec la cle "key"
+// int   NbParam(string const& key)
+//	Indique le nombre de parametre (separes par des espaces) pour la cle "key"
+// string  SParam(string const& key, int num = 0, string def="")
+//	Renvoie la valeur du parametre numero "num" ( 0..(NbParam()-1) ) sous forme de
+//	chaine de caracteres ("string")
+// long    IParam(string const& key, int numero = 0, long def = 0)
+//	Renvoie la valeur du parametre numero "num" ( 0..(NbParam()-1) ) convertie 
+//	en entier ("long")
+// double  DParam(string const& key, int numero = 0, double def = 0)
+//	Renvoie la valeur du parametre numero "num" ( 0..(NbParam()-1) ) convertie 
+//	en flottant ("double")
+//--
+
+
+bool
+DataCards::HasKey(string const& key)
+{
+  return FindKey(key) != NULL;
+}
+
+int 
+DataCards::NbCards()
+{
+return(cards.size());
+}
+
+int 
+DataCards::NbParam(string const& key)
+{
+  DataCards::Card * p = FindKey(key);
+  if (!p) return(-1);
+  else return(p->tokens.size());
+}
+
+string
+DataCards::SParam(string const& key, int numero, string def)
+{
+  DataCards::Card * p = FindKey(key);
+  if (!p) return def;
+  if ( (numero < 0) || (numero >= p->tokens.size()) )  return def;
+  return p->tokens[numero];
+}
+
+long
+DataCards::IParam(string const& key, int numero, long def)
+{
+  string p = SParam(key, numero, "");
+  if (p == "") return def;
+  long i;
+  //istrstream(p.c_str(), p.length()) >> i;
+  sscanf(p.c_str(),"%ld",&i);
+  return i;
+}
+
+double
+DataCards::DParam(string const& key, int numero, double def)
+{
+  string p = SParam(key, numero, "");
+  if (p == "") return def;
+  double i;
+  //istrstream(p.c_str(), p.length()) >> i;
+  sscanf(p.c_str(),"%lg",&i);
+  return i;
+}
+
+   
+ostream& operator << (ostream& s, DataCards c)
+{
+  for (DataCards::CardList::iterator i = c.cards.begin(); i != c.cards.end(); i++) {
+    s << setw(10) << (*i).kw << " ";
+    for (vector<string>::iterator j = (*i).tokens.begin(); j != (*i).tokens.end(); j++)
+      s << (*j) << " ";
+    s << endl;
+  }
+  return s;
+}
+
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/datacards.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/datacards.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/datacards.h	(revision 1307)
@@ -0,0 +1,90 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// $Id: datacards.h,v 1.1.1.1 1999-04-09 17:57:55 ansari Exp $
+//
+// Datacards, acquisition EROS II
+//
+//
+// Eric Aubourg, Decembre 95
+// Reza Ansari, Aout 96
+//
+// DAPNIA/SPP (Saclay) / CEA    LAL - IN2P3/CNRS  (Orsay)
+
+#ifndef DATACARDS_SEEN
+#define DATACARDS_SEEN
+
+#include <string.h>
+#include <string>
+#include <functional>
+#include <list>
+#include <vector>
+#include <string>
+
+#if defined(__KCC__)
+using std::string ;
+#include <functional.h>
+#include <list.h>
+#include <vector.h>
+#endif
+
+#include "peida.h"
+
+typedef int (*ProcCard)(string const& key, string const& toks);
+ 
+class DataCards EXC_AWARE {
+public:
+   DataCards();                  
+   DataCards(string const& fn);
+
+           // nom dans variable d'environnement PEIDA_DATACARDS
+           // par defaut, peida.datacards                        
+           // Si pas chemin complet, on tente dans repertoire 
+           // en cours, puis dans PEIDA_WORK
+
+   virtual ~DataCards() {}
+
+   void    AddProcF(ProcCard f, string const& mtch="*");
+
+   void    Clear();
+   void    ReadFile(string const& fn);
+   void    AppendCard(string const& line);
+
+   int     NbCards();
+   bool    HasKey(string const& key);
+   int     NbParam(string const& key);
+   string  SParam(string const& key, int numero = 0, string def="");
+   long    IParam(string const& key, int numero = 0, long def = 0);
+   double  DParam(string const& key, int numero = 0, double def = 0);
+   
+   friend ostream& operator << (ostream& s, DataCards c);
+
+public:
+   struct Card {
+     string kw;
+     vector<string> tokens;
+	 STRUCTCOMPF(Card,kw)
+   };
+   typedef list<Card> CardList;
+   struct CrdPF {
+     ProcCard pf;
+     string  patt;
+	 STRUCTCOMPF(CrdPF,pf)
+   };
+   typedef list<CrdPF> CrdPFList;
+protected:
+   CardList cards;
+   CrdPFList cpfs;
+
+   void  DoReadFile(string const& fn);
+
+   int   ApplyPF(CrdPF & cpf, string const& key, string const& toks);
+   int   ApplyPFL(string const& key, string const& toks);
+
+   void  RemoveCard(string const& key);
+   
+   Card* FindKey(string const& key);
+   struct KeyEq : binary_function<Card, string, bool> {
+    bool operator()(const Card& x, const string& y) const { return x.kw == y; }
+   };
+};
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/datatypes.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/datatypes.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/datatypes.cc	(revision 1307)
@@ -0,0 +1,83 @@
+// Type de donnees de base 
+//                E. Lesquoy , E. Aubourg 
+//                             R. Ansari 04/95
+
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "defs.h"
+#include "datatypes.h"
+
+/* Nouvelle-Fonction */
+char * DataName(PBaseDataTypes typ)
+{
+switch (typ)
+  {
+  case kuint_1 :
+    return ("uint_1");
+  case kint_1 :
+    return ("int_1");
+  case kuint_2 :
+    return ("uint_2");
+  case kint_2 :
+    return ("int_2");
+  case kint_4:
+    return ("int_4");
+  case kr_4 :
+    return ("r_4");
+  case kr_8 :
+    return ("r_8");
+  default :
+    return ("unknown");
+  }
+}
+
+/* Nouvelle-Fonction */
+char * DataLongName(PBaseDataTypes typ)
+{
+switch (typ)
+  {
+  case kuint_1 :
+    return ("unsigned char (*1)");
+  case kint_1 :
+    return ("signed char (*1)");
+  case kuint_2 :
+    return ("unsigned short int (*2)");
+  case kint_2 :
+    return ("short int (*2)");
+  case kint_4:
+    return ("int (*4)");
+  case kr_4 :
+    return ("float (*4)");
+  case kr_8 :
+    return ("double (*8)");
+  default :
+    return ("unknown");
+  }
+}
+
+/* Nouvelle-Fonction */
+int DataSize(PBaseDataTypes typ)
+{
+switch (typ)
+  {
+  case kuint_1 :
+    return (sizeof(uint_1));
+  case kint_1 :
+    return (sizeof(int_1));
+  case kuint_2 :
+    return (sizeof(uint_2));
+  case kint_2 :
+    return (sizeof(int_2));
+  case kint_4:
+    return (sizeof(int_4));
+  case kr_4 :
+    return (sizeof(r_4));
+  case kr_8 :
+    return (sizeof(r_8));
+  default :
+    return (0);
+  }
+}
+
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/datatypes.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/datatypes.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/datatypes.h	(revision 1307)
@@ -0,0 +1,140 @@
+/*   Manipulation et conversion des types de bases     */
+/*          E. Aubourg, E. Lesquoy                     */
+
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef DATATYPES_H_SEEN
+#define DATATYPES_H_SEEN
+
+#include "machine.h"
+
+
+enum PBaseDataTypes {kpbdt_unknown=-1, kuint_1=1, kint_1=2, 
+                     kuint_2=3, kint_2=4, kuint_4=5, kint_4=6, 
+                     kr_4=7, kr_8=8};
+
+inline PBaseDataTypes DataType(uint_1) {return kuint_1;}
+inline PBaseDataTypes DataType(int_1)  {return kint_1;}
+inline PBaseDataTypes DataType(uint_2) {return kuint_2;}
+inline PBaseDataTypes DataType(int_2)  {return kint_2;}
+inline PBaseDataTypes DataType(uint_4) {return kuint_4;}
+inline PBaseDataTypes DataType(int_4)  {return kint_4;}
+inline PBaseDataTypes DataType(r_4)    {return kr_4;}
+inline PBaseDataTypes DataType(r_8)    {return kr_8;}
+
+char * DataName(PBaseDataTypes);
+char * DataLongName(PBaseDataTypes);
+int    DataSize(PBaseDataTypes);
+
+// Limites des types
+
+inline double   MinRange(uint_1) {return  0.0;}
+inline double   MaxRange(uint_1) {return  255.0;}
+inline double   MinRange(uint_2) {return  0.0;}
+inline double   MaxRange(uint_2) {return  65535.0;}
+inline double   MinRange(int_2)  {return -32768.0;}
+inline double   MaxRange(int_2)  {return  32767.0;}
+inline double   MinRange(int_4)  {return -2147483648.0;}
+inline double   MaxRange(int_4)  {return  2147483647.0;}
+inline double   MinRange(r_4)    {return -3.40282347e+38f;}
+inline double   MaxRange(r_4)    {return  3.40282347e+38f;}
+
+// reduction range donnee si on va du type 1 au type 2 (y/n)
+// ReducRange(type 1 , type 2 )
+// retour:
+
+enum {t_same,t_up,t_spe,t_down}; 
+//         t_same: meme type
+//         t_up  : ascendant   (I,U2)->(I4,R4), I4->R4 
+//         t_spe:  speciaux    I2->U2 , U2->I2 
+//         t_down: descendants R4->I4, (R4,I4)->(U2,I2) 
+
+inline int ConvType(uint_1 , uint_1 ) {return  t_same;}
+inline int ConvType(uint_1 , uint_2 ) {return  t_up;}
+inline int ConvType(uint_1 , int_2 )  {return  t_up;}
+inline int ConvType(uint_1 , int_4 )  {return  t_up;}
+inline int ConvType(uint_1 , r_4 )    {return  t_up;}
+inline int ConvType(uint_2 , uint_1 ) {return  t_down;}
+inline int ConvType(uint_2 , uint_2 ) {return  t_same;}
+inline int ConvType(uint_2 , int_2 )  {return  t_spe;}
+inline int ConvType(uint_2 , int_4 )  {return  t_up;}
+inline int ConvType(uint_2 , r_4 )    {return  t_up;}
+inline int ConvType(int_2 , uint_1 )  {return  t_down;}
+inline int ConvType(int_2 , uint_2 )  {return  t_spe;}
+inline int ConvType(int_2 , int_2 )   {return  t_same;}
+inline int ConvType(int_2 , int_4 )   {return  t_up;}
+inline int ConvType(int_2 , r_4 )     {return  t_up;}
+inline int ConvType(int_4 , uint_1 )  {return  t_down;}
+inline int ConvType(int_4 , uint_2 )  {return  t_down;}
+inline int ConvType(int_4 , int_2 )   {return  t_down;}
+inline int ConvType(int_4 , int_4 )   {return  t_same;}
+inline int ConvType(int_4 , r_4 )     {return  t_up;}
+inline int ConvType(r_4 , uint_1 )    {return  t_down;}
+inline int ConvType(r_4 , uint_2 )    {return  t_down;}
+inline int ConvType(r_4 , int_2 )     {return  t_down;}
+inline int ConvType(r_4 , int_4 )     {return  t_down;}
+inline int ConvType(r_4 , r_4 )       {return  t_same;}
+
+/*
+template <class T> 
+inline T PutInRange(double x,T t) {
+           return (T)( x < MinRange(t) ? MinRange(t) : \
+		      (x > MaxRange(t) ? MaxRange(t) : x));
+	 }
+// BUG GCC 2.6.1. Unresolved: xxx..ng
+*/
+
+inline uint_1 PutInRange(double x, uint_1 t) {
+  return (uint_1)( x < MinRange(t) ? MinRange(t) : \
+	     (x > MaxRange(t) ? MaxRange(t) : x));
+	 }
+inline uint_2 PutInRange(double x, uint_2 t) {
+  return (uint_2)( x < MinRange(t) ? MinRange(t) : \
+	     (x > MaxRange(t) ? MaxRange(t) : x));
+	 }
+inline int_2 PutInRange(double x, int_2 t) {
+  return (int_2)( x < MinRange(t) ? MinRange(t) : \
+	     (x > MaxRange(t) ? MaxRange(t) : x));
+	 }
+inline int_4 PutInRange(double x, int_4 t) {
+  return (int_4)( x < MinRange(t) ? MinRange(t) : \
+	     (x > MaxRange(t) ? MaxRange(t) : x));
+	 }
+inline r_4 PutInRange(double x  , r_4)  {return x;} 
+
+/*
+template <class T> 
+inline T SharePix(double x, T t, double cutmin, double cutmax)
+         { double tmp = (((x - cutmin)/(cutmax-cutmin))* \
+          ( MaxRange(t)-MinRange(t)))+MinRange(t);
+	   return PutInRange(tmp, t);
+	 }
+// BUG GCC 2.6.1. Unresolved: xxx..ng
+*/
+inline double SharePix(double x, uint_1 t, double cutmin, double cutmax)
+         { double tmp = (((x - cutmin)/(cutmax-cutmin))* \
+          ( MaxRange(t)-MinRange(t)))+MinRange(t);
+	   return PutInRange(tmp, t);
+	 }
+inline double SharePix(double x, uint_2 t, double cutmin, double cutmax)
+         { double tmp = (((x - cutmin)/(cutmax-cutmin))* \
+          ( MaxRange(t)-MinRange(t)))+MinRange(t);
+	   return PutInRange(tmp, t);
+	 }
+inline double SharePix(double x, int_2 t, double cutmin, double cutmax)
+         { double tmp = (((x - cutmin)/(cutmax-cutmin))* \
+          ( MaxRange(t)-MinRange(t)))+MinRange(t);
+	   return PutInRange(tmp, t);
+	 }
+inline double SharePix(double x, int_4 t, double cutmin, double cutmax)
+         { double tmp = (((x - cutmin)/(cutmax-cutmin))* \
+          ( MaxRange(t)-MinRange(t)))+MinRange(t);
+	   return PutInRange(tmp, t);
+	 }
+inline double SharePix(double x, r_4 t, double cutmin, double cutmax)
+         { double tmp = (((x - cutmin)/(cutmax-cutmin))* \
+          ( MaxRange(t)-MinRange(t)))+ MinRange(t);
+	   return PutInRange(tmp, t);
+	 }
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/dates.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/dates.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/dates.cc	(revision 1307)
@@ -0,0 +1,882 @@
+#include "defs.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <iostream.h>
+#include <time.h>
+#include <ctype.h>
+#include "defs.h"
+#include "perrors.h"
+#include "dates.h"
+
+//++
+// Class	TimeZone
+// Lib		Outils++ 
+// include	dates.h
+//
+//	Classe de fuseau horaire. Permet les conversion
+//	GMT <-> temps local, en gérant les changements
+//	d'heure hiver-été.
+//	Deux fuseaux horaires sont prédéfinis, "France"
+//	et "Chili".
+//--
+
+TimeZone* gTimeZone = NULL;
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+TimeZone::TimeZone()
+//
+//	Constructeur par défaut. Il lit la variable
+//	d'environnement ACQ_TZ pour choisir le fuseau
+//	horaire. Si la variable n'est pas définie, nous
+//	sommes en France...
+//--
+{
+  char* p = getenv("ACQ_TZ");
+#if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
+  if (!p) p = const_cast<char *>("France");
+#else
+  if (!p) p = "France";
+#endif
+  SetZone(p);
+  END_CONSTRUCTOR;
+}
+
+//++
+TimeZone::TimeZone(const char* nom)
+//
+//	Constructeur à partir du nom d'un fuseau horaire.
+//--
+{
+  SetZone(nom);
+  END_CONSTRUCTOR
+}
+
+//++
+void TimeZone::SetZone(const char* nom)
+//	
+//	Choisit un fuseau horaire. Contient la définition
+//	du fuseau "France" (GMT+1, DST : dernier dimanche
+//	de mars - dernier dimanche de septembre, c'est-à-dire
+//	pré-gouvernement Juppé), et Chili (GMT-4, DST :
+//	deuxième dimanche d'octobre - deuxième dimanche de mars).
+//--
+{
+  if (!strcmp(nom,"France")) {
+     strcpy(code,"MET");
+     strcpy(name,nom);
+     gmtOffset      = 1;
+     hasDST         = 1;
+     dstByWeekDay   = 1;
+     dstStartDay    = Date::jour_Dimanche; // dernier dimanche de mars
+     dstStartNum    = -1;
+     dstStartMonth  = Date::mois_Mars;
+     dstStopDay     = Date::jour_Dimanche; // dernier dimanche de septembre
+     dstStopNum     = -1;
+     dstStopMonth   = Date::mois_Septembre;
+     dstOffset      = 1;
+  } else if (!strcmp(nom,"Chili") || !strcmp(nom,"Chile")) {
+// # Chile has 2nd Sunday in October to 2nd Sunday in March DST
+    strcpy(code,"CST");
+    strcpy(name,"Chili");
+    gmtOffset      = -4;
+    hasDST         = 1;
+    dstByWeekDay   = 1;
+    dstStartDay    = Date::jour_Dimanche; // 2e dimanche d'octobre
+    dstStartNum    = 2;
+    dstStartMonth  = Date::mois_Octobre;
+    dstStopDay     = Date::jour_Dimanche; // 2e dimanche de mars
+    dstStopNum     = 2;
+    dstStopMonth   = Date::mois_Mars;
+    dstOffset      = 1;
+  } else THROW(parmErr);
+}
+
+//++
+int TimeZone::IsDst(const Date& date)
+//
+//	Teste si une date est en heure d'été (DST).
+//--
+{
+  Date dt = date;
+  if (dt.MM < 0 || dt.JJ < 0) THROW(inconsistentErr)
+  if (dt.hh >= 0) dt += gmtOffset/24.0; // date "fictive" en local d'hiver
+  else dt.ss = dt.hh = dt.mm = 0;       // minuit local si heure indeterminee
+  // On est en-dehors des mois frontiere ?
+  if (dstStartMonth < dstStopMonth) {
+     if (dt.MM < dstStartMonth) return 0;
+     if (dt.MM > dstStopMonth)  return 0;
+     if (dt.MM > dstStartMonth && dt.MM < dstStopMonth) return 1;
+  } else {
+     if (dt.MM < dstStopMonth)  return 1;
+     if (dt.MM > dstStartMonth) return 1;
+     if (dt.MM > dstStopMonth && dt.MM < dstStartMonth) return 0;
+  }
+  
+  // Nous sommes dans un mois-frontiere
+  DBASSERT(dt.MM == dstStopMonth || dt.MM == dstStartMonth);
+  
+  if (dt.MM == dstStartMonth) {
+    int jour;
+    if (dstByWeekDay) jour = Date::NthMonthDay(dstStartNum,dstStartDay, dt.MM, dt.AA);
+    else jour = (dstStartNum>0) ? dstStartNum : Date::MonthDays(dt.MM, dt.AA)+1-dstStartNum;
+    if (dt.JJ < jour) return 0;
+    if (dt.JJ > jour) return 1;
+    if (dt.hh > 1) return 1;
+    return 0;
+  } else {
+    int jour;
+    if (dstByWeekDay) jour = Date::NthMonthDay(dstStopNum,dstStopDay, dt.MM, dt.AA);
+    else jour = (dstStopNum>0) ? dstStopNum : Date::MonthDays(dt.MM, dt.AA)+1-dstStopNum;
+    if (dt.JJ < jour) return 1;
+    if (dt.JJ > jour) return 0;
+    if (dt.hh < 2) return 0;
+    return 1;
+  }
+}
+
+//++
+int TimeZone::GetOffset(const Date& date)
+//
+//	Retourne la difference TL-GMT pour une date donnée,
+//	en tenant compte de l'heure d'été éventuelle.
+//--
+{
+  return IsDst(date) ? gmtOffset+dstOffset : gmtOffset;
+}
+
+//++
+// Class	Date
+// Lib		Outils++ 
+// include	dates.h
+//
+//	Une classe date comme une autre, avec gestion
+//	temps local / GMT / changement d'heure, et un 
+//	jour temps sidéral.
+//
+//	Une partie de la date (heure, jour...) peut être
+//	indéterminée. Les comparaisons sont alors faites
+//	de façon astucieuse...
+//
+//	La date peut être déterminée de minuit à minuit
+//	ou de midi à midi (nuit d'observation). Logique
+//	complexe et peut-être foireuse pour passer de
+//	l'un à l'autre, mais pas encore d'ennuis pour le
+//	moment... Une date-nuit doit avoir une heure
+//	indéterminée.
+//
+//	Il faut que Date::gTimeZone soit initialisé pour
+//	éviter des gros pépins, mais PeidaInit() le fait.
+//
+//	An 2000 : Lorsqu'on gère des dates sous forme de chaine :
+//	* En sortie, 2 caractères pour l'année entre 1950 et 1999
+//	  et 4 caractères sinon
+//	* En entrée, si AA<100 on ajoute 1900.
+//--
+
+//++
+short Date::MonthDays(short mois, short annee)
+//
+//	Retourne le nombre de jours dans le mois
+//--
+{
+  if (mois<1 || mois>12) THROW(inconsistentErr);
+  
+  switch(mois) {
+    case mois_Janvier:
+    case mois_Mars:
+    case mois_Mai:
+    case mois_Juillet:
+    case mois_Aout:
+    case mois_Octobre:
+    case mois_Decembre:
+      return 31;
+    case mois_Avril:
+    case mois_Juin:
+    case mois_Septembre:
+    case mois_Novembre:
+      return 30;
+    case mois_Fevrier:
+     return (((annee%4 == 0) && (annee%100 != 0)) || (annee%400 == 0)) ? 29 : 28;
+  }
+  return -1;
+}
+    
+//++
+short Date::YearDays(short annee)
+//
+//	Retourne le nombre de jours dans l'année
+//--
+{
+  return (((annee%4 == 0) && (annee%100 != 0)) || (annee%400 == 0)) ? 366 : 365;
+}
+
+//++
+bool Date::UndetDate() const
+//
+//	Retourne true si une partie de la date (jour
+//	ou mois ou année) est indéterminée.
+//--
+{
+  return ((AA == -1) || (MM == -1) || (JJ == -1));
+}
+
+//++
+bool Date::AllUndetDate() const
+//
+//	Retourne true si toute la date (jour
+//	et mois et année) est indéterminée.
+//--
+{
+  return ((AA == -1) && (MM == -1) && (JJ == -1));
+}
+
+//++
+bool Date::UndetTime() const
+//
+//	Retourne true si une partie de l'heure (heure
+//	ou minutes ou secondes) est indéterminée.
+//--
+{
+  return ((hh == -1) || (mm == -1) || (ss == -1));
+}
+
+//++
+bool Date::AllUndetTime() const
+//
+//	Retourne true si toute l'heure (heure
+//	et minutes et secondes) est indéterminée.
+//--
+{
+  return ((hh == -1) && (mm == -1) && (ss == -1));
+}
+
+//Date::operator double() const
+
+//++
+double
+Date::GetDays() const
+//
+//	Jours écoulés depuis le 0 janvier 1901 0h TU
+//--
+{
+   if (UndetTime() && !AllUndetTime()) THROW(inconsistentErr);
+   if (UndetDate() && !AllUndetDate()) THROW(inconsistentErr);
+   double t=0;
+   if (!UndetDate()) {
+     int nban = AA-1901;
+     if (nban >= 0)  
+       t = nban*365 + (nban/4) - (nban/100) + ((nban+300)/400);
+     else 
+       t = nban*365 + (nban/4) - (nban/100) + ((nban-100)/400);
+     for (int i=1; i<MM; i++)  t += Date::MonthDays(i,AA);
+     t += JJ;
+   }
+   if (!UndetTime()) t += hh/24.0 + mm/1440.0 + ss/86400.0;
+   else if (nuit) t += 0.5;
+   return t;
+}
+
+//++
+void Date::Set(double t)
+//
+//	Jours écoulés depuis le 0 janvier 1901 0h TU
+//--
+{
+   t += 1/8640000.0;
+   int nban = int(floor((t/*-1*/) / 365.2425));
+   if (nban >= 0)  
+     t -= nban*365 + ((nban)/4) - ((nban)/100) + ((nban+300)/400);
+   else 
+     t -= nban*365 + ((nban)/4) - ((nban)/100) + ((nban-100)/400);
+     
+   AA = 1901 + nban;
+   if (t > Date::YearDays(AA)+1) {
+     t -= Date::YearDays(AA);
+     AA++;
+   } else if (t<1) {
+     AA--;
+     t += Date::YearDays(AA);
+   }
+   
+   MM = 1;
+   while (t > Date::MonthDays(MM,AA)+1) {
+     t -= Date::MonthDays(MM,AA);
+     MM++;
+   }
+   
+   JJ = int(t);
+   t -= JJ;
+   
+   t *= 24;
+   hh = int(t);
+   
+   t = (t-hh)*60;
+   mm = int(t);
+   
+   t = (t-mm)*60;
+   ss = t;
+   
+   nuit = 0;
+}
+//++
+Date::Date()
+//
+//	Constructeur. Prend l'heure courante...
+//--
+: timeZone(gTimeZone)
+{
+  time_t t = time(NULL);
+  struct tm* TM = gmtime(&t);
+  
+  AA = TM->tm_year + 1900;
+  MM = TM->tm_mon+1;
+  JJ = TM->tm_mday;
+  hh = TM->tm_hour;
+  mm = TM->tm_min;
+  ss = TM->tm_sec;
+  nuit = 0;
+  END_CONSTRUCTOR
+}
+
+//++
+Date::Date(int J, int M, int A, int h, int m, double s)
+//
+//	Constructeur simple.
+//--
+: JJ(J), MM(M), AA(A), hh(h), mm(m), ss(s), timeZone(gTimeZone), nuit(0)
+{
+  END_CONSTRUCTOR
+}
+
+//++
+Date::Date(double t)
+//
+//	Constructeur à partir des 
+//	jours écoulés depuis le 0 janvier 1901 0h TU
+//
+//--
+: timeZone(gTimeZone)
+{
+  Set(t);
+  END_CONSTRUCTOR
+}
+
+//++
+void Date::SetTimeZone(TimeZone* tz)
+// 
+//	On change de fuseau horaire.
+//--
+{
+  timeZone = tz;
+}
+
+//++
+Date::Date(const char* date, const char* heure, int tOpt)
+//
+//	Constructeur à partir de la date sous la forme
+//	'DD/MM/YYYY'  'HH/MM/SS', et tOpt est Date::kGMTTime
+//	(par défaut) ou Date::kLocalTime.
+//
+//	Tout ou partie de la date peut être indéterminée ('??').
+//--
+: timeZone(gTimeZone)
+{
+  Set(date,heure,tOpt);
+  END_CONSTRUCTOR
+}
+
+//++
+Date::Date(string const& date, string const& heure, int tOpt)
+//
+//	Constructeur à partir de la date sous la forme
+//	'DD/MM/YYYY'  'HH/MM/SS', et tOpt est Date::kGMTTime
+//	(par défaut) ou Date::kLocalTime.
+//
+//	Tout ou partie de la date peut être indéterminée ('??').
+//--
+: timeZone(gTimeZone)
+{
+  Set(date,heure,tOpt);
+  END_CONSTRUCTOR
+}
+
+//++
+void Date::Set(string const& date, string const& heure, int tOpt)
+//
+//	Positionne la date sous la forme
+//	'DD/MM/YYYY'  'HH/MM/SS', et tOpt est Date::kGMTTime
+//	(par défaut) ou Date::kLocalTime.
+//
+//	Tout ou partie de la date peut être indéterminée ('??').
+//--
+{
+  Set(date.c_str(), heure == "" ? (char*)NULL : heure.c_str(), tOpt);
+}
+
+//++
+void Date::Set(const char* date, const char* heure, int tOpt)
+//
+//	Positionne la date sous la forme
+//	'DD/MM/YYYY'  'HH/MM/SS', et tOpt est Date::kGMTTime
+//	(par défaut) ou Date::kLocalTime.
+//
+//	Tout ou partie de la date peut être indéterminée ('??').
+//--
+{
+  nuit = 0;
+  if (date) {
+   if (strlen(date) >= 5) {         //  J(J)/M(M)/AA(AA), ?/?/?, combinaison
+    const char* p = date;
+    if (p[0] == '?' && (p[1] == '?' || p[1] == '/'))   JJ = -1;
+    else {
+      if (!isdigit(p[0])) THROW(inconsistentErr);
+      if (!isdigit(p[1]) && p[1] != '/') THROW(inconsistentErr);
+      JJ = atoi(p);
+      if (JJ <= 0) THROW(inconsistentErr);
+    }
+    
+    if (p[1] == '/') p += 2;
+    else if (p[2] == '/') p+= 3;
+    else THROW(inconsistentErr);
+
+    if (p[0] == '?' && (p[1] == '?' || p[1] == '/'))   MM = -1;
+    else {
+      if (!isdigit(p[0])) THROW(inconsistentErr);
+      if (!isdigit(p[1]) && p[1] != '/') THROW(inconsistentErr);
+      MM = atoi(p);
+      if (MM <= 0 || MM >12) THROW(inconsistentErr);
+    }
+
+    if (p[1] == '/') p += 2;
+    else if (p[2] == '/') p+= 3;
+    else THROW(inconsistentErr);
+
+    if (p[0] == '?')  AA = -1;
+    else {
+      if (!isdigit(p[0])) THROW(inconsistentErr);
+      if (!isdigit(p[1])) THROW(inconsistentErr);
+      AA = atoi(p);
+      if (AA < 100 && AA >= 0 && date[6] != '0') AA += 1900;
+    }
+    
+    if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) THROW(inconsistentErr);
+    
+   } else if (strlen(date)==4) {      // Code EROS de date
+     if (date[0] == '?') AA = -1;
+     else {
+       if (!isdigit(date[0])) THROW(inconsistentErr);
+       AA = 1990 + date[0] - '0';
+     }
+     
+     if (date[1] == '?') MM = -1;
+     else {
+       if (!isalpha(date[1])) THROW(inconsistentErr);
+       if (islower(date[1]))
+         MM = date[1] - 'a' + 1;
+       else
+         MM = date[1] - 'A' + 1;
+       if (MM<1 || MM>12) THROW(inconsistentErr);
+     }
+     
+     if (date[2] == '?' && date[3] == '?') JJ = -1;
+     else {
+       if (!isdigit(date[2])) THROW(inconsistentErr);
+       if (!isdigit(date[3])) THROW(inconsistentErr);
+       JJ = atoi(date+2);
+     }
+     
+     if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) THROW(inconsistentErr);
+     nuit = 1;
+   } else THROW(inconsistentErr);   // Mauvaise longueur
+  } else {                          // Pas de date
+    JJ = MM = AA = -1;
+  }
+  
+  if (heure) {
+    const char* p = heure;
+    if (p[0] == '?' && (p[1] == '?' || p[1] == ':'))   hh = -1;
+    else {
+      if (!isdigit(p[0])) THROW(inconsistentErr);
+      if (!isdigit(p[1]) && p[1] != ':') THROW(inconsistentErr);
+      hh = atoi(p);
+    }
+
+    if (p[1] == ':') p += 2;
+    else if (p[2] == ':') p+= 3;
+    else THROW(inconsistentErr);
+
+    if (p[0] == '?' && (p[1] == '?' || p[1] == ':'))   mm = -1;
+    else {
+      if (!isdigit(p[0])) THROW(inconsistentErr);
+      if (!isdigit(p[1]) && p[1] != '/') THROW(inconsistentErr);
+      mm = atoi(p);
+    }
+
+    if (p[1] == ':') p += 2;
+    else if (p[2] == ':') p+= 3;
+    else THROW(inconsistentErr);
+
+    if (p[0] == '?')   ss = -1;
+    else {
+      if (!isdigit(p[0])) THROW(inconsistentErr);
+      ss = atoi(p);
+    }
+  } else {
+    ss = hh = mm = -1;
+  }
+  
+  if (tOpt == kLocalTime) {
+    DBASSERT(timeZone != NULL);
+    operator -= (timeZone->gmtOffset/24.0);
+    if (timeZone->IsDst(*this))
+      operator -= (timeZone->dstOffset/24.0);   // A VERIFIER SANS DOUTE INEXACT
+  } 
+  
+  if (nuit && !UndetTime() && hh < 12)
+    *this += 1;
+}
+
+//++
+void Date::GetDateStr(char* s, int tOpt) const
+//
+//	Récupère la date sous la forme d'une chaîne 'DD/MM/YYYY'
+//	en tOpt = Date::kGMTTime ou Date::kLocalTime.
+//--
+{
+  Date dt(*this);
+  if (tOpt == kLocalTime && !UndetTime()) {
+    DBASSERT(timeZone != NULL);
+    dt += timeZone->GetOffset(*this)/24.0;
+  }
+  
+  if (dt.AA < 1950 || dt.AA > 1999) 
+    sprintf(s, "%02d/%02d/%04d", dt.JJ, dt.MM, dt.AA);
+  else
+    sprintf(s, "%02d/%02d/%02d", dt.JJ, dt.MM, dt.AA-1900);
+    
+  if (dt.JJ == -1)
+    s[0] = s[1] = '?';
+  if (dt.MM == -1)
+    s[3] = s[4] = '?';
+  if (dt.AA == -1) {
+    s[6] = s[7] = '?';
+    s[8] = '\0';
+  }
+}
+
+//++
+void Date::GetDateCode(char* s, int tOpt) const
+//
+//	Code EROS de la date.
+//--
+{
+  Date dt(*this);
+  if (tOpt == kLocalTime && !UndetTime()) {
+    DBASSERT(timeZone != NULL);
+    dt += timeZone->GetOffset(*this)/24.0;
+  }
+
+  if (!dt.UndetTime() && dt.hh<12) dt -= 1;
+
+  if (dt.AA != -1) {
+    if (dt.AA < 1990 || dt.AA > 2016) THROW(inconsistentErr);
+    int i = dt.AA - 1990;
+    if (i<10)
+      s[0] = '0' + i;
+    else
+      s[0] = 'a' + i - 10;
+  } else
+    s[0] = '?';
+    
+  if (dt.MM != -1)
+    s[1] = 'a' + dt.MM - 1;
+  else
+    s[1] = '?';
+    
+  if (dt.JJ != -1)
+    sprintf(s+2, "%02d", dt.JJ);
+  else
+    s[2] = s[3] = '?';
+  
+  s[4] = 0;
+}
+
+//++
+void Date::GetTimeStr(char* s, int tOpt) const
+//
+//	Récupère l'heure sous la forme 'HH:MM:SS'
+//--
+{
+  Date dt(*this);
+  if (tOpt == kLocalTime) {
+    DBASSERT(timeZone != NULL);
+    dt += timeZone->GetOffset(*this)/24.0;
+  }
+
+  sprintf(s, "%02d:%02d:%02d", dt.hh, dt.mm, int(dt.ss));
+  if (dt.hh == -1)
+    s[0] = s[1] = '?';
+  if (dt.mm == -1)
+    s[3] = s[4] = '?';
+  if (dt.ss == -1)
+    s[6] = s[7] = '?';
+}
+
+//++
+void Date::GetSidTStr(char* s) const
+//
+//	Récupèrera un jour le temps sidéral.
+//--
+{
+  strcpy(s,"TOBEDONE!!");
+}
+
+//++
+string Date::DateStr(int tOpt) const
+//
+//	Récupère la date sous la forme d'une chaîne 'DD/MM/YYYY'
+//	en tOpt = Date::kGMTTime ou Date::kLocalTime.
+//--
+{
+   char s[20];
+   GetDateStr(s,tOpt);
+   return s;
+}
+
+//++
+string Date::DateCode(int tOpt) const
+//
+//	Code EROS de la date.
+//--
+{
+   char s[20];
+   GetDateCode(s,tOpt);
+   return s;
+}
+
+//++
+string Date::TimeStr(int tOpt) const
+//
+//	Récupère l'heure sous la forme 'HH:MM:SS'
+//--
+{
+   char s[20];
+   GetTimeStr(s,tOpt);
+   return s;
+}
+
+//++
+string Date::SidTStr() const
+//
+//	Récupèrera un jour le temps sidéral.
+//--
+{
+   char s[20];
+   GetSidTStr(s);
+   return s;
+}
+
+//++
+int Date::DayOfWeek(int tOpt) const
+//
+//	Retourne le jour dans la semaine, 0-6
+//	avec 0 = Date::jour_Lundi.
+//--
+{
+  double t = GetDays();
+  if (tOpt == kLocalTime && hh >=0) {
+    DBASSERT(timeZone != NULL);
+    t += timeZone->GetOffset(*this)/24.0;
+  }
+  int ndays = int(t);  // nb de jours depuis 0 janvier 1901
+  ndays = (ndays + 1) % 7;
+  if (ndays<0) ndays += 7;
+  return ndays;
+}
+
+//++
+short Date::NthMonthDay(short i, short joursem, short mois, short annee)
+//
+//	Retourne la date correspondant au ieme joursem dans le mois 
+//	correspondant (exemple, 2e dimanche de mars 1960).
+//--
+{
+   if (i>0) {
+     int jprem = Date(1, mois, annee, 0, 0, 0).DayOfWeek();
+     int d = (joursem - jprem);
+     if (d<0) d+=7;
+     return d + 1 + (i-1)*7;
+   } else {
+     int ider = MonthDays(mois, annee);
+     int jder = Date(ider, mois, annee, 0, 0, 0).DayOfWeek();
+     int d = (joursem - jder);
+     if (d>0) d-=7;
+     return d + ider + (i+1)*7;
+   }
+}
+
+//++
+Date& Date::operator += (double dt)     
+//
+//	dt en jours
+//--
+{
+  int u = UndetTime();
+  Set(GetDays()+dt);
+  if (u) ss = hh = mm = -1;
+  return *this;
+}
+
+//++
+Date& Date::operator -= (double dt)    
+//
+//	dt en jours
+//--
+{
+  int u = UndetTime();
+  Set(GetDays()-dt);
+  if (u) ss = hh = mm = -1;
+  return *this;
+}
+
+//++
+Date operator + (Date const& d, double dt)
+//
+//--
+{
+  Date a(d);
+  a += dt;
+  return a;
+}
+
+//++
+Date operator - (Date const& d, double dt)
+//
+//--
+{
+  Date a(d);
+  a -= dt;
+  return a;
+}
+
+//++
+double operator - (Date const& a, Date const& b)
+//
+//	Résultat en jours
+//--
+{
+  if (a.UndetTime() != b.UndetTime()) THROW(inconsistentErr);
+  if (a.UndetDate() != b.UndetDate()) THROW(inconsistentErr);
+  return a.GetDays() - b.GetDays();
+}
+
+//++
+bool operator == (Date const& a, Date const& b)
+//
+//	On n'a pas égalite dès que des éléments déterminés sont différents
+//--
+{
+  if (a.nuit && a.UndetTime() && !b.nuit && !b.UndetTime() && b.hh<12)
+    {Date d = a+1; d.nuit = 0; return d == b;}
+  else if (b.nuit && b.UndetTime() && !a.nuit && !a.UndetTime() && a.hh<12)
+    {Date d = b+1; d.nuit = 0; return a == d;}
+
+  if (a.AA != -1 && b.AA != -1 && a.AA != b.AA) return false;
+  if (a.MM != -1 && b.MM != -1 && a.MM != b.MM) return false;
+  if (a.JJ != -1 && b.JJ != -1 && a.JJ != b.JJ) return false;
+  if (a.hh != -1 && b.hh != -1 && a.hh != b.hh) return false;
+  if (a.mm != -1 && b.mm != -1 && a.mm != b.mm) return false;
+  if (a.ss != -1 && b.ss != -1 && a.ss != b.ss) return false;
+  return true;
+}
+
+//++
+bool operator != (Date const& a, Date const& b)
+//
+//--
+{
+  return !(a == b);
+}
+
+//++
+bool operator <= (Date const& a, Date const& b)
+//
+//	Inégalité large. Pas de subtilités
+//--
+{
+  if (a.nuit && a.UndetTime() && !b.nuit && !b.UndetTime() && b.hh<12)
+    {Date d = a+1; d.nuit = 0; return d <= b;}
+  else if (b.nuit && b.UndetTime() && !a.nuit && !a.UndetTime() && a.hh<12)
+    {Date d = b+1; d.nuit = 0; return a <= d;}
+
+  if (a.AA != -1 && b.AA != -1) {
+    if (a.AA < b.AA) return true;
+    if (a.AA > b.AA) return false;
+  }
+  if (a.MM != -1 && b.MM != -1) {
+    if (a.MM < b.MM) return true;
+    if (a.MM > b.MM) return false;
+  }
+  if (a.JJ != -1 && b.JJ != -1) {
+    if (a.JJ < b.JJ) return true;
+    if (a.JJ > b.JJ) return false;
+  }
+  if (a.hh != -1 && b.hh != -1) {
+    if (a.hh < b.hh) return true;
+    if (a.hh > b.hh) return false;
+  }
+  if (a.mm != -1 && b.mm != -1) {
+    if (a.mm < b.mm) return true;
+    if (a.mm > b.mm) return false;
+  }
+  if (a.ss != -1 && b.ss != -1) {
+    if (a.ss < b.ss) return true;
+    if (a.ss > b.ss) return false;
+  }
+  return true;
+}
+
+//++
+bool operator < (Date const& a, Date const& b)
+//
+//	Inégalité stricte, codée à partir de la large pour résoudre
+//	sans cas particuliers les subtilités 
+//	01/02/95 < ??/03/95 mais pas 01/02/95 < ??/02/95
+//--
+{
+  return (a <= b) && !(a == b);
+}
+
+//++
+bool operator >= (Date const& a, Date const& b)
+//
+//--
+{
+  return (b <= a);
+}
+
+//++
+bool operator > (Date const& a, Date const& b)
+//
+//--
+{
+  return (b < a);
+}
+
+//++
+ostream& operator << (ostream& s, Date const& d)
+//
+//--
+{
+  char x[20];
+  d.GetDateStr(x);
+  s << x << " ";
+  d.GetTimeStr(x);
+  s << x;
+  return s;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/dates.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/dates.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/dates.h	(revision 1307)
@@ -0,0 +1,149 @@
+#ifndef DATES_SEEN
+#define DATES_SEEN
+
+#include <string.h>
+#include <string>
+#include <iostream.h>
+#include "exceptions.h"
+#if defined(__KCC__)
+using std::string ;
+#endif
+
+class TimeZone;
+// <summary> Dates, conversions, operations </summary>
+// Classe generale de date et heure, operation, TU/TL ...
+class Date EXC_AWARE {
+public:
+  // Enumerations jours et mois
+  // <group>
+  enum Jour {jour_Lundi=0, jour_Mardi, jour_Mercredi, jour_Jeudi, jour_Vendredi, jour_Samedi, jour_Dimanche};
+  enum Mois {mois_Janvier=1, mois_Fevrier, mois_Mars, mois_Avril, mois_Mai, mois_Juin, mois_Juillet,
+             mois_Aout, mois_Septembre, mois_Octobre, mois_Novembre, mois_Decembre};
+  enum {kGMTTime=0, kLocalTime=1};
+  // </group>  
+
+  // Constructeur : maintenant 
+  Date();
+  // Constructeur : jours ecoules depuis 0/1/1901 0h TU
+  Date(double);
+  // Constructeur : "jj/mm/aa" ou "amjj", "hh:mm:ss"
+  // topt : kGMTTime (par defaut) ou kLocalTime
+  // <group>
+  Date(const char*, const char* = 0, int topt=0); 
+  Date(string const&, string const& = "", int topt=0); 
+  // </group>
+  // Constructeur : Jour Mois An, Heure Minutes Secondes
+  Date(int J, int M, int A, int h, int m, double s);
+
+  /*operator double() const;*/
+  // Jours depuis le 0 janvier 1901 0h TU
+  double GetDays() const;
+  // Jours depuis le 0 janvier 1901 0h TU
+  void Set(double);
+  //  "jj/mm/aa" ou "amjj", "hh:mm:ss"
+  // <group>
+  void Set(const char*, const char* = 0, int topt=0);
+  void Set(string const&, string const& = "", int topt=0);
+  // </group>
+  
+  // Change de zone horaire.
+  void SetTimeZone(TimeZone* tz);
+
+  // Verifie si des parties de la date sont indeterminees
+  // <group>
+  // Date partiellement indeterminee
+  bool UndetDate() const;
+  // Date totalement indeterminee
+  bool AllUndetDate() const;
+  // Heure partiellement indeterminee
+  bool UndetTime() const;
+  // Heure totalement indeterminee
+  bool AllUndetTime() const;
+  // </group>
+
+  // Conversion vers des chaines de caractere,
+  // date en clair ou code Eros, heure, et temps sideral
+  // en heure local ou GMT.
+  // <group>
+  void GetDateStr(char*, int tOpt=0) const;
+  void GetDateCode(char*, int tOpt=0) const;
+  void GetTimeStr(char*, int tOpt=0) const;
+  void GetSidTStr(char*) const;
+  
+  string DateStr(int tOpt=0) const;
+  string DateCode(int tOpt=0) const;
+  string TimeStr(int tOpt=0) const;
+  string SidTStr() const;
+  // </group>
+
+  // Jour de la semaine, jour_Lundi == 0
+  int  DayOfWeek(int tOpt=0) const;
+  
+  // Ajoute ou soustrait un intervalle en jour et fraction de jour
+  // <group>
+  Date& operator += (double);
+  Date& operator -= (double);
+
+  friend Date operator + (Date const&, double);
+  friend Date operator - (Date const&, double);
+  // </group>
+  
+  // Nombre de jour (et fraction) entre deux dates
+  friend double operator - (Date const&, Date const&);
+  
+  // Comparaisons entre dates
+  // <group>
+  friend bool operator == (Date const&, Date const&);
+  friend bool operator <  (Date const&, Date const&);
+  friend bool operator <= (Date const&, Date const&);
+  friend bool operator >  (Date const&, Date const&);
+  friend bool operator >= (Date const&, Date const&);
+  friend bool operator != (Date const&, Date const&);
+  // </group>
+  
+  // Impression
+  friend ostream& operator << (ostream&, Date const&);
+
+  // Nombre de jours dans le mois
+  static short MonthDays(short mois, short annee);
+  
+  // Nombre de jours dans l'annee
+  static short YearDays(short annee);
+  
+  // Ieme jourssem dans le mois
+  // (2, jour_Dimanche, 5, 1996) : deuxieme dimanche de mai 96
+  static short NthMonthDay(short i, short joursem, short mois, short annee);
+
+  short JJ,MM,AA,hh,mm;
+  double ss; 
+  TimeZone* timeZone;
+  int nuit;  // est-ce une date midi-midi ?
+
+/* void GetSysTimeZone(); */
+};
+
+// <summary> Gestion des fuseaux horaires </summary>
+// Classe de gestion des fuseaux horaires. Tient compte des heures d'ete.
+class TimeZone EXC_AWARE {
+public:
+  char code[4];
+  char name[20];
+
+  short  gmtOffset;
+
+  short  hasDST;
+  short  dstByWeekDay;
+  short  dstStartDay, dstStartNum, dstStartMonth;   // -1 : le dernier, dstStartDay : apres cette date
+  short  dstStopDay, dstStopNum, dstStopMonth;
+  short  dstOffset;
+
+  TimeZone();                 // Tente de deviner le timezone systeme
+  TimeZone(const char*);      // Par nom
+  void SetZone(const char*);
+  int IsDst(Date const& date);
+  int GetOffset(Date const& date);
+};
+
+extern TimeZone* gTimeZone;
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/datime.c
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/datime.c	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/datime.c	(revision 1307)
@@ -0,0 +1,1263 @@
+#include "defs.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+
+#define DATIMEPRIVEE
+#include "strutil.h"
+#include "nbconst.h"
+#include "datime.h"
+
+
+/*       Fonctions de calcule de date et temps (Heure)       */
+/* 
+++ 
+  Module 	Dates (C)
+  Lib	LibsUtil
+  include	datime.h
+
+	Ce groupe de fonctions permettent de manipuler des dates et heures.
+	En particulier, il est possible de calculer l'ecart (en nombre de jours
+	ou de secondes separant deux dates, ou le temps sideral correspondant 
+	a une date et heure legale. Deux structures simples sont definies
+	afin de faciliter le passage des arguments entre differentes fonctions:
+	- *JMA* : Jour, Mois, Annee
+ 	- *HMS* : Heure, Minutes, Secondes
+
+--
+*/
+/*
+++
+  Links	Voir aussi:
+ Temps Sideral, Universel (C)
+--
+*/
+/*
+++
+Titre	Quelques Macros 
+--
+*/
+
+/*
+++
+  StrgtoJMA(strg, jma)
+	Decodage d'une chaine de caracteres "strg" sous forme de "12/3/97" en structure 
+	JMA "jma".
+  JMAtoStrg(jma, strg)
+	Ecrit le contenu de la structure JMA "jma" sous forme de "jj/mm/aaaa" dans la chaine
+	de caracteres "strg"
+  JMAtoStrgLong(jma, strg)
+	Ecriture de date en format long , par ex : "Jeudi , 19 Juin 1997"
+  StrgtoHMS(strg, hms)
+	Decodage d'une chaine de caracteres "strg" sous forme de "hh:mm:ss 10:43:60.5"
+	en structure HMS "hms".
+  HMStoStrg(hms, strg)
+	Ecrit le contenu de la structure HMS "hms" sous forme de "hh:mm:ss" dans la chaine
+	de caracteres "strg"
+  StrtoHMS(strg, hms)
+	Decodage d'une chaine de caracteres "strg" sous forme de "hh:mm:ss 10:43:60.5"
+	en structure HMS "hms" avec gestion des signes (decodage correcte de -44:30:05.23)
+  HMStoStr(hms, strg)
+	Ecrit le contenu de la structure HMS "hms" sous forme de "hh:mm:ss" dans la chaine
+	de caracteres "strg" avec gestion des signes
+--
+*/
+
+void StrtoHMS(char *s,HMS* h)
+/* On ne peut pas ecrire 1:-05:-45 pas gere et debile! (mn et sec >=0.)  cmv 12/8/97 */
+{
+int imoins, i2pt;
+h->Heures = h->Minutes = 0; h->Secondes = 0.;
+/* decodage de la chaine de characteres */
+sscanf(s,"%d:%d:%lf", &(h->Heures),&(h->Minutes),&(h->Secondes));
+/* cas du type 5:34:45.5 */
+if( h->Heures > 0 ) return;
+/* cas du type -5:34:45.5 */
+if( h->Heures < 0 ) {
+  h->Minutes *= -1; h->Secondes *= -1.;
+  return;
+}
+/* Ici les Heures sont donc nulles "0:..." ou "-0:..." */
+/* on n'a donne que l'heure nulle cas "0" ou "-0" sans ":" (idiot mais bon!) */
+i2pt = posc(s,':');
+if( i2pt < 0 ) return;
+/* Ici on a au moins un ou 2 ":" */
+/* cas du type 0:34:45.5 ou 0:0:45.5 sans signe - */
+imoins = posc(s,'-');
+if( imoins < 0 ) return;
+/* cas du type -0:34:45.5 ou -0:0:45.5, le signe - n'est pas decode par sscanf */
+if( imoins < i2pt ) {   /* on a donne -0:34 ou -0:34:45.5 */
+  h->Minutes *= -1; h->Secondes *= -1.;
+  return;
+}
+/* Ici il reste les cas mal codes ou le signe "-" est n'importe ou! */
+/* On laisse le decodage par sscanf */
+return;
+}
+
+
+void HMStoStr(HMS h,char *s)
+/* L'ecriture est forcee a h:mn:sec avec mn et sec >=0  cmv 12/8/97 */
+{
+double v;
+v = HMStoH(h);
+h =  DoubletoHMS(v);
+if( v < 0. ) {
+  h.Heures *= -1; h.Minutes *= -1; h.Secondes *= -1.;
+  sprintf(s,"-%02d:%02d:%04.1f", h.Heures,h.Minutes,h.Secondes);
+} else {
+  sprintf(s,"%02d:%02d:%04.1f", h.Heures,h.Minutes,h.Secondes);
+}
+}
+
+/* Nouvelle-Fonction */
+int NbJourMois(int a, int m)
+/* Retourne le nombre de jours dans le mois m, annee a */
+{
+if(a<100) a+=1900;
+if( m<1 || m>12 ) return(-1);
+m--;
+if(m!=1) return(NbJoMois[m]);
+/* traitement du mois de fevrier bissextile ou non */
+if(  ((a%4==0) && (a%100!=0))
+  ||       (a%400==0)         ) return(NbJoMois[m]+1);
+else return(NbJoMois[m]);
+}
+
+/* Nouvelle-Fonction */
+long JMAtoJ(JMA jma)
+/*           Calcule le Nb. de jours ecoules depuis 0 Jan 1901         */
+/*   Si annee < 100  On considere annee = annee+1900  (1900-1999)      */
+
+{
+long rc,nban;
+int i;
+
+/* Protection */
+if ( (jma.Mois < 1) || (jma.Mois > 12) )  jma.Mois = 1;
+if ( (jma.Jour < 1) || (jma.Jour > 31) )  jma.Jour = 1;
+
+if (jma.Annee < 100)  jma.Annee+=1900;
+nban = jma.Annee - 1901;
+
+/*  Annee Normale = 365 Jours - Bissextile = 366 Jours    */
+/*  366 Jours  :  Divisible par 4 et non divisible par 100  (1972,1976)   */
+/*             :  Divisible par 400 (1900 Non-Biss. et 2000 Biss.)        */
+
+if (nban >= 0)  
+  rc = nban*365 + (nban/4) - (nban/100) + ((nban+300)/400);
+else 
+  rc = nban*365 + (nban/4) - (nban/100) + ((nban-300)/400);
+
+/*    Comptabilisation du nb. des jours des mois ecoule   */
+for (i=1; i<jma.Mois; i++)  rc += NbJourMois(jma.Annee, i);
+rc += jma.Jour;
+
+return(rc);
+}
+
+/* Nouvelle-Fonction */
+JMA JtoJMA(long j)
+/* retourne la date correspondant a j jours ecoules depuis le 0/1/1901 */
+{
+long i;
+int inc,m;
+JMA buf;
+
+inc = (j>=0) ? 1 : -1;
+buf.Jour = buf.Mois = 1; buf.Annee = 1901;
+
+/* recherche de l'annee */
+for(;;) {
+  i = j-JMAtoJ(buf);
+  if( i==0 ) return(buf);
+  if( inc*i<0 ) {
+    /* printf("...annee j=%ld scan=%ld test=%ld\n"
+          ,j,JMAtoJ(buf),inc*i); */
+    break;
+  }
+  buf.Annee += inc;
+}
+if(inc>0) buf.Annee--;
+/* printf("Annee trouvee: %d\n",buf.Annee); */
+
+/* recherche du mois */
+for(m=1;m<=12;m++) {
+  buf.Mois=m;
+  i = j-JMAtoJ(buf);
+  if( i==0 ) return(buf);
+  if(i<0) {
+    /* printf("...mois j=%ld scan=%ld test=%ld\n"
+          ,j,JMAtoJ(buf),i); */
+    buf.Mois--;
+    break;
+  }
+}
+/* printf("Mois trouve: %d\n",buf.Mois); */
+
+/* recherche du jour */
+for(m=1;m<=31;m++) {
+  buf.Jour=m;
+  i = j-JMAtoJ(buf);
+  if( i==0 ) return(buf);
+}
+/* printf("Jour trouve: %d\n",buf.Jour); */
+
+/* on a pas trouve !!! normallement impossible! */
+printf("**** JtoJMA_Erreur: date non trouvee j=%ld ****\n",j);
+buf.Jour = buf.Mois = 1; buf.Annee = 0;
+return(buf);
+}
+
+/* Nouvelle-Fonction */
+int NumJour(JMA jma)
+/*        Cette fonction calcule le numero de jour de la semaine    */
+/*        (Lundi=1 .. Dimanche=7)                                   */
+
+{
+int l;
+
+/*  On appelle JMAtoJ() pour avoir le nb de jours ecoule depuis 1/01/1901  */
+/*  Le premier janvier 1901 etait un Mardi (JMAtoJ = 1 , NumJour = 2)      */
+l = JMAtoJ(jma)%7 ;
+if (l >= 0)  return(l+1);
+else return(l+8);
+}
+
+/* Nouvelle-Fonction */
+JMA JsmmaatoJMA(int nj, int mm, int aa)
+
+/*   Pour "nj=kj*10+jj", calcule la date correspondant au "kj" eme 
+     jour "jj" (1 .. 7 - Lundi .. Dimanche) du mois mm , annee aa
+     Si "nj" est negatif ->  Dernier jour "jj". Si "kj=0", premier jour "jj".
+     Si "kj" ne peut etre atteint -> Dernier jour "jj".
+     Si annee "aa" <= 99   ->  annee de 1901 - 1999       */
+
+{
+JMA  jma;
+int i,k;
+int jj, kj;
+
+kj = nj/10;
+jj = nj%10;
+if (kj < 0)  kj = 0;
+
+if (mm > 12)  mm = 12;
+if (mm < 1 ) mm = 1;
+if (aa < 100)  aa += 1900;
+jma.Mois = mm;
+jma.Annee = aa;
+
+if (kj == 0) {
+  if (jj >= 0)  {      /*   Premier jour du mois   */    
+    if (jj > 7)  jj = 7;
+    if (jj < 1)  jj = 1;
+    jma.Jour = 1;
+    i = NumJour(jma);
+    if (i > jj)  jma.Jour = (7-i)+jj+1;
+    else jma.Jour = 1+(jj-i);
+    }
+  else   {             /*   Dernier jour du mois   */
+    jj = -jj;
+    if (jj > 7)  jj = 7;
+    if (jj < 1)  jj = 1;
+    jma.Jour = NbJourMois(aa,mm);  
+    i = NumJour(jma);
+    if (i >= jj)   jma.Jour -= (i-jj);
+    else  jma.Jour -= (7+i-jj);
+  }
+}
+else {  /*  On demande le kj eme jour jj du mois  */
+  if (jj > 7)  jj = 7;
+  if (jj < 1)  jj = 1;
+  k = 0;
+  for(i=1; i<=NbJourMois(aa,mm); i++) {
+    jma.Jour = i;
+    if (NumJour(jma) == jj)  k++;
+    if (k == kj)  break;
+  }
+/*  On n'a pas kj jour jj ds ce mois, on renvoie le dernier jj */
+  if (k<kj) return(JsmmaatoJMA(-jj, mm, aa));  
+}
+
+return(jma);
+}
+
+JMA JApmmaatoJMA(int nj, int mm, int aa)
+/*    Pour "nj=dd*10+jj", calcule la date correspondant au jour
+      "jj" (1 .. 7 - Lundi .. Dimanche) du mois "mm" , annee "aa"
+      se trouvant apres (ou egal a) la date "dd/mm/aa" .
+      Si annee "aa" <= 99   ->  annee de 1901 - 1999       */
+{
+int i, dd, jj;
+JMA jma;
+
+if (nj < 0) nj = -nj;
+if (nj < 1) nj = 1;
+dd = nj/10;
+jj = nj%10;
+for(i=1; i<=6; i++) {
+  jma = JsmmaatoJMA(jj+10*i, mm, aa);
+  if(jma.Jour >= dd) return(jma);
+}
+printf("JApmmaatoJMA(%d...) Erreur / Pas de jour %d >= %d/%d/%d\n", nj, jj,dd, mm, aa);
+jma.Jour = jma.Mois = jma.Annee = 0;
+return(jma);
+}
+
+/* Nouvelle-Fonction */
+double HMStoH(HMS hms)
+
+/* Cette fonction calcule le nb d'heures en decimales pour hms */
+/* Heures/Minutes/Secondes peuvent etre +/- avec toutes les combi possibles */
+{
+return ((double)hms.Heures + ((double)hms.Minutes)/60. + hms.Secondes/3600.);
+}
+
+
+
+/* Nouvelle-Fonction */
+double HMStoSec(HMS hms)
+/*    Calcul du nb de secondes pour hms    */
+/* Heures/Minutes/Secondes peuvent etre +/- avec toutes les combi possibles */
+{
+return ((double)hms.Heures*3600. + (double)hms.Minutes*60. + hms.Secondes);
+}
+
+/* Nouvelle-Fonction */
+long DatetoSec(char const* date, char const* heure)
+/*   Calcul du nombre de secondes correspondant a date/heure    */
+/*  a partir de l'origine 1er Janv 1990  0H00                   */
+/*  Date entre 1930 - 2050                                      */
+{
+JMA jma,jma0;
+HMS hms;
+long dj;
+
+StrgtoJMA(date,jma);   StrgtoHMS(heure,hms);
+StrgtoJMA("01/01/1990",jma0);
+dj = JMAtoJ(jma) - JMAtoJ(jma0);
+if (dj < -24000)  return(-0x7FFFFFFF);
+if (dj > 24000)  return(0x7FFFFFFF);
+return( dj*3600*24 + (int)(HMStoSec(hms)) );    
+}
+
+/* Nouvelle-Fonction */
+long DatetoSecOff(char const* date, char const* heure)
+{
+JMA jma,jma0;
+HMS hms, hms0;
+long dj,tdec;
+
+StrgtoJMA(date,jma);   StrgtoHMS(heure,hms);
+StrgtoJMA("01/01/1990",jma0);   StrgtoHMS("00:00:00",hms0);
+dj = JMAtoJ(jma) - JMAtoJ(jma0);
+if (dj < -24000)  return(-0x7FFFFFFF);
+if (dj > 24000)  return(0x7FFFFFFF);
+
+/* H_vrai+TOff=H_leg : H_vrai-H_vrai0 = (H_leg-TOff)-(H_leg0-TOff0) */
+tdec  = 3600*(TLegOffset(jma, hms)-TLegOffset(jma0, hms0));
+
+dj = dj*3600*24 + (int)(HMStoSec(hms)) - tdec;
+return(dj);    
+}
+
+/* Nouvelle-Fonction */
+HMS HtoHMS(double h)
+/* Heures decimales en H , M , Sec  Il y a un modulo 24  */
+/* la sortie est telle que 0 <= heures < 24 */
+{
+HMS hms; 
+
+while (h < 0.) h += 24.;
+  
+hms.Heures = (int) h;
+h = (h-hms.Heures)*60.;
+hms.Minutes = (int) h;
+hms.Secondes = (h-hms.Minutes)*60.;
+hms.Heures = hms.Heures % 24;
+
+return(hms);
+}
+
+/* Nouvelle-Fonction */
+HMS DtoDMS(double h)
+/* Degres decimaux en D , M , Sec  Il y a un modulo 360  */
+/* la sortie est telle que -180 < deg <= 180. */
+{
+HMS hms;
+int sgn = 1;
+
+while (h > 180.) h -= 360.;
+while (h <= -180.) h += 360.;
+if( h < 0. ) {h *= -1.; sgn = -1;}
+  
+hms.Heures = (int) h;
+h = (h-hms.Heures)*60.;
+hms.Minutes = (int) h;
+hms.Secondes = (h-hms.Minutes)*60.;
+hms.Heures = hms.Heures % 360;
+
+if( sgn<0 ) {hms.Heures *= -1; hms.Minutes *= -1; hms.Secondes *= -1.;}
+return(hms);
+}
+
+/* Nouvelle-Fonction */
+HMS DoubletoHMS(double h)
+/*    Degres/Heures decimaux en D/H , M , Sec  SANS modulo 360/24  */
+{
+HMS hms;
+
+int sgn = 1;
+if( h < 0. ) {h *= -1.; sgn = -1;}
+
+hms.Heures = (int) h;
+h = (h-hms.Heures)*60.;
+hms.Minutes = (int) h;
+hms.Secondes = (h-hms.Minutes)*60.;
+hms.Heures = hms.Heures;
+
+if( sgn<0 ) {hms.Heures *= -1; hms.Minutes *= -1; hms.Secondes *= -1.;}
+return(hms);
+}
+
+/*
+++
+ Titre	Calcule sur dates et heures
+--
+*/
+
+/*
+++
+int NbJourMois(int a, int m)
+	Retourne le nombre de jours dans le mois "m", annee "a".
+long JMAtoJ(JMA jma)
+	Calcule le Nb. de jours ecoules depuis 0 Jan 1901, 
+	Si annee < 100  On considere annee = annee+1900  (1900-1999)
+JMA JtoJMA(long j)
+	Retourne la date correspondant a un nombre de jours "j"
+	ecoules depuis le 0 Jan 1901.
+int NumJour(JMA jma)
+	Calcule le numero du jour de la semaine correspondant a la date indiquee
+	par la structure JMA "jma". (Lundi=1 .. Dimanche=7)
+JMA JsmmaatoJMA(int nj, int mm, int aa)
+	Pour "nj=kj*10+jj", calcule la date correspondant au "kj" eme 
+	jour "jj" (1 .. 7 - Lundi .. Dimanche) du mois mm , annee aa
+  	Si "nj" est negatif ->  Dernier jour "jj". Si "kj=0", premier jour "jj".
+	Si "kj" ne peut etre atteint -> Dernier jour "jj".
+	Si annee "aa" <= 99   ->  annee de 1901 - 1999       
+JMA JApmmaatoJMA(int nj, int mm, int aa)
+	Pour "nj=dd*10+jj", calcule la date correspondant au jour
+	"jj" (1 .. 7 - Lundi .. Dimanche) du mois "mm" , annee "aa"
+	se trouvant apres (ou egal a) la date "dd/mm/aa" .
+	Si annee "aa" <= 99   ->  annee de 1901 - 1999       
+double HMStoH(HMS hms)
+	Conversion en heures decimales de la structure  "hms"
+double HMStoSec(HMS hms)
+	Conversion en secondes de la structure HMS  "hms"
+HMS HtoHMS(double h)
+	Conversion heures en decimales en structure HMS
+HMS DtoDMS(double h)
+	Conversion degres decimaux en structure HMS (deg,min,sec)
+HMS DoubletoHMS(double h)
+	Conversion degres/heures decimaux en structure HMS (deg/heure,min,sec)
+                   SANS modulo 360/24
+long DatetoSec(char const* date, char const* heure)
+	Calcule le nombre de secondes correspondant a "date,heure" 
+	a partir de l'origine 1er Janv 1990  0H00 ( Date entre 1930 - 2050 )		
+long DatetoSecOff(char const* date, char const* heure)
+	Calcule le nombre de secondes correspondant a "date,heure" 
+	a partir de l'origine 1er Janv 1990  0H00 ( Date entre 1930 - 2050 )
+        en tenant compte des decalages des heures legales.
+--
+*/
+
+
+
+/*   Variables contenant les informations pour conversion  */
+/*  Temps Legal <> TU <> Temps solaire moyen               */
+
+static double  TSolMOff = 0.;     /*  TSol.Moyen - TU  (en heures) */
+static char SiteName[128];           /*  Nom de site  */
+
+static struct
+  {
+  char fg;         /*  Flag (=A ou B) Type de specification  */
+  int jj[2];       /*  Numero ou date du jour                */
+  int mm[2];       /*  Mois    */
+  int Off[3];      /*  Decalage = TLegal - TU    */
+  }  TLegInfo = {'\0',{0,0},{0,0},{0,0,0}} ;
+
+static HMS HChgH = {0,0,0.} ; /*  Heure de changement d'heure */
+
+/* 
+++ 
+  Module 	Temps Sideral, Universel (C)
+  Lib	LibsUtil
+  include	datime.h
+
+	Ce groupe de fonctions permet convertir differentes heures:
+	les temps local, le temps universel (TU), le temps legal (TLeg). Il est 
+	aussi possible de calculer le temps sideral (TS). 
+--
+*/
+/*
+++
+  Links	Voir aussi:
+  Dates (C)
+--
+*/
+/*
+++
+ Titre	T-Legal, TU
+	Conversion entre l'heure legale, le temps universel (TU) et le temps solaire
+	moyen
+--
+*/
+
+/*
+++
+SetTSolMOff(double tsmoff, char *name)
+	Definit pour un site donne, le decalage T Sol. Moyen - TU (en heures) "tmsoff"
+	et le nom du site 
+PrtTSolMOff()
+	Imprime les infos definis par "SetTSolMOff()"
+--
+*/
+
+/* Nouvelle-Fonction */
+void SetTSolMOff(double tsmoff, char *name)
+
+/*     Offset  T Sol. Moyen - TU (en hh:mm:ss) ,  Nom de site name   */
+{
+TSolMOff = tsmoff;
+strcpy(SiteName,name);
+return;
+}
+
+
+/* Nouvelle-Fonction */
+void PrtTSolMOff(void)
+{
+printf("  **Site : %s , T Sol.Moy.-TU  %g  (heures) \n",SiteName,TSolMOff);
+return;
+}
+
+/*
+++
+int SetTLegOff(char* dtz, char* dhz)
+	Initialise la structure TLegInfo. L'argument *dtz peut etre 
+	sous 2 forme differentes et permet de  definir 3 plages 
+	de temps avec 3 decalages horaires (nb entier). 
+	Les dates pivots sont les jours de changement d'heure a 
+	l'heure indiquee par dhz ("hh:mm:ss"), si "dhz==NULL ou 
+	chaine vide, alors changement a 0 heure.  
+|   1) dtz = "A Off1 j1/m1 Off2 j2/m2 Off3"
+|      jx/mx Jour/Mois - Offx : Decalage TLeg - TU                  
+|      pour 01/01 <= jj/mm <  j1/m1   ->  Off1 
+|           j1/m1 <= jj/mm <  j2/m2   ->  Off2 
+|           j2/m2 <= jj/mm <= 31/12   ->  off3 
+|   2) dtz = "B off1 Js1/m1 Off2 Js2/m2 Off3"
+|      Jsx/mx  Numero du jour de la semaine (Js) et numero du mois
+|      Js =  1 ..  7  (Lundi .. Dimanche)  :  1er Jour Js du mois    
+|         = -1 .. -7   Dernier jour Js du mois                  
+|         = k1 .. k7   k eme jour Js du mois                  
+|   3) dtz = "C off1 Js1/m1 Off2 Js2/m2 Off3"
+|      Jsx/mx  Numero du jour de la semaine (Js) et numero du mois avec une 
+|      precision d'une date butee inferieurs    
+|      Js =  ddj ..  (j=1..7  Lundi .. Dimanche)  :  1er Jour j du mois
+|      apres (ou egal a) la date dd/mm    
+	Retour : 0 si Ok -1 Sinon                                          
+void PrtTLegInfo(int aa)	
+	Imprime les informations de decalage TLeg ,  TU - Annee "aa"
+int  TLegOffset(JMA date, HMS heure)
+	Indique le decalage (en nombre d'heures) TLeg-TU	
+--
+*/
+
+/* Nouvelle-Fonction */
+int SetTLegOff(char* dtz, char* dhz)
+
+                        
+{
+int is;
+
+HChgH.Heures = HChgH.Minutes = 0;
+HChgH.Secondes = 0.;
+
+if (dhz) StrgtoHMS(dhz, HChgH);
+if ( (HChgH.Heures < 0) || (HChgH.Heures > 23) )
+  { HChgH.Heures = HChgH.Minutes = 0;  HChgH.Secondes = 0.; }
+
+is = sscanf(dtz,"%c %d %d/%d %d %d/%d %d", &(TLegInfo.fg), &(TLegInfo.Off[0]), &(TLegInfo.jj[0]),  &(TLegInfo.mm[0]), &(TLegInfo.Off[1]), &(TLegInfo.jj[1]),  &(TLegInfo.mm[1]), &(TLegInfo.Off[2]) );
+
+if ( (TLegInfo.fg != 'A') && (TLegInfo.fg != 'B')
+     && (TLegInfo.fg != 'C') )  TLegInfo.fg = '\0';
+if (is != 8) TLegInfo.fg = '\0';
+if (TLegInfo.fg != '\0') return(0);
+else { printf("SetTLegOff()/Erreur %s \n", dtz); return(-1); }
+}
+
+/* Nouvelle-Fonction */
+void PrtTLegInfo(int aa)
+
+/*    Cette fonction  print les infos de TLegInfo     */
+{
+int i,k,j;
+char ForL[2][128];
+JMA jma;
+
+if (TLegInfo.fg == '\0')    printf ("  !!! TlegInfo not set or Error \n");
+
+
+HMStoStrg(HChgH, ForL[0]);
+printf("  ==== TLegInfo : Changement d'heure a %s \n", ForL[0]);
+ForL[0][0] = '\0';
+if (TLegInfo.fg == 'A')  
+  {
+  printf("  ---- TLegInfo : Selection par date (Flag = A)  ---- \n");
+  printf("   -> 01 Janvier - %d %s   :  %d heures \n",TLegInfo.jj[0], NomMo[TLegInfo.mm[0]-1], TLegInfo.Off[0]);
+  printf("   -> %d %s - %d %s  :  %d heures \n",TLegInfo.jj[0], NomMo[TLegInfo.mm[0]-1],TLegInfo.jj[1], NomMo[TLegInfo.mm[1]-1],TLegInfo.Off[1]);
+  printf("   -> %d %s - 31 Decembre  :  %d heures \n",TLegInfo.jj[1], NomMo[TLegInfo.mm[1]-1], TLegInfo.Off[2]);
+  }
+
+if (TLegInfo.fg == 'B')  
+  {
+  printf("  --- TLegInfo : Selection par Jour de semaine et mois (Flag = B)  --- \n");
+  for (i=0;i<2;i++) {
+    k = TLegInfo.jj[i]/10;
+    if (k < 1)  k = 1;
+    j = TLegInfo.jj[i]%10;
+    if (j < 0)  j = -j;
+    if (j < 1) j = 1;
+    if (j > 7) j = 7;
+    if (TLegInfo.jj[i] < 0)  sprintf(ForL[i]," Dernier  %s  de  %s  (KJ=%d)", NomJo[j-1], 
+                                     NomMo[TLegInfo.mm[i]-1], TLegInfo.jj[i]);
+    else  sprintf(ForL[i]," %d eme  %s  de  %s (KJ=%d)", k, NomJo[j-1], 
+                  NomMo[TLegInfo.mm[i]-1], TLegInfo.jj[i]);
+    }
+  printf(" Butees: %s  -  %s \n", ForL[0], ForL[1]);
+  for (i=0;i<2;i++) {
+    jma = JsmmaatoJMA(TLegInfo.jj[i], TLegInfo.mm[i], aa);
+    JMAtoStrg(jma, ForL[i]);
+  }
+  printf("   -> 01 Janvier %d - %s  :  %d heures \n",aa, ForL[0], TLegInfo.Off[0]);
+  printf("   -> %s - %s  :  %d heures \n",ForL[0], ForL[1], TLegInfo.Off[1]);
+  printf("   -> %s - 31 Decembre %d :  %d heures \n",ForL[1], aa, TLegInfo.Off[2]);
+ }
+
+if (TLegInfo.fg == 'C')  
+  {
+  printf("  --- TLegInfo : Selection par Jour de semaine >= dd et mois (Flag = C)  --- \n");
+  for (i=0;i<2;i++) {
+    k = TLegInfo.jj[i]/10;
+    j = TLegInfo.jj[i]%10;
+    if (j < 0)  j = -j;
+    if (j < 1) j = 1;
+    if (j > 7) j = 7;
+    sprintf(ForL[i],"1er %s  apres le %d %s ", NomJo[j-1], k, NomMo[TLegInfo.mm[i]-1]);
+    }
+  printf(" Butees: %s - %s \n", ForL[0], ForL[1]);
+  for (i=0;i<2;i++) {
+    jma = JApmmaatoJMA(TLegInfo.jj[i], TLegInfo.mm[i], aa);
+    JMAtoStrg(jma, ForL[i]);
+  }
+  printf("   -> 01 Janvier %d - %s  :  %d heures \n",aa, ForL[0], TLegInfo.Off[0]);
+  printf("   -> %s - %s  :  %d heures \n",ForL[0], ForL[1], TLegInfo.Off[1]);
+  printf("   -> %s - 31 Decembre %d :  %d heures \n",ForL[1], aa, TLegInfo.Off[2]);
+ }
+
+return;
+}
+
+
+/* Nouvelle-Fonction */
+int  TLegOffset(JMA date, HMS heure)
+
+/*     Cette fonction calcule l'offset   TLeg - TU  pour la date donnee date  */
+{
+JMA jma1,jma2;
+long nbj1,nbj2,nbj;
+double decj1, decj2, decj;
+int Off;
+
+/*   On recherche l'offset correspondant a la date   */
+jma1.Annee = jma2.Annee = date.Annee;
+if (TLegInfo.fg == 'A')
+/*    Periode defini par des dates ds les mois   */ 
+  {
+  jma1.Mois = TLegInfo.mm[0];
+  jma1.Jour = TLegInfo.jj[0];
+  jma2.Mois = TLegInfo.mm[1];
+  jma2.Jour = TLegInfo.jj[1];
+  }
+if (TLegInfo.fg == 'B')
+/*    Periodes definies par jour de semaine et mois   */
+  {
+  jma1 = JsmmaatoJMA(TLegInfo.jj[0],TLegInfo.mm[0],date.Annee);
+  jma2 = JsmmaatoJMA(TLegInfo.jj[1],TLegInfo.mm[1],date.Annee);
+  }
+
+if (TLegInfo.fg == 'C')
+/*    Periodes definies par jour de semaine et mois  avec date inferieure */
+  {
+  jma1 = JApmmaatoJMA(TLegInfo.jj[0],TLegInfo.mm[0],date.Annee);
+  jma2 = JApmmaatoJMA(TLegInfo.jj[1],TLegInfo.mm[1],date.Annee);
+  }
+
+nbj = JMAtoJ(date);
+nbj1 = JMAtoJ(jma1);
+nbj2 = JMAtoJ(jma2);
+
+/*  Les dates pivots sont les jours de changement d'heure a Heure= HChgH */
+decj = (double)nbj + HMStoH(heure)/24.;
+decj1 = (double)nbj1 + HMStoH(HChgH)/24.;
+decj2 = (double)nbj2 + HMStoH(HChgH)/24.;
+
+if ( decj < decj1 )  Off = TLegInfo.Off[0];
+else if (decj < decj2)  Off = TLegInfo.Off[1];
+     else Off = TLegInfo.Off[2];
+
+/*     Impression de debugging   */
+/*Debug--  printf ("   @@@ Debug_TLegOffset (date= %d/%d/%d)  :  %d H. \n",date.Jour,date.Mois,date.Annee,Off);
+printf("  @-1 %s , %d %s %d \n", NomJo[NumJour(jma1)-1], jma1.Jour, NomMo[jma1.Mois-1], jma1.Annee) ;
+printf("  @-2 %s , %d %s %d \n", NomJo[NumJour(jma2)-1], jma2.Jour, NomMo[jma2.Mois-1], jma2.Annee) ;  --*/
+
+
+return (Off);
+}
+
+/*
+++
+HMS TLegtoTU(JMA date, HMS TLeg)
+	Conversion TLegal en TU pour une date donnée
+HMS TUtoTLeg(JMA date, HMS TLeg)
+	Conversion TU en TLegal pour une date donnée. L'heure légale calculée
+	peut être erronnée autour des dates de changement d'heure.
+HMS TUtoTSolM(HMS TU)
+	Conversion TU en temps solaire moyen
+--
+*/
+
+/* Nouvelle-Fonction */
+HMS TLegtoTU(JMA date, HMS hmsz)
+
+/*   Cette fonction transforme le temps legal en temps universel   */
+{
+HMS  TU;
+int Off;
+
+Off = TLegOffset(date, hmsz);
+TU = hmsz;
+TU.Heures -= Off;
+if (TU.Heures >= 24)  TU.Heures -= 24;
+if (TU.Heures < 0)  TU.Heures += 24;
+return(TU);
+}
+
+
+
+/* Nouvelle-Fonction */
+HMS TUtoTLeg(JMA date, HMS hms)
+
+/*   Cette fonction transforme le temps universel en temps legal */
+{
+HMS  TLeg;
+int Off;
+
+Off = TLegOffset(date, hms);    /*  $CHECK$  */
+TLeg = hms;
+TLeg.Heures += Off;
+TLeg.Heures = TLeg.Heures%24;
+if (TLeg.Heures < 0)  TLeg.Heures += 24;
+return(TLeg);
+}
+
+
+/* Nouvelle-Fonction  */
+HMS TUtoTSolM(HMS TU)
+
+/*   Passage  TU  ->  Temps local    */
+{
+double t;
+t = HMStoH(TU) + TSolMOff;
+return(HtoHMS(t));
+}
+
+/*
+++
+ Titre	Temps Sideral
+|      Jour Sideral = 86400 Sec. Sid.  ( = 24 H Sid. )    
+|      Annee Solaire = 365 J 5H 48' 46"  =~  365.2422 J                       
+|      Annee Solaire = 365.2422 Jours Solaire Moyen = 366.2422 Jours Sideraux 
+|      Jour Sol. Moyem = 24 H Sol. = 24 H Sid. * (366.2422 / 365.2422)        
+|      Jour Solaire Moyen = 86636.555359 Sec. Sid. = 24 H 3' 56.555359"       
+|      Heure Solaire Moyen = 3609.85647 Sec. Sid.                             
+|      Sec. Sol. = 1.0027379 Sec. Sid.                                        
+|      Le 1er Janvier 1989 0H TU Il etait 6H 42' 30" GMT_Sideral 
+--
+*/
+
+/*
+++
+HMS TLegtoTSid(JMA date, HMS TZ)
+	Cette fonction calcule le temps sideral a partir du temps
+	legal et de la date
+GMST_at_0h_UT(JMA date)
+	Cette fonction calcule le temps sideral moyen a greenwich a 0h UT
+--
+*/
+
+/* Nouvelle-Fonction  */
+HMS TLegtoTSid(JMA date, HMS TZ)
+
+/*  Cette fonction  donne le temps sideral a partir du temps legal  */
+/*  et la date                                                      */
+{
+HMS  Orgh,TU,TSid;
+JMA  Orgd;
+int off;
+long lj;
+double ts,ratio;
+
+/* Le 1er Janvier 1989 0H TU Il etait 6H 42' 30" GMT_Sideral */
+StrgtoJMA("1/1/1989",Orgd);
+StrgtoHMS("6:42:30",Orgh);
+
+
+
+/*    Nb de jours / Date Origine   */
+lj = JMAtoJ(date) - JMAtoJ(Orgd);
+
+/*  On calcule l'heure TU et on tient compte du decalage eventuel de + ou - 1 jour  */
+off = TLegOffset(date, TZ);
+TU = TZ;
+TU.Heures -= off;
+if (TU.Heures < 0)  
+  {
+  lj -= 1;
+  TU.Heures += 24;
+  }
+if (TU.Heures >= 24)  
+  {
+  lj += 1;
+  TU.Heures -= 24;
+  }
+
+
+
+ratio = ((365.*24.) + 5. + (48. / 60.) + (46. / 3600.)) / 24.;
+ratio = (ratio+1) / ratio ;
+
+/*   Calcul du decalage en heures du temps Sideral par rapport a          */
+/*   l'origine choisie :  ts                                              */
+
+ts = lj * (24. * (ratio - 1) );
+ts += ( TU.Heures * ratio );
+ts += ( ( TU.Minutes / 60. ) * ratio );
+ts += ( (TU.Secondes / 3600. ) * ratio );
+
+ts += HMStoH(Orgh);
+
+/*   On tient compte de l'offset du temps solaire moyen  */
+ts += TSolMOff;
+
+TSid = HtoHMS(ts);
+TSid.Heures = TSid.Heures % 24;
+if (TSid.Heures < 0)  TSid.Heures += 24;
+
+return(TSid);
+}
+
+
+/* Nouvelle-Fonction  */
+HMS GMST_at_0h_UT (JMA date)
+
+/*  Cette fonction  donne le temps sideral moyen a greenwich a 0h UT */
+/*                                                       CMV 5/11/93 */
+{
+HMS Orgh, TSid;
+JMA  Orgd;
+long lj, ejs;
+double js, hs, hs0;
+
+/*  J H ' " sont les vraies valeurs indiscutables (cf metre etalon etc..)  */
+/*  Annee Solaire  = 365 J 5H 48' 45.2" =~  365.2421898148 J               */
+/*  Annee Siderale = 365 J 6H  9'  9.8" =~  365.2563634259 J               */
+/*  Le 1er Janvier 1994 0H TU Il sera 6h 41' 40.4305" GMT_Sideral          */
+StrgtoJMA("1/1/1994",Orgd);
+StrgtoHMS("6:41:40.4305",Orgh);
+hs0 = HMStoH(Orgh);
+
+/*   Nb de jours ecoules depuis la Date Origine */
+lj = JMAtoJ(date) - JMAtoJ(Orgd);
+/* printf("nombre de jours ecoules depuis 1/1/94 %d\n",lj); */
+
+/*   Nb de jours sideraux depuis la Date Origine */
+js = (double) lj * 366.2421898148 / 365.2421898148;
+/*   Nb d'heures siderales depuis Date Origine (modulo un jour) */
+ejs = (int) js;
+hs = js - (double) ejs;
+hs *= 24.;
+hs += hs0;
+
+TSid = HtoHMS(hs);
+/* printf("nombre d'heures siderales depuis la reference (modulo un jour) %d %d %f\n"
+         ,TSid.Heures,TSid.Minutes,TSid.Secondes); */
+
+return(TSid);
+}
+
+/*
+++
+HMS TUtoTSid(JMA date, HMS TU)
+	Cette fonction calcule le temps sideral GMT a partir du temps
+	universel et de la date GMT.
+int TSidtoTU(JMA date, HMS TS, HMS *TU1, HMS *TU2)
+	Cette fonction calcule les temps universels a partir du temps
+	sideral GMT et de la date GMT. Selon la valeur du TS, il peut y avoir
+	une ou deux possibilites pour le TU (return code).
+--
+*/
+
+/* Nouvelle-Fonction  */
+HMS TUtoTSid(JMA date, HMS TU)
+
+/*  Cette fonction  donne le temps sideral GMT a partir du temps universel  */
+/*  et la date  GMT                                                         */
+{
+HMS  Orgh,TSid;
+JMA  Orgd;
+long lj;
+double ts,ratio;
+
+/*   Le 1er Janvier 1989 0H TU Il etait 6H 42' 30" GMT_Sideral */
+StrgtoJMA("1/1/1989",Orgd);
+StrgtoHMS("6:42:30",Orgh);
+
+/*    Nb de jours / Date Origine   */
+lj = JMAtoJ(date) - JMAtoJ(Orgd);
+
+ratio = ((365.*24.) + 5. + (48. / 60.) + (46. / 3600.)) / 24.;
+ratio = (ratio+1) / ratio ;
+
+/*   Calcul du decalage en heures du temps Sideral par rapport a          */
+/*   l'origine choisie :  ts                                              */
+
+ts = lj * (24. * (ratio - 1) );
+ts += ( TU.Heures * ratio );
+ts += ( ( TU.Minutes / 60. ) * ratio );
+ts += ( (TU.Secondes / 3600. ) * ratio );
+
+ts += HMStoH(Orgh);
+
+TSid = HtoHMS(ts);
+TSid.Heures = TSid.Heures % 24;
+if (TSid.Heures < 0)  TSid.Heures += 24;
+
+return(TSid);
+}
+
+/* Nouvelle-Fonction  */
+int TSidtoTU(JMA date, HMS TS, HMS *TU1, HMS *TU2)
+
+/*  Cette fonction  donne les temps universels a partir du temps sideral GMT */
+/*  et la date GMT                                                           */
+{
+int rc = 0;
+HMS  Orgh,T0;
+double ratio,delt,deltt,jsecsid;
+char strd[16],strh[16];
+/* char strh1[16]; */
+
+TU1->Heures = TU2->Heures = -1;
+TU1->Minutes = TU2->Minutes = 0;
+TU1->Secondes = TU2->Secondes = 0.;
+
+ratio = ((365.*24.) + 5. + (48. / 60.) + (46. / 3600.)) / 24.;
+ratio = (ratio / (ratio+1));
+jsecsid = 86400./ratio;
+
+/* temps sideral pour la date a 0h TU */
+StrgtoHMS("00:00:00",T0);
+Orgh =  TUtoTSid(date,T0);
+/* JMAtoStrg(date,strd); HMStoStrg(T0,strh); HMStoStrg(Orgh,strh1);
+printf("... date=%s tu=%s -> org_ts=%s\n",strd,strh,strh1); */
+
+/* difference de temps sideral / a 0h TU */
+delt = HMStoSec(TS) - HMStoSec(Orgh);
+/* printf("... ts=%f org_ts=%f en sec -> delt=%f (jsecsid=%g)\n"
+      ,HMStoSec(TS),HMStoSec(Orgh),delt,jsecsid); */
+
+if(fabs(delt)<1.e-10) delt=0.;
+if(delt<0.) delt += 86400.;
+if( fabs(delt-86400.)<1.e-10 ) delt = 86400. - 1.e-10;
+if(delt<0. || delt>=86400.+1.e-10) {
+  HMStoStrg(TS,strh);
+  JMAtoStrg(date,strd);
+  printf("*** BUG *** TSidtoTU_erreur: delt=%g<0. (d=%s,ts=%s) *******\n"
+        ,delt,strd,strh);
+  return(0);
+}
+
+/* difference de temps / a 0h TU 1ere solution */
+/* printf("... delt=%f en sec sid",delt); */
+deltt = delt*ratio;
+*TU1 = SectoHMS(deltt);
+*TU2 = *TU1;
+rc++;
+/* HMStoStrg((*TU1),strh1);
+printf("... deltt=%f en sec -> TU1=%s\n",deltt,strh1); */
+
+/* Y a t-il une seconde solution ? */
+if(delt>=jsecsid-86400.-1.e-10) return(rc);
+delt += 86400.;
+deltt = delt*ratio;
+*TU2 = SectoHMS(deltt);
+/* HMStoStrg((*TU2),strh1);
+printf("... deltt=%f en sec -> TU2=%s\n",deltt,strh1); */
+rc++;
+
+return (rc);
+}
+
+/*
+++
+void TSidSetupLaSilla()
+	Fonction d'initialisation de conversion  de temps sideral et legal 
+	pour la ESO-Silla "SetTSolMOff() , SetTLegOff()".
+|       Longitude = 70 deg 43.8 min ouest
+|       Latitude  = 29 deg 15.4 min Sud    
+|       T Sol. Moyen - TU = -4.715333 Heures
+|       TLegal-TU : -4 Heures de Mars a Octobre, -3 Heures sinon
+|       Changement le 1er dimanche >= 8/03  8/10 a midi (12:00:00)
+--
+*/
+
+/* Fonction d'initialisation de calcul de temps sideral pour la Silla */
+void TSidSetupLaSilla()
+{
+SetTSolMOff((double)(-4.715333),"La Silla (Chili)");
+if (SetTLegOff("C -3 87/3 -4 87/10 -3","12:00:00") != 0)
+  printf("  TSidSetupLaSilla / Erreur SetTLegOff \n"); 
+/*  Position de l'observatoire */
+/* SetObsPos("La Silla (Chili)","O 70:43:48","S 29:15:24",2347);  */
+return;
+}
+
+
+
+/*
+++
+double ToJulianDay(JMA dateTU, HMS hmsTU);
+	Calcul du jour Julien pour une date TU.
+	Uniquement valable a partir du 15/10/1582 00:00:00.
+--
+*/
+
+double ToJulianDay(JMA dateTU, HMS hmsTU)
+/* Cf Fundamental astronomie, Springer Verlag 2sd ed.  cmv 4/12/98 */
+{
+double j_dat_0_ut;
+long int f,g,a;
+f = (dateTU.Mois>=3) ? dateTU.Annee: dateTU.Annee-1;
+g = (dateTU.Mois>=3) ? dateTU.Mois: dateTU.Mois+12;
+a = 2 - (int)((double)f/100.) + (int)((double)f/400.);
+/* Julian date at 0h UT */
+j_dat_0_ut = (int)(365.25*(double)f)+(int)(30.6001*(double)(g+1))+dateTU.Jour+a+1720994.5;
+return j_dat_0_ut + HMStoH(hmsTU)/24.;
+}
+
+/*
+++
+int FromJulianDay(double JD,JMA* dateTU, HMS* hmsTU);
+	Calcul de la date date et l'heure TU a partir d'un jour Julien.
+	Retourne 0 si succes.
+--
+*/
+
+int FromJulianDay(double JD,JMA* dateTU, HMS* hmsTU)
+/* Cf Fundamental astronomie, Springer Verlag 2sd ed.  cmv 4/12/98 */
+{
+double jd,i,f,a,x,b,c,d,e,h;
+if(JD<0.) return 1;
+
+i = JD - (int)(JD);
+if(i<0.5) jd = (int)(JD)-0.5; else jd = (int)(JD)+0.5;
+
+i = (int)(jd+0.5);
+f = jd+0.5 - i;
+if(i<2299161.0) a = i;
+else {x = (int)((i-1867216.25)/36524.25); a = i+1.+x-(int)(x/4.);}
+b = a+1524.;
+c = (int)((b-122.1)/365.25);
+d = (int)(365.25*c);
+e = (int)((b-d)/30.6001);
+
+x = b-d-(int)(30.6001*e)+f;
+dateTU->Jour = (int)(x);
+
+if(e<13.5) dateTU->Mois = (int)(e-1.); else dateTU->Mois = (int)(e-13.);
+
+if(dateTU->Mois>2.5) dateTU->Annee = (int)(c-4716.); else dateTU->Annee = (int)(c-4715.);
+
+hmsTU->Heures = hmsTU->Minutes = 0; hmsTU->Secondes = 0.;
+h = (JD-ToJulianDay(*dateTU,*hmsTU)) * 24.;
+*hmsTU = HtoHMS(h);
+
+return 0;
+}
+
+
+/*
+++
+double StrgtoDegDec(char *strg)
+	Cette fonction renvoie la valeur decimale en heures
+	d'un angle specifie sous forme de [-][+]dd:mm:ss.
+--
+*/
+
+double StrgtoDegDec(char *strg)
+/*         cmv 4/12/98 */
+{
+int dd,mm;
+float ss;
+char sgn;
+double deg;
+
+dd = mm = 0;
+ss = 0.;
+sgn = *strg;
+if (isdigit(sgn))
+  sscanf(strg,"%d:%d:%f",&dd,&mm,&ss);
+else
+  sscanf(strg+1,"%d:%d:%f",&dd,&mm,&ss);
+deg = (double)(dd) + (double)(mm)/60. + (double)(ss)/3600.;
+if (sgn == '-')  deg = (-deg);
+return(deg);
+}
+
+/*
+++
+char * DegDectoStrg(double deg, char *strg)
+	Cette fonction ecrit une valeur en degre decimal sous 
+	forme de [-]dd:mm:ss.
+--
+*/
+
+char * DegDectoStrg(double deg, char *strg)
+/*         cmv 4/12/98 */
+{
+int dd,mm;
+float ss;
+char sgn;
+
+if (deg < (double)(0.))
+  { deg = (-deg) ; sgn = '-' ; }
+else sgn = '+';
+dd = (int)deg;
+deg = (deg-(double)(dd)) * (double)60.;
+mm = (int)deg;
+ss = (deg-(double)(mm)) * (double)60.;
+if (sgn == '-')
+  sprintf(strg,"-%d:%d:%f",dd,mm,ss);
+else
+  sprintf(strg,"%d:%d:%f",dd,mm,ss);
+return(strg);
+}
+
+/*
+++
+double EccEarth(JMA dateTU)
+	Valeur de l'eccentricite de l'orbite terrestre
+	a la date TU ``dateTU''.
+--
+*/
+double EccEarth(JMA dateTU)
+/* Cf Fundamental astronomie, Springer Verlag 2sd ed p477 table E10.  cmv 9/12/98 */
+{
+double JD,T;
+HMS hmsTU;
+hmsTU.Heures = 12; hmsTU.Minutes = 0; hmsTU.Secondes = 0.;
+JD = ToJulianDay(dateTU,hmsTU);
+/* T en siecles juliens depuis 31/12/1899 a 12h TU --> JD=2415020. */
+T = (JD-2415020.)/36525;
+return(0.0167498 - 0.00004258*T - 0.000000137*T*T);
+}
+
+/*
+++
+double ObliqEarth(JMA dateTU)
+	Valeur de l'obliquite de l'orbite terrestre
+	a la date TU ``dateTU'' (en degres decimaux).
+--
+*/
+double ObliqEarth(JMA dateTU)
+/* Cf Fundamental astronomie, Springer Verlag 2sd ed.  cmv 9/12/98 */
+/* le 1/1/1900 a 0h00 TU --> jd = 2415020.5 */
+{
+double jd;
+HMS hmsTU;
+hmsTU.Heures = hmsTU.Minutes = 0; hmsTU.Secondes = 0.;
+jd = ToJulianDay(dateTU,hmsTU) - 2415020.5;
+return(23.452294 - 0.00013 *jd/365.25);
+}
+
+/*
+++
+double LongEcPerihelie(JMA dateTU)
+	Retourne la Longitude Ecliptique du perihelie de
+	l'orbite terrestre a la date TU ``dateTU'' (en degres decimaux).
+--
+*/
+double LongEcPerihelie(JMA dateTU)
+/* Cf Fundamental astronomie, Springer Verlag 2sd ed p477 table E10.  cmv 9/12/98 */
+{
+double JD,T;
+HMS hmsTU;
+hmsTU.Heures = 12; hmsTU.Minutes = 0; hmsTU.Secondes = 0.;
+JD = ToJulianDay(dateTU,hmsTU);
+/* T en siecles juliens depuis 31/12/1899 a 12h TU --> JD=2415020. */
+T = (JD-2415020.)/36525;
+/* l = 101d 13' 07.15" + 6171.77" *T + 1.823" *T^2 */
+return(101.218652778 + 1.71438055556*T + 0.000506388889*T*T);
+}
+
+/*
+++
+void EquatToEclip(double a,double d,double* l,double *b,JMA dateTU);
+	Renvoie les coordonnees ecliptiques ``l,b'' a partir de
+	coordonnees equatoriales ``a,d'' a la date TU ``dateTU''.
+	La date permet de corriger la variation annuelle
+	de l'obliquite terrestre.
+--
+*/
+void EquatToEclip(double a,double d,double* l,double *b,JMA dateTU)
+/* Cf Fundamental astronomie, Springer Verlag 2sd ed p477 table E10.  cmv 9/12/98 */
+/* l=[0,360[, b=[-90,90] */
+{
+double e,sinb,cosb,sinl,cosl;
+
+e = ObliqEarth(dateTU)*DegenRad;
+a *= DegenRad; d *= DegenRad;
+
+sinb = sin(d)*cos(e)-cos(d)*sin(e)*sin(a);
+if(sinb>1.) sinb=1.; if(sinb<-1.) sinb=-1.;
+*b = asin(sinb);
+cosb = cos(*b);
+
+*l = 0.;
+if(cosb!=0.) {
+  sinl = (sin(d)*sin(e)+cos(d)*cos(e)*sin(a))/cosb;
+  cosl = cos(d)*cos(a)/cosb;
+  if(cosl>1.) cosl=1.; if(cosl<-1.) cosl=-1.;
+  *l = acos(cosl);
+  if(sinl<0.) *l += M_PI;
+  if(*l>2.*M_PI) *l -= 2.*M_PI;
+}
+
+*b /= DegenRad;
+*l /= DegenRad;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/datime.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/datime.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/datime.h	(revision 1307)
@@ -0,0 +1,125 @@
+/*    ------ 1)  Declaration de structure temps et date  ----- */
+/*                            Reza 92/93                       */
+
+#ifndef DATIME_H_SEEN
+#define DATIME_H_SEEN
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct 
+  {
+  int Jour;
+  int Mois;
+  int Annee;
+  }  JMA ;
+
+
+typedef struct 
+  {
+  int  Heures;
+  int Minutes;
+  double Secondes;
+  } HMS ;
+
+/*   ----------    2) Donnees constantes  ---------- */
+#ifdef  DATIMEPRIVEE
+/*   Noms des jours de la semaine - des mois  */
+char *NomJo[7] =  {"Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"};
+char *NomMo[12] = 
+  {"Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet",
+  "Aout","Septembre","Octobre","Novembre","Decembre"};
+
+/*   Nombre de jours des mois   */
+static int NbJoMois[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
+
+#else
+
+extern char *NomJo[7];
+extern char *NomMo[12];
+
+#endif
+
+/*    ------ 3) Macro de manipulation de date et heure  -------  */
+
+#define  NomJour(d)      (NomJo[NumJour(d)-1])
+#define  NomMois(d)      (NomMo[d.Mois-1])
+
+/*   Chaine de forme  hh:mm:sec  <->  structure HMS   */
+#define  StrgtoHMS(s,h)  ( sscanf(s,"%d:%d:%lf", &(h.Heures),&(h.Minutes),&(h.Secondes)) )
+#define  HMStoStrg(h,s)  ( sprintf(s,"%02d:%02d:%02.0f", h.Heures,h.Minutes,h.Secondes) )
+
+/*    Chaine de forme jj/mm/aa  <-> structure JMA     */
+/* EA 140998, machin infame pour que ca marche pour 1998/09/14... Pourquoi avoir fait */
+/* des macros ??????????????????????????????????????????????????????????????????????? */
+#define  StrgtoJMA(strg,j)  ( sscanf(strg,"%d/%d/%d", &(j.Jour),&(j.Mois),&(j.Annee)),\
+    (j.Jour>1900 ? sscanf(strg,"%d/%d/%d", &(j.Annee),&(j.Mois),&(j.Jour)) : 1) ) 
+
+#define  JMAtoStrg(j,strg)  ( sprintf(strg,"%02d/%02d/%4d", j.Jour,j.Mois,j.Annee) )
+#define  JMAtoStrgLong(j,strg)   ( sprintf(strg,"%s , %d %s %d", NomJo[NumJour(j)-1], j.Jour, NomMo[j.Mois-1], j.Annee) )
+
+#define  HtoSec(h)        (h*3600.) 
+#define  SectoHMS(s)      ( HtoHMS(s/3600.) )
+
+
+#define  TLegtoTSolM(d,h)    ( TUtoTSolM(TLegtoTU(d,h)) )
+
+/*  -------  4)  Declaration des fonctions    ----------  */
+
+void StrtoHMS(char *s,HMS* hms);
+void HMStoStr(HMS hms,char *s);
+
+int NbJourMois(int a, int m);
+long JMAtoJ(JMA jma);
+JMA JtoJMA(long j);
+int NumJour(JMA jma);
+JMA JsmmaatoJMA(int jj, int mm, int aa);
+JMA JApmmaatoJMA(int nj, int mm, int aa);
+
+double HMStoH(HMS hms);
+double HMStoSec(HMS hms);
+
+long DatetoSec(char const* date, char const* heure);
+long DatetoSecOff(char const* date, char const* heure);
+
+HMS HtoHMS(double h);
+HMS DtoDMS(double h);
+HMS DoubletoHMS(double h);
+
+void SetTSolMOff(double tsmoff, char *name);
+void PrtTSolMOff(void);
+int  SetTLegOff(char *dtz, char* dhz);
+void PrtTLegInfo(int aa);
+int  TLegOffset(JMA date, HMS heure);
+
+HMS TLegtoTU(JMA date, HMS TLeg);
+HMS TUtoTLeg(JMA date, HMS TLeg);
+HMS TUtoTSolM(HMS TU);
+HMS TLegtoTSid(JMA date, HMS TLeg);
+HMS GMST_at_0h_UT(JMA date);
+HMS TUtoTSid(JMA date, HMS TU);
+int TSidtoTU(JMA date, HMS TS, HMS *TU1, HMS *TU2);
+void TSidSetupLaSilla(void);
+
+double ToJulianDay(JMA dateTU, HMS hmsTU);
+int FromJulianDay(double JD,JMA* dateTU, HMS* hmsTU);
+
+double StrgtoDegDec(char *strg);   
+char * DegDectoStrg(double deg, char *strg);
+
+double EccEarth(JMA dateTU);
+double ObliqEarth(JMA dateTU);
+double LongEcPerihelie(JMA dateTU);
+void EquatToEclip(double alpha,double delta,double* l,double *b,JMA dateTU);
+
+/*   -------------------------------------------------------  */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/difeq.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/difeq.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/difeq.cc	(revision 1307)
@@ -0,0 +1,626 @@
+#include "defs.h"
+#include "difeq.h"
+#include "ctimer.h"
+
+//++
+// Class	DiffEqSolver
+// Lib  	Outils++ 
+// include	difeq.h
+//
+//	Classe abstraite de résolveur d'équation différentielles.
+//	Beaucoup de méthodes renvoient l'objet afin de pouvoir
+//	utiliser une notation chaînée du type
+//|	s.Step(...).Start(...).Solve(...)
+//--
+//++ 
+// Links	Implementations
+// RK4DiffEq
+// RK4CDiffEq
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+DiffEqSolver::DiffEqSolver()
+//
+//	Constructeur vide. 
+//--
+: mFunc(NULL), mOwnFunc(false),
+  mYStart(1), mXStart(0), mStep(0.01)
+{}
+
+//++
+DiffEqSolver::DiffEqSolver(DiffEqFunction* f)
+//
+//	Constructeur général. L'équation est donnée sous forme
+//	de DiffEqFunction
+//--
+: mFunc(f), mOwnFunc(false),
+  mYStart(mFunc->NFuncReal()), mXStart(0), mStep(0.01)
+{}
+
+//++
+DiffEqSolver::DiffEqSolver(DIFEQFCN1 f)
+//
+//	Constructeur pour le cas particulier d'une équation du premier
+//	ordre. Voir DiffEqFcn1. La fonction f correspond à l'équation
+//	y' = f(y).
+//--
+: mFunc(new DiffEqFcn1(f)), mOwnFunc(true),
+  mYStart(mFunc->NFuncReal()), mXStart(0), mStep(0.01)
+{}
+
+DiffEqSolver::~DiffEqSolver()
+{
+  if (mOwnFunc) delete mFunc;
+}
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+DiffEqSolver&
+DiffEqSolver::Func(DiffEqFunction* f)
+//
+//	Permet de spécifier l'équation différentielle, sous la forme
+//	d'une DiffEqFunction. Retourne l'objet DiffEqSolver : notation
+//	chaînée possible
+//--
+{
+  if (mFunc && mOwnFunc) delete mFunc;
+  mFunc    = f;
+  mOwnFunc = false;
+  return *this;
+}
+
+//++
+DiffEqSolver&
+DiffEqSolver::Func(DIFEQFCN1 f)
+//
+//	Permet de spécifier l'équation différentielle, sous la forme
+//	d'une fonction f telle que y' = f(y). Retourne l'objet DiffEqSolver : 
+//	notation chaînée possible.
+//--
+{
+  if (mFunc && mOwnFunc) delete mFunc;
+  mFunc    = new DiffEqFcn1(f);
+  mOwnFunc = true;
+  return *this;
+}
+
+//++
+DiffEqSolver&
+DiffEqSolver::Step(double step)
+//
+//	Spécifie le pas d'intégration de l'équation différentielle (pour
+//	les méthodes où ce pas a un sens). La valeur par défaut est 0.01.
+//	Retourne l'objet DiffEqSolver : notation chaînée possible.
+//--
+{
+  mStep = step;
+  return *this;
+}
+
+//++
+DiffEqSolver&
+DiffEqSolver::StartV(Vector const& yi, double t)
+//
+//	Spécifie le point de départ de l'intégration de l'équadif.
+//	Le vecteur y contient les valeurs intiales. Voir la description
+//	de chaque fonction-objet-équation différentielle pour connaître
+//	le rôle de chaque élément du vecteur. t est la valeur initiale 
+//	du temps.
+//	La dimension de y doit correspondre au nombre apparent de fonctions.
+//	Retourne l'objet DiffEqSolver : notation chaînée possible.
+//--
+{
+  ASSERT(mFunc != NULL);
+  ASSERT(yi.NElts() == mFunc->NFunc());   // Nombre apparent
+  mYStart = yi;
+  mXStart = t;
+  mFunc->AdjustStart(mYStart,t);
+  ASSERT(mYStart.NElts() == mFunc->NFuncReal());
+  return *this;
+}
+
+//++
+DiffEqSolver&
+DiffEqSolver::Start1(double y, double t)
+//
+//	Spécifie le point de départ de l'intégration de l'équadif,
+//	pour une équation y' = f(y). On donne le temps et la valeur de y.
+//	Retourne l'objet DiffEqSolver : notation chaînée possible.
+//--
+{
+  ASSERT(mFunc != NULL);
+  ASSERT(mFunc->NFunc() == 1);   // Nombre apparent
+  mYStart.Realloc(1);
+  mYStart(0) = y;
+  mXStart = t;
+  mFunc->AdjustStart(mYStart,t);
+  ASSERT(mYStart.NElts() == mFunc->NFuncReal());
+  return *this;
+}
+
+//++
+DiffEqSolver&
+DiffEqSolver::Start(double const* yi, double t)
+//
+//	Spécifie le point de départ de l'intégration de l'équadif.
+//	Le tableau yi contient les valeurs intiales. Voir la description
+//	de chaque fonction-objet-équation différentielle pour connaître
+//	le rôle de chaque élément du tableau. t est la valeur initiale 
+//	du temps.
+//	Le nombre d'éléments de yi doit correspondre au nombre apparent
+//	de fonctions.
+//	Retourne l'objet DiffEqSolver : notation chaînée possible.
+//--
+{
+  mYStart.Realloc(mFunc->NFunc());
+  for (int i=0; i<mFunc->NFunc(); i++)
+    mYStart(i) = yi[i];
+  mXStart = t;
+  mFunc->AdjustStart(mYStart,t);
+  ASSERT(mYStart.NElts() == mFunc->NFuncReal());
+  return *this;
+}
+
+//++
+// virtual void DiffEqSolver::SolveArr(Matrix&  y, double* t, double tf, int n)=0
+//	Lance la résolution de l'équadif, jusqu'à la valeur
+//	tf du temps. N valeurs intermédiaires sont retournées dans 
+//	les tableaux y et t :
+//	t[i] est le temps au pas i, pour 0<=i<n
+//	y[i] sont les valeurs des fonctions au pas i.
+//	Voir la description
+//	de chaque fonction-objet-équation différentielle pour connaître
+//	le rôle de chaque élément de y[i].
+//	t[n-1] vaut tf.
+//	Le nombre d'éléments de y[i] doit correspondre au nombre apparent
+//	de fonctions.
+//	Cette fonction doit être redéfinie pour chaque méthode de résolution
+//	d'équations. Elle est appelée par toutes les autres fonctions de
+//	résolution (autres SolveArr, et Solve).
+//--
+
+
+//++
+void
+DiffEqSolver::SolveV(Vector& yf, double tf)
+//
+//	Lance la résolution de l'équadif, jusqu'à la valeur
+//	tf du temps. Les valeurs finales sont retournées dans yf.
+//	Voir la description
+//	de chaque fonction-objet-équation différentielle pour connaître
+//	le rôle de chaque élément de yf.
+//	Le nombre d'éléments de yf doit correspondre au nombre apparent
+//	de fonctions.
+//--
+{
+  double t;
+  Matrix m(1, mFunc->NFuncReal());
+  SolveArr(m, &t, tf, 1);
+  yf.Realloc(mFunc->NFunc());
+  for (int i=0; i<mFunc->NFunc(); i++)
+    yf(i) = m(0,i);
+}
+
+//++
+void
+DiffEqSolver::Solve1(double& yf, double tf)
+//
+//	Lance la résolution de l'équadif, jusqu'à la valeur
+//	tf du temps, pour une équation du premier ordre y' = f(y).
+//	La valeur finale de y est retournée dans yf.
+//--
+{
+  ASSERT(mFunc->NFunc() == 1);
+  double t;
+  Matrix m(1,mFunc->NFuncReal());
+  SolveArr(m, &t, tf, 1);
+  yf = m(0,0);
+}
+
+//++
+void
+DiffEqSolver::Solve(double* yf, double tf)
+//
+//	Lance la résolution de l'équadif, jusqu'à la valeur
+//	tf du temps. Les valeurs finales sont retournées dans yf.
+//	Voir la description
+//	de chaque fonction-objet-équation différentielle pour connaître
+//	le rôle de chaque élément de yf.
+//	Le nombre d'éléments de yf doit correspondre au nombre apparent
+//	de fonctions.
+//--
+{
+  double t;
+  Matrix m(1, mFunc->NFuncReal());
+  SolveArr(m, &t, tf, 1);
+  for (int i=0; i<mFunc->NFunc(); i++)
+    yf[i] = m(0,i);
+}
+
+//++
+void
+DiffEqSolver::SolveArr1(double*  y, double* t, double tf, int n)
+//
+//	Lance la résolution de l'équadif (du premier ordre), jusqu'à la valeur
+//	tf du temps. N valeurs intermediaires sont retournées dans 
+//	les tableaux y et t :
+//	t[i] est le temps au pas i, pour 0<=i<n
+//	y[i] est la valeur de la fonction au pas i.
+//	t[n-1] vaut tf.
+//--
+
+{
+  ASSERT(mFunc->NFunc() == 1);
+  Matrix m(n, mFunc->NFuncReal());
+  SolveArr(m, t, tf, n);
+  for (int i=0; i<n; i++)
+    y[i] = m(i,0);
+}
+
+//++
+void
+DiffEqSolver::SolveArr2(double** y, double* t, double tf, int n)
+//
+//	Lance la résolution de l'équadif, jusqu'à la valeur
+//	tf du temps. N valeurs intermédiaires sont retournées dans 
+//	les tableaux y et t :
+//	t[i] est le temps au pas i, pour 0<=i<n
+//	y[i] sont les valeurs des fonctions au pas i.
+//	Voir la description
+//	de chaque fonction-objet-équation différentielle pour connaître
+//	le rôle de chaque élément de y[i].
+//	t[n-1] vaut tf.
+//	Le nombre d'éléments de y[i] doit correspondre au nombre apparent
+//	de fonctions.
+//--
+{
+   Matrix m(n, mFunc->NFuncReal());
+   SolveArr(m, t, tf, n);
+   for (int i=0; i<n; i++)
+     for (int j=0; j<mFunc->NFunc(); j++)
+       y[i][j] = m(i,j);
+}
+
+
+//++
+// Class	DiffEqFunction
+// Lib	Outils++ 
+// include	difeq.h
+//
+//	Classe de fonctions pour la résolution d'équations différentielles.
+//	On résoud de facon générale un système de n équations différentielles
+//	du premier ordre, donnant les dérivées fpi de n fonctions fi. 
+//	Cette méthode permet de résoudre toutes les sortes d'équations :
+//	pour une équation du second ordre on crée une fonction intermédiaire
+//	qui est la dérivée de la fonction cherchée.
+//--
+
+//++
+// DiffEqFunction::DiffEqFunction(int n)
+//	Constructeur. N est le nombre de fonctions dans le
+//	système.
+//--
+
+//++
+// DiffEqFunction::DiffEqFunction(int n, int napp)
+//	Constructeur. N est le nombre réel de fonctions dans le
+//	système, et napp le nombre apparent (pour l'utilisateur).
+//	En effet, dans certains cas, on peut avoir besoin de fonctions
+//	supplémentaires masquées à l'utilisateur, par exemple la fonction
+//	constante valant 1, si l'équadif fait intervenir le temps (t).
+//--
+
+//++
+//  virtual void ComputeV(Vector& fpi, Vector const& fi)
+//	Calcule les valeurs des dérivées fpi à partir des valeurs 
+//	des fonctions fi. A redéfinir.
+//--
+
+//++
+//  virtual void Compute(double& fp, double f)
+//	Dans le cas où il y a une seule fonction, calcule la dérivée
+//      fp à partir de la valeur de la fonction f. A redéfinir.
+//--
+
+//++
+// int NFunc()
+// 	Nombre apparent de fonctions dans le système
+//--
+  
+//++
+// int NFuncReal() {return mNFunc;}
+// 	Nombre réel de fonctions dans le système
+//--
+
+//++
+// virtual void AdjustStart(Vector& start, double tstart)
+//	Pour ajuster le vecteur de départ quand il y a des 
+//	fonctions à usage interne...
+//--
+
+
+
+//++
+// Class	DiffEqFcn1
+// Lib	Outils++ 
+// include	difeq.h
+//
+//	Objet-fonction générique pour la résolution d'équations
+//	différentielles de la forme y' = f(y).
+//	On fournit une fonction de type
+//|	typedef double(*DIFEQFCN1)(double);
+//	qui retourne y' en fonction de y.
+//--
+//++
+// Links	Parents
+// DiffEqFunction
+//--
+
+//++
+DiffEqFcn1::DiffEqFcn1(DIFEQFCN1 fcn)
+//
+//	Constructeur. On fournit la fonction f tq y'=f(y)
+//--
+: DiffEqFunction(1), mFcn(fcn)
+{}
+
+void
+DiffEqFcn1::Compute(double& fp, double f)
+{
+   fp = (*mFcn)(f);
+}
+
+//++
+// Class	DiffEqFcnT1
+// Lib	Outils++ 
+// include	difeq.h
+//
+//	Objet-fonction générique pour la résolution d'équations
+//	différentielles de la forme y' = f(y,t).
+//	On fournit une fonction de type
+//|	typedef double(*DIFEQFCNT1)(double, double);
+//	qui retourne y' en fonction de y et t.
+//	Note : le système résolu est alors en fait
+//|	y'[0] = fcn(y[0], y[1])
+//|	y'[1] = 1
+//--
+//++
+// Links	Parents
+// DiffEqFunction
+//--
+
+//++
+DiffEqFcnT1::DiffEqFcnT1(DIFEQFCNT1 fcn)
+//
+//	Constructeur. On fournit la fonction f tq y' = f(y,t)
+//--
+: DiffEqFunction(2, 1), mFcn(fcn)
+{}
+
+void
+DiffEqFcnT1::ComputeV(Vector& fpi, Vector const& fi)
+{
+  fpi(0) = (*mFcn)(fi(0), fi(1));
+  fpi(1) = 1;
+}
+
+void
+DiffEqFcnT1::AdjustStart(Vector& start, double tstart)
+{
+  start.Realloc(2);
+  start(1) = tstart;
+}
+
+//++
+// Class	DiffEqFcn2
+// Lib	Outils++ 
+// include	difeq.h
+//
+//	Objet-fonction générique pour la résolution d'équations
+//	différentielles de la forme y'' = f(y',y).
+//	On fournit une fonction de type
+//|	typedef double(*DIFEQFCN2)(double, double);
+//	qui retourne y'' en fonction de y' et y.
+//	Note : le système résolu est en fait
+//|	y'[0] = y[1]
+//|	y'[1] = f(y[1], y[0])
+//--
+//++
+// Links	Parents
+// DiffEqFunction
+//--
+
+//++
+DiffEqFcn2::DiffEqFcn2(DIFEQFCN2 fcn)
+//
+//	Constructeur. On fournit la fonction f tq y''=f(y',y)
+//--
+: DiffEqFunction(2), mFcn(fcn)
+{}
+
+void
+DiffEqFcn2::ComputeV(Vector& fpi, Vector const& fi)
+{
+  fpi(0) = fi(1);
+  fpi(1) = (*mFcn)(fi(1), fi(0));
+}
+
+//++
+// Class	DiffEqFcnT2
+// Lib	Outils++ 
+// include	difeq.h
+//
+//	Objet-fonction générique pour la résolution d'équations
+//	différentielles de la forme y'' = f(y',y,t).
+//	On fournit une fonction de type
+//|	typedef double(*DIFEQFCNT2)(double, double, double);
+//	qui retourne y'' en fonction de y', y et t.
+//	Note : le système résolu est alors en fait
+//|	y'[0] = y[1]
+//|	y'[1] = f(y[1], y[0], y[2])
+//|	y'[2] = 1
+//--
+//++
+// Links	Parents
+// DiffEqFunction
+//--
+
+//++
+DiffEqFcnT2::DiffEqFcnT2(DIFEQFCNT2 fcn)
+//
+//	Constructeur. On fournit la fonction f tq y'' = f(y',y,t)
+//--
+: DiffEqFunction(3,2), mFcn(fcn)
+{}
+
+void
+DiffEqFcnT2::ComputeV(Vector& fpi, Vector const& fi)
+{
+  fpi(0) = fi(1);
+  fpi(1) = (*mFcn)(fi(1), fi(0), fi(2));
+  fpi(2) = 1;
+}
+
+void
+DiffEqFcnT2::AdjustStart(Vector& start, double tstart)
+{
+  start.Realloc(3);
+  start(2) = tstart;
+}
+
+
+//++
+// Class	DiffEqFcnV
+// Lib	Outils++ 
+// include	difeq.h
+//
+//	Objet-fonction générique pour la résolution d'équations
+//	différentielles 3D de la forme y'' = f(y',y), ou y est
+//	un vecteur de dimension 3.
+//	On fournit une fonction de type
+//|	typedef void(*DIFEQFCNV)(Vector& y2, Vector const& y1, 
+//|	                         Vector const& y);
+//	qui retourne y'' en fonction de y' et y.
+//	Note : le système résolu est alors en fait
+//|	v(0-2) = y, v(3-5) = y'
+//|
+//|	v'[0] = v[3]
+//|	v'[1] = v[4]
+//|	v'[2] = v[5]
+//|	v'[3-5] = f(v[3-5], v[0-2])
+//--
+//++
+// Links	Parents
+// DiffEqFunction
+//--
+
+DiffEqFcnV::DiffEqFcnV(DIFEQFCNV fcn)
+: DiffEqFunction(6), mFcn(fcn),
+  tmp1(3), tmp2(3), tmp3(3)
+{}
+
+void
+DiffEqFcnV::ComputeV(Vector& fpi, Vector const& fi)
+{
+  fpi(0) = fi(3);
+  fpi(1) = fi(4);
+  fpi(2) = fi(5);
+  
+  tmp2(0) = fi(3); tmp2(1) = fi(4); tmp2(2) = fi(5);
+  tmp3(0) = fi(0); tmp3(1) = fi(1); tmp3(2) = fi(2);
+  
+  (*mFcn)(tmp1, tmp2, tmp3);
+  
+  fpi(3) = tmp1(0); fpi(4) = tmp1(1); fpi(5) = tmp1(2);
+}
+
+
+//++
+// Class	RK4DiffEq
+// Lib  	Outils++ 
+// include	difeq.h
+//
+//	Classe de résolution d'équadif par la méthode de
+//	Runge-Kutta d'ordre 4.
+//	Voir DiffEqSolver pour les méthodes.
+//--
+//++
+// Links	Parents
+// DiffEqSolver
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+RK4DiffEq::RK4DiffEq()
+: DiffEqSolver(), k1(10), k2(10), k3(10), k4(10)
+{}
+
+//++
+RK4DiffEq::RK4DiffEq(DiffEqFunction* f)
+//
+//	Constructeur général
+//--
+: DiffEqSolver(f), k1(f->NFuncReal()), 
+  k2(f->NFuncReal()), k3(f->NFuncReal()), k4(f->NFuncReal())
+{}
+
+//++
+RK4DiffEq::RK4DiffEq(DIFEQFCN1 f)
+//
+//	Constructeur pour y' = f(y)
+//--
+: DiffEqSolver(f), k1(1), k2(1), k3(1), k4(1)
+{}
+
+void
+RK4DiffEq::SolveArr(Matrix& y, double* t, double tf, int n)
+{
+  //TIMEF;
+  // On calcule le nombre de sous-pas par pas
+   
+   int nStep = (mStep > 0) ? int((tf - mXStart)/n/mStep) : 1;
+   if (nStep <= 1) nStep = 1;
+   
+   double dx = (tf - mXStart)/(n*nStep);
+   
+   Vector yt = mYStart;
+
+   k1.Realloc(mFunc->NFuncReal());
+   k2.Realloc(mFunc->NFuncReal());
+   k3.Realloc(mFunc->NFuncReal());
+   k4.Realloc(mFunc->NFuncReal());
+   
+      
+   for (int i=0; i<n; i++) {
+     for (int j=0; j<nStep; j++)
+       RKStep(yt, yt, dx);
+     for (int k=0; k<mFunc->NFunc(); k++)
+       y(i,k) = yt(k);
+     t[i] = (i+1)*dx*nStep + mXStart;  
+   }
+}
+
+void
+RK4DiffEq::RKStep(Vector& newY, Vector const& y0, double dt)
+{
+    mFunc->ComputeV(k1, y0);
+    k1 *= dt;
+    mFunc->ComputeV(k2, y0 + k1/2);
+    k2 *= dt;
+    mFunc->ComputeV(k3, y0 + k2/2);
+    k3 *= dt;
+    mFunc->ComputeV(k4, y0 + k3);
+    k4 *= dt;
+    
+    newY = y0 + (k1 + k2*2. + k3*2. + k4)/6;
+}
+
Index: /tags/DPC_V0/SophyaLib/NTools/difeq.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/difeq.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/difeq.h	(revision 1307)
@@ -0,0 +1,229 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef DIFEQ_H_SEEN
+#define DIFEQ_H_SEEN
+
+#include "defs.h"
+#include "exceptions.h"
+#include "cvector.h"
+
+class GeneralFunction;
+
+
+// <summary> fonction pour equadifs </summary>
+// Une fonction utilisee pour les equations differentielles.
+// On resoud de facon generale un systeme de n equations differentielles,
+// donnant les derivees fpi de n fonctions fi.
+class DiffEqFunction EXC_AWARE {
+public:
+  // Constructeur. n = nombre de fonctions dans le systeme
+  DiffEqFunction(int n)          : mNFunc(n), mNFuncApp(n) {}
+  
+  // Constructeur. n = nombre reel de fonctions dans le systeme,
+  // m = nombre apparent (il y a dans certaines cas des fonctions a 
+  // usage interne,  par exemple la fonction constante valant 1...)
+  
+  DiffEqFunction(int n, int m)   : mNFunc(n), mNFuncApp(m) {}
+  
+  // Destructeur
+  virtual ~DiffEqFunction()      {}
+  
+  // Calcule les valeurs des derivees fpi a partir des valeurs des fonctions fi
+  virtual void ComputeV(Vector& fpi, Vector const& fi)
+       { Compute(fpi(0), fi(0)); }
+
+  // Dans le cas ou on a une seule fonction, calcule la valeur de la derivee fp
+  // a partir de la valeur de la fonction
+  virtual void Compute(double& /*fp*/, double /*f*/)
+       { ASSERT(mNFunc == 1); }
+  
+  // Nombre apparent de fonctions dans le systeme
+  int NFunc()     {return mNFuncApp;}
+  
+  // Nombre reel de fonctions dans le systeme
+  int NFuncReal() {return mNFunc;}
+  
+  // Pour ajuster vecteur de depart quand il y a des fonctions a usage
+  // interne...
+  virtual void AdjustStart(Vector& /*start*/, double /*tstart*/) 
+    {}   
+protected:
+  // Nombre de fonctions dans le systeme
+  int mNFunc;                   
+  // Nombre apparent de fonctions                 
+  int mNFuncApp;                               
+};
+
+
+// Cas y' = f(y)
+typedef double(*DIFEQFCN1)(double);
+
+// <summary> Cas y' = f(y) </summary>
+// Cas y' = f(y), on fournit la fonction f, sous la forme
+// double f(double), et ca construit la bonne DiffEqFunction
+class DiffEqFcn1 : public DiffEqFunction {
+public:
+  // Constructeur, on fournit une fonction double->double
+  // qui donne y' en fonction de y.
+  DiffEqFcn1(DIFEQFCN1);
+
+  // Implementation de Compute qui va utiliser la fonction fournie
+  // au constructeur.
+  virtual void Compute(double& fp, double f);
+protected:
+  DIFEQFCN1 mFcn;
+};
+
+// Cas y' = f(y,t)
+typedef double(*DIFEQFCNT1)(double, double);
+
+// <summary> y' = f(y,t) </summary>
+// Cas y' = f(y,t), on fournit la fonction f, sous la forme
+// double f(double, double), et ca construit la bonne DiffEqFunction
+class DiffEqFcnT1 : public DiffEqFunction {
+public:
+  // Constructeur, on fournit une fonction (double, double)->double
+  // qui donne y' en fonction de y et t.
+  DiffEqFcnT1(DIFEQFCNT1);
+
+  // Implementation de Compute qui va utiliser la fonction fournie
+  // au constructeur.
+  virtual void ComputeV(Vector& fpi, Vector const& fi);
+
+  // Implementation de AdjustStart qui gere la fonction a usage interne.
+  virtual void AdjustStart(Vector& start, double tstart);
+protected:
+  DIFEQFCNT1 mFcn;
+};
+
+// Cas y'' = f(y',y)
+typedef double(*DIFEQFCN2)(double, double);
+
+class DiffEqFcn2 : public DiffEqFunction {
+public:
+  DiffEqFcn2(DIFEQFCN2);
+
+  virtual void ComputeV(Vector& fpi, Vector const& fi);
+protected:
+  DIFEQFCN2 mFcn;
+};
+
+// Cas y'' = f(y',y,t)
+typedef double(*DIFEQFCNT2)(double, double, double);
+
+// <summary> y'' = f(y',y,t) </summary>
+// Cas y'' = f(y',y,t), on fournit la fonction f, sous la forme
+// double f(double, double, double), et ca construit la bonne DiffEqFunction
+class DiffEqFcnT2 : public DiffEqFunction {
+public:
+  // Constructeur, on fournit une fonction (double, double, double)->double
+  // qui donne y'' en fonction de y', y et t.
+  DiffEqFcnT2(DIFEQFCNT2);
+
+  // Implementation de Compute qui va utiliser la fonction fournie
+  // au constructeur.
+  virtual void ComputeV(Vector& fpi, Vector const& fi);
+
+  // Implementation de AdjustStart qui gere la fonction a usage interne.
+  virtual void AdjustStart(Vector& start, double tstart);
+protected:
+  DIFEQFCNT2 mFcn;
+};
+
+// Cas y'' = f(y',y) avec des 3-vecteurs
+typedef void(*DIFEQFCNV)(Vector&, Vector const&, Vector const&);
+
+// <summary> y'' = f(y',y,t) </summary>
+// Cas y'' = f(y',y,t), on fournit la fonction f, sous la forme
+// double f(Vector), et ca construit la bonne DiffEqFunction
+class DiffEqFcnV : public DiffEqFunction {
+public:
+  // Constructeur, on fournit une fonction (Vector)->double
+  // qui donne y'' en fonction du vecteur (t, y, y')
+  DiffEqFcnV(DIFEQFCNV);
+
+  // Implementation de Compute qui va utiliser la fonction fournie
+  // au constructeur.
+  virtual void ComputeV(Vector& fpi, Vector const& fi);
+protected:
+  DIFEQFCNV mFcn;
+  Vector tmp1, tmp2, tmp3;
+};
+
+// <summary> Classe abstraite de resolveur d'equadif </summary>
+// Classe abstraite de resolveur d'equadif
+// Beaucoup de fonctions renvoient l'objet pour pouvoir faire une
+// notation chainee s.Step(...).Start(...).Solve(...)
+class DiffEqSolver EXC_AWARE {
+public:
+  // Constructeurs. L'equadif est donnee sous forme de DiffEqFunction.
+  // On a prevu le cas particulier du premier degre directement
+  // <group>
+  DiffEqSolver();
+  DiffEqSolver(DiffEqFunction*);
+  DiffEqSolver(DIFEQFCN1);
+  // </group>
+  
+  // Destructeur
+  virtual ~DiffEqSolver();
+
+  // Change la fonction. Notation chainee possible
+  // <group>
+  DiffEqSolver& Func(DiffEqFunction*);
+  DiffEqSolver& Func(DIFEQFCN1);
+  // </group>
+  // Change le pas d'integration. Notation chainee possible
+  DiffEqSolver& Step(double);
+  
+  // Change les conditions initiales. Notation chainee possible.
+  // <group>
+  DiffEqSolver& StartV(Vector const& yi, double t);
+  // si NFunc == 1
+  DiffEqSolver& Start1(double        yi, double t);
+  DiffEqSolver& Start(double const* yi, double t);
+  // </group>
+  
+  // Lance la resolution, avec ou sans conservation de n valeurs intermediaires
+  // <group>
+  virtual void SolveV(Vector& yf, double tf);
+  // si NFunc == 1
+  virtual void Solve1(double& yf, double tf);  
+  virtual void Solve(double* yf, double tf);
+  virtual void SolveArr(Matrix&  y, double* t, double tf, int n)=0;
+  // si NFunc == 1
+  virtual void SolveArr1(double*  y, double* t, double tf, int n);   
+  virtual void SolveArr2(double** y, double* t, double tf, int n);
+  // </group>
+  
+protected:
+  DiffEqFunction* mFunc;
+  bool mOwnFunc;
+
+  Vector  mYStart;
+  double  mXStart;
+  double  mStep;
+};
+
+// <summary> Runge-Kutta ordre 4 </summary>
+// Runge-Kutta ordre 4
+class RK4DiffEq : public DiffEqSolver {
+public:
+  // Constructeurs. Voir <linkto class=DiffEqSolver>DiffEqSolver</linkto>
+  // <group>
+  RK4DiffEq();
+  RK4DiffEq(DiffEqFunction*);
+  RK4DiffEq(DIFEQFCN1);
+  // </group>
+
+  // Implementation de RK4
+  virtual void SolveArr(Matrix& y, double* t, double tf, int n);
+
+protected:
+  // Un pas RK4
+  void RKStep(Vector& newY, Vector const& y0, double dt);
+  // Vecteurs utilises en interne, pour ne pas les reallouer.
+  Vector k1, k2, k3, k4;
+};
+
+
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/dvlist.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/dvlist.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/dvlist.cc	(revision 1307)
@@ -0,0 +1,398 @@
+//  Classe Dynamic Variable List (DVList) de PEIDA
+//                  R. Ansari  1997
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "defs.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "dvlist.h"
+#include "strutil.h"
+
+//++
+// Class	DVList
+// Lib		Outils++
+// include	dvlist.h
+//
+//	Cette classe permet de gérer une ensemble de variables (ou paramètres)
+//	pouvant être définies dynamiquement à l'execution. Le nom des 
+//	variables ne doit pas contenir de blancs ("<espace>") et est 
+//	limité à 64 caractères maximum. Cette classe 
+//	offre la possibilité de sauvegarder l'ensemble 
+//	des variables (Nom, Type, Valeur) dans un fichier, ou de
+//	recréer l'objet DVList et l'ensemble de ses variables à 
+//	partir d'un fichier (Objet PPersist). Une zone commentaire (max=320 c.) 
+//	est associée à chaque objet DVList, accessible à travers  
+//	la méthode "Comment()". Les objets de cette classe sont  
+//	en particulier destinés à être inclus dans d'autres objets 
+//	PPersist plus complexes. La classe DVList gère des 
+//	variables de type entier ("int_4"), réél double précision ("double")
+//	et de type chaine de caracteres ("string, char*", maxi 30 caracteres ).
+//	Une classe intermédiaire (*MuTyV*) est utilisée pour représenter une 
+//	variable et fournit les services de conversion entre les différents types.
+//--
+//--
+//++
+// Links	Parents
+// PPersist
+//--
+
+
+char MuTyV::myStrBuf[64];   // Declare static ds le .h 
+
+static MuTyV ddvdum(-9.e19);
+
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+// DVList()
+//	Constructeur par défaut
+// DVList(DVList& cfd)
+//	Constructeur par copie. Le nouvel objet est une copie complète de "cfd"
+// DVList(char* flnm)
+//	Constructeur avec initialisation à partir du contenu du fichier (PPF)
+//	"flnm". Le fichier doit avoir été créé par la méthode "Write()"
+//--
+
+/* --Methode-- */
+DVList::DVList()
+{
+comment = "";
+}
+
+/* --Methode-- */
+DVList::DVList(DVList& dvl)
+{
+Merge(dvl);
+}
+
+/* --Methode-- */
+DVList::DVList(char *flnm)
+{
+PInPersist s(flnm);
+Read(s);
+}
+
+
+/* --Methode-- */
+DVList::~DVList()
+{
+}
+
+//++
+// Titre	Gestion des variables et opérateurs
+//--
+
+//++
+// void  Clear()
+//	Supprime la définition de toutes les variables de l'objet.
+// DVList&  Merge(const DVList& lv)
+//	Fusionne l'objet avec la liste des variables de l'objet "lv"
+// DVList&  operator= (const DVList& cofr)
+//	Remplace la liste des variables de l'objet par celle de l'objet "cofr".   
+//--
+
+/* --Methode-- */
+DVList&     DVList::operator= (const DVList& dvl)
+{
+Clear();
+return(Merge(dvl));
+}
+
+
+/* --Methode-- */
+void        DVList::Clear()
+{
+mvlist.erase(mvlist.begin(), mvlist.end());
+comment = "";
+}
+
+/* --Methode-- */
+DVList&     DVList::Merge(const DVList& dvl)
+{
+ValList::const_iterator it;
+for(it = dvl.mvlist.begin(); it != dvl.mvlist.end(); it++)
+  {
+  switch ((*it).second.typ) 
+    {
+    case 'I' :
+      SetI((*it).first, (*it).second.mtv.iv);
+      break;
+    case 'D' : 
+      SetD((*it).first, (*it).second.mtv.dv);
+      break;
+    case 'S' : 
+      SetS((*it).first, (*it).second.mtv.strv);
+      break;
+    default :
+      break;
+    }
+  }
+comment = comment + "\n" + dvl.comment;
+return(*this);
+}
+
+
+//++
+// int_4   GetI(string const& key, int_4  def=-1)
+// double  GetD(string const& key, double def=-9.e19)
+// string  GetS(string const& key, char* def="")
+//	Retourne la valeur de la variable de nom "key" et de type entier, réél, 
+//	chaine de caracteres.
+//	Si la variable n'existe pas, la valeur par défaut "def" est renvoyée.
+//--
+
+/* --Methode-- */
+int_4       DVList::GetI(string const& key, int_4 def)
+{
+ValList::iterator it = mvlist.find(key);
+if (it == mvlist.end())  return(def);
+if ( (*it).second.typ != 'I') return(def);
+return((*it).second.mtv.iv);
+}
+
+/* --Methode-- */
+double      DVList::GetD(string const& key, double def)
+{
+ValList::iterator it = mvlist.find(key);
+if (it == mvlist.end())  return(def);
+if ( (*it).second.typ != 'D') return(def);
+return((*it).second.mtv.dv);
+}
+
+/* --Methode-- */
+string      DVList::GetS(string const& key, char* def)
+{
+ValList::iterator it = mvlist.find(key);
+if (it == mvlist.end())  return(def);
+if ( (*it).second.typ != 'S') return(def);
+return((*it).second.mtv.strv);
+}
+
+//++
+// void  SetI(string const& key, int_4  val)
+// void  SetD(string const& key, double val)
+// void  SetS(string const& key, char*  val)
+// void  SetS(string const& key, string val)
+//	Crée la variable de nom "key", de type entier, double, string et 
+//	lui attribue la valeur "val". Si une variable du même nom existe, 
+//	sa valeur et eventuellement son type sont modifiés.  
+//--
+
+/* --Methode-- */
+void        DVList::SetI(string const& key, int_4 val)
+{
+Get(key) = (int_4)val;
+}
+
+/* --Methode-- */
+void        DVList::SetD(string const& key, double val)
+{
+Get(key) = (double)val;
+}
+
+/* --Methode-- */
+void        DVList::SetS(string const& key, char const* val)
+{
+MuTyV div(val);
+Get(key) = div;
+}
+
+/* --Methode-- */
+void        DVList::SetS(string const& key, string val)
+{
+MuTyV div(val);
+Get(key) = div;
+}
+
+
+//++
+// MuTyV&  Get(string const& key) 
+//	Renvoie une référence sur l'objet "MuTyV" de la liste avec le nom "key".
+//	Si cet objet (variable) n'existe pas, il est créé.
+// MuTyV&     operator()  (string const& key) 
+// MuTyV&     operator[]  (string const& key) 
+//
+//	Renvoie la variable de nom "key". Equivalent à "Get(key)". 
+// string&  Comment()
+//	Renvoie une référence sur le champ commentaire de l'objet.
+//--
+
+/* --Methode-- */
+MuTyV&      DVList::Get(string const& key)
+{
+size_t l = key.length();
+if ( (l < 1) || (key.find_first_of(" ") < l) )  return(ddvdum);
+ValList::iterator it = mvlist.find(key);
+if (it == mvlist.end()) mvlist[key] = (int_4) 0;  // $CHECK$ EA. Ambigu si pas de cast...
+it = mvlist.find(key);
+if (it == mvlist.end()) return(ddvdum); 
+else return((*it).second);
+}
+
+//++
+// Titre	Entrée-Sortie
+//--
+
+//++
+//  void  Print()
+//	Imprime (sur "cout") la liste des variables et leurs valeurs.
+//  void  Print(ostream& os)
+//	Imprime sur le flot "os" la liste des variables et leurs valeurs.
+//  ostream&    operator << (ostream& s, DVList& dvl)
+//	sortie sur flot "s" (Appel a "Print(s)").
+//  void  Write(string const& fn)
+//	Ecriture d'un fichier PPersist de nom "fn"
+//  void  Read(string const& fn)
+//	Lecture d'un fichier PPersist de nom "fn"
+//--
+
+
+/* --Methode-- */
+void        DVList::Print(ostream& os) const
+{
+os << "DVList::Print() - NVar= " << (int)mvlist.size() << "\n";
+os << "Comment: " << comment << "\n";
+char buff[128];
+ValList::const_iterator it;
+for(it = mvlist.begin(); it != mvlist.end(); it++)  {
+  switch ((*it).second.typ) 
+    {
+    case 'I' :
+      sprintf(buff, "%s = %d (int) \n", (*it).first.substr(0,64).c_str(), (*it).second.mtv.iv );
+      break;
+    case 'D' : 
+      sprintf(buff, "%s = %.20g (double) \n", (*it).first.substr(0,64).c_str(), (*it).second.mtv.dv );
+      break;
+    case 'S' : 
+      sprintf(buff, "%s = %s (string) \n", (*it).first.substr(0,64).c_str(), (*it).second.mtv.strv );
+      break;
+    default :
+      break;
+    }
+  os << (string)buff;
+  }
+os << endl;
+}
+
+
+/* --Methode-- */
+void        DVList::WriteSelf(POutPersist& s) const
+{
+char buf[320];
+
+int lc = comment.length();
+if (lc > 319) lc = 319;
+if (lc > 0) {
+  sprintf(buf,"Comment: ( %6d ) ", lc); 
+  s.PutLine(buf);
+  s.PutBytes(comment.c_str(), lc);
+  }
+s.PutLine("----Variable-List---------------");
+ValList::const_iterator it;
+for(it = mvlist.begin(); it != mvlist.end(); it++)  {
+  switch ((*it).second.typ) 
+    {
+    case 'I' :
+      sprintf(buf,"I %s %d", (*it).first.substr(0,64).c_str(), (*it).second.mtv.iv );
+      s.PutLine(buf); 
+      break;
+    case 'D' : 
+      sprintf(buf,"D %s %.20g", (*it).first.substr(0,64).c_str(), (*it).second.mtv.dv );
+      s.PutLine(buf); 
+      break;
+    case 'S' : 
+      sprintf(buf,"S %s %s", (*it).first.substr(0,64).c_str(), (*it).second.mtv.strv );
+      s.PutLine(buf); 
+      break;
+    default :
+      break;
+    }
+  }
+
+s.PutLine("ZZZZZ--End-of-Varible-List------");
+}
+
+/* --Methode-- */
+void        DVList::ReadSelf(PInPersist& s)
+{
+char buf[320];
+int_4 j,iv;
+double dv;
+bool ok=true;
+buf[0] = '\0';
+Clear();
+
+s.GetLine(buf, 319);  // Pour lire les "------- "
+if (buf[0] != '-') {  // Il y a un champ commentaire a lire 
+  buf[18] ='\0';
+  int lc = atoi(buf+11);
+  if (lc > 319)  { 
+    cerr << "DVList::ReadSelf() Pb/Bug ??  CommentLength= " << lc << endl;
+    lc = 319;
+    }
+  s.GetBytes(buf, lc);
+  buf[lc] ='\0';
+  comment = buf;
+  }
+
+while(ok) {
+  s.GetLine(buf, 319);
+  buf[319] = '\0';
+  if (strncmp(buf,"ZZZZZ",5) == 0)  { ok=false; break; }
+  j = posc(buf+2, ' ')+2;
+  buf[j] = '\0';
+  switch (buf[0])
+    {
+    case 'I' :
+      iv = (int_4)atol(buf+j+1);
+      SetI(buf+2, iv);
+      break;
+    case 'D' :
+      dv = atof(buf+j+1);
+      SetD(buf+2, dv);
+      break;
+    case 'S' :
+      SetS(buf+2, buf+j+1);
+      break;
+    default :
+      break;
+    }
+  } 
+
+}
+
+//++
+// Titre	Exemples
+//	Utilisation des objets *MuTyV* :
+//|	MuTyV mvu;         // Declaration d'une variable 
+//|	mvu = 60;          // mvu est de type entier (= 60)
+//|	mvu = 66.6;        // et double (= 66.6) maintenant ...   
+//|	MuTyV mvi(14);     // On construit une variable entiere = 14
+//|	float x = mvi;     // x vaut 14.0
+//|	MuTyV mvd(44.4);   // Variable double = 44.4
+//|	int k = mvd;       // k vaut 44  
+//|	MuTyV mvs("Bonjour, Ca va ?");   // Variable chaine de caracteres 
+//|	string s = mvs;    // s vaut "Bonjour, Ca va ?"  
+//	Utilisation des *DVList* :		 
+//|	DVList  dvl;
+//|	dvl("toto") = 14;
+//|	dvl("titi") = 25.5;
+//|	dvl("tata") = "Bonjour, Ca va ?";
+//	Majuscules et minuscules sont differenciees pour les noms, pas de blanc ...
+//|	dvl("hello") = 88;
+//|	dvl("Hello") = 77.77;
+//|	dvl.Comment() = "Test d'objet DVList, avec variables hello, Hello ";
+//|	dvl.Write("dvlist.ppf");
+//	Plus loin, ou dans un autre programme, on relit le fichier fabrique plus haut 
+//|	DVList dvlr("dvlist.ppf");
+//|	int k = dvlr["toto"] ;     //  k = 14
+//|	double b = dvlr["titi"] ;  //  b = 25.5
+//|	string s =  dvlr["tata"] ; //  s = "Bonjour, Ca va ?"
+//|	float c = dvlr["Hello"] ;  //  c = 77.77
+//|	int l =  dvlr["Hello"] ;   //  l = 77
+//|	int m =  dvlr["hello"] ;   //  m = 88
+//--
Index: /tags/DPC_V0/SophyaLib/NTools/dvlist.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/dvlist.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/dvlist.h	(revision 1307)
@@ -0,0 +1,118 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe DVList : Liste dynamique de variables (valeurs) 
+// identifiees par un nom    Reza Ansari - Dec 96
+
+#ifndef DVLIST_H_SEEN
+#define DVLIST_H_SEEN
+
+#include "ppersist.h"
+
+#include <stdio.h>
+
+#include <iostream.h>
+
+#include <list>
+#include <map>
+#include <string.h>
+#include <string>
+#if defined(__KCC__)
+using std::string ;
+#include <list.h>
+#include <map.h>
+#endif
+
+// Classe utilitaire pour manipuler des variables typees 
+class MuTyV {
+public:
+  union {
+  int_4 iv;
+  double dv;
+  char strv[31];
+  } mtv; 
+  char typ;
+
+  static char myStrBuf[64];  
+
+  inline MuTyV() { typ = 'I'; mtv.iv = 0;  mtv.dv = 0.;  mtv.strv[0] ='\0'; }
+  inline MuTyV(int_4 i) { typ = 'I'; mtv.iv = i; mtv.dv = 0.;  mtv.strv[0] ='\0'; }
+  inline MuTyV(float f) { typ = 'D'; mtv.dv = (double)f;  mtv.iv = 0;  mtv.strv[0] ='\0'; }
+  inline MuTyV(double d) { typ = 'D'; mtv.dv = d; mtv.iv = 0;  mtv.strv[0] ='\0'; }
+  inline MuTyV(char const* s)  { typ = 'S'; strncpy(mtv.strv, s, 31); mtv.strv[30] = '\0'; mtv.iv = 0; mtv.dv = 0.; }
+  inline MuTyV(string const& s) { typ = 'S'; strncpy(mtv.strv, s.c_str(), 31); mtv.strv[30] = '\0'; mtv.iv = 0; mtv.dv = 0.; }
+  inline int_4  operator= (int_4 v)  { typ = 'I'; mtv.iv = v; return(v); }
+  inline float  operator= (float v)  { typ = 'D'; mtv.dv = (double)v; return(v); }
+  inline double operator= (double v) { typ = 'D'; mtv.dv = v; return(v); }
+  inline char*  operator= (char* s)  { typ = 'S'; strncpy(mtv.strv, s, 31); 
+                                       mtv.strv[30] = '\0';  return(s); }
+  inline string& operator= (string& s)    { typ = 'S'; strncpy(mtv.strv, s.c_str(), 31); 
+                                            mtv.strv[30] = '\0'; return(s); }
+
+  inline operator int_4() { if (typ == 'I')  return(mtv.iv);
+                            else if (typ == 'D') return((int_4)mtv.dv); 
+                            else return(atol(mtv.strv)); }
+  inline operator float() { if (typ == 'I')  return((float)mtv.iv);
+                            else if (typ == 'D') return((float)mtv.dv); 
+                            else return((float)atof(mtv.strv)); }
+  inline operator double() { if (typ == 'I')  return((double)mtv.iv);
+                            else if (typ == 'D') return(mtv.dv); 
+                            else return(atof(mtv.strv)); }
+  inline operator string() { char *ss=myStrBuf;
+                            if (typ == 'I')  sprintf(ss,"%d", mtv.iv);
+                            else if (typ == 'D') sprintf(ss,"%.20g", mtv.dv);
+                            else ss = mtv.strv;
+                            return(ss); }
+};
+
+//  Classe liste de variables  Dynamic Variable List  
+
+class DVList : public PPersist {
+public:
+  enum {classId = ClassId_DVList };
+
+                    DVList();
+                    DVList(DVList&);
+                    DVList(char *flnm);
+
+  virtual           ~DVList();
+
+  DVList&           operator= (const DVList&);
+
+  void              Clear();
+  DVList&           Merge(const DVList&);
+
+  int_4             GetI(string const& key, int_4 def=-1);
+  double            GetD(string const& key, double def=-9.e19);
+  string            GetS(string const& key, char* def="");
+
+  void              SetI(string const& key, int_4 val);
+  void              SetD(string const& key, double val);
+  void              SetS(string const& key, char const*  val);
+  void              SetS(string const& key, string val);
+
+  MuTyV&            Get(string const& key);
+  inline MuTyV&     operator()  (string const& key)  { return Get(key); }
+  inline MuTyV&     operator[]  (string const& key)  { return Get(key); }
+  inline string&    Comment() { return(comment); }
+
+  inline void       Print() const  { Print(cout); }  
+  virtual void      Print(ostream& os)  const;
+  
+  int_4             ClassId() const        { return classId; }
+  static PPersist*  Create()               { return new DVList;}
+
+  virtual void      WriteSelf(POutPersist&) const;
+  virtual void      ReadSelf(PInPersist&);
+
+private:
+  typedef map<string, MuTyV, less<string> >  ValList; 
+  
+  ValList mvlist;
+  string comment;
+};
+
+inline ostream& operator << (ostream& s, DVList const & dvl)
+  {  dvl.Print(s);  return(s);  }
+
+#endif /* DVLIST_H__SEEN */
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/dynccd.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/dynccd.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/dynccd.cc	(revision 1307)
@@ -0,0 +1,388 @@
+#include "defs.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "fmath.h"
+#include "perandom.h"
+
+#include "cimage.h"
+
+#include "dynccd.h"
+
+//++
+// Class	DynCCD
+// Lib		Images++ 
+// include	dynccd.h
+// 
+//	Cette classe permet la specification des parametres 
+//	definissant la dynamique du CCD, et doit etre utilise
+//      pour le calcul des images de bruit.
+//	- TypNoise = 1 :
+//	Bruit = Sqrt( (RONoise/Gain)**2 + ValPix/Gain )      
+//	- TypNoise = 2 :                                     
+//	Bruit = Sqrt( RefSFond**2 + (ValPix-RefFond)/Gain )  
+//	- TypNoise = 0 
+//	Bruit = 1  (Constant pour tous les pixels) 
+//	- TypNoise = 3         
+//	Bruit = Sqrt(Abs(ValPix)) 
+//
+//	Les pixels hors dynamique sont marques (Bruit = 0)
+//	( < MinADU ou > MaxADU) pour toutes valeurs de TypNoise.
+//	Gain est exprime en electron par ADU, RONoise en electron,
+//	Bruit, ValPix et RefFond en ADU.
+//--
+
+//++
+// Links	Parents
+// PPersist
+//--
+//++
+// Links	Autres
+// RzImage
+// Image<T> 
+//--
+//++
+// Titre	Methodes
+//--
+//++
+// DynCCD(int TypNoise=0, float MinADU=-9.e19, float MaxADU=9.e19, float Gain=1., float RONoise=0., float RefFond=0., float RefSFond=0.);
+//	Creation d'un objet DynCCD ("typ" determine la methode de calcul du bruit)
+//	|Test verbatim 
+//
+// void Set(int TypNoise=0, float MinADU=-9.e19, float MaxADU=9.e19, float Gain=1., float RONoise=0., float RefFond=0., float RefSFond=0.);
+//	Modification des parametres de la dynamique
+// void Print()
+// float Noise(float pixel) const
+//	Renvoie la valeur du bruit pour "pixel" en ADU.
+//--
+
+/* ............................................................ */
+/* :::::::::::::  methode de la classe  DynCCD :::::::::::::::: */
+/* ............................................................ */
+
+/* --Methode-- */
+DynCCD::DynCCD(int typ, float min, float max, float g,
+               float ron, float rf, float rfs)
+{
+if ( (typ >= kConstantNoise) && (typ <= kSqrtADUNoise) )  TypNoise = typ;
+else  TypNoise = kConstantNoise;
+MinADU = min;  MaxADU = max;
+Gain = g;  RONoise = ron;
+RefFond = rf;  RefSFond = rfs;
+}
+
+/* --Methode-- */
+void DynCCD::Set(int typ, float min, float max, float g,
+               float ron, float rf, float rfs)
+{
+if ( (typ >= kConstantNoise) && (typ <= kSqrtADUNoise) )  TypNoise = typ;
+MinADU = min;  MaxADU = max;
+Gain = g;  RONoise = ron;
+RefFond = rf;  RefSFond = rfs;
+}
+
+/* --Methode-- */
+void DynCCD::Print()
+{
+printf("DynCCD: Type= %d Min/MaxADU= %g %g Gain/RoN= %g %g\n",
+       TypNoise, MinADU, MaxADU, Gain, RONoise);
+if (TypNoise == 2)
+  printf("... RefFond= %g  RefSFond= %g \n", RefFond, RefSFond);
+return;
+}
+
+/* --Methode-- */
+float DynCCD::Noise(float pixel) const
+
+/* Cette fonction calcule la valeur du bruit pour pixel     */
+/*  Si TypNoise = 1 :                                       */
+/*     Bruit = Sqrt( (RONoise/Gain)**2 + ValPix/Gain )      */
+/*  Si TypNoise = 2 :                                       */
+/*     Bruit = Sqrt( RefSFond**2 + (ValPix-RefFond)/Gain )  */
+/*  Si TypNoise = 0                                         */
+/*     Bruit = 1  (Constant pour tous les pixels)           */
+/*  Si TypNoise = 3                                         */
+/*     Bruit = Sqrt(Abs(PixelADU))                          */
+/*  Les pixels hors dynamique sont marques (Bruit = 0)      */
+/*  ( < MinADU ou > MaxADU) pour tout valeur de TypNoise    */
+
+{
+float h,s,ronsq;
+float fond;
+
+if ( (pixel > MaxADU) || (pixel < MinADU) )   return(0.);
+if ( TypNoise == kConstantNoise)  return(1.);
+if ( TypNoise == kSqrtADUNoise )  return(fsqrt(fabsf(pixel)));
+
+if ( TypNoise == kSigFondNoise)
+  { fond = RefFond;
+  ronsq = RefSFond * RefSFond; }
+else
+  { fond = 0;
+  ronsq = RONoise/Gain;  ronsq *= ronsq; }
+
+h = (pixel>fond) ? (float)(pixel-fond) : 0.;
+s = ronsq+h/Gain;
+s = fsqrt(s);
+return(s);
+}
+
+/* --------------------------------------------------------------  */
+/*      Quelques fonctions pour manipuler des images de bruit      */
+/* --------------------------------------------------------------  */
+
+//++
+// Module	Images de bruit 
+// Lib		Images++ 
+// include	dynccd.h
+//
+//	Ces fonctions permettent le calcul d'image de bruit a partir d'une 
+//	image (RzImage ou Image<T>) et d'un objet DynCCD 
+//--
+//++
+// Links 	Voir classes
+// DynCCD
+// RzImage
+// Image<T>
+//--
+//++
+// Titre	Les fonctions 
+//--
+
+//++
+// Function	RzImage * NoiseImage(RzImage const *pim, DynCCD const * dynccd)
+//	Construit et renvoie l'image du bruit pour l'image "*pim" (RzImage)
+// Function	Image<T> * NoiseImage(Image<T> const * pim, DynCCD const * dynccd)
+//      Meme fonctionalite pour une image typee (ImageU2, ImageR4, ...)
+// Function	ImgAddNoise(Image<T>&, DynCCD const&)
+//	Calcule l'image du bruit et le rajoute a l'image originale
+//--
+
+/* Nouvelle-Fonction */
+template <class T>
+Image<T> * NoiseImage(Image<T> const * pim, DynCCD const * dynccd)
+
+/* Creation et Calcul d'une image de bruit a partir de l'image */
+/* pim et de dynccd. Voir la methode DynCCD::Noise() pour la   */
+/* description du calcul                                       */
+
+{
+float h,s,ronsq;
+float fond, min,max;
+int i, npix;
+float minois, offnois;
+
+if (pim == NULL)  return(NULL);
+
+const T * pix = pim->ImagePtr();
+npix = pim->XSize()*pim->YSize();
+Image<T> * nois = new Image<T>(pim->XSize(), pim->YSize(), false);
+nois->SetOrg(pim->XOrg(), pim->YOrg());
+T * pno = nois->ImagePtr();
+
+min = dynccd->MinADU;   max = dynccd->MaxADU;
+
+
+switch (dynccd->TypNoise)
+  {
+  case kConstantNoise :
+    for(i=0; i<npix; i++)
+      {
+      if ( (*pix <= max) && (*pix >= min) )  *pno = 1;
+      else *pno = 0;
+      pix++;   pno++;
+      }
+    break;
+
+  case kSqrtADUNoise :
+    for(i=0; i<npix; i++)
+      {
+      if ( (*pix <= max) && (*pix >= min) )  *pno = 1;
+      else *pno = (T) fsqrt(fabsf((float)(*pix)));    
+      pix++;   pno++;
+      }
+    break;
+
+  case kPhotonNoise :
+  case kSigFondNoise :
+    if ( dynccd->TypNoise == kSigFondNoise)
+      { fond = dynccd->RefFond;
+      ronsq = dynccd->RefSFond * dynccd->RefSFond; }
+    else
+      { fond = 0;
+      ronsq = dynccd->RONoise/dynccd->Gain;  ronsq *= ronsq; }
+
+// Calcul de minois / offnois pour obtenir un bruit correct malgre 
+// les conversions (float) -> (entier)
+
+    switch(pim->PixelType())
+      {
+      case kuint_2:
+      case kint_2:
+      case kint_4:
+        minois = 1.001;
+        offnois = 0.5;
+        break;
+      case kr_4:
+      case kr_8:
+        minois = 1.e-9;
+        offnois = 0.;
+        break;
+      default:
+        minois = 1.e-9;
+        offnois = 0.;
+        break;
+      }
+
+    for(i=0; i<npix; i++)
+      {
+      if ( (*pix <= max) && (*pix >= min) ) 
+        {
+        h = (*pix>fond) ? (float)(*pix)-fond : 0.;
+        s = ronsq+h/dynccd->Gain;
+        s = fsqrt(s)+offnois;
+        *pno = (s > minois) ? (T)s : (T)minois;
+        } 
+      else *pno = 0;
+      pix++;   pno++;
+      }
+    break;
+  }
+
+return(nois);
+}
+
+
+/* Nouvelle-Fonction */
+template <class T>
+void ImgAddNoise(Image<T>& img, DynCCD const& dyn)
+{
+	T* p = img.ImagePtr();
+	int nPix = img.XSize() * img.YSize();
+	
+	for (int i=0; i<nPix; i++, p++)
+		*p += (T) (dyn.Noise(*p)*NorRand());
+}
+
+
+
+/* Nouvelle-Fonction */
+RzImage * NoiseImage(RzImage const * pim, DynCCD const * dynccd)
+
+/* Creation et Calcul d'une image de bruit a partir de l'image */
+/* pim et de dynccd. Voir la methode DynCCD::Noise() pour la   */
+/* description du calcul                                       */
+{
+RzImage * nois = NULL;
+
+switch (pim->PixelType()) 
+  {
+  case kuint_2: 
+    {
+    ImageU2 pix((RzImage&)(*pim));
+    nois = NoiseImage(&pix, dynccd);
+    break;
+    }
+  case kint_2:
+    {
+    ImageI2 pix((RzImage&)(*pim));
+    nois = NoiseImage(&pix, dynccd);
+    break;
+    }
+  case kint_4:
+    {
+    ImageI4 pix((RzImage&)(*pim));
+    nois = NoiseImage(&pix, dynccd);
+    break;
+    }
+  case kr_4:
+    {
+    ImageR4 pix((RzImage&)(*pim));
+    nois = NoiseImage(&pix, dynccd);
+    break;
+    }  
+  case kuint_4:
+  case kr_8:
+    cerr << "NoiseImage(RzImage, ...) Unsupported image type (kuint_4/kr_8) " 
+         << int(pim->PixelType()) << "\n" ; 
+    break;
+  default:
+    cerr << "NoiseImage(RzImage, ...) Unknown image type !! " << int(pim->PixelType()) << "\n" ;
+    break;
+  }   
+
+return(nois);
+}
+
+
+// ******** INSTANCES
+
+#if defined(__xlC) || defined(__aCC__)
+void instancetempdynccd(int n)
+{
+/* Cette fonction sert uniquement a forcer le compilo a instancier les
+  classes/fonctions template   */
+
+ImageU2  iu2(n,n), *piu2;
+ImageI2  ii2(n,n), *pii2;
+ImageI4  ii4(n,n), *pii4;
+ImageR4  ir4(n,n), *pir4;
+DynCCD dyn(1,0.,65000., 4., 20.);
+
+piu2 = NoiseImage(&iu2, &dyn);
+pii2 = NoiseImage(&ii2, &dyn);
+pii4 = NoiseImage(&ii4, &dyn);
+pir4 = NoiseImage(&ir4, &dyn);
+
+ImgAddNoise(*piu2, dyn);
+ImgAddNoise(*pii2, dyn);
+ImgAddNoise(*pii4, dyn);
+ImgAddNoise(*pir4, dyn);
+
+return;
+}
+#endif
+
+
+#ifdef __CXX_PRAGMA_TEMPLATES__
+
+#pragma define_template NoiseImage<uint_2>
+#pragma define_template NoiseImage<int_2>
+#pragma define_template NoiseImage<int_4>
+#pragma define_template NoiseImage<r_4>
+
+#pragma define_template ImgAddNoise<uint_2>
+#pragma define_template ImgAddNoise<int_2>
+#pragma define_template ImgAddNoise<int_4>
+#pragma define_template ImgAddNoise<r_4>
+
+#endif
+
+
+#if ( defined(__ANSI_TEMPLATES__) && !defined(__aCC__) )
+template Image<uint_2> * NoiseImage<uint_2>(Image<uint_2> const * , DynCCD const *);
+template Image< int_2> * NoiseImage< int_2>(Image< int_2> const * , DynCCD const *);
+template Image< int_4> * NoiseImage< int_4>(Image< int_4> const * , DynCCD const *);
+template Image<   r_4> * NoiseImage<   r_4>(Image<   r_4> const * , DynCCD const *);
+
+template void ImgAddNoise<uint_2>(Image<uint_2>&, DynCCD const&);
+template void ImgAddNoise< int_2>(Image< int_2>&, DynCCD const&);
+template void ImgAddNoise< int_4>(Image< int_4>&, DynCCD const&);
+template void ImgAddNoise<   r_4>(Image<   r_4>&, DynCCD const&);
+
+#endif
+
+#if defined(__GNU_TEMPLATES__)
+template Image<uint_2> * NoiseImage(Image<uint_2> const *, DynCCD const *);
+template Image< int_2> * NoiseImage(Image< int_2> const *, DynCCD const *);
+template Image< int_4> * NoiseImage(Image< int_4> const *, DynCCD const *);
+template Image<   r_4> * NoiseImage(Image<   r_4> const *, DynCCD const *);
+
+template void ImgAddNoise(Image<uint_2>&, DynCCD const&);
+template void ImgAddNoise(Image< int_2>&, DynCCD const&);
+template void ImgAddNoise(Image< int_4>&, DynCCD const&);
+template void ImgAddNoise(Image<   r_4>&, DynCCD const&);
+
+#endif
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/dynccd.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/dynccd.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/dynccd.h	(revision 1307)
@@ -0,0 +1,65 @@
+/*  Caracteristique du CCD      Reza  03/95  -*- C++ -*- */
+
+#ifndef DYNCCD_H_SEEN
+#define DYNCCD_H_SEEN
+
+#include "machine.h"
+#include "exceptions.h"
+#include "ppersist.h"
+
+enum {kConstantNoise = 0, kPhotonNoise, kSigFondNoise, kSqrtADUNoise};
+
+class DynCCD EXC_AWARE
+{
+  public :
+
+  int_4 TypNoise;        // Type de calcul du bruit 
+  float MinADU,MaxADU;   // Valeur min et max des pixels 
+  float Gain;            // Gain en electron/ADU 
+  float RONoise;         // Bruit de lecture en electron  
+  float RefFond;         // Fond de ciel de ref (TypNoise=2) 
+  float RefSFond;        // Sigma du fond  (TypNoise=2) */
+
+/*    ===>  Les methodes   */
+  DynCCD(int typ=0, float min=-9.e19, float max=9.e19,
+         float g=1., float ron=0., float rf=0., float rfs=0.);
+
+  void Set(int typ=0, float min=-9.e19, float max=9.e19,
+         float g=1., float ron=0., float rf=0., float rfs=0.);
+  void Print();
+  float Noise(float pixel) const;
+};
+
+// Quelques fonctions pour manipuler des images de bruit
+
+class RzImage;
+RzImage * NoiseImage(RzImage const *pim, DynCCD const * dynccd);
+
+template <class T> class Image;
+
+template <class T>
+Image<T> * NoiseImage(Image<T> const * pim, DynCCD const * dynccd);
+
+template <class T>
+void ImgAddNoise(Image<T>&, DynCCD const&);
+
+// Les entrees-sortie
+
+inline POutPersist& operator << (POutPersist& c, DynCCD const& data)
+{
+  c.PutI4(data.TypNoise);
+  c.PutR4s(&data.MinADU, 6);
+  return c;
+}
+
+inline 
+PInPersist& operator >> (PInPersist& c, DynCCD& data)
+{
+  c.GetI4(data.TypNoise);
+  c.GetR4s(&data.MinADU, 6);
+  return c;
+}
+
+//STRUCTPERSISTIO(DynCCD, TypNoise, sizeof(int_4)+6*sizeof(float))
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/fct1dfit.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/fct1dfit.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/fct1dfit.cc	(revision 1307)
@@ -0,0 +1,536 @@
+#include "defs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <math.h>
+#include "fct1dfit.h"
+#include "perrors.h"
+#include "nbconst.h"
+#include "tabmath.h"
+
+//define EXPO exp
+#define EXPO tabFExp
+#define MINEXPM (100.)
+
+//================================================================
+// CLASSES DE FONCTIONS 1D AVEC PARAMETRES POUR LE FIT
+//================================================================
+
+/////////////////////////////////////////////////////////////////
+//++ 
+// Module	Classes de fonctions 1D
+// Lib	Outils++ 
+// include	fct1dfit.h
+//--
+/////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Gauss1DPol
+// \index{Gauss1DPol}
+//
+//|  Gaussienne+polynome:
+//|  Si polcenter=true: xc=(x-par[1]), sinon xc=x
+//|  f(x) = par[0]*exp[-0.5*( (x-par[1]) / par[2] )**2 ]
+//|        +par[3] + par[4]*xc + .... + par[3+NDegPol]*xc**NDegPol
+//|  NDegPol = degre du polynome, si <0 pas de polynome
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+Gauss1DPol::Gauss1DPol(unsigned int ndegpol,bool polcenter)
+//
+//	Createur.
+//--
+: GeneralFunction(1,ndegpol+4), NDegPol(ndegpol), PolCenter(polcenter)
+{
+}
+
+//++
+Gauss1DPol::Gauss1DPol(bool polcenter)
+//
+//	Createur.
+//--
+: GeneralFunction(1,3), NDegPol(-1), PolCenter(polcenter)
+{
+}
+
+Gauss1DPol::~Gauss1DPol()
+{
+}
+
+double Gauss1DPol::Value(double const xp[], double const* Par)
+{
+double xc = (xp[0]-Par[1])/Par[2];
+double e = 0.5*xc*xc;
+if( e<MINEXPM ) e = EXPO(-e); else e = 0.;
+double f = Par[0]*e;
+
+if(NDegPol>=0) {
+  double xcp = (PolCenter) ? Par[1] : 0.;
+  double xpow = 1.;
+  for(int i=0;i<=NDegPol;i++) {
+    f += Par[3+i]*xpow;
+    xpow *= xp[0]-xcp;
+  }
+}
+return (f);
+}
+
+double Gauss1DPol::Val_Der(double const xp[],double const* Par
+                          ,double *DgDpar)
+{
+
+ double xc = (xp[0]-Par[1])/Par[2];
+ double xc2 = xc*xc;
+ double e = 0.5*xc2;
+ if( e<MINEXPM ) e = EXPO(-e); else e = 0.;
+ double f = Par[0]*e;
+
+ DgDpar[0] = e;
+ DgDpar[1] = xc / Par[2] *f;
+ DgDpar[2] = xc2/ Par[2] *f;
+
+ if(NDegPol>=0) {
+   double xcp = (PolCenter) ? Par[1] : 0.;
+   double xpow = 1.;
+   for(int i=0;i<=NDegPol;i++) {
+     DgDpar[3+i] = xpow;
+     f += Par[3+i]*xpow;
+     if(PolCenter && i<NDegPol) DgDpar[2] += -(i+1)*xpow*Par[4+i];
+     xpow *= xp[0]-xcp;
+   }
+ }
+return f;
+}
+
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	GaussN1DPol
+// \index{GaussN1DPol}
+//
+//| Gaussienne_Normalisee+polynome (par[0]=Volume:
+//|  Si polcenter=true: xc=(x-par[1]), sinon xc=x
+//|  f(x) = par[0]/(sqrt(2*Pi)*par[2])*exp[-0.5*((x-par[1])/par[2])**2 ]
+//|        +par[3] + par[4]*xc + .... + par[3+NDegPol]*xc**NDegPol
+//|  NDegPol = degre du polynome, si <0 pas de polynome
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+GaussN1DPol::GaussN1DPol(unsigned int ndegpol,bool polcenter)
+//
+//	Createur.
+//--
+: GeneralFunction(1,ndegpol+4), NDegPol(ndegpol), PolCenter(polcenter)
+{
+}
+
+//++
+GaussN1DPol::GaussN1DPol(bool polcenter)
+//
+//	Createur.
+//--
+: GeneralFunction(1,3), NDegPol(-1), PolCenter(polcenter)
+{
+}
+
+GaussN1DPol::~GaussN1DPol()
+{
+}
+
+double GaussN1DPol::Value(double const xp[], double const* Par)
+{
+ double xc = (xp[0]-Par[1])/Par[2];
+ double xc2 = xc*xc;
+ double e = 0.5*xc2;
+ if( e<MINEXPM ) e = EXPO(-e)/(S2Pi*Par[2]); else e = 0.;
+ double f = Par[0]*e;
+
+ if(NDegPol>=0) {
+   double xcp = (PolCenter) ? Par[1] : 0.;
+   double xpow = 1.;
+   for(int i=0;i<=NDegPol;i++) {
+     f += Par[3+i]*xpow;
+     xpow *= xp[0]-xcp;
+   }
+ }
+
+return (f);
+}
+
+double GaussN1DPol::Val_Der(double const xp[], double const* Par
+                           , double *DgDpar)
+{
+ double xc = (xp[0]-Par[1])/Par[2];
+ double xc2 = xc*xc;
+ double e = 0.5*xc2;
+ if( e<MINEXPM ) e = EXPO(-e)/(S2Pi*Par[2]); else e = 0.;
+ double f = Par[0]*e;
+
+ DgDpar[0] = e;
+ DgDpar[1] = xc / Par[2] *f;
+ DgDpar[2] = (xc2-1.)/ Par[2] *f;
+
+ if(NDegPol>=0) {
+   double xcp = (PolCenter) ? Par[1] : 0.;
+   double xpow = 1.;
+   for(int i=0;i<=NDegPol;i++) {
+     DgDpar[3+i] = xpow;
+     f += Par[3+i]*xpow;
+     if(PolCenter && i<NDegPol) DgDpar[2] += -(i+1)*xpow*Par[4+i];
+     xpow *= xp[0]-xcp;
+   }
+ }
+
+ return f;
+}
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Exp1DPol
+// \index{Exp1DPol}
+//
+//|  Exponentielle+polynome:
+//|  xx = x - X_Center
+//|  f(x) = exp[par[0]+par[1]*xx]
+//|        +par[2] + par[3]*xx + .... + par[2+NDegPol]*xx**NDegPol
+//|  NDegPol = degre du polynome, si <0 pas de polynome
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+Exp1DPol::Exp1DPol(unsigned int ndegpol,double x0)
+//
+//	Createur.
+//--
+: GeneralFunction(1,ndegpol+3), NDegPol(ndegpol), X_Center(x0)
+{
+}
+
+//++
+Exp1DPol::Exp1DPol(double x0)
+//
+//	Createur.
+//--
+: GeneralFunction(1,2), NDegPol(-1), X_Center(x0)
+{
+}
+
+Exp1DPol::~Exp1DPol()
+{
+}
+
+double Exp1DPol::Value(double const xp[], double const* Par)
+{
+double xc = Par[0]+Par[1]*(xp[0]-X_Center);
+double f = ( xc>-MINEXPM ) ? EXPO(xc): 0.;
+
+if(NDegPol>=0) {
+  double xpow = 1.;
+  for(int i=0;i<=NDegPol;i++) {
+    f += Par[2+i]*xpow;
+    xpow *= xp[0]-X_Center;
+  }
+}
+return (f);
+}
+
+double Exp1DPol::Val_Der(double const xp[],double const* Par
+                          ,double *DgDpar)
+{
+double xc = Par[0]+Par[1]*(xp[0]-X_Center);
+double f = ( xc>-MINEXPM ) ? EXPO(xc): 0.;
+
+DgDpar[0] = f;
+DgDpar[1] = (xp[0]-X_Center) * f;
+
+if(NDegPol>=0) {
+  double xpow = 1.;
+  for(int i=0;i<=NDegPol;i++) {
+    DgDpar[2+i] = xpow;
+    f += Par[2+i]*xpow;
+    xpow *= xp[0]-X_Center;
+  }
+}
+return f;
+}
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Polyn1D
+// \index{Polyn1D}
+//
+//| polynome 1D:
+//|  xx = x - X_Center
+//|  f(x) = par[0] + par[1]*xx + .... + par[NDegPol+1]*xx**NDegPol
+//|  NDegPol = degre du polynome
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+Polyn1D::Polyn1D(unsigned int ndegpol,double x0)
+//
+//	Createur.
+//--
+: GeneralFunction(1,ndegpol+1), NDegPol(ndegpol), X_Center(x0)
+{
+}
+
+Polyn1D::~Polyn1D()
+{
+}
+
+double Polyn1D::Value(double const xp[], double const* Par)
+{
+ double xpow = 1.;
+ double f = 0.;
+ for(int i=0;i<=NDegPol;i++) {
+   f += Par[i]*xpow;
+   xpow *= xp[0]-X_Center;
+ }
+ return (f);
+}
+
+double Polyn1D::Val_Der(double const xp[], double const* Par
+                       , double *DgDpar)
+{
+ double xpow = 1.;
+ double f = 0.;
+ for(int i=0;i<=NDegPol;i++) {
+   DgDpar[i] = xpow;
+   f += Par[i]*xpow;
+   xpow *= xp[0]-X_Center;
+ }
+ return f;
+}
+
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	HarmonieNu
+// \index{HarmonieNu}
+//
+//| Analyse harmonique:
+//|  f(t) = par(1) + Sum[par(2k)  *cos(2*pi*k*par(0)*(t-t0)]
+//|                + Sum[par(2k+1)*sin(2*pi*k*par(0)*(t-t0)]
+//|  la somme Sum porte sur l'indice k qui varie de [1,NHarm()+1]
+//|  avec la convention   k=1  pour le fondamental
+//|                       k>1  pour le (k-1)ieme harmonique
+//--
+//++
+//|  par(0) = inverse de la periode (frequence)
+//|  par(1) = terme constant
+//|  par(2), par(3) = termes devant le cosinus et le sinus
+//|                   du fondamental
+//|  par(2(m+1)), par(2(m+1)+1) = termes devant le cosinus
+//|                   et le sinus de l'harmonique m (m>=1).
+//|  NHarm() = nombre d'harmoniques a fitter.
+//|  T0() = centrage des temps, ce n'est pas un parametre du fit.
+//	`Conseil:' Avant de faire un fit avec les `NHarm()'
+//	harmoniques, il est preferable de faire un pre-fit
+//	ou seuls les parametres 1,2 et 3 sont libres et d'injecter
+//	le resultat du fit sur ces 3 parametres comme valeurs
+//	de depart pour le fit global avec les `NHarm()' harmoniques.
+//	De toute facon, le fit ne marchera que si la periode
+//	est initialisee de facon tres precise.
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+HarmonieNu::HarmonieNu(unsigned int nharm,double t0)
+//
+//	Createur.
+//--
+: GeneralFunction(1,4+2*nharm), NHarm(nharm), T0(t0)
+{
+}
+
+HarmonieNu::~HarmonieNu()
+{
+}
+
+double HarmonieNu::Value(double const xp[], double const* Par)
+{
+ double a = 2.*Pi*(xp[0]-T0)*Par[0];
+ double f = Par[1];
+ for(int k=1;k<=NHarm+1;k++) {
+   // k=1 fondamental, k=2 a NHarm+1 harmoniques numero 1 a NHarm
+   f += Par[2*k]*cos(k*a) + Par[2*k+1]*sin(k*a);
+ }
+ return f;
+}
+
+double HarmonieNu::Val_Der(double const xp[], double const* Par
+                        , double *DgDpar)
+{
+ double cs,sn;
+ double dadp0 = 2.*Pi*(xp[0]-T0);
+ double a = dadp0*Par[0];
+ double f = Par[1];
+ DgDpar[0] = 0.;
+ DgDpar[1] = 1.;
+ for(int k=1;k<=NHarm+1;k++) {
+   cs = cos(k*a); sn = sin(k*a);
+   f += Par[2*k]*cs + Par[2*k+1]*sn;
+   DgDpar[0] += k*dadp0*(-Par[2*k]*sn+Par[2*k+1]*cs);
+   DgDpar[2*k]   = cs;
+   DgDpar[2*k+1] = sn;
+ }
+ return f;
+}
+
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	HarmonieT
+// \index{HarmonieT}
+//
+//| Analyse harmonique:
+//|  f(t) = par(1) + Sum[par(2k)  *cos(2*pi*k*(t-t0)/par(0)]
+//|                + Sum[par(2k+1)*sin(2*pi*k*(t-t0)/par(0)]
+//|  la somme Sum porte sur l'indice k qui varie de [1,NHarm()+1]
+//|  avec la convention   k=1  pour le fondamental
+//|                       k>1  pour le (k-1)ieme harmonique
+//--
+//++
+//|  par(0) = periode
+//|  par(1) = terme constant
+//|  par(2), par(3) = termes devant le cosinus et le sinus
+//|                   du fondamental
+//|  par(2(m+1)), par(2(m+1)+1) = termes devant le cosinus
+//|                   et le sinus de l'harmonique m (m>=1).
+//|  NHarm() = nombre d'harmoniques a fitter.
+//|  T0() = centrage des temps, ce n'est pas un parametre du fit.
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+HarmonieT::HarmonieT(unsigned int nharm,double t0)
+//
+//	Createur.
+//--
+: GeneralFunction(1,4+2*nharm), NHarm(nharm), T0(t0)
+{
+}
+
+HarmonieT::~HarmonieT()
+{
+}
+
+double HarmonieT::Value(double const xp[], double const* Par)
+{
+ double a = 2.*Pi*(xp[0]-T0)/Par[0];
+ double f = Par[1];
+ for(int k=1;k<=NHarm+1;k++) {
+   // k=1 fondamental, k=2 a NHarm+1 harmoniques numero 1 a NHarm
+   f += Par[2*k]*cos(k*a) + Par[2*k+1]*sin(k*a);
+ }
+ return f;
+}
+
+double HarmonieT::Val_Der(double const xp[], double const* Par
+                        , double *DgDpar)
+{
+ double cs,sn;
+ double dadp0 = 2.*Pi*(xp[0]-T0);
+ double a = dadp0/Par[0];
+ double f = Par[1];
+ DgDpar[0] = 0.;
+ DgDpar[1] = 1.;
+ for(int k=1;k<=NHarm+1;k++) {
+   cs = cos(k*a); sn = sin(k*a);
+   f += Par[2*k]*cs + Par[2*k+1]*sn;
+   DgDpar[0] += k*dadp0*(-Par[2*k]*sn+Par[2*k+1]*cs)/(-Par[0]*Par[0]);
+   DgDpar[2*k]   = cs;
+   DgDpar[2*k+1] = sn;
+ }
+ return f;
+}
+
+//================================================================
+// CLASSES DE FONCTIONS 2D AVEC PARAMETRES POUR LE FIT
+//================================================================
+
+/////////////////////////////////////////////////////////////////
+//++ 
+// Module	Classes de fonctions 2D
+// Lib	Outils++ 
+// include	fct1dfit.h
+//--
+/////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Polyn2D
+// \index{Polyn2D}
+//
+//| polynome 2D de degre total degre:
+//|  NDegPol = degre du polynome (note N dans la suite)
+//|  x = x - X_Center,  y = y - Y_Center
+//|  f(x,y) = p[0] +sum(k=1,n){ sum(i=0,k){ p[ki]*x^i*y^(k-i) }}
+//|  Il y a k+1 termes de degre k  (ex: x^i*y^(k-i))
+//|  terme de degre k avec x^i: p[ki] avec  ki = k*(k+1)/2 + i
+//| C'est a dire:
+//| deg0:   p0
+//| deg1: + p1*y + p2*x
+//| deg2: + p3*y^2 + p4*x*y + p5*x^2
+//| deg3: + p6*y^3 + p7*x*y^2 + p8*x^2*y + p9*x^3
+//| deg4: + p10*y^4 + p11*x*y^3 + p12*x^2*y^2 + p13*x^3*y + p14*x^4
+//| deg5: + p15*y^5 + ...                       ... + ... + p20*x^5
+//| ...
+//| degk: + p[k*(k+1)/2]*y^k + ...           ... + p[k*(k+3)/2]*x^k
+//| ...
+//| degn: + p[n*(n+1)/2]*y^n + ...           ... + p[n*(n+3)/2]*x^n
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+Polyn2D::Polyn2D(unsigned int ndegpol,double x0,double y0)
+//
+//	Createur.
+//--
+: GeneralFunction(2,ndegpol*(ndegpol+3)/2+1), NDegPol(ndegpol), X_Center(x0), Y_Center(y0)
+{
+}
+
+Polyn2D::~Polyn2D()
+{
+}
+
+double Polyn2D::Value(double const xp[], double const* Par)
+{
+ double f = 0.;
+ double xpow = 1.;
+ for(int i=0;i<=NDegPol;i++) { // On gere la puissance x^i i<ndeg
+   int ip;
+   double ypow = 1.;
+   for(int j=0;j<=NDegPol-i;j++) { // On gere la puissance x^j tq degre=i+j<=ndeg
+     ip = (i+j)*(i+j+1)/2+i;
+     f += Par[ip]*xpow*ypow;
+     ypow *= xp[1]-Y_Center;
+   }
+   xpow *= xp[0]-X_Center;
+ }
+ return f;
+}
+
+double Polyn2D::Val_Der(double const xp[], double const* Par
+                       , double *DgDpar)
+{
+ double f = 0.;
+ double xpow = 1.;
+ for(int i=0;i<=NDegPol;i++) { // On gere la puissance x^i i<ndeg
+   int ip;
+   double ypow = 1.;
+   for(int j=0;j<=NDegPol-i;j++) { // On gere la puissance x^j tq degre=i+j<=ndeg
+     ip = (i+j)*(i+j+1)/2+i;
+     DgDpar[ip] = xpow*ypow;
+     f += Par[ip]*DgDpar[ip];
+     ypow *= xp[1]-Y_Center;
+   }
+   xpow *= xp[0]-X_Center;
+ }
+ return f;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/fct1dfit.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/fct1dfit.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/fct1dfit.h	(revision 1307)
@@ -0,0 +1,136 @@
+#ifndef FCT1DFIT_SEEN
+#define FCT1DFIT_SEEN
+
+#include "generalfit.h"
+
+//================================================================
+// CLASSES DE FONCTIONS 1D AVEC PARAMETRES POUR LE FIT
+//================================================================
+
+//////////////////////////////////////////////////////////////////
+class Gauss1DPol : public GeneralFunction {
+public:
+  Gauss1DPol(unsigned int ndegpol,bool polcenter=false);
+  Gauss1DPol(bool polcenter=false);
+  virtual ~Gauss1DPol();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+
+  inline int NDegP() const {return NDegPol;}
+
+protected:
+  int NDegPol;    // degre du polynome
+  bool PolCenter; // centrage du polynome
+};
+
+//////////////////////////////////////////////////////////////////
+class GaussN1DPol : public GeneralFunction {
+public:
+  GaussN1DPol(unsigned int ndegpol,bool polcenter=false);
+  GaussN1DPol(bool polcenter=false);
+  virtual ~GaussN1DPol();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+
+  inline int NDegP() const {return NDegPol;}
+
+protected:
+  int NDegPol;    // degre du polynome
+  bool PolCenter; // centrage du polynome
+};
+
+//////////////////////////////////////////////////////////////////
+class Exp1DPol : public GeneralFunction {
+public:
+  Exp1DPol(unsigned int ndegpol,double x0=0.);
+  Exp1DPol(double x0=0.);
+  virtual ~Exp1DPol();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+
+  inline int NDegP() const {return NDegPol;}
+  inline double XCenter() {return X_Center;}
+
+protected:
+  int NDegPol;     // degre du polynome
+  double X_Center; // Centrage en X pour stabilitee
+};
+
+//////////////////////////////////////////////////////////////////
+class Polyn1D : public GeneralFunction {
+public:
+  Polyn1D(unsigned int ndegpol,double x0=0.);
+  virtual ~Polyn1D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+
+  inline int NDegP() const {return NDegPol;}
+  inline double XCenter() {return X_Center;}
+
+protected:
+  int NDegPol;     // degre du polynome
+  double X_Center; // Centrage en X pour stabilitee
+};
+
+//////////////////////////////////////////////////////////////////
+class HarmonieNu : public GeneralFunction {
+public:
+  HarmonieNu(unsigned int nharm=0, double t0=0.);
+  virtual ~HarmonieNu();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+
+  inline int NHarmonic()  {return NHarm;}
+  inline double  T0Center() const {return T0;}
+  inline double& T0Center()       {return T0;}
+
+protected:
+  int NHarm;
+  double T0;
+};
+
+//////////////////////////////////////////////////////////////////
+class HarmonieT : public GeneralFunction {
+public:
+  HarmonieT(unsigned int nharm=0, double t0=0.);
+  virtual ~HarmonieT();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+
+  inline int NHarmonic()  {return NHarm;}
+  inline double  T0Center() const {return T0;}
+  inline double& T0Center()       {return T0;}
+
+protected:
+  int NHarm;
+  double T0;
+};
+
+//================================================================
+// CLASSES DE FONCTIONS 2D AVEC PARAMETRES POUR LE FIT
+//================================================================
+
+//////////////////////////////////////////////////////////////////
+class Polyn2D : public GeneralFunction {
+public:
+  Polyn2D(unsigned int ndegpol,double x0=0.,double y0=0.);
+  virtual ~Polyn2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+
+  inline int NDegP() const {return NDegPol;}
+
+protected:
+  int NDegPol;     // degre du polynome
+  double X_Center; // Centrage en X pour stabilitee
+  double Y_Center; // Centrage en Y pour stabilitee
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/fct2dfit.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/fct2dfit.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/fct2dfit.cc	(revision 1307)
@@ -0,0 +1,1567 @@
+#include "defs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <math.h>
+#include "fct2dfit.h"
+#include "perrors.h"
+#include "nbconst.h"
+#include "tabmath.h"
+
+// define SIMPSON4  c'etait la prod 91-95 rcecile
+#define SIMPSON9
+#include "simps2d.h"
+
+// define EXPO exp
+#define EXPO tabFExp
+#define MINEXPM (100.)
+
+//================================================================
+// GeneralFunction 2D pour PSF pixel taille 1x1
+//================================================================
+
+/////////////////////////////////////////////////////////////////
+//++
+// Class	GeneralPSF2D
+// Lib	Outils++ 
+// include	fct2dfit.h
+//
+//	Classe de definition d'une PSF 2D a nPar parametres
+//	Pour definir une PSF, il faut creer une classe qui herite
+//	de ``GeneralPSF2D'' (cf par exemple GauRho2D...).
+//	La disposition des parametres definissant la PSF est indifferente,
+//	toutefois il est conseille de suivre l'ordre:
+//--
+//++
+//  - PSF 2D a NPar parametres:
+//  p[0] = Volume (ou hauteur)
+//  p[1] = centre X0, p[2] = centre Y0
+//  p[3] = SigmaX   , p[4] = SigmaY,    p[5] = Rho
+//  p[6],p[7],... = autres parametres (eventuels) definissant la PSF.
+//                  (ex: pour la Moffat p[6] = exposant Beta et NPar=8).
+//  p[NPar-1] = Fond
+//--
+//++
+//	L'emploi de certaines classes comme par exemple ``GenMultiPSF2D''
+//	necessite de suivre rigoureusement l'ordre indique ci-dessus
+//	pour les parametres.
+//--
+
+//++
+GeneralPSF2D::GeneralPSF2D(unsigned int nPar)
+//
+//--
+: GeneralFunction(2,nPar), VolEps(1.e-4)
+{
+DBASSERT( nPar>0 );
+}
+
+GeneralPSF2D::~GeneralPSF2D()
+{
+}
+
+//++
+double GeneralPSF2D::ValueH(double const xp[], double const* parm)
+//
+//| ValueH = hauteur*forme(x,y)+fond tq forme(0,0)=1.
+//|     alors que Value = volume*forme(x,y)+fond tq volume(forme)=1.
+//| Dans notre convention le dernier parametre est le fond,
+//| le premier le volume et les 2 suivants le centrage x0,y0
+//| ---> Ici parm[0] = hauteur
+//--
+{
+double x0[2];
+int mm1 = mNPar - 1;
+
+// point central en [x0,y0]
+x0[0] = parm[1];  x0[1] = parm[2];
+
+// retour avec hauteur = 1
+return   (Value(xp,parm) - parm[mm1]) / (Value(x0,parm) - parm[mm1])
+         * parm[0] + parm[mm1];
+}
+
+//++
+double GeneralPSF2D::VolPSF(double const* parm)
+//
+//| Cette fonction calcule le volume d'une PSF de hauteur=1
+//| avec une precision de "VolEps"
+//| dans le but de connaitre le coefficient permettant
+//| de convertir le volume d'une PSF en son amplitude
+//| ou vice-versa: " volume = VolPSF * hauteur "
+//|  L'integration se fait 1/4 de pixel par 1/4 de pixel
+//|  ATTENTION: Il s'agit de PSF donc x,y,x0,y0,Sigma.. sont en pixels
+//--
+{
+ double x[2],step;
+ double vol,volprec;
+ int ecart,i,j,k;
+ int mm1 = mNPar-1;
+
+ step = 1. / 4.;
+ vol = volprec = 0.;
+ ecart = 1;
+
+ /* pixel central */
+ for(k=0;k<nd2d;k++) {
+   x[0] = parm[1] + dx2d[k]*step;
+   x[1] = parm[2] + dy2d[k]*step;
+   vol += (ValueH(x,parm)-parm[mm1]) * w2d[k];
+ }
+
+/* increment en couronnes carrees de 2*ecart+1 de cote */
+ while ( ecart < 2 || fabs((vol-volprec)/vol) > VolEps ) {
+   volprec = vol;
+   for (i= -ecart;i<=ecart;i++) for(k=0;k<nd2d;k++) {
+     x[0] = parm[1] + (i+dx2d[k])*step;
+     x[1] = parm[2] + (-ecart+dy2d[k])*step;
+     vol += (ValueH(x,parm)-parm[mm1]) * w2d[k];
+     x[1] = parm[2] + ( ecart+dy2d[k])*step;
+     vol += (ValueH(x,parm)-parm[mm1]) * w2d[k];
+   }
+   for (j= -ecart+1;j<=ecart-1;j++) for(k=0;k<nd2d;k++) {
+     x[1] = parm[2] + (j+dy2d[k])*step;
+     x[0] = parm[1] + (-ecart+dx2d[k])*step;
+     vol += (ValueH(x,parm)-parm[mm1]) * w2d[k];
+     x[0] = parm[1] + ( ecart+dx2d[k])*step;
+     vol += (ValueH(x,parm)-parm[mm1]) * w2d[k];
+   }
+   ecart++;
+   // printf("ec=%d v=%f prec=%f %f\n",ecart,vol,fabs((vol-volprec)/vol),VolEps);
+ }
+
+ vol *= step * step / parm[0];
+ return vol;
+}
+
+//++
+void GeneralPSF2D::DefaultParam(double *parm)
+//
+//	Definition des defauts des parametres
+//--
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+}
+
+//++
+void GeneralPSF2D::SetVolEps(double const prec)
+//
+//	Definition de la precision sur le calcul du volume
+//--
+{
+  VolEps = prec;
+}
+
+//================================================================
+// GeneralFunction 2D pour MULTI-PSF pixel taille 1x1
+//================================================================
+
+/////////////////////////////////////////////////////////////////
+//++
+// Class	GenMultiPSF2D
+// Lib	Outils++ 
+// include	fct2dfit.h
+//
+//	Classe de definition d'un ensemble de PSF2D
+//	pour fiter simultanement plusieurs etoiles et un fond constant.
+//	Les parametres de forme de la PSF (Sx, Sy, Rho etc... et Fond)
+//	sont les memes pour toutes les etoiles, seuls le centre
+//	(X0,Y0) et le volume (ou la hauteur) V varient pour chaque etoile.
+//	La disposition des parametres definissant la PSF generique
+//	est obligatoirement la suivante:
+//--
+//++
+//|  - PSF 2D a NPar parametres:
+//|  p[0] = Volume (ou hauteur)
+//|  p[1] = centre X0, p[2] = centre Y0
+//|  p[3] = SigmaX   , p[4] = SigmaY,    p[5] = Rho
+//|  p[6],p[7],... = autres parametres (eventuels) definissant la PSF.
+//|                  (ex: pour la Moffat p[6] = exposant Beta et NPar=8).
+//|  p[NPar-1] = Fond
+//|
+//--
+//++
+//|  - La Multi-PSF a ses parametres arranges dans l'ordre suivant:
+//|    Soit NStar le nombre d'etoiles a fiter simultanement
+//|         NP = le nombre de parametres de la PSF 2D generique
+//|    On a NF = NP-7 parametres de forme supplementaires
+//|         (ex: nf=0 pour GauRho2D, nf=1 pour MofRho2D)
+//|  p[0],p[1],p[2] = V0,X0,Y0 pour la premiere etoile
+//|  p[3],p[4],p[5] = V1,X1,Y1 pour la deuxieme etoile
+//|  ...
+//|  p[3*i],p[3*i+1],p[3*i+2] = Vi,Xi,Yi pour la (i+1) ieme etoile
+//|  ...
+//|  p[m*i],p[m*i+1],p[m*i+2] = Vm,Xm,Ym   ;   m = NStar-1
+//|                       pour la NStar ieme et derniere etoile
+//|  p[3*NStar],p[3*NStar+1],p[3*NStar+2] = SigmaX, SigmaY et Rho
+//|  p[3*NStar+3],...,p[3*NStar+2+NF] = parametres de forme
+//|                        supplementaires pour definir la PSF 2D
+//|  p[3*NStar+2+NF+1] = Fond
+//--
+
+//++
+GenMultiPSF2D::GenMultiPSF2D(GeneralPSF2D* psf2d,unsigned int nstar)
+//
+//	Createur. ``psf2d'' est le nom de la PSF generique a utiliser,
+//	et ``nstar'' est le nombre d'etoiles a fiter simultanement.
+//--
+  : GeneralPSF2D((psf2d!=NULL) ? 3*nstar+4+psf2d->NPar()-7: 0)
+  , mPsf2D(psf2d), mNStar(nstar)
+{
+DBASSERT( nstar>0 && psf2d!=NULL );
+mNForme = mPsf2D->NPar() - 7;
+DBASSERT( mNForme>=0 );
+mNParm = mPsf2D->NPar();
+mParm = new double[mNParm];
+mDer = new double[mNParm];
+mNParmTot = GeneralPSF2D::NPar();
+cout<<"mNStar="<<mNStar<<" mNParmTot="<<mNParmTot
+    <<" mNParm="<<mNParm<<" mNForme="<<mNForme<<endl;
+}
+
+GenMultiPSF2D::~GenMultiPSF2D()
+{
+delete [] mParm; mParm = NULL;
+delete [] mDer;  mDer = NULL;
+}
+
+double GenMultiPSF2D::Value(double const xp[], double const* Par)
+{
+// Fond commun
+double val = Par[mNParmTot-1];
+
+// Remplissage le tableau des parametres pour la PSF generique
+// ... Communs a toutes les PSF individuelles: Sx,Sy,Rho,[Forme],Fond
+const double *pt = &Par[3*mNStar];
+double *p = &mParm[3];
+{for(int i=0;i<3+mNForme;i++) *(p++) = *(pt++);}  // Sx,Sy,Rho,[Forme...]
+*(p++) = 0.;   // Fond
+
+// ... Propres a chaque etoiles: Vi,Xi,Yi
+pt = Par;
+{for(int i=0;i<mNStar;i++) {
+  mParm[0] = *(pt++);  // Vi (ou Hi)
+  mParm[1] = *(pt++);  // Xi
+  mParm[2] = *(pt++);  // Yi
+  val += mPsf2D->Value(xp,mParm);
+}}
+
+return val;
+}
+
+double GenMultiPSF2D::Val_Der(double const xp[], double const* Par
+                             ,double *DgDpar)
+{
+{for(int i=3*mNStar;i<mNParmTot-1;i++) DgDpar[i] = 0.;}
+
+// Fond commun
+double val = Par[mNParmTot-1];
+DgDpar[mNParmTot-1] = 1.;  // D./DFond
+
+// Remplissage le tableau des parametres pour la PSF generique
+// ... Communs a toutes les PSF individuelles: Sx,Sy,Rho,[Forme],Fond
+const double *pt = &Par[3*mNStar];
+double *p = &mParm[3];
+{for(int i=0;i<3+mNForme;i++) *(p++) = *(pt++);}  // Sx,Sy,Rho,[Forme...]
+*(p++) = 0.;   // Fond
+
+// ... Propres a chaque etoiles: Vi,Xi,Yi
+double *dpt = DgDpar, *dpt2 = &DgDpar[3*mNStar];
+pt = Par;
+{for(int i=0;i<mNStar;i++) {
+  mParm[0] = *(pt++);  // Vi (ou Hi)
+  mParm[1] = *(pt++);  // Xi
+  mParm[2] = *(pt++);  // Yi
+  val += mPsf2D->Val_Der(xp,mParm,mDer);
+  {for(int j=0;j<3;j++) *(dpt++) = mDer[j];}  // D./DVi,D./DXi,D./DYi
+  {for(int j=0;j<3+mNForme;j++) *(dpt2+j) += mDer[3+j];} // D./DSx,D./DSy,D./DRho,[D./DForme]
+}}
+
+return val;
+}
+
+//==============================================================================
+// CLASSES DE FONCTIONS 2D type PSF AVEC PARAMETRES POUR LE FIT pixel taille 1x1
+// la taille du pixel est importante quand on utilise les PSF integrees
+//    (x,y x0,y0 sigmaX.... sont en unites de pixels !!!)
+//==============================================================================
+
+#define _x0_   Par[1]
+#define _y0_   Par[2]
+#define _sigx_ Par[3]
+#define _sigy_ Par[4]
+#define _rho_  Par[5]
+#define _Gm_   Par[6]
+#define _B4_   Par[6]
+#define _B6_   Par[7]
+#define _B2_   Par[8]
+
+/////////////////////////////////////////////////////////////////
+//++ 
+// Module	Classes de PSF 2D
+// Lib	Outils++ 
+// include	fct2dfit.h
+//--
+/////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	GauRho2D
+// \index{GauRho2D}
+//
+//| gaussienne+fond 2D
+//| Par [0]=vol [1]=x0 [2]=y0 [3]=sigx [4]=sigy [5]=rho [6]=fond
+//|   sigx,sigy,rho = sigma et rho de la gaussienne
+//|   x0,y0 = centre de la gaussienne
+//|  PSF(x,y) = N * exp[ - 1/2 (X**2 + Y**2 -2*rho*X*Y) ]
+//|           avec X = (x-x0)/sigx et Y = (y-y0)/sigy
+//|                N = sqrt(1-rho**2)/(2*Pi*sigx*sigy)
+//|  le volume de cette gaussienne est V=1.
+//|  F(x,y) = Par[0]*PSF(x,y)+Par[6] (volume=Par[0],fond=Par[6])
+//--
+//++
+//| -*- Remarque: De la facon dont est ecrite la PSF gaussienne
+//| sigx,sigy representent les sigmas des gaussiennes 1D
+//| qui sont les coupes de la gaussienne 2D pour y=0 et x=0.
+//| Les moments centres d'ordre 2 sont
+//|   sx = sigx/sqrt(1-ro^2) et sy = sigy/sqrt(1-ro^2)
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+GauRho2D::GauRho2D()
+//
+//	Createur
+//--
+: GeneralPSF2D(7)
+{
+}
+
+GauRho2D::~GauRho2D()
+{
+}
+
+double GauRho2D::Value(double const xp[], double const* Par)
+{
+ double N = sqrt(1.-_rho_*_rho_)/(DeuxPi*_sigx_*_sigy_);
+ double X = (xp[0]-_x0_)/_sigx_;
+ double Y = (xp[1]-_y0_)/_sigy_;
+ double z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+ if( z2<MINEXPM ) return Par[0] * N*EXPO(-z2) + Par[6];
+   else return Par[6];
+}
+
+double GauRho2D::ValueH(double const xp[], double const* Par)
+{
+ double X = (xp[0]-_x0_)/_sigx_;
+ double Y = (xp[1]-_y0_)/_sigy_;
+ //double z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+ double z2 = 0.5*(X-Y)*(X-Y) - (_rho_ - 1)*X*Y;
+ if( z2<MINEXPM ) return Par[0] * EXPO(-z2) + Par[6];
+   else return Par[6];
+}
+
+double GauRho2D::VolPSF(double const* Par)
+{
+ return DeuxPi * _sigx_ * _sigy_ / sqrt(1.-_rho_*_rho_);
+}
+
+double GauRho2D::Val_Der(double const xp[], double const* Par
+                        , double *DgDpar)
+{
+ double unmr2 = 1.-_rho_*_rho_;
+ double N = sqrt(unmr2)/(DeuxPi*_sigx_*_sigy_);
+ double X = (xp[0]-_x0_)/_sigx_;
+ double Y = (xp[1]-_y0_)/_sigy_;
+
+ double XmrY = X-_rho_*Y;
+ double YmrX = Y-_rho_*X;
+ double z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+
+ /* g(x,y) */
+ double PSF = 0.;
+ if( z2<MINEXPM ) PSF = N * EXPO(-z2);
+ /* dg(x,y)/d(x0) */
+ DgDpar[1] =  Par[0]* PSF* XmrY/_sigx_;
+ /* dg(x,y)/d(y0) */
+ DgDpar[2] =  Par[0]* PSF* YmrX/_sigy_;
+ /* dg(x,y)/d(sx)*/
+ DgDpar[3] =  Par[0]* PSF* (X*XmrY-1.)/_sigx_;
+ /* dg(x,y)/d(sy) */
+ DgDpar[4] =  Par[0]* PSF* (Y*YmrX-1.)/_sigy_;
+ /* dg(x,y)/d(rho) */
+ DgDpar[5] =  Par[0]* PSF* (X*Y-2.*_rho_/unmr2);
+ /* dg(x,y)/d(Vol) */
+ DgDpar[0] = PSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[6] = 1.;
+
+ return Par[0] * PSF + Par[6];
+}
+
+void GauRho2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+}
+
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	GauRhInt2D
+// \index{GauRhInt2D}
+//
+//| Cette fonction calcule une approximation a l'integrale d'une
+//| gaussienne 2D sur un carre de longueur unite (x,y-05 -> x,y+0.5)
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+GauRhInt2D::GauRhInt2D()
+//
+//	Createur
+//--
+: GeneralPSF2D(7)
+{
+}
+
+GauRhInt2D::~GauRhInt2D()
+{
+}
+
+double GauRhInt2D::Value(double const xp[], double const* Par)
+{
+ double N = sqrt(1.-_rho_*_rho_)/(DeuxPi*_sigx_*_sigy_);
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF = 0.;
+ double X,Y,z2;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+   if( z2<MINEXPM ) SPSF += EXPO(-z2) * w2d[i];
+ }
+ return Par[0]* N*SPSF + Par[6];
+}
+
+double GauRhInt2D::ValueH(double const xp[], double const* Par)
+{
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF = 0.;
+ double X,Y,z2;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+   if( z2<MINEXPM ) SPSF += EXPO(-z2) * w2d[i];
+ }
+ return Par[0] *SPSF + Par[6];
+}
+
+double GauRhInt2D::VolPSF(double const* Par)
+{
+ return DeuxPi * _sigx_ * _sigy_ / sqrt(1.-_rho_*_rho_);
+}
+
+double GauRhInt2D::Val_Der(double const xp[], double const* Par
+                          ,double *DgDpar)
+{
+ for(int i=0; i<=6; i++) DgDpar[i] = 0.;
+ double unmr2 = 1.-_rho_*_rho_;
+ double N = sqrt(unmr2)/(DeuxPi*_sigx_*_sigy_);
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+
+ double z2,PSF,X,Y,XmrY,YmrX;
+ double SPSF = 0.;
+ {
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   XmrY = X-_rho_*Y;
+   YmrX = Y-_rho_*X;
+   z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+   /* g(x,y) */
+   if(z2<MINEXPM) PSF = N * EXPO(-z2) * w2d[i]; else PSF = 0.;
+   SPSF += PSF;
+   /* dg(x,y)/d(x0) */
+   DgDpar[1] += Par[0] * PSF* XmrY/_sigx_;
+   /* dg(x,y)/d(y0) */
+   DgDpar[2] += Par[0] * PSF* YmrX/_sigy_;
+   /* dg(x,y)/d(sx)*/
+   DgDpar[3] += Par[0] * PSF* (X*XmrY-1.)/_sigx_;
+   /* dg(x,y)/d(sy) */
+   DgDpar[4] += Par[0] * PSF* (Y*YmrX-1.)/_sigy_;
+   /* dg(x,y)/d(rho) */
+   DgDpar[5] += Par[0] * PSF* (X*Y-2.*_rho_/unmr2);
+ }
+ }
+ /* dg(x,y)/d(Vol) */
+ DgDpar[0] = SPSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[6] = 1.;
+
+ return Par[0] *SPSF + Par[6];
+}
+
+void GauRhInt2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+}
+
+#define B4 1.
+#define B6 1.
+#define KB4B6 0.136887
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	GdlRho2D
+// \index{GdlRho2D}
+//
+//| Cette fonction calcule une gaussienne 2D de volume 1 approchee
+//|  par son developpement limite au 3ieme ordre (see dophot)
+//|  Meme commentaire que GauRho2D, cf plus haut sauf que:
+//|  Par [0]=vol [1]=x0 [2]=y0 [3]=sigx [4]=sigy [5]=rho [6]=fond
+//|    z**2 = 1/2 (X**2 + Y**2 -2*rho*X*Y)
+//|    PSF(x,y) = N / [ 1 + z**2 + B4/2 *z**4 + B6/6 *z**6 ]
+//|               N = KB4B6
+//|    le coefficient KB4B6 etant trop dur a calculer analytiquement
+//|    Il doit etre calcule numeriquement et entre dans ce programme
+//|  ATTENTION: dans cette routine B4 et B6 sont imposes et pas fites!
+//|  - DL de la gaussienne:  B4=1., B6=1., KB4B6=0.13688679
+//|  le volume de cette gaussienne est V=1.
+//|  F(x,y) = Par[0]*PSF(x,y)+Par[6] (volume=Par[0],fond=Par[6])
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+GdlRho2D::GdlRho2D()
+//
+//	Createur
+//--
+: GeneralPSF2D(7)
+{
+}
+
+GdlRho2D::~GdlRho2D()
+{
+}
+
+double GdlRho2D::Value(double const xp[], double const* Par)
+{
+ double N = KB4B6*sqrt(1.-_rho_*_rho_)/(_sigx_*_sigy_);
+ double X = (xp[0]-_x0_)/_sigx_;
+ double Y = (xp[1]-_y0_)/_sigy_;
+ double z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+ double D = 1.+z2*(1.+z2*(B4/2.+B6/6.*z2));
+ return Par[0] *N/D + Par[6];
+}
+
+double GdlRho2D::ValueH(double const xp[], double const* Par)
+{
+ double X = (xp[0]-_x0_)/_sigx_;
+ double Y = (xp[1]-_y0_)/_sigy_;
+ double z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+ double D = 1.+z2*(1.+z2*(B4/2.+B6/6.*z2));
+ return Par[0] /D + Par[6];
+}
+
+double GdlRho2D::VolPSF(double const* Par)
+{
+ return _sigx_*_sigy_/(KB4B6*sqrt(1.-_rho_*_rho_));
+}
+
+double GdlRho2D::Val_Der(double const xp[], double const* Par
+                        , double *DgDpar)
+{
+ double unmr2 = 1.-_rho_*_rho_;
+ double N = KB4B6*sqrt(unmr2)/(_sigx_*_sigy_);
+ double X = (xp[0]-_x0_)/_sigx_;
+ double Y = (xp[1]-_y0_)/_sigy_;
+ double XmrY = X-_rho_*Y;
+ double YmrX = Y-_rho_*X;
+ double z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+ double D = 1.+z2*(1.+z2*(B4/2.+B6/6.*z2));
+ double dDsD = (1.+z2*(B4+B6/2.*z2))/D;
+
+ /* g(x,y) */
+ double PSF = N / D;
+ /* dg(x,y)/d(x0) */
+ DgDpar[1] = Par[0]* PSF* dDsD*XmrY/_sigx_;
+ /* dg(x,y)/d(y0) */
+ DgDpar[2] = Par[0]* PSF* dDsD*YmrX/_sigy_;
+ /* dg(x,y)/d(sx)*/
+ DgDpar[3] = Par[0]* PSF* (dDsD*X*XmrY-1.)/_sigx_;
+ /* dg(x,y)/d(sy) */
+ DgDpar[4] = Par[0]* PSF* (dDsD*Y*YmrX-1.)/_sigy_;
+ /* dg(x,y)/d(rho) */
+ DgDpar[5] = Par[0]* PSF* (dDsD*X*Y-2.*_rho_/unmr2);
+ /* dg(x,y)/d(Vol) */
+ DgDpar[0] = PSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[6] = 1.;
+
+ return Par[0] *PSF + Par[6];
+}
+
+void GdlRho2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+}
+
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	GdlRhInt2D
+// \index{GdlRhInt2D}
+//
+//	fonction integree de  GdlRho2d
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+GdlRhInt2D::GdlRhInt2D()
+//
+//	Createur
+//--
+: GeneralPSF2D(7)
+{
+}
+
+GdlRhInt2D::~GdlRhInt2D()
+{
+}
+
+double GdlRhInt2D::Value(double const xp[], double const* Par)
+{
+ double N = KB4B6*sqrt(1.-_rho_*_rho_)/(_sigx_*_sigy_);
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+
+ double z2,X,Y,D;
+ double SPSF = 0.;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+   D = 1.+z2*(1.+z2*(B4/2.+B6/6.*z2));
+   SPSF += w2d[i] / D;
+  }
+ return Par[0] *N*SPSF + Par[6];
+}
+
+double GdlRhInt2D::ValueH(double const xp[], double const* Par)
+{
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+
+ double z2,X,Y,D;
+ double SPSF = 0.;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+   D = 1.+z2*(1.+z2*(B4/2.+B6/6.*z2));
+   SPSF += w2d[i] / D;
+  }
+ return Par[0] *SPSF + Par[6];
+}
+
+double GdlRhInt2D::VolPSF(double const* Par)
+{
+ return _sigx_*_sigy_/(KB4B6*sqrt(1.-_rho_*_rho_));
+}
+
+double GdlRhInt2D::Val_Der(double const xp[], double const* Par
+                          , double *DgDpar)
+{
+ for(int i=0; i<=6; i++) DgDpar[i] = 0.;
+ double unmr2 = 1.-_rho_*_rho_;
+ double N = KB4B6*sqrt(unmr2)/(_sigx_*_sigy_);
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+
+ double z2,PSF,X,Y,XmrY,YmrX,D,dDsD;
+ double SPSF = 0.;
+ {
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   XmrY = X-_rho_*Y;
+   YmrX = Y-_rho_*X;
+   z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+   D = 1.+z2*(1.+z2*(B4/2.+B6/6.*z2));
+   dDsD = (1.+z2*(B4+B6/2.*z2))/D;
+   /* g(x,y) */
+   PSF = N / D  * w2d[i];
+   SPSF += PSF;
+   /* dg(x,y)/d(x0) */
+   DgDpar[1] += Par[0]* PSF* dDsD*XmrY/_sigx_;
+   /* dg(x,y)/d(y0) */
+   DgDpar[2] += Par[0]* PSF* dDsD*YmrX/_sigy_;
+   /* dg(x,y)/d(sx)*/
+   DgDpar[3] += Par[0]* PSF* (dDsD*X*XmrY-1.)/_sigx_;
+   /* dg(x,y)/d(sy) */
+   DgDpar[4] += Par[0]* PSF* (dDsD*Y*YmrX-1.)/_sigy_;
+   /* dg(x,y)/d(rho) */
+   DgDpar[5] += Par[0]* PSF* (dDsD*X*Y-2.*_rho_/unmr2);
+ }
+ }
+ /* dg(x,y)/d(Vol) */
+ DgDpar[0] = SPSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[6] = 1.;
+
+ return Par[0] *SPSF + Par[6];
+}
+
+void GdlRhInt2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+}
+
+#undef B4
+#undef B6
+#undef KB4B6
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Gdl1Rho2D
+// \index{Gdl1Rho2D}
+//
+//| Cette fonction calcule une gaussienne 2D approchee
+//| par son developpement limite au 2sd ordre (see dophot)
+//| Meme commentaire que GauRho2D, cf plus haut sauf que:
+//|   z**2 = 1/2 (X**2 + Y**2 -2*rho*X*Y)
+//|   PSF(x,y) = N / [ 1 + z**2 + B4/2 *z**4 ]
+//|   Le coefficient B4 est fitte (6ieme parametres)
+//| ATTENTION: les normalisations N dependent de B4
+//|  1-/ B4 est suppose etre toujours positif pour que la PSF tendent
+//|      vers 0+ quand z2 tend vers l'infini
+//|  2-/ Il y a 3 cas de calcul de K(B4) = int(PSF(x,y)) de 0 a l'infini
+//|             0<B4<1/2, 1/2<B4, et B4=1/2
+//|      mais pour des raisons d'analyse
+//|      numerique j'ai pris 3 intervalles:
+//|             0.<B4<0.499, 0.501<B4, 0.499<=B4<=0.501
+//|      dans le 3ieme intervalle, comme K est continue est derivable
+//|      en B4=1/2, j'ai represente K par la droite tangeante
+//|      ce qui, apres verification dans paw est une tres bonne approx.
+//|      (je tiens les calculs a disposition.. me demander)
+//|  Par [0]=vol [1]=x0 [2]=y0 [3]=sigx [4]=sigy [5]=rho [6]=B4 [7]=fond
+//|  F(x,y) = Par[0]*PSF(x,y)+Par[7]
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+Gdl1Rho2D::Gdl1Rho2D()
+//
+//	Createur
+//--
+: GeneralPSF2D(8)
+{
+}
+
+Gdl1Rho2D::~Gdl1Rho2D()
+{
+}
+
+double Gdl1Rho2D::Value(double const xp[], double const* Par)
+{
+ double K,W,V,dKdB4;
+ if ( 0. < _B4_ && _B4_ < 0.499 ) {
+   V = 1.-2.*_B4_;
+   W = sqrt(V);
+   K = -log( (1.-W)/(1.+W) )/W;
+   dKdB4 = ( K-2./(1.-V) )/V;
+ } else if ( 0.501 < _B4_ ) {
+   V = 1./(2.*_B4_-1.);
+   W = sqrt(V);
+   K = 2.*W*( Pi/2.-atan(W) );
+   dKdB4 = V*( 2.*V/(1.+V) - K );
+ } else if ( 0.499 <= _B4_ && _B4_ <= 0.501 ) {
+   dKdB4 = -4./3.;
+   K = dKdB4 * ( _B4_ - 0.5 ) + 2.;
+ } else {
+   return(0.);
+ }
+ double N = sqrt(1.-_rho_*_rho_)/(_sigx_*_sigy_*DeuxPi*K);
+
+ double X = (xp[0] - _x0_)/_sigx_;
+ double Y = (xp[1] - _y0_)/_sigy_;
+ double z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+ double D = 1.+z2*(1.+z2*_B4_/2.);
+ return Par[0] *N/D + Par[7];
+}
+
+double Gdl1Rho2D::ValueH(double const xp[], double const* Par)
+{
+ double X = (xp[0] - _x0_)/_sigx_;
+ double Y = (xp[1] - _y0_)/_sigy_;
+ double z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+ double D = 1.+z2*(1.+z2*_B4_/2.);
+ return Par[0] /D + Par[7];
+}
+
+double Gdl1Rho2D::VolPSF(double const* Par)
+{
+ double K,W,V,dKdB4;
+ if ( 0. < _B4_ && _B4_ < 0.499 ) {
+   V = 1.-2.*_B4_;
+   W = sqrt(V);
+   K = -log( (1.-W)/(1.+W) )/W;
+   dKdB4 = ( K-2./(1.-V) )/V;
+ } else if ( 0.501 < _B4_ ) {
+   V = 1./(2.*_B4_-1.);
+   W = sqrt(V);
+   K = 2.*W*( Pi/2.-atan(W) );
+   dKdB4 = V*( 2.*V/(1.+V) - K );
+ } else if ( 0.499 <= _B4_ && _B4_ <= 0.501 ) {
+   dKdB4 = -4./3.;
+   K = dKdB4 * ( _B4_ - 0.5 ) + 2.;
+ } else {
+   return(0.);
+ }
+ double N = sqrt(1.-_rho_*_rho_)/(_sigx_*_sigy_*DeuxPi*K);
+ return 1./N;
+}
+
+double Gdl1Rho2D::Val_Der(double const xp[], double const* Par
+                         , double *DgDpar)
+{
+ double K,W,V,dKdB4;
+ if ( 0. < _B4_ && _B4_ < 0.499 ) {
+   V = 1.-2.*_B4_;
+   W = sqrt(V);
+   K = -log( (1.-W)/(1.+W) )/W;
+   dKdB4 = ( K-2./(1.-V) )/V;
+ } else if ( 0.501 < _B4_ ) {
+   V = 1./(2.*_B4_-1.);
+   W = sqrt(V);
+   K = 2.*W*( Pi/2.-atan(W) );
+   dKdB4 = V*( 2.*V/(1.+V) - K );
+ } else if ( 0.499 <= _B4_ && _B4_ <= 0.501 ) {
+   dKdB4 = -4./3.;
+   K = dKdB4 * ( _B4_ - 0.5 ) + 2.;
+ } else {
+   for(int i=0;i<=7;i++) DgDpar[i] = 0.;
+   return(0.);
+ }
+ double unmr2 = 1.-_rho_*_rho_;
+ double N = sqrt(unmr2)/(_sigx_*_sigy_*DeuxPi*K);
+
+ double X = (xp[0] - _x0_)/_sigx_;
+ double Y = (xp[1] - _y0_)/_sigy_;
+ double XmrY = X-_rho_*Y;
+ double YmrX = Y-_rho_*X;
+ double z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+ double D = 1.+z2*(1.+z2*_B4_/2.);
+ double dDsD = (1.+z2*_B4_)/D;
+
+ /* g(x,y) */
+ double PSF = N / D;
+ /* dg(x,y)/d(x0) */
+ DgDpar[1] =  Par[0]* PSF* dDsD*XmrY/_sigx_;
+ /* dg(x,y)/d(y0) */
+ DgDpar[2] =  Par[0]* PSF* dDsD*YmrX/_sigy_;
+ /* dg(x,y)/d(sx)*/
+ DgDpar[3] =  Par[0]* PSF* (dDsD*X*XmrY-1.)/_sigx_;
+ /* dg(x,y)/d(sy) */
+ DgDpar[4] =  Par[0]* PSF* (dDsD*Y*YmrX-1.)/_sigy_;
+ /* dg(x,y)/d(rho) */
+ DgDpar[5] =  Par[0]* PSF* (dDsD*X*Y-2.*_rho_/unmr2);
+ /* dg(x,y)/d(B4) */
+ DgDpar[6] =  Par[0]* PSF* (-dKdB4/K-z2*z2/2./D);
+ /* dg(x,y)/d(Vol) */
+ DgDpar[0] = PSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[7] = 1.;
+
+ return Par[0] *PSF + Par[7];
+}
+
+void Gdl1Rho2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+  parm[6] = 1.;
+}
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Gdl1RhInt2D
+// \index{Gdl1RhInt2D}
+//
+//	fonction integree de Gdl1Rho2D
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+Gdl1RhInt2D::Gdl1RhInt2D()
+//
+//	Createur
+//--
+: GeneralPSF2D(8)
+{
+}
+
+Gdl1RhInt2D::~Gdl1RhInt2D()
+{
+}
+
+double Gdl1RhInt2D::Value(double const xp[], double const* Par)
+{
+ double K,W,V,dKdB4;
+ if ( 0. < _B4_ && _B4_ < 0.499 ) {
+   V = 1.-2.*_B4_;
+   W = sqrt(V);
+   K = -log( (1.-W)/(1.+W) )/W;
+   dKdB4 = ( K-2./(1.-V) )/V;
+ } else if ( 0.501 < _B4_ ) {
+   V = 1./(2.*_B4_-1.);
+   W = sqrt(V);
+   K = 2.*W*( Pi/2.-atan(W) );
+   dKdB4 = V*( 2.*V/(1.+V) - K );
+ } else if ( 0.499 <= _B4_ && _B4_ <= 0.501 ) {
+   dKdB4 = -4./3.;
+   K = dKdB4 * ( _B4_ - 0.5 ) + 2.;
+ } else {
+   return(0.);
+ }
+ double N = sqrt(1.-_rho_*_rho_)/(_sigx_*_sigy_*DeuxPi*K);
+
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF=0.;
+ double z2,X,Y,D;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y -2.*_rho_*X*Y)/2.;
+   D = 1.+z2*(1.+z2*_B4_/2.);
+   SPSF += w2d[i] / D;
+ }
+ return Par[0] *N*SPSF + Par[7];
+}
+
+double Gdl1RhInt2D::ValueH(double const xp[], double const* Par)
+{
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF=0.;
+ double z2,X,Y,D;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y -2.*_rho_*X*Y)/2.;
+   D = 1.+z2*(1.+z2*_B4_/2.);
+   SPSF += w2d[i] / D;
+ }
+ return Par[0] *SPSF + Par[7];
+}
+
+double Gdl1RhInt2D::VolPSF(double const* Par)
+{
+ double K,W,V,dKdB4;
+ if ( 0. < _B4_ && _B4_ < 0.499 ) {
+   V = 1.-2.*_B4_;
+   W = sqrt(V);
+   K = -log( (1.-W)/(1.+W) )/W;
+   dKdB4 = ( K-2./(1.-V) )/V;
+ } else if ( 0.501 < _B4_ ) {
+   V = 1./(2.*_B4_-1.);
+   W = sqrt(V);
+   K = 2.*W*( Pi/2.-atan(W) );
+   dKdB4 = V*( 2.*V/(1.+V) - K );
+ } else if ( 0.499 <= _B4_ && _B4_ <= 0.501 ) {
+   dKdB4 = -4./3.;
+   K = dKdB4 * ( _B4_ - 0.5 ) + 2.;
+ } else {
+   return(0.);
+ }
+ double N = sqrt(1.-_rho_*_rho_)/(_sigx_*_sigy_*DeuxPi*K);
+ return 1./N;
+}
+
+double Gdl1RhInt2D::Val_Der(double const xp[], double const* Par
+                           , double *DgDpar)
+{
+ for(int i=0; i<7; i++) DgDpar[i] = 0.;
+
+ double K,W,V,dKdB4;
+ if ( 0. < _B4_ && _B4_ < 0.499 ) {
+   V = 1.-2.*_B4_;
+   W = sqrt(V);
+   K = -log( (1.-W)/(1.+W) )/W;
+   dKdB4 = ( K-2./(1.-V) )/V;
+ } else if ( 0.501 < _B4_ ) {
+   V = 1./(2.*_B4_-1.);
+   W = sqrt(V);
+   K = 2.*W*( Pi/2.-atan(W) );
+   dKdB4 = V*( 2.*V/(1.+V) - K );
+ } else if ( 0.499 <= _B4_ && _B4_ <= 0.501 ) {
+   dKdB4 = -4./3.;
+   K = dKdB4 * ( _B4_ - 0.5 ) + 2.;
+ } else {
+   return(0.);
+ }
+ double unmr2 = 1.-_rho_*_rho_;
+ double N = sqrt(unmr2)/(_sigx_*_sigy_*DeuxPi*K);
+
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double z2,PSF,X,Y,XmrY,YmrX,D,dDsD;
+ double SPSF=0.;
+ {for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   XmrY = X-_rho_*Y;
+   YmrX = Y-_rho_*X;
+   z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+   D = 1.+z2*(1.+z2*_B4_/2.);
+   dDsD = (1.+z2*_B4_)/D;
+   /* dg(x,y) */
+   PSF = N / D  * w2d[i];
+   SPSF += PSF;
+   /* dg(x,y)/d(x0) */
+   DgDpar[1] += Par[0]* PSF* dDsD*XmrY/_sigx_;
+   /* dg(x,y)/d(y0) */
+   DgDpar[2] += Par[0]* PSF* dDsD*YmrX/_sigy_;
+   /* dg(x,y)/d(sx)*/
+   DgDpar[3] += Par[0]* PSF* (dDsD*X*XmrY-1.)/_sigx_;
+   /* dg(x,y)/d(sy) */
+   DgDpar[4] += Par[0]* PSF* (dDsD*Y*YmrX-1.)/_sigy_;
+   /* dg(x,y)/d(rho) */
+   DgDpar[5] += Par[0]* PSF* (dDsD*X*Y-2.*_rho_/unmr2);
+   /* dg(x,y)/d(B4) */
+   DgDpar[6] += Par[0]* PSF* (-dKdB4/K-z2*z2/2./D);
+ }}
+ /* dg(x,y)/d(Vol) */
+ DgDpar[0] = SPSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[7] = 1.;
+
+ return Par[0] *SPSF + Par[7];
+}
+
+void Gdl1RhInt2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+  parm[6] = 1.;
+}
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Gdl2Rho2D
+// \index{Gdl2Rho2D}
+//
+//| Cette fonction calcule une gaussienne 2D de hauteur 1 approchee
+//| par son developpement limite ordre 3 (see dophot)
+//| Meme commentaire que GauRho2D, cf plus haut sauf que:
+//|   z**2 = 1/2 (X**2 + Y**2 -2*rho*X*Y)
+//|   Z**2 = B2*z2
+//|   PSF(x,y) = h / [ 1 + Z**2 + B4**2/2 *Z**4 + B6**2/6 *Z**6 ]
+//|   B2,B4,B6 peuvent etre fittes
+//| - DL de la gaussienne:  B2=B4=B6=1.
+//|  Par [0]=hauteur [1]=x0 [2]=y0 [3]=sigx [4]=sigy [5]=rho
+//|      [6]=B4 [7]=B6 [8]=B2 [9]= fond
+//|  F(x,y) = Par[0]*PSF(x,y)+Par[9]
+//--
+/////////////////////////////////////////////////////////////////
+
+
+//++
+Gdl2Rho2D::Gdl2Rho2D()
+//
+//	Createur
+//--
+: GeneralPSF2D(10)
+{
+}
+
+Gdl2Rho2D::~Gdl2Rho2D()
+{
+}
+
+double Gdl2Rho2D::Value(double const xp[], double const* Par)
+{
+ double X = (xp[0]-_x0_)/_sigx_;
+ double Y = (xp[1]-_y0_)/_sigy_;
+ double z2 = (X*X + Y*Y - 2*_rho_*X*Y)/2.;
+ double Z2 = _B2_ * _B2_ * z2;
+ double Z4 = Z2*Z2;
+ double Z6 = Z4*Z2;
+ double D = 1. + Z2 + _B4_*_B4_/2.*Z4 + _B6_*_B6_/6.*Z6;
+ return Par[0] /D + Par[9];
+}
+
+double Gdl2Rho2D::ValueH(double const xp[], double const* Par)
+{
+ double X = (xp[0]-_x0_)/_sigx_;
+ double Y = (xp[1]-_y0_)/_sigy_;
+ double z2 = (X*X + Y*Y - 2*_rho_*X*Y)/2.;
+ double Z2 = _B2_ * _B2_ * z2;
+ double Z4 = Z2*Z2;
+ double Z6 = Z4*Z2;
+ double D = 1. + Z2 + _B4_*_B4_/2.*Z4 + _B6_*_B6_/6.*Z6;
+ return Par[0] /D + Par[9];
+}
+
+double Gdl2Rho2D::Val_Der(double const xp[], double const* Par
+                         , double *DgDpar)
+{
+ double unmr2 = 1.-_rho_*_rho_;
+ double X = (xp[0]-_x0_)/_sigx_;
+ double Y = (xp[1]-_y0_)/_sigy_;
+ double XmrY = X-_rho_*Y;
+ double YmrX = Y-_rho_*X;
+ double z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+ double Z2 = _B2_ * _B2_ * z2;
+ double Z4 = Z2*Z2;
+ double Z6 = Z4*Z2;
+ double D = 1. + Z2 + _B4_*_B4_/2.*Z4 + _B6_*_B6_/6.*Z6;
+ double dDsDB2 = (1. + _B4_*_B4_*Z2    + _B6_*_B6_/2.*Z4 )/D;
+ double dDsD = _B2_*_B2_ * dDsDB2;
+ /* g(x,y) */
+ double PSF = 1. / D;
+ /* dg(x,y)/d(x0) */
+ DgDpar[1] = Par[0]* PSF* dDsD*XmrY/_sigx_;
+ /* dg(x,y)/d(y0) */
+ DgDpar[2] = Par[0]* PSF* dDsD*YmrX/_sigy_;
+ /* dg(x,y)/d(sx)*/
+ DgDpar[3] = Par[0]* PSF* (dDsD*X*XmrY-1.)/_sigx_;
+ /* dg(x,y)/d(sy) */
+ DgDpar[4] = Par[0]* PSF* (dDsD*Y*YmrX-1.)/_sigy_;
+ /* dg(x,y)/d(rho) */
+ DgDpar[5] = Par[0]* PSF* (dDsD*X*Y-2.*_rho_/unmr2);
+ /* dg(x,y)/d(B4) */
+ DgDpar[6] = Par[0]* PSF* (-_B4_*Z4/D);
+ /* dg(x,y)/d(B6) */
+ DgDpar[7] = Par[0]* PSF* (-_B6_*Z6/3./D);
+ /* dg(x,y)/d(B2)  */
+ DgDpar[8] = Par[0]* PSF* (-2.*_B2_*z2*dDsDB2);
+ /* dg(x,y)/d(hauteur) */
+ DgDpar[0] = PSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[9] = 1.;
+
+ return Par[0] *PSF + Par[9];
+}
+
+void Gdl2Rho2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+  parm[6] = parm[7] = parm[8] = 1.;
+}
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Gdl2RhInt2D
+// \index{Gdl2RhInt2D}
+//
+//	fonction integree de Gdl2Rho2d
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+Gdl2RhInt2D::Gdl2RhInt2D()
+//
+//	Createur
+//--
+: GeneralPSF2D(10)
+{
+}
+
+Gdl2RhInt2D::~Gdl2RhInt2D()
+{
+}
+
+double Gdl2RhInt2D::Value(double const xp[], double const* Par)
+{
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF=0.;
+ double X,Y,z2,Z2,Z4,Z6,D;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+   Z2 = _B2_ * _B2_ * z2;
+   Z4 = Z2*Z2;
+   Z6 = Z4*Z2;
+   D = 1. + Z2 + _B4_*_B4_/2.*Z4 + _B6_*_B6_/6.*Z6;
+   /* g(x,y) */
+   SPSF += w2d[i] / D;
+ }
+ return Par[0] *SPSF + Par[9];
+}
+
+double Gdl2RhInt2D::ValueH(double const xp[], double const* Par)
+{
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF=0.;
+ double X,Y,z2,Z2,Z4,Z6,D;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+   Z2 = _B2_ * _B2_ * z2;
+   Z4 = Z2*Z2;
+   Z6 = Z4*Z2;
+   D = 1. + Z2 + _B4_*_B4_/2.*Z4 + _B6_*_B6_/6.*Z6;
+   /* g(x,y) */
+   SPSF += w2d[i] / D;
+ }
+ return Par[0] *SPSF + Par[9];
+}
+
+double Gdl2RhInt2D::Val_Der(double const xp[], double const* Par
+                           , double *DgDpar)
+{
+ for(int i=0; i<=9; i++) DgDpar[i] = 0.;
+
+ double unmr2 = 1.-_rho_*_rho_;
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF=0.;
+ double X,Y,XmrY,YmrX,z2,Z2,Z4,Z6,D,dDsD,dDsDB2,PSF;
+ {for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   XmrY = X-_rho_*Y;
+   YmrX = Y-_rho_*X;
+   z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+   Z2 = _B2_ * _B2_ * z2;
+   Z4 = Z2*Z2;
+   Z6 = Z4*Z2;
+   D = 1. + Z2 + _B4_*_B4_/2.*Z4 + _B6_*_B6_/6.*Z6;
+   dDsDB2 = (1. + _B4_*_B4_*Z2    + _B6_*_B6_/2.*Z4 )/D;
+   dDsD = _B2_*_B2_ * dDsDB2;
+   /* dg(x,y) */
+   PSF = w2d[i] / D;
+   SPSF += PSF;
+   /* dg(x,y)/d(x0) */
+   DgDpar[1] += Par[0]* PSF* dDsD*XmrY/_sigx_;
+   /* dg(x,y)/d(y0) */
+   DgDpar[2] += Par[0]* PSF* dDsD*YmrX/_sigy_;
+   /* dg(x,y)/d(sx)*/
+   DgDpar[3] += Par[0]* PSF* (dDsD*X*XmrY-1.)/_sigx_;
+   /* dg(x,y)/d(sy) */
+   DgDpar[4] += Par[0]* PSF* (dDsD*Y*YmrX-1.)/_sigy_;
+   /* dg(x,y)/d(rho) */
+   DgDpar[5] += Par[0]* PSF* (dDsD*X*Y-2.*_rho_/unmr2);
+   /* dg(x,y)/d(B4) */
+   DgDpar[6] += Par[0]* PSF* (-_B4_*Z4/D);
+   /* dg(x,y)/d(B6) */
+   DgDpar[7] += Par[0]* PSF* (-_B6_*Z6/3./D);
+   /* dg(x,y)/d(B2)  */
+   DgDpar[8] += Par[0]* PSF* (-2.*_B2_*z2*dDsDB2);
+ }}
+ /* dg(x,y)/d(hauteur) */
+ DgDpar[0] = SPSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[9] = 1.;
+
+ return Par[0] *SPSF + Par[9];
+}
+
+void Gdl2RhInt2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+  parm[6] = parm[7] = parm[8] = 1.;
+}
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	MofRho2D
+// \index{MofRho2D}
+//
+//| Cette fonction calcule une Moffat 2D
+//|   Par [0]=hauteur [1]=x0 [2]=y0 [3]=sigx [4]=sigy [5]=rho
+//|       [6]=Gm [7]= fond
+//|  PSF(x,y)  = valeur de la Moffat normalisee a un volume = 1
+//|  PSF(x,y) = N / [ 1. +  0.5*(X**2 + Y**2 -2*rho*X*Y) ]**Gm
+//|           avec X = (x-x0)/sigx et Y = (y-y0)/sigy et Gm>1
+//|                N = (1-Gm)*sqrt(1-rho**2)/(2*Pi*sigx*sigy)
+//|  le volume de cette Moffat est V=1.
+//|  F(x,y) = Par[0]*PSF(x,y)+Par[7]
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+MofRho2D::MofRho2D()
+//
+//	Createur 
+//--
+: GeneralPSF2D(8)
+{
+}
+
+MofRho2D::~MofRho2D()
+{
+}
+
+double MofRho2D::Value(double const xp[], double const* Par)
+{
+ double N = (_Gm_-1.)*sqrt(1.-_rho_*_rho_)/(DeuxPi*_sigx_*_sigy_);
+ double X = (xp[0] - _x0_)/_sigx_;
+ double Y = (xp[1] - _y0_)/_sigy_;
+ double z2 = (X*X + Y*Y -2.*_rho_*X*Y)/2.;
+ z2 = _Gm_*log(1. + z2);
+ if( z2<MINEXPM ) return Par[0] *N*EXPO(-z2) + Par[7];
+    else return Par[7];
+}
+
+double MofRho2D::ValueH(double const xp[], double const* Par)
+{
+ double X = (xp[0] - _x0_)/_sigx_;
+ double Y = (xp[1] - _y0_)/_sigy_;
+ double z2 = (X*X + Y*Y -2.*_rho_*X*Y)/2.;
+ z2 = _Gm_*log(1. + z2);
+ if( z2<MINEXPM ) return Par[0] *EXPO(-z2) + Par[7];
+    else return Par[7];
+}
+
+double MofRho2D::VolPSF(double const* Par)
+{
+ double N = (_Gm_-1.)*sqrt(1.-_rho_*_rho_)/(DeuxPi*_sigx_*_sigy_);
+ return 1./N;
+}
+
+double MofRho2D::Val_Der(double const xp[], double const* Par
+                        , double *DgDpar)
+{
+ double unmr2 = 1.-_rho_*_rho_;
+ double N = (_Gm_-1.)*sqrt(unmr2)/DeuxPi/_sigx_/_sigy_;
+ double X = (xp[0] - _x0_)/_sigx_;
+ double Y = (xp[1] - _y0_)/_sigy_;
+ double XmrY = X-_rho_*Y;
+ double YmrX = Y-_rho_*X;
+ double z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+ double D = 1. + z2;
+ double lD = log(D);
+ /* g(x,y) */
+ double PSF = _Gm_*lD;
+ if( PSF<MINEXPM ) PSF = N * EXPO(-PSF); else PSF = 0.;
+ /* dg(x,y)/d(x0) */
+ DgDpar[1] = Par[0]* PSF* XmrY/_sigx_ * _Gm_/D;
+ /* dg(x,y)/d(y0) */
+ DgDpar[2] = Par[0]* PSF* YmrX/_sigy_ * _Gm_/D;
+ /* dg(x,y)/d(sx)*/
+ DgDpar[3] = Par[0]* PSF* (X*XmrY*_Gm_/D - 1.)/_sigx_;
+ /* dg(x,y)/d(sy) */
+ DgDpar[4] = Par[0]* PSF* (Y*YmrX*_Gm_/D - 1.)/_sigy_;
+ /* dg(x,y)/d(rho) */
+ DgDpar[5] = Par[0]* PSF* (X*Y*_Gm_/D - 2.*_rho_/unmr2);
+ /* dg(x,y)/d(Gm) */
+ DgDpar[6] = Par[0]* PSF* (1./(_Gm_-1.) - lD);
+ /* dg(x,y)/d(Vol) */
+ DgDpar[0] = PSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[7] = 1.;
+
+ return Par[0] *PSF + Par[7];
+}
+
+void MofRho2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+  parm[6] = 3.;
+}
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	MofRhInt2D
+// \index{MofRhInt2D}
+//
+//	fonction integree de MofRho2d
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+MofRhInt2D::MofRhInt2D()
+//
+//	Createur 
+//--
+: GeneralPSF2D(8)
+{
+}
+
+MofRhInt2D::~MofRhInt2D()
+{
+}
+
+double MofRhInt2D::Value(double const xp[], double const* Par)
+{
+ double N = (_Gm_-1.)*sqrt(1.-_rho_*_rho_)/(DeuxPi*_sigx_*_sigy_);
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF = 0.;
+ double z2,X,Y;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+   /* g(x,y) */
+   z2  = _Gm_*log(1. + z2);
+   if( z2<MINEXPM ) SPSF += EXPO(-z2) * w2d[i];
+ }
+ return Par[0] * N*SPSF + Par[7];
+}
+
+double MofRhInt2D::ValueH(double const xp[], double const* Par)
+{
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF = 0.;
+ double z2,X,Y;
+ for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   z2 = (X*X + Y*Y - 2.*_rho_*X*Y)/2.;
+   /* g(x,y) */
+   z2  = _Gm_*log(1. + z2);
+   if( z2<MINEXPM ) SPSF += EXPO(-z2) * w2d[i];
+ }
+ return Par[0] *SPSF + Par[7];
+}
+
+double MofRhInt2D::VolPSF(double const* Par)
+{
+ double N = (_Gm_-1.)*sqrt(1.-_rho_*_rho_)/(DeuxPi*_sigx_*_sigy_);
+ return 1./N;
+}
+
+double MofRhInt2D::Val_Der(double const xp[], double const* Par
+                          , double *DgDpar)
+{
+ for(int i=0; i<=7; i++) DgDpar[i] = 0.;
+
+ double unmr2 = 1.-_rho_*_rho_;
+ double N = (_Gm_-1.)*sqrt(unmr2)/(DeuxPi*_sigx_*_sigy_);
+ double x = xp[0] - _x0_;
+ double y = xp[1] - _y0_;
+ double SPSF = 0.;
+ double X,Y,XmrY,YmrX,z2,D,lD,PSF;
+ {for(int i=0; i<nd2d; i++) {
+   X = (x+dx2d[i])/_sigx_;
+   Y = (y+dy2d[i])/_sigy_;
+   XmrY = X-_rho_*Y;
+   YmrX = Y-_rho_*X;
+   z2 = (X*(XmrY-_rho_*Y)+Y*Y)/2.;
+   D = 1. + z2;
+   lD = log(D);
+   /* g(x,y) */
+   PSF = _Gm_*lD;
+   if( PSF<MINEXPM ) PSF = N * EXPO(-PSF) * w2d[i]; else PSF = 0.;
+   SPSF += PSF;
+   /* dg(x,y)/d(x0) */
+   DgDpar[1] += Par[0]* PSF* XmrY/_sigx_ * _Gm_/D;
+   /* dg(x,y)/d(y0) */
+   DgDpar[2] += Par[0]* PSF* YmrX/_sigy_ * _Gm_/D;
+   /* dg(x,y)/d(sx)*/
+   DgDpar[3] += Par[0]* PSF* (X*XmrY*_Gm_/D - 1.)/_sigx_;
+   /* dg(x,y)/d(sy) */
+   DgDpar[4] += Par[0]* PSF* (Y*YmrX*_Gm_/D - 1.)/_sigy_;
+   /* dg(x,y)/d(rho) */
+   DgDpar[5] += Par[0]* PSF* (X*Y*_Gm_/D - 2.*_rho_/unmr2);
+   /* dg(x,y)/d(Gm) */
+   DgDpar[6] += Par[0]* PSF* (1./(_Gm_-1.) - lD);
+ }}
+ /* dg(x,y)/d(Vol) */
+ DgDpar[0] = SPSF;
+ /* dg(x,y)/d(Fond) */
+ DgDpar[7] = 1.;
+
+ return Par[0] *SPSF + Par[7];
+}
+
+void MofRhInt2D::DefaultParam(double *parm)
+{
+  for (int i=0; i<mNPar; i++) parm[i] = 0.;
+  parm[3] = parm[4] = 1.;  // Sigx Sigy
+  parm[6] = 3.;
+}
+
+
+#undef _sigx_
+#undef _sigy_
+#undef _rho_
+#undef _x0_
+#undef _y0_
+#undef _Gm_
+#undef _B4_
+#undef _B6_
+#undef _B2_
+
+//==============================================================================
+// CLASSES DE FONCTIONS 2D type Xi2 AVEC PARAMETRES POUR LE FIT pixel taille 1x1
+// la taille du pixel est importante quand on utilise les PSF integrees
+//    (x,y x0,y0 sigmaX.... sont en unites de pixels !!!)
+//==============================================================================
+
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	X2-GauRho2D
+// \index{X2-GauRho2D}
+//
+//	Chi2 pour une Gaussienne+fond 2D (voir detail dans GauRho2D).
+//--
+/////////////////////////////////////////////////////////////////
+
+//++
+// X2-GauRho2D::X2-GauRho2D()
+//	Createur 
+//--
+X2_GauRho2D::X2_GauRho2D()
+: GeneralXi2(7)
+{
+  gaurho2d = new GauRho2D;
+}
+
+X2_GauRho2D::~X2_GauRho2D()
+{
+  delete gaurho2d;
+}
+
+double X2_GauRho2D::Value(GeneralFitData& data, double* parm, int& ndataused)
+{
+ DBASSERT( data.NVar()==2 );
+ double x[2],z;
+
+ double c2 = 0.;
+ ndataused = 0;
+ for(int k=0;k<data.NData();k++) {
+   if( ! data.IsValid(k) ) continue;
+   x[0] = data.X(k); x[1] = data.Y(k);
+   z = (data.Val(k)-gaurho2d->Value(x,parm))/data.EVal(k);
+   c2 += z*z;
+   ndataused++;
+ }
+ return c2;
+}
+
+double X2_GauRho2D::Derivee2(GeneralFitData& data, int i,int j, double* parm)
+{
+ DBASSERT( data.NVar()==2 && i<7 && j<7);
+ double x[2],dparm[7];
+
+ double d2c2 = 0.;
+ for(int k=0;k<data.NData();k++) {
+   if( ! data.IsValid(k) ) continue;
+   x[0] = data.X(k); x[1] = data.Y(k);
+   gaurho2d->Val_Der(x,parm,dparm);
+   d2c2 += 2.*dparm[i]*dparm[j]/(data.EVal(k)*data.EVal(k));
+ }
+ return d2c2;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/fct2dfit.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/fct2dfit.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/fct2dfit.h	(revision 1307)
@@ -0,0 +1,195 @@
+#ifndef FCT2DFIT_SEEN
+#define FCT2DFIT_SEEN
+
+#include "generalfit.h"
+
+//================================================================
+// GeneralFunction 2D pour PSF pixel taille 1x1
+//================================================================
+
+class GeneralPSF2D : public GeneralFunction {
+public:
+  GeneralPSF2D(unsigned int nPar);
+  virtual ~GeneralPSF2D();
+
+  virtual double ValueH(double const xp[], double const* parm);
+  virtual double VolPSF(double const* parm);
+  virtual void   DefaultParam(double *parm);
+
+  void SetVolEps(double const prec) ;
+protected:
+  double VolEps;
+};
+
+//================================================================
+// GeneralFunction 2D pour MULTI-PSF pixel taille 1x1
+//================================================================
+
+class GenMultiPSF2D : public GeneralPSF2D {
+public:
+  GenMultiPSF2D(GeneralPSF2D* psf2d,unsigned int nstar);
+  virtual ~GenMultiPSF2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+
+protected:
+  GeneralPSF2D* mPsf2D; // Type de PSF generique a fiter.
+  int mNStar;           // Nombre d etoiles a fiter.
+  int mNParmTot;        // Nombre total de parametres pour le fit.
+  int mNParm;           // Nombre de parametre pour la PSF generique.
+  int mNForme;          // Nombre de parametres de forme autres que Sx,Sy,Rho
+  double* mParm;        // pour la PSF generique. Buffer pour PSF generique
+  double* mDer;         // et pour le stoquage temporaire des derivees.
+};
+
+//==============================================================================
+// CLASSES DE FONCTIONS 2D type PSF AVEC PARAMETRES POUR LE FIT pixel taille 1x1
+//==============================================================================
+
+//////////////////////////////////////////////////////////////////
+class GauRho2D : public GeneralPSF2D {
+public:
+  GauRho2D();
+  virtual ~GauRho2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual double VolPSF(double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//////////////////////////////////////////////////////////////////
+class GauRhInt2D : public GeneralPSF2D {
+public:
+  GauRhInt2D();
+  virtual ~GauRhInt2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual double VolPSF(double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//////////////////////////////////////////////////////////////////
+class GdlRho2D : public GeneralPSF2D {
+public:
+  GdlRho2D();
+  virtual ~GdlRho2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual double VolPSF(double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//////////////////////////////////////////////////////////////////
+class GdlRhInt2D : public GeneralPSF2D {
+public:
+  GdlRhInt2D();
+  virtual ~GdlRhInt2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual double VolPSF(double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//////////////////////////////////////////////////////////////////
+class Gdl1Rho2D : public GeneralPSF2D {
+public:
+  Gdl1Rho2D();
+  virtual ~Gdl1Rho2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual double VolPSF(double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//////////////////////////////////////////////////////////////////
+class Gdl1RhInt2D : public GeneralPSF2D {
+public:
+  Gdl1RhInt2D();
+  virtual ~Gdl1RhInt2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual double VolPSF(double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//////////////////////////////////////////////////////////////////
+class Gdl2Rho2D : public GeneralPSF2D {
+public:
+  Gdl2Rho2D();
+  virtual ~Gdl2Rho2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//////////////////////////////////////////////////////////////////
+class Gdl2RhInt2D : public GeneralPSF2D {
+public:
+  Gdl2RhInt2D();
+  virtual ~Gdl2RhInt2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//////////////////////////////////////////////////////////////////
+class MofRho2D : public GeneralPSF2D {
+public:
+  MofRho2D();
+  virtual ~MofRho2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual double VolPSF(double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//////////////////////////////////////////////////////////////////
+class MofRhInt2D : public GeneralPSF2D {
+public:
+  MofRhInt2D();
+  virtual ~MofRhInt2D();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* Par,double* DgDpar);
+  virtual double ValueH(double const xp[], double const* Par);
+  virtual double VolPSF(double const* Par);
+  virtual void   DefaultParam(double *Par);
+};
+
+//==============================================================================
+// CLASSES DE FONCTIONS 2D type Xi2 AVEC PARAMETRES POUR LE FIT pixel taille 1x1
+//==============================================================================
+
+//////////////////////////////////////////////////////////////////
+class X2_GauRho2D : public GeneralXi2 {
+public:
+  X2_GauRho2D();
+  virtual ~X2_GauRho2D();
+
+  virtual double Value(GeneralFitData& data, double* parm, int& ndataused);
+  virtual double Derivee2(GeneralFitData& data, int i,int j, double* parm);
+
+protected:
+  GauRho2D* gaurho2d;
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/fmath.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/fmath.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/fmath.h	(revision 1307)
@@ -0,0 +1,51 @@
+/*    Declaration de fonctions math pour float   */
+
+#ifndef  FMATH_H_SEEN
+#define  FMATH_H_SEEN
+
+#include <math.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef OSF1
+#define   fexp(x)       expf(x)
+#define   fsqrt(x)      sqrtf(x)
+#define   flog10(x)     log10f(x)
+#define   flog(x)       logf(x)
+#else
+#ifdef ULTRIX
+float     fexp(float x);            
+#define   expf(x)  fexp(x)
+float     fsqrt(float x);
+float     flog10(float x);
+float     flog(float x);
+#define   powf(x,y)    ((float) pow((double)(x), (double)(y)))
+#define   fabsf(x)    ((float)(fabs((double)(x))))
+#define   ceilf(x)  fceil(x)
+#define   nintf (int)
+#else
+#define   fexp(x)     ((float)(exp((double)(x))))
+#define   expf(x)     ((float)(exp((double)(x))))
+#define   fabsf(x)    ((float)(fabs((double)(x))))
+#define   fsqrt(x)    ((float)(sqrt((double)(x))))
+#define   sqrtf(x)    ((float)(sqrt((double)(x))))
+#define   flog10(x)   ((float)(log10((double)(x))))
+#define   log10f(x)   ((float)(log10((double)(x))))
+#define   flog(x)     ((float)(log((double)(x))))
+#define   logf(x)     ((float)(log((double)(x))))
+#define   floorf(x)   ((float) floor((double)(x)))
+#define   ceilf(x)    ((float) ceil((double)(x)))
+#define   powf(x,y)    ((float) pow((double)(x), (double)(y)))
+#define   nintf (int)
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/NTools/generaldata.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/generaldata.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/generaldata.cc	(revision 1307)
@@ -0,0 +1,1090 @@
+#include "defs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <math.h>
+#include <string.h>
+#include <string>
+
+#if defined(__KCC__)
+using std::string ;
+#endif
+
+#include "perrors.h"
+#include "nbtri.h"
+#include "generalfit.h"
+#include "generaldata.h"
+
+//================================================================
+// GeneralFitData
+//================================================================
+
+//++
+// Class	GeneralFitData
+// Lib		Outils++ 
+// include	generaldata.h
+//
+//	Classe de stoquage de donnees a plusieurs variables avec erreur
+//	sur l'ordonnee et sur les abscisses (options).
+//|   {x0(i),Ex0(i), x1(i),Ex1(i), x2(i),Ex2(i) ... ; Y(i),EY(i)}
+//--
+
+// Pour memoire, structure du rangement (n=mNVar):
+// - Valeur des abscisses mXP (idem pour mErrXP):
+//   x0,x1,x2,...,xn   x0,x1,x2,...,xn  ....  x0,x1,x2,....,xn
+//   |  1er point  |   |  2sd point  |  ....  | point mNData |
+//   Donc abscisse J=[0,mNVar[ du point numero I=[0,mNData[: mXP[I*mNVar+J]
+// - Valeur de l'ordonnee mF (idem pour mErr et mOK):
+//          f                f                      f
+//   |  1er point  |  |  2sd point  |  .... | point mNData |
+//   Donc point numero I [0,mNData[ : mF[i]
+
+//////////////////////////////////////////////////////////////////////
+//++
+GeneralFitData::GeneralFitData(unsigned int nVar, unsigned int ndatalloc, uint_2 errx)
+//
+//	Constructeur. ``nVar'' represente la dimension de l'espace des abscisses,
+//	``ndatalloc'' le nombre maximum de points et ``errx'' si non nul
+//	indique que l'on fournit des erreurs sur les ``nVar'' variables en abscisse.
+//--
+  : mNVar(0), mNDataAlloc(0), mNData(0), mNDataGood(0), mOk_EXP(0)
+  , mXP(NULL), mErrXP(NULL), mF(NULL), mErr(NULL), mOK(NULL)
+  , BuffVar(NULL), BuffVarR4(NULL)
+{
+ TRY {
+   Alloc(nVar,ndatalloc,errx);
+ } CATCHALL {
+   cout<<"GeneralFitData::GeneralFitData Impossible d'allouer l'espace"<<endl;
+   THROW_SAME;
+ } ENDTRY
+ END_CONSTRUCTOR
+}
+
+//++
+GeneralFitData::GeneralFitData(GeneralFitData& data, bool clean)
+//
+//	Constructeur par copie. Si ``clean'' est ``true''
+//	seules les donnees valides de ``data'' sont copiees.
+//	Si ``clean'' est ``false'' (defaut) toutes les donnees
+//	sont copiees et la taille totale de ``data'' est allouee
+//	meme si elle est plus grande que la taille des donnees stoquees.
+//--
+  : mNVar(0), mNDataAlloc(0), mNData(0), mNDataGood(0), mOk_EXP(0)
+  , mXP(NULL), mErrXP(NULL), mF(NULL), mErr(NULL), mOK(NULL)
+  , BuffVar(NULL), BuffVarR4(NULL)
+{
+ TRY {
+   Alloc(data.mNVar,((clean)?data.mNDataGood:data.mNDataAlloc),((data.mErrXP)?1:0));
+ } CATCHALL {
+   cout<<"GeneralFitData::GeneralFitData Impossible d'allouer l'espace"<<endl;
+   THROW_SAME;
+ } ENDTRY
+
+ // Remplissage
+ if(data.mNData>0) {
+   r_8* ret;
+   for(int i=0;i<data.mNData;i++) {
+     if( clean && data.mOK[i]==0 ) continue;
+       ret = data.GetVec(i,NULL);
+       memcpy(mXP+mNData*mNVar,ret,mNVar*sizeof(r_8));
+       if(mErrXP) memcpy(mErrXP+mNData*mNVar,ret+mNVar,mNVar*sizeof(r_8));
+       mF[mNData]   = ret[2*mNVar];
+       mErr[mNData] = ret[2*mNVar+1];
+       mOK[mNData]  = (uint_2) (ret[2*mNVar+2]+0.001);
+       if(mOK[mNData]!=0) mNDataGood++;
+       mNData++;
+   }
+ }
+
+ END_CONSTRUCTOR
+}
+
+//++
+GeneralFitData::GeneralFitData()
+//
+//	Constructeur par defaut.
+//--
+  : mNVar(0), mNDataAlloc(0), mNData(0), mNDataGood(0), mOk_EXP(0)
+  , mXP(NULL), mErrXP(NULL), mF(NULL), mErr(NULL), mOK(NULL)
+  , BuffVar(NULL), BuffVarR4(NULL)
+{
+ END_CONSTRUCTOR
+}
+
+//++
+GeneralFitData::GeneralFitData(char *flnm)
+//
+//	Constructeur par lecture d'un fichier ppersist..
+//--
+  : mNVar(0), mNDataAlloc(0), mNData(0), mNDataGood(0), mOk_EXP(0)
+  , mXP(NULL), mErrXP(NULL), mF(NULL), mErr(NULL), mOK(NULL)
+  , BuffVar(NULL), BuffVarR4(NULL)
+{
+  PInPersist s(flnm);
+  Read(s);
+  END_CONSTRUCTOR
+}
+
+//++
+GeneralFitData::~GeneralFitData()
+//
+//	Destructeur
+//--
+{
+ Delete();
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::Alloc(unsigned int nVar, unsigned int ndatalloc, int_2 errx)
+//
+//	Pour redefinir la structure de donnees (ou la creer si on a utilise
+//	le createur par defaut). Voir les explications des arguments
+//	dans les commentaires du constructeur. Si ``errx''<0 alors
+//	la valeur prise est celle definie auparavent.
+//--
+{
+DBASSERT( nVar>0 && ndatalloc>0 );
+
+Delete();
+
+if(errx>=0) mOk_EXP = (uint_2) errx;
+mNVar = nVar;
+mNDataAlloc = ndatalloc;
+
+TRY {
+  mXP  = new r_8[nVar*ndatalloc];
+  if(mOk_EXP) mErrXP  = new r_8[nVar*ndatalloc];
+  mF   = new r_8[ndatalloc];
+  mErr = new r_8[ndatalloc];
+  mOK  = new uint_2[ndatalloc];
+  BuffVar   = new r_8[2*nVar+3];
+  BuffVarR4 = (r_4 *) BuffVar;
+} CATCHALL {
+  THROW_SAME;
+} ENDTRY
+}
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFitData::Delete()
+{
+mNVar = mNDataAlloc = mNData = mNDataGood = 0;
+if( mXP  != NULL ) {delete [] mXP;  mXP  = NULL;}
+if( mErrXP  != NULL ) {delete [] mErrXP;  mErrXP  = NULL;}
+if( mF   != NULL ) {delete [] mF;   mF   = NULL;}
+if( mErr != NULL ) {delete [] mErr; mErr = NULL;}
+if( mOK  != NULL ) {delete [] mOK;  mOK  = NULL;}
+if( BuffVar  != NULL ) {delete [] BuffVar; BuffVar = NULL; BuffVarR4 = NULL;}
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::SetDataPtr(int ptr)
+//
+//	Remise a zero de la structure pour nouveau remplissage (pas d'arg)
+//	ou remise a la position ``ptr'' (si arg). Les donnees apres ``ptr''
+//	sont sur-ecrites.
+//--
+{
+ DBASSERT(ptr >= 0 && ptr < mNDataAlloc);
+ mNData = ptr;
+ mNDataGood = 0;
+ if(ptr==0) return;
+ for(int i=0;i<mNData;i++) if(mOK[i]) mNDataGood++;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::KillData(int i)
+//
+//	Pour tuer un point
+//--
+{
+ DBASSERT(i >= 0 && i < mNData);
+
+ if( ! mOK[i] ) return;
+ mOK[i] = 0;
+ mNDataGood--;
+}
+
+//++
+void GeneralFitData::KillData(int i1,int i2)
+//
+//	Pour tuer une serie de points
+//--
+{
+ DBASSERT(i1 >= 0 && i1 < mNData);
+ DBASSERT(i2 >= 0 && i2 < mNData);
+ DBASSERT(i1 <= i2 );
+
+ for(int i=i1;i<=i2;i++) KillData(i);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::ValidData(int i)
+//
+//	Pour re-valider le point numero i ([0,NData]).
+//--
+{
+ DBASSERT(i >= 0 && i < mNData);
+
+ if( mOK[i] ) return;
+ if( mErr[i]<=0. ) return;
+ if(mOk_EXP) {
+   for(int j=0;j<mNVar;j++) if(mErrXP[i*mNVar+j]<=0.) return;
+ }
+ mOK[i] = 1;
+ mNDataGood++;
+}
+
+//++
+void GeneralFitData::ValidData(int i1,int i2)
+//
+//	Pour re-valider les points numeros i1 a i2.
+//--
+{
+ DBASSERT(i1 >= 0 && i1 < mNData);
+ DBASSERT(i2 >= 0 && i2 < mNData);
+ DBASSERT(i1 <= i2 );
+
+ for(int i=i1;i<=i2;i++) ValidData(i);
+}
+
+//++
+void GeneralFitData::ValidData()
+//
+//	Pour re-valider tous les points.
+//--
+{
+ for(int i=0;i<mNData;i++) ValidData(i);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::RedefineData1(int i,double x,double f,double err,double errx)
+//
+//	Pour redefinir un point a
+//|     {x,[errx] ; f,err}
+//--
+{
+ RedefineData(i,&x,f,err,&errx);
+}
+
+//++
+void GeneralFitData::RedefineData2(int i,double x,double y,double f
+                                  ,double err,double errx,double erry)
+//
+//	Pour redefinir un point a
+//|     {x,[errx], y,[erry] ; f,err}
+//--
+{
+ double xp[2] = {x,y};
+ double errxp[2] = {errx,erry};
+ RedefineData(i,xp,f,err,errxp);
+}
+
+//++
+void GeneralFitData::RedefineData(int i,double* xp,double f,double err,double* errxp)
+//
+//	Pour redefinir un point a
+//| {xp[0],[errxp[0]], xp[1],[errxp[1]], xp[2],[errxp[2]],... ; f,err}
+//--
+{
+ DBASSERT(i>=0 && i<mNData);
+ bool ok = true;
+
+ int ip = mNVar*i;
+ for(int j=0;j<mNVar;j++) mXP[ip+j] = xp[j];
+ if(mOk_EXP) {
+   if(errxp) {
+     for(int j=0;j<mNVar;j++)
+       {mErrXP[ip+j] = errxp[j]; if(errxp[j]<=0.) ok=false;}
+   } else {
+     for(int j=0;j<mNVar;j++) mErrXP[ip+j] = Def_ErrX;
+     ok=false;
+   }
+ }
+ mF[i] = f;
+ mErr[i] = err;  if(err<=0.) ok = false;
+ if(ok) {
+   if(! mOK[i]) {mOK[i]=1; mNDataGood++;}
+ } else {
+   if(  mOK[i]) {mOK[i]=0; mNDataGood--;}
+ }
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::AddData1(double x, double f, double err, double errx)
+//
+//	Pour ajouter un point
+//|     {x,[errx] ; f,err}
+//--
+{
+ AddData(&x,f,err,&errx);
+}
+
+//++
+void GeneralFitData::AddData2(double x, double y, double f
+                             , double err, double errx, double erry)
+//
+//	Pour ajouter un point
+//|     {x,[errx], y,[erry] ; f,err}
+//--
+{
+ double xp[2] = {x,y};
+ double errxp[2] = {errx,erry};
+ AddData(xp,f,err,errxp);
+}
+
+//++
+void GeneralFitData::AddData(double* xp, double f, double err,double* errxp)
+//
+//	Pour ajouter un point
+//| {xp[0],[errxp[0]], xp[1],[errxp[1]], xp[2],[errxp[2]],... ; f,err}
+//--
+{
+ DBASSERT(mNData < mNDataAlloc);
+ bool ok = true;
+
+ int ip = mNVar*mNData;
+ for(int i=0;i<mNVar;i++) mXP[ip+i] = xp[i];
+ if(mOk_EXP) {
+   if(errxp) {
+     for(int j=0;j<mNVar;j++)
+       {mErrXP[ip+j] = errxp[j]; if(errxp[j]<=0.) ok=false;}
+   } else {
+     for(int j=0;j<mNVar;j++) mErrXP[ip+j] = Def_ErrX;
+     ok=false;
+   }
+ }
+ mF[mNData] = f;
+ mErr[mNData] = err;
+ if(err<=0.) ok = false;
+ if(ok) { mOK[mNData]=1; mNDataGood++; } else mOK[mNData]=0;
+ mNData++;
+}
+
+//++
+void GeneralFitData::AddData(float* xp, float f, float err, float* errxp)
+//
+//	Pour ajouter un point
+//| {xp[0],[errxp[0]], xp[1],[errxp[1]], xp[2],[errxp[2]],... ; f,err}
+//--
+{
+ {for(int i=0;i<mNVar;i++) BuffVar[i] = (double) xp[i];}
+ if(errxp) for(int i=0;i<mNVar;i++) BuffVar[mNVar+i] = (double) errxp[i];
+ AddData(BuffVar,(double) f,(double)  err,BuffVar+mNVar);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::SetData1(int nData
+            , double* x, double* f, double *err, double *errx)
+//
+//	Pour remplir la structure de donnees d'un seul coup avec
+//|     {x(i),[errx(i)] ; f(i),err(i)}
+//--
+{
+ DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
+
+ for(int i=0;i<nData;i++) {
+   double ex = (errx) ? errx[i]: Def_ErrX;
+   double ef = (err ) ? err[i]:  Def_ErrF;
+   AddData1(x[i],f[i],ef,ex);
+ }
+}
+
+//++
+void GeneralFitData::SetData1(int nData
+            , float* x, float* f, float* err, float *errx)
+//
+//	Pour remplir la structure de donnees d'un seul coup avec
+//|     {x(i),[errx(i)] ; f(i),err(i)}
+//--
+{
+ DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
+
+ for(int i=0;i<nData;i++) {
+   double ex = (errx) ? (double) errx[i]: Def_ErrX;
+   double ef = (err ) ? (double) err[i]:  Def_ErrF;
+   AddData1((double) x[i],(double) f[i],ef,ex);
+ }
+}
+
+//++
+void GeneralFitData::SetData2(int nData, double* x, double* y, double* f
+                             ,double *err,double *errx,double *erry)
+//
+//	Pour remplir la structure de donnees d'un seul coup avec
+//|     {x(i),[errx(i)], y(i),[erry(i)], ; f(i),err(i)}
+//--
+{
+ DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
+
+ for(int i=0;i<nData;i++) {
+   double ex = (errx) ? (double) errx[i]: Def_ErrX;
+   double ey = (erry) ? (double) erry[i]: Def_ErrX;
+   double ef = (err ) ? (double) err[i]:  Def_ErrF;
+   AddData2(x[i],y[i],f[i],ef,ex,ey);
+ }
+}
+
+//++
+void GeneralFitData::SetData2(int nData, float* x, float* y, float* f
+                             ,float *err,float *errx,float *erry)
+//
+//	Pour remplir la structure de donnees d'un seul coup avec
+//|     {x(i),[errx(i)], y(i),[erry(i)], ; f(i),err(i)}
+//--
+{
+ DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
+
+ for(int i=0;i<nData;i++) {
+   double ex = (errx) ? (double) errx[i]: Def_ErrX;
+   double ey = (erry) ? (double) erry[i]: Def_ErrX;
+   double ef = (err ) ? (double) err[i]:  Def_ErrF;
+   AddData2((double) x[i],(double) y[i],(double) f[i],ef,ex,ey);
+ }
+}
+
+//++
+void GeneralFitData::SetData(int nData,double** xp, double *f
+                            , double *err, double** errxp)
+//
+//	Pour remplir la structure de donnees d'un seul coup avec
+//|   {X0(i),[EX0(i)], X1(i),[EX1(i)], X2(i),[EX2(i)], ... ; F(i),Err(i)}
+//	Attention: si la structure est n'est pas vide, les tableaux sont copies
+//	apres les donnees pre-existantes (qui ne sont donc pas detruites). Pour
+//	effacer les donnees pre-existantes utiliser SetDataPtr(0).
+//|   Ici **xp est un pointeur sur un tableau de pointeurs tq
+//|     xp[0] = &X0[0], xp[1] = &X1[0], xp[2] = &X2[0] ...
+//|   ou X0,X1,X2,... sont les tableaux X0[nData] X1[nData] X2[nData] ...
+//|   des variables (meme commentaire pour errxp).
+//--
+{
+ DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
+ if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;}
+
+ for(int i=0;i<nData;i++) {
+   {for(int j=0;j<mNVar;j++) BuffVar[j] = *(xp[j]+i);}
+   if(mOk_EXP && errxp)
+     {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = *(errxp[j]+i);}
+   double ef = (err) ? err[i]:  Def_ErrF;
+   AddData(BuffVar,f[i],ef,BuffVar+mNVar);
+ }
+}
+
+//++
+void GeneralFitData::SetData(int nData,float** xp, float *f
+                            , float *err, float** errxp)
+//
+//	Voir commentaire ci-dessus.
+//--
+{
+ DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
+
+ if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;}
+
+ for(int i=0;i<nData;i++) {
+   {for(int j=0;j<mNVar;j++) BuffVar[j] = (double) *(xp[j]+i);}
+   if(mOk_EXP && errxp)
+     {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = (double) *(errxp[j]+i);}
+   double ef = (err) ? err[i]:  Def_ErrF;
+   AddData(BuffVar,(double) f[i],ef,BuffVar+mNVar);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::PrintStatus()
+//
+//	Impression de l'etat de la structure de donnees
+//--
+{
+  cout<<"GeneralFitData:: "<<endl
+      <<"NVar="<<mNVar<<" NDataAlloc="<<mNDataAlloc<<" Ok_EXP="<<mOk_EXP
+      <<" ,NData="<<mNData<<" NDataGood="<<mNDataGood<<endl
+      <<"  mXP="<<mXP<<"  [mErrXP="<<mErrXP<<"] mF="<<mF<<" mErr="<<mErr
+      <<" mOK="<<mOK<<endl;
+}
+
+//++
+void GeneralFitData::PrintData(int i)
+//
+//	Impression du point i
+//--
+{
+ DBASSERT(i>=0 && i<mNData);
+
+ cout<<" "<<i<<" F( ";
+ {for(int j=0;j<mNVar;j++) cout<<" "<<Absc(j,i);}
+ if(mOk_EXP) {
+   cout<<"  ;  ";
+   for(int j=0;j<mNVar;j++) cout<<" "<<EAbsc(j,i);
+ }
+ cout<<")= "<<Val(i)<<" "<<EVal(i)<<" ("<<IsValid(i)<<")\n";
+}
+
+//++
+void GeneralFitData::PrintData(int i1,int i2)
+//
+//	Impression des points i1 a i2
+//--
+{
+ if(i1<0) i1=0;
+ if(i1>=mNData) i1 = mNData-1;
+ if(i2>=mNData) i2 = mNData-1;
+ if(i1>i2) i2 = mNData-1;
+
+ cout<<"GeneralFitData::PrintData[NData="
+     <<mNData<<"/ NDataGood="<<mNDataGood<<"]"<<endl;
+ for(int i=i1;i<=i2;i++) PrintData(i);
+ cout<<flush;
+}
+
+//++
+void GeneralFitData::PrintData()
+//
+//	Impression de tous les points
+//--
+{
+ DBASSERT(mNData>0);
+
+ PrintData(0,mNData-1);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+int GeneralFitData::GetMinMax(int var,int& imin,int& imax)
+//
+//	Retourne les numeros des points de valeurs minimum et maximum
+//	de la variable ``var'':
+//| La variable "var" est de la forme : var = AB avec
+//|  B = 0 : variable d'ordonnee Y (valeur de A indifferente)
+//|  B = 1 : erreur variable d'ordonnee EY (valeur de A indifferente)
+//|  B = 2 : variable d'abscisse X numero A #[0,NVar[
+//|  B = 3 : erreur variable d'abscisse EX numero A #[0,NVar[
+//| - Return NData checked si ok, -1 si probleme.
+//--
+{
+imin = imax = -1;
+int ix = var/10;
+var = var%10;
+if(var<0 || var>3) return -1;
+if(var>=2 && (ix<0 || ix>=mNVar) ) return -1;
+double min, max;
+int ntest = 0;
+for(int i=0;i<mNData;i++) {
+  if( ! IsValid(i) ) continue;
+  double v;
+  if(var==0)      v = Val(i);
+  else if(var==1) v = EVal(i);
+  else if(var==2) v = Absc(ix,i);
+  else if(var==3) v = EAbsc(ix,i);
+  if(ntest==0) {min = max = v; imin = imax = i;}
+  if(v<min) {min = v; imin = i;}
+  if(v>max) {max = v; imax = i;}
+  ntest++;
+}
+return ntest;
+}
+
+//++
+int GeneralFitData::GetMinMax(int var,double& min,double& max)
+//
+//	Retourne le minimum et le maximum de la variable ``var''
+//	(cf commentaires GetMinMax).
+//--
+{
+min = 1.; max = -1.;
+int imin,imax;
+int ntest = GetMinMax(var,imin,imax);
+if(ntest<=0) return ntest;
+int ix = var/10;
+var = var%10;
+if(var==0) {
+  if(imin>=0) min = Val(imin);
+  if(imax>=0) max = Val(imax);
+} else if(var==1) {
+  if(imin>=0) min = EVal(imin);
+  if(imax>=0) max = EVal(imax);
+} else if(var==2) {
+  if(imin>=0) min = Absc(ix,imin);
+  if(imax>=0) max = Absc(ix,imax);
+} else if(var==3) {
+  if(imin>=0) min = EAbsc(ix,imin);
+  if(imax>=0) max = EAbsc(ix,imax);
+}
+return ntest;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+int GeneralFitData::GetMeanSigma(int var,double& mean,double& sigma,double min,double max)
+//
+//	Retourne la moyenne et le sigma de la variable ``var''
+//	(cf commentaires GetMinMax).
+//| - Return : nombre de donnees utilisees, -1 si pb, -2 si sigma<0.
+//| - Seuls les points valides de valeur entre min,max sont utilises.
+//|   Si min>=max pas de coupures sur les valeurs.
+//--
+{
+mean = sigma = 0.;
+int ix = var/10;
+var = var%10;
+if(var<0 || var>3) return -1;
+if(var>=2 && (ix<0 || ix>=mNVar) ) return -1;
+int ntest = 0;
+for(int i=0;i<mNData;i++) {
+  if( ! IsValid(i) ) continue;
+  double v;
+  if(var==0)      v = Val(i);
+  else if(var==1) v = EVal(i);
+  else if(var==2) v = Absc(ix,i);
+  else if(var==3) v = EAbsc(ix,i);
+  if(min<max && (v<min || max<v)) continue;
+  mean += v;
+  sigma += v*v;
+  ntest++;
+}
+if(ntest==0) {
+  mean = sigma = 0.;
+} else {
+  mean /= (double)ntest;
+  sigma = sigma/(double)ntest - mean*mean;
+  if(sigma<0.) ntest = -2;
+  else if(sigma>0.) sigma = sqrt(sigma);
+}
+return ntest;
+}
+
+//++
+int GeneralFitData::GetMoMeMed(int var,double& mode,double& mean,double& median,
+                               double min,double max,double coeff)
+//
+//	Retourne le mode de la variable ``var''
+//	(cf commentaires GetMinMax).
+//| - Return : nombre de donnees utilisees, -1 si pb.
+//| - Seuls les points valides de valeur entre min,max sont utilises.
+//|   Si min>=max pas de coupures sur les valeurs.
+//| - Le calcul du mode est approximee par la formule:
+//|     Mode = Median - coeff*(Mean-Median)   (def: coeff=0.8)
+//| - Kendall and Stuart donne coeff=2., mais coeff peut etre regle.
+//--
+{
+mode = mean = median = 0.;
+if(mNData<=0) return -1;
+int ix = var/10;
+var = var%10;
+if(var<0 || var>3) return -1;
+if(var>=2 && (ix<0 || ix>=mNVar) ) return -1;
+double* buff = new double[mNData];
+int ntest = 0;
+for(int i=0;i<mNData;i++) {
+  if( ! IsValid(i) ) continue;
+  double v;
+  if(var==0)      v = Val(i);
+  else if(var==1) v = EVal(i);
+  else if(var==2) v = Absc(ix,i);
+  else if(var==3) v = EAbsc(ix,i);
+  if(min<max && (v<min || max<v)) continue;
+  buff[ntest] = v;
+  mean += v;
+  ntest++;
+}
+if(ntest==0) {
+  mean = 0.;
+} else {
+  mean /= (double)ntest;
+  qsort(buff,(size_t) ntest,sizeof(double),qSort_Dble);
+  int im;
+  if(ntest%2==1) {
+    // nombre impair de points
+    im = ntest/2;
+    median = buff[im];
+  } else {
+    // nombre pair de points
+    im = (ntest-1)/2;
+    median = (buff[im]+buff[im+1])/2.;
+  }
+  mode = median - coeff*(mean-median);
+}
+delete [] buff;
+return ntest;
+}
+
+//++
+int GeneralFitData::GetMode(int var,double& mode,double min,double max,double coeff)
+//
+//	Cf description ci-dessus ``GetMoMeMed''.
+//--
+{
+double mean,median;
+return GetMoMeMed(var,mode,mean,median,min,max,coeff);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+double GeneralFitData::PolFit(int varx,Poly& pol,int degre,bool ey)
+//
+//	Pour fiter un polynome de degre ``degre''. On fite
+//	Y=f(X) ou Y=Val et X=Absc(varx). Si ``ey'' est ``true''
+//	le fit prend en compte les erreurs stoquees dans EVal,
+//	sinon fit sans erreurs. Le resultat du fit est retourne
+//	dans le polynome ``pol''.
+//| Return:
+//|  -   Res = le residu du fit
+//|  -   -1 si degre<0
+//|  -   -2 si probleme sur numero de variable X
+//|  -   -4 si NDataGood<0
+//|  -   -5 si nombre de data trouves different de NDataGood
+//--
+{
+if(degre<0) return -1.;
+if(varx<0 || varx>=mNVar) return -2.;
+if(mNDataGood<=0) return -4.;
+Vector x(mNDataGood);
+Vector y(mNDataGood);
+Vector ey2(1);
+if(ey) ey2.Realloc(mNDataGood,true);
+int ntest = 0;
+for(int i=0;i<mNData;i++) {
+  if( ! IsValid(i) ) continue;
+  if(ntest>=mNDataGood) return -5.;
+  x(ntest) = Absc(varx,i);
+  y(ntest) = Val(i);
+  if(ey) ey2(ntest) = EVal(i)*EVal(i);
+  ntest++;
+}
+double res = 0.;
+if(ey) {
+  Vector errcoef(1);
+  res = pol.Fit(x,y,ey2,degre,errcoef);
+} else {
+  res = pol.Fit(x,y,degre);
+}
+return res;
+}
+
+//++
+double GeneralFitData::PolFit(int varx,int vary,Poly2& pol,int degre1,int degre2,bool ez)
+//
+//
+//	Pour fiter un polynome de degre ``degre1''. On fite
+//	Z=f(X,Y) ou Z=Val et X=Absc(varx) et Y=Absc(vary).
+//	Si ``ey'' est ``true'' le fit prend en compte les erreurs
+//	stoquees dans EVal, sinon fit sans erreurs. Si ``degre2''
+//	negatif, le fit determine un polynome en X,Y de degre
+//	total ``degre`''. Si ``degre2'' positif ou nul, le fit
+//	demande un fit de ``degre1'' pour la variable X et de degre
+//	``degre2'' sur la variable Y. Le resultat du fit est retourne
+//	dans le polynome ``pol''.
+//| Return:
+//|  -   Res = le residu du fit
+//|  -   -1 si degre<0
+//|  -   -2 si probleme sur numero de variable X
+//|  -   -3 si probleme sur numero de variable Y
+//|  -   -4 si NDataGood<0
+//|  -   -5 si nombre de data trouves different de NDataGood
+//--
+{
+if(degre1<0) return -1.;
+if(varx<0 || varx>=mNVar) return -2.;
+if(vary<0 || vary>=mNVar || vary==varx) return -3.;
+if(mNDataGood<=0) return -4.;
+Vector x(mNDataGood);
+Vector y(mNDataGood);
+Vector z(mNDataGood);
+Vector ez2(1);
+if(ez) ez2.Realloc(mNDataGood,true);
+int ntest = 0;
+for(int i=0;i<mNData;i++) {
+  if( ! IsValid(i) ) continue;
+  if(ntest>=mNDataGood) return -5.;
+  x(ntest) = Absc(varx,i);
+  y(ntest) = Absc(vary,i);
+  z(ntest) = Val(i);
+  if(ez) ez2(ntest) = EVal(i)*EVal(i);
+  ntest++;
+}
+double res = 0.;
+if(ez) {
+  Vector errcoef(1);
+  if(degre2>0) res = pol.Fit(x,y,z,ez2,degre1,degre2,errcoef);
+  else         res = pol.Fit(x,y,z,ez2,degre1,errcoef);
+} else {
+  if(degre2>0) res = pol.Fit(x,y,z,degre1,degre2);
+  else         res = pol.Fit(x,y,z,degre1);
+}
+return res;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+GeneralFitData* GeneralFitData::FitResidus(GeneralFit& gfit)
+//
+//	Retourne une classe contenant les residus du fit ``gfit''.
+//--
+{
+if(gfit.GetNVar()!=mNVar) return NULL;
+return gfit.DataResidus(true);
+}
+
+//++
+GeneralFitData* GeneralFitData::FitFunction(GeneralFit& gfit)
+//
+//	Retourne une classe contenant la function du fit ``gfit''.
+//--
+{
+if(gfit.GetNVar()!=mNVar) return NULL;
+return gfit.DataFunction(true);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+r_8* GeneralFitData::GetVec(int n, r_8* ret)   const
+//
+//	Retourne la donnee `n' dans le vecteur de double `ret'.
+//| Par defaut, ret=NULL et le buffer interne de la classe est retourne
+//| - Les donnees sont rangees dans l'ordre:
+//|    x0,x1,x2,... ; ex0,ex1,ex2,...  ; y ; ey ; ok(0/1)
+//|    |<- NVar ->| + |<-   NVar   ->| + 1 +  1 +  1
+//|   Le vecteur ret a la taille 2*NVar+2+1
+//--
+{
+int i;
+if (ret == NULL) ret = BuffVar;
+for(i=0; i<2*mNVar+3; i++)  ret[i] = 0.;
+if (n >= mNData) return(ret);
+
+memcpy(ret, mXP+n*mNVar, mNVar*sizeof(r_8));
+if(mErrXP) memcpy(ret+mNVar, mErrXP+n*mNVar, mNVar*sizeof(r_8));
+ret[2*mNVar] = mF[n];
+ret[2*mNVar+1] = mErr[n];
+ret[2*mNVar+2] = (double) mOK[n];
+return(ret);
+}
+
+//++
+r_4* GeneralFitData::GetVecR4(int n, r_4* ret)   const
+//
+//	Retourne la donnee `n' dans le vecteur de float `ret'
+//	(meme commentaires que pour GetVec).
+//--
+{
+if (ret == NULL) ret = BuffVarR4;
+double *buff = new double[2*mNVar+3];
+GetVec(n,buff);
+for(int i=0;i<2*mNVar+3;i++) ret[i] = (float) buff[i];
+delete [] buff;
+return ret;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+string GeneralFitData::VarList_C(const char* nomx)  const
+//
+//	Retourne une chaine de caracteres avec la declaration des noms de 
+//	variables. si "nomx!=NULL" , des instructions d'affectation
+//	a partir d'un tableau "nomx[i]" sont ajoutees. 
+//--
+{
+char buff[256];
+string rets;
+int i;
+rets = "\ndouble";
+for(i=0; i<mNVar; i++) {
+  sprintf(buff," x%d, ex%d",i,i);
+  rets += buff;
+  if(i!=mNVar-1) rets += ","; else rets += ";\n";
+}
+sprintf(buff,"\ndouble y, ey, ok;\n");
+rets += buff;
+if (nomx) {
+  for(i=0; i<mNVar; i++) {
+    sprintf(buff,"x%d=%s[%d];\n", i, nomx, i);
+    rets += buff;
+  }
+  for(i=0; i<mNVar; i++) {
+    sprintf(buff,"ex%d=%s[%d];\n", i, nomx, mNVar+i);
+    rets += buff;
+  }
+}
+sprintf(buff,"y=%s[%d];\ney=%s[%d];\nok=%s[%d];\n"
+       ,nomx,2*mNVar,nomx,2*mNVar+1,nomx,2*mNVar+2);
+rets += buff;
+
+return(rets);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::WriteSelf(POutPersist& s)  const
+//
+//	Ecriture ppersist
+//--
+{
+char strg[256];
+
+// Ecriture entete pour identifier facilement
+sprintf(strg,"GeneralFitData: NVar=%d NDataAlloc=%d NData=%d NDataGood=%d Ok_EXP=%d"
+       ,mNVar,mNDataAlloc,mNData,mNDataGood,mOk_EXP);
+s.PutLine(strg);
+
+// Ecriture des valeurs de definitions
+s.PutI4(mNVar);
+s.PutI4(mNDataAlloc);
+s.PutI4(mNData);
+s.PutI4(mNDataGood);
+s.PutU2(mOk_EXP);
+if(mNVar<=0 || mNDataAlloc<=0 || mNData<=0 || mNDataGood<0) return;
+
+// Ecriture des datas (on n'ecrit que mNData / mNDataAlloc)
+sprintf(strg
+       ,"GeneralFitData: Abscisses, Ordonnee, Erreur Ordonnee, Flag, Erreur Abscisses");
+s.PutLine(strg);
+
+int blen = mNVar + 3;
+if(mOk_EXP) blen += mNVar;
+double *buff = new double[blen];
+for(int i=0;i<mNData;i++) {
+  {for(int j=0;j<mNVar;j++) buff[j] = Absc(j,i);}
+  buff[mNVar] = Val(i);
+  buff[mNVar+1] = EVal(i);
+  buff[mNVar+2] = (double) IsValid(i);
+  if(mOk_EXP) {for(int j=0;j<mNVar;j++) buff[mNVar+3+j] = EAbsc(j,i);}
+  s.PutR8s(buff, blen);
+}
+delete [] buff;
+
+return;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFitData::ReadSelf(PInPersist& s)
+//
+//	Lecture ppersist
+//--
+{
+char strg[256];
+
+Delete();
+
+// Lecture entete
+s.GetLine(strg, 255);
+
+// Ecriture des valeurs de definitions
+int_4 nvar,ndatalloc,ndata,ndatagood;
+s.GetI4(nvar);
+s.GetI4(ndatalloc);
+s.GetI4(ndata);
+s.GetI4(ndatagood);
+s.GetU2(mOk_EXP);
+if(nvar<=0 || ndatalloc<=0 || ndata<=0 || ndatagood<0 || ndatalloc<ndata) return;
+
+// Allocation de la place (attention Alloc efface mNData,mNDataGood);
+Alloc(nvar,ndatalloc,-1);
+mNData = ndata;
+mNDataGood = ndatagood;
+
+// Lecture des datas
+s.GetLine(strg, 255);
+int blen = mNVar + 3;
+if(mOk_EXP) blen += mNVar;
+double *buff = new double[blen];
+for(int i=0;i<mNData;i++) {
+  s.GetR8s(buff, blen);
+  int ip = i*mNVar;
+  {for(int j=0;j<mNVar;j++)  mXP[ip+j] = buff[j];}
+  mF[i] = buff[mNVar];
+  mErr[i] = buff[mNVar+1];
+  mOK[i] = (uint_2)(buff[mNVar+2]+0.01);
+  if(mOk_EXP) {for(int j=0;j<mNVar;j++) mErrXP[ip+j] = buff[mNVar+3+j];}
+}
+delete [] buff;
+
+return;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+// int inline int GetSpaceFree() const
+//	Retourne la place restante dans la structure (nombre de
+//	donnees que l'on peut encore stoquer).
+//--
+//++
+// inline int  NVar()       const
+//	Retourne le nombre de variables Xi
+//--
+//++
+// inline int  NData()
+//	Retourne le nombre de donnees
+//--
+//++
+// inline int  NDataGood()  const
+//	Retourne le nombre de bonnes donnees (utilisees pour le fit)
+//--
+//++
+// inline int  NDataAlloc() const
+//	Retourne la place maximale allouee pour les donnees
+//--
+//++
+// inline unsigned short int IsValid(int i) const
+//	Retourne 1 si point valide, sinon 0
+//--
+//++
+// inline bool HasXErrors()
+//	Retourne ``true'' si il y a des erreurs sur les variables
+//	d'abscisse, ``false'' sinon.
+//--
+//++
+// inline double X1(int i) const
+//	Retourne l'abscisse pour 1 dimension (y=f(x)) donnee I
+//--
+//++
+// inline double X(int i) const
+//	Retourne la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I
+//--
+//++
+// inline double Y(int i) const
+//	Retourne la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I
+//--
+//++
+// inline double Z(int i) const
+//	Retourne la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I
+//--
+//++
+// inline double Absc(int j,int i) const
+//	Retourne la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I
+//--
+//++
+// inline double Val(int i) const
+//	Retourne la valeur de la Ieme donnee
+//--
+//++
+// inline double EX1(int i) const
+//	Retourne l'erreur (dx) sur l'abscisse pour 1 dimension (y=f(x)) donnee I
+//--
+//++
+// inline double EX(int i) const
+//	Retourne l'erreur (dx) sur la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I
+//--
+//++
+// inline double EY(int i) const
+//	Retourne l'erreur (dy) sur la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I
+//--
+//++
+// inline double EZ(int i) const
+//	Retourne l'erreur (dz) sur la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I
+//--
+//++
+// inline double EAbsc(int j,int i) const
+//	Retourne l'erreur (dxj) sur la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I
+//--
+//++
+// inline double EVal(int i) const {return mErr[i];}
+//	Retourne l'erreur de la Ieme donnee
+//--
Index: /tags/DPC_V0/SophyaLib/NTools/generaldata.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/generaldata.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/generaldata.h	(revision 1307)
@@ -0,0 +1,138 @@
+#ifndef GENERALDATA_SEEN
+#define GENERALDATA_SEEN
+
+#include "exceptions.h"
+#include "ppersist.h"
+#include "poly.h"
+
+class GeneralFit;
+
+//================================================================
+// GENERALFITDATA
+//================================================================
+
+class GeneralFitData : public PPersist {
+public:
+  enum {classId = ClassId_GeneralFitData };
+  enum {Def_ErrF = 1, Def_ErrX = 0};
+
+  GeneralFitData(unsigned int nVar, unsigned int nDataAlloc, uint_2 errx=0);
+  GeneralFitData(GeneralFitData& data, bool clean=false);
+  GeneralFitData();
+  GeneralFitData(char *flnm);
+  virtual ~GeneralFitData();
+
+  void Alloc(unsigned int nVar, unsigned int nDataAlloc, int_2 errx=-1);
+  void SetDataPtr(int ptr = 0);
+
+  void KillData(int i);
+  void KillData(int i1,int i2);
+
+  void ValidData(int i);
+  void ValidData(int i1,int i2);
+  void ValidData();
+
+  void RedefineData1(int i,double x,double f,double err=Def_ErrF,double errx=Def_ErrX);
+  void RedefineData2(int i,double x,double y,double f,double err=Def_ErrF
+                    ,double errx=Def_ErrX,double erry=Def_ErrX);
+  void RedefineData(int i,double* xp,double f,double err=Def_ErrF,double* errxp=NULL);
+
+  void AddData1(double x, double f, double err=Def_ErrF,double errx=Def_ErrX);
+  void AddData2(double x, double y, double f, double err=Def_ErrF
+               ,double errx=Def_ErrX,double erry=Def_ErrX);
+  void AddData(double* xp, double f, double err=Def_ErrF,double* errxp=NULL);
+  void AddData(float* xp, float f, float err=Def_ErrF,float* errxp=NULL);
+
+  void SetData1(int nData,double* x,double* f,double *err=NULL,double *errx=NULL);
+  void SetData1(int nData,float* x,float* f,float* err=NULL,float *errx=NULL);
+  void SetData2(int nData,double* x,double* y,double* f,double *err=NULL
+               ,double *errx=NULL,double *erry=NULL);
+  void SetData2(int nData,float* x,float* y,float* f,float* err=NULL
+               ,float *errx=NULL,float *erry=NULL);
+  void SetData(int nData,double** xp,double *f,double *err=NULL,double** errxp=NULL);
+  void SetData(int nData,float** xp,float* f,float* err=NULL,float** errxp=NULL);
+
+  void PrintStatus();
+  void PrintData(int i);
+  void PrintData(int i1,int i2);
+  void PrintData();
+
+  inline int GetSpaceFree() const { return mNDataAlloc - mNData; }
+  inline int NVar()       const {return mNVar;}
+  inline int NData()      const {return mNData;}
+  inline int NDataGood()  const {return mNDataGood;}
+  inline int NDataAlloc() const {return mNDataAlloc;}
+
+  inline unsigned short int IsValid(int i) const
+                {if(i>=0 && i<mNData) return mOK[i]; else return 0;}
+  inline bool HasXErrors() {if(mErrXP) return true; else return false;}
+
+  inline double X1(int i) const
+                {if(i>=0 && i<mNData) return mXP[i]; else return 0.;}
+  inline double X(int i) const
+                {if(i>=0 && i<mNData) return mXP[i*mNVar]; else return 0.;}
+  inline double Y(int i) const
+                {if(i>=0 && i<mNData && 1<mNVar) return mXP[i*mNVar+1]; else return 0.;}
+  inline double Z(int i) const
+                {if(i>=0 && i<mNData && 2<mNVar) return mXP[i*mNVar+2]; else return 0.;}
+  inline double Absc(int j,int i) const
+                {if(i>=0 && i<mNData && j<mNVar)return mXP[i*mNVar+j]; else return 0.;}
+  inline double Val(int i) const
+                {if(i>=0 && i<mNData) return mF[i]; else return 0.;}
+
+  inline double EX1(int i) const
+                {if(mErrXP && i>=0 && i<mNData) return mErrXP[i]; else return 0.;}
+  inline double EX(int i) const
+                {if(mErrXP && i>=0 && i<mNData) return mErrXP[i*mNVar]; else return 0.;}
+  inline double EY(int i) const
+                {if(mErrXP && i>=0 && i<mNData && 1<mNVar) return mErrXP[i*mNVar+1];
+                 else return 0.;}
+  inline double EZ(int i) const
+                {if(mErrXP && i>=0 && i<mNData && 2<mNVar) return mErrXP[i*mNVar+2];
+                 else return 0.;}
+  inline double EAbsc(int j,int i) const
+                {if(mErrXP && i>=0 && i<mNData && j<mNVar) return mErrXP[i*mNVar+j];
+                 else return 0.;}
+  inline double EVal(int i) const
+                {if(i>=0 && i<mNData) return mErr[i]; else return 0.;}
+
+  r_8* GetVec(int n, r_8* ret=NULL)  const ;
+  r_4* GetVecR4(int n, r_4* ret=NULL)  const ;
+  int GetMinMax(int var,int& imin,int& imax);
+  int GetMinMax(int var,double& min,double& max);
+  int GetMeanSigma(int var,double& mean,double& sigma,double min=1.,double max=-1.);
+  int GetMoMeMed(int var,double& mode,double& mean,double& median,
+                 double min=1.,double max=-1.,double coeff=0.8);
+  int GetMode(int var,double& mode,double min=1.,double max=-1.,double coeff=0.8);
+  double PolFit(int varx,Poly& pol,int degre,bool ey=true);
+  double PolFit(int varx,int vary,Poly2& pol,int degre1,int degre2=-1,bool ez=true);
+  GeneralFitData* FitResidus(GeneralFit& gfit);
+  GeneralFitData* FitFunction(GeneralFit& gfit);
+  string VarList_C(const char* nomx)  const;
+
+  int_4             ClassId() const        { return classId; }
+  static PPersist*  Create()               { return new GeneralFitData;}
+
+  virtual void      WriteSelf(POutPersist&) const;
+  virtual void      ReadSelf(PInPersist&);
+
+friend class GeneralFit;
+
+protected:
+  void Delete();
+
+  int_4   mNVar;
+  int_4   mNDataAlloc;
+  int_4   mNData;
+  int_4   mNDataGood;
+  uint_2  mOk_EXP;
+  r_8* mXP;             // x0 y0 z0, x1 y1 z1, ..., xn yn zn 
+  r_8* mErrXP;          // Ex0 Ey0 Ez0, Ex1 Ey1 Ez1, ..., Exn Eyn Ezn 
+  r_8* mF;              // F0, F1, ...., Fn
+  r_8* mErr;            // EF0, EF1, ...., EFn
+  uint_2* mOK; // 1 si pt valid, 0 sinon
+  r_8* BuffVar;
+  r_4* BuffVarR4;
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/generalfit.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/generalfit.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/generalfit.cc	(revision 1307)
@@ -0,0 +1,1884 @@
+#include "defs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <math.h>
+#include <string.h>
+#include <string>
+
+#if defined(__KCC__)
+using std::string ;
+#endif
+
+#include "generalfit.h"
+#include "perrors.h"
+#include "cvector.h"
+#include "nbconst.h"
+#include "tabmath.h"
+
+#define EPS_FIT_MIN 1.e-8
+
+//================================================================
+// GeneralFunction
+//================================================================
+
+//++
+// Class	GeneralFunction
+// Lib	Outils++ 
+// include	generalfit.h
+//
+//	Classe de fonctions parametrees a plusieurs variables.
+//|           F[x1,x2,x3,...:a1,a2,a3,...]
+//--
+
+//////////////////////////////////////////////////////////////////////
+//++
+GeneralFunction::GeneralFunction(unsigned int nVar, unsigned int nPar)
+//
+//	Creation d'une fonction de `nVar' variables et `nPar' parametres.
+//|  F[x(1),x(2),x(3),...x(nVar) : a(1),a(2),a(3),...,a(nPar)]
+//--
+  : mNVar(nVar), mNPar(nPar)
+{
+ DBASSERT( nVar > 0 && nPar > 0 );
+ deltaParm = new double[nPar];
+ tmpParm   = new double[nPar];
+ END_CONSTRUCTOR
+}
+
+//++
+GeneralFunction::~GeneralFunction()
+//
+//--
+{
+ delete[] deltaParm;
+ delete[] tmpParm;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+double GeneralFunction::Val_Der(double const xp[], double const* parm
+                               , double *DgDpar)
+//
+//	Valeur et Derivees de la fonction (fct virtuelle par defaut).
+//--
+{
+ for(int i=0;i<mNPar;i++) tmpParm[i] = parm[i];
+ {for(int i=0;i<mNPar;i++) {
+   double d = deltaParm[i];
+   if(d==0.) { DgDpar[i] = 0.; continue;}
+   tmpParm[i] -= d/2.;
+   double vg = Value(xp,tmpParm);
+   tmpParm[i] += d;
+   double vd = Value(xp,tmpParm);
+   DgDpar[i] = (vd - vg)/d;
+   tmpParm[i] = parm[i];
+ }}
+ return Value(xp, parm);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFunction::SetDeltaParm(int numPar, double d)
+//
+//	Definition de la variation du parametre numPar
+//	pour calculer la derivee automatiquement.
+//--
+{
+ DBASSERT(numPar >= 0 && numPar < mNPar);
+ deltaParm[numPar] = d;
+}
+
+//++
+void GeneralFunction::SetDeltaParm(double const* dparam)
+//
+//	Idem precedente fonction mais pour tous les parametres
+//--
+{
+ for(int i=0;i<mNPar;i++) deltaParm[i] = dparam[i];
+}
+
+//////////////////////////////////////////////////////////////////////
+// Rappel des inline functions pour commentaires
+//++
+// virtual double Value(double const xp[], double const* parm)=0;
+//	Valeur de la fonction a definir par l'utilisateur (fct virtuelle pure)
+//--
+//++
+// inline int     NVar() const
+//	Retourne le nombre de variables Xi
+//--
+//++
+// inline int     NPar() const
+//	Retourne le nombre de parametres Ai
+//--
+
+//================================================================
+// GeneralFunc
+//================================================================
+
+//++
+// Class	GeneralFunc
+// Lib	Outils++ 
+// include	generalfit.h
+//
+//	Classe de fonctions parametrees a plusieurs variables
+//	derivant de ``GeneralFunction''. Permet de definir
+//	une fonction a fiter sans passer par une classe derivee
+//	en utilisant l'ecriture courante du C. La fonction
+//	retournant les derivees par rapport aux parametres du fit
+//	peut etre egalement fournie (optionnel).
+//--
+
+/////////////////////////////////////////////////////////////////
+//++
+GeneralFunc::GeneralFunc(unsigned int nvar, unsigned int npar, double (*fun) (double const*, double const*)
+                        , double (*funder) (double const*, double const*, double*) )
+//
+//	Createur, on passe le nom ``fun'' de la fonction a la mode C.
+//	On peut optionellement egalement passer le nom de la fonction
+//	``funder'' qui retourne les valeurs des derivees par rapport
+//	aux parametres du fit.
+//--
+//++
+//| ----------------------
+//| Exemple d'utilisation:
+//| ----------------------
+//| include "generalfit.h"
+//| ...
+//| double   gaussc(double const* x,double const* p);
+//| double d_gaussc(double const* x,double const* p,double* dp);
+//| ...
+//| main {
+//|  ...
+//|  // Fit SANS calcul automatique des derivees
+//|  GeneralFunc      myfunc(2,7,gaussc);
+//|  GeneralFit       myfit(&myfunc);
+//|  ...
+//|  myfit.Fit();
+//|  ...
+//|  // Fit AVEC calcul automatique des derivees
+//|  GeneralFunc      myfunc(2,7,gaussc,d_gaussc);
+//|  GeneralFit       myfit(&myfunc);
+//|  ...
+//|  myfit.Fit();
+//| }
+//--
+//++
+//| // Definition de la fonction a fitter a la mode C
+//| double gaussc(double const* x,double const* p)
+//| // Fonction: X=(x[0]-p[1])/p[3], Y=(x[1]-p[2])/p[4],
+//| //  f = p[0]*exp{-0.5*[X^2+Y^2-2*p[5]*X*Y]} + p[6]
+//| {
+//|  double X = (x[0]-p[1])/p[3];
+//|  double Y = (x[1]-p[2])/p[4];
+//|  return p[0]*exp(-(X*X+Y*Y-2*p[5]*X*Y)/2)+p[6];
+//| }
+//| // Definition de la fonction des derivees / parametres
+//| // Cette fonction retourne aussi la valeur de la fonction a fitter.
+//| double d_gaussc(double const* x,double const* p,double* dp)
+//| {
+//|  dp[0] = derivee de gaussc par rapport au parametre p[0]
+//|  ...
+//|  dp[6] = derivee de gaussc par rapport au parametre p[6]
+//|  return gaussc(x,p);
+//| }
+//--
+: GeneralFunction(nvar,npar), tmpFun(fun), tmpFunDer(funder)
+{
+}
+
+GeneralFunc::~GeneralFunc()
+{
+}
+
+double GeneralFunc::Value(double const xp[], double const* Par)
+{
+return tmpFun(xp,Par);
+}
+
+double GeneralFunc::Val_Der(double const xp[],double const* parm, double* DgDpar)
+{
+if(tmpFunDer) return tmpFunDer(xp,parm,DgDpar);
+  else        return GeneralFunction::Val_Der(xp,parm,DgDpar);
+}
+
+//================================================================
+// GeneralXi2
+//================================================================
+
+//++
+// Class	GeneralXi2
+// Lib	Outils++ 
+// include	generalfit.h
+//
+//	Classe de Xi2 a plusieurs parametres.
+//|           Xi2[a1,a2,a3,...]
+//--
+
+//////////////////////////////////////////////////////////////////////
+//++
+GeneralXi2::GeneralXi2(unsigned int nPar)
+//
+//	Creation d'un Xi2 de `nPar' parametres.
+//|  Xi2[a(1),a(2),a(3),...,a(nPar)]
+//--
+  : mNPar(nPar)
+{ 
+ DBASSERT( nPar>0 );
+ deltaParm = new double[nPar];
+ END_CONSTRUCTOR
+}
+
+//++
+GeneralXi2::~GeneralXi2()
+//
+//--
+{
+ delete[] deltaParm;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+double GeneralXi2::Derivee(GeneralFitData& data, int i, double* parm)
+//
+//	Derivee du Xi2 par rapport au parametre `i'
+//	pour les valeurs `parm' des parametres.
+//--
+{
+ int dum;
+ double d = deltaParm[i];
+ parm[i] -= d/2.;
+ double vg = Value(data, parm,dum);
+ parm[i] += d;
+ double vd = Value(data, parm,dum);
+ parm[i] -= d/2.;
+ return (vd - vg)/d;
+}
+
+//++
+double GeneralXi2::Derivee2(GeneralFitData& data, int i, int j, double* parm)
+//
+//	Derivee seconde du Xi2 par rapport aux parametres `i' et `j'
+//	pour les valeurs `parm' des parametres. Attention, cette fonction
+//	calcule d/di(dC2/dj), valeur qui est numeriquement differente
+//	de d/dj(dC2/di).
+//--
+//++
+//|
+//| **** Remarque: Derivee2 = dXi2/dPi.dPj represente le Hessien.
+//| Derivee2(k,l)= dXi2/dPk.dPl
+//|              = 2*SUMi{1/Si^2*[df(xi;P)/dPk * df(xi;P)/dPl]
+//|                       + [yi-f(xi;P)] * df(xi;P)/dPk.dPl }
+//| ou (xi,yi) sont les points de mesure. "Si" l'erreur sur le point i
+//|    SUMi represente la somme sur les points de mesure
+//|    f(x;P) represente le modele parametrique a fitter
+//|    "P" represente l'ensemble des parametres et "Pi" le ieme parametre
+//| Les composantes du Hessien dependent des derivees 1ere et 2sd du modele
+//| a fitter f(x;P) selon les parametres "Pi". La prise en compte des derivees
+//| secondes est un facteur destabilisant. De plus le facteur [yi-f(xi;P)]
+//| devant la derivee 2sd est seulement l'erreur de mesure aleatoire qui
+//| n'est pas correlee avec le modele. Le terme avec la derivee 2sd
+//| tend donc a s'annuler et peut donc etre omis.
+//| (cf. Numerical Recipes in C, chap 15 Modeling of Data, Nonlinear Models,
+//|  Calculation of the Gradient and Hessian p682,683)
+//|
+//| **** Conseil: Il est conseille a l'utilisateur de sur-ecrire
+//| la fonction virtuelle Derivee2 et de la remplacer par:
+//| Derivee2(k,l) = 2*SUMi{1/Si^2*[df(xi;P)/dPk * df(xi;P)/dPl]}
+//--
+{
+ double d = deltaParm[i];
+ parm[i] -= d/2.;
+ double vg = Derivee(data,j,parm);
+ parm[i] += d;
+ double vd = Derivee(data,j,parm);
+ parm[i] -= d/2.;
+ d = (vd - vg)/d;
+ return d;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralXi2::SetDeltaParm(int numPar, double d)
+//
+//	Definition de la variation du parametre numPar
+//	pour calculer la derivee automatiquement.
+//--
+{
+ DBASSERT(numPar >= 0 && numPar < mNPar);
+  
+ deltaParm[numPar] = d;
+}
+
+//++
+void GeneralXi2::SetDeltaParm(double const* dparam)
+//
+//	Idem precedente fonction mais pour tous les parametres.
+//--
+{
+ for(int i=0;i<mNPar;i++) deltaParm[i] = dparam[i];
+}
+
+//////////////////////////////////////////////////////////////////////
+// Rappel des inline functions pour commentaires
+//++
+// virtual double Value(GeneralFitData& data, double const* parm, int& ndataused)=0;
+//	Valeur du Xi2 a definir par l'utilisateur (fct virtuelle pure)
+//	a partir des donnees de `data'. l'utilisateur doit egalement
+//	retourner le nombre de points de mesure utilises dans le calcul
+//	du Xi2 (`ndataused').
+//--
+//++
+// inline int     NPar() const
+//	Retourne le nombre de parametres Ai.
+//--
+
+//================================================================
+// GeneralFit
+//================================================================
+//                                Christophe 8/11/93 La Silla
+//                                re-codage C++ 16/01/96 Saclay
+
+//++
+// Class	GeneralFit
+// Lib		Outils++
+// include	generalfit.h
+//
+//	Classe de fit d'une GeneralFunction sur une GeneralFitData
+//--
+
+//////////////////////////////////////////////////////////////////////
+//++
+GeneralFit::GeneralFit(GeneralFunction* f)
+//
+//	Creation d'une classe de fit pour la `GeneralFunction f'.
+//--
+  : mNVar         (f->NVar()),
+    mNPar         (f->NPar()),
+    mFunction     (f),
+    mFuncXi2      (NULL),
+
+    Param         (f->NPar()),
+    errParam      (f->NPar()),
+    stepParam     (f->NPar()),
+    minParam      (f->NPar()),
+    maxParam      (f->NPar()),
+    minStepDeriv  (f->NPar()),
+    Eps           (f->NPar()),
+  
+    ATGA          (f->NPar(), f->NPar()),
+    BETA          (f->NPar()),
+    ATGA_Try      (f->NPar(), f->NPar()),
+    BETA_Try      (f->NPar()),
+    C             (f->NPar()),
+    D             (f->NPar())
+{
+ DBASSERT(mNVar>0 && mNPar>0);
+ DBASSERT(mNPar<1000000);
+
+ TRY {
+   General_Init();
+ } CATCHALL {
+   THROW_SAME;
+ } ENDTRY
+
+ END_CONSTRUCTOR
+}
+
+//++
+GeneralFit::GeneralFit(GeneralXi2* f)
+//
+//	Creation d'une classe de fit pour le `GeneralXi2 f'.
+//	L'emploi de cette methode n'est pas conseillee car elle
+//	calcule automatiquement la derivee 2sd du Xi2 par rapport
+//	aux parametres, ce qui entraine un manque de robustesse
+//	et qui ne garanti pas que la matrice de covariance soit
+//	definie positive (il est possible de surecrire
+//	la methode virtuelle Derivee2 pour palier ce probleme).
+//--
+  : mNVar         (0),
+    mNPar         (f->NPar()),
+    mFunction     (NULL),
+    mFuncXi2      (f),
+
+    Param         (f->NPar()),
+    errParam      (f->NPar()),
+    stepParam     (f->NPar()),
+    minParam      (f->NPar()),
+    maxParam      (f->NPar()),
+    minStepDeriv  (f->NPar()),
+    Eps           (f->NPar()),
+  
+    ATGA          (f->NPar(), f->NPar()),
+    BETA          (f->NPar()),
+    ATGA_Try      (f->NPar(), f->NPar()),
+    BETA_Try      (f->NPar()),
+    C             (f->NPar()),
+    D             (f->NPar())
+{
+ DBASSERT( mNPar>0 );
+ DBASSERT( mNPar < 1000000 );
+
+ TRY {
+   General_Init();
+ } CATCHALL {
+   THROW_SAME;
+ } ENDTRY
+
+ END_CONSTRUCTOR
+}
+
+//
+void GeneralFit::General_Init(void)
+// Initialisation des diverses variables
+{
+ mNtry      = 0;
+ mNParFree  = mNPar;
+ mNParBound = 0;
+
+ mData      = NULL;
+
+ fixParam   = NULL;
+ boundParam = NULL;
+ nameParam  = NULL;
+
+ Lambda_Fac = 10.;
+ stopChi2   = 0.01;
+ maxStep    = 100;
+ nStopMx    = 3;
+ stopChi2SMx = stopChi2;
+ nStopLent  = 0;
+ debugLevel = 0;
+ FileStep = NULL;
+  
+ Chi2       = 0.;
+ mNddl      = -1;
+ nStep      = 0;
+ nStop      = 0;
+ nStopL     = 0;
+ Lambda     = 0.001;
+
+ GetIntEnv("PDEBUG_GENERALFIT",debugLevel);
+
+ TRY {
+   fixParam   = new unsigned short int[mNPar];
+   boundParam = new unsigned short int[mNPar];
+   nameParam  = new string[mNPar];
+ } CATCHALL {
+   cout<<"GeneralFit::GeneralFit Impossible d'allouer l'espace"<<endl;
+   THROW_SAME;
+ } ENDTRY
+
+ Param        = (double)  0.;
+ errParam     = (double)  0.;
+ stepParam    = (double)  1.;
+ minParam     = (double)  1.;
+ maxParam     = (double) -1.;
+ minStepDeriv = (double) 0.;
+ Eps          = (double) EPS_FIT_MIN;
+ char str[8];
+ for(int i=0;i<mNPar;i++) {
+   sprintf(str,"P%d",i);
+   fixParam[i]   = 0;
+   boundParam[i] = 0;
+   nameParam[i]  = str;
+ }
+}
+
+//++
+GeneralFit::~GeneralFit()
+//
+//--
+{
+ delete[] fixParam;
+ delete[] boundParam;
+ delete[] nameParam;
+ if(FileStep!=NULL) fclose(FileStep);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFit::WriteStep(char *filename)
+//
+//	Pour ecrire les iterations dans le fichier filename
+//--
+{
+
+#if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
+if(filename==NULL) filename = const_cast<char *>("generalfit.iter");
+#else
+if(filename==NULL) filename = "generalfit.iter";
+#endif
+FileStep = fopen(filename,"w");
+if(FileStep==NULL) THROW(nullPtrErr);
+}
+
+//++
+void GeneralFit::SetDebug(int level)
+//
+//	Niveau de debug
+//	(voir aussi la variable d'environnement PDEBUG_GENERALFIT).
+//--
+{
+ debugLevel = ( level < 0 ) ? 0: level;
+ if(debugLevel>0) cout<<"SetDebug_level "<<debugLevel<<endl;
+}
+
+//++
+void GeneralFit::SetMaxStep(int n)
+//
+//	Nombre maximum d'iterations permis.
+//--
+{
+ maxStep = ( n <= 1 ) ? 100: n;
+ if(debugLevel>0) cout<<"SetMaxStep "<<maxStep<<endl;
+}
+
+//++
+void GeneralFit::SetLambda_Fac(double fac)
+//
+//	Facteur de multiplication/division de Lambda selon
+//	que le Chi2 a augmente ou diminue.
+//--
+{
+  Lambda_Fac = (fac>1.) ? fac : 10.;
+}
+
+//++
+void GeneralFit::SetStopChi2(double s)
+//
+//	Critere de convergence sur le Chi2.
+//--
+{
+ stopChi2 = ( s <= 0. ) ? 0.01: s;
+ if(debugLevel>0) cout<<"SetStopChi2 "<<stopChi2<<endl;
+}
+
+//++
+void GeneralFit::SetEps(double ep)
+//
+//	Precision des calculs (cf descriptif general).
+//--
+{
+ ep = (ep<=0.) ? EPS_FIT_MIN: ep;
+ if(debugLevel>0) cout<<"SetEps "<<ep<<endl;
+ for(int i=0;i<mNPar;i++) SetEps(i,ep);
+}
+
+//++
+void GeneralFit::SetEps(int n,double ep)
+//
+//	Precision des calculs pour le parametre n.
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ Eps(n) = (ep<=0.) ? EPS_FIT_MIN: ep;
+ if(debugLevel>0) cout<<"SetEps("<<n<<") = "<<Eps(n)<<endl;
+}
+
+//++
+void GeneralFit::SetStopMx(int nstopmx,double stopchi2)
+//
+//	Critere de convergence sur le nombre de stop en chi2
+//	dans le cas ou le chi2 augmente de moins de stopchi2
+//	(cf descriptif general).
+//	Si nstopmx<=0, alors ce critere de convergence n'est pas applique.
+//	Si stopchi2<=0, alors la valeur generale mise par SetStopChi2()
+//	est utilisee.
+//--
+{
+ nStopMx = (nstopmx>0) ? nstopmx : 0;
+ stopChi2SMx = (stopchi2>0.) ? stopchi2 : stopChi2;
+ if(debugLevel>0) cout<<"SetStopMx: nStopMx="<<nStopMx
+                      <<" stopChi2SMx="<<stopChi2SMx<<endl;
+}
+
+//++
+void GeneralFit::SetStopLent(int nstoplent)
+//
+//	Critere de convergence sur le nombre de stop en chi2
+//	dans le cas ou le chi2 diminue (cf descriptif general).
+//	Si nstopl<=0, alors ce critere de convergence n'est pas applique.
+//--
+{
+ nStopLent = (nstoplent>0) ? nstoplent : 0;
+ if(debugLevel>0) cout<<"SetStopLent "<<nStopLent<<endl;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFit::SetFunction(GeneralFunction* f)
+//
+//	Pour changer la fonction a fitter en cours de route
+//	(On ne peut passer d'un fit sur une GeneralFunction
+//	a un fit sur un GeneralXi2 sans recreer la classe).
+//--
+{
+ DBASSERT( mFuncXi2  == NULL );
+ DBASSERT( f != NULL );
+ DBASSERT( f->NVar() == mNVar );
+ DBASSERT( f->NPar() == mNPar );
+ mFunction = f;
+ if(debugLevel>0) cout<<"SetFunction "<<mFunction<<endl;
+}
+
+//++
+void GeneralFit::SetFuncXi2(GeneralXi2* f)
+//
+//	Pour changer le Xi2 a fitter en cours de route
+//	(On ne peut passer d'un fit sur une GeneralFunction
+//	a un fit sur un GeneralXi2 sans recreer la classe).
+//--
+{
+ DBASSERT( mFunction == NULL );
+ DBASSERT( f != NULL );
+ DBASSERT( f->NPar() == mNPar );
+ mFuncXi2  = f;
+ if(debugLevel>0) cout<<"SetFuncXi2 "<<mFuncXi2<<endl;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFit::SetData(GeneralFitData* data)
+//
+//	Pour connecter une structure de donnees.
+//--
+{
+ DBASSERT( data->NVar()==mNVar || mFunction==NULL );
+ mData = data;
+ mNddl = mData->NDataGood() - mNParFree;
+ if(debugLevel>0)
+   cout<<"SetData "<<mData<<" data pour "<<mNddl<<" ddl"<<endl;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFit::SetParam(int n,double value,double step
+                         ,double min,double max)
+//
+//	Definition du parametre "n" a fitter.
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+
+ Param(n)     = value;
+ if(step>0.) {
+   if( fixParam[n] ) { fixParam[n]=0; mNParFree++;}
+ } else {
+   if( ! fixParam[n] ) { fixParam[n]=1; mNParFree--;}
+ }
+ stepParam(n) = step;
+ minParam(n)  = min;
+ maxParam(n)  = max;
+ if(max>min) {
+   if( ! boundParam[n] ) {boundParam[n]=1; mNParBound++;}
+ } else {
+   if( boundParam[n] ) {boundParam[n]=0; mNParBound--;}
+ }
+  
+ if(debugLevel) {cout<<"Set_"; PrintParm(n);}
+}
+
+//++
+void GeneralFit::SetParam(int n, string const& name
+                        ,double value,double step,double min,double max)
+//
+//	Definition du parametre "n" a fitter
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ SetParam(n,value,step,min,max);
+ nameParam[n] = name;
+ if(debugLevel) {cout<<"Set_Param "; PrintParm(n);}
+}
+
+//++
+void GeneralFit::SetParam(int n,double value)
+//
+//	Definition du parametre "n" a fitter
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ Param(n) = value;
+ if(debugLevel) {cout<<"Set_Param "; PrintParm(n);}
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFit::SetStep(int n,double step)
+//
+//	Definition du pas de depart du parametre "n"
+//	Si negatif ou nul, parametre fixe.
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ if(step>0.) {
+   if( fixParam[n] ) { fixParam[n]=0; mNParFree++;}
+ } else {
+   if( ! fixParam[n] ) { fixParam[n]=1; mNParFree--;}
+ }
+ stepParam(n) = step;
+ if(debugLevel) {cout<<"Set_Step"; PrintParm(n);}
+}
+
+//++
+void GeneralFit::SetMinStepDeriv(int i,double val)
+//
+//	Definition du pas minimum `val' pour le parametre `i'
+//	pouvant etre utilise dans le calcul automatique des derivees
+//	(soit de la fonction, soit du Xi2 selon les parametres du fit).
+//	Si nul pas de limite, si negatif alors `EPS(i)' (cf SetEps).
+//	Inutile dans le cas ou les derivees sont donnees
+//	par l'utilisateur.
+//--
+{
+ DBASSERT(i>=0 && i<mNPar);
+ if(val<0.) minStepDeriv(i) = Eps(i);
+   else     minStepDeriv(i) = val;
+ if(debugLevel>0) cout<<"SetMinStepDeriv("<<i<<") = "<<minStepDeriv(i)<<endl;
+}
+
+//++
+void GeneralFit::SetMinStepDeriv(double val)
+//
+//	Definition du pas minimum `val' pour tout les parametres
+//	(voir description SetMinStepDeriv ci-dessus).
+//--
+{
+ if(debugLevel>0) cout<<"SetMinStepDeriv "<<val<<endl;
+ for(int i=0;i<mNPar;i++) SetMinStepDeriv(i,val);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFit::SetBound(int n, double min, double max)
+//
+//	Definition des bornes du parametre "n"
+//	Si max<=min, parametre non-borne.
+//--
+{
+ DBASSERT(n>=0 && n<mNPar && max>min);
+
+ minParam(n)  = min;
+ maxParam(n)  = max;
+ if( ! boundParam[n] ) {
+   boundParam[n] = 1;
+   mNParBound++;
+   if(debugLevel>0)
+     cout<<"SetBound "<<n<<" min="<<min<<" max="<<max
+         <<" (Nbound="<<mNParBound<<")"<<endl;
+ }
+}
+
+//++
+void GeneralFit::SetBound(int n)
+//
+//	Pour re-borner le parametre "n" aux bornes par defaut
+//--
+{
+ DBASSERT(n>=0 && n<mNPar && maxParam(n)>minParam(n));
+ SetBound(n,minParam(n),maxParam(n));
+}
+
+//++
+void GeneralFit::SetUnBound(int n)
+//
+//	Pour ne plus borner le parametre "n"
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+
+ if( boundParam[n] ) {
+   boundParam[n] = 0;
+   mNParBound++;
+   if(debugLevel>0) cout<<" SetUnBound "<<n
+                        <<" (Nbound="<<mNParBound<<")"<<endl;
+ }
+}
+
+//++
+void GeneralFit::SetUnBound()
+//
+//	Pour ne plus borner tous les parametres
+//--
+{
+ for(int i=0;i<mNPar;i++) SetUnBound(i);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFit::SetFix(int n,double v)
+//
+//	Pour fixer le parametre "n" a la valeur "v"
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+
+ Param(n) = v;
+ if( ! fixParam[n] ) {
+   fixParam[n] = 1;
+   mNParFree--;
+ }
+ if(debugLevel>0) cout<<" SetFix "<<n
+                      <<" v="<<v
+                      <<" (Nfree="<<mNParFree
+                      <<")"<<endl;
+}
+
+//++
+void GeneralFit::SetFix(int n)
+//
+//	Pour fixer le parametre "n" a la valeur par defaut
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ SetFix(n,Param(n));
+}
+
+//++
+void GeneralFit::SetFree(int n)
+//
+//	Pour liberer le parametre "n"
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+
+ if( fixParam[n] ) {
+   fixParam[n] = 0;
+   mNParFree++;
+   if(debugLevel>0) cout<<" SetFree "<<n
+                        <<"   Step "<<stepParam(n)
+                        <<" (Nfree="<<mNParFree<<")"<<endl;
+   if(stepParam(n)<=0.)
+     cout<<"ATTENTION SetFree["<<n<<"] avec step<=0 "
+         <<stepParam(n)<<endl;
+ }
+}
+
+//++
+void GeneralFit::SetFree()
+//
+//	Pour liberer tous les parametres
+//--
+{
+ for(int i=0;i<mNPar;i++) SetFree(i);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+double GeneralFit::GetParm(int n)
+//
+//	Retourne la valeur du parametre "n"
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ return Param(n);
+}
+
+//++
+Vector GeneralFit::GetParm()
+//
+//	Retourne les valeurs des parametres dans un vecteur.
+//--
+{
+return Param;
+}
+
+//++
+double GeneralFit::GetParmErr(int n)
+//
+//	Retourne la valeur de l'erreur du parametre "n"
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ return errParam(n);
+}
+
+//++
+double GeneralFit::GetCoVar(int i,int j)
+//
+//	Retourne la covariance pour les parametre `i' et `j'
+//--
+{
+ DBASSERT(i>=0 && i<mNPar && j>=0 && j<mNPar);
+ return ATGA(i,j);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+double GeneralFit::GetStep(int n)
+//
+//	Retourne la valeur du pas du parametre "n"
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ return stepParam(n);
+}
+
+//++
+double GeneralFit::GetMax(int n)
+//
+//	Retourne la valeur de la borne superieure du parametre "n"
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ return maxParam(n);
+}
+
+//++
+double GeneralFit::GetMin(int n)
+//
+//	Retourne la valeur de la borne inferieure du parametre "n"
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+ return minParam(n);
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFit::PrintStatus()
+//
+//	Impression du status du fit
+//--
+{
+ cout<<"GeneralFit::PrintStatus"
+     <<" mData="<<mData
+     <<" mFunction="<<mFunction
+     <<" mFuncXi2="<<mFuncXi2
+     <<endl;
+ cout<<" mNVar="<<mNVar
+     <<" mNPar="<<mNPar
+     <<" mNParFree="<<mNParFree
+     <<" mNParBound="<<mNParBound
+     <<endl;
+ cout<<" Lambda_Fac="<<Lambda_Fac
+     <<" stopChi2="<<stopChi2
+     <<" maxStep="<<maxStep
+     <<" nStopMx="<<nStopMx<<" stopChi2SMx="<<stopChi2SMx
+     <<" nStopLent="<<nStopLent
+     <<" debugLevel="<<debugLevel
+     <<endl;
+ PrintParm();
+}
+
+//++
+void GeneralFit::PrintFit()
+//
+//	Impression des resultats du fit
+//--
+{
+ cout<<"PrintFit: Chi2="<<Chi2
+     <<" Lambda="<<Lambda
+     <<" nStep="<<nStep
+     <<" nStop="<<nStop
+     <<" nStopL="<<nStopL
+     <<" nDDL="<<mNddl
+     <<endl;
+ PrintParm();
+}
+
+//++
+void GeneralFit::PrintParm(int n)
+//
+//	Impression des informations relatives au parametre "n"
+//--
+{
+ DBASSERT(n>=0 && n<mNPar);
+
+ cout<<"Par["<<n<<"] "<<nameParam[n]
+     <<" F"<<fixParam[n]
+     <<" B"<<boundParam[n]
+     <<" : "<<Param(n)
+     <<" +/- "<<errParam(n)
+     <<" : "<<stepParam(n)
+     <<" "<<minParam(n)
+     <<" "<<maxParam(n)
+     <<" : "<<Eps(n)
+     <<" "<<minStepDeriv(n)
+     <<endl;
+}
+
+//++
+void GeneralFit::PrintParm()
+//
+//	Impression des informations relatives a tous les parametres
+//--
+{
+ cout<<"*** Parametres : fix bnd : par err : step min max : eps dmin\n";
+ for (int i=0; i<mNPar; i++) PrintParm(i);
+ cout<<endl;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+int GeneralFit::Fit()
+//
+//--
+//++
+//|  Fonction de fit de la fonction f(x,y,z,...:p1,p2,...,pn)
+//|          sur les donnees x[i],y[i],z[i],...,F[i],ErrF[i]
+//|  - Methode:   fit des moindres carres dans le cas non lineaire
+//|  - Reference: Statistical and Computational Methods in Data Analysis
+//|              Siegmund Brandt, North-Holland 1970  p 204-206.
+//|              Introduction des limites pour la variation des parametres (cmv).
+//|              Increment des parametres selon la methode de Levenberg-Marquardt
+//|  (Numerical Recipes in C, chap 15 Modeling of Data, Nonlinear Models,
+//|   Levenberg-Marquardt Method p683)
+//--
+//++
+//|  - Gestion des parametres bornes:
+//|     si p est un parametre borne entre pmin et pmax, le parametre fitte est q
+//|     tel que     q = tang((p-C)/D)    ....   p = C + D*atan(q)
+//|     ou   C = (pmin+pmax)/2.  et   D = (pmax-pmin)/Pi
+//|     On a  dq = (1+q**2)/D * dp    ....   dp = D/(1+q**2) * dq
+//|     et    dF/dq = dF/dp * dp/dq = D/(1+q**2) * dF/dp
+//|           dF/dp = dF/dq * dq/dp = (1+q**2)/D * dF/dp
+//|                                   ^ q
+//|                   |               |              *| "tang()"
+//|                   |               |              *|
+//|                   |               |              *|
+//|                   |               |             * |
+//|                   |               |            *  |
+//|                   |               |          *    |
+//|                   |               |       *       |
+//|               Pmin|              C|   *           |Pmax
+//|     --------------|---------------*---------------|--------------> p
+//|              -Pi/2|           *   |0              |Pi/2
+//|                   |       *       |               |
+//|                   |    *          |               |
+//|                   |  *            |               |
+//|                   | *             |               |
+//|                   |*              |               |
+//|                   |*              |               |
+//|                   |*              |               |
+//|                   <------------------- D --------->
+//--
+//++
+//|  - Criteres de convergence, arrets standards:
+//|    - SOIT: le Chi2 est descendu de moins de stopChi2
+//|            entre l'iteration n et n+1
+//|            (stopChi2 est change par SetStopChi2)
+//|    - SOIT: 1. le chi2 est remonte de moins de stopChi2SMx et
+//|            2. les parametres libres ont varie de moins de Eps(i)
+//|               pendant les nStopmx dernieres iterations
+//|            Si nStopmx<=0, alors ce critere n'est pas applique (def=3).
+//|            (nStopmx,stopChi2SMx sont changes par SetStopMx, Eps par SetEps)
+//|
+//|  - Criteres de convergence, arrets par non-convergence:
+//|    - plus de "maxStep" iterations.
+//|
+//|  - Criteres de convergence, arrets speciaux:
+//|    - Si l'utilisateur a demande explicitement la methode d'arret
+//|      "SetStopLent()", arret si :
+//|        1. le Chi2 est descendu et
+//|        2. les parametres libres ont varies de moins de Eps
+//|           pendant les nStopLent dernieres iterations.
+//|           (nStopLent est change par SetStopLent, Eps par SetEps)
+//|
+//--
+//++
+//|  - Remarques diverses:
+//|     Les points avec erreurs <=0 ne sont pas utilises dans le fit.
+//|     Les bornes des parametres ne peuvent etre atteintes
+//|  - entrees:
+//|     la fonction est definie par une classe GeneralFunction
+//|     les donnees sont passees par une classe GeneralFitData
+//|     le nombre de parametres et le nombre de variables doivent etre
+//|        coherents entre GeneralFunction GeneralFitData GeneralFit
+//|  - Return: 
+//|       la function elle meme retourne le nombre d'iterations  du fit si succes
+//|       -1  : si le nombre de degre de liberte est <0
+//|       -10 : si l'inversion de la matrice des erreurs n'a pas ete possible
+//|       -11 : si un element diagonal de la matrice des covariances est <=0
+//|       -20 : si le fit n'a pas converge (nstep>nNstepMX)
+//|       -100-N : si le parametre "N" est initialise hors limites
+//|       -200-N : si le parametre "N" atteint sa limite inferieure
+//|       -300-N : si le parametre "N" atteint sa limite superieure
+//--
+{
+ volatile double oldChi2;
+ Matrix COVAR(mNPar,mNPar);
+ Vector DA(mNPar);
+ Vector dparam(mNPar);
+ Vector paramTry(mNPar);
+ Vector param_tr(mNPar);
+ Vector paramTry_tr(mNPar);
+ Vector step_tr(mNPar);
+ nStop = nStopL = nStep = 0;
+ Chi2 = oldChi2 = 0.;
+ Lambda = 0.001;
+ mNddl = mData->NDataGood() - mNParFree;
+ if(mNddl<0) return -1;
+ mNtry++;
+
+ if(debugLevel>= 2)
+   cout<<"\n********* DEBUT GENERALFIT.FIT() **************"<<endl;
+
+ // set matrices C,D dans le cas de parametres bornes
+ if(mNParBound>0) Set_Bound_C_D();
+
+ if(debugLevel>= 2) PrintStatus();
+
+ // check de la coherence des operations et assignations
+ CheckSanity();
+
+ // Pour les parametres bornes on verifie
+ // qu'ils sont initialises dans leurs limites
+ {for(int i=0;i<mNPar;i++) {
+   if( !boundParam[i] || fixParam[i] ) continue;
+   if( minParam(i)<Param(i) && Param(i)<maxParam(i) ) continue;
+   /* if(debugLevel>= 1) */
+    cout<<"Parametre "<<i<<" initialise hors limites "
+        <<minParam(i)<<" < "<<Param(i)
+        <<" < "<<maxParam(i)<<endl;
+   return(-100-i);
+ }}
+
+ // premier essai d'initialisation
+ param_tr = p_vers_tr(Param);
+ dparam = stepParam / 2.;
+ put_in_limits_for_deriv(Param,dparam);
+ if(mFunction!=NULL) mFunction->SetDeltaParm(dparam.Data());
+   else if(mFuncXi2!=NULL) mFuncXi2->SetDeltaParm(dparam.Data());
+ step_tr = dp_vers_dtr(stepParam,param_tr);
+
+ if(debugLevel>= 2) {
+   cout<<"ESSAI numero 1: Param:"<<endl;
+   cout<<Param;
+   cout<<"param_tr:"<<endl;
+   cout<<param_tr;
+   cout<<"step_tr:"<<endl;
+   cout<<step_tr;
+ }
+ if(mFunction!=NULL) TryFunc(Param,param_tr);
+   else if(mFuncXi2!=NULL) TryXi2(Param,param_tr);
+ ATGA = ATGA_Try;
+ BETA = BETA_Try;
+ oldChi2 = Chi2;
+
+ // Iterations
+ while (1) {
+   nStep++;
+
+   // un nouvel essai (si Lambda!=0)
+   {for(int i=0; i<mNPar; i++)
+       if(! fixParam[i] ) ATGA(i,i) *= 1 + Lambda;
+          else  ATGA(i,i) = 1.;}
+
+   // Calcul de la matrice des covariances
+#ifdef __mac__
+   COVAR = ATGA.Inverse();
+#else
+   TRY {
+     COVAR = ATGA.Inverse();
+   } CATCHALL {
+     if(debugLevel>0) {
+       cout<<"Pb inversion matrice ATGA:"<<endl;
+       cout<<ATGA;
+     }
+     return(-10);
+   } ENDTRY
+#endif
+
+   if (debugLevel >= 3) {
+     cout<<"Matrice (tA G A)^-1 = \n";
+     cout<<COVAR;
+   }
+
+   // calculs des deplacements a effectuer
+   DA = COVAR * BETA;
+   if (debugLevel >=2) {
+     cout<<"Correction parametres DA : \n";
+     cout<<DA;
+   }
+   
+
+   //////////////////////////////////////////////////
+   ////////////////// Arret du Fit //////////////////
+   // si Lambda = 0, le fit a converge on s'arrete
+   //                ou bien on a trop d'iterations
+   //////////////////////////////////////////////////
+   if(Lambda == 0 || nStep > maxStep) {
+     // trop d'iterations
+     if(nStep>maxStep) 
+       cout<<"GeneralFit : pas de convergence"<<endl;
+     // Probleme de matrice de covariance non-definie positive?
+     bool bad_covar = false;
+     {for(int i=0; i<mNPar; i++) {
+       if( fixParam[i] ) errParam(i) = 0.;
+       else {
+         stepParam(i) = DA(i);
+         if( COVAR(i,i)<=0. ) {
+            if( debugLevel>0 )
+              cout<<"Erreur: Par["<<i<<"]="<<param_tr(i)
+                  <<" ("<<Param(i)<<") COVAR()="<<COVAR(i,i)
+                  <<" step="<<DA(i)<<endl;
+             errParam(i) = 0.;
+             bad_covar = true;
+         } else {
+           errParam(i) = sqrt( COVAR(i,i) );
+	 }
+       }
+     }}
+     // print de debug pour parametres bornes
+     if(debugLevel>= 2) {
+       cout<<"param_tr:"<<endl;
+       cout<<param_tr;
+       cout<<"stepParam_tr:"<<endl;
+       cout<<stepParam;
+       cout<<"errParam_tr:"<<endl;
+       cout<<errParam;
+     }
+     // Calcul de la matrice des covariances
+     {for(int i=0; i<mNPar; i++) {
+        for(int j=0; j<mNPar; j++) {
+          if( fixParam[i] || fixParam[j] ) {
+            // Parametre fixe, on retourne l'identite
+            if(i==j) ATGA(i,j) = 1.; else ATGA(i,j) = 0.;
+	  } else if( errParam(i)<=0. || errParam(j)<=0.) {
+            // parametres avec mauvaise variance, on retourne 0
+            ATGA(i,j) = 0;
+	  } else {
+            // parametres OK
+            ATGA(i,j) = COVAR(i,j)/(errParam(i)*errParam(j));
+	  }
+	}
+     }}
+     if (debugLevel >= 1) {
+       cout<<">>> Matrice des Covariances = \n";
+       cout<<ATGA;
+     }
+     // Calcul du step et de l'erreur finale en tenant
+     // compte des parametres bornes
+     stepParam = dtr_vers_dp(stepParam,param_tr);
+     errParam  = dtr_vers_dp(errParam,param_tr);
+     // Print si demande et code de retour.
+     if (debugLevel>0 ) PrintFit();
+     if(nStep>maxStep) return(-20);
+       else if(bad_covar) return(-11);
+         else return(nStep);
+   }
+   ////////////////////////////////////////////////////////
+   ////////////////// Fin d'Arret du Fit //////////////////
+   ////////////////////////////////////////////////////////
+
+   // Gestion des deplacements
+   {for (int i=0; i<mNPar; i++) {
+     if( fixParam[i] ) { DA(i) = 0; continue;}
+     // le premier deplacement ne peut etre plus grand que stepParam
+     if( nStep == 1 && fabs(DA(i)) > step_tr(i) ) {
+       DA(i) = DA(i) < 0. ? -step_tr(i) : step_tr(i);
+       if(debugLevel>1 ) cout<<"Excursion parametre "<<i
+                             <<" limitee a "<<DA(i)<<endl;
+     }
+   }}
+   paramTry_tr = param_tr + DA;
+   paramTry = tr_vers_p(paramTry_tr);
+   dparam = dtr_vers_dp(DA,paramTry_tr);
+   dparam /= 2.;
+   put_in_limits_for_deriv(paramTry,dparam);
+   {for(int i=0; i<mNPar; i++) {
+     if( ! boundParam[i] ) continue;
+     if(paramTry(i) <= minParam(i)) {
+       if(debugLevel>0) cout<<"Parametre "<<i
+                            <<" limite au minimum"<<endl;
+       Param(i) = minParam(i);
+       return(-200-i);
+     } else if (paramTry(i) >= maxParam(i)) {
+       if(debugLevel>0) cout<<"Parametre "<<i
+                            <<" limite au maximum"<<endl;
+       Param(i) = maxParam(i);
+       return(-300-i);
+     }
+   }}
+
+   // Nouvel essai
+   if(mFunction!=NULL) mFunction->SetDeltaParm(dparam.Data());
+     else if(mFuncXi2!=NULL) mFuncXi2->SetDeltaParm(dparam.Data());
+   if(debugLevel >= 2) {
+     cout<<">>>>>>>>>>> ESSAI avec nouveaux parametres\n";
+     cout<<"paramTry:\n";
+     cout<<paramTry;
+     cout<<"paramTry_tr:\n";
+     cout<<paramTry_tr;
+     cout<<"dparam:\n";
+     cout<<dparam;
+   }
+   if(mFunction!=NULL) TryFunc(paramTry,paramTry_tr);
+     else if(mFuncXi2!=NULL) TryXi2(paramTry,paramTry_tr);
+
+   if (debugLevel >= 2)
+     cout<<"step "<<nStep<<" Chi2 : old="<<oldChi2
+         <<" new="<<Chi2<<" d="<<Chi2-oldChi2<<endl;
+   if(FileStep) write_in_step(Chi2,paramTry);
+
+   // *************************************************************
+   // ****************** quelle strategie sur Lambda ???? *********
+   // *************************************************************
+   if (Chi2 < oldChi2) {
+     // ****************** le Chi2 est descendu ******************
+     nStop = 0;
+     if(nStopLent>0) {
+       // Arret special demande, comment se comporte les parametres?
+       int k=0;
+       for (int i=0; i<mNPar; i++) if( (!fixParam[i]) &&
+              (fabs(param_tr(i)-paramTry_tr(i))<Eps(i))) k++;
+       if (k==mNParFree) nStopL++; // Tous les parametres ont peu varies
+          else nStopL=0;
+       if (debugLevel>=2) cout<<k<<" parametres sur "<<mNParFree
+                              <<" ont peu varies, nStopL="<<nStopL<<endl;
+     } else nStopL = 0;
+     // Preparation des parametres pour iteration suivante
+     ATGA = ATGA_Try;
+     BETA = BETA_Try;
+     param_tr = paramTry_tr;
+     Param = paramTry;
+     Lambda *= 1./Lambda_Fac;
+     // Arret ?
+     if (oldChi2-Chi2<stopChi2) {
+       // arret normal, convergence
+        Lambda = 0;
+        if (debugLevel >= 2)
+          cout<<"Arret>> demande car Chi2 decroit et oldChi2-Chi2= "
+	      <<oldChi2-Chi2<<"<"<<stopChi2<<endl;
+     } else if (nStopLent>0 && nStopL >= nStopLent) {
+       // arret demande par SetStopLent, variation lente des parametres
+       Lambda = 0.;
+       if (debugLevel >= 2) 
+         cout<<"Arret>> demande car Chi2 decroit et nStop(lent)= "
+             <<nStopL<<">="<<nStopLent<<endl;
+     }
+     oldChi2 = Chi2;
+     if (debugLevel >= 2) cout<<"Succes essai: Lambda divided by "
+                              <<Lambda_Fac<<" -> "<<Lambda<<endl;
+   } else {
+     // ****************** le Chi2 est remonte ******************
+     nStopL = 0;
+     if(nStopMx>0 && Chi2-oldChi2<stopChi2SMx) {
+       // Il est remonte tres peu, comment se comporte les parametres?
+       int k=0;
+       for (int i=0; i<mNPar; i++) if( (!fixParam[i]) &&
+              (fabs(param_tr(i)-paramTry_tr(i))<Eps(i))) k++;
+       if (k==mNParFree) nStop++; // Tous les parametres ont peu varies
+          else nStop=0;
+       if (debugLevel>=2) cout<<k<<" parametres sur "<<mNParFree
+                              <<" ont peu varies, nStop="<<nStop<<endl;
+     } else nStop = 0;
+     // Preparation des parametres pour iteration suivante
+     Lambda *= Lambda_Fac;
+     // Arret ?
+     if (nStopMx>0 && nStop>=nStopMx) {
+       // arret normal, convergence car ci2 varie peu et parametres aussi
+       Lambda = 0.;
+       if (debugLevel >= 2) 
+         cout<<"Arret>> demande car Chi2 croit et nstop= "
+             <<nStop<<">="<<nStopMx<<endl;
+     }
+     Chi2 = oldChi2;
+     if (debugLevel >= 2)
+       cout<<"Echec essai: Lambda multiplied by "<<Lambda_Fac
+           <<" -> "<<Lambda<<" nStop="<<nStop<<endl;
+   }
+
+ } // fin des iterations
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+double GeneralFit::ReCalChi2(int& nddl, double *par)
+//
+//	Recalcul du Chi2 a partir des parametres courants (`par==NULL')
+//	ou a partir du tableau de parametres `par'.
+//	Retourne le chi2 et le nombre de degres de liberte.
+//	Si nddl<0 probleme.
+//--
+{
+double c2 = -.1;
+if(par==NULL) par = Param.Data();
+if( mData->NData() <= 0 ) {nddl = -100; return 0.;}
+
+if( mFunction != NULL ) {
+
+  double e,result;
+
+  nddl = 0; c2  = 0.;
+  for(int k=0; k<mData->NData(); k++) {
+    if (! mData->mOK[k]) continue;
+    e = mData->mErr[k];
+    result = mFunction->Value(&mData->mXP[mNVar*k],par);
+    c2 += (mData->mF[k]-result)*(mData->mF[k]-result)/(e*e);
+    nddl++;
+  }
+  nddl -= mNParFree;
+
+  return c2;
+
+} else if( mFuncXi2 != NULL ) {
+
+  c2 = mFuncXi2->Value(*mData,par,nddl);
+  nddl -= mNParFree;
+  return c2;
+
+} else {
+
+  cout<<"GeneralFit::ReCalChi2_Erreur: mFunction && mFuncXi2 == NULL"<<endl;
+  nddl = -1;
+  return c2;
+}
+
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+GeneralFitData* GeneralFit::DataResidus(bool clean)
+//
+//	Retourne une structure ``GeneralFitData'' contenant
+//	les residus du fit (val-func) pour les points du fit.
+//	Si ``clean'' est ``true''
+//	seules les donnees valides de ``data'' sont copiees.
+//	Si ``clean'' est ``false'' (defaut) toutes les donnees
+//	sont copiees et la taille totale de ``data'' est allouee
+//	meme si elle est plus grande que la taille des donnees stoquees.
+//--
+{
+if(!mData) return NULL;
+if(!mFunction) return NULL;
+GeneralFitData* datres = new GeneralFitData(*mData,clean);
+for(int k=0; k<mData->NData(); k++)
+  datres->mF[k] -= mFunction->Value(&datres->mXP[mNVar*k],Param.Data());
+return datres;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+GeneralFitData* GeneralFit::DataFunction(bool clean)
+//
+//	Retourne une structure ``GeneralFitData'' contenant
+//	les valeurs de la fonction fittee pour les points du fit.
+//	(voir commentaires pour ``clean'' dans ``DataResidus'')
+//--
+{
+if(!mData) return NULL;
+if(!mFunction) return NULL;
+GeneralFitData* datres = new GeneralFitData(*mData,clean);
+for(int k=0; k<mData->NData(); k++)
+  datres->mF[k] = mFunction->Value(&datres->mXP[mNVar*k],Param.Data());
+return datres;
+}
+
+//////////////////////////////////////////////////////////////////////
+//++
+void GeneralFit::PrintFitErr(int rc)
+//
+//	Imprime le commentaire lie a l'erreur rc retournee par Fit()
+//	(voir le commentaire de la methode `Fit()')
+//--
+{
+int n;
+if(rc>0) return;
+
+if(rc==-1)
+  cout<<"rc = "<<rc<<"  : le nombre de degre de liberte est <0"<<endl;
+
+else if(rc==-10)
+  cout<<"rc = "<<rc<<" : l'inversion de la matrice des erreurs n'a pas ete possible"<<endl;
+
+else if(rc==-11)
+  cout<<"rc = "<<rc<<" : un element diagonal de la matrice des covariances est <=0"<<endl;
+
+else if(rc==-20)
+  cout<<"rc = "<<rc<<" : le fit n'a pas converge (nstep>nNstepMX="<<maxStep<<")"<<endl;
+
+else if(rc>-200 && rc<=-100) {
+  n = -100-rc;
+  cout<<"rc = "<<rc<<" : le parametre "<<n<<" ("<<nameParam[n]
+      <<") est initialise hors limites"<<endl;
+}
+
+else if(rc>-300 && rc<=-200) {
+  n = -200-rc;
+  cout<<"rc = "<<rc<<" : le parametre "<<n<<" ("<<nameParam[n]
+      <<") atteint sa limite inferieure"<<endl;
+}
+
+else if(rc>-400 && rc<=-300) {
+  n = -300-rc;
+  cout<<"rc = "<<rc<<" : le parametre "<<n<<" ("<<nameParam[n]
+      <<") atteint sa limite superieure"<<endl;
+}
+
+else cout<<"rc = "<<rc<<" : type d'erreur inconnue"<<endl;
+
+}
+
+//////////////////////////////////////////////////////////////////////
+// Fonctions privees
+//////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFit::write_in_step(double ci2,Vector& par)
+{
+if(FileStep==NULL) return;
+fprintf(FileStep,"%d %d %f",mNtry,nStep,ci2);
+for(int i=0; i<mNPar; i++) fprintf(FileStep," %f",par(i));
+fprintf(FileStep,"\n");
+}
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFit::TryFunc(Vector& par,Vector& par_tr)
+{
+  BETA_Try = 0;
+  ATGA_Try = 0;
+  Chi2  = 0;
+  Vector deriv(mNPar);
+  Vector derivtr(mNPar);
+  double result;
+
+  for(int k=0; k<mData->NData(); k++) {
+    if (! mData->mOK[k]) continue;
+    double e = mData->mErr[k];
+    if(mNParBound==0)
+       result = mFunction->Val_Der(&mData->mXP[mNVar*k]
+                                  ,par.Data(),derivtr.Data());
+    else {
+       result = mFunction->Val_Der(&mData->mXP[mNVar*k]
+                                  ,par.Data(),deriv.Data());
+       dtr_vers_dp(deriv,par_tr,derivtr);
+    }
+    double Gkk = 1/(e*e);
+    double Ck  = mData->mF[k] - result;
+    Chi2 += Ck*Ck*Gkk;
+    for(int j=0; j<mNPar; j++) {
+      if( fixParam[j] ) continue;
+      for(int i=0; i<mNPar; i++)
+        if(!fixParam[i]) ATGA_Try(i,j) += derivtr(i)*Gkk*derivtr(j);
+      BETA_Try(j) += derivtr(j) * Gkk * Ck;
+    }
+  }
+
+  if (debugLevel >= 3) {
+    cout<<"Try: matrice ( At * G * A )_Try\n";
+    cout<<ATGA_Try;
+    cout<<"Try: beta_Try:\n";
+    cout<<BETA_Try;
+  }
+}
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFit::TryXi2(Vector& par,Vector& par_tr)
+{
+  double c, *parloc;
+  BETA_Try = 0;
+  ATGA_Try = 0;
+  Chi2  = 0;
+
+  parloc = par.Data();  // He oui, encore ces ... de const*
+  Chi2 = mFuncXi2->Value(*mData,parloc,mNddl);
+  mNddl -= mNParFree;
+
+  // Calcul des derivees du Xi2 (vecteur du gradient)
+  {for(int i=0;i<mNPar; i++) {
+    if( fixParam[i] ) continue;
+    c = c_dtr_vers_dp(i,par_tr(i));
+    BETA_Try(i) = -0.5 * mFuncXi2->Derivee(*mData,i,parloc) * c;
+  }}
+
+  // Calcul des derivees 2sd du Xi2 (matrice de courbure ou 0.5*Hessien)
+  double c1,c2;
+  {for(int i=0;i<mNPar; i++) {
+    if( fixParam[i] ) continue;
+    c1 = c_dtr_vers_dp(i,par_tr(i));
+    for(int j=0;j<mNPar; j++) {
+      if( fixParam[j] ) continue;
+      c2 = c_dtr_vers_dp(j,par_tr(j));
+      ATGA_Try(i,j) = 0.5 * mFuncXi2->Derivee2(*mData,i,j,parloc) *c1*c2;
+    }
+  }}
+  // et on symetrise car d/di(dC2/dj) =  d/dj(dC2/di) mathematiquement
+  // mais malheureusement pas numeriquement.
+  if( mNPar>1) {
+    for(int i=0;i<mNPar-1; i++) {
+      if( fixParam[i] ) continue;
+      for(int j=i+1;j<mNPar; j++) {
+        if( fixParam[j] ) continue;
+        c1 = 0.5*(ATGA_Try(i,j) + ATGA_Try(j,i));
+        ATGA_Try(i,j) = c1;
+        ATGA_Try(j,i) = c1;
+      }
+    }
+  }
+  
+  if (debugLevel >= 3) {
+    cout<<"Try: matrice ( At * G * A )_Try\n";
+    cout<<ATGA_Try;
+    cout<<"Try: beta_Try:\n";
+    cout<<BETA_Try;
+  }
+}
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFit::CheckSanity()
+{
+  DBASSERT( mData != NULL );
+  DBASSERT( mFunction != NULL || mFuncXi2 != NULL );
+  if( mFunction != NULL ) {
+    DBASSERT( mFunction->NVar() == mNVar );
+    DBASSERT( mData->NVar() == mNVar );
+  }
+  DBASSERT( mNParFree > 0 && mNParFree <= mNPar );
+  DBASSERT( mNParBound >= 0 && mNParBound <= mNPar );
+  DBASSERT( mNParFree <= mData->NDataGood() );
+}
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFit::Set_Bound_C_D(int i)
+// C = (min+max)/2
+// D = (max-min)/Pi
+{
+  // DBASSERT(i>=0 && i<mNPar);
+ C(i) = D(i) = 0.;
+ if( !boundParam[i] || fixParam[i] ) return;
+ C(i) = (maxParam(i)+minParam(i))/2.;
+ D(i) = (maxParam(i)-minParam(i))/M_PI;
+}
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFit::Set_Bound_C_D()
+{
+ for(int i=0;i<mNPar;i++) Set_Bound_C_D(i);
+ if(debugLevel>= 2) {
+   cout<<"Set_Bound_C_D: C=\n";
+   cout<<C;
+   cout<<"Set_Bound_C_D: D=\n";
+   cout<<D;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////
+double GeneralFit::p_vers_tr(int i,double p)
+// tr = tan( (p-C)/D )
+{
+ // DBASSERT(i>=0 && i<mNPar);
+ double tr = p;
+ if(boundParam[i]) tr = tan((p-C(i))/D(i));
+ return(tr);
+}
+
+//////////////////////////////////////////////////////////////////////
+Vector GeneralFit::p_vers_tr(Vector const& p)
+{
+ Vector tr(p);
+ for(int i=0;i<mNPar;i++) {
+   if( fixParam[i] || ! boundParam[i] ) continue;
+   tr(i) = p_vers_tr(i,p(i));
+ }
+ return(tr);
+}
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFit::p_vers_tr(Vector const& p,Vector& tr)
+{
+ for(int i=0;i<mNPar;i++) {
+   if( fixParam[i] ) continue;
+   if( ! boundParam[i] ) tr(i) = p(i);
+     else tr(i) = tan((p(i)-C(i))/D(i));
+ }
+}
+
+//////////////////////////////////////////////////////////////////////
+double GeneralFit::tr_vers_p(int i,double tr)
+// p = C+D*atan(tr)
+{
+ // DBASSERT(i>=0 && i<mNPar);
+ double p = tr;
+ if(boundParam[i]) p = C(i)+D(i)*atan(tr);
+ return(p);
+}
+
+//////////////////////////////////////////////////////////////////////
+Vector GeneralFit::tr_vers_p(Vector const& tr)
+{
+ Vector p(tr);
+ for(int i=0;i<mNPar;i++) {
+   if( fixParam[i] || ! boundParam[i] ) continue;
+   p(i) = tr_vers_p(i,tr(i));
+ }
+ return(p);
+}
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFit::tr_vers_p(Vector const& tr,Vector& p)
+{
+ for(int i=0;i<mNPar;i++) {
+   if( fixParam[i] ) continue;
+   if( ! boundParam[i] ) p(i) = tr(i);
+     else p(i) = C(i)+D(i)*atan(tr(i));
+ }
+}
+
+//////////////////////////////////////////////////////////////////////
+double GeneralFit::c_dp_vers_dtr(int i,double tr)
+// dtr = (1+tr**2)/D * dp = (1+tan( (p-C)/D )**2)/D * dp = coeff * dp
+// attention: df/dp = (1+tr**2)/D * dF/dtr = coeff * dF/dtr
+{
+ // DBASSERT(i>=0 && i<mNPar);
+ double coeff = 1.;
+ if(boundParam[i]) coeff = (1.+tr*tr)/D(i);
+ return(coeff);
+}
+
+//////////////////////////////////////////////////////////////////////
+Vector GeneralFit::dp_vers_dtr(Vector const& dp,Vector const& tr)
+{
+ Vector dtr(dp);
+ for(int i=0;i<mNPar;i++) {
+   if( fixParam[i] || ! boundParam[i] ) continue;
+   dtr(i) *= c_dp_vers_dtr(i,tr(i));
+ }
+ return(dtr);
+}
+
+//////////////////////////////////////////////////////////////////////
+void GeneralFit::dp_vers_dtr(Vector const& dp,Vector const& tr,Vector& dtr)
+{
+ for(int i=0;i<mNPar;i++) {
+   if( fixParam[i] ) continue;
+   if( ! boundParam[i] ) dtr(i) = dp(i);
+     else dtr(i) = (1.+tr(i)*tr(i))/D(i) * dp(i);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////
+double GeneralFit::c_dtr_vers_dp(int i,double tr)
+// dp = D/(1+tr**2) * dtr = coeff * dtr
+// attention: df/dtr = D/(1+tr**2) * dF/dp = coeff * dF/dp
+{
+  // DBASSERT(i>=0 && i<mNPar);
+ double coeff = 1.;
+ if(boundParam[i]) coeff = D(i)/(1.+tr*tr);
+ return(coeff);
+}
+
+//////////////////////////////////////////////////////////////////////
+Vector GeneralFit::dtr_vers_dp(Vector const& dtr,Vector const& tr)
+{
+ Vector dp(dtr);
+ for(int i=0;i<mNPar;i++) {
+   if( fixParam[i] || ! boundParam[i] ) continue;
+   dp(i) *= c_dtr_vers_dp(i,tr(i));
+ }
+ return(dp);
+}
+
+//////////////////////////////////////////////////////////////////////
+// inline fonction pour aller + vite dans le try()
+//void GeneralFit::dtr_vers_dp(Vector const& dtr,Vector const& tr,Vector& dp)
+
+//////////////////////////////////////////////////////////////////////
+int GeneralFit::put_in_limits_for_deriv(Vector const& p,Vector& dp,double dist)
+// 1-/ Redefinit dp pour qu'il soit superieur a minStepDeriv
+// 2-/ Redefinit dp pour que p+/-dp reste dans les limites (parametre borne)
+// Si hors limites alors:
+//     p-dp <= min_p : dp = (p-min_p)*dist
+//     p+dp >= max_p : dp = (max_p-p)*dist
+{
+ int nchanged = 0;
+ bool changed;
+ double dp_old;
+
+ for(int i=0;i<mNPar;i++) {
+   if( fixParam[i] ) {dp(i)=0.; continue;} // Pas calcul derivee pour param fixe
+
+   if( fabs(dp(i))<minStepDeriv(i) ) {
+     // On ne redefinit dp que si minStepDeriv>0.
+     dp_old = dp(i);
+     if(dp(i)>=0.) dp(i) = minStepDeriv(i); else dp(i) = -minStepDeriv(i);
+     if(debugLevel>=2)
+       cout<<"put_in_limits_for_deriv(range) dp["<<i<<"]=abs("<<dp_old
+           <<") <"<<minStepDeriv(i)<<" changed to "<<dp(i)<<endl;
+   }
+
+   if( !boundParam[i] ) continue;
+
+   changed = false;
+   if( p(i)-dp(i)<=minParam(i) ) {
+     dp_old = dp(i);
+     dp(i) = dist*(p(i)-minParam(i));
+     changed = true;
+     if(debugLevel>=2)
+       cout<<"put_in_limits_for_deriv(min) p["<<i<<"}="<<p(i)<<" >="
+           <<minParam(i)<<" .. dp="<<dp_old<<" -> dp="<<dp(i)<<endl;
+   }
+
+   if( p(i)+dp(i)>=maxParam(i) ) {
+     dp_old = dp(i);
+     dp(i) = dist*(maxParam(i)-p(i));
+     changed = true;
+     if(debugLevel>=2)
+       cout<<"put_in_limits_for_deriv(max) p["<<i<<"]="<<p(i)<<" <="
+           <<maxParam(i)<<" .. dp="<<dp_old<<" -> dp="<<dp(i)<<endl;
+   }
+
+   if(changed) nchanged++;
+ }
+
+ return nchanged;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// Rappel des inline functions pour commentaires
+//++
+// inline double   GetChi2()
+//	Retourne le Chi2
+//--
+//++
+// inline double   GetChi2Red() const
+//	Retourne le Chi2 reduit
+//--
+//++
+// inline int      GetNddl()    const
+//	Retourne le nombre de degres de liberte
+//--
+//++
+// inline int      GetNStep()   const
+//	Retourne le nombre d'iterations
+//--
+//++
+// inline int      GetNVar()    const
+//	Retourne le nombre de variables
+//--
+//++
+// inline int      GetNPar()    const
+//	Retourne le nombre de parametres
+//--
+//++
+// inline int      GetNFree()   const
+//	Retourne le nombre de parametres libres
+//--
+//++
+// inline int      GetNBound()  const
+//	Retourne le nombre de parametres bornes
+//--
+//++
+// inline int      GetNStop()   const
+//	Retourne le nstop de convergence
+//--
+//++
+// inline int      GetNStopLent()   const
+//	Retourne le nstop de convergence lente.
+//--
+//++
+// inline double   GetEps(int i)
+//	Retourne la precision de convergence pour le parametre i.
+//--
+//++
+// inline GeneralFunction*  GetFunction()
+//	Retourne le pointeur sur la GeneralFunction utilisee.
+//--
+//++
+// inline GeneralFitData*   GetGData()
+//	Retourne le pointeur sur la GeneralFitData utilisee.
+//--
Index: /tags/DPC_V0/SophyaLib/NTools/generalfit.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/generalfit.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/generalfit.h	(revision 1307)
@@ -0,0 +1,229 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef GENERALFIT_SEEN
+#define GENERALFIT_SEEN
+
+#include "exceptions.h"
+#include "matrix.h"
+#include "cvector.h"
+#include "generaldata.h"
+
+//================================================================
+// GeneralFunction
+//================================================================
+
+class GeneralFunction EXC_AWARE {
+public:
+  GeneralFunction(unsigned int nVar, unsigned int nPar);
+  virtual ~GeneralFunction();
+
+  virtual double Value(double const xp[], double const* parm)=0;
+  virtual double Val_Der(double const xp[], double const* parm
+                        , double* DgDpar);
+
+  void SetDeltaParm(int numPar, double delta=0.);
+  void SetDeltaParm(double const* dparam);
+
+  inline int     NVar() const {return mNVar;}
+  inline int     NPar() const {return mNPar;}
+
+protected:
+  const int mNVar;  // nombre de variables f(x,y,z,...)
+  const int mNPar;  // nombre de parametres
+
+  double *deltaParm;
+  double *tmpParm;
+};
+
+//================================================================
+// GeneralFunc
+//================================================================
+
+class GeneralFunc : public GeneralFunction {
+public:
+  GeneralFunc(unsigned int nvar, unsigned int npar
+        ,double (*fun)(double const*,double const*) 
+        ,double (*funder)(double const*, double const*, double*)=NULL);
+  virtual ~GeneralFunc();
+
+  virtual double Value(double const xp[], double const* Par);
+  virtual double Val_Der(double const xp[],double const* parm
+                        , double* DgDpar);
+
+protected:
+  double (*tmpFun)   (double const*, double const*);
+  double (*tmpFunDer)(double const*, double const*, double*);
+};
+
+//================================================================
+// GeneralXi2
+//================================================================
+
+class GeneralFitData;
+
+class GeneralXi2 EXC_AWARE {
+public:
+  GeneralXi2(unsigned int nPar);
+  virtual ~GeneralXi2();
+
+  virtual double Value(GeneralFitData& data, double* parm, int& ndataused)=0;
+  virtual double Derivee(GeneralFitData& data, int i, double* parm);
+  virtual double Derivee2(GeneralFitData& data, int i,int j, double* parm);
+
+  void SetDeltaParm(int numPar, double delta=0.);
+  void SetDeltaParm(double const* dparam);
+
+  inline int     NPar() const {return mNPar;}
+
+protected:
+  const int mNPar;  // nombre de parametres
+
+  double *deltaParm;
+};
+
+//================================================================
+// GENERALFIT
+//================================================================
+
+class GeneralFit EXC_AWARE {
+public:
+  GeneralFit(GeneralFunction* f);
+  GeneralFit(GeneralXi2* f);
+  ~GeneralFit();
+
+  void            WriteStep(char *filename = NULL);
+  void            SetDebug(int level = 0);
+  void            SetMaxStep(int n = 100);
+  void            SetLambda_Fac(double fac = 10.);
+  void            SetStopChi2(double s = 0.01);
+  void            SetEps(double ep = 1.e-8);
+  void            SetEps(int n,double ep = 1.e-8);
+  void            SetStopMx(int nstopmx = 3, double stopchi2 = -1.);
+  void            SetStopLent(int nstoplent = 3);
+  void            SetFunction(GeneralFunction*);
+  void            SetFuncXi2(GeneralXi2*);
+  void            SetData(GeneralFitData*);
+  void            SetParam(int n,double value, double step
+                          ,double min=1., double max=-1.);
+  void            SetParam(int n,string const&
+                          ,double value, double step
+                          ,double min=1., double max=-1.);
+  void            SetParam(int n,double value);
+  void            SetStep(int n,double value);
+  void            SetMinStepDeriv(int i,double val = 0.);
+  void            SetMinStepDeriv(double val = 0.);
+  void            SetBound(int n,double min,double max);
+  void            SetBound(int n);
+  void            SetUnBound(int n);
+  void            SetUnBound();
+  void            SetFix(int n,double v);
+  void            SetFix(int n);
+  void            SetFree(int n);
+  void            SetFree();
+
+  double          GetParm(int);
+  Vector          GetParm();
+  double          GetParmErr(int);
+  double          GetCoVar(int,int);
+  double          GetStep(int n);
+  double          GetMax(int n);
+  double          GetMin(int n);
+  inline double   GetChi2()    const {return Chi2;};
+  inline double   GetChi2Red() const {
+                        if(mNddl<=0) return (double) mNddl;
+                        return Chi2/(double) mNddl;
+                                     };
+  inline double   GetEps(int i) const {return Eps(i);};
+  inline int      GetNddl()    const {return mNddl;};
+  inline int      GetNStep()   const {return nStep;};
+  inline int      GetNVar()    const {return mNVar;};
+  inline int      GetNPar()    const {return mNPar;};
+  inline int      GetNFree()   const {return mNParFree;};
+  inline int      GetNBound()  const {return mNParBound;};
+  inline int      GetNStop()   const {return nStop;};
+  inline int      GetNStopLent()   const {return nStopLent;};
+  inline GeneralFunction*  GetFunction() const {return mFunction;};
+  inline GeneralFitData*   GetGData() const {return mData;};
+
+  void            PrintStatus();
+  void            PrintFit();
+  void            PrintParm(int n);
+  void            PrintParm();
+
+  int             Fit();
+  double          ReCalChi2(int& nddl, double* par = NULL);
+  GeneralFitData* DataResidus(bool clean=true);
+  GeneralFitData* DataFunction(bool clean=true);
+  void            PrintFitErr(int rc);
+
+protected:
+  int             mNtry;       // numero d'appel de la routine de fit.
+  int             mNVar;       // nombre de variables f(x,y,z,...)
+  int             mNPar;       // nombre de parametres
+  int             mNParFree;   // nombre de parametres libres
+  int             mNParBound;  // nombre de parametres bornes
+  GeneralFunction*  mFunction;
+  GeneralXi2*       mFuncXi2;
+  GeneralFitData*   mData;
+
+  Vector          Param;
+  Vector          errParam;
+  Vector          stepParam;
+  Vector          minParam;
+  Vector          maxParam;
+  Vector          minStepDeriv;
+  Vector          Eps;
+  unsigned short int* fixParam;
+  unsigned short int* boundParam;
+  string*             nameParam;
+  
+  double          Lambda_Fac;
+  double          stopChi2;
+  int             maxStep;
+  int             nStopMx;
+  double          stopChi2SMx;
+  int             nStopLent;
+  int             debugLevel;
+  FILE            *FileStep;
+  
+  Matrix          ATGA;
+  Vector          BETA;
+  Matrix          ATGA_Try;
+  Vector          BETA_Try;
+  Vector          C;
+  Vector          D;
+  
+  double          Chi2;
+  int             mNddl;
+  int             nStep;
+  int             nStop, nStopL;
+  double          Lambda;
+  
+  // Fonctions privees
+  void       write_in_step(double ci2,Vector& par);
+  void       General_Init(void);
+  void       TryFunc(Vector& par,Vector& par_tr);
+  void       TryXi2(Vector& par,Vector& par_tr);
+  void       CheckSanity();
+  void       Set_Bound_C_D(int i);
+  void       Set_Bound_C_D();
+  double     p_vers_tr(int i,double p);
+  Vector     p_vers_tr(Vector const& p);
+  void       p_vers_tr(Vector const& p,Vector& tr);
+  double     tr_vers_p(int i,double tr);
+  Vector     tr_vers_p(Vector const& tr);
+  void       tr_vers_p(Vector const& tr,Vector& p);
+  double     c_dp_vers_dtr(int i,double tr);
+  Vector       dp_vers_dtr(Vector const& dp,Vector const& tr);
+  void         dp_vers_dtr(Vector const& dp,Vector const& tr,Vector& dtr);
+  double     c_dtr_vers_dp(int i,double tr);
+  Vector       dtr_vers_dp(Vector const& dtr,Vector const& tr);
+  int        put_in_limits_for_deriv(Vector const& p,Vector& dp,double dist=0.66);
+  inline void dtr_vers_dp(Vector const& dtr,Vector const& tr,Vector& dp)
+              {  for(int i=0;i<mNPar;i++)
+                   { if( fixParam[i] ) continue;
+                     if( ! boundParam[i] ) dp(i) = dtr(i);
+                       else dp(i) = D(i)/(1.+tr(i)*tr(i)) * dtr(i); }
+              };
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/hbook.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/hbook.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/hbook.h	(revision 1307)
@@ -0,0 +1,83 @@
+/* link to hbook     */
+/*      CMV  94      */
+
+#ifndef HBOOK_H_SEEN
+#define HBOOK_H_SEEN
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void hbandx_(int_4 *,float *,float *,float *);
+void hbandy_(int_4 *,float *,float *,float *);
+
+void hbarx_(int_4 *);
+void hbary_(int_4 *);
+
+void hbfun1_(int_4 *,char *,int_4 *,float *,float *,float fun(float *),int_4);
+void hbfun2_(int_4 *,char *,int_4 *,float *,float *,int_4 *,float *,float *
+            ,float fun(float *,float *),int_4);
+void hbigbi_(int_4 *,int_4 *);
+void hbook1_(int_4 *,char *,int_4 *,float *,float *,float *,int_4);
+void hbook2_(int_4 *,char *,int_4 *,float *,float *
+            ,int_4 *,float *,float *,float *,int_4);
+void hbpro_(int_4 *,float *);
+void hbprof_(int_4 *,char *,int_4 *,float *,float *
+            ,float *,float *,char *,int_4,int_4);
+void hbprox_(int_4 *,float *);
+void hbproy_(int_4 *,float *);
+void hbslix_(int_4 *,int_4 *,float *);
+void hbsliy_(int_4 *,int_4 *,float *);
+void hcdir_(char *,char *,int_4,int_4);
+void hdelet_(int_4 *);
+void hfill_(int_4 *,float *,float *,float *);
+void hfithn_(int_4 *,char *,char *,int_4 *,float *
+            ,float *,float *,float *,float *,float *,int_4,int_4);
+void hfn_(int_4 *,float *);
+void hfunc_(int_4 *,float fun(float *));
+void hgive_(int_4 *,char *,int_4 *,float *,float *
+                          ,int_4 *,float *,float *,int_4 *,int_4 *);
+void hgn_(int_4 *,int_4 *,int_4 *,float *,int_4 *);
+void hgnf_(int_4 *,int_4 *,float *,int_4 *);
+void hgnpar_(int_4 *,char *,int_4);
+float hi_(int_4 *,int_4 *);
+void hidopt_(int_4 *,char *,int_4);
+float hie_(int_4 *,int_4 *);
+float hif_(int_4 *,int_4 *);
+float hij_(int_4 *,int_4 *,int_4 *);
+void hijxy_(int_4 *,int_4 *,int_4 *,float *,float *);
+void hix_(int_4 *,int_4 *,float *);
+void hldir_(char *,char *,int_4,int_4);
+void hmdir_(char *,char *,int_4,int_4);
+float hmax_(int_4 *);
+void hmaxim_(int_4 *,float *);
+float hmin_(int_4 *);
+void hminim_(int_4 *,float *);
+void hnorma_(int_4 *,float *);
+void hnoent_(int_4 *,int_4 *);
+void hpak_(int_4 *,float *);
+void hpake_(int_4 *,float *);
+void hprint_(int_4 *);
+void hrend_(char *,int_4);
+void hrin_(int_4 *,int_4 *,int_4 *);
+float hrndm1_(int_4 *);
+void hrndm2_(int_4 *,float *,float *);
+void hropen_(int_4 *,char *,char *,char *,int_4 *,int_4 *,int_4,int_4,int_4);
+void hrout_(int_4 *,int_4 *,char *,int_4);
+void hscale_(int_4 *,float *);
+float hstati_(int_4 *,int_4 *,char *,int_4 *,int_4);
+float hsum_(int_4 *);
+void hunpak_(int_4 *,float *,char *,int_4 *,int_4);
+void hunpke_(int_4 *,float *,char *,int_4 *,int_4);
+float hx_(int_4 *,float *);
+float hxe_(int_4 *,float *);
+float hxi_(int_4 *,float *,int_4 *);
+float hxyij_(int_4 *,float *,float *,int_4 *,int_4 *);
+float hxy_(int_4 *,float *,float *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/NTools/hisprof.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/hisprof.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/hisprof.cc	(revision 1307)
@@ -0,0 +1,379 @@
+#include "defs.h"
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include "hisprof.h"
+#include "perrors.h"
+#include "cvector.h"
+
+//++
+// Class	HProf
+// Lib	Outils++ 
+// include	hisprof.h
+//
+//	Classe de profil d'histogrammes.
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+/********* Methode *********/
+//++
+HProf::HProf()
+//
+//	Constructeur par defaut.
+//--
+: Histo()
+, SumY(NULL), SumY2(NULL), SumW(NULL), Ok(false), YMin(1.), YMax(-1.), Opt(0)
+{
+ END_CONSTRUCTOR
+}
+
+/********* Methode *********/
+//++
+HProf::HProf(float xMin, float xMax, int nBin, float yMin, float yMax)
+//
+//	Constructeur. Histogramme de profil de ``nBin'' bins entre ``xMin''
+//	et ``xMax'' avec coupure d'acceptance sur y entre ``yMin'' et ``yMax''.
+//	Si yMin>=yMax alors pas de coupure d'acceptance sur y.
+//	Par defaut l'erreur du profil represente la dispersion dans le bin,
+//	SetErrOpt(1) permet de demander de calculer l'erreur sur la moyenne.
+//--
+: Histo(xMin,xMax,nBin)
+, SumY(new double[nBin]), SumY2(new double[nBin]), SumW(new double[nBin])
+, Ok(false), YMin(yMin), YMax(yMax), Opt(0)
+{
+  Histo::Errors();
+  Zero();
+  END_CONSTRUCTOR
+}
+
+/********* Methode *********/
+//++
+HProf::HProf(char *flnm)
+//
+//	Constructeur a partir d'un fichier ppersist.
+//--
+: Histo()
+, SumY(NULL), SumY2(NULL), SumW(NULL), Ok(false), YMin(1.), YMax(-1.), Opt(0)
+{
+  PInPersist s(flnm);
+  Read(s);
+  END_CONSTRUCTOR
+}
+
+/********* Methode *********/
+//++
+HProf::HProf(const HProf& H)
+//
+//	Constructeur par copie.
+//--
+: Histo(H)
+, SumY(new double[H.bins]), SumY2(new double[H.bins]), SumW(new double[H.bins])
+, Ok(H.Ok), YMin(H.YMin), YMax(H.YMax), Opt(H.Opt)
+{
+  memcpy(SumY,  H.SumY,  bins*sizeof(double));
+  memcpy(SumY2, H.SumY2, bins*sizeof(double));
+  memcpy(SumW,  H.SumW,  bins*sizeof(double));
+  END_CONSTRUCTOR
+}
+
+/********* Methode *********/
+void HProf::Delete()
+{
+  if( SumY  != NULL ) { delete[] SumY;  SumY = NULL;}
+  if( SumY2 != NULL ) { delete[] SumY2; SumY2 = NULL;}
+  if( SumW  != NULL ) { delete[] SumW;  SumW = NULL;}
+  Ok = false;
+}
+
+/********* Methode *********/
+HProf::~HProf()
+{
+Delete();
+}
+
+//++
+// Titre	Methodes
+//--
+
+/********* Methode *********/
+//++
+void HProf::Zero()
+//
+//	Remise a zero
+//--
+{
+  memset(SumY,  0, bins*sizeof(double));
+  memset(SumY2, 0, bins*sizeof(double));
+  memset(SumW,  0, bins*sizeof(double));
+  Ok = false;
+  Histo::Zero();
+}
+
+/********* Methode *********/
+//++
+void HProf::SetErrOpt(bool spread)
+//
+//	Pour changer l'option de calcul de l'erreur du profile.
+//	Si ``spread'' = true alors l'erreur represente la dispersion
+//	des donnees dans le bin, si = false elle represente l'erreur
+//	sur la moyenne du bin.
+//| - Pour le bin (j):
+//| H(j) = sum(y), E(j) = sum(y^2), L(j) = sum(w)
+//| ->  s(j) = sqrt(E(j)/L(j) - (H(j)/L(j))^2)  dispersion
+//| ->  e(j) = s(j)/sqrt(L(j)) erreur sur la moyenne
+//| spread=true:  opt=0 : dispersion des donnees dans le bin = s(j)
+//| spread=false: opt=1 : erreur sur la moyenne du bin = e(j)
+//--
+{
+int opt = (spread) ? 0 : 1;
+if(opt!=Opt) {Opt=opt; Ok=false;}
+}
+
+/********* Methode *********/
+//++
+void HProf::UpdateHisto() const
+//
+//	Pour mettre a jour l'histogramme de profil.
+//	Il est important d'appeler cette methode si on veut
+//	utiliser les methodes de la classe Histo qui ne sont
+//	pas redefinies dans la classe HProf.
+//	En effet, pour des raisons de precision la classe
+//	HProf travaille avec des tableaux en double precision
+//	et seulement au moment ou l'on a besoin de l'histogramme
+//	ce dernier est rempli avec les valeurs demandees (moyenne
+//	et dispersion/erreur sur la moyenne).
+//--
+{
+
+float m,e2;
+for(int i=0;i<bins;i++) {
+  if(SumW[i]<=0.) {
+    m = e2 = 0.;
+  } else {
+    m  = SumY[i]/SumW[i];
+    e2 = SumY2[i]/SumW[i] - m*m;
+    if(Opt) e2 /= SumW[i];
+  }
+  data[i] = m;
+  err2[i] = e2;
+}
+// Attention, a cause de "WriteSelf const" UpdateHisto doit etre "const".
+// Comme on veut modifier Ok, on est oblige de faire cette entourloupe:
+HProf *buff = (HProf *) this;
+buff->Ok = true;
+}
+
+/********* Methode *********/
+//++
+void HProf::Add(float x, float y, float w)
+//
+//	Addition au contenu de l'histo pour abscisse x de la valeur y et poids w
+//--
+{
+  if(YMax>YMin && (y<YMin || YMax<y)) return;
+  int numBin = FindBin(x);
+  if (numBin<0) under += w;
+  else if (numBin>=bins) over += w;
+  else {
+    Ok = false;
+    SumY[numBin]  += y;
+    SumY2[numBin] += y*y;
+    SumW[numBin]  += w;
+    nHist += w;
+    nEntries++;
+  }
+}
+
+/********* Methode *********/
+//++
+void HProf::AddBin(int numBin, float y, float w)
+//
+//	Addition au contenu de l'histo bin numBin de la valeur y poids w
+//--
+{
+  if(YMax>YMin && (y<YMin || YMax<y)) return;
+  if (numBin<0) under += w;
+  else if (numBin>=bins) over += w;
+  else {
+    Ok = false;
+    SumY[numBin]  += y;
+    SumY2[numBin] += y*y;
+    SumW[numBin]  += w;
+    nHist += w;
+    nEntries++;
+  }
+}
+
+/********* Methode *********/
+//++
+HProf& HProf::operator = (const HProf& h)
+//
+//--
+{
+if(this == &h) return *this;
+if( h.bins > bins ) Delete();
+Histo *hthis = (Histo *) this;
+*hthis = (Histo) h;
+if(!SumY)  SumY  = new double[bins];
+if(!SumY2) SumY2 = new double[bins];
+if(!SumW)  SumW  = new double[bins];
+memcpy(SumY,  h.SumY,  bins*sizeof(double));
+memcpy(SumY2, h.SumY2, bins*sizeof(double));
+memcpy(SumW,  h.SumW,  bins*sizeof(double));
+Ok = h.Ok;
+YMin = h.YMin;
+YMax = h.YMax;
+Opt = h.Opt;
+
+return *this;
+}
+
+/********* Methode *********/
+//++
+HProf& HProf::operator += (const HProf& a)
+//
+//	Attention dans cette addition il n'y a pas de gestion
+//	des YMin et YMax. L'addition est faite meme si les limites
+//	en Y de ``a'' sont differentes de celles de ``this''.
+//--
+{
+if(bins!=a.bins) THROW(sizeMismatchErr);
+Histo *hthis = (Histo *) this;
+*hthis += (Histo) a;
+for(int i=0;i<bins;i++) {
+  SumY[i]  += a.SumY[i];
+  SumY2[i] += a.SumY2[i];
+  SumW[i]  += a.SumW[i];
+}
+Ok = false;
+
+return *this;
+}
+
+/********* Methode *********/
+//++
+HProf operator + (const HProf& a, const HProf& b)
+//
+//	Meme commentaire que pour l'operateur +=
+//--
+{
+if (b.bins!=a.bins) THROW(sizeMismatchErr);
+HProf c(a);
+return (c += b);
+}
+
+/********* Methode *********/
+//++
+void  HProf::WriteSelf(POutPersist& s)  const
+//
+//	Ecriture ppersist
+//--
+{
+char strg[256];
+
+UpdateHisto();
+
+// Ecriture entete pour identifier facilement
+sprintf(strg,"HProf: YMin=%f  YMax=%f  Opt=%1d",YMin,YMax,Opt);
+s.PutLine(strg);
+
+// Ecriture des valeurs
+s.PutI4(bins);
+s.PutR4(YMin);
+s.PutR4(YMax);
+s.PutU2(Opt);
+
+// Ecriture des donnees propres a l'histogramme de profil.
+sprintf(strg,"HProf: SumY SumY2 SumW");
+s.PutLine(strg);
+s.PutR8s(SumY,  bins);
+s.PutR8s(SumY2, bins);
+s.PutR8s(SumW,  bins);
+
+// Ecriture de l'histogramme
+Histo::WriteSelf(s);
+
+return;
+}
+
+/********* Methode *********/
+//++
+void  HProf::ReadSelf(PInPersist& s)
+//
+//	Lecture ppersist
+//--
+{
+char strg[256];
+
+Delete();
+
+// Lecture entete
+s.GetLine(strg,255);
+
+// Ecriture des valeurs
+s.GetI4(bins);
+s.GetR4(YMin);
+s.GetR4(YMax);
+s.GetU2(Opt);
+Ok = true;
+
+// Ecriture des donnees propres a l'histogramme de profil.
+s.GetLine(strg,255);
+SumY  = new double[bins];
+SumY2 = new double[bins];
+SumW  = new double[bins];
+s.GetR8s(SumY,  bins);
+s.GetR8s(SumY2, bins);
+s.GetR8s(SumW,  bins);
+
+// Ecriture de l'histogramme
+Histo::ReadSelf(s);
+
+return;
+}
+
+
+// Rappel des inlines functions pour commentaires
+//++
+//   inline Histo GetHisto()
+//	Retourne l'histogramme de profil.
+//--
+//++
+// inline void GetMean(Vector& v)
+//	Retourne le contenu de la moyenne dans le vecteur v
+//--
+//++
+// inline void GetError2(Vector& v)
+//	Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
+//--
+//++
+// inline float operator()(int i) const
+//	Retourne le contenu du bin i
+//--
+//++
+// inline float Error2(int i) const
+//	Retourne le carre de la dispersion/erreur du bin i
+//--
+//++
+// inline float Error(int i) const
+//	Retourne la dispersion/erreur du bin i
+//--
+//++
+// inline int Fit(GeneralFit& gfit)
+//	Fit du profile par ``gfit''.
+//--
+//++
+// inline Histo* FitResidus(GeneralFit& gfit)
+//	Retourne l'Histogramme des residus par ``gfit''.
+//--
+//++
+// inline Histo* FitFunction(GeneralFit& gfit)
+//	Retourne l'Histogramme de la fonction fittee par ``gfit''.
+//--
+//++
+// inline void Print(int dyn,float hmin,float hmax,int pflag,int il,int ih)
+//	Print, voir detail dans Histo::Print
+//--
Index: /tags/DPC_V0/SophyaLib/NTools/hisprof.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/hisprof.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/hisprof.h	(revision 1307)
@@ -0,0 +1,74 @@
+#ifndef HISPROF_SEEN
+#define HISPROF_SEEN
+
+#include <stdio.h>
+#include "peida.h"
+#include "cvector.h"
+#include "ppersist.h"
+#include "histos.h"
+
+class HProf : public Histo {
+
+public:
+  enum {classId = ClassId_HProf };
+
+  // CREATOR / DESTRUCTOR
+  HProf();
+  HProf(float xMin, float xMax, int nBin=100, float yMin=1., float yMax=-1.);
+  HProf(char *flnm);
+  HProf(const HProf& H);
+  virtual ~HProf();
+
+  // UPDATING or SETTING
+  void   Zero();
+  void   UpdateHisto() const;
+  void   SetErrOpt(bool spread = true);
+  void   Add(float x, float y, float w = 1.);
+  void   AddBin(int numBin, float y, float w = 1.);
+  
+  // Acces a l information
+  inline Histo GetHisto() {if(!Ok) UpdateHisto(); return (Histo) *this;}
+  inline void GetMean(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetValue(v);}
+  inline void GetError2(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetError2(v);}
+  inline float operator()(int i) const {if(!Ok) UpdateHisto(); return data[i];}
+  inline float Error2(int i) const {if(!Ok) UpdateHisto(); return (float) err2[i];}
+  inline float Error(int i) const
+         {if(!Ok) UpdateHisto(); return err2[i]>0. ? (float) sqrt(err2[i]) : 0.f;}
+
+  // Operators
+  HProf& operator = (const HProf& h);
+  HProf& operator += (const HProf& a);
+  friend HProf operator + (const HProf& a, const HProf& b);
+
+  // Fit
+  inline int    Fit(GeneralFit& gfit)
+         {if(!Ok) UpdateHisto(); return Histo::Fit(gfit,0);}
+  inline Histo* FitResidus(GeneralFit& gfit)
+         {if(!Ok) UpdateHisto(); return Histo::FitResidus(gfit);}
+  inline Histo* FitFunction(GeneralFit& gfit)
+         {if(!Ok) UpdateHisto(); return Histo::FitFunction(gfit);}
+
+  // Print
+  inline void Print(int dyn=100,float hmin=1.,float hmax=-1.,int pflag=0,int il=1,int ih=-1)
+                           {if(!Ok) UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
+
+  int_4             ClassId() const        { return classId; }
+  static PPersist*  Create()               { return new HProf;}
+
+  virtual void      WriteSelf(POutPersist&) const;
+  virtual void      ReadSelf(PInPersist&);
+
+
+protected:
+  void Delete();
+
+  double*        SumY;
+  double*        SumY2;
+  double*        SumW;
+  bool           Ok;
+  float          YMin;
+  float          YMax;
+  uint_2         Opt;
+};
+
+#endif // HISPROF_SEEN
Index: /tags/DPC_V0/SophyaLib/NTools/histos.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/histos.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/histos.cc	(revision 1307)
@@ -0,0 +1,1833 @@
+//
+// $Id: histos.cc,v 1.1.1.1 1999-04-09 17:57:56 ansari Exp $
+//
+
+#include "defs.h"
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include "histos.h"
+#include "perrors.h"
+#include "cvector.h"
+#include "poly.h"
+#include "strutil.h"
+#include "generalfit.h"
+
+//++
+// Class	Histo
+// Lib	Outils++ 
+// include	histos.h
+//
+//	Classe d'histogrammes 1D
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+/********* Methode *********/
+//++
+Histo::Histo()
+//
+//--
+: data(NULL), err2(NULL),
+  under(0), over(0), nHist(0), nEntries(0),
+  bins(0), min(0), max(0),
+  binWidth(0)
+{
+ END_CONSTRUCTOR
+}
+
+/********* Methode *********/
+//++
+Histo::Histo(float xMin, float xMax, int nBin)
+//
+//--
+: data(new float[nBin]), err2(NULL),
+  under(0), over(0), nHist(0), nEntries(0),
+  bins(nBin), min(xMin), max(xMax),
+  binWidth((max - min)/nBin)
+{
+  Zero();
+  END_CONSTRUCTOR
+}
+
+/********* Methode *********/
+//++
+Histo::Histo(char *flnm)
+//
+//--
+: data(NULL), err2(NULL),
+  under(0), over(0), nHist(0), nEntries(0),
+  bins(0), min(0), max(0), binWidth(0)
+{
+  PInPersist s(flnm);
+  Read(s);
+  END_CONSTRUCTOR
+}
+
+/********* Methode *********/
+//++
+Histo::Histo(const Histo& H)
+//
+//--
+: data(new float[H.bins]), err2(NULL),
+  under(H.under), over(H.over), nHist(H.nHist), nEntries(H.nEntries),
+  bins(H.bins), min(H.min), max(H.max),
+  binWidth(H.binWidth)
+{
+  memcpy(data, H.data, bins*sizeof(float));
+  if( H.err2 != NULL ) {
+    err2 = new double[bins];
+    memcpy(err2, H.err2, bins*sizeof(double));
+  }
+  END_CONSTRUCTOR
+}
+
+/********* Methode *********/
+void Histo::Delete()
+{
+  if( data != NULL ) { delete[] data; data = NULL;}
+  if( err2 != NULL ) { delete[] err2; err2 = NULL;}
+  under = over = min = max = binWidth= 0.;
+  nHist = 0.;
+  nEntries = bins = 0;
+}
+
+/********* Methode *********/
+Histo::~Histo()
+{
+Delete();
+}
+
+//++
+// Titre	Methodes
+//--
+
+/********* Methode *********/
+//++
+void Histo::Zero()
+//
+//	Remise a zero
+//--
+{
+  memset(data, 0, bins*sizeof(float));
+  under = over = 0;
+  nHist = 0;
+  nEntries = 0;
+  if( err2 != NULL ) memset(err2, 0, bins*sizeof(double));
+}
+
+/********* Methode *********/
+//++
+void Histo::Errors()
+//
+//	Pour avoir le calcul des erreurs
+//--
+{
+ if( bins > 0 ) {
+   if(err2==NULL) err2 = new double[bins];
+   memset(err2, 0, bins*sizeof(double));
+ }
+}
+
+/********* Methode *********/
+//++
+Histo& Histo::operator = (const Histo& h)
+//
+//--
+{
+  if(this == &h) return *this;
+  if( h.bins > bins ) Delete();
+  if(!data) data = new float[h.bins];
+  if( !h.err2 && err2 ) { delete [] err2; err2=NULL;}
+  if( h.err2 && !err2 ) err2 = new double[h.bins];
+
+  under = h.under;
+  over = h.over;
+  nHist = h.nHist;
+  nEntries = h.nEntries;
+  bins = h.bins;
+  min = h.min;
+  max = h.max;
+  binWidth = h.binWidth;
+  
+  memcpy(data, h.data, bins*sizeof(float));
+  if(err2) memcpy(err2, h.err2, bins*sizeof(double));
+
+  return *this;
+}
+
+/********* Methode *********/
+//++
+Histo& Histo::operator *= (double b)
+//
+//--
+{
+double b2 = b*b;
+for(int i=0;i<bins;i++) {
+  data[i] *= b;
+  if(err2) err2[i] *= b2;
+}
+under *= b;
+over *= b;
+nHist *= b;
+
+return *this;
+}
+
+//++
+Histo& Histo::operator /= (double b)
+//
+//--
+{
+if (b==0.) THROW(inconsistentErr);
+double b2 = b*b;
+for(int i=0;i<bins;i++) {
+  data[i] /= b;
+  if(err2) err2[i] /= b2;
+}
+under /= b;
+over /= b;
+nHist /= b;
+
+return *this;
+}
+
+//++
+Histo& Histo::operator += (double b)
+//
+//--
+{
+for(int i=0;i<bins;i++) data[i] += b;
+under += b;
+over += b;
+nHist += bins*b;
+
+return *this;
+}
+
+//++
+Histo& Histo::operator -= (double b)
+//
+//--
+{
+for(int i=0;i<bins;i++) data[i] -= b;
+under -= b;
+over -= b;
+nHist -= bins*b;
+
+return *this;
+}
+
+/********* Methode *********/
+//++
+Histo operator * (const Histo& a, double b)
+//
+//--
+{
+  Histo result(a);
+  return (result *= b);
+}
+
+//++
+Histo operator * (double b, const Histo& a)
+//
+//--
+{
+  Histo result(a);
+  return (result *= b);
+}
+
+//++
+Histo operator / (const Histo& a, double b)
+//
+//--
+{
+  Histo result(a);
+  return (result /= b);
+}
+
+//++
+Histo operator + (const Histo& a, double b)
+//
+//--
+{
+  Histo result(a);
+  return (result += b);
+}
+
+//++
+Histo operator + (double b, const Histo& a)
+//
+//--
+{
+  Histo result(a);
+  return (result += b);
+}
+
+//++
+Histo operator - (const Histo& a, double b)
+//
+//--
+{
+  Histo result(a);
+  return (result -= b);
+}
+
+//++
+Histo operator - (double b, const Histo& a)
+//
+//--
+{
+  Histo result(a);
+  result *= -1.;
+  return (result += b);
+}
+
+/********* Methode *********/
+//++
+Histo& Histo::operator += (const Histo& a)
+//
+//--
+{
+if(bins!=a.bins) THROW(sizeMismatchErr);
+for(int i=0;i<bins;i++) {
+  data[i] += a(i);
+  if(err2 && a.err2) err2[i] += a.Error2(i);
+    else err2[i] = 0.;
+}
+under += a.under;
+over += a.over;
+nHist += a.nHist;
+nEntries += a.nEntries;
+
+return *this;
+}
+
+//++
+Histo& Histo::operator -= (const Histo& a)
+//
+//--
+{
+if(bins!=a.bins) THROW(sizeMismatchErr);
+for(int i=0;i<bins;i++) {
+  data[i] -= a(i);
+  if(err2 && a.err2) err2[i] += a.Error2(i);
+    else err2[i] = 0.;
+}
+under -= a.under;
+over -= a.over;
+nHist -= a.nHist;
+nEntries += a.nEntries;
+
+return *this;
+}
+
+//++
+Histo& Histo::operator *= (const Histo& a)
+//
+//--
+{
+if(bins!=a.bins) THROW(sizeMismatchErr);
+nHist = 0.;
+for(int i=0;i<bins;i++) {
+  if(err2 && a.err2)
+      err2[i] = a(i)*a(i)*err2[i] + data[i]*data[i]*a.Error2(i);
+    else err2[i] = 0.;
+  data[i] *= a(i);
+  nHist += data[i];
+}
+under *= a.under;
+over *= a.over;
+nEntries += a.nEntries;
+
+return *this;
+}
+
+//++
+Histo& Histo::operator /= (const Histo& a)
+//
+//--
+{
+if(bins!=a.bins) THROW(sizeMismatchErr);
+nHist = 0.;
+for(int i=0;i<bins;i++) {
+  if(a(i)==0.) {
+    data[i]=0.;
+    if(err2) err2[i]=0.;
+    continue;
+  }
+  if(err2 && a.err2)
+      err2[i] = (err2[i] + data[i]/a(i)*data[i]/a(i)*a.Error2(i))
+                /(a(i)*a(i));
+    else err2[i] = 0.;
+  data[i] /= a(i);
+  nHist += data[i];
+}
+if(a.under!=0.) under /= a.under; else under = 0.;
+if(a.over!=0.)  over  /= a.over;  else over  = 0.;
+nEntries += a.nEntries;
+
+return *this;
+}
+
+/********* Methode *********/
+//++
+Histo operator + (const Histo& a, const Histo& b)
+//
+//--
+{
+if (b.bins!=a.bins) THROW(sizeMismatchErr);
+Histo c(a);
+return (c += b);
+}
+
+//++
+Histo operator - (const Histo& a, const Histo& b)
+//
+//--
+{
+if (b.bins!=a.bins) THROW(sizeMismatchErr);
+Histo c(a);
+return (c -= b);
+}
+
+//++
+Histo operator * (const Histo& a, const Histo& b)
+//
+//--
+{
+if (b.bins!=a.bins) THROW(sizeMismatchErr);
+Histo c(a);
+return (c *= b);
+}
+
+//++
+Histo operator / (const Histo& a, const Histo& b)
+//
+//--
+{
+if (b.bins!=a.bins) THROW(sizeMismatchErr);
+Histo c(a);
+return (c /= b);
+}
+
+/********* Methode *********/
+//++
+void Histo::GetAbsc(Vector &v)
+//
+//	Remplissage d'un tableau avec la valeur des abscisses
+//--
+{
+v.Realloc(bins);
+for(int i=0;i<bins;i++) v(i) = BinLowEdge(i);
+return;
+}
+
+//++
+void Histo::GetValue(Vector &v)
+//
+//	Remplissage d'un tableau avec la valeur du contenu
+//--
+{
+v.Realloc(bins);
+for(int i=0;i<bins;i++) v(i) = data[i];
+return;
+}
+
+//++
+void Histo::GetError2(Vector &v)
+//
+//	Remplissage d'un tableau avec la valeur des erreurs au carre
+//--
+{
+v.Realloc(bins);
+if(!err2) {for(int i=0;i<bins;i++) v(i) = 0.; return;}
+for(int i=0;i<bins;i++) v(i) = err2[i];
+return;
+}
+
+//++
+void Histo::GetError(Vector &v)
+//
+//	Remplissage d'un tableau avec la valeur des erreurs
+//--
+{
+v.Realloc(bins);
+if(!err2) {for(int i=0;i<bins;i++) v(i) = 0.; return;}
+for(int i=0;i<bins;i++) v(i) = Error(i);
+return;
+}
+
+/********* Methode *********/
+//++
+void Histo::PutValue(Vector &v, int ierr)
+//
+//	Remplissage du contenu de l'histo avec les valeurs d'un vecteur
+//--
+{
+if(v.NElts()<bins) THROW(sizeMismatchErr);
+for(int i=0;i<bins;i++) {
+  data[i] = v(i);
+  if(err2&&ierr) err2[i] = fabs(v(i));
+}
+return;
+}
+
+//++
+void Histo::PutValueAdd(Vector &v, int ierr)
+//
+//	Addition du contenu de l'histo avec les valeurs d'un vecteur
+//--
+{
+if(v.NElts()<bins) THROW(sizeMismatchErr);
+for(int i=0;i<bins;i++) {
+  data[i] += v(i);
+  if(err2&&ierr) err2[i] += fabs(v(i));
+}
+return;
+}
+
+//++
+void Histo::PutError2(Vector &v)
+//
+//	Remplissage des erreurs au carre de l'histo avec les valeurs d'un vecteur
+//--
+{
+if(v.NElts()<bins) THROW(sizeMismatchErr);
+if(!err2) Errors();
+for(int i=0;i<bins;i++) err2[i] = v(i);
+return;
+}
+
+//++
+void Histo::PutError2Add(Vector &v)
+//
+//	Addition des erreurs au carre de l'histo avec les valeurs d'un vecteur
+//--
+{
+if(v.NElts()<bins) THROW(sizeMismatchErr);
+if(!err2) Errors();
+for(int i=0;i<bins;i++) if(v(i)>0.) err2[i] += v(i);
+return;
+}
+
+//++
+void Histo::PutError(Vector &v)
+//
+//	Remplissage des erreurs de l'histo avec les valeurs d'un vecteur
+//--
+{
+if(v.NElts()<bins) THROW(sizeMismatchErr);
+if(!err2) Errors();
+for(int i=0;i<bins;i++)
+  if(v(i)>0.) err2[i]=v(i)*v(i); else err2[i]=-v(i)*v(i);
+return;
+}
+
+/********* Methode *********/
+//++
+void Histo::Add(float x, float w)
+//
+//	Addition du contenu de l'histo pour abscisse x poids w
+//--
+{
+  int numBin = FindBin(x);
+  if (numBin<0) under += w;
+  else if (numBin>=bins) over += w;
+  else {
+    data[numBin] += w;
+    if(err2!=NULL) err2[numBin] += w*w;
+    nHist += w;
+    nEntries++;
+  }
+}
+
+/********* Methode *********/
+//++
+void Histo::AddBin(int numBin, float w)
+//
+//	Addition du contenu de l'histo bin numBin poids w
+//--
+{
+  if (numBin<0) under += w;
+  else if (numBin>=bins) over += w;
+  else {
+    data[numBin] += w;
+    if(err2!=NULL) err2[numBin] += w*w;
+    nHist += w;
+    nEntries++;
+  }
+}
+
+/********* Methode *********/
+//++
+void Histo::SetBin(float x, float w)
+//
+//	Remplissage du contenu de l'histo pour abscisse x poids w
+//--
+{
+  int numBin = FindBin(x);
+  SetBin(numBin,w);
+}
+
+/********* Methode *********/
+//++
+void Histo::SetBin(int numBin, float w)
+//
+//	Remplissage du contenu de l'histo pour numBin poids w
+//--
+{
+  if (numBin<0) under = w;
+  else if (numBin>=bins) over = w;
+  else {
+    nHist -= data[numBin];
+    data[numBin] = w;
+    nHist += w;
+  }
+}
+
+/********* Methode *********/
+//++
+void Histo::SetErr2(float x, double e2)
+//
+//	Remplissage des erreurs au carre pour abscisse x
+//--
+{
+  int numBin = FindBin(x);
+  SetErr2(numBin,e2);
+}
+
+/********* Methode *********/
+//++
+void Histo::SetErr2(int numBin, double e2)
+//
+//	Remplissage des erreurs au carre pour numBin poids
+//--
+{
+  if( err2==NULL) return;
+  if ( numBin<0 || numBin>=bins ) return;
+  err2[numBin] = e2;
+}
+
+/********* Methode *********/
+//++
+void Histo::SetErr(float x, float e)
+//
+//	Remplissage des erreurs pour abscisse x
+//--
+{
+SetErr2(x, (double) e*e);
+}
+
+/********* Methode *********/
+//++
+void Histo::SetErr(int numBin, float e)
+//
+//	Remplissage des erreurs pour numBin
+//--
+{
+SetErr2(numBin, (double) e*e);
+}
+
+/********* Methode *********/
+//++
+int Histo::IMax() const
+//
+//	Numero du bin ayant le contenu maximum
+//--
+{
+  int imx=0;
+  if(bins==1) return imx;
+  float mx=data[0];
+  for (int i=1; i<bins; i++)
+    if (data[i]>mx) {imx = i; mx=data[i];}
+  return imx;
+}
+
+/********* Methode *********/
+//++
+int Histo::IMin() const
+//
+//	Numero du bin ayant le contenu minimum
+//--
+{
+  int imx=0;
+  if(bins==1) return imx;
+  float mx=data[0];
+  for (int i=1; i<bins; i++)
+    if (data[i]<mx) {imx = i; mx=data[i];}
+  return imx;
+}
+
+/********* Methode *********/
+//++
+float Histo::VMax() const
+//
+//	Valeur le contenu maximum
+//--
+{
+  float mx=data[0];
+  if(bins==1) return mx;
+  for (int i=1;i<bins;i++) if(data[i]>mx) mx=data[i];
+  return mx;
+}
+
+/********* Methode *********/
+//++
+float Histo::VMin() const
+//
+//	Valeur le contenu minimum
+//--
+{
+  float mx=data[0];
+  if(bins==1) return mx;
+  for (int i=1;i<bins;i++) if(data[i]<mx) mx=data[i];
+  return mx;
+}
+
+/********* Methode *********/
+//++
+float Histo::Mean() const
+//
+//	Valeur moyenne
+//--
+{
+  double n = 0;
+  double sx = 0;
+  for (int i=0; i<bins; i++) {
+    double v = (data[i]>=0.) ? data[i] : -data[i];
+    n += v;
+    sx += BinCenter(i)*v;
+  }
+  if(n>0.) return sx/n; else return min;
+}
+
+/********* Methode *********/
+//++
+float Histo::Sigma() const
+//
+//	Valeur du sigma
+//--
+{
+  double n = 0;
+  double sx = 0;
+  double sx2= 0;
+  for (int i=0; i<bins; i++) {
+    double v = (data[i]>=0.) ? data[i] : -data[i];
+    n += v;
+    sx += BinCenter(i)*v;
+    sx2+= BinCenter(i)*BinCenter(i)*v;
+  }
+  // attention a l'erreur d'arrondi si un seul bin rempli!!
+  if( n == 0 ) return 0.;
+  sx2 = sx2/n - (sx/n)*(sx/n);
+  if( sx2>0. ) return sqrt( sx2 );
+      else return 0.;
+}
+
+/********* Methode *********/
+//++
+float Histo::MeanLH(int il,int ih) const
+//
+//	Valeur de la moyenne calculee entre les bin il et ih
+//--
+{
+  if( ih < il ) { il = 0; ih = bins-1; }
+  if( il < 0 ) il = 0;
+  if( ih >= bins ) ih = bins-1;
+  double n = 0;
+  double sx = 0;
+  for (int i=il; i<=ih; i++) {
+    double v = (data[i]>=0.) ? data[i] : -data[i];
+    n += v;
+    sx += BinCenter(i)*v;
+  }
+  if(n>0.) return sx/n; else return BinLowEdge(il);
+}
+
+/********* Methode *********/
+//++
+float Histo::SigmaLH(int il,int ih) const
+//
+//	Valeur de la moyenne calculee entre les bin il et ih
+//--
+{
+  if( ih < il ) { il = 0; ih = bins - 1; }
+  if( il < 0 ) il = 0;
+  if( ih >= bins ) ih = bins - 1;
+  double n = 0;
+  double sx = 0;
+  double sx2= 0;
+  for (int i=il; i<=ih; i++) {
+    double v = (data[i]>=0.) ? data[i] : -data[i];
+    n += v;
+    sx += BinCenter(i)*v;
+    sx2+= BinCenter(i)*BinCenter(i)*v;
+  }
+  if( n == 0 ) return 0.;
+  sx2 = sx2/n - (sx/n)*(sx/n);
+  if( sx2>0. ) return sqrt( sx2 );
+      else return 0.;
+}
+
+/********* Methode *********/
+//++
+float Histo::Mean(float x0, float dx) const
+//
+//	Valeur de la moyenne calculee entre x0-dx et x0+dx
+//--
+{
+  double sdata = 0;
+  double sx = 0;
+  int iMin = FindBin(x0-dx);
+  if (iMin<0) iMin = 0;
+  int iMax = FindBin(x0+dx);
+  if (iMax>bins) iMax=bins;
+  for (int i=iMin; i<iMax; i++) {
+    double v = (data[i]>=0.) ? data[i] : -data[i];
+    sx += BinCenter(i)*v;
+    sdata += v;
+  }
+  if(sdata>0.) return sx/sdata; else return min;
+}
+
+/********* Methode *********/
+//++
+float Histo::Sigma(float x0, float dx) const
+//
+//	Valeur du sigma calcule entre x0-dx et x0+dx
+//--
+{
+  double sx = 0;
+  double sx2= 0;
+  double sdata = 0;
+  int iMin = FindBin(x0-dx);
+  if (iMin<0) iMin = 0;
+  int iMax = FindBin(x0+dx);
+  if (iMax>bins) iMax=bins;
+  for (int i=iMin; i<iMax; i++) {
+    double v = (data[i]>=0.) ? data[i] : -data[i];
+    sx += BinCenter(i)*v;
+    sx2+= BinCenter(i)*BinCenter(i)*v;
+    sdata += v;
+  }
+  if(sdata>0.) return sqrt( sx2/sdata - (sx/sdata)*(sx/sdata) );
+          else return 0.;
+}
+
+/********* Methode *********/
+//++
+float Histo::CleanedMean(float& sigma) const
+//
+//	Valeur de la moyenne et du sigma nettoyes
+//--
+{
+  if (!nHist) return 0;
+  // on fait ca de facon bete, on pourra raffiner apres...
+  float x0 = Mean();
+  float s  = Sigma()+binWidth;
+  
+  for (int i=0; i<3; i++) {
+    float xx0 = Mean(x0,5*s);
+    s  = Sigma(x0,5*s)+binWidth;
+    x0 = xx0;
+  }
+  sigma = s;
+  return x0;
+}
+
+/********* Methode *********/
+//++
+float Histo::CleanedMean() const
+//
+//	Valeur de la moyenne nettoyee
+//--
+{
+  if (!nHist) return 0;
+  float s=0;
+  return CleanedMean(s);
+}
+
+/********* Methode *********/
+//++
+int Histo::BinNonNul() const
+//
+//	Retourne le nombre de bins non-nul
+//--
+{
+int non=0;
+for (int i=0;i<bins;i++) if( data[i] != 0. ) non++;
+return non;
+}
+
+/********* Methode *********/
+//++
+int Histo::ErrNonNul() const
+//
+//	Retourne le nombre de bins ayant une erreur non-nulle
+//--
+{
+if(err2==NULL) return -1;
+int non=0;
+for (int i=0;i<bins;i++) if( err2[i] != 0. ) non++;
+return non;
+}
+
+/********* Methode *********/
+//++
+int Histo::BinPercent(float per) const
+//
+//	Renvoie le numero de bin tel que il y ait "per" pourcent entrees
+//	entre le bin 0 et ce bin (y compris le contenu de ce bin).
+//--
+{
+double n = nHist*per;
+double s = 0.;
+int i;
+for(i=0; i<bins; i++ ) {
+  s += data[i];
+  if( s >= n ) break;
+}
+if( i == bins ) i = bins-1;
+return i;
+}
+
+/********* Methode *********/
+//++
+int Histo::BinPercent(float x,float per,int& imin,int& imax)
+//
+//	Renvoie les numeros de bins imin,imax (0=<i<bins) tels que:
+//|    notons I = bin contenant l'abscisse x
+//|           N1 = nombre d'entrees entre bin 0 et I compris
+//|           N2 = nombre d'entrees entre bin I et bins-1 compris
+//|    imin = bin tel que nombre d'entrees entre imin et I = N1 * per
+//|    imax = bin tel que nombre d'entrees entre I et imax = N2 * per
+//|  Return: <0 si echec
+//|          min(I-imin,imax-I) si ok
+//--
+{
+imin = imax = -1;
+if( per <= 0. ) return -1;
+
+int I = FindBin(x);
+if( I<0 || I>=bins ) return -2;
+
+double N1 = 0.; for(int i=0; i<=I;   i++) N1 += data[i]; N1 *= per;
+double N2 = 0.; {for(int i=I; i<bins; i++) N2 += data[i]; N2 *= per;}
+
+double n = 0.;
+for(imin=I; imin>=0; imin--)   { n += data[imin]; if(n>=N1) break; }
+if( imin<0 ) imin = 0;
+// cout<<"I="<<I<<" imin="<<imin<<" n="<<n<<" N1="<<N1<<endl;
+
+n = 0.;
+for(imax=I; imax<bins; imax++) { n += data[imax]; if(n>=N2) break; }
+if( imax>=bins ) imax = bins-1;
+// cout<<"I="<<I<<" imax="<<imax<<" n="<<n<<" N2="<<N2<<endl;
+
+return ( imax-I > I-imin ) ? I-imin : imax-I ;
+}
+
+/********* Methode *********/
+//++
+int Histo::BinPercent(float x,float per,float& xmin,float& xmax)
+//
+//	Idem precedent mais renvoie xmin et xmax
+//--
+{
+xmin = xmax = 0.;
+int imin,imax;
+int rc = BinPercent(x,per,imin,imax);
+if( rc >= 0 ) { xmin = BinLowEdge(imin); xmax = BinHighEdge(imax); }
+return rc;
+}
+
+/********* Methode *********/
+//++
+void Histo::HInteg(float norm)
+//
+//	Remplace l'histogramme par son integrale normalise a norm:
+//	si norm <= 0 : pas de normalisation, integration seule
+//--
+{
+if(bins>1)
+  for(int i=1; i<bins; i++) {
+    data[i] += data[i-1];
+    if(err2!=NULL) err2[i] += err2[i-1];
+  }
+if( norm <= 0. ) return;
+norm /= data[bins-1];
+for(int i=0; i<bins; i++) {
+  data[i] *= norm;
+  if(err2!=NULL) err2[i] *= norm*norm;
+}
+}
+
+/********* Methode *********/
+//++
+void Histo::HDeriv()
+//
+//	Remplace l'histogramme par sa derivee
+//--
+{
+if( bins <= 1 ) return;
+float *temp = new float[bins];
+memcpy(temp, data, bins*sizeof(float));
+if(bins>=3) for(int i=1; i<bins-1; i++)
+              temp[i] = (data[i+1]-data[i-1])/(2.*binWidth);
+temp[0] = (data[1]-data[0])/binWidth;
+temp[bins-1] = (data[bins-1]-data[bins-2])/binWidth;
+memcpy(data, temp, bins*sizeof(float));
+delete [] temp;
+}
+
+/********* Methode *********/
+//++
+void Histo::HRebin(int nbinew)
+//
+//	Pour rebinner l'histogramme sur nbinew bins
+//--
+{
+  if( nbinew <= 0 ) return;
+
+  // memoraisation de l'histogramme original
+  Histo H(*this);
+
+  // Le nombre de bins est il plus grand ??
+  if( nbinew > bins ) {
+    delete [] data; data = NULL;
+    data = new float[nbinew];
+    if( err2 != NULL ) {
+      delete [] err2; err2 = NULL;
+      err2 = new double[nbinew];
+    }
+  }
+
+  // remise en forme de this
+  bins = nbinew;
+  this->Zero();
+  binWidth = (max-min)/bins;
+  // On recopie les parametres qui n'ont pas changes
+  under = H.under;
+  over  = H.over;
+
+
+  // Remplissage
+  for(int i=0;i<bins;i++) {
+    float xmi = BinLowEdge(i);
+    float xma = BinHighEdge(i);
+    int imi =  H.FindBin(xmi);
+    if( imi < 0 ) imi = 0;
+    int ima =  H.FindBin(xma);
+    if( ima >= H.bins ) ima = H.bins-1;
+    double w = 0.;
+    if( ima == imi ) {
+      w = H(imi) * binWidth/H.binWidth;
+    } else {
+      w += H(imi) * (H.BinHighEdge(imi)-xmi)/H.binWidth;
+      w += H(ima) * (xma -H.BinLowEdge(ima))/H.binWidth;
+      if( ima > imi+1 )
+          for(int ii=imi+1;ii<ima;ii++) w += H(ii);
+    }
+    AddBin(i,(float) w);
+  }
+
+}
+
+/********* Methode *********/
+//++
+int Histo::MaxiLocal(float& maxi,int& imax,float& maxn,int& imaxn)
+//
+//	Retourne le nombre de maxima locaux, la valeur du maximum (maxi)
+//	et sa position (imax), ainsi que la valeur du second maximum
+//	local (maxn) et sa position (imaxn).
+//	Attention: si un maximum a la meme valeur sur plusieurs bins
+//	consecutifs, le bin le plus a droite est pris.
+//--
+{
+int nml = 0;
+imax = imaxn = -1;
+maxi = maxn = -1.f;
+
+bool up = true;
+bool down = false;
+for(int i=0;i<bins;i++) {
+  if( !up ) if( data[i] > data[i-1] ) up = true;
+  if( up && !down ) {
+    if( i == bins-1 ) down=true;
+      else if( data[i] > data[i+1] ) down=true;
+  }
+
+  if( up && down ) {
+    nml++;
+    up = down = false;
+    if( imax < 0 ) {
+      imax = i; maxi = data[i];
+    } else if( data[i] >= maxi ) {
+      imaxn = imax; maxn = maxi;
+      imax = i; maxi = data[i];
+    } else {
+      if( imaxn < 0 || data[i] >= maxn ) { imaxn = i; maxn = data[i]; }
+    }
+  }
+
+}
+return nml;
+}
+
+/********* Methode *********/
+//++
+float Histo::FitMax(int degree, float frac, int debug) const
+//
+//	Fit de la position du maximum de l'histo par un polynome
+//	de degre `degree' a `frac' pourcent du maximum.
+//	L'histo est suppose etre remplit de valeurs positives
+//--
+{
+  if (degree < 2 || degree > 3) degree = 3;
+  if (frac <= 0. || frac >= 1.) frac = 0.5;
+
+  if (debug > 1)
+    cout<<"Histo::FitMax : Nb Entrees histo ="<<NEntries()<<endl;
+
+  if (NEntries() < 1) THROW(inconsistentErr);
+
+  int iMax = IMax();
+  float hmax = (*this)(iMax);
+  float xCenter = BinCenter(iMax);
+
+  if(debug>1)
+    cout<<"Max histo i="<<iMax<<" x="<<xCenter<<" v="<<hmax<<endl;
+
+  /* find limits at frac*hmax */
+
+  float limit = frac*hmax;
+
+  volatile int iLow = iMax;
+  while (iLow>0 && (*this)(iLow)>limit) iLow--;
+
+  volatile int iHigh = iMax;
+  while (iHigh<NBins()-1 && (*this)(iHigh)>limit) iHigh++;
+
+  int nLowHigh;
+  for(;;) {
+    nLowHigh = 0;
+    for (int i=iLow; i<=iHigh; i++) if((*this)(i)>0) {
+      if(!err2) nLowHigh++;
+        else if(Error2(i)>0.) nLowHigh++;
+    }
+    if (debug > 1) cout <<"Limites histo "<<iLow<<" - "<<iHigh
+                        <<" ("<<nLowHigh<<" non nuls)"<<endl;
+    if( nLowHigh >= degree+1 ) break;
+    iLow--;  iHigh++;
+    if(iLow<0 && iHigh>=NBins()) {
+      if (debug>1)
+        cout<<"Mode histogramme = "<<xCenter
+            <<"   BinCenter("<<iMax<<")"<<endl;
+      return xCenter;
+    }
+    if(iLow  < 0       ) iLow  = 0;
+    if(iHigh >= NBins()) iHigh = NBins()-1;
+  }
+
+  Vector xFit(nLowHigh);
+  Vector yFit(nLowHigh);
+  Vector e2Fit(nLowHigh);
+  Vector errcoef(1);
+  int ii = 0;
+  for (int j=iLow; j<=iHigh; j++) {
+    if ((*this)(j)>0) {
+      if(!err2) {
+        xFit(ii) = BinCenter(j)-xCenter;
+        yFit(ii) = (*this)(j);
+        e2Fit(ii) = yFit(ii);
+        ii++;
+      } else if(Error2(j)>0.) {
+        xFit(ii) = BinCenter(j)-xCenter;
+        yFit(ii) = (*this)(j);
+        e2Fit(ii) = Error2(j);
+        ii++;
+      }
+    }
+  }
+  if(debug>4) {
+    int k;
+    for(k=0;k<nLowHigh;k++) cout<<" "<<xFit(k);  cout<<endl;
+    for(k=0;k<nLowHigh;k++) cout<<" "<<yFit(k);  cout<<endl;
+    for(k=0;k<nLowHigh;k++) cout<<" "<<e2Fit(k); cout<<endl;
+  }
+  if( ii != nLowHigh ) THROW(inconsistentErr);
+  Poly pol(degree);
+  TRY {
+    pol.Fit(xFit, yFit, e2Fit, degree, errcoef);
+    if (debug>1) cout << "resultat fit = " << pol << endl;
+    pol.Derivate();
+  } CATCHALL {
+    THROW_SAME;
+  } ENDTRY
+
+  int DPolDeg = pol.Degre();
+  float fd = 0.;
+
+  if (DPolDeg == 0) {
+    // on est dans le cas d'un fit de droite
+    if( pol[0] > 0. ) {
+      // on a fitte une droite de pente >0.
+      fd = xFit(nLowHigh-1) + binWidth/2. + xCenter;
+    } else if( pol[0] < 0. ) {
+      // on a fitte une droite de pente <0.
+      fd = xFit(0) - binWidth/2. + xCenter;
+    } else {
+      // on a fitte une droite de pente =0. (creneau)
+      fd = (xFit(0)+xFit(nLowHigh-1))/2. + xCenter;
+    }
+  } else if (DPolDeg == 1) {
+    // on est dans le cas d'un fit de parabole
+    double r=0;
+    if (pol.Root1(r)==0) THROW(inconsistentErr);
+    fd = r + xCenter;
+  } else if (DPolDeg == 2) {
+    // on est dans le cas d'un fit de cubique
+    double r1=0;
+    double r2=0;
+    if (pol.Root2(r1,r2) == 0) THROW(inconsistentErr);
+    pol.Derivate();
+    fd = (pol(r1)<0) ? r1 + xCenter : r2 + xCenter;
+  } else {
+    // on est dans un cas non prevu
+    THROW(inconsistentErr);
+  }
+
+  if(fd>max) fd = max;
+  if(fd<min) fd = min;
+
+  if (debug>1)
+    cout << "Mode histogramme = " << fd
+         << "    (DerPol.degre =" << DPolDeg
+         << " pol.coeff[0] =" << pol[0]
+         << ")" << endl;
+
+  return fd;
+}
+
+
+/********* Methode *********/
+//++
+float Histo::FindWidth(float frac, int debug) const
+//
+//	Calcul de la largeur a frac pourcent du maximum
+//	autour du bin du maximum.
+//	L'histo est suppose etre remplit de valeurs positives
+//--
+{
+  float xmax = BinCenter( IMax() );
+  return FindWidth(xmax,frac,debug);
+}
+
+/********* Methode *********/
+//++
+float Histo::FindWidth(float xmax,float frac, int debug) const
+//
+//	Calcul de la largeur a frac pourcent de la valeur du bin xmax.
+//	L'histo est suppose etre remplit de valeurs positives
+//--
+{
+  if (frac <= 0 || frac >= 1.) frac = 0.5;
+
+  if (debug > 1)
+    cout << "Histo::FindWidth a " << frac
+         << " de xmax= " << xmax
+         << " , ndata= " << NData()
+         << " , nent= " << NEntries()
+         << " , nbin= " << NBins() << endl;
+
+  if (NEntries() < 1) THROW(inconsistentErr);
+  if (NBins() < 3) THROW(inconsistentErr);
+
+  int iMax = FindBin(xmax);
+  if (iMax<0 || iMax>=NBins()) THROW(inconsistentErr);
+  float hmax = data[iMax];
+  float limit = frac*hmax;
+  if (debug > 1)
+    cout << "  Max histo[" << iMax << "] = " << hmax
+         << ", limite " << limit << endl;
+
+  int iLow = iMax;
+  while (iLow>=0 && data[iLow]>limit) iLow--;
+  if( iLow < 0 ) iLow = 0;
+
+  int iHigh = iMax;
+  while (iHigh<NBins() && data[iHigh]>limit) iHigh++;
+  if( iHigh >=NBins() ) iHigh = NBins()-1;
+
+  float xlow   = BinCenter(iLow);
+  float ylow   = data[iLow];
+
+  float xlow1=xlow, ylow1=ylow;
+  if(iLow+1<NBins()) {
+    xlow1  = BinCenter(iLow+1);
+    ylow1  = data[iLow+1];
+  }
+
+  float xhigh  = BinCenter(iHigh);
+  float yhigh  = data[iHigh];
+
+  float xhigh1=xhigh, yhigh1=yhigh;
+  if(iHigh-1>=0) {
+    xhigh1 = BinCenter(iHigh-1);
+    yhigh1 = data[iHigh-1];
+  }
+
+  float xlpred,xhpred,wd;
+
+  if(ylow1>ylow) {
+    xlpred = xlow + (xlow1-xlow)/(ylow1-ylow)*(limit-ylow);
+    if(xlpred < xlow) xlpred = xlow;
+  } else xlpred = xlow;
+
+  if(yhigh1>yhigh) {
+    xhpred = xhigh + (xhigh1-xhigh)/(yhigh1-yhigh)*(limit-yhigh);
+    if(xhpred > xhigh) xhpred = xhigh;
+  } else xhpred = xhigh;
+
+  wd = xhpred - xlpred;
+
+  if (debug > 1) {
+    cout << "Limites histo: " << "  Width " << wd << endl;
+    cout << "  Low: [" << iLow  << "]=" << ylow << " pred-> " << xlpred
+         << " - High: [" << iHigh  << "]=" << yhigh << " pred-> " << xhpred
+         << endl;
+  }
+
+  return wd;
+}
+
+
+/********* Methode *********/
+//++
+int Histo::EstimeMax(float& xm,int SzPav)
+//
+//	Cf suivant mais im est le bin du maximum de l'histo
+//--
+{
+int im = IMax();
+return EstimeMax(im,xm,SzPav);
+}
+
+/********* Methode *********/
+//++
+int Histo::EstimeMax(int& im,float& xm,int SzPav)
+//
+//	Determine l'abscisses du maximum donne par im
+//	en moyennant dans un pave SzPav  autour du maximum
+//|  Return:
+//|     0 = si fit maximum reussi avec SzPav pixels
+//|     1 = si fit maximum reussi avec moins que SzPav pixels
+//|     2 = si fit maximum echoue et renvoit BinCenter()
+//|    -1 = si echec: SzPav <= 0 ou im hors limites
+//--
+{
+xm = 0;
+if( SzPav <= 0 ) return -1;
+if( im < 0 || im >= bins ) return -1;
+
+if( SzPav%2 == 0 ) SzPav++;
+SzPav = (SzPav-1)/2;
+
+int rc = 0;
+double dxm = 0, wx = 0;
+for(int i=im-SzPav;i<=im+SzPav;i++) {
+  if( i<0 || i>= bins ) {rc=1; continue;}
+  dxm += BinCenter(i) * (*this)(i);
+  wx  += (*this)(i);
+}
+
+if( wx > 0. ) {
+  xm = dxm/wx;
+  return rc;
+} else {
+  xm = BinCenter(im);
+  return 2;
+}
+
+}
+
+/********* Methode *********/
+//++
+void Histo::EstimeWidthS(float frac,float& widthG,float& widthD)
+//
+//	Determine la largeur a frac% du maximum a gauche (widthG)
+//	et a droite (widthD)
+//--
+{
+int i;
+widthG = widthD = -1.;
+if( bins<=1 || frac<=0. || frac>=1. ) return;
+
+int imax = 0;
+float maxi = data[0];
+for(i=1;i<bins;i++) if(data[i]>maxi) {imax=i; maxi=data[i];}
+float xmax = BinCenter(imax);
+float maxf = maxi * frac;
+
+// recherche du sigma a gauche
+widthG = 0.;
+for(i=imax;i>=0;i--) if( data[i] <= maxf ) break;
+if(i<0) i=0;
+if(i<imax) {
+  if( data[i+1] != data[i] ) {
+    widthG = BinCenter(i) + binWidth
+           * (maxf-data[i])/(data[i+1]-data[i]);
+    widthG = xmax - widthG;
+  } else widthG = xmax - BinCenter(i);
+}
+
+// recherche du sigma a droite
+widthD = 0.;
+for(i=imax;i<bins;i++) if( data[i] <= maxf ) break;
+if(i>=bins) i=bins-1;
+if(i>imax) {
+  if( data[i] != data[i-1] ) {
+    widthD = BinCenter(i) - binWidth
+           * (maxf-data[i])/(data[i-1]-data[i]);
+    widthD -= xmax;
+  } else widthD = BinCenter(i) - xmax;
+}
+
+}
+
+//////////////////////////////////////////////////////////
+//++
+int  Histo::Fit(GeneralFit& gfit,unsigned short typ_err)
+//
+//	Fit de l'histogramme par ``gfit''.
+//| typ_err = 0 :
+//|    - erreur attachee au bin si elle existe
+//|    - sinon 1
+//| typ_err = 1 :
+//|    - erreur attachee au bin si elle existe
+//|    - sinon max( sqrt(abs(bin) ,1 )
+//| typ_err = 2 :
+//|    - erreur forcee a 1
+//| typ_err = 3 :
+//|    - erreur forcee a max( sqrt(abs(bin) ,1 )
+//| typ_err = 4 :
+//|    - erreur forcee a 1, nulle si bin a zero.
+//| typ_err = 5 :
+//|    - erreur forcee a max( sqrt(abs(bin) ,1 ),
+//|      nulle si bin a zero.
+//--
+{
+if(NBins()<=0) return -1000;
+if(typ_err>5) typ_err=0;
+
+GeneralFitData mydata(1,NBins());
+
+for(int i=0;i<NBins();i++) {
+  double x = (double) BinCenter(i);
+  double f = (double) (*this)(i);
+  double saf = sqrt(fabs((double) f)); if(saf<1.) saf=1.;
+  double e;
+  if(typ_err==0)      {if(HasErrors()) e=Error(i); else e=1.;}
+  else if(typ_err==1) {if(HasErrors()) e=Error(i); else e=saf;}
+  else if(typ_err==2) e=1.;
+  else if(typ_err==3) e=saf;
+  else if(typ_err==4) e=(f==0.)?0.:1.;
+  else if(typ_err==5) e=(f==0.)?0.:saf;
+  mydata.AddData1(x,f,e);
+}
+
+gfit.SetData(&mydata);
+
+return gfit.Fit();
+}
+
+//++
+Histo* Histo::FitResidus(GeneralFit& gfit)
+//
+//	Retourne une classe contenant les residus du fit ``gfit''.
+//--
+{
+if(NBins()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+Histo* h = new Histo(*this);
+for(int i=0;i<NBins();i++) {
+  double x = (double) BinCenter(i);
+  (*h)(i) -= (float) f->Value(&x,par.Data());
+}
+return h;
+}
+
+//++
+Histo* Histo::FitFunction(GeneralFit& gfit)
+//
+//	Retourne une classe contenant la fonction du fit ``gfit''.
+//--
+{
+if(NBins()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+Histo* h = new Histo(*this);
+for(int i=0;i<NBins();i++) {
+  double x = (double) BinCenter(i);
+  (*h)(i) = (float) f->Value(&x,par.Data());
+}
+return h;
+}
+
+/********* Methode *********/
+//++
+void Histo::PrintF(FILE * fp, int hdyn,float hmin, float hmax,int pflag,
+	      int il, int ih)
+//
+//	Impression de l'histogramme dans le fichier fp
+//|   hdyn = nombre de colonnes pour imprimer les etoiles
+//|       si =0 alors defaut(100),
+//|       si <0 pas de print histo seulement infos
+//|   hmin = minimum de la dynamique
+//|   hmax = maximum de la dynamique
+//|       si hmax<=hmin           : hmin=VMin() hmax=VMax()
+//|       si hmax<=hmin et hmin=0 : hmin=0 hmax=VMax()
+//|       sinon : hmin hmax
+//|   pflag < 0 : on imprime les informations (nbin,min,...) sans l'histogramme
+//|         = 0 : on imprime  "BinCenter(i) data[i]"  (note "... ...")
+//|         bit 0 on : (v=1): numero_bin "... ..."
+//|         bit 1 on : (v=2): "... ..." erreur
+//--
+{
+
+ 
+ if( il > ih ) { il = 0; ih = bins-1; }
+ if( il < 0 ) il = 0;
+ if( ih >= bins ) ih = bins-1;
+
+ double dhmin = (double) hmin;
+ double dhmax = (double) hmax;
+ double hb,hbmn,hbmx;
+
+ if(hdyn==0) hdyn = 100;
+
+ cout << "~Histo::Print  "
+      << " nHist=" << nHist << "  nEntries=" << nEntries
+      << "  under=" << under << "  over=" << over << endl;
+ cout << "       bins=" << bins
+      << "  min=" << min << "  max=" << max
+      << "  binWidth=" << binWidth << endl;
+ cout << "       mean=" << Mean() << " r.m.s=" << Sigma() << endl;
+
+ if(hdyn<0 || pflag<0 ) return;
+
+ if(dhmax<=dhmin) { if(hmin != 0.) dhmin = (double) VMin(); else dhmin=0.;
+                  dhmax = (double) VMax(); }
+ if(dhmin>dhmax) return;
+ if(dhmin==dhmax) {dhmin -= 1.; dhmax += 1.;}
+ double wb = (dhmax-dhmin) / (double) hdyn;
+
+ // determination de la position de la valeur zero
+ int i0 = (int)(-dhmin/wb);
+
+ // si le zero est dans la dynamique,
+ //  il doit imperativement etre une limite de bin
+ if( 0 <= i0 && i0 < hdyn ) {
+   hbmn = dhmin + i0*wb;
+   hbmx = hbmn + wb;
+   if( hbmn != 0. ) {
+     hbmn *= -1.;
+     if( hbmn < hbmx ) {
+       // le zero est + pres du bord negatif du bin
+       dhmin += hbmn;
+       dhmax += hbmn;
+     } else {
+       // le zero est + pres du bord positif du bin
+       dhmin -= hbmx;
+       dhmax -= hbmx;
+     }
+     wb = (dhmax-dhmin) / (double) hdyn;
+     i0 = (int)(-dhmin/wb);
+   }
+ }
+
+ cout <<"       bin minimum="<<dhmin<<"   bin maximum="<<dhmax
+      <<"   binw="<<wb<< endl;
+
+ char* s = new char[hdyn+1];
+ s[hdyn] = '\0';
+
+ // premiere ligne
+ {for(int i=0;i<hdyn;i++) s[i] = '=';}
+ if( 0 <= i0 && i0 < hdyn ) s[i0] = '0';
+ if(pflag&1) fprintf( fp, "====");
+ fprintf( fp, "======================");
+ if(pflag&2 && err2!=NULL) fprintf( fp, "===========");
+ fprintf( fp, "==%s\n",s);
+
+ // histogramme
+ {for(int i=il;i<=ih;i++) {
+   for(int k=0;k<hdyn;k++) s[k] = ' ';
+   hb = (*this)(i);
+
+   //choix du bin (hdyn bin entre [dhmin,dhmax[
+   int ii = (int)( (hb-dhmin)/wb );
+   if(ii<0) ii = 0; else if(ii>=hdyn) ii = hdyn-1;
+
+   // limite du bin
+   hbmn = dhmin + ii*wb;
+   hbmx = hbmn + wb;
+
+   // remplissage de s[] en tenant compte des courbes +/-
+   if(i0<0) {
+     // courbe entierement positive
+     for(int k=0;k<=ii;k++) s[k] = 'X';
+   } else if(i0>=hdyn) {
+     // courbe entierement negative
+     for(int k=hdyn-1;k>=ii;k--) s[k] = 'X';
+   } else {
+     // courbe positive et negative
+     s[i0] = '|';
+     if(ii>i0)        for(int k=i0+1;k<=ii;k++) s[k] = 'X';
+       else if(ii<i0) for(int k=ii;k<i0;k++)    s[k] = 'X';
+          else s[ii] = 'X';
+   }
+
+   // valeur a mettre dans le bin le plus haut/bas
+   int ib;
+   if(hb>0.) ib = (int)( 10.*(hb-hbmn)/(hbmx-hbmn) );
+     else if(hb<0.) ib = (int)( 10.*(hbmx-hb)/(hbmx-hbmn) );
+       else ib = -1;
+   if(ib==-1) s[ii] = '|';
+     else if(ib==0) s[ii] = '.';
+       else if(ib>0 && ib<10) s[ii] = (char)((int) '0' + ib);
+
+   // traitement des saturations +/-
+   if( hb < dhmin ) s[0] = '*';
+    else if( hb > dhmax ) s[hdyn-1] = '*';
+
+   if(pflag&1) fprintf( fp, "%3d ",i);
+   fprintf( fp, "%10.4g %10.4g ",BinCenter(i),hb);
+   if(pflag&2 && err2!=NULL) fprintf( fp, "%10.4g ",Error(i));
+   fprintf( fp, "= %s\n",s);
+ }}
+
+ // derniere ligne
+ for(int i=0;i<hdyn;i++) s[i] = '=';
+ if( 0 <= i0 && i0 < hdyn ) s[i0] = '0';
+ if(pflag&1) fprintf( fp, "====");
+ fprintf( fp, "======================");
+ if(pflag&2 && err2!=NULL) fprintf( fp, "===========");
+ fprintf( fp, "==%s\n",s);
+
+ // valeur basse des bins (sur ["ndig-1" digits + signe] =  ndig char (>=3))
+ const int ndig = 7;
+ char sn[2*ndig+10];
+ hb = ( fabs(dhmin) > fabs(dhmax) ) ? fabs(dhmin) : fabs(dhmax);
+ int n;
+ if( hb > 0. ) n = (int)(log10(hb*1.00000001)); else n = 1;
+ double scaledig = pow(10.,(double) ndig-2);
+ double expo = scaledig/pow(10.,(double) n);
+ // cout <<"n="<<n<<" hb="<<hb<<" scaledig="<<scaledig<<" expo="<<expo<<endl;
+ for(int k=0;k<ndig;k++) {
+   for(int i=0;i<hdyn;i++) s[i] = ' ';
+   {for(int i=0;i<hdyn;i++) {
+     n = (int)( (dhmin + i*wb)*expo );
+     for(int j=0;j<2*ndig+10;j++) sn[j] = ' ';
+     sprintf(sn,"%d%c",n,'\0');
+     strip(sn,'B',' ');
+     // cout <<"n="<<n<<" sn=("<<sn<<")  l="<<strlen(sn)<<" k="<<k;
+     if( (int) strlen(sn) > k ) s[i] = sn[k];
+     // cout <<"  s=("<<s<<")"<<endl;
+   }}
+   if(pflag&1) fprintf( fp, "    ");
+   fprintf( fp, "                      ");
+   if(pflag&2 && err2!=NULL) fprintf( fp, "           ");
+   fprintf( fp, "  %s\n",s);
+ }
+ fprintf( fp, "  (valeurs a multiplier par %.0e)\n",1./expo);
+
+ delete[] s;
+}
+
+/********* Methode *********/
+//++
+void Histo::Print(int hdyn,float hmin, float hmax,int pflag,
+	     int il, int ih)
+//
+//	Impression de l'histogramme sur stdout
+//--
+{
+ Histo::PrintF(stdout, hdyn, hmin, hmax, pflag, il, ih);
+}
+ 
+
+/********* Methode *********/
+//++
+void  Histo::WriteSelf(POutPersist& s)  const
+//
+//	Ecriture ppersist
+//--
+{
+char strg[256];
+
+// Que faut-il ecrire?
+int errok = (err2) ? 1 : 0;
+
+// Ecriture entete pour identifier facilement
+sprintf(strg,"bins=%6d  NEnt=%15d  errok=%1d",bins,nEntries,errok);
+s.PutLine(strg);
+sprintf(strg,"binw=%g  min=%g max=%g",binWidth,min,max);
+s.PutLine(strg);
+sprintf(strg, "under=%g over=%g nHist=%g",under,over,nHist);
+s.PutLine(strg);
+
+// Ecriture des valeurs
+s.PutI4(bins);
+s.PutI4(nEntries);
+s.PutI4(errok);
+
+s.PutR4(binWidth);
+s.PutR4(min);
+s.PutR4(max);
+s.PutR4(under);
+s.PutR4(over);
+
+s.PutR8(nHist);
+
+// Ecriture des donnees Histo 1D
+sprintf(strg,"Histo: Tableau des donnees %d",bins);
+s.PutLine(strg);
+s.PutR4s(data, bins);
+
+// Ecriture des erreurs
+if(errok) {
+  sprintf(strg,"Histo: Tableau des erreurs %d",bins);
+  s.PutLine(strg);
+  s.PutR8s(err2, bins);
+}
+
+return;
+}
+
+/********* Methode *********/
+//++
+void  Histo::ReadSelf(PInPersist& s)
+//
+//	Lecture ppersist
+//--
+{
+char strg[256];
+
+Delete();
+
+// Lecture entete
+s.GetLine(strg, 255);
+s.GetLine(strg, 255);
+s.GetLine(strg, 255);
+
+// Lecture des valeurs
+s.GetI4(bins);
+s.GetI4(nEntries);
+int_4 errok;
+s.GetI4(errok);
+
+s.GetR4(binWidth);
+s.GetR4(min);
+s.GetR4(max);
+s.GetR4(under);
+s.GetR4(over);
+
+s.GetR8(nHist);
+
+// Lecture des donnees Histo 1D
+data = new float[bins];
+s.GetLine(strg, 255);
+s.GetR4s(data, bins);
+
+// Lecture des erreurs
+if(errok) {
+  s.GetLine(strg, 255);
+  err2 = new double[bins];
+  s.GetR8s(err2, bins);
+}
+
+return;
+}
+
+
+
+// Rappel des inlines functions pour commentaires
+//++
+// inline float          XMin() const
+//	Retourne l'abscisse minimum
+//--
+//++
+// inline float          XMax() const
+//	Retourne l'abscisse maximum
+//--
+//++
+// inline int            NBins() const
+//	Retourne le nombre de bins
+//--
+//++
+// inline float          BinWidth() const
+//	Retourne la largeur du bin
+//--
+//++
+// inline float*         Bins() const
+//	Retourne le pointeur sur le tableaux des contenus
+//--
+//++
+// inline float          operator()(int i) const
+//	Retourne le contenu du bin i
+//--
+//++
+// inline float&         operator()(int i)
+//	Remplit le contenu du bin i
+//--
+//++
+// inline float          Error(int i) const
+//	Retourne l'erreur du bin i
+//--
+//++
+// inline double         Error2(int i) const
+//	Retourne l'erreur au carre du bin i
+//--
+//++
+// inline double&        Error2(int i)
+//	Remplit l'erreur au carre du bin i
+//--
+//++
+// inline float          NData() const
+//	Retourne la somme ponderee
+//--
+//++
+// inline float          NEntries()
+//	Retourne le nombre d'entrees
+//--
+//++
+// inline float          NOver() const
+//	Retourne le nombre d'overflow
+//--
+//++
+// inline float          NUnder() const
+//	Retourne le nombre d'underflow
+//--
+//++
+// inline float          BinLowEdge(int i)  const
+//	Retourne l'abscisse du bord inferieur du bin i
+//--
+//++
+// inline float          BinCenter(int i)   const
+//	Retourne l'abscisse du centre du bin i
+//--
+//++
+// inline float          BinHighEdge(int i) const
+//	Retourne l'abscisse du bord superieur du bin i
+//--
+//++
+// inline int            FindBin(float x) const   
+//	Retourne le numero du bin contenant l'abscisse x
+//--
Index: /tags/DPC_V0/SophyaLib/NTools/histos.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/histos.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/histos.h	(revision 1307)
@@ -0,0 +1,165 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// $Id: histos.h,v 1.1.1.1 1999-04-09 17:57:56 ansari Exp $
+//
+
+#ifndef HISTOS_SEEN
+#define HISTOS_SEEN
+
+#include <stdio.h>
+#include "peida.h"
+#include "cvector.h"
+#include "ppersist.h"
+
+class GeneralFit;
+
+class Histo : public PPersist {
+
+public:
+  enum {classId = ClassId_Histo1D };
+
+  // CREATOR / DESTRUCTOR
+  Histo();
+  Histo(float xMin, float xMax, int nBin=100);
+  Histo(char *flnm);
+  Histo(const Histo& H);
+  virtual        ~Histo();
+
+  // OPTIONS
+  void   Errors();
+
+  // UPDATING or SETTING
+  void   Zero();
+  void   Add(float x, float w = 1.);
+  void   AddBin(int numBin, float w = 1.);
+  void   SetBin(float x, float w = 1.);
+  void   SetBin(int numBin, float w = 1.);
+  void   SetErr2(float x, double e2);
+  void   SetErr2(int numBin, double e2);
+  void   SetErr(float x, float e);
+  void   SetErr(int numBin, float e);
+
+  // Operators
+  Histo& operator = (const Histo& h);
+  Histo& operator *= (double b);
+  Histo& operator /= (double b);
+  Histo& operator += (double b);
+  Histo& operator -= (double b);
+  friend Histo operator * (const Histo& a, double b);
+  friend Histo operator * (double b, const Histo& a);
+  friend Histo operator / (const Histo& a, double b);
+  friend Histo operator + (const Histo& a, double b);
+  friend Histo operator + (double b, const Histo& a);
+  friend Histo operator - (const Histo& a, double b);
+  friend Histo operator - (double b, const Histo& a);
+  Histo& operator += (const Histo& a);
+  Histo& operator -= (const Histo& a);
+  Histo& operator *= (const Histo& a);
+  Histo& operator /= (const Histo& a);
+  friend Histo operator + (const Histo& a, const Histo& b);
+  friend Histo operator - (const Histo& a, const Histo& b);
+  friend Histo operator * (const Histo& a, const Histo& b);
+  friend Histo operator / (const Histo& a, const Histo& b);
+
+  // get/put dans/depuis un vector
+  void GetAbsc(Vector& v);
+  void GetValue(Vector& v);
+  void GetError2(Vector& v);
+  void GetError(Vector& v);
+  void PutValue(Vector& v, int ierr=0);
+  void PutValueAdd(Vector &v, int ierr=0);
+  void PutError2(Vector& v);
+  void PutError2Add(Vector& v);
+  void PutError(Vector& v);
+
+  // INLINES
+  inline float          XMin() const             {return min;}
+  inline float          XMax() const             {return max;}
+  inline int_4          NBins() const            {return bins;}
+  inline float          BinWidth() const         {return binWidth;}
+  inline float*         Bins() const             {return data;}
+  inline float          operator()(int i) const  {return data[i];}
+  inline float&         operator()(int i)        {return data[i];}
+  inline bool           HasErrors() { if(err2) return true; else return false;}
+  inline float          Error(int i) const
+                          {if(err2) {if(err2[i]>0.) return sqrt(err2[i]); else return 0.;}
+                           else return 0.;}
+  inline double         Error2(int i) const
+                          {if(err2) return err2[i]; else return 0.;}
+  inline double&        Error2(int i) {return err2[i];}
+  inline float          NData() const            {return (float) nHist;}
+  inline float          NEntries() const         {return nEntries;}
+  inline float          NOver() const            {return over;}
+  inline float          NUnder() const           {return under;}
+
+  inline float          BinLowEdge(int i)  const {return min + i*binWidth;}
+  inline float          BinCenter(int i)   const {return min + (i+0.5)*binWidth;}
+  inline float          BinHighEdge(int i) const {return min + (i+1)*binWidth;} 
+  inline int_4          FindBin(float x) const   
+                            {return (int_4) floorf((x - min) / binWidth);}
+
+  // Info, statistique et calculs sur les histogrammes
+  int            BinNonNul() const;
+  int            ErrNonNul() const;
+  int            IMax() const;
+  int            IMin() const;
+  float          VMax() const;
+  float          VMin() const;
+  float          Mean() const;
+  float          Sigma() const;
+  float          MeanLH(int il,int ih) const;
+  float          SigmaLH(int il,int ih) const;
+  float          Mean(float x0, float dx) const;
+  float          Sigma(float x0, float dx) const;
+  float          CleanedMean() const;
+  float          CleanedMean(float& sigma) const;
+  int            BinPercent(float per) const;
+  int            BinPercent(float x,float per,int& imin,int& imax);
+  int            BinPercent(float x,float per,float& xmin,float& xmax);
+  void           HInteg(float norm = 0.);
+  void           HDeriv();
+  void           HRebin(int nbinew);
+
+  int            MaxiLocal(float& maxi,int& imax,float& maxn,int& imaxn);
+  float          FitMax(int degree=2, float frac=0.5f, int debug=0) const;
+  float          FindWidth(float xmax,float frac=0.5f, int debug=0) const;
+  float          FindWidth(float frac=0.5f, int debug=0) const;
+  int            EstimeMax(float& xm,int SzPav = 3);
+  int            EstimeMax(int& im,float& xm,int SzPav = 3);
+  void           EstimeWidthS(float frac,float& widthG,float& widthD);
+
+  // Fit
+  int    Fit(GeneralFit& gfit,unsigned short typ_err=0);
+  Histo* FitResidus(GeneralFit& gfit);
+  Histo* FitFunction(GeneralFit& gfit);
+
+  // Print et Display ASCII
+  void           PrintF(FILE * fp, int dyn = 100, float hmin = 1., float hmax = -1.,
+			int pflag = 0, int il = 1, int ih = -1);
+  void           Print(int dyn = 100, float hmin = 1., float hmax = -1.,
+			int pflag = 0, int il = 1, int ih = -1);
+
+  // PPersist objet
+  int_4             ClassId() const        { return classId; }
+  static PPersist*  Create()               { return new Histo;}
+
+  virtual void      WriteSelf(POutPersist&) const;
+  virtual void      ReadSelf(PInPersist&);
+
+
+protected:
+  void Delete();
+
+  float*         data;		 
+  double*        err2;		 
+  float          under;
+  float          over;
+  double         nHist;
+  int_4          nEntries;
+  int_4          bins;
+  float          min;
+  float          max;
+  float          binWidth;
+};
+
+#endif // HISTOS_SEEN
Index: /tags/DPC_V0/SophyaLib/NTools/histos2.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/histos2.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/histos2.cc	(revision 1307)
@@ -0,0 +1,2053 @@
+//
+//    cmv 05/08/96
+//
+
+#include "defs.h"
+
+#include <string.h>
+#include <new.h>
+#include <stdlib.h>
+#include <stdio.h>
+#ifndef __mac__
+#include <values.h>
+#endif
+
+#include "histos2.h"
+#include "generalfit.h"
+
+//++
+// Class	Histo2D
+// Lib	Outils++ 
+// include	histos2.h
+//
+//	Classe d'histogrammes 2D
+//--
+
+///////////////////////////////////////////////////////////////////
+//++
+// Titre	Constructeurs
+//--
+
+//++
+Histo2D::Histo2D(float xMin, float xMax, int nxBin
+                ,float yMin, float yMax, int nyBin)
+//
+//	Createur d'un histogramme 2D ayant nxBin,nyBin bins
+//	entre xMin,xMax et yMin,yMax.
+//--
+      : data(new float[nxBin*nyBin]), err2(NULL)
+      , nHist(0), nEntries(0)
+      , nx(nxBin), ny(nyBin), nxy(nxBin*nyBin)
+      , xmin(xMin), xmax(xMax), ymin(yMin), ymax(yMax)
+      , wbinx((xMax - xMin)/nxBin), wbiny((yMax - yMin)/nyBin)
+      , hprojx(NULL), hprojy(NULL)
+{
+DBASSERT(nxBin>0 && nyBin>0 && xMin<xMax && yMin<yMax);
+for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.;
+Zero();
+b_s.H = NULL;
+END_CONSTRUCTOR
+}
+
+//++
+Histo2D::Histo2D(const Histo2D& h)
+//
+//	Constructeur par copie.
+//--
+{
+int i,j;
+data = new float[h.nxy];
+memcpy(data, h.data, h.nxy*sizeof(float));
+
+err2 = NULL;
+if(h.err2) {
+  err2 = new double[h.nxy];
+  memcpy(err2, h.err2, h.nxy*sizeof(double));
+}
+
+nHist = h.nHist; nEntries = h.nEntries;
+for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j]=h.over[i][j];
+nx = h.nx;  ny = h.ny;  nxy = h.nxy;
+xmin = h.xmin; xmax = h.xmax; ymin = h.ymin; ymax = h.ymax;
+wbinx = h.wbinx; wbiny = h.wbiny;
+b_s.H = NULL;
+
+hprojx = hprojy = NULL;
+if(h.hprojx) {
+  SetProjX();
+  *hprojx = *(h.hprojx);
+}
+if(h.hprojy) {
+  SetProjY();
+  *hprojy = *(h.hprojy); 
+}
+
+int nb;
+float min,max;
+nb = h.NSliX();
+if(nb>0) {
+  SetSliX(nb);
+  for(i=0; i<NSliX();i++) *HSliX(i) = *(h.HSliX(i));
+}
+nb = h.NSliY();
+if(nb>0) {
+  SetSliY(nb);
+  for(i=0; i<NSliY();i++) *HSliY(i) = *(h.HSliY(i));
+}
+
+nb = h.NBandX();
+if(nb>0) {
+  for(i=0; i<nb;i++) {
+    h.GetBandX(i,min,max);
+    SetBandX(min,max);
+    *HBandX(i) = *(h.HBandX(i));
+  }
+  for(i=0; i<NBandX();i++) *HBandX(i) = *(h.HBandX(i));
+}
+nb = h.NBandY();
+if(nb>0) {
+  for(i=0; i<nb;i++) {
+    h.GetBandY(i,min,max);
+    SetBandY(min,max);
+    *HBandY(i) = *(h.HBandY(i));
+  }
+  for(i=0; i<NBandY();i++) *HBandY(i) = *(h.HBandY(i));
+}
+
+END_CONSTRUCTOR
+}
+
+//++
+Histo2D::Histo2D()
+//
+//	Constructeur par defaut.
+//--
+      : data(NULL), err2(NULL)
+      , nHist(0), nEntries(0)
+      , nx(0), ny(0), nxy(0)
+      , xmin(0), xmax(0), ymin(0), ymax(0)
+      , wbinx(0), wbiny(0)
+      , hprojx(NULL), hprojy(NULL)
+{
+for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.;
+b_s.H = NULL;
+END_CONSTRUCTOR
+}
+
+//++
+Histo2D::Histo2D(char *flnm)
+//
+//	Constructeur par lecture d'un fichier ppersist.
+//--
+      : data(NULL), err2(NULL)
+      , nHist(0), nEntries(0)
+      , nx(0), ny(0), nxy(0)
+      , xmin(0), xmax(0), ymin(0), ymax(0)
+      , wbinx(0), wbiny(0)
+      , hprojx(NULL), hprojy(NULL)
+{
+b_s.H = NULL;
+PInPersist s(flnm);
+Read(s);
+END_CONSTRUCTOR
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+void Histo2D::Delete()
+//
+//	Desallocation de la place de l'histogramme (fct privee).
+//--
+{
+  if( data != NULL ) { delete[] data; data = NULL;}
+
+  if( err2 != NULL ) { delete[] err2; err2 = NULL;}
+
+  DelProj();
+
+  DelBandX();
+  DelBandY();
+
+  DelSliX();
+  DelSliY();
+
+  nHist = 0;
+  nEntries = 0;
+  nx = 0; ny = 0; nxy = 0;
+  xmin = 0; xmax = 0; ymin = 0; ymax = 0;
+  wbinx = 0; wbiny = 0;
+  for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.;
+  b_s.H = NULL;
+}
+
+//++
+Histo2D::~Histo2D()
+//
+//	Destructeur.
+//--
+{
+Delete();
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+// Titre	Methodes generales
+//--
+
+//++
+void Histo2D::Zero()
+//
+//	Remise a zero du contenu, des erreurs et des valeurs.
+//--
+{
+  nHist = nEntries = 0;
+  for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.;
+  memset(data, 0, nxy*sizeof(float));
+  memset(over, 0, 9*sizeof(float));
+
+  if( err2 != NULL ) memset(err2, 0, nxy*sizeof(double));
+
+  ZeroProj();
+
+  ZeroBandX();
+  ZeroBandY();
+
+  ZeroSliX();
+  ZeroSliY();
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+void Histo2D::Errors()
+//
+//	Pour avoir le calcul des erreurs.
+//--
+{
+ if( nxy > 0 ) {
+   if(err2==NULL) err2 = new double[nxy];
+   memset(err2, 0, nxy*sizeof(double));
+ }
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+Histo2D& Histo2D::operator = (const Histo2D& h)
+//
+//--
+{
+  int i,j,nb;
+  float min,max;
+
+  if(this == &h) return *this;
+  if( h.nxy > nxy ) Delete();
+  if(!data) data = new float[h.nxy];
+  if( !h.err2 && err2 ) { delete [] err2; err2=NULL;}
+  if( h.err2 && !err2 ) err2 = new double[h.nxy];
+
+  for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] = h.over[i][j];
+  nHist = h.nHist;
+  nEntries = h.nEntries;
+  nx = h.nx;  ny = h.ny;  nxy = h.nxy;
+  xmin = h.xmin; xmax = h.xmax; wbinx = h.wbinx;
+  ymin = h.ymin; ymax = h.ymax; wbiny = h.wbiny;
+  
+  memcpy(data, h.data, nxy*sizeof(float));
+  if(err2) memcpy(err2, h.err2, nxy*sizeof(double));
+
+  DelProjX();
+  if(h.hprojx) {
+    SetProjX();
+    *hprojx = *(h.hprojx);
+  }
+  DelProjY();
+  if(h.hprojy) {
+    SetProjY();
+    *hprojy = *(h.hprojy);
+  }
+
+  DelSliX();
+  nb = h.NSliX();
+  if(nb>0) {
+    SetSliX(nb);
+    for(i=0; i<NSliX();i++) *HSliX(i) = *(h.HSliX(i));
+  }
+  DelSliY();
+  nb = h.NSliY();
+  if(nb>0) {
+    SetSliY(nb);
+    for(i=0; i<NSliY();i++) *HSliY(i) = *(h.HSliY(i));
+  }
+
+  DelBandX();
+  nb = h.NBandX();
+  if(nb>0) {
+    for(i=0; i<nb;i++) {
+      h.GetBandX(i,min,max);
+      SetBandX(min,max);
+      *HBandX(i) = *(h.HBandX(i));
+    }
+    for(i=0; i<NBandX();i++) *HBandX(i) = *(h.HBandX(i));
+  }
+  DelBandY();
+  nb = h.NBandY();
+  if(nb>0) {
+    for(i=0; i<nb;i++) {
+      h.GetBandY(i,min,max);
+      SetBandY(min,max);
+      *HBandY(i) = *(h.HBandY(i));
+    }
+    for(i=0; i<NBandY();i++) *HBandY(i) = *(h.HBandY(i));
+  }
+
+  return *this;
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+Histo2D& Histo2D::operator *= (double b)
+//
+//--
+{
+int i,j;
+double b2 = b*b;
+for(i=0;i<nxy;i++) {
+  data[i] *= b;
+  if(err2) err2[i] *= b2;
+}
+for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] *= b;
+nHist *= b;
+
+if(hprojx) *hprojx *= b;
+if(hprojy) *hprojy *= b;
+if(NSliX()>0) for(i=0; i<NSliX();i++) *HSliX(i) *= b;
+if(NSliY()>0) for(i=0; i<NSliY();i++) *HSliY(i) *= b;
+if(NBandX()>0) for(i=0; i<NBandX();i++) *HBandX(i) *= b;
+if(NBandY()>0) for(i=0; i<NBandY();i++) *HBandY(i) *= b;
+
+return *this;
+}
+
+//++
+Histo2D& Histo2D::operator /= (double b)
+//
+//--
+{
+int i,j;
+if (b==0.) THROW(inconsistentErr);
+double b2 = b*b;
+for(i=0;i<nxy;i++) {
+  data[i] /= b;
+  if(err2) err2[i] /= b2;
+}
+for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] /= b;
+nHist /= b;
+
+if(hprojx) *hprojx /= b;
+if(hprojy) *hprojy /= b;
+if(NSliX()>0) for(i=0; i<NSliX();i++) *HSliX(i) /= b;
+if(NSliY()>0) for(i=0; i<NSliY();i++) *HSliY(i) /= b;
+if(NBandX()>0) for(i=0; i<NBandX();i++) *HBandX(i) /= b;
+if(NBandY()>0) for(i=0; i<NBandY();i++) *HBandY(i) /= b;
+
+return *this;
+}
+
+//++
+Histo2D& Histo2D::operator += (double b)
+//
+//--
+{
+int i,j;
+float min,max;
+for(i=0;i<nxy;i++) data[i] += b;
+for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] += b;
+nHist += nxy*b;
+
+if(hprojx) *hprojx += b*ny;
+if(hprojy) *hprojy += b*nx;
+if(NSliX()>0) for(i=0; i<NSliX();i++) *HSliX(i) += b*ny/NSliX();
+if(NSliY()>0) for(i=0; i<NSliY();i++) *HSliY(i) += b*nx/NSliY();
+if(NBandX()>0) for(i=0; i<NBandX();i++) {
+  GetBandX(i,min,max);
+  *HBandX(i) += b*(max-min)/(ymax-ymin)*ny;
+}
+if(NBandY()>0) for(i=0; i<NBandY();i++) {
+  GetBandY(i,min,max);
+  *HBandY(i) += b*(max-min)/(xmax-xmin)*nx;
+}
+
+return *this;
+}
+
+//++
+Histo2D& Histo2D::operator -= (double b)
+//
+//--
+{
+int i,j;
+float min,max;
+for(i=0;i<nxy;i++) data[i] -= b;
+for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] -= b;
+nHist -= nxy*b;
+
+if(hprojx) *hprojx -= b*ny;
+if(hprojy) *hprojy -= b*nx;
+if(NSliX()>0) for(i=0; i<NSliX();i++) *HSliX(i) -= b*ny/NSliX();
+if(NSliY()>0) for(i=0; i<NSliY();i++) *HSliY(i) -= b*nx/NSliY();
+if(NBandX()>0) for(i=0; i<NBandX();i++) {
+  GetBandX(i,min,max);
+  *HBandX(i) -= b*(max-min)/(ymax-ymin)*ny;
+}
+if(NBandY()>0) for(i=0; i<NBandY();i++) {
+  GetBandY(i,min,max);
+  *HBandY(i) -= b*(max-min)/(xmax-xmin)*nx;
+}
+
+return *this;
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+Histo2D operator * (const Histo2D& a, double b)
+//
+//--
+{
+  Histo2D result(a);
+  return (result *= b);
+}
+
+//++
+Histo2D operator * (double b, const Histo2D& a)
+//
+//--
+{
+  Histo2D result(a);
+  return (result *= b);
+}
+
+//++
+Histo2D operator / (const Histo2D& a, double b)
+//
+//--
+{
+  Histo2D result(a);
+  return (result /= b);
+}
+
+//++
+Histo2D operator + (const Histo2D& a, double b)
+//
+//--
+{
+  Histo2D result(a);
+  return (result += b);
+}
+
+//++
+Histo2D operator + (double b, const Histo2D& a)
+//
+//--
+{
+  Histo2D result(a);
+  return (result += b);
+}
+
+//++
+Histo2D operator - (const Histo2D& a, double b)
+//
+//--
+{
+  Histo2D result(a);
+  return (result -= b);
+}
+
+//++
+Histo2D operator - (double b, const Histo2D& a)
+//
+//--
+{
+  Histo2D result(a);
+  result *= -1.;
+  return (result += b);
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+Histo2D& Histo2D::operator += (const Histo2D& a)
+//
+//--
+{
+int i,j;
+if(nx!=a.nx || ny!=a.ny) THROW(sizeMismatchErr);
+for(i=0;i<nxy;i++) {
+  data[i] += a.data[i];
+  if(err2 && a.err2) err2[i] += a.err2[i];
+}
+for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] += a.over[i][j];
+nHist += a.nHist;
+nEntries += a.nEntries;
+
+if(hprojx && a.hprojx) *hprojx += *(a.hprojx);
+if(hprojy && a.hprojy) *hprojy += *(a.hprojy);
+ZeroSliX();  ZeroSliY();
+ZeroBandX(); ZeroBandY();
+
+return *this;
+}
+
+//++
+Histo2D& Histo2D::operator -= (const Histo2D& a)
+//
+//--
+{
+int i,j;
+if(nx!=a.nx || ny!=a.ny) THROW(sizeMismatchErr);
+for(i=0;i<nxy;i++) {
+  data[i] -= a.data[i];
+  if(err2 && a.err2) err2[i] += a.err2[i];
+}
+for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] += a.over[i][j];
+nHist -= a.nHist;
+nEntries += a.nEntries;
+
+if(hprojx && a.hprojx) *hprojx -= *(a.hprojx);
+if(hprojy && a.hprojy) *hprojy -= *(a.hprojy);
+ZeroSliX();  ZeroSliY();
+ZeroBandX(); ZeroBandY();
+
+return *this;
+}
+
+//++
+Histo2D& Histo2D::operator *= (const Histo2D& a)
+//
+//--
+{
+int i,j;
+if(nx!=a.nx || ny!=a.ny) THROW(sizeMismatchErr);
+nHist = 0.;
+for(i=0;i<nxy;i++) {
+  if(err2 && a.err2)
+      err2[i] = a.data[i]*a.data[i]*err2[i] + data[i]*data[i]*a.err2[i];
+  data[i] *= a.data[i];
+  nHist += data[i];
+}
+for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] *= a.over[i][j];
+nEntries += a.nEntries;
+
+if(hprojx && a.hprojx) *hprojx *= *(a.hprojx);
+if(hprojy && a.hprojy) *hprojy *= *(a.hprojy);
+ZeroSliX();  ZeroSliY();
+ZeroBandX(); ZeroBandY();
+
+return *this;
+}
+
+//++
+Histo2D& Histo2D::operator /= (const Histo2D& a)
+//
+//--
+{
+int i,j;
+if(nx!=a.nx || ny!=a.ny) THROW(sizeMismatchErr);
+nHist = 0.;
+for(i=0;i<nxy;i++) {
+  if(a.data[i]==0.) {
+    data[i]=0.;
+    if(err2) err2[i]=0.;
+    continue;
+  }
+  if(err2 && a.err2)
+      err2[i] = (err2[i] + data[i]/a.data[i]*data[i]/a.data[i]*a.err2[i])
+                /(a.data[i]*a.data[i]);
+  data[i] /= a.data[i];
+  nHist += data[i];
+}
+for(i=0;i<3;i++) for(j=0;j<3;j++) 
+  if(a.over[i][j]!=0.) over[i][j] *= a.over[i][j]; else over[i][j] = 0.;
+nEntries += a.nEntries;
+
+if(hprojx && a.hprojx) *hprojx /= *(a.hprojx);
+if(hprojy && a.hprojy) *hprojy /= *(a.hprojy);
+ZeroSliX();  ZeroSliY();
+ZeroBandX(); ZeroBandY();
+
+return *this;
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+Histo2D operator + (const Histo2D& a, const Histo2D& b)
+//
+//--
+{
+if (b.nx!=a.nx || b.ny!=a.ny) THROW(sizeMismatchErr);
+Histo2D c(a);
+return (c += b);
+}
+
+//++
+Histo2D operator - (const Histo2D& a, const Histo2D& b)
+//
+//--
+{
+if (b.nx!=a.nx || b.ny!=a.ny) THROW(sizeMismatchErr);
+Histo2D c(a);
+return (c -= b);
+}
+
+//++
+Histo2D operator * (const Histo2D& a, const Histo2D& b)
+//
+//--
+{
+if (b.nx!=a.nx || b.ny!=a.ny) THROW(sizeMismatchErr);
+Histo2D c(a);
+return (c *= b);
+}
+
+//++
+Histo2D operator / (const Histo2D& a, const Histo2D& b)
+//
+//--
+{
+if (b.nx!=a.nx || b.ny!=a.ny) THROW(sizeMismatchErr);
+Histo2D c(a);
+return (c /= b);
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+void Histo2D::GetXCoor(Vector &v)
+//
+//	Remplissage d'un tableau avec les valeurs des abscisses.
+//--
+{
+float x,y;
+v.Realloc(nx);
+for(int i=0;i<nx;i++) {BinLowEdge(i,0,x,y); v(i) = x;}
+return;
+}
+
+//++
+void Histo2D::GetYCoor(Vector &v)
+//
+//	Remplissage d'un tableau avec les valeurs des ordonnees.
+//--
+{
+float x,y;
+v.Realloc(ny);
+for(int i=0;i<ny;i++) {BinLowEdge(0,i,x,y); v(i) = y;}
+return;
+}
+
+//++
+//| Remarque sur les indices:
+//|  H(i,j)   -> i  = coord x (0<i<nx),     j  = coord y (0<j<ny)
+//|  v(ii,jj) -> ii = ligne (0<i<NRows()),  jj = colonne (0<i<NCol())
+//|  On fait une correspondance directe i<->ii et j<->jj
+//|  ce qui, en representation classique des histos2D et des matrices
+//|  entraine une inversion x<->y cad une symetrie / diagonale principale
+//|  H(0,...)  represente ^         mais v(0,...) represente
+//|                       |x.......               |xxxxxxxx|
+//|                       |x.......               |........|
+//|                       |x.......               |........|
+//|                       |x.......               |........|
+//|                       |x.......               |........|
+//|                       --------->
+//|                       colonne no 1            ligne no 1
+//--
+
+//++
+void Histo2D::GetValue(Matrix &v)
+//
+//	Remplissage d'un tableau avec les valeurs du contenu.
+//--
+{
+v.Realloc(nx,ny);
+for(int i=0;i<nx;i++)
+  for(int j=0;j<ny;j++) v(i,j) = (*this)(i,j);
+return;
+}
+
+//++
+void Histo2D::GetError2(Matrix &v)
+//
+//	Remplissage d'un tableau avec les valeurs du carre des erreurs.
+//--
+{
+int i,j;
+v.Realloc(nx,ny);
+if(!err2) for(i=0;i<nx;i++)
+            for(j=0;j<ny;j++) { v(i,j) = 0.; return;}
+for(i=0;i<nx;i++)
+  for(j=0;j<ny;j++) v(i,j) = Error2(i,j);
+return;
+}
+
+//++
+void Histo2D::GetError(Matrix &v)
+//
+//	Remplissage d'un tableau avec les valeurs des erreurs.
+//--
+{
+int i,j;
+v.Realloc(nx,ny);
+if(!err2) for(i=0;i<nx;i++)
+            for(j=0;j<ny;j++) { v(i,j) = 0.; return;}
+for(i=0;i<nx;i++)
+  for(j=0;j<ny;j++) v(i,j) = Error(i,j);
+return;
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+void Histo2D::PutValue(Matrix &v, int ierr)
+//
+//	Remplissage du contenu de l'histo avec les valeurs d'un tableau.
+//--
+{
+int i,j;
+if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
+for(i=0;i<nx;i++) for(j=0;j<ny;j++) {
+  (*this)(i,j) = v(i,j);
+  if(err2 && ierr) Error2(i,j) = fabs(v(i,j));
+}
+return;
+}
+
+//++
+void Histo2D::PutValueAdd(Matrix &v, int ierr)
+//
+//	Addition du contenu de l'histo avec les valeurs d'un tableau.
+//--
+{
+int i,j;
+if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
+for(i=0;i<nx;i++) for(j=0;j<ny;j++) {
+  (*this)(i,j) += v(i,j);
+  if(err2 && ierr) Error2(i,j) += fabs(v(i,j));
+}
+return;
+}
+
+//++
+void Histo2D::PutError2(Matrix &v)
+//
+//	Remplissage des erreurs au carre de l'histo
+//	avec les valeurs d'un tableau.
+//--
+{
+int i,j;
+if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
+if(!err2) Errors();
+for(i=0;i<nx;i++) for(j=0;j<ny;j++) Error2(i,j) = v(i,j);
+return;
+}
+
+//++
+void Histo2D::PutError2Add(Matrix &v)
+//
+//	Addition des erreurs au carre de l'histo
+//	avec les valeurs d'un tableau.
+//--
+{
+int i,j;
+if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
+if(!err2) Errors();
+for(i=0;i<nx;i++) for(j=0;j<ny;j++)
+          if(v(i,j)>0.) Error2(i,j) += v(i,j);
+return;
+}
+
+//++
+void Histo2D::PutError(Matrix &v)
+//
+//	Remplissage des erreurs de l'histo avec les valeurs d'un tableau.
+//--
+{
+int i,j;
+if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
+if(!err2) Errors();
+for(i=0;i<nx;i++) for(j=0;j<ny;j++)
+  if(v(i,j)>0.) Error2(i,j)=v(i,j)*v(i,j); else Error2(i,j)= -v(i,j)*v(i,j);
+return;
+}
+
+///////////////////////////////////////////////////////////////////
+/********* Methode *********/
+//++
+void Histo2D::Add(float x, float y, float w)
+//
+//	Addition du contenu de l'histo pour x,y poids w.
+//--
+{
+list<bande_slice>::iterator it;
+int i,j;
+FindBin(x,y,i,j);
+
+if( hprojx != NULL ) hprojx->Add(x,w);
+if( hprojy != NULL ) hprojy->Add(y,w);
+
+if(lbandx.size()>0)
+  for( it = lbandx.begin(); it != lbandx.end(); it++)
+    if( (*it).min <= y && y < (*it).max ) (*it).H->Add(x,w);
+
+if(lbandy.size()>0)
+  for( it = lbandy.begin(); it != lbandy.end(); it++)
+    if( (*it).min <= x && x < (*it).max ) (*it).H->Add(y,w);
+
+if(lslix.size()>0)
+  for( it = lslix.begin(); it != lslix.end(); it++)
+    if( (*it).min <= y && y < (*it).max ) (*it).H->Add(x,w);
+
+if(lsliy.size()>0)
+  for( it = lsliy.begin(); it != lsliy.end(); it++)
+    if( (*it).min <= x && x < (*it).max ) (*it).H->Add(y,w);
+
+if( i<0 || i>=nx || j<0 || j>=ny ) {
+  if(i<0) i=0; else if(i>=nx) i=2; else i=1;
+  if(j<0) j=0; else if(j>=ny) j=2; else j=1;
+  over[i][j] += w;
+  over[1][1] += w;
+  return;
+}
+
+data[j*nx+i] += w;
+if(err2!=NULL) err2[j*nx+i] += w*w;
+nHist += w;
+nEntries++;
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+void Histo2D::IJMax(int& imax,int& jmax,int il,int ih,int jl,int jh)
+//
+//	Recherche du bin du maximum dans le pave [il,ih][jl,jh].
+//--
+{
+if( il > ih ) { il = 0; ih = nx-1; }
+if( jl > jh ) { jl = 0; jh = ny-1; }
+if( il < 0 ) il = 0;
+if( jl < 0 ) jl = 0;
+if( ih >= nx ) ih = nx-1;
+if( jh >= ny ) jh = ny-1;
+
+imax = jmax = 0;
+if(nxy==1) return;
+
+float mx=(*this)(il,jl);
+for (int i=il; i<=ih; i++)
+   for (int j=jl; j<=jh; j++)
+      if ((*this)(i,j)>mx) {imax = i; jmax = j; mx=(*this)(i,j);}
+}
+
+//++
+void Histo2D::IJMin(int& imax,int& jmax,int il,int ih,int jl,int jh)
+//
+//	Recherche du bin du minimum dans le pave [il,ih][jl,jh].
+//--
+{
+if( il > ih ) { il = 0; ih = nx-1; }
+if( jl > jh ) { jl = 0; jh = ny-1; }
+if( il < 0 ) il = 0;
+if( jl < 0 ) jl = 0;
+if( ih >= nx ) ih = nx-1;
+if( jh >= ny ) jh = ny-1;
+
+imax = jmax = 0;
+if(nxy==1) return;
+
+float mx=(*this)(il,jl);
+for (int i=il; i<=ih; i++)
+   for (int j=jl; j<=jh; j++)
+      if ((*this)(i,j)<mx) {imax = i; jmax = j; mx=(*this)(i,j);}
+}
+
+
+//++
+float Histo2D::VMax(int il,int ih,int jl,int jh) const
+//
+//	Recherche du maximum dans le pave [il,ih][jl,jh].
+//--
+{
+if( il > ih ) { il = 0; ih = nx-1; }
+if( jl > jh ) { jl = 0; jh = ny-1; }
+if( il < 0 ) il = 0;
+if( jl < 0 ) jl = 0;
+if( ih >= nx ) ih = nx-1;
+if( jh >= ny ) jh = ny-1;
+
+float mx=(*this)(il,jl);
+if(nxy==1) return mx;
+for (int i=il; i<=ih; i++)
+   for (int j=jl; j<=jh; j++)
+      if ((*this)(i,j)>mx) mx=(*this)(i,j);
+return mx;
+}
+
+//++
+float Histo2D::VMin(int il,int ih,int jl,int jh) const
+//
+//	Recherche du minimum dans le pave [il,ih][jl,jh].
+//--
+{
+if( il > ih ) { il = 0; ih = nx-1; }
+if( jl > jh ) { jl = 0; jh = ny-1; }
+if( il < 0 ) il = 0;
+if( jl < 0 ) jl = 0;
+if( ih >= nx ) ih = nx-1;
+if( jh >= ny ) jh = ny-1;
+
+float mx=(*this)(il,jl);
+if(nxy==1) return mx;
+for (int i=il; i<=ih; i++)
+   for (int j=jl; j<=jh; j++)
+      if ((*this)(i,j)<mx) mx=(*this)(i,j);
+return mx;
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+float Histo2D::NOver(int i,int j) const
+//
+//	Renvoie les under.overflow dans les 8 quadrants.
+//|  over[3][3]:        20 | 21 | 22
+//|                        |    |
+//|                    --------------
+//|                        |    |
+//|                     10 | 11 | 12        11 = all overflow+underflow
+//|                        |    |
+//|                    --------------
+//|                        |    |
+//|                     00 | 01 | 02
+//--
+{
+if( i < 0 || i>=3 || j < 0 || j>=3 ) return over[1][1];
+return over[i][j];
+}
+
+
+///////////////////////////////////////////////////////////////////
+//++
+int Histo2D::BinNonNul() const
+//
+//	Retourne le nombre de bins non-nuls.
+//--
+{
+int non=0;
+for (int i=0;i<nxy;i++) if( data[i] != 0. ) non++;
+return non;
+}
+
+//++
+int Histo2D::ErrNonNul() const
+//
+//	Retourne le nombre de bins avec erreurs non-nulles.
+//--
+{
+if(err2==NULL) return -1;
+int non=0;
+for (int i=0;i<nxy;i++) if( err2[i] != 0. ) non++;
+return non;
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+int Histo2D::EstimeMax(float& xm,float& ym,int SzPav
+                      ,int il,int ih,int jl,int jh)
+//
+//	Idem EstimeMax(int...) mais retourne x,y.
+//--
+{
+int im,jm;
+IJMax(im,jm,il,ih,jl,jh);
+return EstimeMax(im,jm,xm,ym,SzPav);
+}
+
+//++
+int Histo2D::EstimeMax(int im,int jm,float& xm,float& ym,int SzPav)
+//
+//	Determine les abscisses et ordonnees du maximum donne par im,jm
+//	en moyennant dans un pave SzPav x SzPav autour du maximum.
+//|  Return:
+//|    0 = si fit maximum reussi avec SzPav pixels
+//|    1 = si fit maximum reussi avec moins que SzPav pixels
+//|                                dans au moins 1 direction
+//|    2 = si fit maximum echoue et renvoit BinCenter()
+//|   -1 = si echec: SzPav <= 0 ou im,jm hors limites
+//--
+{
+xm = ym = 0;
+if( SzPav <= 0 ) return -1;
+if( im < 0 || im >= nx ) return -1;
+if( jm < 0 || jm >= ny ) return -1;
+
+if( SzPav%2 == 0 ) SzPav++;
+SzPav = (SzPav-1)/2;
+
+int rc = 0;
+double dxm = 0, dym = 0, wx = 0;
+for(int i=im-SzPav;i<=im+SzPav;i++) {
+  if( i<0 || i>= nx ) {rc=1; continue;}
+  for(int j=jm-SzPav;j<=jm+SzPav;j++) {
+    if( j<0 || j>= ny ) {rc=1; continue;}
+    float x,y;
+    BinCenter(i,j,x,y);
+    dxm += x * (*this)(i,j);
+    dym += y * (*this)(i,j);
+    wx  += (*this)(i,j);
+  }
+}
+
+if( wx > 0. ) {
+  xm = dxm/wx;
+  ym = dym/wx;
+  return rc;
+} else {
+  BinCenter(im,jm,xm,ym);
+  return 2;
+}
+
+}
+
+//++
+int Histo2D::FindMax(int& im,int& jm,int SzPav,float Dz
+                    ,int il,int ih,int jl,int jh)
+//
+//	Pour trouver le maximum de l'histogramme en tenant compte
+//	des fluctuations.
+//| Methode:
+//| 1-/ On recherche le bin maximum MAX de l'histogramme
+//| 2-/ On considere que tous les pixels compris entre [MAX-Dz,MAX]
+//|     peuvent etre des pixels maxima.
+//| 3-/ On identifie le bin maximum en choissisant le pixel du 2-/
+//|     tel que la somme des pixels dans un pave SzPav x SzPav soit maximale.
+//| INPUT:
+//|  SzPav = taille du pave pour departager
+//|  Dz    = tolerance pour identifier tous les pixels "maximum"
+//| OUTPUT:
+//|  im,jm = pixel maximum trouve
+//| RETURN:
+//|   <0 =  Echec
+//|   >0 =  nombre de pixels possibles pour le maximum
+//--
+{
+if( il > ih ) { il = 0; ih = nx-1; }
+if( jl > jh ) { jl = 0; jh = ny-1; }
+if( il < 0 ) il = 0;
+if( jl < 0 ) jl = 0;
+if( ih >= nx ) ih = nx-1;
+if( jh >= ny ) jh = ny-1;
+if( SzPav < 0 ) SzPav = 0;
+  else { if( SzPav%2 == 0 ) SzPav++; SzPav = (SzPav-1)/2;}
+if( Dz < 0 ) Dz = 0.;
+float max = VMax(il,ih,jl,jh) - Dz;
+int nmax = 0;
+float sumx = -MAXFLOAT;
+for(int i=il;i<=ih;i++) for(int j=jl;j<=jh;j++) {
+  if( (*this)(i,j) < max) continue;
+  nmax++;
+  float sum = 0.;
+  for(int ii=i-SzPav;ii<=i+SzPav;ii++) {
+    if( ii<0 || ii >= nx ) continue;
+    for(int jj=j-SzPav;jj<=j+SzPav;jj++) {
+      if( jj<0 || jj >= ny ) continue;
+      sum += (*this)(ii,jj);
+    }
+  }
+  if( sum > sumx ) { im = i; jm = j; sumx = sum;}
+}
+if( nmax <= 0 ) { IJMax(im,jm,il,ih,jl,jh); return 1;}
+return nmax;
+}
+
+//////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////
+//++
+int  Histo2D::Fit(GeneralFit& gfit,unsigned short typ_err)
+//
+//	Fit de l'histogramme par ``gfit''.
+//| typ_err = 0 :
+//|    - erreur attachee au bin si elle existe
+//|    - sinon 1
+//| typ_err = 1 :
+//|    - erreur attachee au bin si elle existe
+//|    - sinon max( sqrt(abs(bin) ,1 )
+//| typ_err = 2 :
+//|    - erreur forcee a 1
+//| typ_err = 3 :
+//|    - erreur forcee a max( sqrt(abs(bin) ,1 )
+//| typ_err = 4 :
+//|    - erreur forcee a 1, nulle si bin a zero.
+//| typ_err = 5 :
+//|    - erreur forcee a max( sqrt(abs(bin) ,1 ),
+//|      nulle si bin a zero.
+//--
+{
+if(NBinX()*NBinY()<=0) return -1000;
+if(typ_err>5) typ_err=0;
+
+GeneralFitData mydata(2,NBinX()*NBinY());
+
+for(int i=0;i<NBinX();i++) for(int j=0;j<NBinY();j++) {
+  float x,y;
+  BinCenter(i,j,x,y);
+  double f = (double) (*this)(i,j);
+  double saf = sqrt(fabs(f)); if(saf<1.) saf=1.;
+  double e;
+  if(typ_err==0)      {if(HasErrors()) e=Error(i,j); else e=1.;}
+  else if(typ_err==1) {if(HasErrors()) e=Error(i,j); else e=saf;}
+  else if(typ_err==2) e=1.;
+  else if(typ_err==3) e=saf;
+  else if(typ_err==4) e=(f==0.)?0.:1.;
+  else if(typ_err==5) e=(f==0.)?0.:saf;
+  mydata.AddData2((double) x,(double) y,f,e);
+}
+
+gfit.SetData(&mydata);
+
+return gfit.Fit();
+}
+
+//++
+Histo2D* Histo2D::FitResidus(GeneralFit& gfit)
+//
+//	Retourne une classe contenant les residus du fit ``gfit''.
+//--
+{
+if(NBinX()<=0 || NBinY()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+Histo2D* h2 = new Histo2D(*this);
+for(int i=0;i<NBinX();i++) for(int j=0;j<NBinY();j++) {
+  float xc,yc;
+  BinCenter(i,j,xc,yc);
+  double x[2] = {(double)xc,(double)yc};
+  (*h2)(i,j) -= (float) f->Value(x,par.Data());
+}
+return h2;
+}
+
+//++
+Histo2D* Histo2D::FitFunction(GeneralFit& gfit)
+//
+//	Retourne une classe contenant la fonction du fit ``gfit''.
+//--
+{
+if(NBinX()<=0 || NBinY()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+Histo2D* h2 = new Histo2D(*this);
+for(int i=0;i<NBinX();i++) for(int j=0;j<NBinY();j++) {
+  float xc,yc;
+  BinCenter(i,j,xc,yc);
+  double x[2] = {(double)xc,(double)yc};
+  (*h2)(i,j) = (float) f->Value(x,par.Data());
+}
+return h2;
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+void Histo2D::PrintStatus()
+//
+//	Impression des informations sur l'histogramme.
+//--
+{
+printf("~Histo::Print    nHist=%g nEntries=%d\n",nHist,nEntries);
+printf("over: [ %g %g %g // %g %g %g  // %g %g %g ]\n"
+      ,over[2][0],over[2][1],over[2][2]
+      ,over[1][0],over[1][1],over[1][2]
+      ,over[0][0],over[0][1],over[0][2]);
+printf("  nx=%d xmin=%g xmax=%g binx=%g  ",nx,xmin,xmax,wbinx);
+printf("  ny=%d ymin=%g ymax=%g biny=%g\n",ny,ymin,ymax,wbiny);
+}
+
+///////////////////////////////////////////////////////////////////
+//++
+void Histo2D::Print(float min,float max
+                   ,int il,int ih,int jl,int jh)
+//
+//	Impression de l'histogramme sur stdout entre [il,ih] et [jl,jh].
+//--
+{
+int ns = 35;
+// numero d'index:  00000000001111111111222222222233333
+//                  01234567890123456789012345678901234
+// valeur entiere:  00000000001111111111222222222233333
+//                  12345678901234567890123456789012345
+const char *s =    "+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+if( il > ih ) { il = 0; ih = nx-1; }
+if( jl > jh ) { jl = 0; jh = ny-1; }
+if( il < 0 ) il = 0;
+if( jl < 0 ) jl = 0;
+if( ih >= nx ) ih = nx-1;
+if( jh >= ny ) jh = ny-1;
+
+PrintStatus();
+
+if( il != 0 || ih != nx-1 || jl != 0 || jh != ny-1 ) {
+  float xl,xh,yl,yh;
+  BinLowEdge(il,jl,xl,yl);
+  BinHighEdge(ih,jh,xh,yh);
+  printf("  impression");
+  printf("  en X: %d=[%d,%d] xmin=%g xmax=%g  "
+        ,ih-il+1,il,ih,xl,xh);
+  printf("  en Y: %d=[%d,%d] ymin=%g ymax=%g\n"
+        ,jh-jl+1,jl,jh,yl,yh);
+}
+
+if(min >= max) { if(min != 0.) min = VMin(il,ih,jl,jh); else min=0.;
+                 max = VMax(il,ih,jl,jh); }
+if(min>max) return;
+if(min==max) {min -= 1.; max += 1.;}
+printf("   min=%g max=%g\n",min,max);
+
+// imprime numero de bin en colonne
+printf("\n");
+if( nx-1 >= 100 ) {
+  printf("     ");
+  for(int i=il;i<=ih;i++) printf("%1d",(int) (i%1000)/100);
+  printf("\n");
+}
+if( nx-1 >= 10 ) {
+  printf("     ");
+  for(int i=il;i<=ih;i++) printf("%1d",(int) (i%100)/10);
+  printf("\n");
+}
+printf("     ");
+for(int i=il;i<=ih;i++) printf("%1d",i%10);
+printf("\n");
+printf("     "); {for(int i=il;i<=ih;i++) printf("-"); printf("\n");}
+
+// imprime histogramme
+for(int j=jh;j>=jl;j--) {
+  printf("%3d: ",j);
+  for(int i=il;i<=ih;i++) {
+    int h;
+    if( 1<=max-min && max-min<=35 ) h = (int)( (*this)(i,j) - min ) - 1;
+      else h = (int)( ((*this)(i,j)-min)/(max-min) * ns ) - 1;
+    char c;
+    if(h<0 && (*this)(i,j)>min) c = '.';
+      else if(h<0) c = ' ';
+        else if(h>=ns) c = '*';
+          else c = s[h];
+    printf("%c",c);
+  }
+  printf("\n");
+}
+
+// imprime numero de bin en colonne
+printf("     "); {for(int i=il;i<=ih;i++) printf("-"); printf("\n");}
+if( nx-1 >= 100 ) {
+  printf("     ");
+  for(int i=il;i<=ih;i++) printf("%1d",(int) (i%1000)/100);
+  printf("\n");
+}
+if( nx-1 >= 10 ) {
+  printf("     ");
+  for(int i=il;i<=ih;i++) printf("%1d",(int) (i%100)/10);
+  printf("\n");
+}
+printf("     ");
+{for(int i=il;i<=ih;i++) printf("%1d",i%10);}
+printf("\n");
+
+}
+
+// Rappel des inline functions pour commentaires
+//++
+// inline float   XMin()
+//	Retourne l'abscisse minimum.
+//--
+//++
+// inline float   XMax()
+//	Retourne l'abscisse maximum.
+//--
+//++
+// inline float   YMin()
+//	Retourne l'ordonnee minimum.
+//--
+//++
+// inline float   YMax()
+//	Retourne l'ordonnee maximum.
+//--
+//++
+// inline int     NBinX()
+//	Retourne le nombre de bins selon X.
+//--
+//++
+// inline int     NBinY()
+//	Retourne le nombre de bins selon Y.
+//--
+//++
+// inline float   WBinX()
+//	Retourne la largeur du bin selon X.
+//--
+//++
+// inline float   WBinY()
+//	Retourne la largeur du bin selon Y.
+//--
+//++
+// inline float*  Bins() const
+//	Retourne le pointeur sur le tableaux des contenus.
+//--
+//++
+// inline float   operator()(int i,int j) const
+//	Retourne le contenu du bin i,j.
+//--
+//++
+// inline float&  operator()(int i,int j)
+//	Remplit le contenu du bin i,j.
+//--
+//++
+// inline float   Error(int i,int j)  const
+//	Retourne l'erreur du bin i,j.
+//--
+//++
+// inline double  Error2(int i,int j) const
+//	Retourne l'erreur au carre du bin i,j.
+//--
+//++
+// inline double& Error2(int i,int j)
+//	Remplit l'erreur au carre du bin i,j.
+//--
+//++
+// inline float   NData() const
+//	Retourne la somme ponderee.
+//--
+//++
+// inline int     NEntries() const
+//	Retourne le nombre d'entrees.
+//--
+//++
+// inline void BinLowEdge(int i,int j,float& x,float& y)
+//	Retourne l'abscisse et l'ordonnee du coin inferieur du bin i,j.
+//--
+//++
+// inline void BinCenter(int i,int j,float& x,float& y)
+//	Retourne l'abscisse et l'ordonnee du centre du bin i,j.
+//--
+//++
+// inline void BinHighEdge(int i,int j,float& x,float& y)
+//	Retourne l'abscisse et l'ordonnee du coin superieur du bin i,j.
+//--
+//++
+// inline void FindBin(float x,float y,int& i,int& j)
+//	Retourne les numeros du bin contenant l'abscisse et l'ordonnee x,y.
+//--
+
+///////////////////////////////////////////////////////////////////
+//++
+// Titre	Methodes pour gerer les projections
+//--
+
+//++
+void Histo2D::SetProjX()
+//
+//	Pour creer la projection X.
+//--
+{
+if( hprojx != NULL ) DelProjX();
+hprojx = new Histo(xmin,xmax,nx);
+if( err2 != NULL && hprojx != NULL ) hprojx->Errors();
+}
+
+//++
+void Histo2D::SetProjY()
+//
+//	Pour creer la projection Y.
+//--
+{
+if( hprojy != NULL ) DelProjY();
+hprojy = new Histo(ymin,ymax,ny);
+if( err2 != NULL && hprojy != NULL  ) hprojy->Errors();
+}
+
+//++
+void Histo2D::SetProj()
+//
+//	Pour creer les projections X et Y.
+//--
+{
+SetProjX();
+SetProjY();
+}
+
+//++
+void Histo2D::ShowProj()
+//
+//	Informations sur les projections.
+//--
+{
+if( hprojx != NULL ) cout << ">>>> Projection X set : "<< hprojx <<endl;
+  else cout << ">>>> NO Projection X set"<<endl;
+if( hprojy != NULL ) cout << ">>>> Projection Y set : "<< hprojy <<endl;
+  else cout << ">>>> NO Projection Y set"<<endl;
+}
+
+//++
+void Histo2D::DelProjX()
+//
+//	Destruction de l'histogramme de la projection selon X.
+//--
+{
+if( hprojx == NULL ) return;
+delete hprojx;
+hprojx = NULL;
+}
+
+//++
+void Histo2D::DelProjY()
+//
+//	Destruction de l'histogramme de la projection selon X.
+//--
+{
+if( hprojy == NULL ) return;
+delete hprojy;
+hprojy = NULL;
+}
+
+//++
+void Histo2D::DelProj()
+//
+//	Destruction des histogrammes des projections selon X et Y.
+//--
+{
+DelProjX();
+DelProjY();
+}
+
+//++
+void Histo2D::ZeroProjX()
+//
+//	Remise a zero de la projection selon X.
+//--
+{
+if( hprojx == NULL ) return;
+hprojx->Zero();
+}
+
+//++
+void Histo2D::ZeroProjY()
+//
+//	Remise a zero de la projection selon Y.
+//--
+{
+if( hprojy == NULL ) return;
+hprojy->Zero();
+}
+
+//++
+void Histo2D::ZeroProj()
+//
+//	Remise a zero des projections selon X et Y.
+//--
+{
+ZeroProjX();
+ZeroProjY();
+}
+
+// Rappel des inline functions pour commentaires
+//++
+// inline Histo*  HProjX()
+//	Retourne le pointeur sur l'histo 1D de la projection selon X.
+//--
+//++
+// inline Histo*  HProjY()
+//	Retourne le pointeur sur l'histo 1D de la projection selon Y.
+//--
+
+///////////////////////////////////////////////////////////////////
+//++
+// Titre	Methodes pour gerer les bandes
+//--
+
+//++
+int Histo2D::SetBandX(float ybmin,float ybmax)
+//
+//	Pour creer une bande en X entre ybmin et ybmax.
+//--
+{
+b_s.num = lbandx.size();
+b_s.min = ybmin;
+b_s.max = ybmax;
+b_s.H = new Histo(xmin,xmax,nx);
+lbandx.push_back(b_s);
+b_s.H = NULL;
+return lbandx.size()-1;
+}
+
+//++
+int Histo2D::SetBandY(float xbmin,float xbmax)
+//
+//	Pour creer une bande en Y entre xbmin et xbmax.
+//--
+{
+b_s.num = lbandy.size();
+b_s.min = xbmin;
+b_s.max = xbmax;
+b_s.H = new Histo(ymin,ymax,ny);
+lbandy.push_back(b_s);
+b_s.H = NULL;
+return lbandy.size()-1;
+}
+
+//++
+void Histo2D::DelBandX()
+//
+//	Destruction des histogrammes des bandes selon X.
+//--
+{
+if( lbandx.size() <= 0 ) return;
+for(list<bande_slice>::iterator i = lbandx.begin(); i != lbandx.end(); i++)
+       if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
+lbandx.erase(lbandx.begin(),lbandx.end());
+}
+
+//++
+void Histo2D::DelBandY()
+//
+//	Destruction des histogrammes des bandes selon Y.
+//--
+{
+if( lbandy.size() <= 0 ) return;
+for(list<bande_slice>::iterator i = lbandy.begin(); i != lbandy.end(); i++)
+       if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
+lbandy.erase(lbandy.begin(),lbandy.end());
+}
+
+//++
+void Histo2D::ZeroBandX()
+//
+//	Remise a zero des bandes selon X.
+//--
+{
+if( lbandx.size() <= 0 ) return;
+list<bande_slice>::iterator i;
+for(i = lbandx.begin(); i != lbandx.end(); i++)
+              (*i).H->Zero();
+}
+
+//++
+void Histo2D::ZeroBandY()
+//
+//	Remise a zero des bandes selon Y.
+//--
+{
+if( lbandy.size() <= 0 ) return;
+list<bande_slice>::iterator i;
+for(i = lbandy.begin(); i != lbandy.end(); i++)
+              (*i).H->Zero();
+}
+
+//++
+Histo* Histo2D::HBandX(int n) const
+//
+//	Retourne un pointeur sur la bande numero `n' selon X.
+//--
+{
+if( lbandx.size() <= 0 || n < 0 || n >= (int) lbandx.size() ) return NULL;
+for(list<bande_slice>::const_iterator i = lbandx.begin(); i != lbandx.end(); i++)
+              if( (*i).num == n ) return (*i).H;
+return NULL;
+}
+
+//++
+Histo* Histo2D::HBandY(int n) const
+//
+//	Retourne un pointeur sur la bande numero `n' selon Y.
+//--
+{
+if( lbandy.size() <= 0 || n < 0 || n >= (int) lbandy.size() ) return NULL;
+for(list<bande_slice>::const_iterator i = lbandy.begin(); i != lbandy.end(); i++)
+              if( (*i).num == n ) return (*i).H;
+return NULL;
+}
+
+//++
+void Histo2D::GetBandX(int n,float& ybmin,float& ybmax) const
+//
+//	Retourne les limites de la bande numero `n' selon X.
+//--
+{
+ybmin = 0.; ybmax = 0.;
+if( lbandx.size() <= 0 || n < 0 || n >= (int) lbandx.size() ) return;
+for(list<bande_slice>::const_iterator i = lbandx.begin(); i != lbandx.end(); i++)
+  if( (*i).num == n ) { ybmin = (*i).min; ybmax = (*i).max; return;}
+return;
+}
+
+//++
+void Histo2D::GetBandY(int n,float& xbmin,float& xbmax) const
+//
+//	Retourne les limites de la bande numero `n' selon Y.
+//--
+{
+xbmin = 0.; xbmax = 0.;
+if( lbandy.size() <= 0 || n < 0 || n >= (int) lbandy.size() ) return;
+for(list<bande_slice>::const_iterator i = lbandy.begin(); i != lbandy.end(); i++)
+  if( (*i).num == n ) { xbmin = (*i).min; xbmax = (*i).max; return;}
+return;
+}
+
+//++
+void Histo2D::ShowBand(int lp)
+//
+//	Informations sur les bandes.
+//--
+{
+  cout << ">>>> Nombre de bande X : " << lbandx.size() << endl;
+if( lp>0 && lbandx.size()>0 ) {
+  list<bande_slice>::iterator i;
+  for(i = lbandx.begin(); i != lbandx.end(); i++) {
+    cout<<"  "<<(*i).num<<" de ymin="<<(*i).min<<" a ymax="<<(*i).max;
+    if(lp>1) cout << "   H=" << (*i).H;
+    cout << endl;
+  }
+}
+
+cout << ">>>> Nombre de bande Y : " << lbandy.size() << endl;
+if( lp>0 && lbandy.size()>0 ) {
+  list<bande_slice>::iterator i;
+  for(i = lbandy.begin(); i != lbandy.end(); i++) {
+    cout<<"  "<<(*i).num<<" de xmin="<<(*i).min<<" a xmax="<<(*i).max;
+    if(lp>1) cout << "   H=" << (*i).H;
+    cout << endl;
+  }
+}
+}
+
+// Rappel des inline functions pour commentaires
+//++
+// inline int     NBandX()
+//	Retourne le nombre de bandes selon X
+//--
+//++
+// inline int     NBandY()
+//	Retourne le nombre de bandes selon Y
+//--
+
+///////////////////////////////////////////////////////////////////
+//++
+// Titre	Methodes pour gerer les bandes equidistantes
+//--
+
+//++
+int Histo2D::SetSliX(int nsli)
+//
+//	Pour creer `nsli' bandes equidistantes selon X.
+//--
+{
+if( nsli <= 0 ) return -1;
+if( nsli >  ny ) nsli = ny;
+if( lslix.size() > 0 ) DelSliX();
+float w = (ymax-ymin)/nsli;
+
+for(int i=0; i<nsli; i++ ) {
+  b_s.num = i;
+  b_s.min = ymin + i*w;
+  b_s.max = b_s.min + w;
+  b_s.H = new Histo(xmin,xmax,nx);
+  lslix.push_back(b_s);
+  b_s.H = NULL;
+}
+return (int) lslix.size();
+}
+
+//++
+int Histo2D::SetSliY(int nsli)
+//
+//	Pour creer `nsli' bandes equidistantes selon Y.
+//--
+{
+if( nsli <= 0 ) return -1;
+if( nsli >  nx ) nsli = nx;
+if( lsliy.size() > 0 ) DelSliY();
+float w = (xmax-xmin)/nsli;
+
+for(int i=0; i<nsli; i++ ) {
+  b_s.num = i;
+  b_s.min = xmin + i*w;
+  b_s.max = b_s.min + w;
+  b_s.H = new Histo(ymin,ymax,ny);
+  lsliy.push_back(b_s);
+  b_s.H = NULL;
+}
+return (int) lsliy.size();
+}
+
+//++
+void Histo2D::DelSliX()
+//
+//	Destruction des bandes equidistantes selon X.
+//--
+{
+if( lslix.size() <= 0 ) return;
+for(list<bande_slice>::iterator i = lslix.begin(); i != lslix.end(); i++)
+       if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
+lslix.erase(lslix.begin(),lslix.end());
+}
+
+//++
+void Histo2D::DelSliY()
+//
+//	Destruction des bandes equidistantes selon Y.
+//--
+{
+if( lsliy.size() <= 0 ) return;
+for(list<bande_slice>::iterator i = lsliy.begin(); i != lsliy.end(); i++)
+       if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
+lsliy.erase(lsliy.begin(),lsliy.end());
+}
+
+//++
+void Histo2D::ZeroSliX()
+//
+//	Remise a zero des bandes equidistantes selon X.
+//--
+{
+if( lslix.size() <= 0 ) return;
+list<bande_slice>::iterator i;
+for(i = lslix.begin(); i != lslix.end(); i++)
+              (*i).H->Zero();
+}
+
+//++
+void Histo2D::ZeroSliY()
+//
+//	Remise a zero des bandes equidistantes selon Y.
+//--
+{
+if( lsliy.size() <= 0 ) return;
+list<bande_slice>::iterator i;
+for(i = lsliy.begin(); i != lsliy.end(); i++)
+              (*i).H->Zero();
+}
+
+//++
+Histo* Histo2D::HSliX(int n) const
+//
+//	Retourne un pointeur sur la bande equidistante numero `n'
+//	selon X.
+//--
+{
+if( lslix.size() <= 0 || n < 0 || n >= (int) lslix.size() ) return NULL;
+for(list<bande_slice>::const_iterator i = lslix.begin(); i != lslix.end(); i++)
+              if( (*i).num == n ) return (*i).H;
+return NULL;
+}
+
+//++
+Histo* Histo2D::HSliY(int n) const
+//
+//	Retourne un pointeur sur la bande equidistante numero `n'
+//	selon Y.
+//--
+{
+if( lsliy.size() <= 0 || n < 0 || n >= (int) lsliy.size() ) return NULL;
+for(list<bande_slice>::const_iterator i = lsliy.begin(); i != lsliy.end(); i++)
+              if( (*i).num == n ) return (*i).H;
+return NULL;
+}
+
+//++
+void Histo2D::ShowSli(int lp)
+//
+//	Informations sur les bandes equidistantes.
+//--
+{
+list<bande_slice>::iterator i;
+cout << ">>>> Nombre de slice X : " << lslix.size() << endl;
+if( lp>0 && lslix.size() > 0 )
+  for(i = lslix.begin(); i != lslix.end(); i++) {
+    cout<<"  "<<(*i).num<<" de ymin="<<(*i).min<<" a ymax="<<(*i).max;
+    if(lp>1) cout << "   H=" << (*i).H;
+    cout << endl;
+  }
+
+cout << ">>>> Nombre de slice Y : " << lsliy.size() << endl;
+if( lp>0 && lsliy.size()>0 )
+  for(i = lsliy.begin(); i != lsliy.end(); i++) {
+    cout<<"  "<<(*i).num<<" de xmin="<<(*i).min<<" a xmax="<<(*i).max;
+    if(lp>1) cout << "   H=" << (*i).H;
+    cout << endl;
+  }
+}
+
+// Rappel des inline functions pour commentaires
+//++
+// inline int     NSliX()
+//	Retourne le nombre de slices selon X
+//--
+//++
+// inline int     NSliY()
+//	Retourne le nombre de slices selon Y
+//--
+
+
+///////////////////////////////////////////////////////////////////
+//++
+// Titre	Methodes pour ecriture ppersist
+//--
+
+//++
+void  Histo2D::WriteSelf(POutPersist& s)  const
+//
+//	Ecriture fichier de type ppersist.
+//--
+{
+char strg[256];
+int j;
+float min,max;
+Histo* h;
+
+// Que faut-il ecrire?
+int_4 errok = (err2) ? 1 : 0;
+int_4 projx = (hprojx) ? 1 : 0;
+int_4 projy = (hprojy) ? 1 : 0;
+int_4 nslix = NSliX();
+int_4 nsliy = NSliY();
+int_4 nbanx = NBandX();
+int_4 nbany = NBandY();
+
+// Ecriture entete pour identifier facilement
+sprintf(strg,"nx=%d  ny=%d  nxy=%d errok=%1d",nx,ny,nxy,errok);
+s.PutLine(strg);
+sprintf(strg,"nHist=%g nEntries=%d",nHist,nEntries);
+s.PutLine(strg);
+sprintf(strg,"wbinx=%g wbiny=%g",wbinx,wbiny);
+s.PutLine(strg);
+sprintf(strg,"xmin=%g xmax=%g ymin=%g ymax=%g",xmin,xmax,ymin,ymax);
+s.PutLine(strg);
+sprintf(strg,"projx/y=%d %d nbandx/y=%d %d nbslix/y=%d %d"
+       ,projx,projy,nbanx,nbany,nslix,nsliy);
+s.PutLine(strg);
+sprintf(strg,"over %g %g %g %g %g %g %g %g %g"
+       ,over[0][0],over[0][1],over[0][2]
+       ,over[1][0],over[1][1],over[1][2]
+       ,over[2][0],over[2][1],over[2][2]);
+s.PutLine(strg);
+
+// Ecriture variables de definitions
+s.PutI4(nx);
+s.PutI4(ny);
+s.PutI4(nxy);
+s.PutI4(errok);
+s.PutI4(nEntries);
+s.PutR8(nHist);
+
+s.PutR4(xmin);
+s.PutR4(xmax);
+s.PutR4(ymin);
+s.PutR4(ymax);
+s.PutR4(wbinx);
+s.PutR4(wbiny);
+
+s.PutR4s(&over[0][0],9);
+
+s.PutI4(projx);
+s.PutI4(projy);
+s.PutI4(nslix);
+s.PutI4(nsliy);
+s.PutI4(nbanx);
+s.PutI4(nbany);
+
+// Ecriture histo2D
+sprintf(strg,"Histo2D: Tableau des donnees %d = %d * %d",nxy,nx,ny);
+s.PutLine(strg);
+for(j=0;j<ny;j++) s.PutR4s(data+j*nx,nx);
+
+
+// Ecriture erreurs
+if(errok) {
+  sprintf(strg,"Histo2D: Tableau des erreurs %d = %d * %d",nxy,nx,ny);
+  s.PutLine(strg);
+  for(j=0;j<ny;j++) s.PutR8s(err2+j*nx,nx);
+}
+
+// Ecriture des projections
+if(projx) {
+  sprintf(strg,"Histo2D: Projection X");
+  s.PutLine(strg);
+  hprojx->Write(s);
+}
+if(projy) {
+  sprintf(strg,"Histo2D: Projection Y");
+  s.PutLine(strg);
+  hprojy->Write(s);
+}
+
+// Ecriture des slices
+if(nslix>0) {
+  sprintf(strg,"Histo2D: Slices X %d",nslix);
+  s.PutLine(strg);
+  for(j=0;j<nslix;j++) {
+    h = HSliX(j);
+    h->Write(s);
+  }
+}
+if(nsliy>0) {
+  sprintf(strg,"Histo2D: Slices Y %d",nsliy);
+  s.PutLine(strg);
+  for(j=0;j<nsliy;j++) {
+    h = HSliY(j);
+    h->Write(s);
+  }
+}
+
+// Ecriture des bandes
+if( nbanx>0 ) {
+  sprintf(strg,"Histo2D: Bandes X %d",nbanx);
+  s.PutLine(strg);
+  list<bande_slice>::const_iterator it;
+  for(it = lbandx.begin(); it != lbandx.end(); it++) {
+    min = (*it).min;
+    max = (*it).max;
+    s.PutR4(min);
+    s.PutR4(max);
+  }
+  for(it = lbandx.begin(); it != lbandx.end(); it++) {
+    h = (*it).H;
+    h->Write(s);
+  }
+}
+if( nbany>0 ) {
+  sprintf(strg,"Histo2D: Bandes Y %d",nbany);
+  s.PutLine(strg);
+  list<bande_slice>::const_iterator it;
+  for(it = lbandy.begin(); it != lbandy.end(); it++) {
+    min = (*it).min;
+    max = (*it).max;
+    s.PutR4(min);
+    s.PutR4(max);
+  }
+  for(it = lbandy.begin(); it != lbandy.end(); it++) {
+    h = (*it).H;
+    h->Write(s);
+  }
+}
+
+return;
+}
+
+//++
+void  Histo2D::ReadSelf(PInPersist& s)
+//
+//	Lecture fichier de type ppersist.
+//--
+{
+Delete();
+
+int j;
+float min,max;
+Histo* h;
+char strg[256];
+int_4 errok, projx, projy, nslix, nsliy, nbanx, nbany;
+
+// Lecture entete
+s.GetLine(strg, 255);
+s.GetLine(strg, 255);
+s.GetLine(strg, 255);
+s.GetLine(strg, 255);
+s.GetLine(strg, 255);
+s.GetLine(strg, 255);
+
+
+// Lecture variables de definitions
+s.GetI4(nx);
+s.GetI4(ny);
+s.GetI4(nxy);
+s.GetI4(errok);
+s.GetI4(nEntries);
+s.GetR8(nHist);
+
+s.GetR4(xmin);
+s.GetR4(xmax);
+s.GetR4(ymin);
+s.GetR4(ymax);
+s.GetR4(wbinx);
+s.GetR4(wbiny);
+
+s.GetR4s(&over[0][0],9);
+
+s.GetI4(projx);
+s.GetI4(projy);
+s.GetI4(nslix);
+s.GetI4(nsliy);
+s.GetI4(nbanx);
+s.GetI4(nbany);
+
+// Lecture histo2D
+data = new float[nxy];
+s.GetLine(strg, 255);
+for(j=0;j<ny;j++) s.GetR4s(data+j*nx,nx);
+
+// Lecture erreurs
+if(errok) {
+  s.GetLine(strg, 255);
+  err2 = new double[nxy];
+  for(j=0;j<ny;j++) s.GetR8s(err2+j*nx,nx);
+}
+
+// Lecture des projections
+if(projx) {
+  s.GetLine(strg, 255);
+  SetProjX();
+  hprojx->Read(s);
+}
+if(projy) {
+  s.GetLine(strg, 255);
+  SetProjY();
+  hprojy->Read(s);
+}
+
+// Lecture des slices
+if(nslix>0) {
+  s.GetLine(strg, 255);
+  SetSliX(nslix);
+  DBASSERT (nslix==NSliX());
+  for(j=0;j<NSliX();j++) HSliX(j)->Read(s);
+}
+if(nsliy>0) {
+  s.GetLine(strg, 255);
+  SetSliY(nsliy);
+  DBASSERT (nsliy==NSliY());
+  for(j=0;j<NSliY();j++) HSliY(j)->Read(s);
+}
+
+// Lecture des bandes
+if( nbanx>0 ) {
+  s.GetLine(strg, 255);
+  for( j=0; j<nbanx; j++) {
+    s.GetR4(min);
+    s.GetR4(max);
+    SetBandX(min,max);
+  }
+  DBASSERT (nbandx==NBandX());
+  for( j=0; j<NBandX(); j++) {
+    h = HBandX(j);
+    h->Read(s);
+  }
+}
+if( nbany>0 ) {
+  s.GetLine(strg, 255);
+  for( j=0; j<nbany; j++) {
+    s.GetR4(min);
+    s.GetR4(max);
+    SetBandY(min,max);
+  }
+  DBASSERT (nbandy==NBandY());
+  for( j=0; j<NBandY(); j++) {
+    h = HBandY(j);
+    h->Read(s);
+  }
+}
+
+return;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/histos2.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/histos2.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/histos2.h	(revision 1307)
@@ -0,0 +1,226 @@
+//
+// histogrammes 2D     cmv 2/8/96
+//
+
+#ifndef HISTOS2_SEEN
+#define HISTOS2_SEEN
+
+#include "defs.h"
+#include <string>
+
+#include <list>
+#if defined(__KCC__)
+#include <list.h>
+#endif
+
+#include "peida.h"
+#include "histos.h"
+#include "utils.h"
+#include "ppersist.h"
+
+
+class GeneralFit;
+
+
+class Histo2D : public PPersist {
+
+public:
+  enum {classId = ClassId_Histo2D };
+
+  // CREATOR / DESTRUCTOR
+  Histo2D(float xMin, float xMax, int nxBin
+         ,float yMin, float yMax, int nyBin);
+  Histo2D(const Histo2D& h);
+  Histo2D();
+  Histo2D(char *flnm);
+
+  virtual  ~Histo2D();
+
+  // OPTIONS
+  void   Errors();  
+  
+  // UPDATING
+  void   Zero();
+  void   Add(float x, float y, float w = 1.);
+
+  // Operators
+  Histo2D& operator = (const Histo2D& h);
+  Histo2D& operator *= (double b);
+  Histo2D& operator /= (double b);
+  Histo2D& operator += (double b);
+  Histo2D& operator -= (double b);
+  friend Histo2D operator * (const Histo2D& a, double b);
+  friend Histo2D operator * (double b, const Histo2D& a);
+  friend Histo2D operator / (const Histo2D& a, double b);
+  friend Histo2D operator + (const Histo2D& a, double b);
+  friend Histo2D operator + (double b, const Histo2D& a);
+  friend Histo2D operator - (const Histo2D& a, double b);
+  friend Histo2D operator - (double b, const Histo2D& a);
+  Histo2D& operator += (const Histo2D& a);
+  Histo2D& operator -= (const Histo2D& a);
+  Histo2D& operator *= (const Histo2D& a);
+  Histo2D& operator /= (const Histo2D& a);
+  friend Histo2D operator + (const Histo2D& a, const Histo2D& b);
+  friend Histo2D operator - (const Histo2D& a, const Histo2D& b);
+  friend Histo2D operator * (const Histo2D& a, const Histo2D& b);
+  friend Histo2D operator / (const Histo2D& a, const Histo2D& b);
+
+  // get/put dans/depuis une matrice / vector
+  void GetXCoor(Vector& v);
+  void GetValue(Matrix &v);
+  void GetYCoor(Vector& v);
+  void GetError2(Matrix& v);
+  void GetError(Matrix& v);
+  void PutValue(Matrix& v, int ierr=0);
+  void PutValueAdd(Matrix& v, int ierr=0);
+  void PutError2(Matrix& v);
+  void PutError2Add(Matrix& v);
+  void PutError(Matrix& v);
+
+  // INLINES
+  inline float   XMin() const {return xmin;}
+  inline float   XMax() const {return xmax;}
+  inline float   YMin() const {return ymin;}
+  inline float   YMax() const {return ymax;}
+  inline int_4   NBinX() const {return nx;}
+  inline int_4   NBinY() const {return ny;}
+  inline float   WBinX() const {return wbinx;}
+  inline float   WBinY() const {return wbiny;}
+  inline float*  Bins() const  {return data;}
+  inline float   operator()(int i,int j) const {return data[j*nx+i];}
+  inline float&  operator()(int i,int j)       {return data[j*nx+i];}
+  inline bool    HasErrors() { if(err2) return true; else return false;}
+  inline float   Error(int i,int j)  const
+                   {if(err2)
+                      {if(err2[j*nx+i]>0.) return sqrt(err2[j*nx+i]); else return 0.;}
+                    else return 0.;}
+  inline double  Error2(int i,int j) const
+                   {if(err2) return err2[j*nx+i]; else return 0.;}
+  inline double& Error2(int i,int j) {return err2[j*nx+i];}
+  inline float   NData() const    {return (float) nHist;}
+  inline int_4   NEntries() const {return nEntries;}
+  inline void BinLowEdge(int i,int j,float& x,float& y)
+                 {x = xmin + i*wbinx; y = ymin + j*wbiny;}
+  inline void BinCenter(int i,int j,float& x,float& y)
+                 {x = xmin + (i+0.5)*wbinx; y = ymin + (j+0.5)*wbiny;}
+  inline void BinHighEdge(int i,int j,float& x,float& y)
+                 {x = xmin + (i+1)*wbinx; y = ymin + (j+1)*wbiny;}
+  inline void FindBin(float x,float y,int& i,int& j)
+    { i = (int) floorf((x - xmin)/wbinx); j = (int) floorf((y - ymin)/wbiny);}
+
+  // Info, statistique et calculs sur les histogrammes
+  float   NOver(int i=-1,int j=-1) const;
+  int     BinNonNul() const;
+  int     ErrNonNul() const;
+  void    IJMax(int& imax,int& jmax,int il=1,int ih= -1,int jl=1,int jh= -1);
+  void    IJMin(int& imax,int& jmax,int il=1,int ih= -1,int jl=1,int jh= -1);
+  float   VMax(int il=1,int ih= -1,int jl=1,int jh= -1) const;
+  float   VMin(int il=1,int ih= -1,int jl=1,int jh= -1) const;
+  int     EstimeMax(float& xm,float& ym,int SzPav = 3
+                   ,int il=1,int ih= -1,int jl=1,int jh= -1);
+  int     EstimeMax(int im,int jm,float& xm,float& ym,int SzPav = 3);
+  int     FindMax(int& im,int& jm,int SzPav = 3,float Dz = 0.
+                 ,int il=1,int ih= -1,int jl=1,int jh= -1);
+
+  // Fit
+  int      Fit(GeneralFit& gfit,unsigned short typ_err=0);
+  Histo2D* FitResidus(GeneralFit& gfit);
+  Histo2D* FitFunction(GeneralFit& gfit);
+
+  // Print et Display ASCII
+  void    PrintStatus();
+  void    Print(float min=1.,float max=-1.
+               ,int il=1,int ih= -1,int jl=1,int jh= -1);
+
+  // PROJECTIONS
+  void           SetProjX();
+  void           SetProjY();
+  void           SetProj();
+  void           DelProjX();
+  void           DelProjY();
+  void           DelProj();
+  void           ZeroProjX();
+  void           ZeroProjY();
+  void           ZeroProj();
+  inline Histo*  HProjX() const {return hprojx;}
+  inline Histo*  HProjY() const {return hprojy;}
+  void           ShowProj();
+
+  // BANDES
+  inline int     NBandX() const {return lbandx.size();}
+  inline int     NBandY() const {return lbandy.size();}
+  int            SetBandX(float ybmin,float ybmax);
+  int            SetBandY(float xbmin,float xbmax);
+  void           DelBandX();
+  void           DelBandY();
+  void           ZeroBandX();
+  void           ZeroBandY();
+  Histo*         HBandX(int n) const;
+  Histo*         HBandY(int n) const;
+  void           GetBandX(int n,float& ybmin,float& ybmax) const;
+  void           GetBandY(int n,float& xbmin,float& xbmax) const;
+  void           ShowBand(int lp = 0);
+
+  // SLICES
+  inline int     NSliX() const {return lslix.size();}
+  inline int     NSliY() const {return lsliy.size();}
+  int            SetSliX(int nsli);
+  int            SetSliY(int nsli);
+  void           DelSliX();
+  void           DelSliY();
+  void           ZeroSliX();
+  void           ZeroSliY();
+  Histo*         HSliX(int n) const;
+  Histo*         HSliY(int n) const;
+  void           ShowSli(int lp = 0);
+
+  int_4             ClassId() const        { return classId; }
+  static PPersist*  Create()               { return new Histo2D;}
+
+  virtual void      WriteSelf(POutPersist&) const;
+  virtual void      ReadSelf(PInPersist&);
+
+#ifndef __DECCXX
+protected:
+#endif
+  struct bande_slice {
+    int num;
+    float min, max;
+    Histo* H;
+    STRUCTCOMP(bande_slice)
+  };
+#ifdef __DECCXX
+protected:
+#endif
+
+  void Delete();
+
+  float*         data;
+  double*        err2;
+
+  float          over[3][3];
+  double         nHist;
+  int_4          nEntries;
+
+  int_4          nx,ny,nxy;
+  float          xmin;
+  float          xmax;
+  float          ymin;
+  float          ymax;
+  float          wbinx;
+  float          wbiny;
+
+  bande_slice    b_s;
+
+  Histo*         hprojx;
+  Histo*         hprojy;
+
+  list<bande_slice>  lbandx;
+  list<bande_slice>  lbandy;
+  
+  list<bande_slice>  lslix;
+  list<bande_slice>  lsliy;
+
+};
+
+#endif // HISTOS2_SEEN
Index: /tags/DPC_V0/SophyaLib/NTools/imageop.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/imageop.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/imageop.cc	(revision 1307)
@@ -0,0 +1,1315 @@
+#include "defs.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "simplesort.h"
+#include "nbmath.h"
+#include "histos.h"
+#include "datatypes.h"
+#include "imageop.h"
+#include "nbtri.h"
+
+
+//++
+//  Module	Operations sur les images (C++)
+//  Lib	Images++
+//  include	imageop.h
+//
+//	Operations sur les images.
+//--
+
+
+// Outils prives.
+template <class T>
+float RzCmvSigmaCiel(T const * pix,int nx,int ny,int ndata,int bin,
+		     int taille,float frac,int deg,
+		     float low,float high,int deb);
+
+#ifdef IMGRGCHECK
+#define CHECKIMG2(_img_,_x_,_y_)                                  \
+      if ((_x_ >= (_img_).siz_x) || (_y_ >= (_img_).siz_y) ||              \
+          (_x_ < 0) || (_y_ < 0)) THROW(rangeCheckErr);  \
+      if (!(_img_).ImagePtr()) THROW(nullPtrErr)
+#else
+#if defined(IMGVOIDCHECK)
+#define CHECKIMG2(_img_,_x_,_y_) \
+      if (!(_img_).ImagePtr()) THROW(NullPtrErr)
+#else
+#define CHECKIMG2(_img_,_x_,_y_)
+#endif
+#endif /* IMGRGCHECK */
+
+// Les fonctions
+
+/* Nouvelle-Fonction */
+
+template <class T>
+void CleanImagesOld(int nImg, Image<T>** imgTab, double nSig,
+                 double lowbad, double highbad)
+
+/*  Nettoie une serie d'image a partir de l'histo de la  */
+/* serie de valeurs pour chaque pixel (Voir E. Aubourg)  */
+
+{
+  if (lowbad < MinRange((T)0))
+    lowbad = MinRange((T)0);
+
+  if (highbad > MaxRange((T)0))
+    highbad = MaxRange((T)0);
+
+  if (lowbad >= highbad)
+    {lowbad = MinRange((T)0); highbad = MaxRange((T)0);}
+  Histo h(lowbad, highbad, 500);
+
+  for (int i=0; i<imgTab[0]->XSize(); i++)
+    for (int j=0; j<imgTab[0]->YSize(); j++) {
+      h.Zero();
+      for (int k=0; k<nImg; k++)
+        h.Add((*imgTab[k])(i,j));
+      float x0, s0=0;
+      x0 = h.CleanedMean(s0);
+      float low = x0 - s0*nSig; if (low < lowbad) low = lowbad;
+      float hi  = x0 + s0*nSig; // if (hi  > highbad) hi = highbad;
+      for (k=0; k<nImg; k++)
+        if ((*imgTab[k])(i,j) > hi || (*imgTab[k])(i,j) < low)
+          (*imgTab[k])(i,j) = 0;
+    }
+}
+
+/* Nouvelle-Fonction */
+
+template <class T>
+//++
+void CleanImages(int nImg, Image<T>** imgTab, double nSig,
+                 double lowbad, double highbad)
+//
+//	Nettoie une serie de `nImg' images `imgTab' a partir
+//	d'une moyenne tronquee a `nSig' sigma
+//	de la serie de valeurs pour chaque pixel.
+//	Les valeurs des pixels sont prises entre `lowbad' et `highbad'.
+//--
+{
+  if (lowbad < MinRange((T)0))
+    lowbad = MinRange((T)0);
+
+  if (highbad > MaxRange((T)0))
+    highbad = MaxRange((T)0);
+
+  if (lowbad >= highbad)
+    {lowbad = MinRange((T)0); highbad = MaxRange((T)0);}
+  
+  double sx, sx2, sig, mean;
+  int n;
+
+  for (int i=0; i<imgTab[0]->XSize(); i++)
+    for (int j=0; j<imgTab[0]->YSize(); j++) {
+      sig = 1e20; mean = 0;
+      for (int l = 0; l<3; l++) {
+        double low = mean - nSig*sig;
+        if (low < lowbad) low = lowbad;
+        double high = mean + nSig*sig;
+        if (high > highbad) high = highbad;
+        sx = sx2 = n = 0;
+        for (int k=0; k<nImg; k++) {
+          double p = (*imgTab[k])(i,j);
+          if (p > low && p < high) {
+            sx += p;
+            sx2 += p*p;
+            n++;
+          }
+        }
+        if (n>0) {
+          mean = sx / n;
+          sig  = sqrt( sx2/n - (sx/n)*(sx/n) );
+        } // sinon on laisse tel quel, ca sera coupe...
+      }
+      double low = mean - nSig*sig;
+      if (low < lowbad) low = lowbad;
+      double high = mean + nSig*sig;
+      if (high > highbad) high = highbad;
+      for (int k=0; k<nImg; k++)
+        if ((*imgTab[k])(i,j) > high || (*imgTab[k])(i,j) < low)
+          (*imgTab[k])(i,j) = 0;
+    }
+}
+
+/* Nouvelle-Fonction */
+
+template <class T>
+//++
+float ImgFondCielHisto(Image<T> const& img, float binWidth, int degree, float frac,
+                       float low, float high, int debug)
+//
+//	Calcul du fond de ciel par histogrammation. L'histogramme
+//	va de `low' a `high' avec une largeur de bin `binWidth'.
+//	La valeur la plus probalbe est fittee par un polynome de degre
+//	`degree' en utilisant les bins entourant le maximum
+//	a `frac' pourcent de sa hauteur.
+//--
+{
+  // CHECKIMG2(img,0,0);
+
+  if (degree < 2 || degree > 3)
+    degree = 3;
+
+  if (frac <= 0 || frac >= 1)
+    frac = 0.5;
+
+  if (low < MinRange((T)0)+2)
+    low = MinRange((T)0)+2;
+
+  if (high > MaxRange((T)0)-2)
+    high = MaxRange((T)0)-2;
+
+  if (low >= high)
+    {low = MinRange((T)0); high = MaxRange((T)0);}
+
+// verifier binwidth
+
+//  if ( binWidth < 65536.0/img.XSize()*img.YSize() )
+//    binWidth = 65536.0/img.XSize()*img.YSize();
+
+  if (binWidth<0)
+    binWidth = 1;
+
+  if (debug > 1)
+    cout << __FUNCTION__ << " binWidth =" << binWidth <<
+      ", degree = " << degree <<
+      ", frac = "   << frac   <<
+      ", low = "    << low    <<
+      ", high = "   << high   << endl;
+
+  int nBins = int(((double)high-(double)low)/(double)binWidth + 1);
+  Histo hist(low, high, nBins);
+
+  int nPix = img.XSize()*img.YSize();
+  for (int i=0; i<nPix; i++)
+    hist.Add(img[i]);
+
+  hist(0) = 0;
+
+  float fd = hist.FitMax(degree, frac, debug);
+
+  (float&) img.fond = fd;
+
+  return fd;
+}
+
+
+/* Nouvelle-Fonction */
+
+template <class T>
+float ImgSigmaCiel(Image<T> const& img, int ndata, int binWidth,
+		   int taille, float frac, int degree,
+		   float low, float high, int debug)
+{
+  (float&) img.sigmaFond = RzCmvSigmaCiel(img.ImagePtr(), img.XSize(), img.YSize(),
+				 ndata, binWidth, taille, frac,
+				 degree, low, high, debug);
+  return img.sigmaFond;
+}
+
+
+/* Nouvelle-Fonction */
+
+template <class T>
+//++
+float RzCmvSigmaCiel(T const* pix,int nx,int ny,int ndata,int bin,
+		     int taille,float frac,int deg,
+		     float low,float high,int deb)
+//
+//	Calcul du fond de ciel par histogrammation
+//
+//| INPUT:
+//|   - pix   : tableau pix[nx][ny]
+//|   - nx,ny : dimensions du tableau pix
+//|   - ndata : nombre de donnees a utiliser
+//|   - bin   : largeur du bin en ADU
+//|   - taille: 1/2 dimension de l'histogramme en ADU
+//|   - frac  : fraction du maximum au dessus de laquelle on fite
+//|   - deg   : degre fit polynome sous la gaussienne (0 ou 2)
+//|   - low   : valeur basse limite en ADU
+//|   - high  : valeur haute limite en ADU
+//|   - deb   : flag de debug
+//--
+//++
+//| OUTPUT:
+//|   - retourne : le sigma du fond de ciel si OK
+//|                -1 si probleme definition
+//|                -2 si probleme allocation
+//|                -3 si probleme remplissage histogramme
+//|                -4 si probleme recherche maximum
+//|                -5 si probleme calcul fraction du maximum
+//|                -6 si probleme nombre de bin
+//|                -7 si probleme nombre de fit
+//| 
+//--
+//                // EA seul changement par rapport a la version C :
+//                // pix est un T*, en template. -> C++ necessaire.
+{
+FLOATDOUBLE X,Y,EY;
+double (*Fun) (double ,double *,double *);
+int_4 npar;
+double par[6], epar[6],minpar[6],maxpar[6],stepar[6],stochi2;
+int_4 i,j,i1,j1,j2,n,ip,nbin,inc,ibin0,max,imax,lmax,b1,b2;
+float *histo,*xbin,*ehisto,fwhm,rc;
+double vp,pxv;
+
+/* set reasonable parameters */
+Fun = Gauss1DPolF ;
+if ( deg<=1 ) deg=0;  else deg=2;
+low = ( low < 0 ) ? 0 : low;
+high = ( high > 65530 ) ? 65530 : high;
+if ( low >= high ) { low=0; high = 65530;}
+bin = ( bin <= 0 ) ? 1 : bin;
+nbin = int(2.*taille /bin + 1);
+if ( nbin < 20 ) nbin = 20;
+if ( nbin >= 65530 ) nbin = 65530;
+ibin0 = int(-nbin*bin/2.);
+inc = int(nx*ny / ndata); inc = int(sqrt( (double) inc ));
+inc = (inc<1) ? 1 : inc;
+if(deb>1)
+  { printf("Sigma_Ciel: pix[%d,%d] ndata=%d bin=%d taille=%d"
+          ,nx,ny,ndata,bin,taille);
+  printf(" frac=%f low=%g high=%g nbin=%d ibin0=%d inc=%d\n"
+        ,frac,low,high,nbin,ibin0,inc); }
+if ( nx < 5 || ny < 5 ) return (-1.);
+
+/* allocate place for histogramme */
+if ( (histo  = (float *) calloc(nbin, sizeof(float)) ) == NULL )
+       return(-2.);
+if ( (xbin   = (float *) calloc(nbin, sizeof(float)) ) == NULL )
+       {free(histo); return(-2.);}
+if ( (ehisto = (float *) calloc(nbin, sizeof(float)) ) == NULL )
+       {free(histo); free(xbin); return(-2.);}
+
+/* fill histogramme */
+ndata=0;
+for (j=1;j<ny-1;j=j+inc) { for (i=1;i<nx-1;i=i+inc) {
+  ip = (int)(*(pix+j*nx+i));
+  if ( ip < low || ip > high ) continue;
+  vp = (double) ip;
+  pxv = 0.; n=0;
+  for(j1=j-1;j1<=j+1;j1++) { for(i1=i-1;i1<=i+1;i1++) {
+    if ( i1 == i && j1 == j ) continue;
+    ip = (int)(*(pix+j1*nx+i1));
+    if ( ip < low || ip > high ) continue;
+    pxv += (double) ip;
+    n++;
+  } }
+  if ( n != 8 ) continue;
+  vp = vp - pxv/n;
+  ip = int((vp-ibin0)/bin);
+  if( ip<0 || ip >= nbin ) continue;
+  histo[ip]++;
+  ndata++;
+} }
+for(i=0;i<nbin;i++)
+  { xbin[i] = (float) ibin0 + ( (float) i + 0.5 ) * (float) bin;
+  ehisto[i] = (histo[i]<1.) ? -1. : sqrt((double) histo[i]);}
+
+if(deb>1) printf("     nombre de data corrects = %d\n",ndata);
+if( ndata < 1 ) {rc= -3.; goto END;}
+
+/* find maximum */
+max = -1; imax = -1;
+for(i=nbin-1;i>=0;i--) if(histo[i]>max) { max=int(histo[i]); imax=i;}
+if(deb>1) printf("     maxi histo = %d (bin=%d)\n",max,imax);
+if ( imax == -1 || imax == 0 || imax == nbin-1 ) {rc= -4.; goto END;}
+if(deb>2) {
+  for(i=imax-10;i<=imax+10;i++) if(i>=0 && i<nbin) printf(" %5f",xbin[i]);
+  printf("\n");
+  for(i=imax-10;i<=imax+10;i++) if(i>=0 && i<nbin) printf(" %5d",(int) histo[i]);
+  printf("\n"); }
+
+/* find limites a half maximum */
+lmax = (int) ( (float) max * 0.5 );
+for(b1=imax;b1>0;b1--)    if(histo[b1]<=lmax) break;
+for(b2=imax;b2<nbin;b2++)  if(histo[b2]<=lmax) break;
+fwhm = (xbin[b2]-xbin[b1]);
+if(deb>1) printf("     fwhm = %f (%d,%d)\n",fwhm,b1,b2);
+
+/* find limites a frac*max */
+lmax = (int) ( (float) max * frac ) + 1;
+if( lmax < 1 )
+   {if(deb>1) printf("     lmax=%d\n",lmax); rc= -5.; goto END;}
+for(b1=imax;b1>0;b1--)    if(histo[b1]<=lmax) break;
+for(b2=imax;b2<nbin;b2++)  if(histo[b2]<=lmax) break;
+
+n=0;
+for(i=b1;i<=b2;i++) if( histo[i] > 0 ) n++;
+if(deb>1) printf("     limites bin %d %d (v=%d) bin non nuls=%d\n"
+                ,b1,b2,lmax,n);
+/* pas assez de bin, on en ajoute artificiellement */
+/* 8 est une borne large pour fiter gauss + parab (3+3) */
+if( n < 8 ) {
+  j1 = b1; j2 = b2;
+  for(i=1;i<nbin;i++) {
+    if ( b1-i >= 0 ) j1=b1-i;
+    if ( b2+i < nbin ) j2=b2+i;
+    if ( histo[j1] > 0 ) n++;
+    if ( histo[j2] > 0 ) n++;
+    if( n >= 6 ) break;
+  }
+  b1 = j1; b2 = j2;
+  if(deb>1) printf("     Re-update des limites bin %d %d (v=%d) bin non nuls=%d\n"
+                  ,b1,b2,lmax,n);
+}
+if( n < 4 ) {rc= -6.; goto END;}
+ndata = n;
+
+/* fit dans les limites */
+npar = 3+deg+1; Set_FitFunDPol(deg);
+if(ndata<8) {npar=4; Set_FitFunDPol(0);}
+if(ndata<5) {npar=3; Set_FitFunDPol(-1);}
+X.fx  = xbin;
+Y.fx  = histo;
+EY.fx = ehisto;
+stochi2 = 0.0001;
+n = nbin;
+par[0] = max;
+par[1] = histo[imax-1]*xbin[imax-1]+histo[imax]*xbin[imax]+histo[imax+1]*xbin[imax+1];
+par[1] = par[1]/(histo[imax-1]+histo[imax]+histo[imax+1]);
+par[2] = (fwhm<1.) ? 1. : fwhm/2.36;
+par[3] = par[4] = par[5] = 0.;
+stepar[0] = par[0]/20.; stepar[1] = 1.; stepar[2] = par[2]/5.;
+stepar[3] = 1.; stepar[5] = 0.1;
+stepar[4] =  0.;
+for(i=0;i<6;i++) {minpar[i] = 1.; maxpar[i] = -1.;}
+minpar[2] = 0.1; maxpar[2] = 65530.;
+if(deb>1) printf("     choix de fit a %d parametres b1=%d,b2=%d,ndata=%d)\n"
+                ,npar,b1,b2,ndata);
+
+i = (deb>=3) ? deb-2 : 0 ;
+vp = FitFun(Fun,FITFUN_FLOAT,X,Y,EY,&n,b1,b2,par
+           ,epar,stepar,minpar,maxpar,npar,stochi2,50,i);
+
+if( vp<=0. && vp != -4. ) {rc= -7.; goto END;}
+rc = par[2];
+if(deb>1) printf("     sigma=%f (h=%f centrage=%f) xi2=%f (%f pour %d)\n"
+                ,rc,par[0],par[1],vp,vp/(n-npar),npar);
+
+END:
+free(histo); free(xbin); free(ehisto);
+return(rc);
+}
+
+/* ................................................................................. */
+/*                  Filtrage ( Convolution ) d' images                               */
+/* ................................................................................. */
+
+/* Nouvelle-Fonction */
+template <class T>
+//++
+Image<T> * FilterImage(Image<T> const * pim, Image<T> * pom, ImageR4 *matx)
+//
+//	Filtrage ( Convolution ) d'une image `pim' par une matrice carree
+//	representee par l'ImageR4 `matx'.
+//	Le resultat se retrouve dans `pom'.
+//	Si `pom' = NULL, elle est cree.
+//	`pim' et `pom' doivent avoir la meme taille.
+//--
+{
+ 
+float vpix, *mxe;
+bool fgcr;
+int i,j,k,l,m,n;
+int ndim, nd2;
+
+fgcr = false;
+
+if ((pim == NULL) || (matx == NULL))
+  { printf(" FilterImage_Erreur : pim ou matx = NULL ! \n");
+  return(NULL);  }
+if (matx->XSize() != matx->YSize())
+  { printf("FilterImage_Erreur: Filtrage par matrice carre uniquement (%d,%d)\n",
+            matx->XSize(), matx->YSize());  return(NULL); }
+ndim = matx->XSize();
+if ( (ndim < 3) || ((ndim%2) == 0) || (ndim > 25))
+  { printf("FilterImage_Erreur: Pb dimension matrice (%d) (Impair, entre 3 et 25)\n", ndim);
+  return(NULL); }
+if (pom == NULL)
+  {  pom = new Image<T>(pim->XSize(), pim->YSize(), false);   fgcr = true; }
+
+if ( (pim->XSize() != pom->XSize()) || (pim->YSize() != pom->YSize()) )
+  { printf("FilterImage_Erreur : Taille pim et pom differentes ! \n") ;
+  if (fgcr) delete pom;   return(NULL) ;}
+
+nd2 = ndim/2;
+
+/*  Traitement de la partie centrale */
+for(j=nd2; j<(pom->YSize()-nd2); j++)
+  {
+  for(i=nd2; i<(pom->XSize()-nd2); i++)
+    {
+    vpix = 0.;   mxe = matx->ImagePtr();
+    for(l=-nd2; l<=nd2; l++)
+      for(k=-nd2; k<=nd2; k++)
+         { vpix += (float)((*pim)((i+k), (j+l))) * (*mxe);
+         mxe++; }
+    (*pom)(i, j) = (T)vpix;
+    }
+  }
+
+/*  Traitement bord en Y  en haut */
+for(j=0; j<nd2; j++)
+  {
+  for(i=nd2; i<(pom->XSize()-nd2); i++)
+    {
+    vpix = 0.;  mxe = matx->ImagePtr();
+    for(l=-nd2; l<=nd2; l++)
+
+      for(k=-nd2; k<=nd2; k++)
+        {
+        m = i+k;  n = j+l;
+        if (n < 0)  n = 0;
+        vpix += (float)((*pim)(m, n)) * (*mxe);
+        mxe++;
+        }
+    (*pom)(i, j) = (T)vpix;
+    }
+  }
+
+/* Traitement bord en Y en bas  */
+for(j=(pom->YSize()-nd2); j<pom->YSize(); j++)
+  {
+  for(i=nd2; i<(pom->XSize()-nd2); i++)
+    {
+    vpix = 0.;  mxe = matx->ImagePtr();
+    for(l=-nd2; l<=nd2; l++)
+      for(k=-nd2; k<=nd2; k++)
+        {
+        m = i+k;  n = j+l;
+        if (n >= pim->YSize())  n = (pim->YSize()-1);
+        vpix += (float)((*pim)(m, n)) * (*mxe);
+        mxe++;
+        }
+    (*pom)(i, j) = (T)vpix;
+    }
+  }
+
+/*  traitement bords en X et coins */
+for(j=0; j<pom->YSize(); j++)
+  {
+  for(i=0; i<nd2; i++)
+    {
+    vpix = 0.;  mxe = matx->ImagePtr();
+    for(l=-nd2; l<=nd2; l++)
+      for(k=-nd2; k<=nd2; k++)
+        {
+        m = i+k;  n = j+l;
+        if (m < 0)  m = 0;
+        if (n < 0)  n = 0;
+        if (n >= pim->YSize())  n = (pim->YSize()-1);
+        vpix += (float)((*pim)(m, n)) * (*mxe);
+        mxe++;
+        }
+    (*pom)(i, j) = (T)vpix;
+    }
+  for(i=(pom->XSize()-nd2); i<pom->XSize(); i++)
+    {
+    vpix = 0.;  mxe = matx->ImagePtr();
+    for(l=-nd2; l<=nd2; l++)
+      for(k=-nd2; k<=nd2; k++)
+        {
+        m = i+k;  n = j+l;
+        if (m >= pim->XSize())  m = (pim->XSize()-1);
+        if (n < 0)  n = 0;
+        if (n >= pim->YSize())  n = (pim->YSize()-1);
+        vpix += (float)((*pim)(m, n)) * (*mxe);
+        mxe++;
+        }
+    (*pom)(i, j) = (T)vpix;
+    }
+  }
+
+
+return(pom);
+
+}
+
+//////////////////////////////////////////////////////////////////////////////
+/* Nouvelle-Fonction    CMV 14/10/97 */
+template <class T>
+//++
+Image<T> * FilterStat(Image<T> const * pim, Image<T> * pom
+                     ,int N,int M,float lowbad,float highbad)
+//
+//	Filtrage median d'une image `(*pim)'.
+//	Le resultat se retrouve dans `(*pom)'.
+//	Si pom = NULL l'image de sortie est cree automatiquement.
+//	pim et pom doivent avoir la meme taille.
+//	Le masque de calcul du filtre median est un rectangle `N'x`M'
+//	La dynamique de l'image est `lowbad,highbad'.
+//	Si lowbad>=highbad dynamique infinie.
+//--
+{
+if(pim == NULL)
+  {printf(" FilterStat_Erreur : pim = NULL ! \n");
+  return(NULL);}
+if( N<=0 || M<=0 )
+  {printf("FilterStat_Erreur: Filtrage par matrice (%d,%d)\n",N,M);
+  return(NULL);}
+bool fgcr = false;
+if(pom == NULL)
+  {pom = new Image<T>(pim->XSize(), pim->YSize(), false);   fgcr = true;}
+if( (pim->XSize() != pom->XSize()) || (pim->YSize() != pom->YSize()) )
+  { printf("FilterImage_Erreur : Taille pim et pom differentes ! \n");
+  if(fgcr) delete pom;   return(NULL);}
+
+T low  = (T) lowbad;
+T high = (T) highbad;
+if(high>low) fgcr = true; else fgcr = false;
+
+N /= 2; M /= 2;
+double * tab = new double[(2*N+1)*(2*M+1)];
+
+for(int j=0;j<pom->YSize();j++) {
+  for(int i=0;i<pom->XSize();i++) {
+    int n=0;
+    for(int jj=j-M;jj<=j+M;jj++) {
+      if( jj<0 || jj >= pom->YSize() ) continue;
+      for(int ii=i-N;ii<=i+N;ii++) {
+        if( ii<0 || ii >= pom->XSize() ) continue;
+          if( fgcr && ( (*pim)(ii,jj)<=low || high<=(*pim)(ii,jj) ) ) continue;
+          tab[n] = (double) (*pim)(ii,jj);
+          n++;
+      }
+    }
+    if(n==0) (*pom)(i,j) = 0;
+    else if(n==1) (*pom)(i,j) = (T) tab[0];
+    else {
+      HeapSort(n,tab);
+      if(n%2==1) (*pom)(i,j) = (T) tab[(n-1)/2];
+      else (*pom)(i,j) = (T) (tab[n/2]+tab[n/2-1])/2.;
+    }
+  }
+}
+
+delete [] tab;
+return(pom);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+/* Nouvelle-Fonction    CMV 7/8/98 */
+template <class T>
+//++
+Image<T> * CSplineImage(Image<T> const & f1,double pxsz,double x0,double y0,int natural)
+//
+//	Fonction retournant un pointeur sur une image qui contient
+//	le Spline 3 a 2 dimensions de l'images f1 (NULL est retourne si probleme).
+//	`pxsz' est la taille du pixel de l'image retournee en considerant
+//	que l'image `f1' en entree a une taille de pixel egale a 1.
+//	`x0,y0' est le decalage eventuel a appliquer de l'image origine a
+//	l'image retournee, ce decalage etant mesure en unites de pixels
+//	de l'image origine (1).
+//	`natural' a la signification decrite dans la classe `CSpline2'.
+//	Attention, la taille de l'image retournee sera `nx/pxsz' et `ny/pxsz'.
+//	Pour eviter les problemes d'extrapolation sur les bords de l'image
+//	d'origine, il leurs est assigne la valeur du centre du pixel auquel ils
+//	appartiennent.
+//--
+{
+//// open for result
+int nx = f1.XSize();
+int ny = f1.YSize();
+float dum;
+dum = nx/pxsz;
+int dx = (int) (dum+0.5);
+dum = ny/pxsz;
+int dy = (int) (dum+0.5);
+cout<<"Taille image en entree: "<<nx<<" "<<ny<<endl
+    <<"Taille image en sortie: "<<dx<<" "<<dy<<" (pix size="<<pxsz<<")"<<endl
+    <<"Decalage en x="<<x0<<" en y="<<y0<<endl;
+if(nx<=1 || ny<=1) return NULL;
+if(dx<=0 || dy<=0) return NULL;
+
+Image<T> *f2 = NULL;
+TRY {
+  f2 = new Image<T>(dx,dy);
+} CATCHALL {
+  cout<<"Impossible d'ouvrir le fichier resultat"<<endl;
+  return NULL;
+} ENDTRY
+
+//// Spline 3 2D ... nx+2 pour tenir compte des effets de bords !
+double *x = new double[nx+2];
+double *y = new double[ny+2];
+double *z = new double[(nx+2)*(ny+2)];
+{
+int k;
+// Centre pixel (0,0) en (0.5,0.5) et on ajoute les coordonnees
+// des bords pour extrapolation sur tout l'intervalle.
+// Les coordonnees vont de [0,nx] et [0,ny] (valeurs extremes comprises).
+x[0] = 0.; x[nx+1] = nx;
+y[0] = 0.; y[ny+1] = ny;
+for(k=1;k<=nx;k++) x[k] = k-0.5;
+for(k=1;k<=ny;k++) y[k] = k-0.5;
+// Remplissage des valeurs avec effet de bord [0] et [nx+1],[ny+1].
+k = 0;
+int ii,jj;
+for(int j=0;j<ny+2;j++) {
+  jj = j-1;
+  if(jj<0) jj=0; else if(jj>=ny) jj=ny-1;
+  for(int i=0;i<nx+2;i++) {
+    ii = i-1;
+    if(ii<0) ii=0; else if(ii>=nx) ii=nx-1;
+    z[k] = (double) f1(ii,jj);
+    k++;
+  }
+}
+}
+
+CSpline2 spl(nx+2,x,ny+2,y,z,natural,true);
+spl.ComputeCSpline();
+
+*f2 = 0.;
+{
+// Attention au decalage possible !
+// Les valeurs vont de [0.5*pxsz,(dx-0.5)*pxsz] idem pour y...
+// a corriger eventuellement du decalage x0,y0.
+double xmin = -pxsz/10000., xmax = nx+pxsz/10000.;
+double ymin = -pxsz/10000., ymax = ny+pxsz/10000.;
+for(int j=0;j<dy;j++) {
+  double yy = (j+0.5)*pxsz - y0;
+  if( yy<=ymin || yy>=ymax ) continue;
+  for(int i=0;i<dx;i++) {
+    double xx = (i+0.5)*pxsz - x0;
+    if( xx<=xmin || xx>=xmax ) continue;
+    (*f2)(i,j) = (T) spl.CSplineInt(xx,yy);
+}}}
+
+//// nettoyage
+delete [] x;
+delete [] y;
+delete [] z;
+
+return f2;
+}
+//////////////////////////////////////////////////////////////////////////////
+
+
+
+/* Nouvelle-Fonction */
+int FondSigmaCiel(RzImage *pim, float low, float high,int pvsz
+              ,float nbsig1,float nbsig2,float nbsig3
+              ,float binsg,float frac,int modu,int deb)
+{
+int rc;
+
+  switch (pim->PixelType())
+    {
+    case kuint_2:
+      {
+      ImageU2 imt((RzImage&)(*pim));
+      rc = imt.FondSigmaCiel(low, high, pvsz, nbsig1, nbsig2, nbsig3, binsg, frac, modu, deb);
+      pim->fond = imt.fond;
+      pim->sigmaFond = imt.sigmaFond;
+      break;
+      }
+    case kint_2:
+      {
+      ImageI2 imt((RzImage&)(*pim));
+      rc = imt.FondSigmaCiel(low, high, pvsz, nbsig1, nbsig2, nbsig3, binsg, frac, modu, deb);
+      pim->fond = imt.fond;
+      pim->sigmaFond = imt.sigmaFond;
+      break;
+      }
+    case kint_4:
+      {
+      ImageI4 imt((RzImage&)(*pim));
+      rc = imt.FondSigmaCiel(low, high, pvsz, nbsig1, nbsig2, nbsig3, binsg, frac, modu, deb);
+      pim->fond = imt.fond;
+      pim->sigmaFond = imt.sigmaFond;
+      break;
+      }
+    case kr_4:
+      {
+      ImageR4 imt((RzImage&)(*pim));
+      rc = imt.FondSigmaCiel(low, high, pvsz, nbsig1, nbsig2, nbsig3, binsg, frac, modu, deb);
+      pim->fond = imt.fond;
+      pim->sigmaFond = imt.sigmaFond;
+      break;
+      }
+    default:
+      {
+      cout<<"FindSigmaCiel: type d'image non-prevu "<<(int) pim->PixelType()<<endl;
+      exit(-1);
+      }
+    }
+
+return(rc);
+}
+
+/* Nouvelle-Fonction */
+int CalFondImage(RzImage *pim, double low, double high, int action)
+
+/*  ATTENTION: Adaptation a partir d'une version C              */ 
+/*             CalculFond() de imgstat.c                        */
+ 
+/*  Cette fonction calcule le fond et le sigma du ciel a la CMV */
+/*  CMV / E.Aubourg / Reza                                      */
+/*  action Bit 0  CheckDyn()                                    */
+/*         Bit 1  ImgFondCielHisto()                            */
+/*         Bit 2  ImgSigmaCiel                                  */
+/*         Bit 3  FondSig2Ciel()                                */
+/*         Bit 1+2+3 (=14)   Fond_Ciel() + Sigma_Ciel() Si OK   */
+/*                            FondSig2Ciel()  sinon             */
+/*  action = 0  ou  >= 15  CheckDyn + Bit 1+2+3 (=14)           */
+/*  Rc=0 OK  Erreur Sinon                                       */
+/*  Sortie : Mise a jour de la struct RzImage                   */
+
+{
+int n,ok,rc,fga;
+float fnd, sg;
+
+int nbsig, vitesse, nbin;
+float minaff, maxaff, minpix, maxpix;
+float fracmax,fracnul,fracsat;
+char *meth;
+
+#define DBG  0
+
+if (action >= 15)   action = 15;
+if (action <= 0)  action = 15;
+fga = action;
+fnd = sg = -1.;
+ok = 1;
+
+if (action & 1)  
+  { pim->CheckDyn(low, high); 
+   action--;  }
+
+n = pim->XSize()*pim->YSize();
+
+if (action & 6)
+  {
+  int npu = (n/4 < 5000) ? 5000 : n/4;
+  meth = (char *)"Fond/Sig";
+  switch (pim->PixelType())
+    {
+    case kuint_2:
+      {
+      ImageU2 imt((RzImage&)(*pim));
+      if (action & 2) 
+        fnd = ImgFondCielHisto(imt, 1.0f, 2, 0.5f, (float)low, (float)high, DBG);
+      if (action & 4)
+        {  sg = ImgSigmaCiel(imt, npu, 1, 200, 0.1f, 2, 
+			     (float)low, (float)high, DBG);
+          if (sg < -1.e-3 )  ok = 0; }
+      break;
+      }
+    case kint_2:
+      {
+      ImageI2 imt((RzImage&)(*pim));
+      if (action & 2) 
+        fnd = ImgFondCielHisto(imt, 1.0f, 2, 0.5f, (float)low, (float)high, DBG);
+      if (action & 4)
+        {  sg = ImgSigmaCiel(imt, npu, 1, 200, 0.1f, 2,
+			     (float)low, (float)high, DBG);
+          if (sg < -1.e-3 )  ok = 0; }
+      break;
+      }
+    case kint_4:
+      {
+      ImageI4 imt((RzImage&)(*pim));
+      if (action & 2) 
+        fnd = ImgFondCielHisto(imt, 1.0f, 2, 0.5f, (float)low, (float)high, DBG);
+      if (action & 4)
+        {  sg = ImgSigmaCiel(imt, npu, 1, 200, 0.1f, 2, 
+			     (float)low, (float)high, DBG);
+          if (sg < -1.e-3 )  ok = 0; }
+      break;
+      }
+    case kr_4:
+      {
+      ImageR4 imt((RzImage&)(*pim));
+      if (action & 2) 
+        fnd = ImgFondCielHisto(imt, 1.0f, 2, 0.5f, (float)low, (float)high, DBG);
+      if (action & 4)
+        {  sg = ImgSigmaCiel(imt, npu, 1, 200, 0.1f, 2, 
+			     (float)low,(float) high, DBG);
+          if (sg < -1.e-3 )  ok = 0; }
+      break;
+      }
+
+    case kuint_4:
+    case kr_8:
+      cerr << "CalFondImage(RzImage *, ...) Unsupported image type (kuint_4/kr_8) " 
+           << (int) pim->PixelType() << "\n" ; 
+      break;
+    default:
+      cerr << "CalFondImage(RzImage *, ...) Unknown image type !! " << (int) pim->PixelType() << "\n" ;
+    break;
+    }
+
+  }
+
+if ( (action == 8) || (!ok && (action & 8)) )
+  {
+  fracmax = 0.85;   nbsig = 1;     vitesse = 3;
+  minpix = low;   maxpix = high;  nbin = 10000;
+  rc = RzFondSig2Ciel(pim, vitesse, fracmax, nbsig, nbin,  
+                      &minpix, &maxpix, &fnd, &sg,
+                      &minaff, &maxaff, &fracnul, &fracsat);
+  if (rc != 0)   ok = 0;
+  meth = (char *)"FondSig2";
+  }
+
+if (ok > 0)     /*  Mise a jour */ 
+  {
+  if (fnd > -1.)  pim->fond = fnd; 
+  if (sg > -1. )  pim->sigmaFond = sg;     
+  printf("CalculFond_Info: Meth=%s (%d) Fond/Sig= %5g %4g Nul/Sat=%d %d\n",
+         meth, fga, fnd, sg, pim->nbNul, pim->nbSat);
+  return(0);
+  }
+else
+  {
+  printf("CalculFond_Erreur: Action=%d  NbNul/Sat=%d %d\n",fga,
+          pim->nbNul, pim->nbSat);
+  return(1);
+  }
+
+}
+
+
+
+/* Nouvelle-Fonction */
+
+int RzFondSig2Ciel(RzImage * pim, int vitesse, float FracMax, int NbSigmas, int NBin,
+	           float *MinPix, float *MaxPix, float *Fond, float *SigFond,
+                   float *MinAff, float *MaxAff, float *FracNul, float *FracSature)
+
+/*   ATTENTION : Cette fonction a ete mis en C++, pour traiter des   */
+/*               RzImage a partir de la fonction FondSig2Ciel()      */
+/*               de imgstat.c                                        */
+/*                                        R. Ansari  04/95           */
+
+/*    Cette fonction calcule les valeurs suivantes pour une image    */
+/*    Arguments d'entree :                                           */
+/*     - pim : Pointeur RzImage                                      */
+/*     - vitesse : 1 pixel / vitesse pris en compte                  */
+/*     - FracMax : Parametre de calcul (voir ci-dessous)             */
+/*     - NbSigmas: MinAff =  Fond + NbSigmas*SigFond                 */
+/*       **Note : Si NbSigmas < 0 , on prend :                       */
+/*                 MinAff =  Fond + NbSigmas*SigFond                 */
+/*              et MaxAff =  Fond - NbSigmas*SigFond                 */
+/*         Dans ce cas la gamme d'affichage fait ressortir le fond.  */
+/*     - NBin : Nb de bins de l'histo                                */
+/*     - La valeur mini des pixels et la valeur de saturation        */
+/*       (ValNul et ValSat) doivent etre fournies ds Min/MaxPix      */
+/*              sorties :                                            */
+/*  - MinPix,MaxPix = Valeurs Min et Max des pixels  (<ValSat)       */
+/*  - Fond =  Pic de l'histo des pixels                              */
+/*  - SigFond = sigma du fond calcule par la relation                */
+/*     NbPixel(Fond+SigFond) =  Pic histo * 0.606 (=Exp(-0.5))       */
+/*  - MinAff = Bruit + NbSigmas * Sigma bruit                        */
+/*  - MaxAff est calcule tel que la relation suivante soit verifie   */
+/*     NbPixel(MinAff<Pixel<MaxAff) =  Nb de pixel entre Min-MaxAff  */
+/*      = FracMax * NbPixel(MinAff<Pixel<ValSat                      */
+/*  - FracNul = Nb pixel < ValNul / Nb total pixel                   */
+/*  - FracSat = Nb pixel satures (>ValSat) / Nb total pixel          */
+
+/*     return code : 0 OK , 1 Erreur calloc                          */
+/*                   2 : Pic histos non trouve                       */
+/*                   3,4 : Probleme de Min/MaxAff avec ValSat        */
+/*                   5 : Gamme dynamique minimale non respectee      */
+/*                         (MaxAff - MinAff > MINDYNAMIC             */
+
+{
+
+#define MINNBIN 100
+#define MAXNBIN 32765
+
+int nbin;
+
+float minhis = 0., maxhis = 65530. , binwidth;
+int xdim, ydim;
+int_4 under,over,tothis;
+int_4 *phis;
+float ValNul,ValSat;
+int_4 *q;
+
+float val;
+int i;
+float min, max;
+int_4 nbpix,nbpix2, imin, imax;
+int bin,binmax;
+int sigl,sigr;
+float fracfond,fracsignal;
+
+float MINDYNAMIC = 5;          /* Gamme dynamique minimale (MaxAff-MinAff)*/
+
+#define FRACPIC		0.6065     /*  Valeur de exp(-0.5)   */
+
+xdim = pim->XSize();
+ydim = pim->YSize();
+
+ValNul = *MinPix;
+ValSat = *MaxPix;
+if ((ValSat < ValNul+0.01))  ValSat = ValNul+0.01;  
+
+nbin = NBin;
+if (nbin < MINNBIN)  nbin = MINNBIN;
+if (nbin > MAXNBIN)  nbin = MAXNBIN;
+
+if (vitesse < 1)  vitesse = 1;
+if (vitesse > xdim*ydim/100)  vitesse = xdim*ydim/100;
+
+
+/*  Je modifie min et max histo et nbin en fonction de valnul et valsat */
+/*  je garde binwidth constant     */
+
+binwidth = (ValSat-ValNul) / nbin;
+minhis = ValNul;
+maxhis = minhis + nbin*binwidth;
+
+
+(*MinAff) = minhis;
+(*MaxAff) = maxhis;
+*MinPix = 0.;
+*MaxPix = -1.;
+*Fond = -1.;
+*SigFond = -1.;
+*FracNul = 0.0;
+*FracSature = 0.0;
+
+/* allocation dynamique de memoire */
+phis = new int_4[nbin];
+
+/* mise a zero de l'histogramme */
+for ( q=phis ; q<phis+nbin ; *q++ = 0 )  ;
+under = over = tothis = 0;
+
+
+
+nbpix2 = nbpix = 0;
+min = ValSat+1.;
+max = ValNul-1;
+
+/*   Boucle sur les pixels   */
+/*     Pour aller plus vite, on prend un pixel sur 7   */
+for ( i = 0 ; i < xdim*ydim ; i += vitesse )
+  {
+  val = pim->IValue(i);
+
+   /*   Calcul PixMax/Min et NbPix sature  */
+  if (val > ValSat)  nbpix++;
+  else {
+    if(val < ValNul) nbpix2++;
+    else {
+	    if (val > max) max = val;
+	    else if (val < min) min = val;
+	}
+  }
+
+   /* remplissage de l'histogramme */
+  bin = (int)((val - minhis) / binwidth) ;
+  if ( bin < 0 )  under++;
+  else 
+    {
+    if (bin < nbin) { (*(phis+bin))++; tothis++; }
+    else   over++; 
+    }
+  }     /*  Fin de for : Boucle sur les pixels   */
+
+(*MinPix) = min; 
+(*MaxPix) = max;
+/*       Ne pas oublier le facteur vitesse pour le calcul FracSatue  */
+(*FracNul) = (float)(nbpix2 * vitesse) / (float)(xdim*ydim); 
+(*FracSature) = (float)(nbpix * vitesse) / (float)(xdim*ydim); 
+
+/*  On verifie qu'il y a eu une entree ds l'histo */
+if (tothis <= 0)
+  { delete[] phis;  return(2); }
+  
+/* recherche du maximum */
+binmax = -1 ; imax = -1 ; q = phis;
+for ( i = 0 ; i < nbin ;  i++, q++ )
+  if ( *(q) > imax ) {imax = *(q) ; binmax = i ;}
+
+if ( (binmax < 0) || (binmax >= nbin) )
+  { delete[] phis;  return(2); }
+
+*Fond = minhis + binmax * binwidth;   
+
+/*   On va chercher le sigma du fond  */
+imin = (int_4) ( (float)(imax) * FRACPIC ) ;
+
+/*
+printf("StatsDebug : min/maxhis  %g  %g  (nbin= %d) w=%g\n",
+        minhis,maxhis,nbin,binwidth);
+printf(".binmax= %d  imax(=pic) = %d  , imin= %d  \n ",binmax,imax,imin);   
+*/
+
+nbpix = 0;
+
+sigr = 0;
+q = phis+binmax;
+while ( ((*q) > imin) && (sigr < (nbin-binmax)) ) 
+  { sigr++; nbpix += (*q) ; q++; }
+
+sigl = 0;
+q = phis+binmax;
+while ( ((*q) > imin) && (sigl < binmax) ) 
+  { sigl++; nbpix += (*q) ; q--; }
+nbpix -= (*(phis+binmax));
+
+(*SigFond) = (float)(sigl+sigr)*binwidth/2.; 
+fracfond = (float)(nbpix) / (float)(tothis);
+
+(*MinAff) = minhis+(binmax-sigl)*binwidth;
+(*MaxAff) = minhis+(binmax+sigr)*binwidth;
+
+
+/*   Check sur NbSigmas  :  */
+if (NbSigmas == 0) NbSigmas = 1;
+if (NbSigmas < 0)    /*   On considere le cas ou NbSigmas est negatif   */
+  {
+  if ( (bin = binmax+NbSigmas*sigr) < 0 )  bin = 0;
+  (*MinAff) = minhis + (float)bin*binwidth;
+  if ( (bin = binmax-NbSigmas*sigr) >= nbin ) bin = nbin-1;
+  (*MaxAff) = minhis + (float)bin*binwidth;
+  goto sortie;
+  }
+
+if ( (bin = binmax+NbSigmas*sigl) >= nbin ) 
+  { delete[] phis;  return(4); }
+
+(*MinAff) = minhis + bin*binwidth;
+
+/*   Calcul du nb de pixel entre MinAff et ValSat  */
+nbpix = 0;
+for( q = phis+bin ; q < phis+nbin ; q++)  nbpix += (*q);
+
+fracsignal = (float)(nbpix) / (float)(tothis+over+under);
+nbpix = (int_4)((float)nbpix * FracMax);
+nbpix2 = 0; q = phis+bin; i = bin;
+while( (nbpix2 < nbpix) && (i < nbin) )  
+  { nbpix2 += (*q); i++; q++; }
+
+(*MaxAff) = minhis + (float)i*binwidth;
+
+
+sortie:        /*   On sort en liberant l'espace   */
+
+/*
+printf("  Stats..Debug : Fond,sigl,sigr,SigFond = %g,%d,%d,%g \n",
+(*Fond),sigl,sigr,(*SigFond));
+ printf("    Min/MaxPix= %g  %g , Min/MaxAff= %g  %g \n",(*MinPix),
+(*MaxPix),(*MinAff),(*MaxAff));
+printf("    FracFond,FracSignal %g  %g  FracNul,FracSat  %g  %g\n",
+       fracfond,fracsignal,(*FracNul),(*FracSature));   
+*/
+
+delete[] phis;
+if ( (*MaxAff) < ((*MinAff)+MINDYNAMIC) )  return(5);
+return(0);
+
+}
+
+
+// ********** INSTANCES
+
+#if defined(__xlC) || defined(__aCC__)
+void instancetempimageop(int n)
+{
+/* Cette fonction sert uniquement a forcer le compilo a instancier les
+  classes/fonctions template   */
+
+int m = n-50;
+ImageU2  iu2(n,n), *tiu2[5], xiu2(n,n);
+ImageI2  ii2(n,n), *tii2[5], xii2(n,n);
+ImageI4  ii4(n,n), *tii4[5], xii4(n,n);
+ImageR4  ir4(n,n), *tir4[5], xir4(n,n);
+
+ImageR4  matx(5,5);
+
+RzCmvSigmaCiel(iu2.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
+RzCmvSigmaCiel(ii2.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
+RzCmvSigmaCiel(ii4.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
+RzCmvSigmaCiel(ir4.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
+
+ImgFondCielHisto(iu2);
+ImgFondCielHisto(ii2);
+ImgFondCielHisto(ii4);
+ImgFondCielHisto(ir4);
+
+ImgSigmaCiel(iu2, 100, 1, 100);
+ImgSigmaCiel(ii2, 100, 1, 100);
+ImgSigmaCiel(ii4, 100, 1, 100);
+ImgSigmaCiel(ir4, 100, 1, 100);
+
+CleanImages(5, tiu2); 
+CleanImages(5, tii2); 
+CleanImages(5, tii4); 
+CleanImages(5, tir4); 
+
+FondLocal(iu2, (float)50., (float)50., (float)5., (float)7., (float)0.5, (float)0.9, 0);
+FondLocal(ii2, (float)50., (float)50., (float)5., (float)7., (float)0.5, (float)0.9, 0);
+FondLocal(ii4, (float)50., (float)50., (float)5., (float)7., (float)0.5, (float)0.9, 0);
+FondLocal(ir4, (float)50., (float)50., (float)5., (float)7., (float)0.5, (float)0.9, 0);
+
+FilterImage(&iu2, &xiu2, &matx);
+FilterImage(&ii2, &xii2, &matx);
+FilterImage(&ii4, &xii4, &matx);
+FilterImage(&ir4, &xir4, &matx);
+
+FilterStat(&iu2, &xiu2,(int)3,(int)3,(float)1.,(float)-1.);
+FilterStat(&ii2, &xii2,(int)3,(int)3,(float)1.,(float)-1.);
+FilterStat(&ii4, &xii4,(int)3,(int)3,(float)1.,(float)-1.);
+FilterStat(&ir4, &xir4,(int)3,(int)3,(float)1.,(float)-1.);
+
+CSplineImage(iu2,(double)1,(double)0,(double)0,(int)0);
+CSplineImage(ii2,(double)1,(double)0,(double)0,(int)0);
+CSplineImage(ii4,(double)1,(double)0,(double)0,(int)0);
+CSplineImage(ir4,(double)1,(double)0,(double)0,(int)0);
+
+return;
+}
+
+#endif
+
+
+#ifdef __CXX_PRAGMA_TEMPLATES__
+
+#pragma define_template RzCmvSigmaCiel<uint_2>
+#pragma define_template RzCmvSigmaCiel<int_2>
+#pragma define_template RzCmvSigmaCiel<int_4>
+#pragma define_template RzCmvSigmaCiel<r_4>
+
+#pragma define_template ImgFondCielHisto<uint_2>
+#pragma define_template ImgFondCielHisto<int_2>
+#pragma define_template ImgFondCielHisto<int_4>
+#pragma define_template ImgFondCielHisto<r_4>
+
+#pragma define_template ImgSigmaCiel<uint_2>
+#pragma define_template ImgSigmaCiel<int_2>
+#pragma define_template ImgSigmaCiel<int_4>
+#pragma define_template ImgSigmaCiel<r_4>
+
+#pragma define_template CleanImages<uint_2>
+#pragma define_template CleanImages<int_2>
+#pragma define_template CleanImages<int_4>
+#pragma define_template CleanImages<r_4>
+
+#pragma define_template FondLocal<uint_2>
+#pragma define_template FondLocal<int_2>
+#pragma define_template FondLocal<int_4>
+#pragma define_template FondLocal<r_4>
+
+#pragma define_template FilterImage<uint_2>
+#pragma define_template FilterImage<int_2>
+#pragma define_template FilterImage<int_4>
+#pragma define_template FilterImage<r_4>
+
+#pragma define_template FilterStat<uint_2>
+#pragma define_template FilterStat<int_2>
+#pragma define_template FilterStat<int_4>
+#pragma define_template FilterStat<r_4>
+
+#pragma define_template CSplineImage<uint_2>
+#pragma define_template CSplineImage<int_2>
+#pragma define_template CSplineImage<int_4>
+#pragma define_template CSplineImage<r_4>
+
+#endif
+
+
+#if ( defined(__ANSI_TEMPLATES__) && !defined(__aCC__) )
+template float RzCmvSigmaCiel<uint_2 const>(uint_2 const*, int, int, int, int, int, float, int, float, float, int);
+template float RzCmvSigmaCiel< int_2 const>( int_2 const*, int, int, int, int, int, float, int, float, float, int);
+template float RzCmvSigmaCiel< int_4 const>( int_4 const*, int, int, int, int, int, float, int, float, float, int);
+template float RzCmvSigmaCiel<   r_4 const>(   r_4 const*, int, int, int, int, int, float, int, float, float, int);
+template float ImgFondCielHisto<uint_2>(Image<uint_2> const&, float, int, float, float , float , int);
+template float ImgFondCielHisto< int_2>(Image< int_2> const&, float, int, float, float , float , int);
+template float ImgFondCielHisto< int_4>(Image< int_4> const&, float, int, float, float , float , int);
+template float ImgFondCielHisto<   r_4>(Image<   r_4> const&, float, int, float, float , float , int);
+template float ImgSigmaCiel<uint_2>(Image<uint_2> const& img, int, int, int, float, int, float , float, int);
+template float ImgSigmaCiel< int_2>(Image< int_2> const& img, int, int, int, float, int, float , float, int);
+template float ImgSigmaCiel< int_4>(Image< int_4> const& img, int, int, int, float, int, float , float, int);
+template float ImgSigmaCiel<   r_4>(Image<   r_4> const& img, int, int, int, float, int, float , float, int);
+template void CleanImages<uint_2>(int, Image<uint_2>**, double, double, double);
+template void CleanImages< int_2>(int, Image< int_2>**, double, double, double);
+template void CleanImages< int_4>(int, Image< int_4>**, double, double, double);
+template void CleanImages<   r_4>(int, Image<   r_4>**, double, double, double);
+
+template float FondLocal<uint_2>( Image<uint_2> const & image ,float xcentre ,
+			  float ycentre , float rayon1 ,float rayon2 ,
+			  float fraclow ,float frachigh , int lp) ;
+template float FondLocal< int_2>( Image<int_2> const & image ,float xcentre ,
+			  float ycentre , float rayon1 , float rayon2 ,
+			  float fraclow ,float frachigh , int lp) ;
+template float FondLocal< int_4>( Image<int_4> const & image ,float xcentre ,
+			  float ycentre , float rayon1 , float rayon2 ,
+			  float fraclow ,float frachigh , int lp) ;
+template float FondLocal<r_4>( Image<r_4> const & image ,float xcentre ,
+			  float ycentre , float rayon1 , float rayon2 ,
+			  float fraclow ,float frachigh , int lp) ;
+
+template Image<uint_2>* FilterImage<uint_2>(Image<uint_2> const *, Image<uint_2>*, ImageR4 *);
+template Image< int_2>* FilterImage< int_2>(Image< int_2> const *, Image< int_2>*, ImageR4 *);
+template Image< int_4>* FilterImage< int_4>(Image< int_4> const *, Image< int_4>*, ImageR4 *);
+template Image<   r_4>* FilterImage<   r_4>(Image<   r_4> const *, Image<   r_4>*, ImageR4 *);
+
+template Image<uint_2>* FilterStat<uint_2>(Image<uint_2> const *, Image<uint_2>*,int,int,float,float);
+template Image< int_2>* FilterStat< int_2>(Image< int_2> const *, Image< int_2>*,int,int,float,float);
+template Image< int_4>* FilterStat< int_4>(Image< int_4> const *, Image< int_4>*,int,int,float,float);
+template Image<   r_4>* FilterStat<   r_4>(Image<   r_4> const *, Image<   r_4>*,int,int,float,float);
+
+template Image<uint_2>* CSplineImage<uint_2>(Image<uint_2> const &,double,double,double,int);
+template Image< int_2>* CSplineImage< int_2>(Image< int_2> const &,double,double,double,int);
+template Image< int_4>* CSplineImage< int_4>(Image< int_4> const &,double,double,double,int);
+template Image<   r_4>* CSplineImage<   r_4>(Image<   r_4> const &,double,double,double,int);
+
+#endif
+
+
+#ifdef __GNU_TEMPLATES__
+template float RzCmvSigmaCiel(uint_2 const*, int, int, int, int, int, float, int, float, float, int);
+template float RzCmvSigmaCiel( int_2 const*, int, int, int, int, int, float, int, float, float, int);
+template float RzCmvSigmaCiel( int_4 const*, int, int, int, int, int, float, int, float, float, int);
+template float RzCmvSigmaCiel(   r_4 const*, int, int, int, int, int, float, int, float, float, int);
+template float ImgFondCielHisto(Image<uint_2> const&, float, int, float, float , float , int);
+template float ImgFondCielHisto(Image< int_2> const&, float, int, float, float , float , int);
+template float ImgFondCielHisto(Image< int_4> const&, float, int, float, float , float , int);
+template float ImgFondCielHisto(Image<   r_4> const&, float, int, float, float , float , int);
+template float ImgSigmaCiel(Image<uint_2> const& img, int, int, int, float, int, float , float, int);
+template float ImgSigmaCiel(Image< int_2> const& img, int, int, int, float, int, float , float, int);
+template float ImgSigmaCiel(Image< int_4> const& img, int, int, int, float, int, float , float, int);
+template float ImgSigmaCiel(Image<   r_4> const& img, int, int, int, float, int, float , float, int);
+template void CleanImages(int, Image<uint_2>**, double, double, double);
+template void CleanImages(int, Image< int_2>**, double, double, double);
+template void CleanImages(int, Image< int_4>**, double, double, double);
+template void CleanImages(int, Image<   r_4>**, double, double, double);
+
+template float FondLocal( Image<uint_2> const & image ,float xcentre ,
+			  float ycentre , float rayon1 ,float rayon2 ,
+			  float fraclow ,float frachigh , int lp) ;
+template float FondLocal( Image<int_2> const & image ,float xcentre ,
+			  float ycentre , float rayon1 , float rayon2 ,
+			  float fraclow ,float frachigh , int lp) ;
+template float FondLocal( Image<int_4> const & image ,float xcentre ,
+			  float ycentre , float rayon1 , float rayon2 ,
+			  float fraclow ,float frachigh , int lp) ;
+template float FondLocal( Image<r_4> const & image ,float xcentre ,
+			  float ycentre , float rayon1 , float rayon2 ,
+			  float fraclow ,float frachigh , int lp) ;
+
+template Image<uint_2>* FilterImage(Image<uint_2> const *, Image<uint_2>*, ImageR4 *);
+template Image< int_2>* FilterImage(Image< int_2> const *, Image< int_2>*, ImageR4 *);
+template Image< int_4>* FilterImage(Image< int_4> const *, Image< int_4>*, ImageR4 *);
+template Image<   r_4>* FilterImage(Image<   r_4> const *, Image<   r_4>*, ImageR4 *);
+
+template Image<uint_2>* FilterStat(Image<uint_2> const *, Image<uint_2>*,int,int,float,float);
+template Image< int_2>* FilterStat(Image< int_2> const *, Image< int_2>*,int,int,float,float);
+template Image< int_4>* FilterStat(Image< int_4> const *, Image< int_4>*,int,int,float,float);
+template Image<   r_4>* FilterStat(Image<   r_4> const *, Image<   r_4>*,int,int,float,float);
+
+template Image<uint_2>* CSplineImage(Image<uint_2> const &,double,double,double,int);
+template Image< int_2>* CSplineImage(Image< int_2> const &,double,double,double,int);
+template Image< int_4>* CSplineImage(Image< int_4> const &,double,double,double,int);
+template Image<   r_4>* CSplineImage(Image<   r_4> const &,double,double,double,int);
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/imageop.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/imageop.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/imageop.h	(revision 1307)
@@ -0,0 +1,65 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+// Operations non elementaires sur les images.
+// Les operations elementaires sont des methodes de la classe.
+
+//    C. Magneville  (Version C)  E. Aubourg / R. Ansari C++
+
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef IMAGEOP_H_SEEN
+#define IMAGEOP_H_SEEN
+
+#include "cimage.h"
+#include "cspline.h"
+
+template <class T>
+void CleanImages(int nImg, Image<T>** imgTab, double nSig=1,
+                 double lowbad=-1e20, double highbad=1e20);
+
+
+template <class T>
+float ImgFondCielHisto(Image<T> const& img, float binWidth=1, int degre=2, 
+                       float frac=0.5f,
+                       float low=-999999.0, float high=999999.0,
+                       int debug=0);
+template <class T>
+float ImgSigmaCiel(Image<T> const& img, int ndata, int binWidth, int taille,
+                   float frac=0.5f, int degre=2,
+                   float low=-999999.0, float high=999999.0,
+                   int debug=0);
+
+int CalFondImage(RzImage *pim, double low, double high, int action);
+
+int FondSigmaCiel(RzImage *pim, float low, float high, int pvsz=100
+              ,float nbsig1=3.5f,float nbsig2=7.f,float nbsig3=5.f
+              ,float binsg=0.5f,float frac=0.33f,int modu=1,int deb=0);
+
+int RzFondSig2Ciel(RzImage * pim, int vitesse, float FracMax, int NbSigmas, int NBin, 
+	               float *MinPix, float *MaxPix, float *Fond, float *SigFond,
+                   float *MinAff, float *MaxAff, float *FracNul, float *FracSature);
+
+template <class T>
+float FondLocal(Image<T> const & image, float xcentre, float ycentre,
+                float rayon1, float rayon2, float fraclow, float frachigh, int lp=0);
+
+// Filtrage / convolution d'images 
+
+template <class T>
+Image<T> * FilterImage(Image<T> const * pim, Image<T> * pom, ImageR4 *matx);
+
+///////////////////////////////////////////////////////////////////
+//// Filtre statistique d'images
+template <class T>
+Image<T> * FilterStat(Image<T> const * pim, Image<T> * pom
+                     ,int N,int M,float lowbad,float highbad);
+///////////////////////////////////////////////////////////////////
+//// Spline d'images
+template <class T>
+Image<T> * CSplineImage(Image<T> const& f1,double pxsz=1.,double x0=0.,double y0=0.
+                       ,int natural=(int)CSpline::NaturalAll);
+///////////////////////////////////////////////////////////////////
+
+
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/integ.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/integ.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/integ.cc	(revision 1307)
@@ -0,0 +1,474 @@
+#include "defs.h"
+#include "integ.h"
+#include "generalfit.h"
+
+// A faire :
+//   1 dans GLInteg, optimiser recalcul en utilisant des poids
+//     calcules sur [0,1] et chgt de variable
+//   2 dans GLInteg, distinction nStep = subdivisions de l'intervalle,
+//     et on applique GL d'ordre "ordre" sur chaque subdivision, en
+//     utilisant le (1)
+
+//++
+// Class	Integrator
+// Lib		Outils++ 
+// include	integ.h
+//
+//	Classe abstraite d'intégration numérique 1D.
+//	On fournit une fonction double f(double) au constructeur, ou
+//	une GeneralFunction avec des paramètres définis.
+//	L'objet Integrator est convertible en valeur double qui est la valeur
+//	de l'intégrale. Diverses méthodes permettent de choisir des options
+//	de calcul, et ces méthodes retournent une référence sur l'objet, pour
+//	permettre une notation chaînée.
+//--
+//++ 
+// Links	Implementations
+// TrpzInteg
+// GLInteg
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+Integrator::Integrator()
+//
+//	Constructeur par défaut. L'objet n'est pas utilisable en l'état.
+//--
+
+: mFunc(NULL), mGFF(NULL), mGFFParm(NULL),
+  mNStep(50), mDX(-1), mReqPrec(-1),
+  mXMin(0), mXMax(1)
+{}
+
+//++
+Integrator::Integrator(FUNC f, double xmin, double xmax)
+//
+//	Constructeur à partir de la fonction double->double, et des
+//	bornes d'intégration.
+//--
+: mFunc(f), mGFF(NULL), mGFFParm(NULL),
+  mNStep(50), mDX(-1), mReqPrec(-1),
+  mXMin(xmin), mXMax(xmax)
+{}
+
+//++
+Integrator::Integrator(FUNC f)
+// 
+//	Constructeur sans spécifier les bornes. Elles sont positionnées
+//	à [0,1], et on pourra les modifier plus tard.
+//--
+: mFunc(f), mGFF(NULL), mGFFParm(NULL),
+  mNStep(50), mDX(-1), mReqPrec(-1),
+  mXMin(0), mXMax(1)
+{}
+
+//++
+Integrator::Integrator(GeneralFunction* gff, double* par, double xmin, double xmax)
+//
+//	Constructeur à partir d'une GeneralFunction. La fonction doit être une
+//	fonction de une variable, et on fournit les valeurs des paramètres ainsi
+//	que les bornes d'intégration.
+//--
+: mFunc(NULL), mGFF(gff), mGFFParm(par),
+  mNStep(50), mDX(-1), mReqPrec(-1),
+  mXMin(xmin), mXMax(xmax)
+{
+  DBASSERT(gff->NVar() == 1);
+}
+
+//++
+Integrator::Integrator(GeneralFunction* gff, double* par)
+//
+//	Constructeur à partir d'une GeneralFunction. La fonction doit être une
+//	fonction de une variable, et on fournit les valeurs des paramètres. 
+//	On ne spécifie pas les bornes. Elles sont positionnées
+//	à [0,1], et on pourra les modifier plus tard.
+//--
+: mFunc(NULL), mGFF(gff), mGFFParm(par),
+  mNStep(50), mDX(-1), mReqPrec(-1),
+  mXMin(0), mXMax(1)
+{
+  DBASSERT(gff->NVar() == 1);
+}
+
+Integrator::~Integrator()
+{}
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+Integrator& 
+Integrator::NStep(int n)
+//
+//	Spécifie le nombre de pas pour l'intégration numérique.
+//	La signification peut dépendre de la méthode d'intégration.
+//--
+{
+  mNStep = n;
+  mDX = mReqPrec = -1;
+  StepsChanged();
+  return *this;
+}
+
+//++
+Integrator& 
+Integrator::DX(double d)
+//
+//	Spécifie le pas d'intégration.
+//	La signification peut dépendre de la méthode d'intégration.
+//--
+{
+  mDX = d;
+  mNStep = mReqPrec = -1;
+  StepsChanged();
+  return *this;
+}
+
+//++
+Integrator& 
+Integrator::ReqPrec(double p)
+//
+//	Spécifie la précision souhaitée. 
+//	La signification peut dépendre de la méthode d'intégration.
+//	Non disponible dans toutes les méthodes d'intégration.
+//--
+{
+  DBASSERT( !"Pas encore implemente !");
+  mReqPrec = p;
+  mDX = mNStep = -1;
+  StepsChanged();
+  return *this;
+}
+
+//++
+Integrator& 
+Integrator::Limits(double xmin, double xmax)
+//
+//	Spécifie les bornes de l'intégrale.
+//--
+{
+  mXMin = xmin;
+  mXMax = xmax;
+  LimitsChanged();
+  return *this;
+}
+
+//++
+Integrator& 
+Integrator::Func(FUNC f)
+//
+//	Spécifie la fonction à intégrer, sous forme double f(double).
+//--
+{
+  mFunc = f;
+  mGFFParm = NULL;
+  mFunc = NULL;
+  FuncChanged();
+  return *this;
+}
+
+//++
+Integrator& 
+Integrator::Func(GeneralFunction* gff, double* par)
+//
+//	Spécifie la fonction à intégrer, sous forme de GeneralFunction
+//	à une variable, et les paramètres sont fournis.
+//--
+{
+  mGFF = gff;
+  mGFFParm = par;
+  mFunc = NULL;
+  DBASSERT(gff->NVar() == 1);
+  FuncChanged();
+  return *this;
+}
+
+double
+Integrator::FVal(double x) const
+{
+  DBASSERT( mFunc || (mGFF && mGFFParm) );
+  return mFunc ? (*mFunc)(x) : mGFF->Value(&x, mGFFParm); 
+}
+
+double
+Integrator::ValueBetween(double xmin, double xmax)
+{
+  Limits(xmin,xmax);
+  return Value();
+}
+
+//++
+// Class	TrpzInteg
+// Lib		Outils++ 
+// include	integ.h
+//
+//	Classe d'intégration par la méthode des trapèzes.
+//	Voir Integrator pour les méthodes. Le nombre de pas
+//	est le nombre de trapèze, le pas d'intégration est
+//	la largeur des trapèzez. Impossible de demander une
+//	précision.
+//
+//--
+//++
+// Links	Parents
+// Integrator
+//--
+
+//++
+// Titre	Constructeurs
+//	Voir Integrator pour les détails.
+//--
+
+//++
+TrpzInteg::TrpzInteg()
+//
+//--
+{}
+
+//++
+TrpzInteg::TrpzInteg(FUNC f, double xmin, double xmax)
+//
+//--
+: Integrator(f, xmin, xmax)
+{}
+
+//++
+TrpzInteg::TrpzInteg(FUNC f)
+//
+//--
+: Integrator(f)
+{}
+
+//++
+TrpzInteg::TrpzInteg(GeneralFunction* gff, double* par, double xmin, double xmax)
+//
+//--
+: Integrator(gff, par, xmin, xmax)
+{}
+
+//++
+TrpzInteg::TrpzInteg(GeneralFunction* gff, double* par)
+//
+//--
+: Integrator(gff, par)
+{}
+
+TrpzInteg::~TrpzInteg()
+{}
+
+double
+TrpzInteg::Value()
+{
+  double dx = mDX;
+  double nstep = mNStep;
+
+  if (dx > 0)
+    nstep = (mXMax - mXMin)/dx;
+
+  if (nstep <= 0)
+    nstep = 10;
+
+  dx = (mXMax - mXMin) / nstep;
+
+  double s = (FVal(mXMin) + FVal(mXMax))/2;
+  double x = dx + mXMin;
+  for (int i=1; i<nstep; i++, x += dx)
+    s += FVal(x);
+    
+  return s * dx;
+}
+
+
+
+//++
+// Class	GLInteg
+// Lib		Outils++ 
+// include	integ.h
+//
+//	Classe d'intégration par la méthode de Gauss-Legendre.
+//	Voir Integrator pour les méthodes. 
+//	Pour le moment, nstep est l'ordre de la méthode.
+//	Il est prévu un jour de spécifier l'ordre, et que NStep
+//	découpe en intervalles sur chacun desquels on applique GL.
+//	Le principe de la méthode est de calculer les valeurs de la 
+//	fonction aux zéros des polynomes de Legendre. Avec les poids
+//	qui vont bien, GL d'ordre n est exacte pour des polynomes de 
+//	degré <= 2n+1.
+//	Impossible de demander une précision donnée.
+//
+//--
+//++
+// Links	Parents
+// Integrator
+//--
+
+//++
+// Titre	Constructeurs
+//	Voir Integrator pour les détails.
+//--
+
+
+
+
+//++
+GLInteg::GLInteg()
+//
+//--
+: mXPos(NULL), mWeights(NULL)
+{}
+
+
+//++
+GLInteg::GLInteg(FUNC f, double xmin, double xmax)
+//
+//--
+: Integrator(f, xmin, xmax), mXPos(NULL), mWeights(NULL), mOrder(8)
+{
+  NStep(1);
+}
+
+//++
+GLInteg::GLInteg(FUNC f)
+//
+//--
+: Integrator(f), mXPos(NULL), mWeights(NULL), mOrder(8)
+{
+  NStep(1);
+}
+
+//++
+GLInteg::GLInteg(GeneralFunction* gff, double* par, double xmin, double xmax)
+//
+//--
+: Integrator(gff, par, xmin, xmax), mXPos(NULL), mWeights(NULL), mOrder(8)
+{
+  NStep(1);
+}
+
+//++
+GLInteg::GLInteg(GeneralFunction* gff, double* par)
+//
+//--
+: Integrator(gff, par), mXPos(NULL), mWeights(NULL), mOrder(8)
+{
+  NStep(1);
+}
+
+GLInteg::~GLInteg()
+{
+  delete[] mXPos;
+  delete[] mWeights;
+  mXPos = mWeights = NULL;
+}
+
+void
+GLInteg::InvalWeights()
+{
+  delete[] mXPos;
+  delete[] mWeights;
+  mXPos = mWeights = NULL;
+}
+
+
+void
+GLInteg::LimitsChanged()
+{
+  ComputeBounds();
+}
+
+void
+GLInteg::StepsChanged()
+{
+  ComputeBounds();
+}
+
+GLInteg&
+GLInteg::AddBound(double x)
+{
+  if (x<=mXMin || x>=mXMax) THROW(rangeCheckErr); 
+  // On introduira les classes d'exections apres reflexion et de maniere systematique (Rz+cmv)
+  // if (x<=mXMin || x>=mXMax) throw range_error("GLInteg::AddBound  bound outside interval");
+  mBounds.insert(x);
+  return *this;
+}
+
+
+GLInteg&
+GLInteg::SetOrder(int order)
+{
+  mOrder = order;
+  InvalWeights();
+  return *this;
+}
+
+
+
+double
+GLInteg::Value()
+{
+  if (!mXPos) ComputeWeights();
+  double s = 0;
+  set<double>::iterator i=mBounds.begin();
+  set<double>::iterator j=i; j++;
+  while (j != mBounds.end()) {
+    double s1 = 0;
+    double x1 = *i;
+    double x2 = *j;
+    for (int k=0; k<mOrder; k++)
+       s1 += mWeights[k] * FVal(x1 + (x2-x1)*mXPos[k]);
+    s += s1*(x2-x1);
+    i++; j++;
+  }
+  return s;
+}
+
+void
+GLInteg::ComputeBounds()
+{
+  mBounds.erase(mBounds.begin(), mBounds.end());
+  for (int i=0; i<=mNStep; i++) 
+    mBounds.insert(mXMin + (mXMax-mXMin)*i/mNStep);
+}
+
+void
+GLInteg::ComputeWeights()
+{
+   const double EPS_gauleg = 3.0e-11;
+
+   int m=(mOrder+1)/2;
+   const double xxMin = 0;
+   const double xxMax = 1;
+   
+   mXPos    = new double[mOrder];
+   mWeights = new double[mOrder];
+   
+   double xm=0.5*(xxMax+xxMin);
+   double xl=0.5*(xxMax-xxMin);
+   for (int i=1;i<=m;i++)  {
+      double z=cos(3.141592654*(i-0.25)/(mOrder+0.5));
+      double z1, pp;
+      do {
+         double p1=1.0;
+         double p2=0.0;
+         for (int j=1;j<=mOrder;j++) {
+            double p3=p2;
+            p2=p1;
+            p1=((2.0*j-1.0)*z*p2-(j-1.0)*p3)/j;
+         }
+         pp=mOrder*(z*p1-p2)/(z*z-1.0);
+         z1=z;
+         z=z1-p1/pp;
+      } while (fabs(z-z1) > EPS_gauleg);
+      mXPos[i-1]         = xm-xl*z;
+      mXPos[mOrder-i]    = xm+xl*z;
+      mWeights[i-1]      = 2.0*xl/((1.0-z*z)*pp*pp);
+      mWeights[mOrder-i] = mWeights[i-1];
+   }
+
+}
+
Index: /tags/DPC_V0/SophyaLib/NTools/integ.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/integ.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/integ.h	(revision 1307)
@@ -0,0 +1,102 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// integ.h
+//
+// $Id: integ.h,v 1.1.1.1 1999-04-09 17:57:55 ansari Exp $
+//
+
+#ifndef INTEG_H_SEEN
+#define INTEG_H_SEEN
+
+#include "defs.h"
+#include "exceptions.h"
+#include <set>
+#if defined(__KCC__)
+#include <set.h>
+#endif
+
+class GeneralFunction;
+
+class Integrator EXC_AWARE {
+public:
+  typedef double(*FUNC)(double);
+
+  Integrator();
+  Integrator(FUNC, double xmin, double xmax);
+  Integrator(FUNC);
+  Integrator(GeneralFunction*, double* par, double xmin, double xmax);
+  Integrator(GeneralFunction*, double* par);
+  virtual ~Integrator();
+
+  virtual double Value() = 0;
+  virtual double ValueBetween(double xmin, double xmax);
+  virtual operator double() {return Value();}
+
+  virtual Integrator& NStep(int);
+  virtual Integrator& DX(double);
+  virtual Integrator& ReqPrec(double);   // NOT YET !
+  virtual Integrator& Limits(double xmin, double xmax);
+  virtual Integrator& Func(FUNC);
+  virtual Integrator& Func(GeneralFunction*, double* par);
+
+protected:
+  FUNC             mFunc;
+  GeneralFunction* mGFF;
+  double*          mGFFParm;
+
+  int              mNStep;   // -1 si pas fixe
+  double           mDX;
+  double           mReqPrec;
+  double           mXMin, mXMax;
+  
+  double           FVal(double x) const;
+  virtual void     LimitsChanged() {}
+  virtual void     StepsChanged() {}
+  virtual void     FuncChanged() {}
+};
+
+
+
+class TrpzInteg : public Integrator {
+public:
+  TrpzInteg();
+  TrpzInteg(FUNC, double xmin, double xmax);
+  TrpzInteg(FUNC);
+  TrpzInteg(GeneralFunction*, double* par, double xmin, double xmax);
+  TrpzInteg(GeneralFunction*, double* par);
+
+  ~TrpzInteg();
+
+  virtual double Value();
+};
+
+class GLInteg : public Integrator {
+public:
+  GLInteg();
+  GLInteg(FUNC, double xmin, double xmax);
+  GLInteg(FUNC);
+  GLInteg(GeneralFunction*, double* par, double xmin, double xmax);
+  GLInteg(GeneralFunction*, double* par);
+
+  ~GLInteg();
+
+  virtual double Value();
+  virtual GLInteg& AddBound(double x);
+  virtual GLInteg& SetOrder(int order);
+protected:
+
+  double* mXPos;     // integration entre 0 et 1
+  double* mWeights;  // integration entre 0 et 1
+  int     mOrder;    // ordre GL
+  set<double> mBounds; // limites des intervalles d'integration
+  
+  void ComputeWeights();
+  void LimitsChanged();
+  void StepsChanged();
+  void InvalWeights();
+  void ComputeBounds();
+};
+
+
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/linfit.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/linfit.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/linfit.cc	(revision 1307)
@@ -0,0 +1,118 @@
+#include "defs.h"
+#include "peida.h"
+#include "linfit.h"
+#include "matrix.h"
+#include "cvector.h"
+
+double LinFit(const Vector& x, const Vector& y, int nf, double (*f)(int, double), 
+	   Vector& c)
+{
+  int n = x.NElts();
+  if (n != y.NElts()) THROW(sizeMismatchErr);
+  
+  Matrix fx(nf, n);
+  for (int i=0; i<nf; i++)
+    for (int j=0; j<n; j++)
+      fx(i,j) = f(i,x(j));
+
+  return LinFit(fx,y,c);
+}
+
+
+
+double LinFit(const Matrix& fx, const Vector& y, Vector& c)
+{
+  int n = y.NElts();
+  if ( n != fx.NCol()) THROW(sizeMismatchErr);
+
+  int nf = fx.NRows();
+
+  Matrix a(nf,nf);
+
+  for (int j=0; j<nf; j++)
+    for (int k=j; k<nf; k++)
+      a(j,k) = a(k,j) = fx.Row(j) * fx.Row(k);
+   
+  c = fx * y;
+
+  if (Matrix::GausPiv(a,c) == 0) THROW(singMatxErr);
+
+  double xi2 = 0;
+
+  for (int k=0; k<n; k++) {
+    double x = 0;
+    for (int i=0; i<nf; i++)
+      x += c(i) * fx(i,k);
+    x -= y(k);
+    xi2 += x*x;
+  }
+  return xi2;
+}
+
+
+
+double LinFit(const Vector& x, const Vector& y, const Vector& errY2, int nf,
+	   double (*f)(int, double), Vector& c, Vector& errC)
+{
+  int n = x.NElts();
+  if (n != y.NElts()) THROW(sizeMismatchErr);
+  
+  Matrix fx(nf, n);
+  for (int i=0; i<nf; i++)
+    for (int j=0; j<n; j++)
+      fx(i,j) = f(i,x(j));
+
+  return LinFit(fx,y,errY2,c,errC);
+}
+
+
+double LinFit(const Matrix& fx, const Vector& y, const Vector& errY2,
+	   Vector& c, Vector& errC)
+{
+  int n = y.NElts();
+  if ( n != errY2.NElts()) THROW(sizeMismatchErr);
+  if ( n != fx.NCol()) THROW(sizeMismatchErr);
+
+  int nf = fx.NRows();
+
+  Matrix a(nf,nf);
+
+  c.Realloc(nf);
+  errC.Realloc(nf);
+
+  for (int j=0; j<nf; j++)
+    for (int k=j; k<nf; k++) {
+      double x=0;
+      for (int l=0; l<n; l++)
+	x += fx(j,l) * fx(k,l) / errY2(l);        // Matrice a inverser
+      a(j,k) = a(k,j) = x;
+    }
+ 
+  Matrix d(nf,nf+1);
+  for (int k=0; k<nf; k++) {
+    double x=0;
+    for (int l=0; l<n; l++)
+      x += fx(k,l) * y(l) / errY2(l);             // Second membre 1ere colonne
+    d(k,0) = x;
+    for (int m=1; m<=nf; m++)
+      d(k,m) = (k==m) ? 1 : 0;                // Reste second membre = Id.
+  }
+
+  if (Matrix::GausPiv(a,d) == 0) THROW(singMatxErr);
+
+  for (int l=0; l<nf; l++) {
+    c(l) = d(l,0);                            // Parametres = 1ere colonne
+    errC(l) = d(l,l+1);                        // Erreurs = diag inverse.
+  }
+
+  double xi2 = 0;
+
+  for (int jj=0; jj<n; jj++) {
+    double x = 0;
+    for (int ii=0; ii<nf; ii++)
+      x += c(ii) * fx(ii,jj);
+    x -= y(jj);
+    xi2 += x*x/errY2(jj);
+  }
+  return xi2;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/linfit.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/linfit.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/linfit.h	(revision 1307)
@@ -0,0 +1,41 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// $Id: linfit.h,v 1.1.1.1 1999-04-09 17:57:56 ansari Exp $
+//
+
+// Routines de fit lineaire, avec ou sans erreurs, en fournissant
+// les fonctions ou les valeurs.
+#ifndef LINFIT_SEEN
+#define LINFIT_SEEN
+
+class Matrix;
+class Vector;
+
+
+double LinFit(const Vector& x, const Vector& y, int nf,
+	   double (*f)(int, double), Vector& c);
+// fit lineaire des y en tant que somme de c(i)f(i,x), i=0..nf-1;
+
+
+double LinFit(const Matrix& fx, const Vector& y, Vector& c);
+// fit lineaire des y en tant que somme de c(i)f(i,x), i=0..nf-1,
+// la matrice fx contient les valeurs des f:
+// fx(i,j) = f(i, x(j)).
+		      
+
+double LinFit(const Vector& x, const Vector& y, const Vector& errY2, int nf,
+	   double (*f)(int, double), Vector& c, Vector& errC);
+// fit lineaire des y en tant que somme de c(i)f(i,x), i=0..nf-1,
+// errY2 contient les carres des erreurs sur les Y.
+// au retour, errC contient les erreurs sur les coefs.
+
+
+double LinFit(const Matrix& fx, const Vector& y, const Vector& errY2,
+	   Vector& c, Vector& errC);
+// fit lineaire des y en tant que somme de c(i)f(i,x), i=0..nf-1,
+// la matrice fx contient les valeurs des f:
+// fx(i,j) = f(i, x(j)).
+// errY2 contient les carres des erreurs sur les Y.
+// au retour, errC contient les erreurs sur les coefs.
+
+#endif // LINFIT_SEEN 
Index: /tags/DPC_V0/SophyaLib/NTools/matrix.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/matrix.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/matrix.cc	(revision 1307)
@@ -0,0 +1,1006 @@
+// $Id: matrix.cc,v 1.1.1.1 1999-04-09 17:57:56 ansari Exp $
+
+#include "defs.h"
+#include <string.h>
+#include <iostream.h>
+#include <iomanip.h>
+#include <values.h>
+#include "peida.h"
+#include "matrix.h"
+#include "cvector.h"
+#include "generalfit.h"
+
+// Sous Linux, LN_MAXDOUBLE LN_MINDOUBLE ne semblent pas etre definies
+//   Reza 11/02/99
+#ifndef M_LN2
+#define M_LN2 0.69314718055994530942
+#endif
+#ifndef LN_MINDOUBLE
+#define LN_MINDOUBLE  (M_LN2 * (DMINEXP - 1))
+#endif
+#ifndef LN_MAXDOUBLE
+#define LN_MAXDOUBLE  (M_LN2 * DMAXEXP)
+#endif
+
+
+//++
+// Class	Matrix
+// Lib	Outils++
+// include	matrix.h
+//
+//	Classe générale de matrice, calculs matriciels et algèbre linéaire.
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+Matrix::Matrix()
+//
+//	Construit une matrice 1x1 (pour ppersist).
+//--
+: nr(1), nc(1), ndata(1), nalloc(1), data(new double[1])
+{
+  // if (r<=0 || c<=0) THROW(rangeCheckErr);
+  memset(data, 0, nalloc*sizeof(double));
+  END_CONSTRUCTOR
+}
+
+//++
+Matrix::Matrix(int r, int c)
+//
+//	Construit une matrice de r lignes et c colonnes.
+//--
+: nr(r), nc(c), ndata(r*c), nalloc(r*c), data(new double[r*c])
+{
+  // if (r<=0 || c<=0) THROW(rangeCheckErr);
+  memset(data, 0, nalloc*sizeof(double));
+  END_CONSTRUCTOR
+}
+
+//++
+Matrix::Matrix(int r, int c, double* values)
+//
+//	Construit une matrice de r lignes et c colonnes. On fournit
+//	le tableau des valeurs : pas d'allocation.
+//--
+: nr(r), nc(c), ndata(r*c), nalloc(0), data(values)
+{
+  END_CONSTRUCTOR
+}
+
+//++
+Matrix::Matrix(const Matrix& a)
+//
+//	Constructeur par copie.
+//--
+: nr(a.nr), nc(a.nc), ndata(a.nr*a.nc), nalloc(a.nr*a.nc),
+  data(new double[a.nr*a.nc])
+{
+  memcpy(data, a.data, nalloc * sizeof(double));
+  END_CONSTRUCTOR
+}
+
+
+Matrix::~Matrix()
+{
+  DBASSERT(ndata == nr*nc);
+  if (nalloc) delete[] data;
+}
+
+//++
+// Titre	Méthodes
+//--
+
+
+//++
+void Matrix::Zero()
+//
+//	Remise à zero de tous les éléments
+//--
+{
+  DBASSERT(ndata == nr*nc);
+  for (int i=0; i<ndata; i++)
+    data[i] = 0;
+}
+
+//++
+void Matrix::Realloc(int r, int c, bool force)
+//
+//	Change la taille de la matrice. Réallocation physique seulement si
+//	pas assez de place, ou forcée si force=true.
+//--
+{
+  DBASSERT(ndata == nr*nc);
+  if (!nalloc) THROW(allocationErr);
+  int ncop = ndata;                      // ancien elements
+  ndata = r*c;
+  if (ndata < ncop) ncop = ndata;
+  nr = r;
+  nc = c;
+  if (nalloc < ndata || force) {
+    double* p = new double[ndata];
+    memcpy(p,data,ncop * sizeof(double));
+    delete[] data;
+    data = p;
+    nalloc = ndata;
+  } else if (nalloc != ndata)                 // Sans doute facultatif, mais plus
+    memset(data+ndata, 0, (nalloc-ndata)*sizeof(double));  //propre
+}
+
+//++
+Matrix& Matrix::operator = (const Matrix& a)
+//
+//	Opérateur d'affectation.
+//--
+{
+  if (this == &a) return *this;
+  Realloc(a.nr, a.nc);
+  memcpy(data, a.data, ndata * sizeof(double));
+  return *this;
+}
+
+
+//++
+Matrix& Matrix::operator = (double x)
+//
+//	Opérateur d'affectation depuis scalaire : identité * scalaire.
+//--
+{
+  if (nr != nc) THROW(sizeMismatchErr);
+  for (int r=0; r<nr; r++)
+    for (int c=0; c<nc; c++)
+      (*this)(r,c) = (r==c) ? x : 0.0;
+  return *this;
+}
+
+//++
+// r_8& [const]         operator()(int r, int c) [const]
+//	Accès aux éléments
+//--
+
+//++
+ostream& operator << (ostream& s, const Matrix& a)
+//
+//	Impression
+//--
+{
+  for (int r=0; r<a.nr; r++) {
+    s << "| ";
+    for (int c=0; c<a.nc; c++)
+      s << setw(6) << a(r,c) << " ";
+    s << "|\n";
+    }
+  return s;
+}
+
+// ****************** MATRIX / SCALAR ******************************
+
+
+//++
+Matrix& Matrix::operator *= (double b)
+//
+//--
+{
+  double* p    = data;
+  double* pEnd = data + ndata;
+
+  while (p < pEnd)
+    *p++ *= b;
+
+  return *this;
+}
+
+//++
+Matrix& Matrix::operator += (double b)
+//
+//--
+{
+  double* p    = data;
+  double* pEnd = data + ndata;
+
+  while (p < pEnd)
+    *p++ += b;
+
+  return *this;
+}
+
+//++
+Matrix& Matrix::operator -= (double b)
+//
+//--
+{
+  double* p    = data;
+  double* pEnd = data + ndata;
+
+  while (p < pEnd)
+    *p++ -= b;
+
+  return *this;
+}
+
+//++
+Matrix& Matrix::operator /= (double b)
+//
+//--
+{
+  DBASSERT( b != 0. );
+  double* p    = data;
+  double* pEnd = data + ndata;
+
+  while (p < pEnd)
+    *p++ /= b;
+
+  return *this;
+}
+
+//++
+Matrix operator * (const Matrix& a, double b)
+//
+//--
+{
+  Matrix result(a);
+  return (result *= b);
+}
+
+//++
+Matrix operator * (double b, const Matrix& a)
+//
+//--
+{
+  Matrix result(a);
+  return (result *= b);
+}
+
+//++
+Matrix operator + (const Matrix& a, double b)
+//
+//--
+{
+  Matrix result(a);
+  return (result += b);
+}
+
+//++
+Matrix operator + (double b, const Matrix& a)
+//
+//--
+{
+  Matrix result(a);
+  return (result += b);
+}
+
+//++
+Matrix operator - (const Matrix& a, double b)
+//
+//--
+{
+  Matrix result(a);
+  return (result -= b);
+}
+
+//++
+Matrix operator - (double b, const Matrix& a)
+//
+//--
+{
+  Matrix result(a);
+  result *= -1;
+  return (result += b);
+}
+
+//++
+Matrix operator / (const Matrix& a, double b)
+//
+//--
+{
+  Matrix result(a);
+  return (result /= b);
+}
+
+//++
+Matrix operator * (const Matrix& a, int b)
+//
+//--
+{
+  Matrix result(a);
+  return (result *= b);
+}
+
+//++
+Matrix operator * (int b, const Matrix& a)
+//
+//--
+{
+  Matrix result(a);
+  return (result *= b);
+}
+
+//++
+Matrix operator + (const Matrix& a, int b)
+//
+//--
+{
+  Matrix result(a);
+  return (result += b);
+}
+
+//++
+Matrix operator + (int b, const Matrix& a)
+//
+//--
+{
+  Matrix result(a);
+  return (result += b);
+}
+
+//++
+Matrix operator - (const Matrix& a, int b)
+//
+//--
+{
+  Matrix result(a);
+  return (result -= b);
+}
+
+//++
+Matrix operator - (int b, const Matrix& a)
+//
+//--
+{
+  Matrix result(a);
+  result *= -1;
+  return (result += b);
+}
+
+//++
+Matrix operator / (const Matrix& a, int b)
+//
+//--
+{
+  Matrix result(a);
+  return (result /= b);
+}
+
+
+// **************** MATRIX / MATRIX ***********************88
+
+//++
+Matrix& Matrix::operator += (const Matrix& a)
+//
+//--
+{
+  if (nc!=a.nc || nr!=a.nr) THROW(sizeMismatchErr);
+
+  double* p    = data;
+  double* pEnd = data + ndata;
+  double* q    = a.data;
+
+  while (p < pEnd)
+    *p++ += *q++;
+
+  return *this;
+}
+
+//++
+Matrix& Matrix::operator -= (const Matrix& a)
+//
+//--
+{
+  if (nc!=a.nc || nr!=a.nr) THROW(sizeMismatchErr);
+
+  double* p    = data;
+  double* pEnd = data + ndata;
+  double* q    = a.data;
+
+  while (p < pEnd)
+    *p++ -= *q++;
+
+  return *this;
+}
+
+
+//++
+Matrix& Matrix::operator *= (const Matrix& a)
+//
+//--
+{
+  if (nc != a.nc || nr != a.nr || nc != nr) THROW(sizeMismatchErr);
+
+  double* oldRow = new double[nr];
+  double* orEnd = oldRow + nc;
+  double* orp;
+  double* trp;
+
+  for (double* tr = data; tr < data+ndata; tr += nc) {
+    for (orp = oldRow, trp = tr;
+         orp < orEnd;)
+      *orp++ = *trp++;
+
+    double* ac;
+    double* acp;
+
+    for (trp = tr, ac = a.data; ac< a.data+nr; ac++, trp++) {
+      double sum = 0;
+      for (orp = oldRow, acp = ac; acp < ac+ndata; acp += nr, orp++)
+        sum += *orp * *acp;
+      *trp = sum;
+    }
+  }
+  delete[] oldRow;
+  return *this;
+}
+
+//++
+Matrix operator + (const Matrix& a, const Matrix& b)
+//
+//--
+{
+  if (b.nc != a.nc || b.nr != a.nr) THROW(sizeMismatchErr);
+
+  Matrix c(a);
+  return (c += b);
+}
+
+//++
+Matrix operator - (const Matrix& a, const Matrix& b)
+//
+//--
+{
+  if (b.nc != a.nc || b.nr != a.nr) THROW(sizeMismatchErr);
+
+  Matrix c(a);
+  return (c -= b);
+}
+
+#if 0
+
+Matrix operator * (const Matrix& a, const Matrix& b)
+{
+  if (a.nc != b.nr) THROW(sizeMismatchErr);
+
+  Matrix c(a.nr, b.nc);
+
+  double* pc = c.data;
+
+  double* pa = a.data;
+
+  double* pb = b.data;
+
+  for (int rc = 0; rc < c.nr; rc++) {
+    for (int cc = 0; cc < c.nc; cc++) {      // boucle sur c
+      double sum = 0;
+      for (int ca = 0; ca < a.nc; ca++) {     // boucle sur a & b
+        sum += *pa * *pb;
+        pa++;
+        pb += b.nc;
+      }
+      *pc++ = sum;
+      pa -= a.nc;                           // retour meme ligne
+      pb -= b.ndata - 1;                    // haut de la colonne suiv
+    }
+                                            // ligne suivante c
+    pb = b.data;                            // en revient en b(1,1)
+    pa += a.nc;                             // debut ligne suivante
+  }
+
+  return c;
+}
+#endif
+
+//++
+Matrix operator * (const Matrix& a, const Matrix& b)
+//
+//--
+{
+  if (a.nc != b.nr) THROW(sizeMismatchErr);
+
+  Matrix c(a.nr, b.nc);
+
+  for (int rc = 0; rc < c.nr; rc++)
+    for (int cc = 0; cc < c.nc; cc++) {      // boucle sur c
+      double sum = 0;
+      for (int ca = 0; ca < a.nc; ca++)     // boucle sur a & b
+        sum += a(rc,ca) * b(ca,cc);
+      c(rc,cc) = sum;
+    }
+
+  return c;
+
+}
+
+
+//++
+Matrix Matrix::Transpose() const
+//
+//	Retourne la transposée.
+//--
+#if HAS_NAMED_RETURN
+return a(nc,nr)
+#endif
+{
+#if !HAS_NAMED_RETURN
+Matrix a(nc,nr);
+#endif
+  for (int i=0; i<nr; i++)
+    for (int j=0; j<nc; j++)
+      a(j,i) = (*this)(i,j);
+#if !HAS_NAMED_RETURN
+return a;
+#endif
+}
+
+
+//++
+Matrix Matrix::Inverse() const
+//
+//	Retourne la matrice inverse.
+//
+//	*Exception* : singMatxErr si la matrice est singulière.
+//--
+#if HAS_NAMED_RETURN
+return b(nr,nc)
+#endif
+{
+#if !HAS_NAMED_RETURN
+Matrix b(nc,nr);
+#endif
+  Matrix a(*this);
+  b = 1.0;
+  if (fabs(Matrix::GausPiv(a,b)) < 1.e-50) THROW(singMatxErr);
+#if !HAS_NAMED_RETURN
+return b;
+#endif
+}
+
+
+void Matrix::WriteSelf(POutPersist& s) const
+{
+  DBASSERT(ndata == nr*nc);
+  s << nr << nc;
+  s.PutR8s(data, ndata);
+}
+
+void Matrix::ReadSelf(PInPersist& s)
+{
+  int_4 r,c;
+  s >> r >> c;
+  Realloc(r,c);
+  DBASSERT(ndata == nr*nc);
+  s.GetR8s(data, ndata);
+}
+
+
+MatrixRC::MatrixRC()
+: matrix(0), data(0), index(0), step(0)
+{}
+
+MatrixRC::MatrixRC(Matrix& m, RCKind rckind, int ind)
+: matrix(&m), data(Org(m,rckind,ind)),
+  index(ind), step(Step(m,rckind)), kind(rckind)
+{
+  if (kind == matrixDiag & m.nc != m.nr) THROW(sizeMismatchErr);
+}
+
+
+int MatrixRC::Next()
+{
+  if (!matrix) return -1;             // Failure ?
+  if (kind == matrixDiag) return -1;  // Failure ?
+  index++;
+  if (kind == matrixRow) {
+    if (index > matrix->nr) {
+      index = matrix->nr;
+      return -1;
+    }
+    data += matrix->nc;
+  } else {
+    if (index > matrix->nc) {
+      index = matrix->nc;
+      return -1;
+    }
+    data++;
+  }
+  return index;
+}
+
+
+int MatrixRC::Prev()
+{
+  if (!matrix) return -1;             // Failure ?
+  if (kind == matrixDiag) return -1;  // Failure ?
+  index--;
+  if (index < 0) {
+    index = 0;
+    return -1;
+  }
+  if (kind == matrixRow)
+    data -= matrix->nc;
+  else
+    data--;
+  return index;
+}
+
+
+int MatrixRC::SetCol(int c)
+{
+  if (!matrix) return -1;             // Failure ?
+  if (c<0 || c>matrix->nc) return -1;
+  kind = matrixCol;
+  index = c;
+  step = Step(*matrix, matrixCol);
+  data = Org(*matrix, matrixCol, c);
+  return c;
+}
+
+
+int MatrixRC::SetRow(int r)
+{
+  if (!matrix) return -1;             // Failure ?
+  if (r<0 || r>matrix->nr) return -1;
+  kind = matrixRow;
+  index = r;
+  step = Step(*matrix, matrixRow);
+  data = Org(*matrix, matrixRow, r);
+  return r;
+}
+
+
+int MatrixRC::SetDiag()
+{
+  if (!matrix) return -1;             // Failure ?
+  if (matrix->nc != matrix->nr) THROW(sizeMismatchErr);
+  kind = matrixDiag;
+  index = 0;
+  step = Step(*matrix, matrixDiag);
+  data = Org(*matrix, matrixDiag);
+  return 0;
+}
+
+
+MatrixRC& MatrixRC::operator = (const MatrixRC& rc)
+{
+  matrix = rc.matrix;
+  data   = rc.data;
+  index  = rc.index;
+  step   = rc.step;
+  kind   = rc.kind;
+  return *this;
+}
+
+//MatrixRC::operator Vector() const
+Vector MatrixRC::GetVect() const
+#if HAS_NAMED_RETURN
+return v(NElts())
+#endif
+{
+#if !HAS_NAMED_RETURN
+  Vector v(NElts());
+#endif
+  int n = NElts();
+  for (int i=0; i<n; i++)
+    v(i) = (*this)(i);
+#if !HAS_NAMED_RETURN
+  return v;
+#endif
+}
+
+
+MatrixRC& MatrixRC::operator += (const MatrixRC& rc)
+{
+  int n = NElts();
+  if ( n != rc.NElts() ) THROW(sizeMismatchErr);
+  if ( kind != rc.kind ) THROW(sizeMismatchErr);
+
+  for (int i=0; i<n; i++)
+    (*this)(i) += rc(i);
+
+  return *this;
+}
+
+
+
+MatrixRC& MatrixRC::operator -= (const MatrixRC& rc)
+{
+  int n = NElts();
+  if ( n != rc.NElts() ) THROW(sizeMismatchErr);
+  if ( kind != rc.kind ) THROW(sizeMismatchErr);
+
+  for (int i=0; i<n; i++)
+    (*this)(i) -= rc(i);
+
+  return *this;
+}
+
+
+MatrixRC& MatrixRC::operator *= (double x)
+{
+  int n = NElts();
+
+  for (int i=0; i<n; i++)
+    (*this)(i) *= x;
+
+  return *this;
+}
+
+
+MatrixRC& MatrixRC::operator /= (double x)
+{
+  int n = NElts();
+
+  for (int i=0; i<n; i++)
+    (*this)(i) /= x;
+
+  return *this;
+}
+
+
+MatrixRC& MatrixRC::operator -= (double x)
+{
+  int n = NElts();
+
+  for (int i=0; i<n; i++)
+    (*this)(i) -= x;
+
+  return *this;
+}
+
+
+MatrixRC& MatrixRC::operator += (double x)
+{
+  int n = NElts();
+
+  for (int i=0; i<n; i++)
+    (*this)(i) += x;
+
+  return *this;
+
+}
+
+
+double operator * (const MatrixRC& a, const MatrixRC& b)
+{
+  int n = a.NElts();
+  if ( n != b.NElts() ) THROW(sizeMismatchErr);
+  if ( a.kind != b.kind ) THROW(sizeMismatchErr);
+  double sum = 0;
+  for (int i=0; i<n; i++)
+    sum += a(i)*b(i);
+  return sum;
+}
+
+
+MatrixRC& MatrixRC::LinComb(double a, double b, const MatrixRC& rc, int first)
+{
+  int n = NElts();
+  if ( n != rc.NElts() ) THROW(sizeMismatchErr);
+  if ( kind != rc.kind ) THROW(sizeMismatchErr);
+
+  for (int i=first; i<n; i++)
+    (*this)(i) = (*this)(i)*a + rc(i)*b;
+
+  return *this;
+}
+
+
+MatrixRC& MatrixRC::LinComb(double b, const MatrixRC& rc, int first)
+{
+  int n = NElts();
+  if ( n != rc.NElts() ) THROW(sizeMismatchErr);
+  if ( kind != rc.kind ) THROW(sizeMismatchErr);
+
+  for (int i=first; i<n; i++)
+    (*this)(i) += rc(i)*b;
+
+  return *this;
+}
+
+
+
+MatrixRC Matrix::Row(int r) const
+#if HAS_NAMED_RETURN
+return rc((Matrix&)*this, matrixRow, r)
+#endif
+{
+#if !HAS_NAMED_RETURN
+        MatrixRC rc((Matrix&)*this, matrixRow, r);
+        return rc;
+#endif
+}
+
+
+MatrixRC Matrix::Col(int c) const
+#if HAS_NAMED_RETURN
+return rc((Matrix&)*this, matrixCol, c)
+#endif
+{
+#if !HAS_NAMED_RETURN
+        MatrixRC rc((Matrix&)*this, matrixCol, c);
+        return rc;
+#endif
+}
+
+
+MatrixRC Matrix::Diag() const
+#if HAS_NAMED_RETURN
+return rc((Matrix&)*this, matrixDiag)
+#endif
+{
+#if !HAS_NAMED_RETURN
+        MatrixRC rc((Matrix&)*this, matrixDiag);
+        return rc;
+#endif
+}
+
+
+int MatrixRC::IMaxAbs(int first)
+{
+  int n=NElts();
+  if (first>n) THROW(rangeCheckErr);
+  int imax=first;
+  double vmax = fabs((*this)(first));
+  double v;
+  for (int i=first+1; i<n; i++)
+    if ((v=fabs((*this)(i))) > vmax) {
+      vmax = v;
+      imax = i;
+    }
+  return imax;
+}
+
+
+void MatrixRC::Swap(MatrixRC& rc1, MatrixRC& rc2)
+{
+  int n=rc1.NElts();
+  if (n != rc2.NElts()) THROW(sizeMismatchErr);
+  if (rc1.kind != rc2.kind) THROW(sizeMismatchErr);
+  if (rc1.data == rc2.data) return; // C'est le meme
+  for (int i=0; i<n; i++)
+    {double tmp = rc1(i); rc1(i) = rc2(i); rc2(i) = tmp;}
+}
+
+
+
+double Matrix::GausPiv(Matrix& a, Matrix& b)
+{
+  int n = a.NRows();
+  if ( n != b.NRows()) THROW(sizeMismatchErr);
+
+  // On fait une normalisation un peu brutale...
+  double vmin=MAXDOUBLE;
+  double vmax=0;
+  for (int iii=0; iii<a.NRows(); iii++)
+    for (int jjj=0; jjj<a.NCol(); jjj++) {
+      if (fabs(a(iii,jjj)) > vmax) vmax = fabs(a(iii,jjj));
+      if (fabs(a(iii,jjj)) < vmin && fabs(a(iii,jjj))>0) vmin = fabs(a(iii,jjj));
+    }
+  double nrm = sqrt(vmin*vmax);
+  if (nrm > 1.e5 || nrm < 1.e-5) {
+    a /= nrm;
+    b /= nrm;
+    //cout << "normalisation matrice " << nrm << endl;
+  } else 
+    nrm=1;
+
+  double det = 1.0;
+  if (nrm != 1) {
+    double ld = a.NRows() * log(nrm);
+    if (ld <= LN_MINDOUBLE || ld >= LN_MAXDOUBLE) {
+     // cerr << "Matrix warning, overflow for det" << endl;
+    } else {
+      det = exp(ld);
+    }
+  }
+
+  MatrixRC pivRowa(a,matrixRow);
+  MatrixRC pivRowb(b,matrixRow);
+
+  for (int k=0; k<n-1; k++) {
+    int iPiv = a.Col(k).IMaxAbs(k);
+    if (iPiv != k) {
+      MatrixRC aIPiv(a.Row(iPiv));
+      MatrixRC aK(a.Row(k));
+      MatrixRC::Swap(aIPiv,aK);
+      MatrixRC bIPiv(b.Row(iPiv));
+      MatrixRC bK(b.Row(k));
+      MatrixRC::Swap(bIPiv,bK);
+    }
+    double pivot = a(k,k);
+    if (fabs(pivot) < 1.e-50) return 0.0;
+    //det *= pivot;
+    pivRowa.SetRow(k); // to avoid constructors
+    pivRowb.SetRow(k);
+    for (int i=k+1; i<n; i++) {
+      double r = -a(i,k)/pivot;
+      a.Row(i).LinComb(r, pivRowa); // + rapide que -= r * pivRowa
+      b.Row(i).LinComb(r, pivRowb);
+    }
+  }
+  det *= a(n-1, n-1);
+
+  // on remonte
+
+  for (int kk=n-1; kk>0; kk--) {
+    double pivot = a(kk,kk);
+    if (fabs(pivot) <= 1.e-50) return 0.0;
+    pivRowa.SetRow(kk); // to avoid constructors
+    pivRowb.SetRow(kk);
+    for (int jj=0; jj<kk; jj++) {
+      double r = -a(jj,kk)/pivot;
+      a.Row(jj).LinComb(r, pivRowa);
+      b.Row(jj).LinComb(r, pivRowb);
+    }
+  }
+
+ 
+  for (int l=0; l<n; l++) {
+    if (fabs(a(l,l)) <= 1.e-50) return 0.0;
+    b.Row(l) /= a(l,l);
+  }
+
+  return det;
+}
+
+//++
+double Matrix::Norm1()
+//
+//	Norme 1 : somme des valeurs absolues.
+//--
+{
+  double s = 0;
+  for (int k = 0; k < nr*nc; k++)
+    s += fabs(data[k]);
+  return s;
+}
+
+//++
+double Matrix::Norm2()
+//
+//	Norme 2, euclidienne.
+//--
+{
+  double s = 0;
+  for (int k = 0; k < nr*nc; k++)
+    s += data[k] * data[k];
+  return sqrt(s);
+}
+
+//////////////////////////////////////////////////////////
+//++
+Matrix* Matrix::FitResidus(GeneralFit& gfit)
+//
+//	Retourne une classe contenant les residus du fit ``gfit''.
+//	On suppose que x=j (colonnes) et y=i (lignes) pour m(i,j).
+//--
+{
+if(NCol()<=0||NRows()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+Matrix* m = new Matrix(*this);
+for(int i=0;i<NRows();i++) for(int j=0;j<NCol();j++) {
+  double x[2] = {(double)j,(double)i};
+  (*m)(i,j) -= f->Value(x,par.Data());
+}
+return m;
+}
+
+//++
+Matrix* Matrix::FitFunction(GeneralFit& gfit)
+//
+//	Retourne une classe contenant la fonction du fit ``gfit''.
+//	On suppose que x=j (colonnes) et y=i (lignes) pour m(i,j).
+//--
+{
+if(NCol()<=0||NRows()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+Matrix* m = new Matrix(*this);
+for(int i=0;i<NRows();i++) for(int j=0;j<NCol();j++) {
+  double x[2] = {(double)j,(double)i};
+  (*m)(i,j) = f->Value(x,par.Data());
+}
+return m;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/matrix.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/matrix.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/matrix.h	(revision 1307)
@@ -0,0 +1,292 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Eric Aubourg, Septembre 94
+#ifndef MATRIX_SEEN
+#define MATRIX_SEEN
+
+#define RGCHECK
+
+#include <stdio.h>
+#include <iostream.h>
+#include "peida.h"
+#include "ppersist.h"
+
+class GeneralFit;
+
+// <summary> Operations matricielles </summary>
+// Operations matricielles, algebre lineaire...
+class Matrix : public PPersist {
+  friend class Vector;
+  friend class MatrixRC;
+public:
+  Matrix();
+  // Constructeur, matrice a zero
+  Matrix(int r, int c);
+  // Constructeur avec des valeurs. Pas d'allocation, juste pointe.
+  Matrix(int r, int c, double* values);
+  // Constructeur par copie
+  Matrix(const Matrix& a);
+  // Destructeur
+  virtual ~Matrix();
+
+  // Construction automatique pour PPF
+  // <group>
+  enum {classId = ClassId_Matrix};
+  int_4                 ClassId() const         { return classId; }
+  static PPersist*      Create() {return new Matrix(1,1);}
+  // </group>
+
+  // Remise a zero de tous les elements
+  void Zero();
+  // Change la taille de la matrice. Reallocation physique seulement si
+  // pas assez de place, ou forcee si force=true
+  void Realloc(int r, int c, bool force=false);
+
+  // Operateur d'affectation
+  Matrix& operator = (const Matrix& a);
+  // Affectation depuis scalaire : identite * scalaire
+  Matrix& operator = (double x);
+
+  // Impression
+  friend ostream& operator << (ostream& s, const Matrix& a);
+
+  // Acces aux elements
+  // <group>
+  r_8&          operator()(int r, int c);
+  r_8 const&    operator()(int r, int c) const;
+  // </group>
+
+  // Acces au tableau des elements
+  // <group>
+  inline r_8* Data() {return data;}
+  inline const r_8* Data() const {return data;}
+  // </group>
+  // Norme 1 : somme des valeurs absolues
+  double  Norm1();
+  // Norme 2, euclidienne
+  double  Norm2();
+  
+  // Operations matricielles avec scalaire, allocation d'une nouvelle matrice
+  // <group>
+  friend Matrix operator * (const Matrix& a, double b);
+  friend Matrix operator * (double b, const Matrix& a);
+  friend Matrix operator + (const Matrix& a, double b);
+  friend Matrix operator + (double b, const Matrix& a);
+  friend Matrix operator - (const Matrix& a, double b);
+  friend Matrix operator - (double b, const Matrix& a);
+  friend Matrix operator / (const Matrix& a, double b);
+  // </group>
+
+  // Operations matricielles avec scalaires entiers, pour eviter l'appel
+  // du constructeur de vecteur a partir d'un entier...
+  // sinon v*2 = v * Vector(2), BUG !
+  // <group>
+  friend Matrix operator * (const Matrix& a, int b);
+  friend Matrix operator * (int b, const Matrix& a);
+  friend Matrix operator + (const Matrix& a, int b);
+  friend Matrix operator + (int b, const Matrix& a);
+  friend Matrix operator - (const Matrix& a, int b);
+  friend Matrix operator - (int b, const Matrix& a);
+  friend Matrix operator / (const Matrix& a, int b);
+  // </group>
+
+  // Operations matricielles "en place", avec scalaire
+  // <group>
+  Matrix& operator *= (double b);
+  Matrix& operator += (double b);
+  Matrix& operator -= (double b);
+  Matrix& operator /= (double b);
+  // </group>
+
+  // Operations matricielles
+  // <group>
+  friend Matrix operator * (const Matrix& a, const Matrix& b);
+  friend Matrix operator + (const Matrix& a, const Matrix& b);
+  friend Matrix operator - (const Matrix& a, const Matrix& b);
+
+  Matrix& operator *= (const Matrix& a);
+  Matrix& operator += (const Matrix& b);
+  Matrix& operator -= (const Matrix& b);
+  // </group>
+
+  // Matrice transposee
+  Matrix Transpose() const;
+  // Matrice inverse
+  // <thrown> singMatxErr </thrown>
+  Matrix Inverse() const;
+
+  // Nombre de lignes
+  inline int NRows() const {return nr;}
+  // Nombre de colonnes
+  inline int NCol()  const {return nc;}
+
+  // Entrees-sorties PPF
+  // <group>
+  void ReadSelf(PInPersist&);
+  void WriteSelf(POutPersist&) const;
+  // </group>
+
+  // Acces aux rangees et colonnes
+  // <group>
+  MatrixRC Row(int r) const;
+  MatrixRC Col(int c) const;
+  MatrixRC Diag() const;
+  // </group>
+  /* Versions const ? Alors il faut constructeur const pour MatrixRC,    */
+  /* mais MatrixRC contient un Matrix* qui detruit const....             */
+  /* mais en eux-meme, ils ne modifient pas la matrice. Ils permettent   */
+  /* de le faire...                                                      */
+
+  // Pivot de Gauss : diagonalise la matrice A, en effectuant les memes
+  // operations sur la matrice B
+  static double GausPiv(Matrix& A, Matrix& B);
+
+  // Residus et fonction fittees.
+  Matrix* FitResidus(GeneralFit& gfit);
+  Matrix* FitFunction(GeneralFit& gfit);
+
+protected:
+  int_4 nr;
+  int_4 nc;
+  int ndata;
+  int nalloc;
+  r_8* data;
+};
+
+
+inline r_8& Matrix::operator()(int r, int c)
+{
+#ifdef RGCHECK
+  if (r<0 || r>=nr || c<0 || c>=nc) THROW(rangeCheckErr);
+#endif
+  return(data[r*nc + c]);
+}
+
+
+inline r_8 const& Matrix::operator()(int r, int c) const
+{
+#ifdef RGCHECK
+  if (r<0 || r>=nr || c<0 || c>=nc) THROW(rangeCheckErr);
+#endif
+  return(data[r*nc + c]);
+}
+
+enum RCKind {matrixRow=0, matrixCol=1, matrixDiag=2};
+
+
+// <summary> Acces aux lignes et colonnes des matrices </summary>
+// Permet d'acceder a une ligne ou colonne d'une matrice, en place, comme
+// avec un vecteur.
+class MatrixRC EXC_AWARE {
+friend class Vector;
+friend class Matrix;
+public:
+  MatrixRC();
+
+  virtual ~MatrixRC() {}
+
+  int Next();
+  int Prev();
+  int SetCol(int c);
+  int SetRow(int r);
+  int SetDiag();
+
+  static int Step(const Matrix& m, RCKind rckind);
+  static double* Org(const Matrix&, RCKind rckind, int ind=0);
+
+  int NElts() const;
+  r_8& operator()(int i);
+  r_8  operator()(int i) const;
+
+  MatrixRC& operator = (const MatrixRC& rc);
+  //operator Vector() const;
+  Vector GetVect() const;
+
+  MatrixRC& operator += (const MatrixRC& rc);
+  MatrixRC& operator -= (const MatrixRC& rc);
+
+  MatrixRC& operator *= (double x);
+  MatrixRC& operator /= (double x);
+  MatrixRC& operator -= (double x);
+  MatrixRC& operator += (double x);
+
+  friend double operator * (const MatrixRC& a, const MatrixRC& b);
+
+  MatrixRC& LinComb(double a, double b, const MatrixRC& rc, int first=0);
+  MatrixRC& LinComb(double b, const MatrixRC& rc, int first=0);
+
+  int IMaxAbs(int first=0);
+
+  static void Swap(MatrixRC& rc1, MatrixRC& rc2);
+  // comme c'est symetrique, soit c'est static MatrixRC, soit static Matrix,
+  // soit Matrix avec verification qu'on parle bien de la meme...
+
+protected:
+  MatrixRC(Matrix& m, RCKind kind, int index=0);
+  Matrix* matrix;
+  r_8*    data;
+  int     index;
+  int     step;
+  RCKind  kind;
+};
+
+
+inline int MatrixRC::Step(const Matrix& m, RCKind rckind)
+{
+  switch (rckind)
+    {
+    case matrixRow  :
+      return 1;
+    case matrixCol  :
+      return m.nc;
+    case matrixDiag :
+      return m.nc+1;
+    }
+  return -1;
+}
+
+
+inline double* MatrixRC::Org(const Matrix& m, RCKind rckind, int index)
+{
+  switch (rckind)
+    {
+    case matrixRow :
+      return m.data + index * m.nc;
+    case matrixCol :
+      return m.data + index;
+    case matrixDiag :
+      return m.data;
+    }
+  return (double*) -1;
+}
+
+
+inline int MatrixRC::NElts() const
+{
+  if (!matrix) return -1;             // Failure ?
+  switch (kind)
+    {
+    case matrixRow :
+      return matrix->nc;
+    case matrixCol :
+      return matrix->nr;
+    case matrixDiag :
+      return matrix->nc;
+    }
+  return -1;
+}
+
+
+
+inline  double& MatrixRC::operator()(int i)
+{
+  return data[i*step];
+}
+
+
+inline  double MatrixRC::operator()(int i) const
+{
+  return data[i*step];
+}
+
+#endif /* MATRIX_SEEN */
+
Index: /tags/DPC_V0/SophyaLib/NTools/matxop.c
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/matxop.c	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/matxop.c	(revision 1307)
@@ -0,0 +1,904 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <math.h>
+
+
+#include "matxop.h"
+#include "nbmath.h"
+
+/*  Fonctions de manipulation de matrices et de vecteurs    */
+/*  Resolution de systemes lineaires                        */
+
+/*                              R. Ansari  Juillet 1993     */
+/*                              LaSilla (Chili)             */
+
+
+#define MXXFLOAT        1.e36
+
+
+
+/* Nouvelle-Fonction */
+
+int IVecxVec(int *v1, int *v2, int n)
+
+/*  Produit scalaire de deux vecteurs entiers       */
+/*  Retour (int) = v1(n) . v2(n)                    */
+
+{
+register int i,rc;
+register int *ip1, *ip2;
+
+ip1 = v1;  ip2 = v2;
+rc = 0;
+/* for(i=0; i<n; i++)  rc += *(ip1+i) * *(ip2+i); */
+for(i=0; i<n; i++)  rc += *ip1++ * *ip2++;
+return(rc);
+}
+
+
+/* Nouvelle-Fonction */
+
+float RVecxVec(float *v1, float *v2, int n)
+
+/*  Produit scalaire de deux vecteurs reels           */
+/*  Retour (float) = v1(n) . v2(n)                    */
+
+{
+register int i;
+register float rc;
+register float *fp1, *fp2;
+
+fp1 = v1;  fp2 = v2;
+rc = 0.0;
+/* for(i=0; i<n; i++)  rc += *(fp1+i) * *(fp2+i); */
+for(i=0; i<n; i++)  rc += *fp1++ * *fp2++;
+return(rc);
+}
+
+
+/* Nouvelle-Fonction */
+
+double DVecxVec(double *v1, double *v2, int n)
+
+/*  Produit scalaire de deux vecteurs double          */
+/*  Retour (float) = v1(n) . v2(n)                    */
+
+{
+register int i;
+register double rc;
+register double *fp1, *fp2;
+
+fp1 = v1;  fp2 = v2;
+rc = 0.0;
+/* for(i=0; i<n; i++)  rc += *(fp1+i) * *(fp2+i); */
+for(i=0; i<n; i++)  rc += *fp1++ * *fp2++;
+return(rc);
+}
+
+
+/* Nouvelle-Fonction */
+
+void  IMatxVec(int *mx, int *vi, int *vo, int n)
+
+/*  Matrice * Vecteur  (Entiers)     Integer           */
+/*  Vecteur Vo(n) = Matrice Mx(n,n) . Vi(n)            */
+
+{
+register  int *vp, *mxp;
+register int s;
+register int j,i;
+
+vp = vi;   mxp = mx;
+
+for (i=0; i<n; i++)
+  { s = 0;  
+  for(j=0; j<n; j++)   s += *(mxp+j) * *(vp+j);
+  *(vo+i) = s;  mxp += n; }
+
+return;
+}
+
+
+/* Nouvelle-Fonction */
+
+void  RMatxVec(float *mx, float *vi, float *vo, int n)
+
+/*  Matrice * Vecteur  (Reels)     float               */
+/*  Vecteur Vo(n) = Matrice Mx(n,n) . Vi(n)            */
+
+
+/*  Matrice * Vecteur  (Reels)  */
+{
+register  float *vp, *mxp;
+register float s;
+register int j,i;
+
+vp = vi;   mxp = mx;
+
+for (i=0; i<n; i++)
+  { s = 0;  
+  for(j=0; j<n; j++)   s += *(mxp+j) * *(vp+j);
+  *(vo+i) = s;  mxp += n; }
+
+return;
+}
+
+
+/* Nouvelle-Fonction */
+
+void  DMatxVec(double *mx, double *vi, double *vo, int n)
+
+/*  Matrice * Vecteur  (double)     double             */
+/*  Vecteur Vo(n) = Matrice Mx(n,n) . Vi(n)            */
+
+
+/*  Matrice * Vecteur  (Reels)  */
+{
+register  double *vp, *mxp;
+register double s;
+register int j,i;
+
+vp = vi;   mxp = mx;
+
+for (i=0; i<n; i++)
+  { s = 0;  
+  for(j=0; j<n; j++)   s += *(mxp+j) * *(vp+j);
+  *(vo+i) = s;  mxp += n; }
+
+return;
+}
+
+
+
+
+/* Nouvelle-Fonction */
+
+float SolveRLinSyst(float *mx, float *b, float *x, int n)
+
+/*  Resolution de systeme lineaire                           */
+/*  Matrice Mx(n,n) * Vecteur X(n) = Vecteur B(n)            */
+/*  Inconnu : vecteur X                                      */
+/*  Retour = Determinant du systeme (=0 Pb)  et X[]          */
+/*  Note : Au retour le vecteur B(n) et la matrice Mx(n,n)   */
+/*  sont modifies. Mx(n,n) contient une matrice triangulaire */
+/*  superieure                                               */                          
+
+{
+int i,k;
+register int j;
+register float *fp1, *fp2;
+double det;
+float vt1;
+register float vt2;
+register float six;
+int pivok;
+
+
+#define  MINPIVOT   1.e-15
+#define  MINDETER   1.e-15
+
+
+
+for (i=0; i<n-1; i++)   /*  Boucle sur les pivots */
+  {
+
+/*  printf("\n Iteration %d : \n",i);
+  for (k=0; k<n; k++)
+    {
+    for (j=0; j<n; j++)  printf(" %10g ",*(mx+k*n+j));
+    printf("    b= %10g \n",*(b+k));
+    }  */
+
+  fp1 = fp2 = mx+i*n;  
+  vt1 = *(fp1+i) ;
+
+  if ((vt1 < MINPIVOT) && (vt1 > -MINPIVOT) )   /* Pivot trop petit  */
+    {
+    pivok = 0;
+    for (k=i+1; k<n; k++)
+      {
+      vt1 = *(mx+k*n+i) ;
+      if ((vt1 > MINPIVOT) || (vt1 < -MINPIVOT) )
+        {
+        fp2 = mx+k*n;  
+        for (j=i; j<n; j++)
+          {
+          *(fp1+j) += *(fp2+j);
+          }
+        *(b+i) += *(b+k);
+        vt1 = *(fp1+i) ;  
+        fp2 = fp1;
+        pivok = 1;
+        break;
+        }
+      }
+    if (!pivok)  return(0.0);
+    }    
+
+  for (k=i+1; k<n; k++)
+    {
+    fp1 += n;
+    vt2 = *(fp1+i) / vt1 ; 
+    for (j=i+1; j<n; j++)  
+      *(fp1+j) -= (vt2 * *(fp2+j));
+
+    *(fp1+i) = 0.0;  
+    *(b+k) -= (vt2 * *(b+i)) ;
+    }
+
+  }
+
+/*   Calcul du determinant  */
+det = 1.0;
+for (i=0; i<n; i++)  det *= *(mx+i*n+i);
+if ((det < MINDETER) && (det > -MINDETER) )  return(0.0);
+if (det > MXXFLOAT)  det = MXXFLOAT;
+if (det < -MXXFLOAT)  det = -MXXFLOAT;
+
+
+for(i=n-1; i>=0; i--)
+  {
+  fp1 = mx+i*n;
+  six = *(b+i);
+  for (j=i+1; j<n; j++)  six -= (x[j] * *(fp1+j) );
+  x[i] = six / (*(fp1+i));
+
+/*  printf("  Solution X[%2d] = %g \n",i,x[i]);  */
+  }
+
+return(det);
+}
+
+
+
+
+
+/* Nouvelle-Fonction */
+
+double SolveDLinSyst(double *mx, double *b, double *x, int n)
+
+/*  Resolution de systeme lineaire                           */
+/*  Matrice Mx(n,n) * Vecteur X(n) = Vecteur B(n)            */
+/*  Inconnu : vecteur X                                      */
+/*  Retour = Determinant du systeme (=0 Pb)  et X[]          */
+/*  Note : Au retour le vecteur B(n) et la matrice Mx(n,n)   */
+/*  sont modifies. Mx(n,n) contient une matrice triangulaire */
+/*  superieure                                               */                          
+
+{
+int i,k;
+register int j;
+register double *fp1, *fp2;
+double det;
+double vt1;
+register double vt2;
+register double six;
+int pivok;
+
+
+#define  DMINPIVOT   1.e-25
+#define  DMINDETER   1.e-30
+
+
+
+for (i=0; i<n-1; i++)   /*  Boucle sur les pivots */
+  {
+
+/*  printf("\n Iteration %d : \n",i);
+  for (k=0; k<n; k++)
+    {
+    for (j=0; j<n; j++)  printf(" %10g ",*(mx+k*n+j));
+    printf("    b= %10g \n",*(b+k));
+    }  */
+
+  fp1 = fp2 = mx+i*n;  
+  vt1 = *(fp1+i) ;
+
+  if ((vt1 < DMINPIVOT) && (vt1 > -DMINPIVOT) )   /* Pivot trop petit  */
+    {
+    pivok = 0;
+    for (k=i+1; k<n; k++)
+      {
+      vt1 = *(mx+k*n+i) ;
+      if ((vt1 > DMINPIVOT) || (vt1 < -DMINPIVOT) )
+        {
+        fp2 = mx+k*n;  
+        for (j=i; j<n; j++)
+          {
+          *(fp1+j) += *(fp2+j);
+          }
+        *(b+i) += *(b+k);
+        vt1 = *(fp1+i) ;  
+        fp2 = fp1;
+        pivok = 1;
+        break;
+        }
+      }
+    if (!pivok)  return(0.0);
+    }    
+
+  for (k=i+1; k<n; k++)
+    {
+    fp1 += n;
+    vt2 = *(fp1+i) / vt1 ; 
+    for (j=i+1; j<n; j++)  
+      *(fp1+j) -= (vt2 * *(fp2+j));
+
+    *(fp1+i) = 0.0;  
+    *(b+k) -= (vt2 * *(b+i)) ;
+    }
+
+  }
+
+/*   Calcul du determinant  */
+det = 1.0;
+for (i=0; i<n; i++)  det *= *(mx+i*n+i);
+if ((det < DMINDETER) && (det > -DMINDETER) )  return(0.0);
+if (det > MXXFLOAT)  det = MXXFLOAT;
+if (det < -MXXFLOAT)  det = -MXXFLOAT;
+
+
+for(i=n-1; i>=0; i--)
+  {
+  fp1 = mx+i*n;
+  six = *(b+i);
+  for (j=i+1; j<n; j++)  six -= (x[j] * *(fp1+j) );
+  x[i] = six / (*(fp1+i));
+
+/*  printf("  Solution X[%2d] = %g \n",i,x[i]);  */
+  }
+
+return(det);
+}
+
+
+
+
+/*    ==============================================================  */
+/*   Fonctions de Fit lineaire de Xi2                                 */
+/*    ==============================================================  */
+
+/*   .......... Fit avec vecteurs depart reels ...............      */
+
+static int FFBusy = -1;                /*  Flag Deja Busy (GetFitVect effectue)  */
+static int FNVarMax = 0;               /*  Nb Maxi de variables a ajuster        */
+static int FVLenMax = 0;               /*  Longueur maxi des vecteurs            */
+static float **FVeci = NULL;           /*  Vecteurs en entree  *Vecf = Y         */
+                                       /*                      *(Vecf+i) = X[i]  */
+static float **FVecf = NULL;           /*  Vecteurs *FVecf = *FVecf+2 = B = M.X  */                                           
+                                       /*           *(FVecf+1) = La sortie = Ai  */
+static float *FVSpace = NULL;          /*  Espace pour les *FVeci                */  
+static float *FVSpacef = NULL;         /*    "   "    "    *FVecf                */
+static double  *FFMtx = NULL;          /*  Matrice a inverser = M                */
+static double  *FFMtx2 = NULL;         /*   Copie de M                           */
+static double  *FFSort = NULL;         /*  RFitLinErr() pour Sortie GausPiv()    */
+                                       /*  FNVarMax Lignes * (FNVarMax+1) Col.   */
+                                       /*  Col1= Solution, Col2..N+1 : MatInv    */        
+
+
+int InitRFitLin(int nvarmx, int szv)
+
+/*  Initialisation du fit de Xi2 Entier             */
+/*  Allocation d'espace memoire                     */
+/*  nvarmx = Nb maxi de variable                    */
+/*  szv = Taille maxi des vecteurs de points        */
+
+{
+int i;
+
+FFBusy = -1;
+nvarmx ++;
+if (nvarmx < 7)  nvarmx = 7;
+if (szv < 25) szv = 25;
+
+if ( (FVeci = malloc(nvarmx*sizeof(float *))) == NULL )
+  { printf("InitRFitLin_Erreur: (Pb malloc(Veci)) \n");
+  return(1);
+  }
+
+if ( (FVSpace = malloc(nvarmx*szv*sizeof(float))) == NULL )
+  { printf("InitRFitLin_Erreur: (Pb malloc(VSpace)) \n");
+  free(FVeci);
+  return(2);
+  }
+
+for(i=0; i<nvarmx; i++)  *(FVeci+i) = FVSpace+i*szv;
+
+
+if ( (FVecf = malloc(3*sizeof(float *))) == NULL )
+  { printf("InitRFitLin_Erreur: (Pb malloc(Vecf)) \n");
+  free(FVeci);
+  free(FVSpace);
+  return(3);
+  }
+
+if ( (FVSpacef = malloc(3*szv*sizeof(float))) == NULL )
+  { printf("InitRFitLin_Erreur: (Pb malloc(VSpacef)) \n");
+  free(FVeci);
+  free(FVSpace);
+  free(FVecf);
+  return(4);
+  }
+
+for(i=0; i<3; i++)  *(FVecf+i) = FVSpacef+i*szv;
+
+
+if ( (FFMtx = malloc(nvarmx*nvarmx*sizeof(double))) == NULL )
+  { printf("InitRFitLin_Erreur: (Pb malloc(FMtx)) \n");
+  free(FVeci);
+  free(FVSpace);
+  free(FVecf);
+  free(FVSpacef);
+  return(5);
+  }
+
+if ( (FFMtx2 = malloc(nvarmx*nvarmx*sizeof(double))) == NULL )
+  { printf("InitRFitLin_Erreur: (Pb malloc(FMtx2)) \n");
+  free(FVeci);
+  free(FVSpace);
+  free(FVecf);
+  free(FVSpacef);
+  free(FFMtx);
+  return(6);
+  }
+
+if ( (FFSort = malloc((nvarmx+1)*nvarmx*sizeof(double))) == NULL )
+  { printf("InitRFitLin_Erreur: (Pb malloc(FFSort)) \n");
+  free(FVeci);
+  free(FVSpace);
+  free(FVecf);
+  free(FVSpacef);
+  free(FFMtx);
+  free(FFMtx2);
+  return(7);
+  }
+
+FFBusy = 0;
+FNVarMax = nvarmx-1;
+FVLenMax = szv;
+
+return(0);
+}
+
+
+/* Nouvelle-Fonction */
+void EndRFitLin()
+{
+
+if (FVeci != NULL)  free(FVeci);
+if (FVSpace != NULL)  free(FVSpace);
+if (FVecf != NULL)  free(FVecf);
+if (FVSpacef != NULL)  free(FVSpacef);
+if (FFMtx != NULL)  free(FFMtx);
+if (FFMtx2 != NULL)  free(FFMtx2);
+if (FFSort != NULL)  free(FFSort);
+
+FVeci = NULL;
+FVSpace = NULL;
+FVecf = NULL;
+FVSpacef = NULL;
+FFMtx = NULL;
+FFMtx2 = NULL;
+
+FFBusy = -1;
+FNVarMax = 0;
+FVLenMax = 0;
+return;
+}
+
+
+/* Nouvelle-Fonction */
+
+float **GetRFitVect(int nvar, int vsz)
+/*  reservation de l'espace des vecteurs pour le fit  */
+{
+int nvmx, vszmx;
+
+if (FFBusy > 0)  
+  { printf("GetRFitVect_Erreur:  FFBusy= %d \n",FFBusy);
+  return(NULL);  }
+if ((nvar < 1) || (vsz < 1) )  
+  { printf("GetRFitVect_Erreur:  NVar,VSz= %d %d \n",nvar,vsz);
+  return(NULL);  }
+if ((nvar > FNVarMax) || (vsz > FVLenMax) || (FFBusy < 0))
+  {
+  EndRFitLin();
+  if (nvar > FNVarMax)   nvmx = nvar;
+  else  nvmx = FNVarMax;
+  if (vsz > FVLenMax)  vszmx = vsz;
+  else vszmx = FVLenMax;
+  if (InitRFitLin(nvmx, vszmx) != 0)  return(NULL);
+  }
+
+FFBusy = 1;
+return(FVeci);
+}
+
+
+/* Nouvelle-Fonction */
+void FreeRFitVect()
+{
+FFBusy = 0;
+return;
+}
+
+/* Nouvelle-Fonction */
+
+float RFitLin(int nd, int vsz, float *XVar)
+
+/*  Effectue le fit de Xi2 pour nd inconnu, Taille vecteurs vsz */
+/*  Les vecteurs doivent etre remplis auparavant                */
+/*  Retourne la valeur du Xi2 du fit, Negatif si Pb.            */
+
+{
+int i,j;
+register float *ip;
+register float *fp, *fp2;
+register double x;
+register float y;
+register float *ffmtx, *ffmtx2;
+float det, rc;
+
+
+if ((nd > FNVarMax) || (vsz > FVLenMax) )   {rc = -1000.0;  goto Fin; }
+
+/*  Fabrication matrice du syteme lineaire a resoudre  */
+ffmtx = (float *)FFMtx;
+ffmtx2 = (float *)FFMtx2;
+for(i=0; i<nd; i++)
+  {
+  fp = ffmtx+i*nd;   fp2 = ffmtx2+i*nd;
+  ip = *(FVeci+i+1);
+
+/*  Elements diagonals  */
+  *(fp2+i) = *(fp+i) = RVecxVec( ip, ip, vsz) ;  
+ 
+  for(j=i+1; j<nd; j++)  
+    {                /* Les autres elements  */
+    *(fp2+j) = *(fp+j) = RVecxVec( ip, *(FVeci+j+1), vsz) ;
+  /* Matrice symetrique */ 
+    *(ffmtx2+j*nd+i) = *(ffmtx+j*nd+i) = *(fp+j);  
+    }
+
+/*  Second membre  M.X = B   */
+  fp = *FVecf;  fp2 = *(FVecf+2);
+  *(fp2+i) = *(fp+i) = RVecxVec( ip, *FVeci, vsz) ;
+  
+  }
+
+/*  On resoud le systeme lineaire : */
+det = SolveRLinSyst(ffmtx, *FVecf, *(FVecf+1), nd);
+if (det == 0.0)   {rc = -500.0;  goto Fin; }
+
+/*  On calcule le Xi2  */
+x = RVecxVec( *FVeci, *FVeci, vsz);
+fp = *(FVecf+2);  
+for(i=0; i<nd; i++)
+  {
+  XVar[i] = y = *(*(FVecf+1)+i);  
+  fp2 = ffmtx2+i*nd+i;   
+  x += (y * y * *fp2);
+  x -= ( 2.0 * ( y * *(fp+i) ) );
+  for (j=i+1; j<nd; j++)  
+    { fp2++;  
+    x += 2.0 * y * *(*(FVecf+1)+j) * *fp2 ;  }    
+  }
+
+rc = (float)x;
+
+Fin:
+FreeRFitVect();
+return(rc);
+}
+
+
+
+/* Nouvelle-Fonction */
+
+float RFitLinErr(int nd, int vsz, float *XVar, float *Err)
+
+/*  Effectue le fit de Xi2 pour nd inconnu, Taille vecteurs vsz */
+/*  Les vecteurs doivent etre remplis auparavant                */
+/*  Retourne la valeur du Xi2 du fit, Negatif si Pb.            */
+
+{
+int i,j,md;
+register float *ip;
+register double *dp, *dp2;
+register float *fp;
+register double x,y;
+float rc;
+double det;
+
+
+if ((nd > FNVarMax) || (vsz > FVLenMax) )   {rc = -1000.0;  goto Fin; }
+
+md = nd+1;  
+/*  Mise a zero de la matrice de sortie et creation matrice identite */
+for(i=0; i<nd*md; i++)  FFSort[i] = 0.;
+for(i=1; i<nd*md; i += md+1) FFSort[i] = 1.;  
+
+/*  Fabrication matrice du syteme lineaire a resoudre  */
+
+for(i=0; i<nd; i++)
+  {
+  dp = FFMtx+i*nd;   dp2 = FFMtx2+i*nd;
+  ip = *(FVeci+i+1);
+
+/*  Elements diagonals  */
+  *(dp+i) = *(dp2+i) = RVecxVec( ip, ip, vsz) ;  
+ 
+  for(j=i+1; j<nd; j++)  
+    {                /* Les autres elements  */
+    *(dp+j) = *(dp2+j) = RVecxVec( ip, *(FVeci+j+1), vsz) ;
+  /* Matrice symetrique */ 
+    *(FFMtx+j*nd+i) = *(FFMtx2+j*nd+i) = *(dp+j);  
+    }
+
+/*  Second membre  M.X = B   */
+  dp = FFSort+i*md;  fp = *(FVecf+2);  
+  *dp = *(fp+i) = RVecxVec( ip, *FVeci, vsz) ;
+  
+  }
+
+
+/*  Appel GausPiv pour resoudre le systeme et inverser la matrice */
+det = GausPiv(FFMtx, nd, nd, FFSort, md, md, 0);
+/* printf("Det= %g Resul= %g %g %g \n",det,FFSort[0], FFSort[md], FFSort[2*md]); */
+if (det == 0.0)  {rc = -500.0;  goto Fin; } 
+ 
+/*  On calcule le Xi2   Et remplissage vecteurs sortie */
+
+x = RVecxVec( *FVeci, *FVeci, vsz);
+fp = *(FVecf+2);  
+for(i=0; i<nd; i++)
+  {
+  y = FFSort[1+i*(md+1)]; 
+  Err[i] = (y >= 0.) ? (float)sqrt(y) : -(float)sqrt(-y);
+  XVar[i]= y =FFSort[i*md];
+ 
+  dp2 = FFMtx2+i*nd+i;  
+  x += (y * y * *dp2);
+  x -= ( 2.0 * ( y * (double)*(fp+i) ) );
+  for (j=i+1; j<nd; j++)  
+    { dp2++;  
+    x += 2.0 *  y * FFSort[j*md] * *dp2 ;  }    
+  }
+rc = (float)x;
+
+Fin:
+FreeRFitVect();
+return(rc);
+}
+
+
+
+
+/*   .......... Fit avec vecteurs depart double ...............      */
+
+/*   Voir description des variables ds IniRFitLin()   */
+static int DFBusy = -1;
+static int DNVarMax = 0;
+static int DVLenMax = 0;
+static double **DVeci = NULL;
+static double **DVecf = NULL;
+static double *DVSpace = NULL;
+static double *DVSpacef = NULL;
+static double  *DFMtx = NULL;
+static double  *DFMtx2 = NULL;
+
+
+int InitDFitLin(int nvarmx, int szv)
+
+/*  Initialisation du fit de Xi2 Entier             */
+/*  Allocation d'espace memoire                     */
+/*  nvarmx = Nb maxi de variable                    */
+/*  szv = Taille maxi des vecteurs de points        */
+
+{
+int i;
+
+DFBusy = -1;
+nvarmx ++;
+if (nvarmx < 7)  nvarmx = 7;
+if (szv < 25) szv = 25;
+
+if ( (DVeci = malloc(nvarmx*sizeof(double *))) == NULL )
+  { printf("InitDFitLin_Erreur: (Pb malloc(Veci)) \n");
+  return(1);
+  }
+
+if ( (DVSpace = malloc(nvarmx*szv*sizeof(double))) == NULL )
+  { printf("InitDFitLin_Erreur: (Pb malloc(VSpace)) \n");
+  free(DVeci);
+  return(2);
+  }
+
+for(i=0; i<nvarmx; i++)  *(DVeci+i) = DVSpace+i*szv;
+
+
+if ( (DVecf = malloc(3*sizeof(double *))) == NULL )
+  { printf("InitDFitLin_Erreur: (Pb malloc(Vecf)) \n");
+  free(DVeci);
+  free(DVSpace);
+  return(3);
+  }
+
+if ( (DVSpacef = malloc(3*szv*sizeof(double))) == NULL )
+  { printf("InitDFitLin_Erreur: (Pb malloc(VSpacef)) \n");
+  free(DVeci);
+  free(DVSpace);
+  free(DVecf);
+  return(4);
+  }
+
+for(i=0; i<3; i++)  *(DVecf+i) = DVSpacef+i*szv;
+
+
+if ( (DFMtx = malloc(nvarmx*nvarmx*sizeof(double))) == NULL )
+  { printf("InitDFitLin_Erreur: (Pb malloc(FMtx)) \n");
+  free(DVeci);
+  free(DVSpace);
+  free(DVecf);
+  free(DVSpacef);
+  return(5);
+  }
+
+if ( (DFMtx2 = malloc(nvarmx*nvarmx*sizeof(double))) == NULL )
+  { printf("InitDFitLin_Erreur: (Pb malloc(FMtx2)) \n");
+  free(DVeci);
+  free(DVSpace);
+  free(DVecf);
+  free(DVSpacef);
+  free(DFMtx);
+  return(6);
+  }
+
+DFBusy = 0;
+DNVarMax = nvarmx-1;
+DVLenMax = szv;
+
+return(0);
+}
+
+
+/* Nouvelle-Fonction */
+void EndDFitLin()
+{
+
+if (DVeci != NULL)  free(DVeci);
+if (DVSpace != NULL)  free(DVSpace);
+if (DVecf != NULL)  free(DVecf);
+if (DVSpacef != NULL)  free(DVSpacef);
+if (DFMtx != NULL)  free(DFMtx);
+if (DFMtx2 != NULL)  free(DFMtx2);
+
+DVeci = NULL;
+DVSpace = NULL;
+DVecf = NULL;
+DVSpacef = NULL;
+DFMtx = DFMtx2 = NULL;
+
+DFBusy = -1;
+DNVarMax = 0;
+DVLenMax = 0;
+return;
+}
+
+
+/* Nouvelle-Fonction */
+
+double **GetDFitVect(int nvar, int vsz)
+/*  reservation de l'espace des vecteurs pour le fit  */
+{
+int nvmx, vszmx;
+
+if (DFBusy > 0)  return(NULL);
+if ( (nvar < 1) || (vsz < 1) ) return(NULL);
+if ((nvar > DNVarMax) || (vsz > DVLenMax) || (DFBusy < 0))
+  {
+  EndDFitLin();
+  if (nvar > DNVarMax)   nvmx = nvar;
+  else  nvmx = DNVarMax;
+  if (vsz > DVLenMax)  vszmx = vsz;
+  else vszmx = DVLenMax;
+  InitDFitLin(nvmx, vszmx);
+  }
+
+DFBusy = 1;
+return(DVeci);
+}
+
+
+/* Nouvelle-Fonction */
+void FreeDFitVect()
+{
+DFBusy = 0;
+return;
+}
+
+
+/* Nouvelle-Fonction */
+
+double DFitLin(int nd, int vsz, double *XVar)
+
+/*  Effectue le fit de Xi2 pour nd inconnu, Taille vecteurs vsz */
+/*  Les vecteurs doivent etre remplis auparavant                */
+/*  Retourne la valeur du Xi2 du fit, Negatif si Pb.            */
+
+{
+int i,j;
+register double *ip;
+register double *fp, *fp2;
+register double x,y;
+double det,rc;
+
+
+if ((nd > DNVarMax) || (vsz > DVLenMax) )   { rc = -1000.;  goto Fin; }
+
+/*   Impression de debug  */
+/* 
+for(i=0; i<nd+1; i++)
+  {
+  ip = *(DVeci+i);
+  printf("DFitLin_Debug Veci[%d][0..5]= %lg %lg %lg %lg %lg %lg \n",
+       i,*ip, *(ip+1), *(ip+2), *(ip+3), *(ip+4), *(ip+5));  
+  } 
+*/
+
+
+/*  Fabrication matrice du syteme lineaire a resoudre  */
+
+for(i=0; i<nd; i++)
+  {
+  fp = DFMtx+i*nd;   fp2 = DFMtx2+i*nd;
+  ip = *(DVeci+i+1);
+
+/*  Elements diagonals  */
+  *(fp2+i) = *(fp+i) =  DVecxVec( ip, ip, vsz) ;  
+ 
+  for(j=i+1; j<nd; j++)  
+    {                /* Les autres elements  */
+    *(fp2+j) = *(fp+j) = DVecxVec( ip, *(DVeci+j+1), vsz) ;
+  /* Matrice symetrique */ 
+    *(DFMtx2+j*nd+i) = *(DFMtx+j*nd+i) = *(fp+j);  
+    }
+
+/*  Second membre  M.X = B   */
+  fp = *DVecf;  fp2 = *(DVecf+2);
+  *(fp2+i) = *(fp+i) = DVecxVec( ip, *DVeci, vsz) ;
+  
+  }
+
+/* 
+printf("DFitLin_Debug B[0..5]= %lg %lg %lg %lg %lg %lg \n",
+       *fp2, *(fp2+1), *(fp2+2), *(fp2+3), *(fp2+4), *(fp2+5));
+*/
+
+/*  On resoud le systeme lineaire : */
+fp = *(DVecf+1);
+det = SolveDLinSyst(DFMtx, *DVecf, fp, nd);
+if (det == 0.0)   { rc = -500.;  goto Fin; }
+
+/*  On calcule le Xi2  */
+x = DVecxVec( *DVeci, *DVeci, vsz);
+for(i=0; i<nd; i++)   /* Et on remplit le vecteur de sortie */
+  {
+  fp2 = DFMtx2+i*nd+i;   y = XVar[i] = *(*(DVecf+1)+i);  
+  x += (y * y * *fp2);
+  x -= ( 2.0 * ( y * *(*(DVecf+2)+i) ) );
+  for (j=i+1; j<nd; j++)  
+    { fp2++;  
+    x += ( 2.0 * ( y * *(*(DVecf+1)+j) * *fp2 ) );  }    
+  }
+rc = x;
+
+
+Fin:
+FreeDFitVect();
+return(rc);
+}
+
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/matxop.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/matxop.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/matxop.h	(revision 1307)
@@ -0,0 +1,57 @@
+/*  Fonctions de manipulation de matrices et de vecteurs    */
+/*  Resolution de systemes lineaires                        */
+
+/*                              R. Ansari  Juillet 1993     */
+/*  Note: 07/94 Fonction GausPiv(Inversion Matrice) CMV     */
+/*        est utilisee pour  R/DFitLinErr()                 */
+
+#ifndef MATXOP_H_SEEN
+#define MATXOP_H_SEEN
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*   Declaration des fonctions   */
+
+/*  Operation Vecteurs/ Matrices   */
+int IVecxVec(int *v1, int *v2, int n);
+float RVecxVec(float *v1, float *v2, int n);
+double DVecxVec(double *v1, double *v2, int n);
+void  IMatxVec(int *mx, int *vi, int *vo, int n);
+void  RMatxVec(float *mx, float *vi, float *vo, int n);
+void  DMatxVec(double *mx, double *vi, double *vo, int n);
+
+/*  Resolution  de systemes lineaires  */
+float SolveRLinSyst(float *mx, float *b, float *x, int n);
+double SolveDLinSyst(double *mx, double *b, double *x, int n);
+
+
+/*  Ajustement de Chi2   */
+
+/*  Ajustement avec vecteurs de depart Reels  */
+int InitRFitLin(int nstmx, int szv);
+void EndRFitLin(void);
+float **GetRFitVect(int nvar, int vsz);
+void FreeRFitVect(void);
+float RFitLin(int nd, int vsz, float *XVar);
+float RFitLinErr(int nd, int vsz, float *XVar, float *Err);
+
+/*  Ajustement avec vecteurs de depart double  */
+int InitDFitLin(int nstmx, int szv);
+void EndDFitLin(void);
+double **GetDFitVect(int nvar, int vsz);
+void FreeDFitVect(void);
+double DFitLin(int nd, int vsz, double *XVar);
+double DFitLinErr(int nd, int vsz, double *XVar, double *Err);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/median.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/median.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/median.cc	(revision 1307)
@@ -0,0 +1,25 @@
+#if 0
+#include "median.h"
+#include <algorithm>
+
+float MedianFilter(float tab[], int n)
+{
+  sort(tab, tab+n);
+  return (n%2 ? tab[n/2] : (tab[n/2]+tab[n/2-1])/2);
+}
+
+double MedianFilter(double tab[], int n)
+{
+  sort(tab, tab+n);
+  return (n%2 ? tab[n/2] : (tab[n/2]+tab[n/2-1])/2);
+}
+
+void   MedianFilterWindowIdx(float const data[], int ndata, int width, 
+			     int index[])
+{
+  float* tab = new float[witdh];
+
+
+  delete[] tab;
+}
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/median.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/median.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/median.h	(revision 1307)
@@ -0,0 +1,28 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+#include "defs.h"
+
+// Filtre median, retourne la valeur mediane du tableau tab.
+//  *** Le tableau est modifie (trie par ordre croissant)
+float  MedianFilter(float  tab[], int n); 
+double MedianFilter(double tab[], int n);
+int    MedianFilterIdx(float tab[], int n); 
+int    MedianFilterIdx(double tab[], int n); 
+
+// Filtre median sur fenetre glissante. 
+// data[index[i]] est la ieme valeur filtree
+void   MedianFilterWindowIdx(float const data[], int ndata, int width, 
+			     int index[]);
+
+// Filtre median sur fenetre glissante. 
+// fdata[] est le tableau filtre
+void   MedianFilterWindow(float const data[], int ndata, int width,
+			  float fdata[]);
+
+// Filtre median sur fenetre glissante. 
+// fdata[] est le tableau filtre. assoc sont des donnees associees,
+// par exemple des erreurs, qui sont reordonnees avec la meme permutation
+// dans fassoc.
+void   MedianFilterWindow(float const data[], float const assoc[],
+			  int ndata, int width,
+			  float[] fdata, float fassoc[]);
Index: /tags/DPC_V0/SophyaLib/NTools/nbconst.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/nbconst.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/nbconst.h	(revision 1307)
@@ -0,0 +1,81 @@
+/* quelques fonctions mathematiques et constantes utiles */
+/*                                         cmv  23/06/94 */
+#ifndef NBCONST_H_SEEN
+#define NBCONST_H_SEEN
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// EA conflit entre les diverses copies de nbmath.h, nbconst.h... A nettoyer...
+#undef Pi
+#undef Pis2
+#undef DeuxPi
+#undef SPi
+#undef S2Pi
+#undef Rac2
+#undef Log2
+#undef LnPi
+#undef LgPi
+#undef Ln10
+#undef DftoDm
+#undef Hln2pi
+#undef DegenRad
+#undef JourSec
+#undef AnSec
+
+#undef UAenKM
+#undef UAenLY
+#undef KPCenKM
+#undef KPCenUA
+#undef KPenLY
+#undef LYenKM
+#undef RSolenKM
+#undef RTenKM
+#undef MSolenKg
+#undef GC_RE
+
+#undef GRAND  
+#undef GRAND2 
+#undef IGRAND 
+
+#define Pi     (double) (3.1415926535897931)   /* c'est Pi */
+#define Pis2   (double) (1.57079632679489655)  /* c'est Pi/2 */
+#define DeuxPi (double) (6.2831853071795862)   /* c'est 2*Pi */
+#define SPi    (double) (1.7724538509055159)   /* c'est sqrt(Pi) */
+#define S2Pi   (double) (2.5066282746310002)   /* c'est sqrt(2*Pi) */
+#define Rac2   (double) (1.4142135623730950)   /* c'est sqrt(2) */
+#define Log2   (double) (0.30102999566398119)  /* c'est log10(2) */
+#define LnPi   (double) (1.1447298858494002)   /* c'est ln(Pi) */
+#define LgPi   (double) (0.49714987269413385)  /* c'est log10(Pi) */
+#define Ln10   (double) (2.3025850929940456)   /* c'est ln(10) */
+#define DftoDm (double) (1.0857362047581295)   /* c'est 2.5/ln(10) */
+#define Hln2pi (double) (0.91893853320467267)  /* c'est Ln(2*pi)/2 */
+#define DegenRad (double) (0.0174532925199)    /* nombre de radians dans un degre */
+
+#define JourSec (float) (86400.)    /* nombre de secondes dans 24H */
+#define AnSec  (int) (31557600)     /* nombre de secondes dans 365.25 jours */
+
+#define UAenKM (double) (149597870.) /* nombre de kilometres dans une unite astronomique */
+#define UAenLY (double) (1.5812507406e-5) /* unite astronomique en annees lumiere */
+#define KPCenKM (double) (3.0856775807e+16) /* nombre de kilometres dans un kiloparsec */
+#define KPCenUA (double) (206264806.248) /* nombre d'unites astronomiques dans un kiloparsec */
+#define KPenLY (double) (3261.5637763) /* kiloparsec en annees lumiere */
+#define LYenKM (double) (9.4607304725808*e+12) /* annee lumiere en kilometres */
+#define RSolenKM (double) (6.9599e+5) /* Rayon solaire en kilometres */
+#define RTenKM (double) (6378.14) /* rayon equatorial terrestre en kilometres */
+
+#define MSolenKg (double) (1.9891e+30) /* masse solaire en kilogramme */
+
+#define GC_RE ((double) 4.7854172e-17) /* c'est G/c**2 en unites kpc/Mo  */
+
+#define GRAND  (float) (1.e+35)
+#define GRAND2 (double) (1.e+35)
+#define IGRAND (int_4) (2147483647)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/nbinteg.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/nbinteg.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/nbinteg.h	(revision 1307)
@@ -0,0 +1,146 @@
+/* Pour integration par la methode "higher order gaussian terms" */
+/*                                                cmv   23/06/94 */
+
+#ifndef NBINTEG_H_SEEN
+#define NBINTEG_H_SEEN
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*=============================================================*/
+static int mIhoq2 = 2;
+static double Ihoq2X[2] =
+   { -0.288675135, 0.288675135 };
+static double Ihoq2W[2] =
+   {  0.500000000, 0.500000000 };
+/*=============================================================*/
+static int mIhoq3 = 3;
+static double Ihoq3X[3] =
+   { -0.387298335, 0.000000000, 0.387298335 };
+static double Ihoq3W[3] =
+   {  0.277777778, 0.444444444, 0.277777778 };
+/*=============================================================*/
+static int mIhoq4 = 4;
+static double Ihoq4X[4] =
+   { -0.430568156,-0.169990522, 0.169990522, 0.430568156 };
+static double Ihoq4W[4] =
+   {  0.173927423, 0.326072577, 0.326072577, 0.173927423 };
+/*=============================================================*/
+static int mIhoq5 = 5;
+static double Ihoq5X[5] =
+   { -0.453089923,-0.269234655, 0.000000000, 0.269234655,
+      0.453089923 };
+static double Ihoq5W[5] =
+   {  0.118463443, 0.239314335, 0.284444444, 0.239314335,
+      0.118463443 };
+/*=============================================================*/
+static int mIhoq6 = 6;
+static double Ihoq6X[6] =
+   { -0.466234757,-0.330604693,-0.119309593, 0.119309593,
+      0.330604693, 0.466234757 };
+static double Ihoq6W[6] =
+   {  0.085662246, 0.180380787, 0.233956967, 0.233956967,
+      0.180380787, 0.085662246 };
+/*=============================================================*/
+static int mIhoq7 = 7;
+static double Ihoq7X[7] =
+   { -0.474553956,-0.370765593,-0.202922576, 0.000000000,
+      0.202922576, 0.370765593, 0.474553956 };
+static double Ihoq7W[7] =
+   {  0.064742483, 0.139852696, 0.190915025, 0.208979592,
+      0.190915025, 0.139852696, 0.064742483 };
+/*=============================================================*/
+static int mIhoq8 = 8;
+static double Ihoq8X[8] =
+   { -0.480144928,-0.398333239,-0.262766205,-0.091717321,
+      0.091717321, 0.262766205, 0.398333239, 0.480144928 };
+static double Ihoq8W[8] =
+   {  0.050614268, 0.111190517, 0.156853323, 0.181341892,
+      0.181341892, 0.156853323, 0.111190517, 0.050614268 };
+/*=============================================================*/
+static int mIhoq9 = 9;
+static double Ihoq9X[9] =
+   { -0.484080120,-0.418015554,-0.306685716,-0.162126712,
+      0.000000000, 0.162126712, 0.306685716, 0.418015554,
+      0.484080120 };
+static double Ihoq9W[9] =
+   {  0.040637194, 0.090324080, 0.130305348, 0.156173539,
+      0.165119678, 0.156173539, 0.130305348, 0.090324080,
+      0.040637194 };
+/*=============================================================*/
+static int mIhoq10 = 10;
+static double Ihoq10X[10] =
+   { -0.486953264,-0.432531683,-0.339704784,-0.216697697,
+     -0.074437169, 0.074437169, 0.216697697, 0.339704784,
+      0.432531683, 0.486953264 };
+static double Ihoq10W[10] =
+   {  0.033335672, 0.074725675, 0.109543181, 0.134633360,
+      0.147762112, 0.147762112, 0.134633360, 0.109543181,
+      0.074725675, 0.033335672 };
+/*=============================================================*/
+static int mIhoq16 = 16;
+static double Ihoq16X[16] =
+   { -0.494700467,-0.472287512,-0.432815601,-0.377702204,
+     -0.308938122,-0.229008389,-0.140801775,-0.047506255,
+      0.047506255, 0.140801775, 0.229008389, 0.308938122,
+      0.377702204, 0.432815601, 0.472287512, 0.494700467 };
+static double Ihoq16W[16] =
+   {  0.013576230, 0.031126762, 0.047579256, 0.062314486,
+      0.074797994, 0.084578260, 0.091301708, 0.094725305,
+      0.094725305, 0.091301708, 0.084578260, 0.074797994,
+      0.062314486, 0.047579256, 0.031126762, 0.013576230 };
+/*=============================================================*/
+
+
+/* Integration 2D domaine carre */
+/* Selon Abramowitz p892-893 formule 25.462, residu ordre 0.5**6 */
+/* 0.387298=0.5*sqrt(3/5)  0.197531=16/81  0.123457=10/81  0.077160=25/324 */
+/*  */
+#if defined(SIMPSON9)
+  static int   nd2d = 9;
+  static float dx2d[9] = { 0.000000 ,  0.000000 ,  0.000000
+                         ,-0.387298 ,  0.387298 , -0.387298
+                         , 0.387298 , -0.387298 ,  0.387298 };
+  static float dy2d[9] = { 0.000000 , -0.387298 ,  0.387298
+                         , 0.000000 ,  0.000000 , -0.387298
+                         , 0.387298 ,  0.387298 , -0.387298 };
+  static float  w2d[9] = { 0.197531 ,  0.123457 ,  0.123457
+                         , 0.123457 ,  0.123457 ,  0.077157
+                         , 0.0771605,  0.0771605,  0.0771605};
+#elif defined(SIMPSON4)
+  static int   nd2d = 4;
+  static float dx2d[4] = { 0.288675, 0.288675,-0.288675,-0.288675 };
+  static float dy2d[4] = { 0.288675,-0.288675, 0.288675,-0.288675 };
+  static float  w2d[4] = { 0.250000, 0.250000, 0.250000, 0.250000 };
+#elif defined(INTEG5)
+  static int   nd2d = 5;
+  static float dx2d[5] = { 0. , -0.3, -0.3,  0.3, 0.3 };
+  static float dy2d[5] = { 0. , -0.3,  0.3, -0.3, 0.3 };
+  static float  w2d[5] = { 0.2,  0.2,  0.2,  0.2, 0.2 };
+#elif  defined(NOINTEG)
+  static int   nd2d = 1;
+  static float dx2d[1] = { 0. };
+  static float dy2d[1] = { 0. };
+  static float  w2d[1] = { 1. };
+#else
+  static int   nd2d = 0;
+  static float dx2d[1] = { 999999. };
+  static float dy2d[1] = { 999999. };
+  static float  w2d[1] = { 0. };
+#endif
+
+
+/* Coeff pour le calcul du volume de f(x,y,z) dans des cubes 3D */
+static int   nd3d = 6;
+static float dx3d[6] = { 0.5, -0.5, 0.0,  0.0, 0.0,  0.0  };
+static float dy3d[6] = { 0.0,  0.0, 0.5, -0.5, 0.0,  0.0  };
+static float dz3d[6] = { 0.0,  0.0, 0.0,  0.0, 0.5, -0.5  };
+static float  w3d[6] = { 0.166667, 0.166667, 0.166667, 
+                         0.166667, 0.166667, 0.166667 };
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/NTools/nbmath.c
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/nbmath.c	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/nbmath.c	(revision 1307)
@@ -0,0 +1,2735 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <math.h>
+#include "nbmath.h"
+#include "matxop.h"
+#include "nbinteg.h"
+#include "nbtri.h"
+
+#define ITMAX 256
+#define EPS 3.0e-7
+#define DEB_GausPiv 0
+#define DEB_MeanSig 0
+
+/*
+++ 
+  Module	Fonction mathematiques (C)
+  Lib	LibsUtil
+  include	nbmath.h
+
+	Fonction mathematiques (C)
+--
+*/
+
+void FitFun_MrqCof( double (*FunFit) (double ,double *,double *) ,int_4 type
+           ,FLOATDOUBLE temps,FLOATDOUBLE mag,FLOATDOUBLE err
+           ,int_4 *ndata,int_4 I1,int_4 I2
+           ,double *parcur,int_4 npar,int_4 *ind
+           ,double *ATGA,double *BETA,double *ci2,int_4 deb);
+void nbgcf(double *gammcf,double a,double x,double *gln);
+void nbgser(double *gamser,double a,double x,double *gln);
+
+
+static int FITFUN_DPOL = -1;
+
+
+/*=========================================================================*/
+/*                                      Christophe 8/11/93 La Silla */
+/*
+++
+double FitFun
+|        ( double (*FunFit) (double ,double *,double *) ,int_4 type
+|        ,FLOATDOUBLE temps,FLOATDOUBLE mag,FLOATDOUBLE err
+|        ,int_4 *ndata,int_4 I1,int_4 I2
+|        ,double *par,double *epar,double *stepar
+|        ,double *minpar,double *maxpar,int_4 npar
+|        ,double stochi2,int_4 NstepMX,int_4 deb)
+
+	Pour fitter une fonction parametrique sur des donnees.
+	(Obsolete, utilisez GeneralFit en C++).
+--
+*/
+/*
+++
+| Fonction de fit de la courbe FunFit sur les donnees
+| - Methode:   fit des moindres carres dans le cas non lineaire
+| - Reference: Statistical and Computational Methods in Data Analysis
+|              Siegmund Brandt, North-Holland 1970  p 204-206.
+|              Introduction des limites pour la variation des parametres (cmv).
+|              Increment des parametres selon la methode de Levenberg-Marquardt
+|              (Numerical Receipes in C p 542)
+| - Remarques diverses:
+|     Les points avec erreurs negatives ou nulles ne sont pas
+|                utilises dans le fit.
+|     Si le fit est hautement non lineaire, il faut donner de bonnes
+|                approximations pour les parametres de depart.
+|     Les limites minpar,maxpar sont des limites absolues mais possibles
+| - Memo personnel:
+|     data = Ti, Fi ERRi  i=0,n-1
+|     parametres Pj  j=1,npar
+|     fonction FunFit(t,P1,P2,..,Pnpar)
+|     matrice A(n,4) = [Aij] = - [dg(T)/dPj]  pour t=Ti
+|     matrice G(n,n) = [Gij] = matrice diagonale 1/ERRj**2
+|     matrice C(n) = [Ci] = (Fi - FunFit(t,P1,P2,..,Pnpar))
+|     Pj(iteration n) = Pj(iteration n-1) + Zj
+--
+*/
+/*
+++
+| -----------
+| | ENTREES |
+| -----------
+| - FunFit  fonction a fiter
+| - type    type des donnees a fiter (union temps,mag,err):
+|           float=FITFUN_FLOAT / double=FITFUN_DOUBLE
+| - temps:  union FLOATDOUBLE des tableaux des temps:
+| - mag:    union FLOATDOUBLE des tableaux des magnitudes:
+| - err:    union FLOATDOUBLE des tableaux des erreurs sur la magnitude
+| - ndata:  nombre de donnees en entree, donc en c:
+| - I1:     indice de depart pour le fit
+| - I2:     indice de fin pour le fit
+|           (si I2 <= I1 defaut: 1,*ndata)
+| - par:    contient les valeurs d'initialisation des parametres
+| - stepar: si >0. on fit le parametre, sinon parametre fixe
+| - minpar: les valeurs minimum pouvant prendre les parametres
+| - maxpar: les valeurs minimum pouvant prendre les parametres
+|           (si maxpar[i] <= minpar[i] pas de limitation sur le parametre i)
+| - stochi2:la valeur de variation du chi2 d'une iteration l'autre
+|           en dessous de laquelle on arrete d'iterer:
+|           (si <=0 le default est 0.01).
+| - npar:   nombre de parametres du fit *par --> *(par+npar-1)
+| - NstepMX:nombre maximum d'iterations
+| - deb:    niveau de print (0/1/2/3)
+--
+*/
+/*
+++
+| ----------
+| | SORTIES |
+| ----------
+| - ndata: nombre de donnees utilisees dans le fit
+| - par: contient les valeurs fitees des parametres
+| - epar: contient les erreurs sur les valeurs fitees des parametres
+| - FitFun: la function elle meme retourne le Xi2 du fit si succes
+|       -1. si l'inversion de la matrice des erreurs n'a pas ete possible
+|       -2. si les parametres initiaux sont en desaccord avec les limites
+|       -3. si le nombre de donnees est inferieur au nombre de parametres
+|       -4. si le fit n'a pas converge (nstep>nNstepMX)
+--
+*/
+/*
+++
+| --------------
+| | MEMO PERSO |
+| --------------
+| la structure FLOATDOUBLE:
+| union FloatDouble {
+|   float  *fx;
+|   double *dx;
+| };
+| - Si les tableaux temps,mag,emag sont des float alors
+|   temps.fx doit contenir l'adresse du tableau des temps
+|            (et idem pour mag.fx et err.fx)
+| - Si les tableaux temps,mag,emag sont des double alors
+|   temps.dx doit contenir l'adresse du tableau des temps
+|            (et idem pour mag.dx et err.dx)
+--
+*/
+double FitFun( double (*FunFit) (double ,double *,double *) ,int_4 type
+             ,FLOATDOUBLE temps,FLOATDOUBLE mag,FLOATDOUBLE err
+             ,int_4 *ndata,int_4 I1,int_4 I2
+             ,double *par,double *epar,double *stepar
+             ,double *minpar,double *maxpar,int_4 npar
+             ,double stochi2,int_4 NstepMX,int_4 deb)
+{
+int_4 ind[NPAR_FITFUN], i, j, k, nstep, nparsave, nstop, nstopMX;
+double LimitC2,lambda,eps;
+double ATGA[NPAR_FITFUN][NPAR_FITFUN], COVAR[NPAR_FITFUN][NPAR_FITFUN]
+     , ALPHA[NPAR_FITFUN][NPAR_FITFUN];
+double DA[NPAR_FITFUN], BETA[NPAR_FITFUN];
+double parcur[NPAR_FITFUN],partry[NPAR_FITFUN];
+double ci2, ci20;
+
+/* initialisation */
+if( type != FITFUN_FLOAT && type != FITFUN_DOUBLE) {
+  printf("FitFun: Type de variable non prevue dans union FLOATDOUBLE %d\n",type);
+  exit(-1);
+}
+
+if(npar>NPAR_FITFUN) {
+  printf("FitFun: trop de parametres npar=%d > NPAR_FITFUN=%d\n",npar,NPAR_FITFUN);
+  exit(-1);
+}
+nstopMX = 3;
+eps = 1.e-8;
+LimitC2=0.01;
+if ( stochi2 > 0. ) LimitC2 = stochi2;      /* test des valeurs d'arret */
+nstop = 0;
+
+/* fit du centre autour des valeurs estimees */
+nparsave = npar;
+for (i=0;i<nparsave;i++) parcur[i] = *(par+i);
+
+npar=0;
+for (i=0;i<nparsave;i++) {
+  ind[i]= -1;
+  *(epar+i) = 0.;
+  partry[i] = *(parcur+i);
+  if ( stepar[i] > 0. ) {
+    ind[npar]=i;
+    npar++;
+} }
+
+if ( I2 <= I1 ) { I1 = 0; I2 = *ndata-1;}
+if ( I2-I1+1 < npar ) {
+  printf("le nombre de donnees %d est inferieur au nombre de parametres %d\n"
+        ,I2-I1+1,npar);
+  return(-3.);
+}
+ 
+for (j=0;j<npar;j++) {
+  i = ind[j];
+  if(*(maxpar+i)>*(minpar+i) && (*(parcur+i)<=*(minpar+i) || *(parcur+i)>=*(maxpar+i))) {
+    printf("Parametre %d initialise hors limites: %f # [%f,%f]\n"
+          ,i,*(parcur+i),*(minpar+i),*(maxpar+i));
+    return(-2.);
+} }
+
+if ( deb >= 2 ) {
+  printf("\n******************* ENTREE DANS FitFun ");
+  printf("npar=%d LimitC2=%f\n",npar,LimitC2);
+  printf("parametres"); for(i=0;i<nparsave;i++) printf(" %f",*(parcur+i)); printf("\n");
+  if ( deb >= 3 ) {
+    printf("       ind"); for(i=0;i<nparsave;i++) printf(" %12d",*(ind+i)); printf("\n");
+    printf("    stepar"); for(i=0;i<nparsave;i++) printf(" %12.5g",*(stepar+i)); printf("\n");
+    printf("    minpar"); for(i=0;i<nparsave;i++) printf(" %12.5g",*(minpar+i)); printf("\n");
+    printf("    maxpar"); for(i=0;i<nparsave;i++) printf(" %12.5g",*(maxpar+i)); printf("\n");
+} }
+
+/* premiere essai avec les parametres d'initialisation */
+
+FitFun_MrqCof(FunFit,type,temps,mag,err,ndata,I1,I2,parcur,npar,ind,ALPHA[0],BETA,&ci2,deb);
+
+ci20 = ci2;
+lambda = 0.001;
+
+if ( *ndata < npar ) {
+  printf("le nombre de donnees %d est inferieur au nombre de parametres %d\n",*ndata,npar);
+  return(-3.);
+}
+
+if ( deb >= 2 ) printf("Passage d'initialisation ci2= %e, lambda=%e\n",ci2,lambda);
+
+/* et maintenant les iterations */
+
+nstep = 0;
+/************************ ITERATIONS *******************************************/
+ITERATE:
+nstep++;
+
+if ( deb >= 2 ) printf("------------------------- pas %d\n",nstep);
+
+if(nstep > NstepMX) {
+  printf("FitFun: Le fit n'a pas converge (trop d'iterations %d).\n",nstep);
+  if (deb>0 ) {
+    printf("== Parametres finals:");
+    for(k=0;k<nparsave;k++) printf(" %15.8e",parcur[k]); printf("\n");
+    for(i=0;i<npar;i++) { *(epar+ind[i]) = -1.; par[ind[i]] = parcur[ind[i]];}
+  }
+  return(-4.);
+}
+
+for(j=0;j<npar;j++) {
+  for(i=0;i<npar;i++) ATGA[j][i] = ALPHA[j][i];
+  ATGA[j][j] *= 1.0 + lambda;
+}
+
+/* inversion de   ( At * G * A ) */
+if( GausPiv(ATGA[0],NPAR_FITFUN,npar,COVAR[0],NPAR_FITFUN,npar,1) == 0. ) {
+  printf("La matrice des erreurs n'est pas inversible\n");
+  return(-1.);
+}
+if( deb >= 3 ) {
+  printf("matrice 1/( At * G * A )\n");
+  for ( i=0; i<npar; i++ ) {
+    for ( j=0; j<npar; j++ ) printf(" %15.8e",COVAR[i][j]);
+    printf("\n");
+} }
+
+/* compute next increment */
+for(i=0;i<npar;i++) {
+  DA[i] = 0.;
+  for(j=0;j<npar;j++) DA[i] += COVAR[i][j] * BETA[j];
+}
+if ( deb >= 2 ) {
+  printf("Correction parametres proposee:");
+  for (i=0;i<npar;i++) printf(" %12.5e",DA[i]); printf("\n");
+}
+
+/* on s'arrete la, il y a eu convergence */
+if ( lambda == 0. ) {
+  for(i=0;i<npar;i++) { *(epar+ind[i]) = sqrt(COVAR[i][i]); par[ind[i]] = parcur[ind[i]];}
+  if (deb>0 ) {
+    printf("===============================================================\n");
+    printf("== ci2= %15.8e (%15.8e) ndata= %d nstep= %d\n",ci2,ci2/(*ndata-npar+1),*ndata,nstep);
+    printf("== Parametres finals:"); for(k=0;k<nparsave;k++) printf(" %15.8e", par[k]); printf("\n");
+    printf("==               +/- "); for(k=0;k<nparsave;k++) printf(" %15.8e",epar[k]); printf("\n");
+    printf("===============================================================\n");
+  }
+  return( (float) ci2 );
+}
+
+/* essai des nouveaux parametres */
+for(j=0;j<npar;j++) {
+  k = ind[j];
+  if( nstep == 1 && fabs(DA[j]) > stepar[k] ) {
+    partry[k] = parcur[k] + stepar[k] * DA[j] / fabs(DA[j]);
+  } else {
+    partry[k] = parcur[k] + DA[j];
+  }
+  if(maxpar[k] > minpar[k] ) {
+    if( partry[k] < minpar[k] ) {
+      partry[k] = minpar[k];
+      if(deb>=2) printf("Parametre %3d limite au minimum %e\n",k,partry[k]);
+    }
+    if( partry[k] > maxpar[k] ) {
+      partry[k] = maxpar[k];
+      if(deb>=2) printf("Parametre %3d limite au maximum %e\n",k,partry[k]);
+    }
+} }
+if ( deb>=2)
+  {
+  printf("essai avec");
+  for(k=0;k<nparsave;k++) printf(" %15.8e", partry[k]);
+  printf("\n");
+  }
+
+/* calcul du nouveau ci2 avec partry */
+FitFun_MrqCof(FunFit,type,temps,mag,err,ndata,I1,I2,partry,npar,ind,ATGA[0],DA,&ci2,deb);
+if(deb>=2) printf("Ci2: old=%e new=%e %e\n",ci20,ci2,ci2-ci20);
+
+/* test sur l'evolution du ci2 et la strategie a suivre */
+if ( ci2 < ci20 ) {
+  nstop = 0;
+  for (j=0;j<npar;j++) {
+    for(i=0;i<npar;i++) ALPHA[j][i] = ATGA[j][i];
+    BETA[j] = DA[j];
+    parcur[ind[j]] = partry[ind[j]];
+  }
+  lambda *= 0.1;
+  if( ci20 - ci2 < LimitC2 ) lambda = 0.;
+  ci20 = ci2;
+  if(deb>=2) {
+    printf("lambda divided by 10. %e\n",lambda);
+    printf("Nouveaux parametres"); for(k=0;k<nparsave;k++) printf(" %12.5e",parcur[k]); printf("\n");
+  }
+} else {
+  /* on arrete si pas assez de variation de chi2 + pas assez de variation de parametres */
+  if( ci2 - ci20 < LimitC2 ) {
+    k=0;
+    for(i=0;i<npar;i++) if( fabs( parcur[ind[i]] - partry[ind[i]] ) < eps ) k++;
+    if(k == npar) { nstop++; } else { nstop=0;};
+    /* printf("ci2-ci20=%f npar=%d (%d) nstop=%d\n"
+           ,ci2-ci20,npar,k,nstop); */
+  } else {
+    nstop = 0;
+  }
+  lambda *= 10.;
+  if(nstop>=nstopMX) lambda = 0.;
+  ci2 = ci20;
+  if(deb>=2) printf("Echec essai, lambda multiplied by 10. %e\n",lambda);
+}
+
+goto ITERATE;
+
+}
+
+/*=========================================================================*/
+void FitFun_MrqCof(double (*FunFit) (double ,double *,double *) ,int_4 type
+           ,FLOATDOUBLE temps,FLOATDOUBLE mag,FLOATDOUBLE err
+           ,int_4 *ndata,int_4 I1,int_4 I2
+           ,double *parcur,int_4 npar,int_4 *ind
+           ,double *ATGA,double *BETA,double *ci2,int_4 deb)
+{
+int_4 i, j, k;
+double deriv[NPAR_FITFUN], t, f, e, Gkk, Ck, funfit;
+
+for (i=0; i<npar;i++) { BETA[i] = 0.; for (j=0; j<npar;j++) *(ATGA+i*NPAR_FITFUN+j) = 0.;}
+*ci2 = 0.;
+*ndata = 0;
+
+/* calcul de  ( At * G * A ) */
+for (k=I1; k<=I2; k++) {
+  e = (type == FITFUN_FLOAT) ? *(err.fx + k) : *(err.dx + k);
+  if ( e > 0. ) {
+    (*ndata)++;
+    t = (type == FITFUN_FLOAT) ? *(temps.fx + k) : *(temps.dx + k);
+    f = (type == FITFUN_FLOAT) ? *(mag.fx   + k) : *(mag.dx + k);
+    funfit = FunFit(t,parcur,deriv);
+    Gkk = 1./e/e;
+    Ck = f - funfit;
+    *ci2 += Ck*Ck*Gkk;
+    for ( j=0; j<npar; j++ ) {
+      for ( i=j; i<npar; i++ ) *(ATGA+i*NPAR_FITFUN+j) += deriv[ind[i]] * Gkk * deriv[ind[j]];
+      BETA[j] += deriv[ind[j]] * Gkk * Ck;
+} } }
+
+for(j=1;j<npar;j++) for(i=0;i<j;i++) *(ATGA+i*NPAR_FITFUN+j) = *(ATGA+j*NPAR_FITFUN+i);
+
+if( deb >= 3 ) {
+  printf("matrice ( At * G * A )\n");
+  for ( i=0; i<npar; i++ ) {
+    for ( j=0; j<npar; j++ ) printf(" %15.8e",*(ATGA+i*NPAR_FITFUN+j));
+    printf("\n");
+  }
+  printf("BETA:");
+  for ( j=0; j<npar; j++ ) printf(" %15.8e",BETA[j]);
+  printf("\n");
+}
+
+}
+
+/*=========================================================================*/
+/*                                          Christophe 8/11/93 La Silla */
+/*
+++
+double GausPiv(double *A,int_4 nca,int_4 n,double *B,int_4 ncb,int_4 m,int_4 Inv)
+	Inversion de matrice par la methode du pivot de Gauss.
+--
+*/
+/*
+++
+| Inv=0: resolution d'un systeme A(n,n) * X(n,m) = B(n,m)  
+|        en entree matrices A,B de taille A[?>=n][nca>=n] et B[?>=n][ncb>=m]
+|        en sortie la matrice B contient le resultat X
+| Inv#0: inversion de la matrice A(n,n)
+|        en entree matrice A
+|        en sortie la matrice B contient le resultat 1/A 
+| GausPiv: retourne le determinant (0. si non-inversible!)
+--
+*/
+/*
+++
+|Remarque: 
+|-matrice A[?>=n][nca>=n],
+|       element Aij = "A'[i][j] de ss matrice A'[n][n]" = *(A+i*nca+j)
+|       ou 0<=i<n indice de ligne; ou 0<=j<n indice de colonne; 
+|-matrice B[?>=n][ncb>=m],
+|       element Bij = "B'[i][j] de ss matrice B'[n][m]" = *(B+i*ncb+j)
+|       ou 0<=i<n indice de ligne; ou 0<=j<m indice de colonne;
+|exemple 1: on veut resoudre le systeme A(4,4) * X = B(4,3)
+|           et on definit dans le prog appelant: double A[12][7],B[32][5]
+|           on appelle: GausPiv(&A[0][0],7,4,&B[0][0],5,3,0)
+|exemple 2: on veut resoudre le systeme A(4,4) * X = B(4)
+|           et on definit dans le prog appelant: double A[4][4],B[4]
+|           on appelle: GausPiv(A[0],4,4,B,1,1,0)
+|exemple 3: on veut resoudre le systeme A(4,4) * X = B(4)
+|           et on definit dans le prog appelant: double A[9][4],B[7,3]
+|           on appelle: GausPiv(A[0],4,4,B,3,1,0)
+|Methode: methode de gauss avec choix du pivot maximum
+|Reference: Statistical and Computational Methods in Data Analysis
+|           Siegmund Brandt, North-Holland 1970  p 350-361.
+|Attention: la matrice A est detruite et la matrice B aussi (evidemment)
+--
+*/
+double GausPiv(double *A,int_4 nca,int_4 n,double *B,int_4 ncb,int_4 m,int_4 Inv)
+{
+int_4 deb=DEB_GausPiv;
+int_4 i,j,k,l,i1,i2,j1,j2,j3,j4,ij,ii,il,lj,kj,k1,nj,kk,ik,nn,kmax,i1max;
+double amax,save,det;
+
+if ( n < 1 ) {
+  printf("GausPiv: pas de resolution de systeme de dimension %d\n",n);
+  return(0.);
+}
+
+/* ********************************************************** */
+/* cas d'une inversion de matrice: on met B = matrice identite*/
+/* ********************************************************** */
+if ( Inv != 0 ) {
+  if ( m != n ) {
+    printf("GausPiv: Vous voulez inverser une matrice non carree %d %d\n",n,m);
+    return(0.);
+  }
+  for (i=0;i<n;i++) {
+    for (j=0;j<n;j++) {
+      if ( i != j ) { *(B+i*ncb+j) = 0.; } else { *(B+i*ncb+j) = 1.;}
+} } }
+
+if ( deb>0 ) {
+  printf("** Matrices de depart\n");
+  printf("Matrice A %d %d:\n",nca,n);
+  for (i=0;i<n;i++) {
+    for (j=0;j<n;j++) printf(" %15.8e",*(A+i*nca+j));
+    printf("\n");
+  }
+  printf("Matrice B %d %d:\n",ncb,m);
+  for (i=0;i<n;i++) {
+    for (j=0;j<m;j++) printf(" %15.8e",*(B+i*ncb+j));
+    printf("\n");
+} }
+
+/* ***************************************************************** */
+/*    reduction de la matrice A a la forme triangulaire superieure   */
+/* ***************************************************************** */
+det=1.;
+kmax = n-1;
+for (k=0;k<kmax;k++) {         /* on travaille sur la ligne k */
+  if ( deb>0 ) printf("-----> reduction ligne %d\n",k);
+  amax=0.;    /*recherche du plus grand coeff pour le pivot*/
+  j2=k;       /* dans col k pour les lignes >= k */
+  for (j1=k;j1<n;j1++) {
+    ik = j1*nca+k;
+    if( fabs(amax)-fabs(*(A+ik)) < 0. ) {
+      amax = *(A+ik);
+      j2 = j1;
+  } }
+  if ( deb>0 ) printf("pivot sur la ligne %d max= %f\n",j2,amax);
+  if ( j2 != k ) {      /* echange des lignes k et j2 si necessaire*/
+    for (j=k;j<n;j++) {
+      j3=k*nca+j;
+      j4=j2*nca+j;
+      save = *(A+j3);
+      *(A+j3) = *(A+j4);
+      *(A+j4) = save;
+    }
+    for (j=0;j<m;j++) {
+      j3=k*ncb+j;
+      j4=j2*ncb+j;
+      save = *(B+j3);
+      *(B+j3) = *(B+j4);
+      *(B+j4) = save;
+    }
+    if ( deb>0 ) {
+      printf("Matrice A echange des lignes %d et %d :\n",k,j2);
+      for (i=0;i<n;i++) {
+        for (j=0;j<n;j++) printf(" %15.8e",*(A+i*nca+j));
+        printf("\n");
+      }
+      printf("Matrice B echange des lignes %d et %d :\n",k,j2);
+      for (i=0;i<n;i++) {
+        for (j=0;j<m;j++) printf(" %15.8e",*(B+i*ncb+j));
+        printf("\n");
+  } } }
+  k1=k+1;  /* on effectue la substitution-soustraction sur les lignes qui suivent*/
+  kk = k*nca+k;      /* c'est le pivot*/
+  if ( deb>0 ) printf("valeur du pivot %f\n",*(A+kk));
+  if ( *(A+kk) == 0. ) {
+    /* printf("Matrice non-inversible: pivot %d nul\n",k); */
+    return(0.);
+  } else { det *= *(A+kk); }
+  for (i=k1;i<n;i++) {
+    ik = i*nca+k;  /* c est le premier element de la ligne i */
+    for (j=k1;j<n;j++) {
+      ij= i*nca+j;
+      kj= k*nca+j;
+      *(A+ij) += -*(A+kj) * *(A+ik) / *(A+kk);
+    }
+    for (j=0;j<m;j++) {
+      ij= i*ncb+j;
+      kj= k*ncb+j;
+      *(B+ij) += -*(B+kj) * *(A+ik) / *(A+kk);
+  } }
+  if ( deb>0 ) {
+    printf("Matrice A:\n");
+    for (i=0;i<n;i++) {
+      for (j=0;j<n;j++) printf(" %15.8e",*(A+i*nca+j));
+      printf("\n");
+    }
+    printf("Matrice B:\n");
+    for (i=0;i<n;i++) {
+      for (j=0;j<m;j++) printf(" %15.8e",*(B+i*ncb+j));
+      printf("\n");
+} } }     /* fin du travail sur la ligne k */
+det *= *(A+(n-1)*nca+(n-1));
+if ( deb>0 ) printf("Determinant de A= %e\n",det);
+
+/* ********************************************************** */
+/*       back substitution                                    */
+/* ********************************************************** */
+nn=(n-1)*nca+(n-1);     /* l'element (n,n) */
+for (j=0;j<m;j++) {
+  nj=(n-1)*ncb+j;
+  if ( *(A+nn) == 0. ) {
+    /* printf("Matrice non-inversible pivot (%d,%d) nul\n",n-1,n-1); */
+    return(0.);
+  }
+  *(B+nj) /= *(A+nn);   /* la derniere ligne traitee a part*/
+  i1max=n-1;
+  if( i1max >= 0 ) {    /* les lignes n-1 a 1 dans cet ordre*/
+    for(i1=1;i1<=i1max;i1++) {
+      i=n-1-i1;         /* ici i va de n-2 a 0 */
+      ij=i*ncb+j;
+      ii=i*nca+i;
+      i2=i+1;           /* pour la ligne i on somme de i+1 a n */
+      for (l=i2;l<n;l++) {
+        il=i*nca+l;
+        lj=l*ncb+j;
+        *(B+ij) -= *(A+il) * *(B+lj);
+      }
+      if ( *(A+ii) == 0. ) {
+        /* printf("Matrice non-inversible pivot (%d,%d) nul\n",i,i); */
+        return(0.);
+      }
+      *(B+ij) /= *(A+ii);
+} } }
+if ( deb>0 ) {
+  printf("-----> Matrice B resultat:\n");
+  for (i=0;i<n;i++) {
+    for (j=0;j<m;j++) printf(" %15.8e",*(B+i*ncb+j));
+    printf("\n");
+} }
+return(det);
+}
+
+/*=========================================================================*/
+/*                                       CMV 17/11/92  */
+/*
+++
+int_4 paramga -
+  (float sxin, float syin, float rhoin -
+  , float *smax, float *axisrat, float *tiltdeg)
+
+	Pour transformer le sx,sy,rho d'une gaussienne en sa,sc/sa,teta.
+--
+*/
+/*
+++
+| - input : sx ]0,inf] ,sy ]0,inf] ,rho ]-1,+1[
+| - output : smax (longeur du grand axe), axisrat (rapport des axes ]0.,1.])
+|     tiltdeg (angle entre le grand axe et l'axe ox en degre ]-90,+90])
+| - Les fonctions sont:
+| exp[-0.5*{[(x/SX)**2-2*RHO/(SX*SY)*x*y+(y/SY)**2]/(1-RHO**2)}]
+| exp[-0.5*{ (A/SA)**2                  +(C/SC)**2            }]
+| - Remarque: sx,sy representent les sigmas des variables x,y et
+| sont differents des sigmas des coupes x=0 et y=0 qui valent:
+|    sigmaX(y=0) = sx*sqrt(1-ro^2) different de sx
+|    sigmaY(x=0) = sy*sqrt(1-ro^2) different de sy
+--
+*/
+int_4 paramga(float sxin, float syin, float rhoin
+             , float *smax, float *axisrat, float *tiltdeg)
+/*
+Cf Formulae and Methods in Experimental Data Evaluation Vol. 1
+rechercher a Bivariate gaussian distribution
+*/
+{
+double sx,sy,rho,a,b,c,alpha,coscar,sincar,cossin,sa,sc;
+
+*smax = 0.; *axisrat = 0.; *tiltdeg = 0.; a = 0.; b = 0.; c = 0.;
+
+/* lecture des arguments */
+sx = sxin;  sy = syin;  rho = rhoin;
+
+/* cas des coniques degenerees ou erreurs dans les parametres*/
+if ( sx <= 0. || sy <= 0. || rho > 1. || rho < -1. ) return(-1);
+
+/* sortie fit : [(x/SX)**2 - 2*RHO/(SX*SY)*x*y + (y/SY)**2]/(1-RHO**2) = 1
+   equation ellipse: A*x**2 + 2*B*x*y + C*y**2  = 1       */
+sa = (1.-rho*rho);
+a = 1./sx/sx/sa;  b = -rho/sx/sy/sa;  c = 1./sy/sy/sa;
+
+/* cas des coniques degenerees (droites limites) */
+if ( rho == 1. || rho == -1. ) return(-2);
+
+/* axes principaux OX OY pour : x = cos(ALPHA)*X - sin(APLHA)*Y
+        (ALPHA = (ox,oX))       y = sin(ALPHA)*X + cos(APLHA)*Y
+  soit   ( A*cos**2 + C*sin**2 + 2*B*cos*sin )*X**2
+     +   ( A*sin**2 + C*cos**2 - 2*B*cos*sin )*Y**2
+     + 2*( -A*cos*sin + C*cos*sin + B*(cos**2-sin**2) )*X*Y
+                   = (X/SA)**2 + (Y/SC)**2 = 1
+  et oX oY axes principaux pour : Tan ( 2*ALPHA ) = 2*B/(A-C) */
+
+if ( a == c && rho == 0. ) {
+  /*  cas d'un cercle */
+  coscar = 0.5;    sincar = coscar;    cossin = coscar;    alpha = 0.;
+} else {
+  if ( a == c ) {
+    /* cas SX=SY ellipse a +/-45 degres */
+    if ( rho > 0. ) {
+      /* cas +45 degres */
+      alpha = Pi / 4.;
+    } else {
+      /* cas -45 degres */
+      alpha = -Pi / 4.;
+    }
+  } else {
+    /* cas general */
+    alpha = atan(2.*b/(a-c)) /2.;
+  }
+  coscar = cos(alpha);
+  sincar = sin(alpha);
+  cossin = coscar*sincar;
+  coscar *= coscar;
+  sincar *= sincar;
+  alpha *= 180./Pi;
+}
+
+sa = a*coscar+c*sincar+2.*b*cossin;
+sc = c*coscar+a*sincar-2.*b*cossin;
+sa = ( sa < 0. ) ? 1./sqrt(-sa) : 1./sqrt(sa);
+sc = ( sc < 0. ) ? 1./sqrt(-sc) : 1./sqrt(sc);
+
+if ( sa >= sc ) {
+  *smax = sa;
+  *axisrat = sc/sa;
+  *tiltdeg = alpha;
+} else {
+  *smax = sc;
+  *axisrat = sa/sc;
+  *tiltdeg = alpha+90.;
+  if ( *tiltdeg > 90. ) *tiltdeg = *tiltdeg-180.;
+}
+
+return(0);
+}
+
+/*========================================================================*/
+/*                               CMV 21/01/94 */
+/*
+++
+int_4 gaparam -
+  (float smax, float axisrat, float tiltdeg -
+  , float *sxin, float *syin, float *rhoin)
+
+	Pour transformer le sa,sc/sa,tiltdeg d'une gaussienne en sx,sy,rho
+	Pour calculer les parametres d'une gaussienne
+--
+*/
+/*
+++
+| - input : sa ]0,inf] ,axisrat ]0,1] ,tiltdeg ]-90,+90]
+|         sa (longeur du grand axe), axisrat (rapport des axes )
+|         tiltdeg (angle entre le grand axe et l'axe ox en degre)
+| - output : sx ]0,inf] , sy ]0,inf] , rho ]-1,1[
+| - Les fonctions sont:
+| exp[-0.5*{ (A/SA)**2                  +(C/SC)**2            }]
+| exp[-0.5*{[(x/SX)**2-2*RHO/(SX*SY)*x*y+(y/SY)**2]/(1-RHO**2)}]
+| - Voir aussi la remarque de la fonction paramga.
+--
+*/
+int_4 gaparam(float smax, float axisrat, float tiltdeg
+             , float *sxin, float *syin, float *rhoin)
+{
+double sx,sy,rho,alpha,coscar,sincar,cossin,sa,sc,a,b,c;
+
+*sxin = 0.; *syin = 0.; *rhoin = 0.;
+
+/* cas des coniques degenerees ou erreurs dans les parametres*/
+if ( smax <= 0. || axisrat <= 0. || axisrat > 1. ) return(-1);
+
+/* lecture des arguments */
+sa = smax;  sc = sa*axisrat;  alpha = tiltdeg*Pi/180.;
+
+coscar = cos(alpha);
+sincar = sin(alpha);
+cossin = coscar*sincar;
+coscar *= coscar;
+sincar *= sincar;
+
+a = 1./(coscar/sa/sa + sincar/sc/sc);
+  a = sqrt(a);         /* = sqrt(1-ro**2)*sx */
+b = 1./(sincar/sa/sa + coscar/sc/sc);
+  b = sqrt(b);         /* = sqrt(1-ro**2)*sy */
+c = cossin*(-1./sa/sa + 1./sc/sc);
+rho = c*a*b;
+sx = a / sqrt(1.-rho*rho);
+sy = b / sqrt(1.-rho*rho);
+
+*sxin = sx; *syin = sy; *rhoin = rho;
+
+return(0);
+}
+
+/*===================================================================*/
+/*
+++
+double nberfc(double x)
+	Erreur fonction complementaire: -log10(erfc)
+	Pratiquement pour avoir la proba que
+	]-inf,-x] U [x,+inf[ selon une loi gaussiene centree et normee
+	il faut appeler nberfc(x/sqrt(2))
+	Le job tiens compte de la saturation machine pour x grand.
+	La valeur est approximee au developpement limite de erfc
+	( see . Abramowitz p299 7.1.23 )
+--
+*/
+double nberfc(double x)
+{
+double v;
+if(x<0.) return(0.);
+if ( x < 10. ) {
+  v = erfc(x);
+  v = -log10(v);
+} else {
+  v = 2.*x*x;
+  v = 1./v - 3./(v*v) + 15./(v*v*v);
+  v += LnPi/2. + log(x) + x*x;
+  v /= Ln10;
+}
+return(v);
+}
+
+/*=========================================================================*/
+/*
+++
+float probnb(float sci2,int_4 inddl,int_4 *ipass)
+	Retourne -log10(p) ou p est la probabilte que le chi2
+	d'une fluctuation inddl points soit superieur a sci2.
+	ipass est le type de calcul utilise.
+--
+*/
+float probnb(float sci2,int_4 inddl,int_4 *ipass)
+{
+int_4 it;
+float nddl;
+double ci2,a1,a2,p,q,val,terme1,terme2,terme3,terme4,teradd,xnprim;
+
+*ipass = 0;
+val = 0.;
+nddl = inddl;
+ci2 = sci2;
+a1 = nddl/2.;
+a2 = ci2/2.;
+
+q = nbgammq(a1,a2);
+if(q>0. && q<1.) {
+  val = -log10(q);   /* moins le log10 de la proba que le chi2 soit > ci2 */
+  *ipass = 1;
+} else if ( q==1.) {
+  p = nbgammp(a1,a2);
+  val = p/Ln10;      /* -log10(q) = -log(1-p)/Ln10 = -(p)/Ln10 = p/Ln10 */
+  *ipass = 2;
+} else {
+  /* approximation de mimile */
+  xnprim = nddl / 2. - 1.;
+  terme1 = nddl / 2. * Log2;        /* 1/2**n */
+  terme2 = Hln2pi + (xnprim+0.5)*log(xnprim) - xnprim + 1./(12.*xnprim);
+  terme2 /= Ln10;         /* formule de stirling pour Gamma[nddl/2] */
+  terme3 = ci2/2. - xnprim*log(ci2);
+  terme3 /= Ln10;         /* exp(-ci2/2)*ci2**(n/2-1) */
+  terme4 = teradd = 1.;
+  for ( it=1; it <= inddl-2; it +=2) {
+    teradd *= ( (double) (nddl -1.) - (double) it ) / ci2;
+    terme4 += teradd;
+    if ( teradd < 1.e-4 ) break;
+  }
+  terme4 = -log10(2.*terme4);
+  val = terme1 + terme2 + terme3 + terme4;
+  *ipass = 3;
+}
+return ((float) val);
+}
+
+/*=========================================================================*/
+/*
+++
+double nbgammln(double xx)
+	Fonction log de la fonction Gamma
+--
+*/
+double nbgammln(double xx)
+{
+   double x,tmp,ser;
+   static double cof[6]={76.18009173,-86.50532033,24.01409822,
+      -1.231739516,0.120858003e-2,-0.536382e-5};
+   int_4 j;
+
+   x=xx-1.0;
+   tmp=x+5.5;
+   tmp -= (x+0.5)*log(tmp);
+   ser=1.0;
+   for (j=0;j<=5;j++) {
+      x += 1.0;
+      ser += cof[j]/x;
+   }
+   return -tmp+log(2.50662827465*ser);
+}
+
+/*=========================================================================*/
+/*
+++
+double nbgammq(double a,double x)
+	Fonction GammaQ
+--
+*/
+double nbgammq(double a,double x)
+{
+   double gamser,gammcf,gln;
+
+   if (x < 0.0 || a <= 0.0) { printf("Invalid arguments in routine NBGAMMQ (%f,%f)\n"
+                                    ,a,x); exit(-1);}
+   if (x < (a+1.0)) {
+      nbgser(&gamser,a,x,&gln);
+      return 1.0-gamser;
+   } else {
+      nbgcf(&gammcf,a,x,&gln);
+      return gammcf;
+   }
+}
+
+/*=========================================================================*/
+/*
+++
+double nbgammp(double a,double x)
+	Fonction GammaP
+--
+*/
+double nbgammp(double a,double x)
+{
+   double gamser,gammcf,gln;
+
+   if (x < 0.0 || a <= 0.0) { printf("Invalid arguments in routine NBGAMMP (%f,%f)\n"
+                                    ,a,x); exit(-1);}
+   if (x < (a+1.0)) {
+      nbgser(&gamser,a,x,&gln);
+      return gamser;
+   } else {
+      nbgcf(&gammcf,a,x,&gln);
+      return 1.0-gammcf;
+   }
+}
+
+/*=========================================================================*/
+void nbgcf(double *gammcf,double a,double x,double *gln)
+{
+   int_4 n;
+   double gold=0.0,g,fac=1.0,b1=1.0;
+   double b0=0.0,anf,ana,an,a1,a0=1.0;
+
+   *gln=nbgammln(a);
+   a1=x;
+   for (n=1;n<=ITMAX;n++) {
+      an=(double) n;
+      ana=an-a;
+      a0=(a1+a0*ana)*fac;
+      b0=(b1+b0*ana)*fac;
+      anf=an*fac;
+      a1=x*a0+anf*a1;
+      b1=x*b0+anf*b1;
+      if (a1) {
+         fac=1.0/a1;
+         g=b1*fac;
+         if (fabs((g-gold)/g) < EPS) {
+            *gammcf=exp(-x+a*log(x)-(*gln))*g;
+            return;
+         }
+         gold=g;
+      }
+   }
+   printf("a too large, ITMAX too small in routine NBGCF (%f,%f)\n",a,x); exit(-1);
+}
+
+/*=========================================================================*/
+void nbgser(double *gamser,double a,double x,double *gln)
+{
+   int_4 n;
+   double sum,del,ap;
+
+   *gln=nbgammln(a);
+   if (x <= 0.0) {
+      if (x < 0.0) { printf("x less than 0 in routine NBGSER (%f,%f)\n",a,x); exit(-1); }
+      *gamser=0.0;
+      return;
+   } else {
+      ap=a;
+      del=sum=1.0/a;
+      for (n=1;n<=ITMAX;n++) {
+         ap += 1.0;
+         del *= x/ap;
+         sum += del;
+         if (fabs(del) < fabs(sum)*EPS) {
+            *gamser=sum*exp(-x+a*log(x)-(*gln));
+            return;
+         }
+      }
+      printf("a too large, ITMAX too small in routine NBGSER (%f,%f)\n",a,x); exit(-1);
+      return;
+   }
+}
+
+/*==========================================================================*/
+/*
+++
+void Set_Ihoq(int degre,int *mIhoqN,double *IhoqNX,double *IhoqNW)
+	Set mIhoqN,IhoqNX,IhoqNW pour integration Gauss-Legendre
+--
+*/
+void Set_Ihoq(int degre,int *mIhoqN,double *IhoqNX,double *IhoqNW)
+{
+switch (degre) {
+  case  2:
+         *mIhoqN = mIhoq2;
+          IhoqNX = Ihoq2X;
+          IhoqNW = Ihoq2W;
+          break;
+  case  3:
+         *mIhoqN = mIhoq3;
+          IhoqNX = Ihoq3X;
+          IhoqNW = Ihoq3W;
+          break;
+  case  4:
+         *mIhoqN = mIhoq4;
+          IhoqNX = Ihoq4X;
+          IhoqNW = Ihoq4W;
+          break;
+  case  5:
+         *mIhoqN = mIhoq5;
+          IhoqNX = Ihoq5X;
+          IhoqNW = Ihoq5W;
+          break;
+  case  6:
+         *mIhoqN = mIhoq6;
+          IhoqNX = Ihoq6X;
+          IhoqNW = Ihoq6W;
+          break;
+  case  7:
+         *mIhoqN = mIhoq7;
+          IhoqNX = Ihoq7X;
+          IhoqNW = Ihoq7W;
+          break;
+  case  8:
+         *mIhoqN = mIhoq8;
+          IhoqNX = Ihoq8X;
+          IhoqNW = Ihoq8W;
+          break;
+  case  9:
+         *mIhoqN = mIhoq9;
+          IhoqNX = Ihoq9X;
+          IhoqNW = Ihoq9W;
+          break;
+  case 10:
+         *mIhoqN = mIhoq10;
+          IhoqNX = Ihoq10X;
+          IhoqNW = Ihoq10W;
+          break;
+  case 16:
+         *mIhoqN = mIhoq16;
+          IhoqNX = Ihoq16X;
+          IhoqNW = Ihoq16W;
+          break;
+  default:
+         *mIhoqN = mIhoq8;
+          IhoqNX = Ihoq8X;
+          IhoqNW = Ihoq8W;
+          break;
+}
+return;
+}
+
+/*==========================================================================*/
+/*
+++
+int Get_Ihoq(int degre,double *ihoqnx,double *ihoqnw)
+	Ecrit les positions et les poids pour l'integration de Gauss-Legendre
+	dans les tableaux *ihoqnx,*ihoqnw.
+	Retourne le nombre de points.
+	Si *ihoqnx==NULL ou *ihoqnw==NULL
+	retourne seulement le nombre de points (cad la taille minimale
+        que doivent les tableaux *ihoqnx,*ihoqnw).
+--
+*/
+int Get_Ihoq(int degre,double *ihoqnx,double *ihoqnw)
+{
+int mIhoqN, i;
+double *IhoqNX, *IhoqNW;
+switch (degre) {
+  case  2:
+          mIhoqN = mIhoq2;
+          IhoqNX = Ihoq2X;
+          IhoqNW = Ihoq2W;
+          break;
+  case  3:
+          mIhoqN = mIhoq3;
+          IhoqNX = Ihoq3X;
+          IhoqNW = Ihoq3W;
+          break;
+  case  4:
+          mIhoqN = mIhoq4;
+          IhoqNX = Ihoq4X;
+          IhoqNW = Ihoq4W;
+          break;
+  case  5:
+          mIhoqN = mIhoq5;
+          IhoqNX = Ihoq5X;
+          IhoqNW = Ihoq5W;
+          break;
+  case  6:
+          mIhoqN = mIhoq6;
+          IhoqNX = Ihoq6X;
+          IhoqNW = Ihoq6W;
+          break;
+  case  7:
+          mIhoqN = mIhoq7;
+          IhoqNX = Ihoq7X;
+          IhoqNW = Ihoq7W;
+          break;
+  case  8:
+          mIhoqN = mIhoq8;
+          IhoqNX = Ihoq8X;
+          IhoqNW = Ihoq8W;
+          break;
+  case  9:
+          mIhoqN = mIhoq9;
+          IhoqNX = Ihoq9X;
+          IhoqNW = Ihoq9W;
+          break;
+  case 10:
+          mIhoqN = mIhoq10;
+          IhoqNX = Ihoq10X;
+          IhoqNW = Ihoq10W;
+          break;
+  case 16:
+          mIhoqN = mIhoq16;
+          IhoqNX = Ihoq16X;
+          IhoqNW = Ihoq16W;
+          break;
+  default:
+          mIhoqN = mIhoq8;
+          IhoqNX = Ihoq8X;
+          IhoqNW = Ihoq8W;
+          break;
+}
+if( ihoqnx!=NULL && ihoqnw!=NULL ) {
+  for(i=0;i<mIhoqN;i++) {
+    ihoqnx[i] = IhoqNX[i];
+    ihoqnw[i] = IhoqNW[i];
+  }
+}
+return(mIhoqN);
+}
+
+/*===================================================================*/
+#define EPS_gauleg 3.0e-11
+/*
+++
+void nbgauleg(double x1,double x2,double *x,double *w,int n)
+	Integration des fonctions a une dimension y=f(x)
+	par la Methode de Gauss-Legendre.
+	Calcul des coefficients du developpement
+--
+*/
+/*
+++
+| INPUT:
+|  x1,x2 : bornes de l'intervalle (dans nbinteg.h -> x1=-0.5 x2=0.5)
+|  n = degre du developpement
+| OUTPUT:
+|  x[] = valeur des abscisses ou l'on calcule (dim=n)
+|  w[] = valeur des coefficients associes
+| REMARQUES:
+|  - x et w doivent au moins etre dimensionner a n.
+|  - l'integration est rigoureuse si sur l'intervalle d'integration
+|    la fonction f(x) peut etre approximee par un polynome
+|    de degre 2*m (monome le + haut x**(2*n-1) )
+|  - Voir la fonction Integ_Fun pour un calcul d'ordre 8
+--
+*/
+void nbgauleg(double x1,double x2,double *x,double *w,int n)
+{
+   int m,j,i;
+   double z1,z,xm,xl,pp,p3,p2,p1;
+
+   m=(n+1)/2;
+   xm=0.5*(x2+x1);
+   xl=0.5*(x2-x1);
+   for (i=1;i<=m;i++)  {
+      z=cos(3.141592654*(i-0.25)/(n+0.5));
+      do {
+         p1=1.0;
+         p2=0.0;
+         for (j=1;j<=n;j++) {
+            p3=p2;
+            p2=p1;
+            p1=((2.0*j-1.0)*z*p2-(j-1.0)*p3)/j;
+         }
+         pp=n*(z*p1-p2)/(z*z-1.0);
+         z1=z;
+         z=z1-p1/pp;
+      } while (fabs(z-z1) > EPS_gauleg);
+      x[i-1]=xm-xl*z;
+      x[n-i]=xm+xl*z;
+      w[i-1]=2.0*xl/((1.0-z*z)*pp*pp);
+      w[n-i]=w[i-1];
+   }
+}
+#undef EPS_gauleg
+
+/*==========================================================================*/
+/*
+++
+double Integ_Fun(double xmin,double xmax,double (*fonc)(double),int npas)
+	Pour integrer la fonction fonc de xmin a xmax sur npas.
+	On emploit une methode Higher-order-gaussienne d'ordre 8, ce qui
+	fait un calcul equivalent de N*npas pas.
+--
+*/
+double Integ_Fun(double xmin,double xmax,double (*fonc)(double),int npas)
+{
+int i,j;
+double dlim,sum,xc,xci;
+
+if( xmax <= xmin ) return(0.);
+if( npas <= 0 ) npas=1;
+sum = 0.;
+dlim = (xmax-xmin)/npas;
+for(i=0;i<npas;i++) {
+  xci = (double) i + 0.5;
+  for(j=0;j<mIhoq8;j++) {
+    xc = xmin + ( xci + Ihoq8X[j] ) * dlim;
+    sum += fonc(xc) * Ihoq8W[j];
+} }
+return(sum*dlim);
+}
+
+/*=========================================================================*/
+/*
+++
+double Integ_Fun_2D -
+  (double (*fonc)(double x,double y) -
+  ,double xmin,double xmax,double ymin,double ymax -
+  ,int npasx,int npasy)
+
+	Integration 2D de fonc(x,y) dans le carre [xmin,xmax] et [ymin,ymax]
+--
+*/
+double Integ_Fun_2D(double (*fonc)(double x,double y)
+                ,double xmin,double xmax,double ymin,double ymax
+                ,int npasx,int npasy)
+{
+int i,j;
+double x,y,pasx,pasy,sum,sumy;
+
+pasx = (xmax-xmin)/npasx;
+pasy = (ymax-ymin)/npasy;
+
+sum = 0.;
+for(i=0;i<npasx;i++) {
+  x = xmin + ((double) i + 0.5 ) * pasx;
+  sumy = 0.;
+  for(j=0;j<npasy;j++) {
+    y = ymin + ((double) j + 0.5 ) * pasy;
+    sumy += fonc(x,y);
+  }
+  sum += sumy;
+}
+return( sum*pasx*pasy);
+}
+
+/*=========================================================================*/
+/*                                    Christophe 01/07/94 */
+/*
+++
+void Set_FitFunDPol(int DPol)
+	Pour donner l'ordre du polynome pour le fit.
+--
+*/
+void Set_FitFunDPol(int DPol) 
+{
+FITFUN_DPOL = DPol;
+}
+
+/*==================================================================*/
+/*                                             Christophe 01/07/94  */
+/*
+++
+double Gauss1DPolF(double x,double *Par,double *DgDpar) 
+	Fonction de fit Gausienne+polynome.
+--
+*/
+/*
+++
+|  f(x) = par[0]*exp[-0.5*( (x-par[1]) / par[2] )**2 ]
+|        +par[3] + par[4]*x + .... + par[3+FITFUN_DPOL]*x**FITFUN_DPOL
+|  FITFUN_DPOL peut etre definit avec la routine Set_FitFunDPol
+--
+*/
+double Gauss1DPolF(double x,double *Par,double *DgDpar) 
+{
+double f,xc,xc2,e,xpow;
+int i;
+
+xc = (x-Par[1])/Par[2];
+xc2 = xc*xc;
+e = exp(-0.5*xc2);
+f = Par[0]*e;
+
+DgDpar[0] = e;
+DgDpar[1] = xc / Par[2] *f;
+DgDpar[2] = xc2/ Par[2] *f;
+
+if(FITFUN_DPOL>=0) {
+  xpow = 1.;
+  for(i=0;i<=FITFUN_DPOL;i++) {
+    DgDpar[3+i] = xpow;
+    f += Par[3+i]*xpow;
+    xpow *= x;
+  }
+}
+
+return (f);
+}
+
+/*==================================================================*/
+/*                                             Christophe 29/08/95  */
+/*
+++
+double GaussI1DPol(double x,double *Par,double *DgDpar) 
+	Fonction de fit Gausienne integree+polynome.
+--
+*/
+/*
+++
+|  f(x) = par[0] / (sqrt(2*Pi)*par[2]) * exp[-0.5*( (x-par[1]) / par[2] )**2 ]
+|        +par[3] + par[4]*x + .... + par[3+FITFUN_DPOL]*x**FITFUN_DPOL
+|  FITFUN_DPOL peut etre definit avec la routine Set_FitFunDPol
+--
+*/
+double GaussI1DPol(double x,double *Par,double *DgDpar) 
+{
+double f,xc,xc2,e,xpow;
+int i;
+
+xc = (x-Par[1])/Par[2];
+xc2 = xc*xc;
+e = exp(-0.5*xc2)/(S2Pi*Par[2]);
+f = Par[0]*e;
+
+DgDpar[0] = e;
+DgDpar[1] = xc / Par[2] *f;
+DgDpar[2] = (xc2-1.)/ Par[2] *f;
+
+if(FITFUN_DPOL>=0) {
+  xpow = 1.;
+  for(i=0;i<=FITFUN_DPOL;i++) {
+    DgDpar[3+i] = xpow;
+    f += Par[3+i]*xpow;
+    xpow *= x;
+  }
+}
+
+return (f);
+}
+
+/*====================================================================*/
+/*                                             Christophe 01/07/94    */
+/*
+++
+double Polyn1D(double x,double *Par,double *DgDpar) 
+	Fonction de fit de polynome.
+--
+*/
+/*
+++
+|  f(x) = par[0] + par[1]*x + .... + par[FITFUN_DPOL]*x**FITFUN_DPOL
+|  FITFUN_DPOL peut etre definit avec la routine Set_FitFunDPol
+--
+*/
+double Polyn1D(double x,double *Par,double *DgDpar) 
+{
+double f,xpow;
+int i,DPol;
+
+DPol = (FITFUN_DPOL<0) ? 0 : FITFUN_DPOL ;
+xpow = 1.;
+f = 0.;
+for(i=0;i<=DPol;i++)
+  {
+  DgDpar[i] = xpow;
+  f += Par[i]*xpow;
+  xpow *= x;
+  }
+return (f);
+}
+
+/*=========================================================================*/
+/*
+++
+double FitProp(double *x,double *y,double *ey,int *n,double *a1)
+	Fit d'une proportion a1: y = a1 * x
+--
+*/
+/*
+++
+| Input:
+|    x = tableau des abscisses
+|    y = tableau des ordonnees
+|    ey = erreurs sur les y
+|    n = nombre de donnees en entree
+| Output:
+|    n = nombre de points utilises (point non utilise si ey<=0)
+|    a1 coefficient
+| Return:
+|    valeur du xi2 si fit reussi,
+|    -1. si pas assez de points
+|    -2. si determinant negatif
+--
+*/
+double FitProp(double *x,double *y,double *ey,int *n,double *a1)
+{
+register int i,np;
+register double X2,XY,Y2,w;
+
+np=0;
+X2=XY=Y2=*a1=0.;
+for(i=0;i<*n;i++) {
+  if(ey[i]<=0.) continue;
+  np++;
+  w = ey[i]*ey[i];
+  X2 += x[i]*x[i]/w;
+  XY += x[i]*y[i]/w;
+  Y2 += y[i]*y[i]/w;
+}
+*n = np;
+if(np<1) return(-1.);
+if(X2==0.) return(-2.);
+*a1 = XY/X2;
+w = Y2 + *a1**a1*X2 -2.**a1*XY;
+return(w);
+}
+
+/*=========================================================================*/
+/*
+++
+double FitLin(double *x,double *y,double *ey,int *n,double *a0,double *a1)
+	Fit d'une droite: y=a0+a1*x
+--
+*/
+/*
+++
+| Input:
+|    x = tableau des abscisses
+|    y = tableau des ordonnees
+|    ey = erreurs sur les y
+|    n = nombre de donnees en entree
+| Output:
+|    n = nombre de points utilises (point non utilise si ey<=0)
+|    a0,a1 coefficients de la droite
+| Return:
+|    valeur du xi2 si fit reussi,
+|    -1. si pas assez de points
+|    -2. si determinant negatif
+--
+*/
+double FitLin(double *x,double *y,double *ey,int *n,double *a0,double *a1)
+{
+register int i,np;
+register double I,X,X2,Y,XY,Y2,w;
+
+np=0;
+Y2=I=X=X2=Y=XY=*a0=*a1=0.;
+for(i=0;i<*n;i++) {
+  if(ey[i]<=0.) continue;
+  np++;
+  w = ey[i]*ey[i];
+  I  += 1./w;
+  X  += x[i]/w;
+  X2 += x[i]*x[i]/w;
+  Y  += y[i]/w;
+  Y2 += y[i]*y[i]/w;
+  XY += x[i]*y[i]/w;
+}
+*n = np;
+if(np<2) return(-1.);
+w = X*X-X2*I;
+if(w==0.) return(-2.);
+*a1 = (Y*X-XY*I)/w;
+*a0 = (X*XY-X2*Y)/w;
+w = Y2 + *a0**a0*I + *a1**a1*X2
+    + 2.*( - Y**a0  - *a1*XY + *a0**a1*X );
+return(w);
+}
+
+/*=========================================================================*/
+/*
+++
+double FitPar(double *x,double *y,double *ey,int *n,double *a0,double *a1,double *a2)
+	Fit d'une parabole: y=a0+a1.x+a2.x^2
+--
+*/
+/*
+++
+| Input:
+|    x = tableau des abscisses
+|    y = tableau des ordonnees
+|    ey = erreurs sur les y
+|    n = nombre de donnees en entree
+| Output:
+|    n = nombre de points utilises (point non utilise si ey<=0)
+|    a0,a1 coefficients de la droite
+| Return:
+|    valeur du xi2 si fit reussi,
+|    -1. si pas assez de points
+|    -2. si determinant negatif
+--
+*/
+double FitPar(double *x,double *y,double *ey,int *n,double *a0,double *a1,double *a2)
+{
+register int i,np;
+register double I,X,X2,X3,X4,Y,Y2,XY,X2Y,w,x2;
+
+np=0;
+I=X=X2=X3=X4=Y=Y2=XY=X2Y=*a0=*a1=*a2=0.;
+
+for(i=0;i<*n;i++) {
+  if(ey[i]<=0.) continue;
+  np++;
+  x2 = x[i]*x[i];
+  w = ey[i]*ey[i];
+  I   += 1./w;
+  X   += x[i]/w;
+  X2  += x2/w;
+  X3  += x2*x[i]/w;
+  X4  += x2*x2/w;
+  Y   += y[i]/w;
+  Y2  += y[i]*y[i]/w;
+  XY  += x[i]*y[i]/w;
+  X2Y += x2*y[i]/w;
+}
+*n = np;
+if(np<3) return(-1.);
+w = X2*(X2*X2-X3*X) -X*(X3*X2-X4*X) +I*(X3*X3-X4*X2);
+if(w==0.) return(-2.);
+*a2 =  (Y*(X2*X2-X3*X)  -XY*(X*X2-X3*I)  +X2Y*(X*X-X2*I)  )/w;
+*a1 = -(Y*(X3*X2-X4*X)  -XY*(X2*X2-X4*I) +X2Y*(X2*X-X3*I) )/w;
+*a0 =  (Y*(X3*X3-X4*X2) -XY*(X2*X3-X4*X) +X2Y*(X2*X2-X3*X))/w;
+w = Y2 + *a0**a0*I + *a1**a1*X2 + *a2**a2*X4
+    +2.*( -Y**a0  -*a1*XY -*a2*X2Y
+          +*a0**a1*X +*a0**a2*X2+*a1**a2*X3 );
+return(w);
+}
+
+/*=========================================================================*/
+/*
+++
+double FitParLin -
+  (double *xx,double *y,double *ey,int *n,double x0,int Deg_d -
+  ,double *a0,double *a1,double *b1,double *b2)
+
+--
+*/
+/*
+++
+| Fit d'une parabole: y=a0+b1*(x-x0)+b2*(x-x0)**2
+|                                     pour x>x0
+|    et d'une droite: y=a0+a1*(x-x0)  pour x<=x0
+| Input:
+|    x = tableau des abscisses
+|    y = tableau des ordonnees
+|    ey = erreurs sur les y
+|    n = nombre de donnees en entree
+|    x0 = abscisse du point pivot (il n'est pas fitte)
+|    Deg_d = degre du fit a droite de x0 (1 ou 2)
+| Output:
+|    n = nombre de points utilises (point non utilise si ey<=0)
+|    a0,a1 coefficients de la droite
+|    a0,b1,b2 coefficients de la parabole
+--
+*/
+/*
+++
+| Return:
+|    valeur du xi2 si fit reussi,
+|    -1. si pas assez de points
+|    -2. si determinant negatif
+| Remarque:
+|    Il faut evidemment au moins 2 points a gauche du pivot x0
+|                       et 3 points a droite du pivot x0
+| Matrices A * a = B :
+|        |   I_   X_g   X_d X2_d |   | a0 |   |    Y_ |
+|        |  X_g  X2_g     0    0 | * | a1 | = |  XY_g |
+|        |  X_d     0  X2_d X3_d |   | b1 |   |  XY_d |
+|        | X2_d     0  X3_d X4_d |   | b2 |   | X2Y_d |
+--
+*/
+double FitParLin(double *xx,double *y,double *ey,int *n,double x0,int Deg_d
+                ,double *a0,double *a1,double *b1,double *b2)
+{
+int i,np,npg,npd,nddl;
+double w,x,x2,A[4][4],B[4];
+double Y2,I,Y,X_g,X2_g,XY_g,X_d,X2_d,X3_d,X4_d,XY_d,X2Y_d;
+
+if( Deg_d<1 || Deg_d>2 ) Deg_d=2;
+nddl = Deg_d + 2;
+*a0=*a1=*b1=*b2=0.;
+Y2=I=Y=X_g=X2_g=XY_g=X_d=X2_d=X3_d=X4_d=XY_d=X2Y_d=0.;
+np=npg=npd=0;
+for(i=0;i<*n;i++) {
+  if(ey[i]<=0.) continue;
+  np++;
+  x = xx[i]-x0;
+  x2 = x*x;
+  w = ey[i]*ey[i];
+  I  += 1./w;
+  Y  += y[i]/w;
+  Y2 += y[i]*y[i]/w;
+  if(x<=0.) {
+    if(x<0.) npg++;
+    X_g  += x/w;
+    X2_g += x2/w;
+    XY_g += x*y[i]/w;;
+  } else {
+    npd++;
+    X_d   += x/w;
+    X2_d  += x2/w;
+    X3_d  += x2*x/w;
+    X4_d  += x2*x2/w;
+    XY_d  += x*y[i]/w;;
+    X2Y_d += x2*y[i]/w;;
+  }
+}
+*n = np;
+A[0][0] = I;
+A[1][1] = X2_g;
+A[3][3] = X4_d;
+A[0][1] = A[1][0] = X_g;
+A[0][2] = A[2][0] = X_d;
+A[3][2] = A[2][3] = X3_d;
+A[0][3] = A[3][0] = A[2][2] = X2_d;
+A[1][2] = A[2][1] = A[1][3] = A[3][1] = 0.;
+B[0] = Y;
+B[1] = XY_g;
+B[2] = XY_d;
+B[3] = X2Y_d;
+if( np<4 || npg < 1 || npd < 2 ) return(-1.);
+w = GausPiv(&A[0][0],4,nddl,B,1,1,0);
+if(w==0.) return(-2.);
+*a0 = B[0];
+*a1 = B[1];
+*b1 = B[2];
+if(nddl==4) *b2 = B[3];
+w = Y2 + *a0**a0*I + *a1**a1*X2_g + *b1**b1*X2_d + *b2**b2*X4_d
+  + 2.*( - *a0*Y - *a1*XY_g + *a0**a1*X_g
+         - *b1*XY_d - *b2*X2Y_d + *a0**b1*X_d + *a0**b2*X2_d + *b1**b2*X3_d
+       );
+return(w);
+}
+
+/*=========================================================================*/
+/*
+++
+double FitPropClean(double *x,double *y,double *ey,int *n,double per_clean,double *a1)
+	Fit de y(i) = a1*x(i) en deux passes:
+--
+*/
+/*
+++
+|   1-/ fit avec tous les points
+|   2-/ fit ou on enleve les per_clean*n points les plus eloignes
+| Input:
+|    x = tableau des abscisses
+|    y = tableau des ordonnees
+|    ey = erreurs sur les y
+|    n = nombre de donnees en entree
+|    per_clean = pourcentage des points a tuer pour la seconde passe
+--
+*/
+/*
+++
+| Output:
+|    n = nombre de points utilises (point non utilise si ey<=0)
+|    a1 = coefficients de proportionalite
+| Return:
+|    valeur du xi2 si fit reussi,
+|    -1. si echec fit passe no 1
+|    -2. si echec fit passe no 2
+|    -3. si probleme malloc
+|    -4. si probleme nombre de points a tuer
+--
+*/
+double FitPropClean(double *x,double *y,double *ey,int *n,double per_clean,double *a1)
+{
+int npt,k,i,nclass;
+double *class,aa1,c2,cut;
+
+*a1 =0.;
+
+/* 1ere passe */
+npt = *n;
+c2 = FitProp(x,y,ey,&npt,&aa1);
+if(c2<0.) {*n = npt; return(-1.);}
+*a1 = aa1;
+/* printf("pass 1: %g*x c2=%g/%d\n",*a1,c2,npt); */
+
+class = malloc( *n * sizeof(double) );
+if( class == NULL ) {*n=npt; return(-3.);}
+
+/* elimination des mauvais points */
+nclass = 0;
+for(i=0;i<*n;i++) {
+  if(ey[i]<=0.) continue;
+  c2 = (y[i]-aa1*x[i])/ey[i];
+  class[nclass] = c2*c2;
+  nclass++;
+}
+qsort(class,(size_t) nclass,(size_t) sizeof(double),qSort_Dble);
+k = (int) ( (1. - per_clean ) * (double) nclass );
+if(k<0) k=0;
+if(k>=nclass) k = nclass-1;
+cut = class[k];
+k = 0;
+for(i=0;i<*n;i++) {
+  class[i] = ey[i];
+  c2 = (y[i]-aa1*x[i])/ey[i];
+  c2 *= c2;
+  if(ey[i]>0. && c2>cut) {class[i] = -1.; k++;}
+}
+/* printf("nombre pt tues %d cut=%g\n",k,cut); */
+
+/* 2sd passe */
+npt = *n;
+c2 = FitProp(x,y,class,&npt,&aa1);
+if(c2<0.) {*n = npt; free(class); return(-2.);}
+*a1 = aa1;
+*n = npt;
+/* printf("pass 2: %g*x c2=%g/%d\n",*a1,c2,npt); */
+
+free(class);
+return(c2);
+}
+
+/*=========================================================================*/
+/*
+++
+double FitLinClean -
+  (double *x,double *y,double *ey,int *n -
+  ,double per_clean,double *a0,double *a1)
+
+	Fit de y(i) = a0 + a1*x(i) en deux passes:
+--
+*/
+/*
+++
+|   1-/ fit avec tous les points
+|   2-/ fit ou on enleve les per_clean*n points les plus eloignes
+| Input:
+|    x = tableau des abscisses
+|    y = tableau des ordonnees
+|    ey = erreurs sur les y
+|    n = nombre de donnees en entree
+|    per_clean = pourcentage des points a tuer pour la seconde passe
+| Output:
+|    n = nombre de points utilises (point non utilise si ey<=0)
+|    a0,a1 = coefficients de la droite
+--
+*/
+/*
+++
+| Return:
+|    valeur du xi2 si fit reussi,
+|    -1. si echec fit passe no 1
+|    -2. si echec fit passe no 2
+|    -3. si probleme malloc
+|    -4. si probleme nombre de points a tuer
+--
+*/
+double FitLinClean(double *x,double *y,double *ey,int *n
+                  ,double per_clean,double *a0,double *a1)
+{
+int npt,k,i,nclass;
+double *class,aa0,aa1,c2,cut;
+
+*a0 = *a1 =0.;
+
+/* 1ere passe */
+npt = *n;
+c2 = FitLin(x,y,ey,&npt,&aa0,&aa1);
+if(c2<0.) {*n = npt; return(-1.);}
+*a0 = aa0;
+*a1 = aa1;
+/* printf("pass 1: %g + %g*x c2=%g/%d\n",*a0,*a1,c2,npt); */
+
+class = malloc( *n * sizeof(double) );
+if( class == NULL ) {*n=npt; return(-3.);}
+
+/* elimination des mauvais points */
+nclass = 0;
+for(i=0;i<*n;i++) {
+  if(ey[i]<=0.) continue;
+  c2 = (y[i]-(aa0+aa1*x[i]))/ey[i];
+  class[nclass] = c2*c2;
+  nclass++;
+}
+qsort(class,(size_t) nclass,(size_t) sizeof(double),qSort_Dble);
+k = (int) ( (1. - per_clean ) * (double) nclass );
+if(k<0) k=0;
+if(k>=nclass) k = nclass-1;
+cut = class[k];
+k = 0;
+for(i=0;i<*n;i++) {
+  class[i] = ey[i];
+  c2 = (y[i]-(aa0+aa1*x[i]))/ey[i];
+  c2 *= c2;
+  if(ey[i]>0. && c2>cut) {class[i] = -1.; k++;}
+}
+/* printf("nombre pt tues %d cut=%g\n",k,cut); */
+
+/* 2sd passe */
+npt = *n;
+c2 = FitLin(x,y,class,&npt,&aa0,&aa1);
+if(c2<0.) {*n = npt; free(class); return(-2.);}
+*a0 = aa0;
+*a1 = aa1;
+*n = npt;
+/* printf("pass 2: %g + %g*x c2=%g/%d\n",*a0,*a1,c2,npt); */
+
+free(class);
+return(c2);
+}
+
+/*===================================================================*/
+/*
+++
+double FitParClean -
+  (double *x,double *y,double *ey,int *n -
+  ,double per_clean,double *a0,double *a1,double *a2)
+
+	Fit de y(i) = a0 + a1*x(i) + a2*x(i)^2 en deux passes:
+--
+*/
+/*
+++
+|   1-/ fit avec tous les points
+|   2-/ fit ou on enleve les per_clean*n points les plus eloignes
+| Input:
+|    x = tableau des abscisses
+|    y = tableau des ordonnees
+|    ey = erreurs sur les y
+|    n = nombre de donnees en entree
+|    per_clean = pourcentage des points a tuer pour la seconde passe
+| Output:
+|    n = nombre de points utilises (point non utilise si ey<=0)
+|    a0,a1,a2 = coefficients de la parabole
+| Return:
+|    valeur du xi2 si fit reussi,
+|    -1. si echec fit passe no 1
+|    -2. si echec fit passe no 2
+|    -3. si probleme malloc
+|    -4. si probleme nombre de points a tuer
+--
+*/
+double FitParClean(double *x,double *y,double *ey,int *n
+                  ,double per_clean,double *a0,double *a1,double *a2)
+{
+int npt,k,i,nclass;
+double *class,aa0,aa1,aa2,c2,cut;
+
+*a0 = *a1 = *a2 =0.;
+
+/* 1ere passe */
+npt = *n;
+c2 = FitPar(x,y,ey,&npt,&aa0,&aa1,&aa2);
+if(c2<0.) {*n = npt; return(-1.);}
+*a0 = aa0;
+*a1 = aa1;
+*a2 = aa2;
+/* printf("pass 1: %g + %g*x + %g*x**2 c2=%g/%d\n",*a0,*a1,*a2,c2,npt); */
+
+class = malloc( *n * sizeof(double) );
+if( class == NULL ) {*n=npt; return(-3.);}
+
+/* elimination des mauvais points */
+nclass = 0;
+for(i=0;i<*n;i++) {
+  if(ey[i]<=0.) continue;
+  c2 = (y[i]-(aa0+aa1*x[i]+aa2*x[i]*x[i]))/ey[i];
+  class[nclass] = c2*c2;
+  nclass++;
+}
+qsort(class,(size_t) nclass,(size_t) sizeof(double),qSort_Dble);
+k = (int) ( (1. - per_clean ) * (double) nclass );
+if(k<0) k=0;
+if(k>=nclass) k = nclass-1;
+cut = class[k];
+k = 0;
+for(i=0;i<*n;i++) {
+  class[i] = ey[i];
+  c2 = (y[i]-(aa0+aa1*x[i]+aa2*x[i]*x[i]))/ey[i];
+  c2 *= c2;
+  if(ey[i]>0. && c2>cut) {class[i] = -1.; k++;}
+}
+/* printf("nombre pt tues %d cut=%g\n",k,cut); */
+
+/* 2sd passe */
+npt = *n;
+c2 = FitPar(x,y,class,&npt,&aa0,&aa1,&aa2);
+if(c2<0.) {*n = npt; free(class); return(-2.);}
+*a0 = aa0;
+*a1 = aa1;
+*a2 = aa2;
+*n = npt;
+/* printf("pass 2: %g + %g*x + %g*x**2 c2=%g/%d\n",*a0,*a1,*a2,c2,npt); */
+
+free(class);
+return(c2);
+}
+
+/*===========================================================*/
+/*
+++
+float interpole(float m,int n,float *t1,float *t2)
+	Interpolation lineaire y=f(x):
+--
+*/
+/*
+++
+|   t1[n] = tableau des x
+|   t2[n] = tableau des y
+|   m = valeur ou on interpole
+|   RETURN: f(m)
+--
+*/
+float interpole(float m,int n,float *t1,float *t2)
+{
+int i,n1;
+float r;
+
+if ( n == 1 ) return ( t2[0] );
+
+n1=n-1;
+if ( m < t1[0] )  m=t1[0];
+if ( m > t1[n1] ) m=t1[n1];
+
+for(i=0;i<n;i++) if ( m <= t1[i] ) break;
+i = (i==0) ? 1  : i;
+i = (i==n) ? n1 : i;
+
+r = t2[i-1] + (t2[i]-t2[i-1]) / (t1[i]-t1[i-1]) * (m-t1[i-1]);
+
+/*
+printf("interpole: i=%3d m=%g t1=%g %g t2=%g %g r=%g\n"
+      ,i,m,t1[i-1],t1[i],t2[i-1],t2[i],r);
+for(i=0;i<n;i++) printf(" (%g,%g)",t1[i],t2[i]); printf("\n");
+*/
+
+return(r);
+}
+
+/*=========================================================*/
+/*                         Christophe 10/11/93 La Silla    */
+/*
+++
+int_4 MeanSig(float *mag,float *err,int_4 *ndata,float nsigma,float *mean,float *sigma)
+	Fonction de calcul de la moyenne tronquee et du sigma d'un tableau
+--
+*/
+/*
+++
+| Methode: 1-/ moyenne-sigma, 2-/ moyenne tronquee et sigma,
+| ENTREE:
+|  mag: magnitude
+|  err: erreur sur la magnitude
+|  ndata: nombre de donnees
+|  nsigma: nombre de sigma dans lequel on calcule le maximum
+|          si <=0, une seule passe pour la moyenne
+| SORTIE:
+|  ndata: nombre de data utilises pour calculer mean et sigma
+|  mean: moyenne des donnees
+|  sigma: sigma des donnees
+|  MeanSig: 0 si calcul ok, <0 sinon
+--
+*/
+int_4 MeanSig(float *mag,float *err,int_4 *ndata,float nsigma,float *mean,float *sigma)
+{
+int_4 deb=DEB_MeanSig;
+int_4 pass,passmx,i,n=0;
+double m,s2,v,scut;
+
+*mean = *sigma = 0.;
+passmx = ( nsigma <= 0. ) ? 1 : 2 ;
+for (pass=1;pass<=passmx;pass++) {
+  m = s2 = 0.;
+  n=0;
+  scut = GRAND;
+  if( pass == 2 ) scut=nsigma* *sigma;
+  for (i=0;i<*ndata;i++) {
+    v = *(mag+i);
+    if( *(err+i) > 0. && fabs(v-*mean) < scut ) {
+      n++;
+      m += v;
+      s2 += v * v;
+  } }
+  if ( n >= 2 ) {
+    *mean = m / n;
+    *sigma = sqrt( s2 / n - m/n * m/n );
+  } else {
+    *mean = *sigma = 0.;
+    *ndata=n;
+    return(-1);
+  }
+  if ( deb>0 ) printf("MeanSig: pass=%d mean=%f sigma=%f n=%d\n"
+                   ,pass,*mean,*sigma,n);
+}
+*ndata=n;
+return(0);
+}
+
+/*=========================================================================*/
+/*
+++
+int Most_Probable -
+  ( float *val, int nval, float binin, int nmoy -
+  , float low, float high, float *most, int deb)
+
+	Pour calculer la valeur la plus probable par maximum d'histogramme.
+--
+*/
+/*
+++
+| INPUT:
+|  - val= pointeur sur un tableau de valeurs (float).
+|  - nval= nombre de valeurs a traiter.
+|  - binin= taille du bin.
+|  - nmoy= la valeur retournee est la moyenne de +/- nmoy bins
+|          autour du max de l'histo.
+|  - low, high= les valeurs permises mini et maxi des valeurs
+|                (si low>high calcul automatique).
+|  - deb= niveau de debug.
+| OUTPUT:
+|  - most = valeur la plus probable.
+| RETURN CODE:
+|  -1 : nval <=0
+|  -2 : bin <=0
+|  -3 : low>=high apres cadrage automatique
+|  -4 : nombre de valeurs remplies nul au niveau de la 1ere passe
+|  -51 : pas trouve de maximum 1ere passe
+|  -52 : pas trouve de maximum 2sd passe
+--
+*/
+int Most_Probable( float *val, int nval, float binin, int nmoy
+                 , float low, float high, float *most, int deb)
+{
+int histo[503],i,nbin,n,ib,ibmax,vmax,pass;
+float bin,xmax=0.;
+double moy,sum;
+
+if(deb>1) printf("Most_Probable: nval=%d binin=%f nmoy=%d low,high=%f %f\n"
+                ,nval,binin,nmoy,low,high);
+if (nval<=0) return(-1);
+if (binin<=0.) return(-2);
+nmoy = (nmoy<0) ? 0 : nmoy;
+if(low>= high) {
+  low = GRAND;
+  high = -low;
+  for(i=0;i<nval;i++) {if(val[i]>high) high=val[i]; if(val[i]<low) low=val[i];}
+}
+if(deb>1) printf("nmoy=%d low,high=%f %f\n",nmoy,low,high);
+if(low>= high) return(-3);
+
+/* premiere passe "nbin" bins entre low et high, nbin=min(high-low)/bin+1,501) */
+/* seconde  passe "nbin" autour du maxi 1ere passe, nbin=min(high-low)/bin,501) */
+
+for ( pass=1;pass<=2;pass++) {
+
+  bin=binin;
+  nbin = (int) ( (high-low)/bin ) + 1;
+  if(nbin>501) {
+    nbin = 501;
+    if(pass!=1){
+      low  = xmax - 250*binin - binin/2.;
+      high = xmax + 250*binin + binin/2.;
+  } }
+  /* re-scaling du bin pour etre sur */ 
+  bin=(high-low)/nbin;
+  if(deb>1) printf("pass=%2d low,high=%f %f bin=%f nbin=%d\n"
+                  ,pass,low,high,bin,nbin);
+  for(i=0;i<nbin;i++) histo[i]=0;
+  n=0;
+  for(i=0;i<nval;i++) {
+    if( val[i]>=high || val[i]<low ) continue;
+    ib = (int) ((val[i]-low)/bin);
+    if( ib<0 && ib >= nbin ) continue;
+    histo[ib]++;
+    n++;
+  }
+  if(n<=0) return (-4);
+  vmax = -1; ibmax= -1;
+  if(n<=0) return (-4);
+  for(i=0;i<nbin;i++) {
+    if(histo[i]<vmax) continue;
+    vmax = histo[i];
+    ibmax = i;
+  }
+  if(ibmax<0) return (-50-pass);
+  xmax = low + ibmax*bin + bin/2.;
+  if(deb>1) printf("bin du maximum %5d (%d) abscisse=%f\n",ibmax,vmax,xmax);
+  if(deb>3) {
+    printf("histogramme:\n");
+    for (i= ibmax-25;i<=ibmax+25;i++) {
+      if (i<0) continue;
+      if (i>=nbin) break;
+      printf(" %5d",histo[i]);
+      if(i%10==9) printf("\n");
+    }
+    printf("\n");
+  }
+}
+
+sum = moy =0.; n=0;
+for (i= -nmoy;i<=nmoy;i++) {
+  if (ibmax-i>=0 && ibmax+i<nbin) {
+    moy += ( xmax + i * bin ) * histo[ibmax+i];
+    sum += (double) histo[ibmax+i];
+    n++;
+} }
+
+*most = moy / sum;
+if(deb>0) printf("Most_probable: most=%f (avec %d points)\n",*most,n);
+
+return(0);
+
+}
+
+/*============================================================*/
+/*                                      Christophe 27/01/95   */
+/*
+++
+float Ajust_GaFn
+|    (int Ns,float *fcfr
+|    ,float *haut,float *ehaut,float *mean,float *emean
+|    ,float *sigma,float *esigma,float *fond,float *efond
+|    ,int fixfond,int NBIN_RESOL
+|    ,float perc_net,float frac_sgb,float dyn_sgb,int deb)
+
+	Fonction de fit gaussienne + fond (1D) du tableau fcfr
+	avec reglage des parametres d'entree.
+--
+*/
+/*
+++
+| ATTENTION: le tableau fcfr est modifie !!!              
+| ---------                                               
+| ENTREES:                                                
+|   Ns = nombre d'entrees dans fcfr
+|   fcfr = tableau des valeurs a fitter
+|   fond = valeur a donner au fond si fixfond = 1
+|   fixfond =  1 fond fixe dans le fit a la valeur fond
+|           =  2 fond fixe dans le fit a une valeur
+|                     calculee automatiquement sur
+|                     les bords de l'histogramme 
+|           >  2 fond fixe a zero (<=> 1 + fond=0)
+|           <= 0 fond libre dans le fit
+|   NBIN_RESOL = nombre maxi de bins pour l'histo de fit
+|                de la resolution
+|   perc_net = pourcentage de donnees a nettoyer pour
+|              calculer mean,sigma de la 1ere passe
+|   frac_sgb = le bin de fit sera sigma*fracsgb
+|              ou sigma est calcule en premiere passe
+|   dyn_sgb = limites de l'histo de fit
+|        xmin=mean-dyn_sgb*sigma , xmax=mean+dyn_sgb*sigma
+|   deb = niveau de debug
+--
+*/
+/*
+++
+| SORTIES:                                                
+|   haut = valeur de la hauteur
+|   ehaut = erreur sur la valeur de la hauteur
+|   mean = valeur moyenne du decalage
+|   emean = erreur sur la valeur moyenne du decalage
+|   sigma = valeur de la resolution
+|   esigma = erreur sur la valeur de la resolution
+|   fond = valeur du fond
+|   efond = erreur sur la valeur du fond 
+|   return code = chi2 du fit  (<0 si Pb)
+--
+*/
+float Ajust_GaFn(int Ns,float *fcfr
+           ,float *haut,float *ehaut,float *mean,float *emean
+           ,float *sigma,float *esigma,float *fond,float *efond
+           ,int fixfond,int NBIN_RESOL
+           ,float perc_net,float frac_sgb,float dyn_sgb,int deb)
+{
+int_4 i,j,i1,i2,nbin,ibin,entries;
+float c2,xmin,xmax,binw,ymax;
+float *y,*ey,*x;
+double m,s;
+FLOATDOUBLE X,Y,EY;
+double (*Fun) (double ,double *,double *);
+int_4 npar,n;
+double par[4], epar[4],minpar[4],maxpar[4],stepar[4],stochi2;
+
+fixfond = ( fixfond <= 0 ) ? 0 : fixfond;
+perc_net = ( perc_net >= 1. || perc_net < 0. ) ? 0.1 : perc_net;
+NBIN_RESOL = ( NBIN_RESOL <= 0 ) ? 50 : NBIN_RESOL;
+frac_sgb = ( frac_sgb <= 0. ) ? 0.5 : frac_sgb;
+dyn_sgb  = ( dyn_sgb  <= 0. ) ? 5.0 : dyn_sgb;
+x = y = ey = NULL;
+x  = (float *) calloc(NBIN_RESOL+2,sizeof(float));
+y  = (float *) calloc(NBIN_RESOL+2,sizeof(float));
+ey = (float *) calloc(NBIN_RESOL+2,sizeof(float));
+if ( x==NULL || y==NULL || ey==NULL ) {c2 = -100.; goto END;}
+
+if(deb>0) printf("Ajust_GaFn[%d] perc_net=%f nbin=%d frac_sgb=%f dyn_sgb=%f\n"
+              ,Ns,perc_net,NBIN_RESOL,frac_sgb,dyn_sgb);
+
+/* on vire perc_net % des points a gauche et a droite de la distribution */
+qsort(fcfr,(size_t) Ns,(size_t) sizeof(float),qSort_Float);
+i = perc_net * Ns;
+if(perc_net>0. && i==0) i=1;
+i1 = i; i2 = Ns-1-i;
+if(deb>1) {
+  printf("  df/f=");
+  for(j=0;j<10;j++) printf("%8.2f ",fcfr[j]);
+  printf("\n");
+  printf("selection de %d (%f) a %d (%f)\n",i1,fcfr[i1],i2,fcfr[i2]);
+}
+if(i2<=i1) { c2= -101.; goto END;}
+
+/* calcul mean et sigma 1ere passe */
+m = s = 0.; j = 0;
+for(i=i1;i<=i2;i++) {m += fcfr[i]; s += fcfr[i]*fcfr[i]; j++;}
+m /= j;
+s = sqrt(s/j - m*m);
+*mean = m; *sigma = s;
+if(deb>1) printf("premiere passe: mean=%f sigma=%f\n",*mean,*sigma);
+
+/* remplissage histo a +/- dyn_sgb * sigma */
+xmin = *mean - dyn_sgb* *sigma;
+xmax = *mean + dyn_sgb* *sigma;
+if(xmin>=xmax) {c2 = -102.; goto END;}
+binw = *sigma * frac_sgb;
+nbin = (xmax-xmin)/binw;
+if(nbin<6) nbin=6; if(nbin>NBIN_RESOL) nbin=NBIN_RESOL;
+binw = (xmax-xmin)/nbin;
+for(i=0;i<nbin;i++)
+    {x[i] = xmin + ((float) i + 0.5)*binw; y[i] = 0.;}
+if(deb>1) {
+  printf("histo[%d] lim=[%f,%f] bw=%f x=\n"
+        ,nbin,xmin,xmax,binw);
+  for(j=0;j<nbin;j++)
+    {printf("%8.2f ",x[j]); if(j%10==9) printf("\n");}
+  if(j%10!=0) printf("\n");
+}
+entries = 0;
+for(i=0;i<Ns;i++) { ibin = (fcfr[i]-xmin)/binw;
+         if(ibin>=0 && ibin<nbin) {y[ibin]+=1.; entries++;} }
+ymax = 0.;
+for(i=0;i<nbin;i++) {ey[i] = (y[i]>1.)? sqrt((double) y[i]) : 1.;
+                    if(y[i]>ymax) ymax=y[i];}
+if(deb>1) {
+  printf("histo (entries=%d) ymax=%f y=\n",entries,ymax);
+  for(j=0;j<nbin;j++)
+    {printf("%8.0f ",y[j]); if(j%10==9) printf("\n");}
+  if(j%10!=0) printf("\n");
+  if(deb>2) {
+    printf("histo ey=\n");
+    for(j=0;j<nbin;j++)
+      {printf("%8.0f ",ey[j]); if(j%10==9) printf("\n");}
+    if(j%10!=0) printf("\n"); }
+}
+if(ymax<2.) {c2 = -103.; goto END;}
+
+if(fixfond!=1) {
+  *fond = (y[0]+y[1]+y[nbin-1]+y[nbin-2])/4.;
+  if(fixfond>2) *fond = 0.;
+}
+*haut = ymax - *fond;
+
+/* fit gaussienne + fond constant */
+Fun = Gauss1DPolF ; Set_FitFunDPol(0);
+X.fx  = x;
+Y.fx  = y;
+EY.fx = ey;
+par[0] = *haut;
+par[1] = *mean;
+par[2] = *sigma;
+par[3] = *fond;
+stepar[0] = par[0]/10.; stepar[1] = par[2]/5.;
+stepar[2] = par[2]/10.; stepar[3] = 0.5;
+if(fixfond) { stepar[3] = 0.; epar[3]=0.;}
+for(i=0;i<4;i++) {minpar[i] = 1.; maxpar[i] = -1.;}
+minpar[2] = 0.00001; maxpar[2] = 9999.;
+npar = 4;
+stochi2 = 0.0001;
+n = nbin;
+j = (deb>2)? 1:0;
+c2 = FitFun(Fun,FITFUN_FLOAT,X,Y,EY,&n,0,0,par
+           ,epar,stepar,minpar,maxpar,npar,stochi2,60,j);
+
+END:
+
+if( c2 > 0. ) {
+  *haut  =  par[0]; *mean  =  par[1]; *sigma  =  par[2]; *fond  =  par[3];
+  *ehaut = epar[0]; *emean = epar[1]; *esigma = epar[2]; *efond = epar[3];
+} else {
+  *ehaut = *emean = *esigma = *efond = 0.;
+}
+if(x !=NULL) free(x);
+if(y !=NULL) free(y);
+if(ey!=NULL) free(ey);
+
+return(c2);
+}
+
+/*==========================================================*/
+/*                                    Christophe 27/03/95   */
+/*
+++
+float HFit_GaFn -
+  (int Ns,float *fcfr -
+  ,float *haut,float *ehaut,float *mean,float *emean -
+  ,float *sigma,float *esigma,float *fond,float *efond -
+  ,int fixfond,int nbin,float xmin,float xmax,int deb)
+
+	Fonction de fit gaussienne + fond (1D) du tableau fcfr
+	dans un histo de "nbin" bins de "xmin a xmax"
+--
+*/
+/*
+++
+| ENTREES:
+|   Ns = nombre d'entrees dans fcfr
+|   fcfr = tableau des valeurs a fitter
+|   mean = valeur de depart pour la moyenne
+|   sigma = valeur de depart pour le sigma
+|   fond = valeur de depart pour le fond
+|   fixfond > 0  fond fixe dans le fit a la valeur fond
+|           <= 0 fond libre dans le fit
+|   nbin = nombre de bins pour l'histo de fit
+|   xmin = valeur inferieure de l'histo
+|   xmax = valeur superieure de l'histo
+|   deb = niveau de debug
+--
+*/
+/*
+++
+| SORTIES:
+|   haut = valeur de la hauteur
+|   ehaut = erreur sur la valeur de la hauteur
+|   mean = valeur moyenne du decalage
+|   emean = erreur sur la valeur moyenne du decalage
+|   sigma = valeur de la resolution
+|   esigma = erreur sur la valeur de la resolution
+|   fond = valeur du fond
+|   efond = erreur sur la valeur du fond
+|   return code = chi2 du fit  (<0 si Pb)
+--
+*/
+float HFit_GaFn(int Ns,float *fcfr
+           ,float *haut,float *ehaut,float *mean,float *emean
+           ,float *sigma,float *esigma,float *fond,float *efond
+           ,int fixfond,int nbin,float xmin,float xmax,int deb)
+{
+int_4 i,j,ibin,entries;
+float c2,binw,ymax;
+float *y,*ey,*x;
+FLOATDOUBLE X,Y,EY;
+double (*Fun) (double ,double *,double *);
+int_4 npar,n;
+double par[4], epar[4],minpar[4],maxpar[4],stepar[4],stochi2;
+
+if(xmax<=xmin) return(-102);
+fixfond = ( fixfond <= 0 ) ? 0 : fixfond;
+nbin = ( nbin <= 0 ) ? 50 : nbin;
+x = y = ey = NULL;
+x  = (float *) calloc(nbin+2,sizeof(float));
+y  = (float *) calloc(nbin+2,sizeof(float));
+ey = (float *) calloc(nbin+2,sizeof(float));
+if ( x==NULL || y==NULL || ey==NULL ) {c2 = -100.; goto END;}
+
+if(deb>0) printf("HFit_GaFn[%d pts] nbin=%d de %g a %g\n"
+              ,Ns,nbin,xmin,xmax);
+
+/* remplissage histo */
+binw = (xmax-xmin)/nbin;
+for(i=0;i<nbin;i++) {x[i]=xmin+((float) i +0.5)*binw; y[i]=0.;}
+if(deb>1) {
+  printf("histo[%d] lim=[%f,%f] bw=%f x=\n",nbin,xmin,xmax,binw);
+  for(j=0;j<nbin;j++){printf("%8.2f ",x[j]); if(j%10==9) printf("\n");}
+  if(j%10!=0) printf("\n");
+}
+entries = 0;
+for(i=0;i<Ns;i++) {
+  ibin = (fcfr[i]-xmin)/binw;
+  if(ibin>=0 && ibin<nbin) {y[ibin]+=1.; entries++;}
+}
+
+ymax = 0.;
+for(i=0;i<nbin;i++) {ey[i] = (y[i]>1.)? sqrt((double) y[i]) : 1.;
+                    if(y[i]>ymax) ymax=y[i];}
+if(deb>1) {
+  printf("histo (entries=%d) ymax=%f y=\n",entries,ymax);
+  for(j=0;j<nbin;j++){printf("%8.0f ",y[j]); if(j%10==9)printf("\n");}
+  if(j%10!=0) printf("\n");
+  if(deb>2) {
+    printf("histo ey=\n");
+    for(j=0;j<nbin;j++){printf("%8.0f ",ey[j]); if(j%10==9)printf("\n");}
+    if(j%10!=0) printf("\n");
+} }
+if(ymax<2.) {c2 = -103.; goto END;}
+
+*haut = ymax - *fond;
+
+/* fit gaussienne + fond constant */
+Fun = Gauss1DPolF ; Set_FitFunDPol(0);
+X.fx  = x;
+Y.fx  = y;
+EY.fx = ey;
+par[0] = *haut;
+par[1] = *mean;
+par[2] = *sigma;
+par[3] = *fond;
+stepar[0] = par[0]/10.; stepar[1] = par[2]/5.;
+stepar[2] = par[2]/10.; stepar[3] = 0.5;
+if(fixfond) { stepar[3] = 0.; epar[3]=0.;}
+for(i=0;i<4;i++) {minpar[i] = 1.; maxpar[i] = -1.;}
+minpar[2] = 0.00001; maxpar[2] = 9999.;
+npar = 4;
+stochi2 = 0.0001;
+n = nbin;
+j = (deb>2)? 1:0;
+c2 = FitFun(Fun,FITFUN_FLOAT,X,Y,EY,&n,0,0,par
+           ,epar,stepar,minpar,maxpar,npar,stochi2,60,j);
+
+END:
+
+if( c2 > 0. ) {
+  *haut  =  par[0]; *mean  =  par[1]; *sigma  =  par[2]; *fond  =  par[3];
+  *ehaut = epar[0]; *emean = epar[1]; *esigma = epar[2]; *efond = epar[3];
+} else {
+  *ehaut = *emean = *esigma = *efond = 0.;
+}
+if(x !=NULL) free(x);
+if(y !=NULL) free(y);
+if(ey!=NULL) free(ey);
+
+return(c2);
+}
+
+/*==============================================================*/
+/*                                    Christophe 15/02/95       */
+/*
+++
+int Ajust_MnSg -
+  (int Ns,float *fcfr -
+  ,float *mean,float *emean,float *sigma,float *esigma -
+  ,float perc_net,float n_sigma,int deb)
+
+	Calcul mean sigma tronques du tableau fcfr.
+--
+*/
+/*
+++
+| ATTENTION: le tableau fcfr est modifie
+| ---------
+| Methode:
+|  1- calcul de la moyenne Mcent en enlevant perc_net% des pts
+|     les + faibles et perc_net% des pts les + forts
+|  2- calcul de la valeur cutup correspondant a 2*perc_net%
+|     des pts les + hauts en valeur absolue (fcfr-Mcent)
+|  3- calcul moyenne et sigma en enlevant les points ayant
+|        abs(fcfr-Mcent) > cutup    (1ere passe)
+|  4- calcul moyenne et sigma en enlevant les points ayant
+|        abs(fcfr-Mcent) > cutup   et
+|        abs(fcfr-M(1ere passe)) > n_sigma*sigma(1ere passe)
+--
+*/
+/*
+++
+| ENTREES:
+|   Ns = nombre d'entrees dans fcfr
+|   fcfr = tableau des valeurs a fitter
+|   perc_net = pourcentage de donnees a nettoyer pour
+|              calculer mean,sigma
+|   n_sigma = nombre de sigma en passe 2 pour
+|              calculer mean,sigma
+|   deb = niveau de debug
+| SORTIES:
+|   mean = valeur moyenne du decalage
+|   emean = erreur sur la valeur moyenne du decalage
+|   sigma = valeur de la resolution
+|   esigma = erreur sur la valeur de la resolution
+|   return code = nombre de points utilises (<0 si Pb)
+--
+*/
+int Ajust_MnSg(int Ns,float *fcfr
+           ,float *mean,float *emean,float *sigma,float *esigma
+           ,float perc_net,float n_sigma,int deb)
+{
+int i,i1,i2,n,nvire,pass;
+double m,s,mcent,cutup,cuts;
+float *dum;
+
+/* set up des valeurs par defaut */
+perc_net = ( perc_net >= 1. || perc_net < 0. ) ? 0.1 : perc_net;
+n_sigma = ( n_sigma <= 0. ) ? 3.0 : n_sigma;
+nvire = perc_net * Ns;
+if(perc_net>0. && nvire==0) nvire=1;
+*emean = *esigma = -1.;
+if(deb>0) printf("Ajust_MnSg[%d] perc_net=%f (vire=%d) n_sigma=%f\n"
+                ,Ns,perc_net,nvire,n_sigma);
+
+/* on ordonne par ordre croissant de fcfr */
+qsort(fcfr,(size_t) Ns,(size_t) sizeof(float),qSort_Float);
+i1 = nvire; i2 = Ns-1-nvire;
+if(deb>1) printf("    select de %d (%f) a %d (%f)\n",i1,fcfr[i1],i2,fcfr[i2]);
+if(i2<=i1) return(-101);
+
+/* on vire perc_net % des points a gauche et a droite de la distribution */
+mcent = 0.; n = 0;
+for(i=i1;i<=i2;i++) {mcent += fcfr[i]; n++;}
+if(n<1) return(-102);
+mcent /= (double) n;
+if(deb>1) printf("    mean cent=%f sur %d points\n",mcent,n);
+
+/* allocate space and fill absolute value */
+if( (dum  = (float *) calloc(Ns,sizeof(float))) == NULL ) return(-103);
+for(i=0;i<Ns;i++) dum[i] = fabs( mcent - fcfr[i] );
+
+/* on ordonne par ordre croissant de abs(fcfr-mcent) */
+qsort(dum,(size_t) Ns,(size_t) sizeof(float),qSort_Float);
+i = Ns-1-2*nvire;
+if(i<0) {n= -104; goto END_Ajust_MnSg;}
+
+/* on vire 2.*perc_net % des points les + hauts de la distribution */
+cutup = dum[i];
+if(deb>1) printf("    cutup=%f sur %d points\n",cutup,i);
+
+/* calcul mean et sigma en 2 passes avec coupure n_sigma*sigma(1ere passe)*/
+cuts = GRAND2;
+for(pass=1;pass<=2;pass++) {
+  m = s = 0.; n = 0;
+  for(i=0;i<Ns;i++) {
+    if( fabs(mcent-fcfr[i]) > cutup ) continue;
+    if( fabs((double) (*mean-fcfr[i])) > cuts ) continue;
+    m += fcfr[i];
+    s += fcfr[i]*fcfr[i];
+    n++;
+  }
+  if(n<=2) {n= -105; *mean = *sigma = -1.; goto END_Ajust_MnSg;}
+  m /= n;
+  s = s/n - m*m;
+  if(s<=0.) {n= -106; *mean = *sigma = -1.; goto END_Ajust_MnSg;}
+  s = sqrt(s);
+  *mean = m;
+  *sigma = s;
+  cuts = n_sigma * s;
+  if(deb>1)
+    printf("    pass=%d mean=%g sigma=%g (%d pts) cuts=%f\n"
+          ,pass,*mean,*sigma,n,cuts);
+}
+
+*emean = s/sqrt((double) n);
+*esigma = s/sqrt(2. * (double) n);
+if(deb>0) printf("mean=%g (+/-%g) sigma=%g (+/-%g) sur %d pts\n"
+              ,*mean,*emean,*sigma,*esigma,n);
+
+END_Ajust_MnSg:
+if( dum != NULL ) free(dum);
+return(n);
+}
+
+/*=================================================================*/
+/*                                       Nathalie 16/02/95         */
+/*
+++
+float Int3DCube(float(*fonction)(float,float,float),float step,float precision)
+	Cette fonction calcule l'integrale 3D: f(x,y,z)dx.dy.dz
+	L'integrale est calculee en incrementant des couronnes cubiques
+	centrees sur le point de coordonnees (0,0,0)
+--
+*/
+/*
+++
+| ENTREES:
+|   fonction = f(x,y,z)
+|   step = pas de l'integration
+|   precision = coupure en dV(couronne i)/Vtot(couronnes 0 a i)
+| SORTIES:
+|   return: l'integrale
+| REMARQUES:
+|   la fonction f(x,y,z) doit decroitre tres vite en r**2
+--
+*/
+float Int3DCube(float(*fonction)(float,float,float),float step,float precision)
+{
+
+  float f;
+  double vol,volprec;
+  int ecart,i,j,k,l;
+  int encore,deb=0;
+
+  vol = volprec = 0.;
+
+  /* contribution du cube central */
+  for(l=0;l<nd3d;l++) {
+    f = fonction(dx3d[l]*step,dy3d[l]*step,dz3d[l]*step);
+    vol += f*w3d[l];
+  }
+  ecart = 1;
+
+  /* increment en couronnes cubiques de 2*ecart+1 de cote */  
+  do {
+    volprec = vol;
+    for (i= -ecart;i<=ecart;i++) for(l=0;l<nd3d;l++) {
+      for(j= -ecart;j<=ecart;j++) {
+	f=fonction((i+dx3d[l])*step,(j+dy3d[l])*step,(-ecart+dz3d[l])*step);
+	vol += f*w3d[l];
+	f=fonction((i+dx3d[l])*step,(j+dy3d[l])*step,( ecart+dz3d[l])*step);
+	vol += f*w3d[l];
+      }
+
+      for(k= -ecart+1;k<=ecart-1;k++) {
+	f=fonction((i+dx3d[l])*step,(-ecart+dy3d[l])*step,(k+dz3d[l])*step);
+	vol += f*w3d[l];
+	f=fonction((i+dx3d[l])*step,( ecart+dy3d[l])*step,(k+dz3d[l])*step);
+	vol += f*w3d[l];
+      }
+    }
+    for (j= -ecart+1;j<=ecart-1;j++) for(k= -ecart+1;k<=ecart-1;k++) 
+      for(l=0;l<nd3d;l++) {
+	f=fonction((-ecart+dx3d[l])*step,(j+dy3d[l])*step,(k+dz3d[l])*step);
+	vol += f*w3d[l];
+	f=fonction(( ecart+dx3d[l])*step,(j+dy3d[l])*step,(k+dz3d[l])*step);
+	vol += f*w3d[l];
+    }
+
+    ecart = ecart + 1;
+    encore = ((fabs((vol-volprec)/vol) > precision) || (ecart <= 2) );
+    if(deb>1) printf("ec=%d v=%g deltav/v=%g\n"
+           ,ecart-1,vol*step*step*step,((vol-volprec)/vol));
+  } while(encore);
+
+  vol *= step * step* step;
+  if(deb>0) printf("\nVol = %g\n",vol); 
+  return(vol);
+}
+
+
+/*=================================================================*/
+/*                                             cmv  6/11/97        */
+/*
+++
+int IntFaisDr -
+  (int n,float *cs,float *sn,float *p,float *x0,float *y0 -
+  ,int npass,float perclean,int lp)
+
+	Pour calculer le point d'intersection moyen
+	d'un faisceau de droites.
+--
+*/
+/*
+++
+| L'equation des droites est sous la forme:
+|      cos(alpha)*x + sin(alpha)*y = p
+| [cos(alpha),sin(alpha)] coordonnees du vecteur unitaire joignant
+| l'origine au point de moindre approche de la droite a l'origine.
+| p est la distance de la droite a l'origine.
+--
+*/
+/*
+++
+| -- Input:
+|  n  : nombre de droites
+|  cs : tableau des coefficients cos(alpha)
+|  sn : tableau des coefficients sin(alpha)
+|  p  : tableau des coefficients p
+|  npass    : nombre de passes de nettoyage
+|  perclean : pourcentage d'etoiles a tuer
+|             d'une passe a la suivante
+|      ex: perclean=0.2, si il y a 200 etoiles dans une passe
+|      la passe suivante en utilisera 160 et la suivante 128.
+|  lp : niveau d'impression
+--
+*/
+/*
+++
+| -- Output:
+|  x0 : valeur de l'abscisse du point d'intersection moyen trouve
+|  y0 :             ordonnee
+| -- Return:
+|  nombre de droites utilisees pour le calcul de x0,y0
+--
+*/
+int IntFaisDr(int n,float *cs,float *sn,float *p,float *x0,float *y0
+             ,int npass,float perclean,int lp)
+{
+int i,j,ns, nsuse=-9, ipass;
+double sumC2,sumS2,sumCS,sumCP,sumSP,den;
+float *d2=NULL, d2cut=-1.;
+unsigned short *good=NULL;
+
+*x0 = *y0 = 0.;
+if(n<=1) return(-1);
+if(lp<0) lp=0;\
+if(npass<=0) npass=1;
+if(perclean<=0.) { perclean=0.; npass=1;}
+if(lp)
+  printf("IntFaisDr avec %d points en %d passes avec nettoyage de %g%%\n"
+        ,n,npass,perclean*100);
+
+d2 = (float *) malloc(n * sizeof(float));
+if(d2==NULL) {
+  if(lp)
+    printf("allocation de %d float impossible\n",n);
+  return(-2);
+}
+good = (unsigned short *) malloc(n * sizeof(unsigned short));
+if(good==NULL) {
+  if(lp)
+    printf("allocation de %d unsigned short impossible\n",n);
+  free(d2);
+  return(-3);
+}
+for(i=0;i<n;i++) good[i]=1;
+
+for(ipass=1;ipass<=npass;ipass++) {
+
+  /* Calcul du point d'intersection pour la passe ipass */
+  sumC2=sumS2=sumCS=sumCP=sumSP=0.;
+  ns=0;
+  for(i=0;i<n;i++) {
+    if( !good[i] ) continue;
+    sumC2 += cs[i]*cs[i];
+    sumS2 += sn[i]*sn[i];
+    sumCS += cs[i]*sn[i];
+    sumCP += cs[i]*p[i];
+    sumSP += sn[i]*p[i];
+    ns++;
+  }
+  den = sumCS*sumCS - sumC2*sumS2;
+  if(den==0.) {
+    if(lp)
+      printf("denominateur nul pass=%d, sumCS=%g sumC2=%g sumS2=%g pour %d dr\n"
+            ,ipass,sumCS,sumC2,sumS2,ns);
+    free(d2); free(good);
+    return(-100-ipass);
+  }
+  if(ns<2) {
+    if(lp) printf("Pas ou plus assez de droites %d\n",ns);
+    return(nsuse);
+  }
+  *x0 = (sumSP*sumCS - sumCP*sumS2)/den;
+  *y0 = (sumCP*sumCS - sumSP*sumC2)/den;
+  nsuse = ns;
+  if(lp) printf("Pass=%d, %d dr x0=%g y0=%g\n",ipass,nsuse,*x0,*y0);
+  if(ipass==npass) break;
+
+  /* Calcul de la coupure en distance**2 pour la passe suivante */
+  ns = 0;
+  for(i=0;i<n;i++) {
+    if( !good[i] ) continue;
+    d2[ns] = (*x0*cs[i] * *y0*sn[i]-p[i]);
+    d2[ns] *= d2[ns];
+    ns++;
+  }  
+  qsort(d2,(size_t) ns,sizeof(float),qSort_Float);
+  j = (int) (ns-ns*perclean); if(j<0) j=0;  if(j>=ns) j=ns-1;
+  d2cut = d2[j];
+  ns=0;
+  for(i=0;i<n;i++) {
+    if( !good[i] ) continue;
+    den = (*x0*cs[i] * *y0*sn[i]-p[i]);
+    den *= den;
+    if( den>d2cut ) good[i]=0; else ns++;
+  }
+  if(lp>1)
+    printf("  next pass: i=%d  cut=%g -> restera %d dr\n",j,d2cut,ns);
+}
+
+free(d2); free(good);
+return(nsuse);
+}
Index: /tags/DPC_V0/SophyaLib/NTools/nbmath.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/nbmath.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/nbmath.h	(revision 1307)
@@ -0,0 +1,134 @@
+/* quelques fonctions mathematiques et constantes utiles */
+/*                                         cmv  23/06/94 */
+#ifndef NBMATH_H_SEEN
+#define NBMATH_H_SEEN
+
+#include <machine.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* EA conflit entre les diverses copies de nbmath.h, nbconst.h... A nettoyer... */
+#undef  Pi   
+#undef  Pis2
+#undef  DeuxPi 
+#undef  SPi   
+#undef  S2Pi   
+#undef  Rac2   
+#undef  Log2   
+#undef  LnPi   
+#undef  LgPi   
+#undef  Ln10   
+#undef  DftoDm 
+#undef  Hln2pi 
+#undef  JourSec 
+#undef  AnSec  
+
+#undef  GRAND  
+#undef  GRAND2 
+#undef  IGRAND 
+
+#define  Pi     (double) ( 3.14159265358979310e+00)  /* c'est Pi */
+#define  Pis2   (double) (1.57079632679489655)       /* c'est Pi/2 */
+#define  DeuxPi (double) ( 6.28318530717958620e+00)  /* c'est 2*Pi */
+#define  SPi    (double) ( 1.77245385090551590e+00)  /* c'est sqrt(Pi) */
+#define  S2Pi   (double) ( 2.50662827463100020e+00)  /* c'est sqrt(2*Pi) */
+#define  Rac2   (double) ( 1.41421356237309510e+00)  /* c'est sqrt(2) */
+#define  Log2   (double) ( 3.01029995663981200e-01)  /* c'est log10(2) */
+#define  LnPi   (double) ( 1.14472988584940020e+00)  /* c'est ln(Pi) */
+#define  LgPi   (double) ( 4.97149872694133850e-01)  /* c'est log10(Pi) */
+#define  Ln10   (double) ( 2.30258509299404590e+00)  /* c'est ln(10) */
+#define  DftoDm (double) ( 1.08573620475812940e+00)  /* c'est 2.5/ln(10) */
+#define  Hln2pi (double) ( 9.18938533204672670e-01)  /* c'est Ln(2*pi)/2 */
+
+#define  JourSec (float) (86400.000000) /* nombre de secondes dans 24H */
+#define  AnSec  (int) (31557600) /* nombre de secondes dans 365.25 jours */
+
+#define  GRAND  (float)  (1.e+35)
+#define  GRAND2 (double) (1.e+35)
+#define  IGRAND (int_4) (2147483647)
+
+/* pour le fit 1-dim */
+#define NPAR_FITFUN 10
+#define FITFUN_FLOAT 1
+#define FITFUN_DOUBLE 2
+union FloatDouble { float  *fx; double *dx; };
+typedef union FloatDouble FLOATDOUBLE;
+
+double FitFun( double (*FunFit) (double ,double *,double *) ,int_4 type
+             ,FLOATDOUBLE temps,FLOATDOUBLE mag,FLOATDOUBLE err
+             ,int_4 *ndata,int_4 I1,int_4 I2
+             ,double *par,double *epar,double *stepar
+             ,double *minpar,double *maxpar,int_4 npar
+             ,double stochi2,int_4 NstepMX,int_4 deb);
+
+double GausPiv(double *A,int_4 nca,int_4 n,double *B,int_4 ncb,int_4 m,int_4 Inv);
+
+int_4 paramga(float sxin, float syin, float rhoin
+             , float *smax, float *axisrat, float *tiltdeg);
+int_4 gaparam(float smax, float axisrat, float tiltdeg
+             , float *sxin, float *syin, float *rhoin);
+
+double nberfc(double x);
+float probnb(float sci2,int_4 inddl,int_4 *ipass);
+double nbgammln(double xx);
+double nbgammq(double a,double x);
+double nbgammp(double a,double x);
+
+void Set_Ihoq(int degre,int *mIhoqN,double *IhoqNX,double *IhoqNW);
+int Get_Ihoq(int degre,double *IhoqNX,double *IhoqNW);
+void nbgauleg(double x1,double x2,double *x,double *w,int n);
+double Integ_Fun(double xmin,double xmax,double (*fonc)(double),int npas);
+double Integ_Fun_2D(double (*fonc)(double x,double y)
+                ,double xmin,double xmax,double ymin,double ymax
+                ,int npasx,int npasy);
+
+void Set_FitFunDPol(int DPol);
+double Gauss1DPolF(double x,double *Par,double *DgDpar);
+double GaussI1DPol(double x,double *Par,double *DgDpar);
+double Polyn1D(double x,double *Par,double *DgDpar); 
+
+double FitProp(double *x,double *y,double *ey,int *n,double *a1);
+double FitLin(double *x,double *y,double *ey,int *n
+             ,double *a0,double *a1);
+double FitPar(double *x,double *y,double *ey,int *n
+             ,double *a0,double *a1,double *a2);
+double FitParLin(double *xx,double *y,double *ey,int *n,double x0,int Deg_d
+                ,double *a0,double *a1,double *b1,double *b2);
+double FitPropClean(double *x,double *y,double *ey,int *n
+                  ,double per_clean,double *a1);
+double FitLinClean(double *x,double *y,double *ey,int *n
+                  ,double per_clean,double *a0,double *a1);
+double FitParClean(double *x,double *y,double *ey,int *n
+                  ,double per_clean,double *a0,double *a1,double *a2);
+
+float interpole(float x,int n,float *t1,float *t2);
+
+int_4 MeanSig(float *mag,float *err,int_4 *ndata,float nsigma,float *mean,float *sigma);
+int Most_Probable( float *val, int nval, float binin, int nmoy
+                 , float low, float high, float *most, int deb);
+float Ajust_GaFn(int Ns,float *fcfr
+           ,float *haut,float *ehaut,float *mean,float *emean
+           ,float *sigma,float *esigma,float *fond,float *efond
+           ,int fixfond,int NBIN_RESOL
+           ,float perc_net,float frac_sgb,float dyn_sgb,int deb);
+float HFit_GaFn(int Ns,float *fcfr
+           ,float *haut,float *ehaut,float *mean,float *emean
+           ,float *sigma,float *esigma,float *fond,float *efond
+           ,int fixfond,int nbin,float xmin,float xmax,int deb);
+int Ajust_MnSg(int Ns,float *fcfr
+           ,float *mean,float *emean,float *sigma,float *esigma
+           ,float perc_net,float n_sigma,int deb);
+
+float Int3DCube(float(*fonction)(float, float, float), float step, 
+	       float precision);
+
+int IntFaisDr(int n,float *cs,float *sn,float *p,float *x0,float *y0
+             ,int npass,float perclean,int lp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/nbrandom.c
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/nbrandom.c	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/nbrandom.c	(revision 1307)
@@ -0,0 +1,574 @@
+#include "defs.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+#include "machine.h"
+#include "nbmath.h"
+#include "nbrandom.h"
+
+static double GAU_RANGE=6.;
+
+/* 
+++ 
+  Module 	Tirages aleatoires (C)
+  Lib	LibsUtil
+  include	nbrandom.h
+--
+*/
+
+/*
+++
+  frand01()
+	tirage aleatoire entre 0 et 1, retourne float  
+  drand01()
+	tirage aleatoire entre 0 et 1, retourne double  
+  rand01()
+	 c'est le defaut: drand01()
+  frandpm1()
+	tirage aleatoire entre -1 et 1, retourne float
+  drandpm1()
+	tirage aleatoire entre -1 et 1, retourne double
+  ranfpm1()
+	c'est le defaut: drandpm1()
+--
+*/
+
+/*=========================================================================*/
+/*
+++
+  void Ini_Ranf_Quick(long seed_val, int lp)
+	Initialisation rapide du generateur (drand48) par un entier
+	de 32 bits de type long (cf srand48).
+--
+*/
+void Ini_Ranf_Quick(long seed_val, int lp)
+{
+if(lp) printf("Ini_Ranf_Quick: %d\n",(int) seed_val);
+srand48(seed_val);
+return;
+}
+
+/*=========================================================================*/
+/*
+++
+  void Ini_Ranf(unsigned short seed_16v[3], int lp)
+	Initialisation complete du generateur (drand48) par
+	48 bits (cf seed48).
+--
+*/
+void Ini_Ranf(unsigned short seed_16v[3], int lp)
+{
+if(lp) printf("Ini_Ranf: %d %d %d\n"
+             ,seed_16v[0],seed_16v[1],seed_16v[2]);
+seed48(seed_16v);
+return;
+}
+
+/*=========================================================================*/
+/*
+++
+  void Get_Ranf(unsigned short seed_16v[3], int lp)
+	Recuperation de l'etat du generateur (drand48) sur
+	de 48 bits (cf seed48).
+--
+*/
+void Get_Ranf(unsigned short seed_16v[3], int lp)
+{
+unsigned short seed[3] = {0,0,0};
+unsigned short *p;
+p = seed48(seed);
+memcpy(seed_16v,p,3*sizeof(unsigned short));
+if(lp) printf("Get_Ranf: %d %d %d\n"
+             ,seed_16v[0],seed_16v[1],seed_16v[2]);
+/* on re-initialise a ce qui etait avant */
+seed48(seed_16v);
+return;
+}
+
+/*=========================================================================*/
+/*
+++
+  void Auto_Ini_Ranf(int lp)
+	Initialisation automatique (pseudo) aleatoire du generateur.
+	L'initialiseur est donne par le nombre de millisecondes
+	ecoulees depuis le dernier jour multiple de 23 du nombre de jours
+	depuis le 0 heure le 1er Janvier 1970 UTC (cf gettimeofday).
+	Pour retomber sur la meme initialisation
+	il faut generer deux aleatoires a moins de 1/1000 seconde
+	ou generer le deuxieme aleatoire 23 jours apres le premier
+	a la meme heure (a 1/1000 de seconde pres). La fonction
+	d'initialisation utilisee est Ini_Ranf_Quick(long).
+--
+*/
+void Auto_Ini_Ranf(int lp)
+{
+struct timeval now;
+long nj,nj23,seed=0;
+double buf;
+
+gettimeofday (&now,0);
+
+/* dans 32 bits signes on met environ 23 jours a 1/1000 de seconde pres! */
+/* Nombre de jours depuis l'origine */
+nj = (long) now.tv_sec / 86400;
+/* Nombre de jours depuis le dernier jour multiple de 23 jours */
+nj23 = nj % 23;
+/* nombre de secondes depuis le dernier jour multiple de 23 jours */
+buf = (double) (nj23*86400 + (now.tv_sec-nj*86400));
+/* nombre de milliemes de secondes depuis ... */
+buf = buf*1000. +  now.tv_usec/1000.;
+seed = (long) buf;
+
+if(lp) {
+  printf("Auto_Ini_Ranf: date %d s %d 10^-6 sec seed=%d:\n"
+        ,now.tv_sec,now.tv_usec,seed);
+  if(lp>1) printf("... njours=%d nj23=%d buf=%.20g\n",nj,nj23,buf);
+}
+Ini_Ranf_Quick(seed,lp);
+return;
+}
+
+/*=========================================================================*/
+/*
+++
+  void SetGauRange(double range)
+	Generation de distribution gaussienne:
+	Changement de l'initialisation de l'excursion du tirage
+	en nombre de sigmas
+--
+*/
+void SetGauRange(double range)
+{
+GAU_RANGE = range;
+}
+
+/*=========================================================================*/
+/*
+++
+  float NorRand(void)
+	Generation aleatoire gaussienne normee centree
+--
+*/
+float NorRand(void)
+{
+double x,A,B;
+
+LAB10:
+A = drand01();
+if ( A == 0. ) goto LAB10;
+B = drand01();
+x = sqrt(-2.*log(A))*cos(DeuxPi*B);
+return( (float) x );
+}
+
+/*=========================================================================*/
+/*
+++
+  float NorRand1(void)
+	Generation aleatoire gaussienne normee centree
+	la distribution est limitee entre +/- GAU_RANGE (obsolete).
+--
+*/
+float NorRand1(void)
+{
+double b, x, y, gauss;
+
+b = 1./sqrt(2.*M_PI);
+LAB10:
+x = GAU_RANGE*drandpm1();
+y = drand01()*b;
+gauss = b*exp(-x*x/2.);
+if ( gauss-y < 0. ) goto LAB10 ;
+return( (float) x );
+}
+
+/*=========================================================================*/
+/*
+++
+  double GauRnd(double am, double s)
+	Generation aleatoire gaussienne de centre "am" et de sigma "s".
+--
+*/
+double GauRnd(double am, double s)
+{
+double x,A,B;
+
+LAB10:
+A = drand01();
+if ( A == 0. ) goto LAB10;
+B = drand01();
+x = am + s * sqrt(-2.*log(A))*cos(DeuxPi*B);
+return(x);
+}
+
+/*=========================================================================*/
+/*
+++
+  double GauRnd1(double am, double s)
+	Generation aleatoire gaussienne de centre "am" et de
+	sigma "s" la distribution est limitee entre am +/- GAU_RANGE (obsolete).
+--
+*/
+double GauRnd1(double am, double s)
+{
+double s2, b, x, y, gauss;
+
+s2 = 2.*s*s;
+b = 1./sqrt(2.*M_PI*s);
+LAB10:
+x = am + GAU_RANGE*s*drandpm1();
+y = drand01()*b;
+gauss = b*exp(-(x-am)*(x-am)/s2);
+if ( gauss-y < 0. ) goto LAB10 ;
+return(x);
+}
+
+/*==========================================================================*/
+/*
+++
+  void NormGau(double *x,double *y,double mx,double my,double sa,double sb,double teta);
+	Tirage de 2 nombres aleatoires x et y distribues sur une gaussienne 2D
+	de centre (x=mx,y=my), de sigmas grand axe et petit axe (sa,sb)
+	et dont le grand axe fait un angle teta (radian) avec l'axe des x.
+--
+*/
+/*
+++
+| - La densite de probabilite (normalisee a 1) sur laquelle on tire est:
+| N*exp[-0.5*{ (A/sa)**2+(C/sc)**2 }],  N=1/(2Pi*sa*sc)
+| ou A et B sont les coordonnees selon le grand axe et le petit axe
+| et teta = angle(x,A), le resultat subit ensuite une rotation d'angle teta.
+| - La matrice des covariances C des variables A,B est:
+|   | sa^2   0   |
+|   |            |  et det(C) = (1-ro^2)*sa^2*sb^2
+|   |  0    sb^2 |
+| - La distribution x,y resultante est:
+| N*exp[-0.5*{[(dx/sx)^2-2*ro/(sx*sy)*dx*dy+(dy/sy)^2]/(1-ro^2)}]
+| ou N est donne dans NormCo et sx,sy,ro sont calcules a partir
+| de sa,sc,teta (voir fonctions paramga ou gaparam). La matrice des
+| covariances des variables x,y est donnee dans la fonction NormCo.
+--
+*/
+void NormGau(double *x,double *y
+            ,double mx,double my,double sa,double sb,double teta)
+{
+double c,s,X,Y;
+
+LAB10:
+ s = drand01();
+ if ( s == 0. ) goto LAB10;
+s = sqrt(-2.*log(s));
+c = DeuxPi * drand01();
+
+X = sa*s*cos(c);
+Y = sb*s*sin(c);
+
+c = cos(teta); s = sin(teta);
+*x = mx + c*X - s*Y;
+*y = my + s*X + c*Y;
+}
+
+/*==========================================================================*/
+/*
+++
+  int NormCo(double *x,double *y,double mx,double my,double sx,double sy,double ro)
+	Tirage de 2 nombres aleatoires x et y distribues sur une gaussienne 2D
+	de centre (mx,my), de coefficient de correlation rho (ro) et telle que
+	les sigmas finals des variables x et y soient sx,sy (ce sont
+	les valeurs des distributions marginales des variables aleatoires x et y
+	c'est a dire les sigmas des projections x et y de l'histogramme 2D
+	de la gaussienne). Retourne 0 si ok.
+--
+*/
+/*
+++
+| - La densite de probabilite (normalisee a 1) sur laquelle on tire est:
+|   N*exp[-0.5*{[(dx/sx)^2-2*ro/(sx*sy)*dx*dy+(dy/sy)^2]/(1-ro^2)}]
+|     avec dx = x-mx, dy = y-my et N = 1/[2Pi*sx*sy*sqrt(1-ro^2)]
+| - Dans ce cas la distribution marginale est (ex en X):
+|   1/(sqrt(2Pi)*sx) * exp[-0.5*{dx^2/sx^2}]
+| - La matrice des covariances C des variables x,y est:
+|   |   sx^2      ro*sx*sy |
+|   |                      |  et det(C) = (1-ro^2)*sx^2*sy^2
+|   | ro*sx*sy      sy^2   |
+| - La matrice inverse C^(-1) est:
+|   |   1/sx^2      -ro/(sx*sy) |
+|   |                           | * 1/(1-ro^2)
+|   | -ro/(sx*sy)      1/sy^2   |
+--
+*/
+/*
+++
+| - Remarque:
+| le sigma que l'on obtient quand on fait une coupe de la gaussienne 2D
+| en y=0 (ou x=0) est: SX0(y=0) = sx*sqrt(1-ro^2) different de sx
+|                      SY0(x=0) = sy*sqrt(1-ro^2) different de sy
+| La distribution qui correspond a des sigmas SX0,SY0
+| pour les coupes en y=0,x=0 de la gaussienne 2D serait:
+|   N*exp[-0.5*{ (dx/SX0)^2-2*ro/(SX0*SY0)*dx*dy+(dy/SY0)^2 }]
+| avec N = sqrt(1-ro^2)/(2Pi*SX0*SY0) et les variances
+| des variables x,y sont toujours
+|  sx=SX0/sqrt(1-ro^2), sy=SY0/sqrt(1-ro^2)
+--
+*/
+int NormCo(double *x,double *y
+          ,double mx,double my,double sx,double sy,double ro)
+{
+double a,b,sa;
+if( ro <= -1. || ro >= 1. ) return(1);
+LAB10:
+ b = drand01();
+ if ( b == 0. ) goto LAB10;
+b = sqrt(-2.*log(b));
+a = DeuxPi * drand01();
+sa = sin(a);
+
+*x = mx + sx*b*(sqrt(1.-ro*ro)*cos(a)+ro*sa);
+*y = my + sy*b*sa;
+
+return(0);
+}
+
+/*==========================================================================*/
+/*
+++
+  Titre	Exemple d'utilisation des aleatoires avec initialisation.
+--
+*/
+/*
+++
+|   #include "nbrandom.h"
+|   
+|   void main() {
+|   long i,ini=123456789;
+|   unsigned short seed[3];
+|   
+|   printf(" 1./ ==> test nitialisation par un long\n");
+|   Ini_Ranf_Quick(ini,1);
+|   for(i=0;i<10;i++) printf("%d  -> %f\n",i,ranf01());
+--
+*/
+/*
+++
+|   
+|   printf("\n 2./ ==> test initialisation par tableau de 3 unsigned short\n");
+|   Ini_Ranf_Quick(ini,1);
+|   for(i=0;i<5;i++) printf("%d  -> %f\n",i,ranf01());
+|   Get_Ranf(seed,1);
+|   for(i=5;i<10;i++) printf("%d  -> %f\n",i,ranf01());
+|   Ini_Ranf(seed,1);
+|   for(i=5;i<10;i++) printf("%d  -> %f\n",i,ranf01());
+|   Get_Ranf(seed,1);
+--
+*/
+/*
+++
+|   
+|   printf("\n 3./ ==> test initialisation automatique\n");
+|   Auto_Ini_Ranf(2);
+|   for(i=0;i<5;i++) printf("%d  -> %f\n",i,ranf01());
+|   i=0; while(i<10000000) i++;
+|   Auto_Ini_Ranf(2);
+|   for(i=0;i<5;i++) printf("%d  -> %f\n",i,ranf01());
+|   i=0; while(i<10000000) i++;
+|   Auto_Ini_Ranf(2);
+|   for(i=0;i<5;i++) printf("%d  -> %f\n",i,ranf01());
+|   }
+--
+*/
+/*
+++
+|    1./ ==> test initialisation par un long
+|   Ini_Ranf_Quick: 123456789
+|   0  -> 0.052468
+|   1  -> 0.025444
+|   2  -> 0.099272
+|   3  -> 0.436130
+|   4  -> 0.327740
+|   5  -> 0.821202
+|   6  -> 0.560493
+|   7  -> 0.018157
+|   8  -> 0.872758
+|   9  -> 0.652496
+--
+*/
+/*
+++
+|   
+|    2./ ==> test initialisation par tableau de 3 unsigned short
+|   Ini_Ranf_Quick: 123456789
+|   0  -> 0.052468
+|   1  -> 0.025444
+|   2  -> 0.099272
+|   3  -> 0.436130
+|   4  -> 0.327740
+--
+*/
+/*
+++
+|   Get_Ranf: 36117 51106 21478
+|   5  -> 0.821202
+|   6  -> 0.560493
+|   7  -> 0.018157
+|   8  -> 0.872758
+|   9  -> 0.652496
+--
+*/
+/*
+++
+|   Ini_Ranf: 36117 51106 21478
+|   5  -> 0.821202
+|   6  -> 0.560493
+|   7  -> 0.018157
+|   8  -> 0.872758
+|   9  -> 0.652496
+|   Get_Ranf: 16576 62373 42761
+--
+*/
+/*
+++
+|   
+|    3./ ==> test initialisation automatique
+|   Auto_Ini_Ranf: date 887117206 s 868138 10^-6 sec seed=826006868:
+|   ... njours=10267 nj23=9 buf=826006868.13800001
+|   Ini_Ranf_Quick: 826006868
+|   0  -> 0.798860
+|   1  -> 0.342478
+|   2  -> 0.401300
+|   3  -> 0.442912
+|   4  -> 0.170912
+--
+*/
+/*
+++
+|   Auto_Ini_Ranf: date 887117207 s 188779 10^-6 sec seed=826007188:
+|   ... njours=10267 nj23=9 buf=826007188.77900004
+|   Ini_Ranf_Quick: 826007188
+|   0  -> 0.455599
+|   1  -> 0.811427
+|   2  -> 0.703880
+|   3  -> 0.409569
+|   4  -> 0.390399
+--
+*/
+/*
+++
+|   Auto_Ini_Ranf: date 887117207 s 489750 10^-6 sec seed=826007489:
+|   ... njours=10267 nj23=9 buf=826007489.75
+|   Ini_Ranf_Quick: 826007489
+|   0  -> 0.567094
+|   1  -> 0.893156
+|   2  -> 0.975995
+|   3  -> 0.531331
+|   4  -> 0.834354
+--
+*/
+/*==========================================================================*/
+
+/*==========================================================================*/
+/* 
+++ 
+  Module 	Tirages aleatoires selon une fonction (C)
+  Lib	LibsUtil
+  include	nbrandom.h
+--
+*/
+/*
+++
+  TIREALEA *init_tirage_alea(int nbin,double xmin,double xmax,double (*fonc) (double))
+	Initialise la structure qui va permettre le tirage aleatoire
+	d'un nombre compris entre xmin et xmax selon la
+	distribution fonc (histo de nbin bins)
+--
+*/
+TIREALEA *init_tirage_alea(int nbin,double xmin,double xmax,double (*fonc) (double))
+{
+int sof,i;
+double x;
+struct tirage_alea *t;
+
+if ( xmax-xmin<0.) return(NULL);
+
+if(nbin<=3) nbin=50;
+
+sof = sizeof(struct tirage_alea);
+if( (t = malloc(sof) ) == NULL ) {
+  printf("impossible d'allouer *tirage_alea par malloc \n");
+  return(NULL);
+}
+
+t->Nbin=nbin; t->Min=xmin; t->Max=xmax; t->Lbin=(xmax-xmin) /nbin;
+
+sof = nbin * sizeof(double);
+if( (t->Tab = malloc(sof) ) == NULL ) {
+  printf("impossible d'allouer *tirage_alea.Tab par malloc \n");
+  return(NULL);
+}
+
+x = xmin + .5*t->Lbin;
+t->Tab[0] =  fonc(x);
+for(i=1;i<nbin;i++) {
+  x = xmin + (i+.5)*t->Lbin;
+  t->Tab[i] = t->Tab[i-1] + fonc(x);
+}
+
+for(i=0;i<nbin-1;i++)  t->Tab[i] /= t->Tab[nbin-1];
+t->Tab[nbin-1] = 1.;
+
+return(t);
+}
+
+/*==========================================================================*/
+/*
+++
+  double tirage_alea( TIREALEA *alea )
+	tirage aleatoire d'un nombre compris entre xmin et xmax
+	selon la fonction fonc (cf init_tirage_alea).
+--
+*/
+double tirage_alea( TIREALEA *alea )
+{ 
+int i,ibin = -1;
+double z,t1,t2,x1,x2,t;
+
+z=drand01();
+/* protections z<=0 ou z>=1 */
+if( z <= 0. ) return ( alea->Min );
+if( z >= 1. ) return ( alea->Max );
+/* cas z <= tab[0] */
+if(z <= alea->Tab[0]) {
+  t = alea->Min + (alea->Lbin/2.)/alea->Tab[0] * z;
+  return (t);
+}
+
+/* recherche du premier bin plus grand que z */
+for(i=0;i<alea->Nbin;i++) {
+  ibin=i;
+  if ( z < alea->Tab[i] ) break;
+}
+
+/* extrapolation pour trouver la valeur du tirage aleatoire */
+if( ibin == alea->Nbin-1 ) ibin--;
+t1=alea->Tab[ibin];
+x1 = alea->Min + (ibin+0.5) * alea->Lbin;
+t2=alea->Tab[ibin+1];
+x2 = x1 + alea->Lbin;
+t = x1 + (x2-x1)/(t2-t1) *(z-t1);
+if ( t < alea->Min ) t = alea->Min;
+if ( t > alea->Max ) t = alea->Max;
+return(t);
+}
+
+/*==========================================================================*/
+/*
+++
+  int end_tirage_alea( TIREALEA *alea )
+	De-allocation de la structure qui a permis le tirage aleatoire.
+--
+*/
+int end_tirage_alea( TIREALEA *alea )
+{ 
+if ( alea != NULL ) { free(alea); return(0);}
+  else return(-1);
+}
Index: /tags/DPC_V0/SophyaLib/NTools/nbrandom.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/nbrandom.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/nbrandom.h	(revision 1307)
@@ -0,0 +1,56 @@
+/* fonctions pour generateurs aleatoires */
+/*                         cmv  23/06/94 */
+
+#ifndef NBRANDOM_H_SEEN
+#define NBRANDOM_H_SEEN
+
+#include "defs.h"
+#include <stdlib.h>
+#ifdef __mac__
+#include <unixmac.h>
+#endif
+
+#define frand01() ( (float) drand48() )
+#define drand01() ( drand48() )
+#define ranf01() drand01()
+
+#define frandpm1() ( 2. * frand01() - 1.)
+#define drandpm1() ( 2. * drand01() - 1.)
+#define ranfpm1() drandpm1()
+
+struct tirage_alea {
+  int Nbin;
+  double Min,Max,Lbin;
+  double *Tab;
+};
+typedef struct tirage_alea TIREALEA;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void Ini_Ranf_Quick(long seed_val, int lp);
+void Ini_Ranf(unsigned short seed_16v[3], int lp);
+void Get_Ranf(unsigned short seed_16v[3], int lp);
+void Auto_Ini_Ranf(int lp);
+
+void SetGauRange(double range);
+float NorRand1(void);
+double GauRnd1(double am, double s);
+float NorRand(void);
+double GauRnd(double am, double s);
+int NormCo(double *a,double *b
+          ,double mx,double my,double sx,double sy,double ro);
+void NormGau(double *x,double *y
+            ,double mx,double my,double sa,double sb,double teta);
+
+TIREALEA *init_tirage_alea(int nbin,double xmin,double xmax,double (*fonc) (double));
+double tirage_alea(TIREALEA *alea);
+int end_tirage_alea(TIREALEA *alea);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/NTools/nbtri.c
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/nbtri.c	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/nbtri.c	(revision 1307)
@@ -0,0 +1,785 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include "nbtri.h"
+
+/* 
+++ 
+  Module	Tri de tableaux (C)
+  Lib	LibsUtil
+  include	nbtri.h
+
+	Tri de tableaux et indexation.
+--
+*/
+
+/*=========================================================================*/
+/*
+++
+  void HeapSort(int n,double *ra_int)
+	On reordonne par ordre numerique croissant
+	le tableau ra_int[n]: Numerical Recipes mode C.
+--
+*/
+void HeapSort(int n,double *ra_int)
+{
+   int l,j,ir,i;
+   double rra,*ra;
+
+   /* attention, Numerical recipes prend des tableaux de 1 a n on remet
+      de 0 a n-1 en decramentant le pointeur du tableau d'entree*/
+   ra = ra_int-1;
+
+   l=(n >> 1)+1;
+   ir=n;
+   for (;;) {
+      if (l > 1)
+         rra=ra[--l];
+      else {
+         rra=ra[ir];
+         ra[ir]=ra[1];
+         if (--ir == 1) {
+            ra[1]=rra;
+            return;
+         }
+      }
+      i=l;
+      j=l << 1;
+      while (j <= ir) {
+         if (j < ir && ra[j] < ra[j+1]) ++j;
+         if (rra < ra[j]) {
+            ra[i]=ra[j];
+            j += (i=j);
+         }
+         else j=ir+1;
+      }
+      ra[i]=rra;
+   }
+}
+
+/*=========================================================================*/
+/*
+++
+  void HeapSortF(int n,float *ra_int)
+	On reordonne par ordre numerique croissant
+	le tableau ra_int[n]: Numerical Recipes mode C.
+--
+*/
+void HeapSortF(int n,float *ra_int)
+{
+   int l,j,ir,i;
+   float rra,*ra;
+
+   /* attention, Numerical reciepes prend des tableaux de 1 a n on remet
+      de 0 a n-1 en decramentant le pointeur du tableau d'entree*/
+   ra = ra_int-1;
+
+   l=(n >> 1)+1;
+   ir=n;
+   for (;;) {
+      if (l > 1)
+         rra=ra[--l];
+      else {
+         rra=ra[ir];
+         ra[ir]=ra[1];
+         if (--ir == 1) {
+            ra[1]=rra;
+            return;
+         }
+      }
+      i=l;
+      j=l << 1;
+      while (j <= ir) {
+         if (j < ir && ra[j] < ra[j+1]) ++j;
+         if (rra < ra[j]) {
+            ra[i]=ra[j];
+            j += (i=j);
+         }
+         else j=ir+1;
+      }
+      ra[i]=rra;
+   }
+}
+
+/*=========================================================================*/
+/*
+++
+  void HeapSortF2(int n,float *ra_int,float *ra2_int)
+	On reordonne par ordre numerique croissant
+	le tableau ra_int[n] et ra2_int en parralelle.
+	Numerical Recipes mode C.
+--
+*/
+void HeapSortF2(int n,float *ra_int,float *ra2_int)
+{
+   int l,j,ir,i;
+   float rra,rra2,*ra,*ra2;
+
+   /* attention, Numerical reciepes prend des tableaux de 1 a n on remet
+      de 0 a n-1 en decramentant le pointeur du tableau d'entree*/
+   ra = ra_int-1;
+   ra2 = ra2_int-1;
+
+   l=(n >> 1)+1;
+   ir=n;
+   for (;;) {
+      if (l > 1)
+        {rra=ra[--l];   rra2=ra2[l];}
+      else {
+         rra=ra[ir];    rra2=ra2[ir];
+         ra[ir]=ra[1];   ra2[ir]=ra2[1];
+         if (--ir == 1) {
+            ra[1]=rra;  ra2[1]=rra2;
+            return;
+         }
+      }
+      i=l;
+      j=l << 1;
+      while (j <= ir) {
+         if (j < ir && ra[j] < ra[j+1]) ++j;
+         if (rra < ra[j]) {
+            ra[i]=ra[j];  ra2[i]=ra2[j];
+            j += (i=j);
+         }
+         else j=ir+1;
+      }
+      ra[i]=rra;   ra2[i]=rra2;
+   }
+}
+
+/*=========================================================================*/
+/*
+++
+  int_4 tri_double ( double *tab, int_4 *indx,int_4 N)
+	Methode de tri sans finesse (double boucles).
+| entree : tab -> tableau de double de longueur N (0 a N-1 )
+| sortie : indx -> tableau d'entiers de longueur N : la case i   
+|          contient le classement du ieme element dans tab  
+| Retourne:  0 si tri impossible
+|            1 si tri reussi
+--
+*/
+int_4 tri_double ( double *tab, int_4 *indx,int_4 N)
+{
+int_4 i,j,k;
+
+if (N<=0) return (-1);
+
+for (i=0; i<N ; i++) indx[i]=i;
+if (N==1) return (N);
+
+/* classement dans l'ordre croissant */
+for (i=1; i< N ; i++)
+  { 
+
+  if ( *(tab+indx[i]) < *(tab+indx[i-1]) )
+    { 
+     k = indx[i-1];
+     indx[i-1] = indx[i];
+     indx[i] = k;
+
+     if ( i > 1 )
+        for (j=i ; j>=1 ; j--)
+          { if ( *(tab+indx[j]) < *(tab+indx[j-1]) )
+            { 
+            k = indx[j-1];
+            indx[j-1] = indx[j];
+            indx[j] = k;
+    } } } }
+
+return (N) ;
+}
+
+/*=========================================================================*/
+/*
+++
+  int_4 tri_float ( float *tab, int_4 *indx,int_4 N)
+	Methode de tri sans finesse (double boucles).
+| entree : tab -> tableau de flottant de longueur N (0 a N-1 )
+| sortie : indx -> tableau d'entiers de longueur N : la case i   
+|          contient le classement du ieme element dans tab  
+| Retourne:  0 si tri impossible
+|            1 si tri reussi
+--
+*/
+int_4 tri_float ( float *tab, int_4 *indx,int_4 N)
+{
+int_4 i,j,k;
+
+if (N<=0) return (-1);
+
+for (i=0; i<N ; i++) indx[i]=i;
+if (N==1) return (N);
+
+/* classement dans l'ordre croissant */
+for (i=1; i< N ; i++)
+  { 
+
+  if ( *(tab+indx[i]) < *(tab+indx[i-1]) )
+    { 
+     k = indx[i-1];
+     indx[i-1] = indx[i];
+     indx[i] = k;
+
+     if ( i > 1 )
+        for (j=i ; j>=1 ; j--)
+          { if ( *(tab+indx[j]) < *(tab+indx[j-1]) )
+            { 
+            k = indx[j-1];
+            indx[j-1] = indx[j];
+            indx[j] = k;
+    } } } }
+
+return (N) ;
+}
+
+/*=========================================================================*/
+/*
+++
+  int_4 tri_entier ( int_4 *tab,int_4 *indx,int_4 N)
+	Methode de tri sans finesse (double boucles).
+| entree : tab -> tableau d'entiers de longueur N (0 a N-1 )
+| sortie : indx -> tableau d'entiers de longueur N : la case i   
+|          contient le classement du ieme element dans tab  
+| Retourne:  0 si tri impossible
+|            1 si tri reussi
+--
+*/
+int_4 tri_entier ( int_4 *tab,int_4 *indx,int_4 N)
+{
+int_4 i,j,k;
+
+if (N<=0) return (-1);
+
+for (i=0; i<N ; i++) indx[i]=i;
+if (N==1) return (N);
+
+/* classement dans l'ordre croissant */
+for (i=1; i< N ; i++)
+  { 
+
+  if ( *(tab+indx[i]) < *(tab+indx[i-1]) )
+    { 
+     k = indx[i-1];
+     indx[i-1] = indx[i];
+     indx[i] = k;
+
+     if ( i > 1 )
+        for (j=i ; j>=1 ; j--)
+          { if ( *(tab+indx[j]) < *(tab+indx[j-1]) )
+            { 
+            k = indx[j-1];
+            indx[j-1] = indx[j];
+            indx[j] = k;
+    } } } }
+
+return (N) ;
+}
+
+/*=========================================================================*/
+/*
+++
+  int_4 tri_rapide_I (int_4 *datum,int_4 *index,int_4 N)
+	algorythme de tri rapide
+	( p114-119 THE ART OF COMPUTER PROGRAMMING, vol. 3 SORTING AND
+	SEARCHING de D.E. Knuth)
+| datum  ( entree/sortie ) -> vecteur de dimension N contenant des ENTIERS
+|        desordonnes en entree. Ces elements ressortent ordonnes.
+| index  ( sortie ) -> vecteur de dimension N contenant des entiers.
+|        Le contenu de la case i de index nous indique la place
+|        du ieme element du datum originel.
+| tri_rapide = -1 si echec, 1 si reussite de l'operation
+--
+*/
+int_4 tri_rapide_I (int_4 *datum,int_4 *index,int_4 N)
+{
+/* 14 = nb max d'entrees que la pile (stack) peut contenir. Ce 14 limite la longueur 
+             maximale possible pour les vecteurs a 32 768 ( = 2**15 ) */
+
+int_4 stklo[14], stkhi[14], hi, nstak, i, limlo, limhi, lo, ikey;
+int_4 dkey;
+
+/* initialisations */
+
+for (i=0; i<=N-1 ;i++)  index[i]=i;
+
+nstak=0;
+limlo=0; limhi=N-1;
+
+grande_boucle:
+  dkey = *(datum+limlo);
+  ikey = *(index+limlo);
+
+/* compare tous les elements d'un ss-vecteur entre limlo et limhi avec la donnee-cle courante */
+
+  lo=limlo; hi=limhi;
+  
+sous_boucle_1:
+  if ( lo == hi ) goto lo_egal_hi;
+
+  if ( *(datum+hi) <= dkey ) goto remplacement_lo;
+  hi = hi - 1;
+
+/* le pointeur  hi doit pointer une donnee plus petite que la cle qui va etre remplacer */
+
+  goto sous_boucle_1;
+
+remplacement_lo:
+  *(datum+lo) = *(datum+hi);
+  *(index+lo) = *(index+hi);
+  lo = lo + 1;
+  
+sous_boucle_2:
+  if ( lo == hi ) goto lo_egal_hi;
+
+  if ( *(datum+lo) >= dkey ) goto remplacement_hi;
+
+  lo = lo + 1;
+  goto sous_boucle_2;
+
+remplacement_hi:
+  *(datum+hi) = *(datum+lo);
+  *(index+hi) = *(index+lo);
+  hi = hi - 1;
+
+/* le pointeur lo doit pointer une donnee plus grande que la cle qui va etre remplacer */
+
+  goto sous_boucle_1;
+
+lo_egal_hi:
+
+/* lo et hi sont egaux, et pointent sur une valeur qui va etre remplacer. Tant que toutes les valeurs sous ce point sont inferieures a la cle et que toutes les valeurs apres ce point sont superieures a la cle, c'est la que nous remettrons la cle dans le vecteur */
+
+  *(datum+lo) = dkey;
+  *(index+lo) = ikey;
+
+/* A ce point du ss-prog. toutes les donnees entre limlo et lo-1 inclus sont inferieurs a datum(lo), et toutes les donnes entre lo+1 et limhi sont superieures a datum(lo)  
+   Si les deux ss-tableaux ne contiennent pas plus d'un element, on prend l'intervale le plus recent de la pile ( si le stack est vide c'est fini ). Si le plus grand des deux ss-tableaux contient plus d'un element et si le plus petit contient au plus un element, alors on oublie le plus petit et on reduit l'autre. Si le plus petit ss-tableau contient au moins 2 elements, alors on place le plus grand ss-tableau dans la pile et on processe le ss-tableau.  */
+  
+  if ( (limhi-lo) > (lo-limlo) ) goto cas_1;
+
+/* cas 1 : le ss-tableau inferieur est plus long. Si il contient un element au plus, alors on prend l'intervalle du stack le plus recent, on le ramene et on travaille dessus */
+
+  if ( (lo-limlo) <= 1) goto test_fin;
+
+/* si le ss-tableau superieur ( le + court ss-tableau ) contient  un element au plus alors on processe le  ss-tableau inferieur ( le + long), mais si le ss-tableau superieur contient plus d'un element, alors on place le  ss-tableau inferieur ( le + long) sur la pile et on processe le ss-tableau superieur. */
+
+  if ( (limhi-lo) >= 2) goto cas_1b;
+
+/* cas 1a : si le ss-tableau superieur ( le + court ss-tableau ) contient  un element au plus alors on revient en arriere et on agit sur le  ss-tableau inferieur ( le + long) */
+
+  limhi=lo-1;
+  goto grande_boucle;
+
+/* cas 1b :  si le ss-tableau superieur ( le + court ss-tableau ) contient plus d'un element, alors on place le  ss-tableau inferieur ( le + long) sur la pile et on processe le ss-tableau superieur. */
+
+cas_1b:
+  nstak=nstak+1;
+  *(stklo+nstak)=limlo;
+  *(stkhi+nstak)=lo-1;
+  limlo=lo+1;
+  goto grande_boucle;
+ 
+/* cas 2 : le ss-tableau superieur est plus long, si il contient  un element au plus alors on agit sur l'intervalle le plus recent de la pile. */
+
+cas_1:
+  if ( (limhi-lo) <= 1) goto test_fin;
+
+/* si le ss-tableau inferieur ( le + court ss-tableau ) contient  un element au plus alors on processe le  ss-tableau superieur ( le + long), mais si le ss-tableau inferieur contient plus d'un element, alors on place le  ss-tableau superieur ( le + long) sur la pile et on processe le ss-tableau inferieur. */
+
+   if ( (lo-limlo) >= 2) goto cas_2b;
+
+/*  cas 2a : si le ss-tableau inferieur ( le + court ss-tableau ) contient  un element au plus alors on revient en arriere et on agit sur le  ss-tableau superieur ( le + long) */
+
+  limlo=lo+1;
+  goto grande_boucle;
+  
+/* cas 2b :  si le ss-tableau inferieur ( le + court ss-tableau ) contient plus d'un element, alors on place le  ss-tableau superieur ( le + long) sur la pile et on processe le ss-tableau inferieur. */
+
+cas_2b:
+  nstak=nstak+1;
+  *(stklo+nstak)=lo+1;
+  *(stkhi+nstak)=limhi;
+  limlo=lo-1;
+  goto grande_boucle;
+   
+/* on prend l'intervalle le plus recent de la pile. Si le stack est vide, c'est fini !!! */
+        
+test_fin:
+  if (nstak <= 0) return (1);
+  limlo = *(stklo+nstak);
+  limhi = *(stkhi+nstak);
+  nstak=nstak-1;
+  goto grande_boucle;
+
+}
+
+/*=========================================================================*/
+/*
+++
+  int_4 tri_rapide_F (float *datum,int_4 *index,int_4 N)
+	Idem tri_rapide_I mais pour un tableau de flottants
+	 REMPLI avec des ENTIERS.
+--
+*/
+int_4 tri_rapide_F (float *datum,int_4 *index,int_4 N)
+{
+/* ATTENTION, Ce programme tri un tableau de flottants REMPLI avec des ENTIERS!!!!!
+  14 = nb max d'entrees que la pile (stack) peut contenir. Ce 14 limite la longueur 
+             maximale possible pour les vecteurs a 32 768 ( = 2**15 ) */
+
+int_4 stklo[14], stkhi[14], hi, nstak, i, limlo, limhi, lo, ikey;
+float dkey;
+
+/* initialisations */
+
+for (i=0; i<=N-1 ; i++) index[i]=i;
+nstak=0;
+limlo=0; limhi=N-1;
+
+grande_boucle:
+  dkey = *(datum+limlo);
+  ikey = *(index+limlo);
+
+/* compare tous les elements d'un ss-vecteur entre limlo et limhi avec la donnee-cle courante */
+
+  lo=limlo; hi=limhi;
+  
+sous_boucle_1:
+  if ( lo == hi ) goto lo_egal_hi;
+
+  if ( *(datum+hi) <= dkey ) goto remplacement_lo;
+  hi = hi - 1;
+
+/* le pointeur  hi doit pointer une donnee plus petite que la cle qui va etre remplacer */
+
+  goto sous_boucle_1;
+
+remplacement_lo:
+  *(datum+lo) = *(datum+hi);
+  *(index+lo) = *(index+hi);
+  lo = lo + 1;
+  
+sous_boucle_2:
+  if ( lo == hi ) goto lo_egal_hi;
+
+  if ( *(datum+lo) >= dkey ) goto remplacement_hi;
+
+  lo = lo + 1;
+  goto sous_boucle_2;
+
+remplacement_hi:
+  *(datum+hi) = *(datum+lo);
+  *(index+hi) = *(index+lo);
+  hi = hi - 1;
+
+/* le pointeur lo doit pointer une donnee plus grande que la cle qui va etre remplacer */
+
+  goto sous_boucle_1;
+
+lo_egal_hi:
+
+/* lo et hi sont egaux, et pointent sur une valeur qui va etre remplacer. Tant que toutes les valeurs sous ce point sont inferieures a la cle et que toutes les valeurs apres ce point sont superieures a la cle, c'est la que nous remettrons la cle dans le vecteur */
+
+  *(datum+lo) = dkey;
+  *(index+lo) = ikey;
+
+/* A ce point du ss-prog. toutes les donnees entre limlo et lo-1 inclus sont inferieurs a datum(lo), et toutes les donnes entre lo+1 et limhi sont superieures a datum(lo)  
+   Si les deux ss-tableaux ne contiennent pas plus d'un element, on prend l'intervale le plus recent de la pile ( si le stack est vide c'est fini ). Si le plus grand des deux ss-tableaux contient plus d'un element et si le plus petit contient au plus un element, alors on oublie le plus petit et on reduit l'autre. Si le plus petit ss-tableau contient au moins 2 elements, alors on place le plus grand ss-tableau dans la pile et on processe le ss-tableau.  */
+  
+  if ( (limhi-lo) > (lo-limlo) ) goto cas_1;
+
+/* cas 1 : le ss-tableau inferieur est plus long. Si il contient un element au plus, alors on prend l'intervalle du stack le plus recent, on le ramene et on travaille dessus */
+
+  if ( (lo-limlo) <= 1) goto test_fin;
+
+/* si le ss-tableau superieur ( le + court ss-tableau ) contient  un element au plus alors on processe le  ss-tableau inferieur ( le + long), mais si le ss-tableau superieur contient plus d'un element, alors on place le  ss-tableau inferieur ( le + long) sur la pile et on processe le ss-tableau superieur. */
+
+  if ( (limhi-lo) >= 2) goto cas_1b;
+
+/* cas 1a : si le ss-tableau superieur ( le + court ss-tableau ) contient  un element au plus alors on revient en arriere et on agit sur le  ss-tableau inferieur ( le + long) */
+
+  limhi=lo-1;
+  goto grande_boucle;
+
+/* cas 1b :  si le ss-tableau superieur ( le + court ss-tableau ) contient plus d'un element, alors on place le  ss-tableau inferieur ( le + long) sur la pile et on processe le ss-tableau superieur. */
+
+cas_1b:
+  nstak=nstak+1;
+  *(stklo+nstak)=limlo;
+  *(stkhi+nstak)=lo-1;
+  limlo=lo+1;
+  goto grande_boucle;
+ 
+/* cas 2 : le ss-tableau superieur est plus long, si il contient  un element au plus alors on agit sur l'intervalle le plus recent de la pile. */
+
+cas_1:
+  if ( (limhi-lo) <= 1) goto test_fin;
+
+/* si le ss-tableau inferieur ( le + court ss-tableau ) contient  un element au plus alors on processe le  ss-tableau superieur ( le + long), mais si le ss-tableau inferieur contient plus d'un element, alors on place le  ss-tableau superieur ( le + long) sur la pile et on processe le ss-tableau inferieur. */
+
+   if ( (lo-limlo) >= 2) goto cas_2b;
+
+/*  cas 2a : si le ss-tableau inferieur ( le + court ss-tableau ) contient  un element au plus alors on revient en arriere et on agit sur le  ss-tableau superieur ( le + long) */
+
+  limlo=lo+1;
+  goto grande_boucle;
+  
+/* cas 2b :  si le ss-tableau inferieur ( le + court ss-tableau ) contient plus d'un element, alors on place le  ss-tableau superieur ( le + long) sur la pile et on processe le ss-tableau inferieur. */
+
+cas_2b:
+  nstak=nstak+1;
+  *(stklo+nstak)=lo+1;
+  *(stkhi+nstak)=limhi;
+  limlo=lo-1;
+  goto grande_boucle;
+   
+/* on prend l'intervalle le plus recent de la pile. Si le stack est vide, c'est fini !!! */
+        
+test_fin:
+  if (nstak <= 0) return (1);
+  limlo = *(stklo+nstak);
+  limhi = *(stkhi+nstak);
+  nstak=nstak-1;
+  goto grande_boucle;
+
+}
+
+/*===================================================================================*/
+/*
+++
+  int qSort_Float(const void *a1,const void *a2)
+	Fonction de tri de `float' a utiliser dans qsort.
+--
+*/
+int qSort_Float(const void *a1,const void *a2)
+{
+if( *((float *) a1) < *((float *) a2) ) return(-1);
+if( *((float *) a1) > *((float *) a2) ) return( 1);
+return(0);
+}
+
+/*===================================================================================*/
+/*
+++
+  int qSort_Dble(const void *a1,const void *a2)
+	Fonction de tri de `double' a utiliser dans qsort.
+--
+*/
+int qSort_Dble(const void *a1,const void *a2)
+{
+if( *((double *) a1) < *((double *) a2) ) return(-1);
+if( *((double *) a1) > *((double *) a2) ) return( 1);
+return(0);
+}
+
+/*===================================================================================*/
+/*
+++
+  int qSort_Int(const void  *a1,const void  *a2)
+	Fonction de tri de `int' a utiliser dans qsort.
+--
+*/
+int qSort_Int(const void  *a1,const void  *a2)
+{
+if( *((int *) a1) < *((int *) a2) ) return(-1);
+if( *((int *) a1) > *((int *) a2) ) return( 1);
+return(0);
+}
+
+/*===================================================================================*/
+/*
+++
+  int qSort_Ushort(const void  *a1,const void  *a2)
+	Fonction de tri de `unsigned short' a utiliser dans qsort.
+--
+*/
+int qSort_Ushort(const void  *a1,const void  *a2)
+{
+if( *((unsigned short *) a1) < *((unsigned short *) a2) ) return(-1);
+if( *((unsigned short *) a1) > *((unsigned short *) a2) ) return( 1);
+return(0);
+}
+
+/*===================================================================================*/
+/*
+++
+  int qSort_Short(const void  *a1,const void  *a2)
+	Fonction de tri de `short' a utiliser dans qsort.
+--
+*/
+int qSort_Short(const void  *a1,const void  *a2)
+{
+if( *((short *) a1) < *((short *) a2) ) return(-1);
+if( *((short *) a1) > *((short *) a2) ) return( 1);
+return(0);
+}
+
+/*===================================================================================*/
+/*
+++
+  void IndexR4(int_4 n, float* arr_c, int_4* indx_c)
+	Indexes an array arr[1..n], i.e., outputs the array indx[1..n]
+	such that arr[indx[j]] is in ascending order for j=1,2,,N.
+	The input quantities n and arr are not changed.
+--
+*/
+#define SWAP_INDEXR4(a,b) itemp=(a);(a)=(b);(b)=itemp;
+#define M 7
+#define NSTACK 50
+void IndexR4(int_4 n, float* arr_c, int_4* indx_c)
+/* encore du Num.Rec. avec tableaux commencant a 1. */
+{
+        float *arr; int_4 *indx;
+	int_4 i,indxt,ir=n,itemp,j,k,l=1;
+	int_4 jstack=0;
+	float a;
+        int_4 istack[NSTACK+1];
+
+        arr = arr_c-1;
+        indx = indx_c-1;
+
+	for (j=1;j<=n;j++) indx[j]=j;
+	for (;;) {
+		if (ir-l < M) {
+			for (j=l+1;j<=ir;j++) {
+				indxt=indx[j];
+				a=arr[indxt];
+				for (i=j-1;i>=1;i--) {
+					if (arr[indx[i]] <= a) break;
+					indx[i+1]=indx[i];
+				}
+				indx[i+1]=indxt;
+			}
+			if (jstack == 0) break;
+			ir=istack[jstack--];
+			l=istack[jstack--];
+		} else {
+			k=(l+ir) >> 1;
+			SWAP_INDEXR4(indx[k],indx[l+1]);
+			if (arr[indx[l+1]] > arr[indx[ir]]) {
+				SWAP_INDEXR4(indx[l+1],indx[ir])
+			}
+			if (arr[indx[l]] > arr[indx[ir]]) {
+				SWAP_INDEXR4(indx[l],indx[ir])
+			}
+			if (arr[indx[l+1]] > arr[indx[l]]) {
+				SWAP_INDEXR4(indx[l+1],indx[l])
+			}
+			i=l+1;
+			j=ir;
+			indxt=indx[l];
+			a=arr[indxt];
+			for (;;) {
+				do i++; while (arr[indx[i]] < a);
+				do j--; while (arr[indx[j]] > a);
+				if (j < i) break;
+				SWAP_INDEXR4(indx[i],indx[j])
+			}
+			indx[l]=indx[j];
+			indx[j]=indxt;
+			jstack += 2;
+			if (jstack > NSTACK) {
+                          printf("NSTACK too small in indexx. %d>%d",jstack,NSTACK);
+                          exit(-1);
+			}
+			if (ir-i+1 >= j-l) {
+				istack[jstack]=ir;
+				istack[jstack-1]=i;
+				ir=j-1;
+			} else {
+				istack[jstack]=j-1;
+				istack[jstack-1]=l;
+				l=i;
+			}
+		}
+	}
+}
+#undef SWAP_INDEXR4
+#undef M
+#undef NSTACK
+
+/*===================================================================================*/
+/*
+++
+  void IndexR8(int_4 n, double* arr_c, int_4* indx_c)
+	Indexes an array arr[1..n], i.e., outputs the array indx[1..n]
+	such that arr[indx[j]] is in ascending order for j=1,2,,N.
+	The input quantities n and arr are not changed.
+--
+*/
+#define SWAP_INDEXR8(a,b) itemp=(a);(a)=(b);(b)=itemp;
+#define M 7
+#define NSTACK 50
+void IndexR8(int_4 n, double* arr_c, int_4* indx_c)
+/* encore du Num.Rec. avec tableaux commencant a 1. */
+{
+        double *arr; int_4 *indx;
+	int_4 i,indxt,ir=n,itemp,j,k,l=1;
+	int_4 jstack=0;
+	double a;
+        int_4 istack[NSTACK+1];
+
+        arr = arr_c-1;
+        indx = indx_c-1;
+
+	for (j=1;j<=n;j++) indx[j]=j;
+	for (;;) {
+		if (ir-l < M) {
+			for (j=l+1;j<=ir;j++) {
+				indxt=indx[j];
+				a=arr[indxt];
+				for (i=j-1;i>=1;i--) {
+					if (arr[indx[i]] <= a) break;
+					indx[i+1]=indx[i];
+				}
+				indx[i+1]=indxt;
+			}
+			if (jstack == 0) break;
+			ir=istack[jstack--];
+			l=istack[jstack--];
+		} else {
+			k=(l+ir) >> 1;
+			SWAP_INDEXR8(indx[k],indx[l+1]);
+			if (arr[indx[l+1]] > arr[indx[ir]]) {
+				SWAP_INDEXR8(indx[l+1],indx[ir])
+			}
+			if (arr[indx[l]] > arr[indx[ir]]) {
+				SWAP_INDEXR8(indx[l],indx[ir])
+			}
+			if (arr[indx[l+1]] > arr[indx[l]]) {
+				SWAP_INDEXR8(indx[l+1],indx[l])
+			}
+			i=l+1;
+			j=ir;
+			indxt=indx[l];
+			a=arr[indxt];
+			for (;;) {
+				do i++; while (arr[indx[i]] < a);
+				do j--; while (arr[indx[j]] > a);
+				if (j < i) break;
+				SWAP_INDEXR8(indx[i],indx[j])
+			}
+			indx[l]=indx[j];
+			indx[j]=indxt;
+			jstack += 2;
+			if (jstack > NSTACK) {
+                          printf("NSTACK too small in indexx. %d>%d",jstack,NSTACK);
+                          exit(-1);
+			}
+			if (ir-i+1 >= j-l) {
+				istack[jstack]=ir;
+				istack[jstack-1]=i;
+				ir=j-1;
+			} else {
+				istack[jstack]=j-1;
+				istack[jstack-1]=l;
+				l=i;
+			}
+		}
+	}
+}
+#undef SWAP_INDEXR8
+#undef M
+#undef NSTACK
Index: /tags/DPC_V0/SophyaLib/NTools/nbtri.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/nbtri.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/nbtri.h	(revision 1307)
@@ -0,0 +1,40 @@
+/* fonction de tri */
+/*    cmv 23/06/94 */
+
+#ifndef NBTRI_H_SEEN
+#define NBTRI_H_SEEN
+
+
+#include <machine.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void HeapSort(int n,double *ra_int);
+void HeapSortF(int n,float *ra_int);
+void HeapSortF2(int n,float *ra_int,float *ra2_int);
+
+int_4 tri_double ( double *tab, int_4 *indx,int_4 N);
+int_4 tri_float ( float *tab, int_4 *indx,int_4 N);
+int_4 tri_entier ( int_4 *tab,int_4 *indx,int_4 N);
+
+int_4 tri_rapide_I (int_4 *datum,int_4 *index,int_4 N);
+int_4 tri_rapide_F (float *datum,int_4 *index,int_4 N);
+
+int qSort_Float(const void *a1,const void *a2);
+int qSort_Dble(const void *a1,const void *a2);
+int qSort_Int(const void *a1,const void *a2);
+int qSort_Ushort(const void *a1,const void *a2);
+int qSort_Short(const void *a1,const void *a2);
+
+void IndexR4(int_4 n, float* arr_c, int_4* indx_c);
+void IndexR8(int_4 n, double* arr_c, int_4* indx_c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/NTools/ntuple.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/ntuple.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/ntuple.cc	(revision 1307)
@@ -0,0 +1,356 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "perrors.h"
+#include "ntuple.h"
+
+
+#define BADVAL -1.e19
+#define LENNAME 8
+#define LENNAME1  (LENNAME+1)
+
+//++
+// Class	NTuple
+// Lib	Outils++ 
+// include	ntuple.h
+//
+//	Classe de ntuples
+//--
+
+/* --Methode-- */
+//++
+NTuple::NTuple()
+//
+//	Createur par defaut
+//--
+{
+mNVar = mNEnt = mBlk = mNBlk = 0;
+mVar = NULL;
+mNames = NULL;
+mInfo = NULL;
+}
+
+
+//++
+NTuple::NTuple(int nvar, char** noms, int blk)
+//
+//	Createur d'un ntuple de `nvar' variables dont les
+//	noms sont dans le tableau de cahines de caracteres `noms'
+//	avec `blk' d'evenements par blocks.
+//--
+{
+mNVar = mNEnt = mBlk = mNBlk = 0;
+mVar = NULL;
+mNames = NULL;
+mInfo = NULL;
+if (nvar <= 0)  THROW(sizeMismatchErr); 
+mNVar = nvar;
+mVar = new r_4[nvar];
+if (blk < 10) blk = 10;
+mBlk = blk;
+// On prend des noms de LENNAME char pour le moment
+mNames = new char[nvar*LENNAME1];
+r_4* pt = new r_4[nvar*blk];
+mNBlk = 1;
+mPtr.push_back(pt);
+int i;
+for(i=0; i<nvar; i++)
+  { strncpy(mNames+i*LENNAME1, noms[i], LENNAME);  
+  mNames[i*LENNAME1+LENNAME] = '\0'; }
+return;
+}
+
+/* --Methode-- */
+//++
+NTuple::NTuple(char *flnm)
+//
+//	Createur lecture fichier ppersist.
+//--
+{
+mNVar = mNEnt = mBlk = mNBlk = 0;
+mVar = NULL;
+mNames = NULL;
+mInfo = NULL;
+PInPersist s(flnm);
+Read(s);
+}
+
+/* --Methode-- */
+NTuple::~NTuple()
+{
+Clean();
+}
+
+/* --Methode-- */
+void NTuple::Clean()
+{
+if (mVar) delete[] mVar;
+if (mNames)  delete[] mNames;
+if (mInfo) delete mInfo;
+int i;
+for(i=0; i<mNBlk; i++)  delete[] mPtr[i];
+mPtr.erase(mPtr.begin(), mPtr.end());
+mNVar = mNEnt = mBlk = mNBlk = 0;
+mVar = NULL;
+mNames = NULL;
+return;
+}
+
+/* --Methode-- */
+//++
+void  NTuple::Fill(r_4* x)
+//
+//	Remplit le ntuple avec le tableau cd reels `x'.
+//--
+{
+int numb = mNEnt/mBlk;
+if (numb >= mNBlk) {
+  r_4* pt = new r_4[mNVar*mBlk];
+  mNBlk++;
+  mPtr.push_back(pt);
+}
+int offb = mNEnt-numb*mBlk;
+memcpy((mPtr[numb]+offb*mNVar), x, mNVar*sizeof(r_4));
+mNEnt++;
+return;
+}
+
+
+/* --Methode-- */
+//++
+float NTuple::GetVal(int n, int k)  const
+//
+//	Retourne la valeur de la variable `k' de l'evenement `n'.
+//--
+{
+if (n >= mNEnt)   return(BADVAL);
+if ( (k < 0) || (k >= mNVar) )    return(BADVAL);
+int numb = n/mBlk;
+int offb = n-numb*mBlk;
+return(*(mPtr[numb]+offb*mNVar+k));
+}
+
+
+/* --Methode-- */
+//++
+int NTuple::IndexNom(const char* nom)  const
+//
+//	Retourne le numero de la variable de nom `nom'.
+//--
+{
+int i;
+for(i=0; i<mNVar; i++)  
+  if ( strcmp(nom, mNames+i*LENNAME1) == 0)  return(i);
+return(-1);
+}
+
+
+static char nomretour[2*LENNAME1];
+/* --Methode-- */
+//++
+char* NTuple::NomIndex(int k)  const
+//
+//	Retourne le nom de la variable numero 'k'
+//--
+{
+nomretour[0] = '\0';
+if ((k >= 0) && (k < mNVar))  strcpy(nomretour, mNames+k*LENNAME1);
+return(nomretour);
+}
+
+/* --Methode-- */
+//++
+string NTuple::VarList_C(const char* nomx)  const
+//
+//	Retourne une chaine de caracteres avec la declaration des noms de 
+//	variables. si "nomx!=NULL" , des instructions d'affectation
+//	a partir d'un tableau "nomx[i]" sont ajoutees. 
+//--
+{
+string rets;
+int i;
+for(i=0; i<mNVar; i++) {
+  if ( (i%5 == 0) && (i > 0) )  rets += ";";  
+  if (i%5 == 0)   rets += "\ndouble "; 
+  else rets += ",";
+  rets += mNames+i*LENNAME1;
+  }
+rets += "; \n";
+if (nomx) { 
+  char buff[256];
+  for(i=0; i<mNVar; i++) {
+    sprintf(buff,"%s=%s[%d]; ",  mNames+i*LENNAME1, nomx, i);
+    rets += buff;
+    if ( (i%3 == 0) && (i > 0) )  rets += "\n"; 
+    }
+  }
+
+return(rets);
+}
+
+
+/* --Methode-- */
+//++
+r_4* NTuple::GetVec(int n, r_4* ret)   const
+//
+//	Retourne l'evenement `n' dans le vecteur `ret'.
+//--
+{
+int i;
+if (ret == NULL)   ret = mVar;
+if (n >= mNEnt) {
+  for(i=0; i<mNVar; i++)   ret[i] = BADVAL;
+  return(ret);
+}
+  
+int numb = n/mBlk;
+int offb = n-numb*mBlk;
+memcpy(ret, (mPtr[numb]+offb*mNVar), mNVar*sizeof(r_4));
+return(ret);
+}
+
+/* --Methode-- */
+//++
+void  NTuple::GetMinMax(int k, float& min, float& max)  const
+//
+//	Retourne le minimum et le maximum de la variable `k'.
+//--
+{
+min = 9.e19; max = -9.e19;
+if ( (k < 0) || (k >= mNVar) )    return;
+int jb,ib,i;
+float x;
+i=0;
+for(jb=0; jb< mNBlk; jb++)
+  for(ib=0; ib< mBlk; ib++) {
+    if (i >= mNEnt)  break;
+    i++;
+    x = *(mPtr[jb]+ib*mNVar+k);
+    if(i==1) {min = x; max = x;}
+    if (x < min)  min = x;
+    if (x > max)  max = x;
+  }
+return;
+}
+
+/* --Methode-- */
+//++
+DVList&  NTuple::Info()
+//
+//	Renvoie une référence sur l'objet DVList Associé
+//--
+{
+if (mInfo == NULL)  mInfo = new DVList;
+return(*mInfo);
+}
+
+/* --Methode-- */
+//++
+void  NTuple::Print(int num, int nmax)  const
+//
+//	Imprime `nmax' evenements a partir du numero `num'.
+//--
+{
+int i,j;
+
+printf("Num     ");
+for(i=0; i<mNVar; i++)  printf("%8s ", mNames+i*LENNAME1);
+putchar('\n');
+
+if (nmax <= 0)  nmax = 1;
+if (num < 0)  num = 0;
+nmax += num;
+if (nmax > mNEnt) nmax = mNEnt;
+for(i=num; i<nmax; i++) {
+  GetVec(i, NULL); 
+  printf("%6d  ", i);  
+  for(j=0; j<mNVar; j++)  printf("%8g ", (float)mVar[j]);
+  putchar('\n');
+}
+return;
+}
+
+/* --Methode-- */
+//++
+void  NTuple::Show(ostream& os)  const
+//
+//	Imprime l'information generale sur le ntuple.
+//--
+{
+os << "NTuple: NVar= " << mNVar << " NEnt=" << mNEnt  
+   << " (Blk Sz,Nb= " << mBlk << " ," << mNBlk << ")\n";
+os << "            Variables       Min      Max       \n";
+int i;
+float min, max;
+char buff[128];
+for(i=0; i<mNVar; i++) {
+  GetMinMax(i, min, max);
+  sprintf(buff, "%3d  %16s  %10g  %10g \n", i, mNames+i*LENNAME1, min, max);
+  os << (string)buff ;
+  }
+os << endl;
+}
+
+
+/* --Methode-- */
+//++
+void  NTuple::WriteSelf(POutPersist& s)  const
+//
+//	Ecriture ppersist du ntuple.
+//--
+{
+char strg[256];
+if (mInfo)  sprintf(strg, "NVar=%6d  NEnt=%9d  BlkSz=%6d NBlk=%6d  HasInfo", 
+                          (int)mNVar, (int)mNEnt, (int)mBlk, (int)mNBlk);
+else sprintf(strg, "NVar=%6d  NEnt=%9d  BlkSz=%6d NBlk=%6d ", 
+                   (int)mNVar, (int)mNEnt, (int)mBlk, (int)mNBlk);
+s.PutLine(strg);
+s.PutI4(mNVar);
+s.PutBytes(mNames, mNVar*LENNAME1);
+s.PutI4(mNEnt);
+s.PutI4(mBlk);
+s.PutI4(mNBlk);
+if (mInfo)  mInfo->Write(s);
+int jb;
+for(jb=0; jb<mNBlk; jb++)
+  s.PutR4s(mPtr[jb], mNVar*mBlk); 
+return;
+}
+
+/* --Methode-- */
+//++
+void  NTuple::ReadSelf(PInPersist& s)
+//
+//	Lecture ppersist du ntuple.
+//--
+{
+
+Clean();
+
+char strg[256];
+s.GetLine(strg, 255);
+// Pour savoir s'il y avait un DVList Info associe
+bool hadinfo = false;
+if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0)  hadinfo = true;
+
+s.GetI4(mNVar);
+mNames = new char[mNVar*LENNAME1];
+mVar = new r_4[mNVar];
+s.GetBytes(mNames, mNVar*LENNAME1);
+s.GetI4(mNEnt);
+s.GetI4(mBlk);
+s.GetI4(mNBlk);
+
+if (hadinfo) {    // Lecture eventuelle du DVList Info
+  if (mInfo == NULL)  mInfo = new DVList;
+  mInfo->Read(s);
+  }
+
+int jb; 
+for(jb=0; jb<mNBlk; jb++) {
+  r_4* pt = new r_4[mNVar*mBlk];
+  mPtr.push_back(pt);
+  s.GetR4s(mPtr[jb], mNVar*mBlk); 
+}
+
+}
Index: /tags/DPC_V0/SophyaLib/NTools/ntuple.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/ntuple.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/ntuple.h	(revision 1307)
@@ -0,0 +1,82 @@
+// Class NTuple
+//  CMV+Reza     Juillet 97
+//  CEA-DAPNIA      LAL-IN2P3/CNRS
+
+#ifndef NTUPLE_H_SEEN
+#define NTUPLE_H_SEEN
+
+#include <iostream.h>
+#include <string>
+#include <vector>
+
+#if defined(__KCC__)
+using std::string ;
+#include <vector.h>
+#endif
+
+#include "ppersist.h"
+#include "dvlist.h"
+
+
+class NTuple : public PPersist {
+public:
+  enum {classId = ClassId_NTuple };
+
+  		    NTuple(int nvar, char** noms, int blk=512);
+		    NTuple();
+		    NTuple(char* flnm);
+  virtual           ~NTuple();
+
+  void              Fill(r_4* x);
+
+  inline int_4      NEntry() { return(mNEnt); }
+  inline int_4      NVar() { return(mNVar); }
+
+  float             GetVal(int n, int k)   const;
+  inline float	    GetVal(int n, char* nom) const 
+                         { return(GetVal(n, IndexNom(nom)) ); }
+  int               IndexNom(const char* nom)  const ;
+  char*             NomIndex(int k) const;
+  string            VarList_C(const char* nomx=NULL)  const;
+
+  r_4*	            GetVec(int n, r_4* ret=NULL)  const ;
+
+  void              GetMinMax(int k, float& min, float& max)   const ; 
+  inline void       GetMinMax(const char* nom, float& min, float& max)  const 
+                         { GetMinMax(IndexNom(nom), min, max); }
+
+  void              Print(int num, int nmax=1)  const ;
+  void              Show(ostream& os) const;
+  inline void       Show() const { Show(cout); }
+
+  DVList&           Info();
+
+  int_4             ClassId() const        { return classId; }
+  static PPersist*  Create()               { return new NTuple;}
+
+  virtual void      WriteSelf(POutPersist&) const;
+  virtual void      ReadSelf(PInPersist&);
+
+
+private:
+  void  Clean();
+
+  int_4 mNVar, mNEnt, mBlk, mNBlk;
+  r_4* mVar;
+  char* mNames;
+
+  vector<r_4*> mPtr;
+
+  DVList* mInfo;        // Infos (variables) attachees au NTuple
+  
+};
+
+inline ostream& operator << (ostream& s, NTuple const & nt)
+  {  nt.Show(s);  return(s);  }
+
+#ifdef __MWERKS__
+__MSL_FIX_ITERATORS__(r_4*);
+#endif
+
+#endif
+  
Index: /tags/DPC_V0/SophyaLib/NTools/outilsinit.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/outilsinit.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/outilsinit.cc	(revision 1307)
@@ -0,0 +1,78 @@
+// Classe d'initialisation du module Outils++ 
+#include <unistd.h>
+
+#include "outilsinit.h"
+
+#include "matrix.h"
+#include "cvector.h"
+#include "poly.h"
+#include "dvlist.h"
+#include "histos.h"
+#include "histos2.h"
+#include "hisprof.h"
+#include "ntuple.h"
+#include "generaldata.h"
+
+#include "cimage.h"
+
+#include "tabmath.h"
+#include "dates.h"
+#include "datime.h"
+
+int PeidaOutilsInitiator::FgInit = 0;
+
+PeidaOutilsInitiator::PeidaOutilsInitiator()
+  : PeidaInitiator()
+{
+  FgInit++;
+  if (FgInit > 1)  return;
+
+//   Enregistrement des classes PPersist du modules Outils++
+  
+  PPRegister(Matrix);
+  PPRegister(Vector);
+  PPRegister(Poly);
+  PPRegister(Poly2);
+  PPRegister(DVList);
+  PPRegister(Histo);
+  PPRegister(Histo2D);
+  PPRegister(HProf);
+  PPRegister(NTuple);
+  PPRegister(GeneralFitData);
+
+  PPersistMgr::RegisterClass(RzImage::classId,  RzImage::Create);
+  { ImageU2 iu2;
+  PPersistMgr::RegisterClass(iu2.ClassId(),  ImageU2::Create); }
+  { ImageI2 ii2;
+  PPersistMgr::RegisterClass(ii2.ClassId(),  ImageI2::Create); }
+  { ImageI4 ii4;
+  PPersistMgr::RegisterClass(ii4.ClassId(),  ImageI4::Create); }
+  { ImageR4 ir4;
+  PPersistMgr::RegisterClass(ir4.ClassId(),  ImageR4::Create); }
+
+  //PPersistMgr::RegisterClass(Matrix::classId,  Matrix::Create);
+
+  int pnice;
+  char* snice = getenv("PEIDANICE");
+  if (!snice) pnice=8;
+  else pnice = atoi(snice);
+  nice(pnice);
+
+//  TSidSetupLaSilla();    Old-Eros
+
+  gTimeZone = new TimeZone;
+
+  ptabFExp = new TabFExp;
+
+}
+
+PeidaOutilsInitiator::~PeidaOutilsInitiator()
+{
+  FgInit--;
+}
+
+
+// On met un objet initiator en statique, pour les loaders qui savent 
+// appeler le constructeur des objets statiques   Reza 08/98
+static PeidaOutilsInitiator poutilsinit;
+
Index: /tags/DPC_V0/SophyaLib/NTools/outilsinit.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/outilsinit.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/outilsinit.h	(revision 1307)
@@ -0,0 +1,23 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe d'initialiseur du module Outils++
+
+#ifndef OUTILSINIT_H_SEEN
+#define OUTILSINIT_H_SEEN
+
+
+// Classe d''initialisation pour les modules de PEIDA++
+#include "peidainit.h"
+
+class PeidaOutilsInitiator : public PeidaInitiator {
+private:
+  static int FgInit;
+public:
+  			PeidaOutilsInitiator();
+  virtual		~PeidaOutilsInitiator();
+};
+
+#undef PeidaInit
+#define PeidaInit() PeidaOutilsInitiator peidaoutilsinitiator
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/NTools/pclassids.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/pclassids.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/pclassids.h	(revision 1307)
@@ -0,0 +1,53 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+#ifndef PEIDA_CLASS_ID_H
+#define PEIDA_CLASS_ID_H
+
+// ClassIds pour Peida. Il est possible d'en definir d'autres, mais on regroupe
+// ici toutes les classIds pour eviter des collisions.
+//
+// ClassIds pour utilisateur >= 0x4000
+//
+
+enum PeidaClassIds {
+
+//  Module Outils++
+   ClassId_Poly1    = 0x0101,
+   ClassId_Poly2    = 0x0102,
+   ClassId_Matrix   = 0x0103,
+   ClassId_Vector   = 0x0104,
+   ClassId_DVList   = 0x0105,
+
+   ClassId_PMatrixF = 0x0110,
+   ClassId_PMatrixD = 0x0111,
+   ClassId_PVectorF = 0x0112,
+   ClassId_PVectorD = 0x0113,
+
+   ClassId_Histo1D  = 0x0201,
+   ClassId_Histo2D  = 0x0202,
+   ClassId_HProf    = 0x0203,
+   ClassId_NTuple   = 0x0210,
+ 
+   ClassId_GeneralFitData  = 0x0290,
+
+//  Module Images++
+   ClassId_Image    = 0x0300,    // classId = 0x0300 + ImageType pour images types   
+   ClassId_ZFidu    = 0x0330,
+   ClassId_Voronoi  = 0x0340,
+   ClassId_RLEImage = 0x0350,
+
+//  Module StarReco++
+   ClassId_StarList = 0x0500,
+   ClassId_Transfo  = 0x0501,
+   ClassId_PSF      = 0x0510,
+   ClassId_Star     = 0x1000,     // Et ce qui suit, classId = 0x1000 + StarType
+
+//  Module Samba
+   ClassId_SphereTetaPhi  = 0x0611,
+   ClassId_SphereGorski   = 0x0612,
+   ClassId_LocalMap       = 0x0601,
+   ClassId_Scan           = 0x0631,
+   ClassId_MainLobe       = 0x0641
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/peida.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/peida.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/peida.h	(revision 1307)
@@ -0,0 +1,18 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+#ifndef PEIDA_SEEN
+#define PEIDA_SEEN
+
+#include "defs.h"
+#include "utils.h"
+#include "machine.h"
+#include "perrors.h"
+#include "exceptions.h"
+#include "fmath.h"
+
+#ifdef __mac__
+#include "unixmac.h"
+#endif
+
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/pemath.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/pemath.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/pemath.h	(revision 1307)
@@ -0,0 +1,26 @@
+/* quelques fonctions mathematiques et constantes utiles */
+/*                                         cmv  23/06/94 */
+
+#ifndef PEMATH_SEEN
+#define PEMATH_SEEN
+
+#include "machine.h"
+
+#define  Pi     (double) (3.1415926535898)    /* c'est Pi */
+#define  DeuxPi (double) (6.2831853071796)    /* c'est 2*Pi */
+#define  SPi    (double) (1.772453850906)     /* c'est sqrt(Pi) */
+#define  S2Pi   (double) (2.506628274631)     /* c'est sqrt(2*Pi) */
+#define  Rac2   (double) (1.414213562373)     /* c'est sqrt(2) */
+#define  Log2   (double) (0.301029995664)     /* c'est log10(2) */
+#define  LnPi   (double) (1.14472988585)      /* c'est ln(Pi) */
+#define  LgPi   (double) (0.497149872694)     /* c'est log10(Pi) */
+#define  Ln10   (double) (2.302585092994)     /* c'est ln(10) */
+#define  DftoDm (double) (1.085736204758)     /* c'est 2.5/ln(10) */
+#define  Hln2pi (double) 0.918938533205       /* c'est Ln(2*pi)/2 */
+#define  JourSec (float) (86400.)       /* nombre de secondes dans 24H */
+#define  AnSec  (int) (31557600)   /* nombre de secondes dans 365.25 jours */
+#define  GRAND  (float) (1.e+35)
+#define  GRAND2 (double) (1.e+35)
+#define  IGRAND (int_4) (2147483647)
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/perandom.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/perandom.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/perandom.cc	(revision 1307)
@@ -0,0 +1,215 @@
+#include "defs.h"
+#include "perandom.h"
+#include "pemath.h"
+#include <iostream.h>
+
+////////////////////////////////////////////////////////////////////////////
+//++
+// Class	FunRan
+// Lib  Outils++ 
+// include	perandom.h
+//
+//	Tirage aleatoire sur un histogramme 1D.
+//--
+
+//++
+FunRan::FunRan(FunRan::Func f, float xMin, float xMax, int nBin)
+//
+//	Createur.
+//--
+: Histo(xMin, xMax, nBin)
+{
+  (*this)(0) = f(BinLowEdge(0));
+  for(int i=1; i<nBin; i++)
+    (*this)(i) = (*this)(i-1) + f(BinLowEdge(i));
+    
+  for(int j=0; j<nBin; j++)
+    (*this)(j) /= (*this)(nBin-1);
+  END_CONSTRUCTOR
+}
+
+//++
+FunRan::FunRan(double *tab, int nBin)
+//
+//	Createur.
+//--
+: Histo(0, (float)(nBin), nBin)
+{
+  (*this)(0) = tab[0];
+  for(int i=1; i<nBin; i++)
+    (*this)(i) = (*this)(i-1) + tab[i];
+
+  if ((*this)(nBin-1) == 0) {
+    cerr << "FunRan::FunRan : sum(prob) = 0" << endl;
+    exit(-1);
+  }
+
+  for(int j=0; j<nBin; j++)
+    (*this)(j) /= (*this)(nBin-1);
+  END_CONSTRUCTOR
+}
+
+FunRan::FunRan(double *tab, int nBin, float xMin, float xMax)
+: Histo(xMin, xMax, nBin)
+{
+  (*this)(0) = tab[0];
+  for(int i=1; i<nBin; i++)
+    (*this)(i) = (*this)(i-1) + tab[i];
+
+  if ((*this)(nBin-1) == 0) {
+    cerr << "FunRan::FunRan : sum(prob) = 0" << endl;
+    exit(-1);
+  }
+
+  for(int j=0; j<nBin; j++)
+    (*this)(j) /= (*this)(nBin-1);
+  END_CONSTRUCTOR
+}
+
+//++
+int FunRan::BinRandom()
+//
+//	Tirage avec retour du numero de bin.
+//--
+{
+  double z=drand01();
+  if (z <= 0) return 0;
+  if (z >= 1) return bins-1;
+  
+  // recherche du premier bin plus grand que z
+  int iBin = 0;
+  for (; iBin<bins; iBin++)
+    if (z < (*this)(iBin)) break;
+
+  return iBin;
+}
+
+//++
+double FunRan::Random()
+//
+//	Tirage avec retour abscisse du bin interpole.
+//--
+{
+  double z=drand01();
+  if (z <= 0) return min;
+  if (z >= 1) return max;
+  // cas z <= tab[0] 
+  if (z <= (*this)(0)) {
+    double t = min + binWidth/(*this)(0) * z;
+    return t;
+  }
+
+  // recherche du premier bin plus grand que z
+  int iBin = 0;
+  for (; iBin<bins; iBin++)
+    if (z < (*this)(iBin)) break;
+
+  // interpolation pour trouver la valeur du tirage aleatoire
+  double t1 = (*this)(iBin-1);
+  double x1 = BinLowEdge(iBin-1);
+  double t2 = (*this)(iBin);
+  double x2 = x1 + binWidth;
+  double t = x1 + (x2-x1) / (t2-t1) * (z-t1);
+  if (t < min) t = min;
+  if (t > max) t = max;
+  return(t);
+}
+
+                   
+
+////////////////////////////////////////////////////////////////////////////
+//++
+// Class	FunRan2D
+// Lib  Outils++ 
+// include	perandom.h
+//
+//	Tirage aleatoire sur un histogramme 2D.
+//--
+
+//++
+FunRan2D::FunRan2D(double *tab, int nBinX, int nBinY)
+//
+//	Createur.
+//--
+{
+  // Tirage en X, somme sur les Y.
+   double* tabX = new double[nBinX];
+   for (int i=0; i<nBinX; i++) {
+     tabX[i] = 0;
+     for (int j=0; j<nBinY; j++) {
+       tabX[i] += tab[i*nBinY +j];
+     }
+   }
+   ranX = new FunRan(tabX, nBinX);
+   delete[] tabX;
+   
+   ranY = new(FunRan*[nBinX]);
+   
+   for (int k=0; k<nBinX; k++)
+      ranY[k] = new FunRan(tab + nBinY*k, nBinY);
+   
+   nx = nBinX;
+  END_CONSTRUCTOR
+}
+
+//++
+FunRan2D::FunRan2D(double **tab, int nBinX, int nBinY)
+//
+//	Createur.
+//--
+{
+  // Tirage en X, somme sur les Y.
+   double* tabX = new double[nBinX];
+   for (int i=0; i<nBinX; i++) {
+     tabX[i] = 0;
+     for (int j=0; j<nBinY; j++) {
+       tabX[i] += tab[i][j];
+     }
+   }
+   ranX = new FunRan(tabX, nBinX);
+   
+   ranY = new(FunRan*[nBinX]);
+   
+   for (int k=0; k<nBinX; k++)
+    if (tabX[k] != 0) 
+      ranY[k] = new FunRan(tab[k], nBinY);
+    else ranY[k] = NULL;
+   
+   delete[] tabX;
+   nx = nBinX;
+  END_CONSTRUCTOR
+}
+
+FunRan2D::~FunRan2D()
+{
+  for (int i=nx-1; i>=0; i--)
+    delete ranY[i];
+    
+  delete[] ranY;
+  
+  delete ranX;
+}
+
+//++
+void FunRan2D::BinRandom(int& x, int& y)
+//
+//	Tirage avec retour du numeros de bin.
+//--
+{
+  x = ranX->BinRandom();
+  FAILNIL(ranY[x]);
+  y = ranY[x]->BinRandom();
+}
+
+//++
+void FunRan2D::Random(double& x, double& y)
+//
+//	Tirage avec retour abscisse et ordonnee
+//	du bin interpole.
+//--
+{
+  x = ranX->Random();
+  int i = int(ceil(x));
+  FAILNIL(ranY[i]);
+  y = ranY[i]->Random();
+}
Index: /tags/DPC_V0/SophyaLib/NTools/perandom.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/perandom.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/perandom.h	(revision 1307)
@@ -0,0 +1,41 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+// Nombres aleatoires pour Peida.
+
+#ifndef PERANDOM_SEEN
+#define PERANDOM_SEEN
+
+#include <stdlib.h>
+#include "defs.h"
+#include "machine.h"
+#include "histos.h"
+#include "nbrandom.h"
+
+class FunRan : public Histo {
+public:
+  typedef double (*Func)(double);
+  FunRan(Func f, float xMin=0.0, float xMax=1.0, int nBin=100);
+  FunRan(double *tab, int nBin);
+  FunRan(double *tab, int nBin, float xMin, float xMax);
+  void IFunRan(double *tab, int nBin);
+  double Random(void);
+  int BinRandom(void);
+};
+
+class FunRan2D EXC_AWARE {
+public:
+//  typedef double (*Func)(double, double);
+//  FunRan2D(Func f, float xMin=0.0, float xMax=1.0, int nBinX=100,
+//                   float yMin=0.0, float yMax=1.0, int nBinY=100);
+  FunRan2D(double *tab, int nBinX, int nBinY);
+  FunRan2D(double **tab, int nBinX, int nBinY);
+  ~FunRan2D();
+  void Random(double& x, double& y);
+  void BinRandom(int& x, int& y);
+private:
+  FunRan* ranX;
+  FunRan** ranY;
+  int nx;
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/poly.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/poly.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/poly.cc	(revision 1307)
@@ -0,0 +1,1023 @@
+#include "defs.h"
+#include "poly.h"
+#include "linfit.h"
+
+//++
+// Class	Poly
+// Lib  	Outils++ 
+// include	poly.h
+//
+//	Classe de calcul sur polynômes à une variable.
+//--
+
+//++
+// Links	Parents
+// Vector
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+
+//++
+// Poly::Poly(int degre=0)
+//
+//	Crée un nouveau polynôme, en allouant de la place pour 
+//	le degré spécifié. 
+//--
+
+Poly::Poly(int degre)
+: Vector(degre+1), dirty(0), deg(0)
+{
+  END_CONSTRUCTOR
+}
+
+
+void Poly::UpdateDeg() const
+{
+  int i = nalloc-1;
+  while (data[i] == 0 && i>0) i--;
+
+  (int&) deg = i;          // bientot mutable dans ANSI C++ 
+  (int&) dirty = 0;
+}
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+// double& Poly::operator[](int i)
+//	Permet d'accéder au coefficient de degré i (avec version 
+//	const).
+//--
+
+//++
+double Poly::operator()(double x) const
+//
+//	Calcule la valeur du polynôme au point x.
+//--
+{
+  UpdateDegIfDirty();
+  double res = data[deg];
+  for (int i=deg-1; i>=0; i--) {
+    res *= x;
+    res += data[i];
+  }
+  return res;
+}
+
+//++
+void Poly::Derivate()
+//
+//	Remplace le polynôme par le polynôme dérivé.
+//--
+{
+  UpdateDegIfDirty();
+  if (deg == 0) { data[0] = 0; return;}
+  for (int i=1; i<=deg; i++)
+    data[i-1] = data[i]*i;
+  data[deg] = 0;
+  deg--;
+}
+
+
+//++
+void Poly::Derivate(Poly& der) const
+//
+//	Retourne dans der le polynôme dérivé.
+//--
+{
+  UpdateDegIfDirty();
+  der.Realloc(deg);
+//  der.Zero();    // on sait que Realloc met a zero le reste.
+  for (int i=1; i<=deg; i++)
+    der.data[i-1] = data[i]*i;
+}
+
+
+//++
+int Poly::Roots(Vector& roots) const
+//
+//	Retourne dans roots les racines réelles, si on sait
+//	les calculer. Retourne le nombre de racines.
+//--
+{
+  UpdateDegIfDirty();
+
+  switch (deg)
+    {
+    case 0 :           // degre 0
+      return 0;
+    case 1 :           // degre 1
+      roots.Realloc(1);
+      return Root1(roots(0));
+    case 2 :           // degre 2
+      roots.Realloc(2);
+      return Root2(roots(0),roots(1));
+    default :
+      THROW(parmErr);
+    }
+}
+
+
+//++
+int Poly::Root1(double& r) const
+//
+//	Seulement si le polynôme est de degré 1: retourne
+//	la racine dans "r". Retourne 1 (nombre de racines).
+//--
+{
+  UpdateDegIfDirty();
+  if (deg != 1) THROW(sizeMismatchErr);
+
+  if (data[1] == 0) return 0;
+  r = -data[0]/data[1];
+  return 1;
+}
+
+//++
+int Poly::Root2(double& r1, double& r2) const
+//
+//	Seulement si le polynôme est de degre 2: retourne
+//	les racines dans "r1" et "r2". Retourne 0, 1 ou 2
+//	(nombre de racines).
+//--
+{
+  UpdateDegIfDirty();
+  if (deg != 2) THROW(sizeMismatchErr);
+
+  double delta = data[1]*data[1] - 4*data[0]*data[2];
+  if (delta < 0) return 0;
+  if (delta == 0) {
+    r1 = r2 = -data[1]/2/data[0];
+    return 1;
+  }
+  r1 = (-data[1] - sqrt(delta))/2/data[0];
+  r2 = (-data[1] + sqrt(delta))/2/data[0];
+  return 2;
+}
+
+//++
+Poly& Poly::operator = (Poly const& a)
+//
+//	Opérateur d'affectation.
+//--
+{
+  if (this == &a) return *this;
+  Vector::operator=(a);
+
+  UpdateDeg();
+  return *this;
+}
+
+//++
+// Titres	Opérations sur polynômes
+//--
+
+//++
+Poly& Poly::operator += (Poly const& b)
+//
+//--
+{
+  UpdateDegIfDirty();
+  b.UpdateDegIfDirty();
+
+  if (b.deg > deg)
+    Realloc(b.deg);
+
+  int n = (deg > b.deg) ? deg : b.deg;
+  for (int i=0; i<=n; i++)
+    data[i] += b.data[i];
+
+  UpdateDeg();
+  return *this;
+}
+
+//++
+Poly& Poly::operator -= (Poly const& b)
+//
+//--
+{
+  UpdateDegIfDirty();
+  b.UpdateDegIfDirty();
+
+  if (b.deg > deg)
+    Realloc(b.deg);
+
+  int n = (deg > b.deg) ? deg : b.deg;
+  for (int i=0; i<=n; i++)
+    data[i] -= b.data[i];
+
+  UpdateDeg();
+  return *this;
+}
+
+
+//++
+Poly operator+ (Poly const& a, Poly const& b)
+//
+//--
+#if HAS_NAMED_RETURN
+     return c((a.deg > b.deg)?(a.deg+1):(b.deg+1))
+#endif
+{
+#if !HAS_NAMED_RETURN
+Poly c((a.deg > b.deg)?(a.deg+1):(b.deg+1));
+#endif
+  c = a;
+  c += b;
+#if !HAS_NAMED_RETURN
+return c;
+#endif
+}
+
+//++
+Poly operator- (Poly const& a, Poly const& b)
+//
+//--
+#if HAS_NAMED_RETURN
+     return c((a.deg > b.deg)?(a.deg+1):(b.deg+1))
+#endif
+{
+#if !HAS_NAMED_RETURN
+Poly c((a.deg > b.deg)?(a.deg+1):(b.deg+1));
+#endif
+  c = a;
+  c -= b;
+#if !HAS_NAMED_RETURN
+return c;
+#endif
+}
+
+//++
+Poly operator* (Poly const& a, Poly const& b)
+//
+//--
+//#if HAS_NAMED_RETURN
+//     return c(a.deg + b.deg)
+//#endif
+{
+//#if !HAS_NAMED_RETURN
+Poly c(a.deg + b.deg);
+//#endif
+  a.UpdateDegIfDirty();
+  b.UpdateDegIfDirty();
+
+  c.deg = a.deg + b.deg;
+
+  for (int i=0; i<=c.deg; i++) {
+    c[i] = 0;
+    int kmin = (i <= a.deg) ? 0 : i - a.deg;
+    int kmax = (i <= a.deg) ? i : a.deg;
+    for (int k=kmin; k<=kmax; k++)
+      c[i] += a[k] * b[i-k];
+  }
+//#if !HAS_NAMED_RETURN
+return c;
+//#endif
+}
+
+//++
+Poly& Poly::operator *= (double a)
+//
+//--
+{
+  UpdateDegIfDirty();
+
+  for (int i=0; i<=deg; i++)
+    data[i] *= a;
+
+  return *this;
+}
+
+
+//++
+Poly operator* (double a, Poly const& b)
+//
+//--
+#if HAS_NAMED_RETURN
+     return c(b)
+#endif
+{
+#if !HAS_NAMED_RETURN
+  Poly c(b);
+#endif
+
+   c *= a;
+
+#if !HAS_NAMED_RETURN
+  return c;
+#endif
+}
+
+
+void Poly::ReadSelf(PInPersist& s)
+{
+  int_4 dg;
+  s >> dg;
+  Realloc(dg, true);
+
+  #ifdef DEBUG
+  int r = nr; int c = nc;
+  #endif
+
+  Vector::ReadSelf(s);
+
+  DBASSERT(r == nr && c == nc);
+  UpdateDeg();
+
+  #ifdef DEBUG
+  DBASSERT(dg == deg);
+  #endif
+}
+
+void Poly::WriteSelf(POutPersist& s) const
+{
+  UpdateDegIfDirty();
+  ((Poly*)(this))->Realloc(deg, true);
+  s << deg;
+  Vector::WriteSelf(s);
+}
+
+//++
+void Poly::Print(ostream& s) const
+//
+//	Impresssion.
+//--
+{
+  UpdateDegIfDirty();
+  int nz=0;
+  for (int i = deg; i>=0; i--) {
+    if ((*this)[i] != 0) {
+      nz = 1;
+      if (i < deg && (*this)[i] > 0) s << "+";
+      s << (*this)[i];
+      if (i == 1) s << "*X ";
+      if (i > 1) s << "*X^" << i << " ";
+    }
+  }
+  if (!nz) s << " 0 ";
+}
+
+//++
+ostream& operator << (ostream& s, const Poly& a)
+//
+//	Impressions sur le stream "s".
+//--
+{
+  a.Print(s);
+  return s;
+}
+
+//++
+double Poly::Fit(Vector const& x, Vector const& y, int degre)
+//
+//	Ajustement polynomial par moindre carrés. Un polynôme de
+//	degré "degre" est ajusté sur les données "x" et "y", et stocké dans
+//	l'objet courant. Retourne le chi2.
+//--
+{
+  int n = x.NElts();
+  if (n != y.NElts()) THROW(sizeMismatchErr);
+
+  Realloc(degre);
+
+  Matrix a(degre+1, n);
+
+  for (int c=0; c<n; c++) {
+    double xpow = 1.0;
+    for (int l=0; l<=degre; l++) {
+      a(l,c) = xpow;
+      xpow *= x(c);
+    }
+  }
+
+  double rc = LinFit(a,y,(Vector&)*this);
+  UpdateDeg();
+  return rc;
+}
+
+//++
+double Poly::Fit(Vector const& x, Vector const& y, Vector const& erry2, int degre,
+                 Vector& errCoef)
+//
+//	Ajustement polynomial par moindre carrés. Un polynôme de
+//	degré est ajusté sur les données x et y, et stocké dans
+//	l'objet courant. erry2 contient le carre des erreurs sur y. 
+//	Retourne le chi2.
+//--
+{
+  int n = x.NElts();
+  if (n != y.NElts()) THROW(sizeMismatchErr);
+  if (n != erry2.NElts()) THROW(sizeMismatchErr);
+
+  Realloc(degre);
+  errCoef.Realloc(degre+1);
+
+  Matrix a(degre+1, n);
+
+  for (int c=0; c<n; c++) {
+    double xpow = 1.0;
+    for (int l=0; l<=degre; l++) {
+      a(l,c) = xpow;
+      xpow *= x(c);
+    }
+  }
+
+  double rc = LinFit(a,y,erry2,(Vector&)*this,errCoef);
+  UpdateDeg();
+  return rc;
+}
+
+int binomial(int n, int p)
+{
+  int c = 1;
+  for (int i=n-p+1; i<=n; i++) c *= i;
+  for (int j=2; j<=p; j++) c /= j;
+  return c;
+}
+
+
+//++
+// Poly Poly::power(int n) const
+//
+//	Retourne le polynôme à la puissance n
+//--
+
+Poly Poly::power(int n) const // a accelerer !!!
+{
+  if (n < 0) THROW(rangeCheckErr);
+  if (n == 0) { Poly r(0); r[0] = 1; return r;}
+  if (n == 1) { return *this; }
+  return *this * power(n-1);
+}
+
+//++
+Poly Poly::operator() (Poly const& b) const
+//
+//	Substitution d'un polynôme dans un autre.
+//--
+{
+  Poly c(b.Degre()*Degre());
+  for (int i=0; i<= Degre(); i++)
+    c += (*this)[i] * b.power(i);
+  return c;
+}
+
+
+// ******************* POLY 2 VARIABLES ******************
+
+//++
+// Class	Poly2
+// Lib  	Outils++ 
+// include	poly.h
+//
+//	Classe de calcul sur polynômes à deux variables.
+//--
+
+//++
+// Links	Parents
+// Vector
+//--
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+Poly2::Poly2(int degreX, int degreY)
+//
+//	Crée un polynôme de degrés partiels degreX et degreY.
+//--
+:Vector((degreX+1)*(degreY+1)), dirty(0),
+ maxDegX(degreX), maxDegY(degreY), degX(0), degY(0), deg(0)
+{
+  END_CONSTRUCTOR
+}
+
+//++
+Poly2::Poly2(Poly const& polX, Poly const& polY)
+//
+//	Crée un polynôme à deux variables comme produit
+//	de deux polynômes à une variable, p2(x,y)=px(x)py(y)
+//--
+:Vector((polX.Degre()+1)*(polY.Degre()+1)), dirty(0),
+ maxDegX(polX.Degre()), maxDegY(polY.Degre()),
+ degX(polX.Degre()), degY(polY.Degre()), deg(degX+degY)
+{
+  for (int i=0; i<=degX; i++)
+    for (int j=0; j<=degY; j++)
+      Coef(i,j) = polX[i]*polY[j];
+  END_CONSTRUCTOR
+}
+
+//++
+Poly2::Poly2(Poly2 const& a)
+//
+//	Constructeur par copie.
+//--
+:Vector(a), dirty(a.dirty),
+ maxDegX(a.maxDegX), maxDegY(a.maxDegY),
+ degX(a.degX), degY(a.degY), deg(a.deg)
+{
+  END_CONSTRUCTOR
+}
+
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+Poly2& Poly2::operator = (Poly2 const& a)
+//
+//	Opérateur d'affectation.
+//--
+{
+  if (this == &a) return *this;
+  if (maxDegX < a.DegX() || maxDegY < a.DegY())
+    Realloc(a.DegX(), a.DegY());
+
+
+  for (int i=0; i<= maxDegX; i++)
+    for (int j=0; j<= maxDegY; j++)
+      Coef(i,j) = a.Coef(i,j);
+
+  UpdateDeg();
+  return *this;
+}
+
+//++
+void Poly2::Realloc(int degreX, int degreY)
+//
+//	Redimensionne le polynôme comme etant un 
+//	polynôme de degrés partiels degreX et degreY.
+//--
+{
+  UpdateDegIfDirty();
+  Poly2 tmp(*this);
+  Vector::Realloc((degreX+1)*(degreY+1));
+  Zero();
+  maxDegX = degreX;
+  maxDegY = degreY;
+
+  for (int i=0; i<= tmp.degX; i++)
+    for (int j=0; j<= tmp.degY; j++)
+      Coef(i,j) = tmp.Coef(i,j);
+}
+
+
+void Poly2::UpdateDeg() const
+{
+  (int&)degX=(int&)degY=(int&)deg=0;
+
+  for (int dx=0; dx<=maxDegX; dx++)
+    for (int dy=0; dy<=maxDegY; dy++)
+      if (Coef(dx,dy) != 0) {
+        if (dx > degX) (int&)degX = dx;
+        if (dy > degY) (int&)degY = dy;
+        if (dx+dy > deg) (int&)deg = dx+dy;
+      }
+
+  (int&)dirty = 0;
+}
+
+//++
+// int Poly2::DegX() const
+//	Degré partiel en X.
+// int Poly2::DegY() const
+//	Degré partiel en Y
+// int Poly2::MaxDegX() const
+//	Degré partiel maximum (alloué) en X
+// int Poly2::MaxDegY() const
+//	Degré partiel maximum (alloué) en Y
+// int Poly2::Deg()  const
+//	Degré total.
+//--
+
+//++
+// double& Poly2::Coef(int dx, int dy)
+//	Retourne le coefficient de x^dx y^dy
+//	(avec aussi version const).
+//--
+
+//++
+double Poly2::operator()(double x, double y) const
+//
+//	Retourne la valeur en (x,y).
+//--
+{
+  UpdateDegIfDirty();
+  double res = 0;
+  double xPow = 1;
+  for (int dx=0; dx<=maxDegX; dx++) {
+    double yPow = 1;
+    for (int dy=0; dy<=maxDegY; dy++) {
+      res += Coef(dx,dy) * xPow * yPow;
+      yPow *= y;
+    }
+    xPow *= x;
+  }
+  return res;
+}
+
+//++
+double Poly2::Fit(Vector const& x, Vector const& y, Vector const& z,
+                  int degreX, int degreY)
+//
+//	Ajustement par moindre carrés z = P(x,y), degrés partiels imposés.
+//--
+{
+  int n = x.NElts();
+  if (n != y.NElts()) THROW(sizeMismatchErr);
+  if (n != z.NElts()) THROW(sizeMismatchErr);
+
+  Realloc(degreX, degreY);
+
+  Matrix a((degreX+1)*(degreY+1), n);
+
+  for (int c=0; c<n; c++) {
+    double xPow = 1.0;
+    for (int dx = 0; dx <= degreX; dx++) {
+      double yPow = 1.0;
+      for (int dy = 0; dy <= degreY; dy++) {
+        a(IndCoef(dx,dy), c) = xPow*yPow;
+        yPow *= y(c);
+      }
+      xPow *= x(c);
+    }
+  }
+
+  double rc = LinFit(a,z,(Vector&)*this);
+  UpdateDeg();
+  return rc;
+}
+
+
+//++
+double Poly2::Fit(Vector const& x, Vector const& y, Vector const& z,
+                  Vector const& errz2, int degreX, int degreY,
+                  Vector& errCoef)
+//
+//	Ajustement par moindre carrés z = P(x,y), degrés partiels imposés,
+//	et erreurs^2 sur z dans errz2.
+//--
+{
+  int n = x.NElts();
+  if (n != y.NElts()) THROW(sizeMismatchErr);
+  if (n != z.NElts()) THROW(sizeMismatchErr);
+  if (n != errz2.NElts()) THROW(sizeMismatchErr);
+
+  Realloc(degreX, degreY);
+  errCoef.Realloc((degreX+1)*(degreY+1));
+
+  Matrix a((degreX+1)*(degreY+1), n);
+
+  for (int c=0; c<n; c++) {
+    double xPow = 1.0;
+    for (int dx = 0; dx <= degreX; dx++) {
+      double yPow = 1.0;
+      for (int dy = 0; dy <= degreY; dy++) {
+        a(IndCoef(dx,dy), c) = xPow*yPow;
+        yPow *= y(c);
+      }
+      xPow *= x(c);
+    }
+  }
+
+  double rc = LinFit(a,z,errz2,(Vector&)*this,errCoef);
+  UpdateDeg();
+  return rc;
+}
+
+//++
+double Poly2::Fit(Vector const& x, Vector const& y, Vector const& z,
+                  int degre)
+//
+//	Ajustement par moindre carrés z = P(x,y), degré total imposé.
+//--
+{
+  int n = x.NElts();
+  if (n != y.NElts()) THROW(sizeMismatchErr);
+  if (n != z.NElts()) THROW(sizeMismatchErr);
+
+  Realloc(degre, degre);   // certains vaudront 0, impose.
+
+  Matrix a((degre+1)*(degre+2)/2, n);
+  Vector cf((degre+1)*(degre+2)/2);
+#define C_INDEX(i,j) ((i) + (j)*(2*degre+3-(j))/2)
+
+  for (int c=0; c<n; c++) {
+    double xPow = 1.0;
+    for (int dx = 0; dx <= degre; dx++) {
+      double yPow = 1.0;
+      for (int dy = 0; dy <= degre; dy++) {
+        if (dy+dx <= degre)
+          a(C_INDEX(dx,dy), c) = xPow*yPow;
+        yPow *= y(c);
+      }
+      xPow *= x(c);
+    }
+  }
+
+  double rc = LinFit(a,z,cf);
+
+  for (int dx = 0; dx <= degre; dx++)
+    for (int dy = 0; dy <= degre; dy++)
+      if (dx+dy <= degre)
+        Coef(dx,dy) = cf(C_INDEX(dx,dy));
+      else
+        Coef(dx,dy) = 0;
+
+  UpdateDeg();
+  return rc;
+}
+
+
+//++
+double Poly2::Fit(Vector const& x, Vector const& y, Vector const& z,
+                  Vector const& errz2, int degre,
+                  Vector& errCoef)
+//
+//	Ajustement par moindre carrés z = P(x,y), degré total imposé,
+//	et erreurs^2 sur z dans errz2.
+//--
+{
+  int n = x.NElts();
+  if (n != y.NElts()) THROW(sizeMismatchErr);
+  if (n != z.NElts()) THROW(sizeMismatchErr);
+  if (n != errz2.NElts()) THROW(sizeMismatchErr);
+
+  Realloc(degre, degre);
+  errCoef.Realloc((degre+1)*(degre+1));
+#define C_INDEX(i,j) ((i) + (j)*(2*degre+3-(j))/2)
+
+  Matrix a((degre+1)*(degre+2)/2, n);
+  Vector cf((degre+1)*(degre+2)/2);
+  Vector ecf((degre+1)*(degre+2)/2);
+
+  for (int c=0; c<n; c++) {
+    double xPow = 1.0;
+    for (int dx = 0; dx <= degre; dx++) {
+      double yPow = 1.0;
+      for (int dy = 0; dy <= degre; dy++) {
+        if (dy+dx <= degre)
+          a(C_INDEX(dx,dy), c) = xPow*yPow;
+        yPow *= y(c);
+      }
+      xPow *= x(c);
+    }
+  }
+
+  double rc = LinFit(a,z,errz2,cf,ecf);
+
+
+  for (int dx = 0; dx <= degre; dx++)
+    for (int dy = 0; dy <= degre; dy++)
+      if (dx+dy <= degre) {
+        Coef(dx,dy) = cf(C_INDEX(dx,dy));
+        errCoef(IndCoef(dx,dy)) = ecf(C_INDEX(dx,dy));
+      } else {
+        Coef(dx,dy) = 0;
+        errCoef(IndCoef(dx,dy)) = 0;
+      }
+  UpdateDeg();
+  return rc;
+}
+
+
+void Poly2::ReadSelf(PInPersist& s)
+{
+  int_4 dgx, dgy;
+  s >> dgx >> dgy;
+
+  Realloc(dgx, dgy);
+
+  #ifdef DEBUG
+  int r = nr; int c = nc;
+  #endif
+
+  Vector::ReadSelf(s);
+
+  DBASSERT(r == nr && c == nc);
+  UpdateDeg();
+}
+
+void Poly2::WriteSelf(POutPersist& s) const
+{
+  s << maxDegX << maxDegY;
+  Vector::WriteSelf(s);
+}
+
+//++
+void Poly2::Print(ostream& s) const
+//
+//	Impression sur stream s.
+//--
+{
+  UpdateDegIfDirty();
+  int nz=0;
+  int notfirst=0;
+  for (int dx = degX; dx>=0; dx--)
+    for (int dy= degY; dy>=0; dy--) {
+      double c = Coef(dx,dy);
+      if (c != 0) {
+        nz = 1;
+        if (notfirst && c > 0) {
+          s << "+";
+          notfirst = 1;
+        }
+        s << c << " ";
+        if (dx == 1) s << "* X ";
+        if (dx > 1) s << "* X^" << dx << " ";
+        if (dy == 1) s << "* Y ";
+        if (dy > 1) s << "* Y^" << dy << " ";
+        s << endl;
+    }
+  }
+  if (!nz) s << " 0 ";
+}
+
+//++
+ostream& operator << (ostream& s, const Poly2& a)
+//
+//	Impression sur stream s.
+//--
+{
+  a.Print(s);
+  return s;
+}
+
+
+//++
+// Titre	Opérations
+//--
+
+//++
+Poly2& Poly2::operator += (Poly2 const& b)
+//
+//--
+{
+  if (maxDegX < b.DegX() || maxDegY < b.DegY())
+    Realloc(b.DegX(),b.DegY());
+
+  UpdateDegIfDirty();
+
+  int mx = b.DegX();
+  int my = b.DegY();
+  for (int i=0; i<= mx; i++)
+    for (int j=0; j<= my; j++)
+      Coef(i,j) += b.Coef(i,j);
+
+  UpdateDeg();
+  return *this;
+}
+
+//++
+Poly2& Poly2::operator -= (Poly2 const& b)
+//
+//--
+{
+  if (maxDegX < b.DegX() || maxDegY < b.DegY())
+    Realloc(b.DegX(),b.DegY());
+
+  UpdateDegIfDirty();
+
+  int mx = b.DegX();
+  int my = b.DegY();
+  for (int i=0; i<= mx; i++)
+    for (int j=0; j<= my; j++)
+      Coef(i,j) -= b.Coef(i,j);
+
+  UpdateDeg();
+  return *this;
+}
+
+//++
+Poly2 operator+ (Poly2 const& a, Poly2 const& b)
+//
+//--
+#if HAS_NAMED_RETURN
+     return c(a)
+#endif
+{
+#if !HAS_NAMED_RETURN
+Poly2 c(a);
+#endif
+  c += b;
+#if !HAS_NAMED_RETURN
+return c;
+#endif
+}
+
+//++
+Poly2 operator- (Poly2 const& a, Poly2 const& b)
+//
+//--
+#if HAS_NAMED_RETURN
+     return c(a)
+#endif
+{
+#if !HAS_NAMED_RETURN
+Poly2 c(a);
+#endif
+  c -= b;
+#if !HAS_NAMED_RETURN
+return c;
+#endif
+}
+
+//++
+Poly2& Poly2::operator *= (double a)
+//
+//--
+{
+  for (int i=0; i<NElts(); i++)
+    data[i] *= a;
+
+  return *this;
+}
+
+//++
+Poly2 operator * (double a, Poly2 const& b)
+//
+//--
+#if HAS_NAMED_RETURN
+     return c(b)
+#endif
+{
+#if !HAS_NAMED_RETURN
+Poly2 c(b);
+#endif
+  c *= a;
+#if !HAS_NAMED_RETURN
+return c;
+#endif
+}
+
+//++
+Poly2 operator* (Poly2 const& a, Poly2 const& b)
+//
+//--
+{
+  Poly2 c(a.DegX() + b.DegX(), a.DegY() + b.DegY());
+  a.UpdateDegIfDirty();
+  b.UpdateDegIfDirty();
+
+  for (int i=0; i<=a.DegX(); i++)
+    for (int j=0; j<=a.DegY(); j++)
+      for (int k=0; k<=b.DegX(); k++)
+        for (int l=0; l<=b.DegY(); l++)
+          c.Coef(i+k,j+l) += a.Coef(i,j)*b.Coef(k,l);
+  return c;
+}
+
+//++
+Poly2 Poly2::power(int n) const
+//
+//	Calcule le polynôme P(x,y)^n
+//--
+{
+  if (n < 0) THROW(rangeCheckErr);
+  if (n == 0) { Poly2 r(0); r.Coef(0,0) = 1; return r;}
+  if (n == 1) { return *this; }
+  return *this * power(n-1);
+}
+
+
+//++
+Poly2 Poly2::operator() (Poly const& a, Poly const& b) const
+//
+//	Substitution de deux polynômes en X et Y,
+//	P2(pa(x), pb(y)).
+//--
+{
+  UpdateDegIfDirty();
+  Poly2 c(maxDegX*a.Degre(), maxDegY*b.Degre());
+
+  for (int i=0; i<= degX; i++)
+    for (int j=0; j<= degY; j++) {
+      Poly2 d(a.power(i), b.power(j));
+      c += Coef(i,j) * d;
+    }
+
+  return c;
+}
+
+//++
+Poly2 Poly::operator() (Poly2 const& a) const
+//
+//	Substitution d'un polynôme à deux variables dans
+//	un polynôme à une variable, P(P2(x,y)).
+//--
+{
+  Poly2 c(a.MaxDegX()*Degre(), a.MaxDegY()*Degre());
+
+  for (int i=0; i<= Degre(); i++)
+    c += (*this)[i] * a.power(i);
+  return c;
+}
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/poly.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/poly.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/poly.h	(revision 1307)
@@ -0,0 +1,184 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// $Id: poly.h,v 1.1.1.1 1999-04-09 17:57:58 ansari Exp $
+//
+
+
+// Des polynomes avec des operations de bases et surtout des fits.
+
+#ifndef POLY_SEEN
+#define POLY_SEEN
+
+#include <stdio.h>
+#include "peida.h"
+#include "cvector.h"
+
+class Poly2;
+
+class Poly : public Vector {
+public:
+  Poly(int degre = 0);
+
+  enum {classId = ClassId_Poly1};
+  int_4                 ClassId() const         { return classId; }
+  static PPersist*      Create() {return new Poly;}
+
+  inline int Degre() const {UpdateDegIfDirty(); return deg;}
+
+  inline void Realloc(int n, bool force=false) {Vector::Realloc(n+1,force);}
+
+  inline double operator[](int i) const {return data[i];}
+  inline double& operator[](int i) {dirty = 1; return data[i];}
+  // Retourne le coefficient de degre i
+
+  double operator()(double x) const;
+  // Retourne la valeur prise en x.
+
+  void   Derivate();
+  // Derive le polynome en place
+
+  void   Derivate(Poly& der) const;
+  // Derive le polynome dans un autre
+
+  int    Roots(Vector& roots) const;
+  // retourne les racines si on peut les calculer...
+
+  int    Root1(double& r) const;
+  // special degre 1
+
+  int    Root2(double& r1, double& r2) const;
+  // special degre 2
+
+  friend Poly operator* (Poly const& a, Poly const& b);
+  friend Poly operator+ (Poly const& a, Poly const& b);
+  friend Poly operator- (Poly const& a, Poly const& b);
+
+  Poly& operator = (Poly const& b);
+  Poly& operator += (Poly const& b);
+  Poly& operator -= (Poly const& b);
+
+  friend Poly operator* (double a, Poly const& b);
+
+  Poly& operator *= (double a);
+
+  Poly power(int n) const;
+  Poly operator() (Poly const& b) const;
+  Poly2 operator() (Poly2 const& b) const;
+
+  void ReadSelf(PInPersist&);
+  void WriteSelf(POutPersist&) const;
+
+  void Print(ostream& s) const;
+  friend ostream& operator << (ostream& s, const Poly& a);
+
+  double Fit(Vector const& x, Vector const& y, int degre);
+  // Fit d'un polynome de degre donne sur les x et y.
+
+  double Fit(Vector const& x, Vector const& y, Vector const& erry2, int degre,
+            Vector& errCoef);
+  // En plus, on fournit les carres des erreurs sur y et on a les erreurs
+  // sur les coefficients dans un vecteur.
+
+private:
+  int dirty;
+  int_4 deg;
+  void UpdateDeg() const;
+  void UpdateDegIfDirty() const {if (dirty) UpdateDeg();}
+};
+
+int binomial(int n, int p);
+
+
+class Poly2 : public Vector {  // Ca pourrait etre une matrice mais
+                                  // la encore, un vecteur est utile pour les
+                                  // fits.
+
+public:
+  Poly2(int degreX=0, int degreY=0);
+  // degres alloues.
+  Poly2(Poly const& polX, Poly const& polY);
+  Poly2(Poly2 const& a);
+
+  enum {classId = ClassId_Poly2};
+  int_4                 ClassId() const         { return classId; }
+  static PPersist*      Create() {return new Poly2;}
+
+  inline int DegX() const {UpdateDegIfDirty(); return degX;}
+  inline int DegY() const {UpdateDegIfDirty(); return degY;}
+  inline int MaxDegX() const {return maxDegX;}
+  inline int MaxDegY() const {return maxDegY;}
+  inline int Deg()  const {UpdateDegIfDirty(); return deg;}
+  // les degres partiels en x et y, et totaux.
+
+  double operator()(double x, double y) const;
+  // retourne la valeur en (x,y)
+
+  inline int IndCoef(int dx, int dy) const {
+    if (dx>maxDegX || dy>maxDegY) THROW(rangeCheckErr);
+    return dx + (maxDegX+1)*dy;
+  }
+  // l'indice du coefficient dans le vecteur. Public uniquement parce
+  // que ca sert a recuperer les erreurs sur les coefficients lors
+  // d'un fit...
+
+  inline double Coef(int dx, int dy) const {
+    return (dx>maxDegX || dy>maxDegY) ? 0 : data[IndCoef(dx,dy)];
+  }
+  inline double& Coef(int dx, int dy) {
+    if (dx>maxDegX || dy>maxDegY) THROW(rangeCheckErr);
+    dirty = 1; return data[IndCoef(dx,dy)];
+  }
+  // retourne le coefficient de degre (dx,dy)
+
+  double Fit(Vector const& x, Vector const& y, Vector const& z,
+             int degreX, int degreY);
+  double Fit(Vector const& x, Vector const& y, Vector const& z,
+             Vector const& errz2, int degreX, int degreY,
+             Vector& errCoef);
+  // degres partiels imposes. cf Poly::Fit sinon
+
+
+  double Fit(Vector const& x, Vector const& y, Vector const& z,
+             int degre);
+  double Fit(Vector const& x, Vector const& y, Vector const& z,
+             Vector const& errz2, int degre,
+             Vector& errCoef);
+  // degre total impose. cf Poly::Fit sinon
+
+  Poly2& operator = (Poly2 const& b);
+
+  Poly2& operator += (Poly2 const& b);
+  Poly2& operator -= (Poly2 const& b);
+
+  friend Poly2 operator + (Poly2 const& a, Poly2 const& b);
+  friend Poly2 operator - (Poly2 const& a, Poly2 const& b);
+  friend Poly2 operator * (Poly2 const& a, Poly2 const& b);
+
+  Poly2 power(int n) const;
+
+  Poly2& operator *= (double a);
+  friend Poly2 operator * (double a, Poly2 const& b);
+
+  Poly2 operator() (Poly const& px, Poly const& py) const;
+//  Poly2 operator() (Poly2 const& px, Poly2 const& py) const;
+
+  void Realloc(int degreX, int degreY);
+
+  void ReadSelf(PInPersist&);
+  void WriteSelf(POutPersist&) const;
+
+  void Print(ostream& s) const;
+  friend ostream& operator << (ostream& s, const Poly2& a);
+
+private:
+  int dirty;
+  int_4 maxDegX;
+  int_4 maxDegY;
+  int degX;
+  int degY;
+  int deg;
+  void UpdateDeg() const;
+  void UpdateDegIfDirty() const {if (dirty) UpdateDeg();}
+};
+
+#endif // POLY_SEEN
Index: /tags/DPC_V0/SophyaLib/NTools/pversion.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/pversion.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/pversion.cc	(revision 1307)
@@ -0,0 +1,35 @@
+#include "pversion.h"
+#include "peidainit.h"
+#include <stdio.h>
+
+
+void PrintPeidaVersion(void)
+{
+  char* compiler;
+  #ifdef __GNUG__
+  compiler = "gcc " __VERSION__;
+  #endif
+  #ifdef __xlC
+  compiler = "xlC " ;
+  #endif
+  #ifdef __DECCXX
+  compiler = "cxx " ;
+  #endif
+  #ifdef __aCC__ 
+  compiler = const_cast<char *>("HP-aCC ") ;
+  #endif
+  #ifdef __KCC__ 
+  compiler = const_cast<char *>("KCC ") ;
+  #endif
+  
+
+  fprintf(stderr,"PEIDA_PLANCK Version %4.1f Revision %d (%s) -- %s %s %s\n",
+	  PEIDA_VERSION, PEIDA_REVISION, PEIDA_TAG, 
+	  __DATE__, __TIME__, compiler);
+}
+
+double PeidaVersion(void)
+{
+  return PEIDA_VERSION + (PEIDA_REVISION/1000.);
+}
+
Index: /tags/DPC_V0/SophyaLib/NTools/pversion.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/pversion.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/pversion.h	(revision 1307)
@@ -0,0 +1,8 @@
+#ifndef PVERSION_H
+#define PVERSION_H
+
+#define PEIDA_VERSION   4.0
+#define PEIDA_REVISION  1
+#define PEIDA_TAG       "V_Avr99"
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/rk4cdifeq.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/rk4cdifeq.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/rk4cdifeq.cc	(revision 1307)
@@ -0,0 +1,193 @@
+#include "defs.h"
+#include "rk4cdifeq.h"
+#include "ctimer.h"
+#include <iostream.h>
+
+inline double max_dbl(double a, double b) { return ((a < b) ? b : a); } 
+
+//++
+// Class	RK4CDiffEq
+// Lib  	Outils++ 
+// include	rk4cdifeq.h
+//
+//	Classe de résolution d'équadif par la méthode de
+//	Runge-Kutta d'ordre 4 adaptatif.
+//	Voir DiffEqSolver et R4KDiffEq pour les méthodes.
+//
+//	On peut demander une précision relative ou absolue
+//	sur chacune des fonctions du système. Le pas d'intégration
+//	est adapté automatiquement pour fournir au moins 
+//	cette précision.
+//--
+
+//++
+// Links	Parents
+// RK4DiffEq
+// DiffEqSolver
+//--
+
+//++
+// Titre	Constructeurs
+//	Voir RK4DiffEq et DiffEqSolver
+//--
+
+//++
+RK4CDiffEq::RK4CDiffEq()
+//
+//--
+: RK4DiffEq(), eps(1.e-4), relAccuracy(true), accScale(10), yTemp(10), ySave(10)
+{}
+
+//++
+RK4CDiffEq::RK4CDiffEq(DiffEqFunction* f)
+//
+//--
+: RK4DiffEq(f), eps(1.e-4), relAccuracy(true), accScale(f->NFuncReal()), yTemp(f->NFuncReal()), ySave(f->NFuncReal())
+{}
+
+//++
+RK4CDiffEq::RK4CDiffEq(DIFEQFCN1 f)
+//
+//--
+: RK4DiffEq(f), eps(1.e-4), relAccuracy(true), accScale(1), yTemp(1), ySave(1)
+{}
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+// RK4CDiffEq& RK4CDiffEq::Accuracy(double eps)
+//	Fixe la précision requise sur les fonctions. Cette précision
+//	est par défaut relative. Elle peut être absolue, auquel cas
+//	il faut fixer, pour chaque fonction, un facteur d'échelle, et
+//	la précision sur chaque fonction est alors scale[i]*eps.
+//--
+
+RK4CDiffEq& 
+RK4CDiffEq::Accuracy(double x)
+{
+  eps = x;
+  return *this;
+}
+
+//++
+RK4CDiffEq&  
+RK4CDiffEq::AbsAccuracy(Vector const& vScal)
+//
+//	On souhaite une précision absolue, et le vecteur vScal contient
+//	le facteur d'échelle pour chaque fonction (voir Accuracy).
+//--
+{
+  accScale = vScal;
+  relAccuracy = false;
+  return *this;
+}
+
+//++
+RK4CDiffEq&  
+RK4CDiffEq::AbsAccuracy(double scal)
+//
+//	On souhaite une précision absolue, et le vecteur scal contient
+//	le facteur d'échelle à appliquer à toutes les fonctions.
+//	La précision absolue souhaitée est alors eps*scal.
+//--
+{
+  for (int i=0; i<accScale.NElts(); i++)
+    accScale(i) = scal;
+  relAccuracy = false;
+  return *this;
+}
+
+//++
+RK4CDiffEq&  
+RK4CDiffEq::RelAccuracy()
+//
+//	On souhaite une précision relative. En quelque sorte, le facteur d'échelle 
+//	pour chaque fonction est alors la valeur de la fonction.
+//--
+{
+  relAccuracy = true;
+  return *this;
+}
+
+static const double pgrow   = -0.20;
+static const double pshrink = -0.25;
+static const double safety  = 0.9;
+static const double errcon = pow((4/safety),1/pgrow);
+
+void
+RK4CDiffEq::RKCStep(Vector& newY, Vector const& y0, Vector const& yScale, 
+	       double dttry, double& dtdone, double& dtnext)
+{
+  double err;
+  ySave = y0;
+  do {
+    // Deux petits pas
+    RKStep(yTemp, ySave, dttry/2.);
+    RKStep(newY, yTemp, dttry/2.);
+    
+    // Un grand pas
+    RKStep(yTemp, ySave, dttry);
+    
+    yTemp -= newY;   // l'erreur courante
+
+    err = 0;
+    for (int i=0; i<yTemp.NElts(); i++) 
+      err = max_dbl(fabs(yScale(i) ? (yTemp(i)/yScale(i)) : yTemp(i)), err);
+    
+    err /= eps;
+    if (err > 1) 
+      dttry *= safety*pow(err,pshrink);
+    else {
+      dtdone = dttry;
+      if (err > errcon)
+	dtnext = safety*dttry*pow(err,pgrow);
+      else
+	dtnext = dttry*4;
+    }
+  }  while (err > 1);
+  
+  // Et on corrige a l'ordre 5
+
+  newY += yTemp/15;
+}
+
+void
+RK4CDiffEq::SolveArr(Matrix& y, double* t, double tf, int n)
+{
+  //TIMEF;
+  // Les intervalles a stocker dans la matrice des resultats
+
+  double dxres = (tf - mXStart)/n;
+
+  Vector yt = mYStart;
+  
+  k1.Realloc(mFunc->NFuncReal());
+  k2.Realloc(mFunc->NFuncReal());
+  k3.Realloc(mFunc->NFuncReal());
+  k4.Realloc(mFunc->NFuncReal());
+  yTemp.Realloc(mFunc->NFuncReal());
+  ySave.Realloc(mFunc->NFuncReal());
+
+  double x = mXStart;
+  double step = mStep;
+  double nstep;
+
+  for (int i=0; i<n; i++) {
+    double xEndStep = (i+1)*dxres + mXStart;
+    do {
+      if (relAccuracy) accScale = yt;
+      if ((x+step-xEndStep)*(x+step-mXStart)>0) step = xEndStep-x;
+      RKCStep(yt, yt, accScale, step, step, nstep);
+      x += step;
+      //cout << x << " " << step << endl;
+      step = nstep;
+    } while ((x-xEndStep)*(x-mXStart) < 0);
+    for (int j=0; j<mFunc->NFunc(); j++)
+      y(i,j) = yt(j);
+    t[i] = xEndStep;
+    //cout << "fin boucle "<<i<<"  "<<x<<"  "<<yt(0)<<endl;
+  }
+   
+}
Index: /tags/DPC_V0/SophyaLib/NTools/rk4cdifeq.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/rk4cdifeq.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/rk4cdifeq.h	(revision 1307)
@@ -0,0 +1,42 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef RK4CDIFEQ_H_SEEN
+#define RK4CDIFEQ_H_SEEN
+
+#include "difeq.h"
+
+// <summary> Runge-Kutta ordre 4 adaptatif </summary>
+// Runge-Kutta ordre 4 adaptatif, avec correction du pas d'integration
+class RK4CDiffEq : public RK4DiffEq {
+public:
+  // Constructeurs. Voir <linkto class=DiffEqSolver>DiffEqSolver</linkto>
+  // <group>
+  RK4CDiffEq();
+  RK4CDiffEq(DiffEqFunction*);
+  RK4CDiffEq(DIFEQFCN1);
+  // </group>
+
+  // Precision souhaitee, en absolu ou relatif, independamment pour chaque
+  // fonction ou globalement
+  // <group>
+  RK4CDiffEq& Accuracy(double);
+  RK4CDiffEq& AbsAccuracy(Vector const& vScal);
+  RK4CDiffEq& AbsAccuracy(double scal);
+  RK4CDiffEq& RelAccuracy();
+  // </group>
+  
+  // Implementation RK4 adaptatif
+  virtual void SolveArr(Matrix& y, double* t, double tf, int n);
+
+protected:
+  // Un pas adaptatif
+  void RKCStep(Vector& newY, Vector const& y0, Vector const& yScale, 
+	       double dttry, double& dtdone, double& dtnext);
+
+  double eps;
+  bool   relAccuracy;
+  Vector accScale;
+  Vector yTemp; // Pour ne pas reallouer
+  Vector ySave;
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/rzimage.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/rzimage.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/rzimage.cc	(revision 1307)
@@ -0,0 +1,902 @@
+//  Classe image generique      
+//                  E.Aubourg , E. Lesquoy  01-03/95 
+//                  Modifs R. Ansari   04/95
+
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+//  $Id: rzimage.cc,v 1.1.1.1 1999-04-09 17:57:57 ansari Exp $
+
+#include "defs.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "rzimage.h"
+#include "dvlist.h"
+#include "generalfit.h"
+
+
+/* .........  Methodes de la classe  RzVect    .........   */
+//++
+// Class 	RzVect<T>
+// Lib 		Images++
+// include	rzvect.h
+//
+//	Cette classe permet de construire des vecteurs de types T 
+//	"(short, int, float, double, ...)". Cette classe est utilisee
+//	par la classe *RzImage*.
+//--
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// RzVect<T>(int n)
+//	Constructeur avec allocation d'espace pour "n" elements
+//	"RzVect<uint_1>, RzVect<uint_2>, RzVect<int_2>, RzVect<int_4>"
+//	" RzVect<r_4>, RzVect<r_8>"
+// RzVect<T>(int n, T* data)
+//	Constructeur avec specification du tableau de stockage des elements
+//	*Attention* "data" doit etre alloue a la bonne taille ("n")
+// ~RzVect<T>()
+//	Destructeur - Libere l'espace de stockage des elements si l'objet a
+//	ete construit par le premier constructeur
+//	
+//--
+
+/* --Methode-- */
+template <class T>
+RzVect<T>::RzVect(int n)
+: p(new T[n]), nElt(n), nImgRef(1), shareable(1), ownTable(1)
+{END_CONSTRUCTOR}
+
+/* --Methode-- */
+template <class T>
+RzVect<T>::RzVect(int n, T* data)
+: p(data), nElt(n), nImgRef(0), shareable(0), ownTable(0)
+{END_CONSTRUCTOR}
+
+
+/* --Methode-- */
+template <class T>
+RzVect<T>::~RzVect()
+{
+  if (ownTable) delete[] p;
+  #ifdef DEBUG
+  p = (T*) -1;
+  #endif
+}
+
+//++
+// Titre	Acces aux elements
+//--
+//++
+// T& operator[](int i)
+//	Acces a l'element "i" (lecture/ecriture)
+// int  IElem(int k)
+//      Valeur converti en entier "(int)" de l'element "k" (lecture)
+// float  FElem(int k)
+//      Valeur converti en reel "(float)" de l'element "k" (lecture)
+// double  DElem(int k)
+//      Valeur converti en reel "(double)" de l'element "k" (lecture)
+//--
+
+/* ..............   Classe  RzImage    ...............   */
+
+//++
+// Class 	RzImage
+// Lib 		Images++
+// include	rzimage.h
+//
+//	Cette classe permet de gerer les donnees correspondantes a une image.
+//	Une image est un tableau rectangulaire de valeurs de pixels.
+//	*RzImage* offre la possibilite de creer des images de valeurs de
+//	pixels entier ou flottant "(unsigned char uint_1, short int_2," 
+//	"unsigned short uint_2, int int_4, float r_4, double r_8)"
+//	les objets de la classe RzImage sont faiblement types. La classe
+//      *Image<T>* qui derive de RzImage permet la creation d'objets
+//	types. Chaque image peut contenir un objet *DVList* permettant 
+//	a l'utilisateur d'associer un ensemble de valeurs a l'image. 
+//--
+//++
+// Links	Parents
+// PPersist
+//--
+//++
+// Links	Descendants
+// Image<T>
+// FitsImage<T>
+//--
+//++
+// Links	Voir aussi
+// DVList
+//--
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// RzImage()
+//	Creation d'une image vide, non typee.
+// RzImage(PBaseDataTypes dType, int sizx, int sizy, -
+//         int imgId = 0, char const * imgName = 0)
+//	Creation d'une image de taille "sizx * sizy" pixels , de type "dType".
+//      (dType = kuint_1, kuint_2, kint_2, kint_4, kr_4, kr_8).
+//      "imgId" et "imgName" permettent d'indiquer une identification optionnelle.
+// RzImage(const RzImage&, int sharePixels=0)
+//	Constructeur par copie. Permet de partager le tableau des pixels (RzVect)
+//	si "sharePixels" non nul (<> 0)
+// RzImage(char *flnm)
+//	Les RzImage etant des objets persistants (*PPersist*), ils peuvent etre
+//	instancies a partir d'un fichier (nom = "flnm") ecrit par la methode Write()
+// ~RzImage()
+//	Destructeur. 
+//  operator= (RzImage const &)
+//	Copie les valeurs de pixels d'une image a l'autre.
+//	Si la 1ere image a son propre tableau de pixel, il faut que 
+//	les deux images aient le meme type de pixels et la meme taille.
+//	Sinon, une exception ("typeMismatchErr" ou "sizeMismatchErr") est 
+//	generee.  
+//--
+
+/* --Methode-- */
+RzImage::RzImage(PBaseDataTypes dType)
+: dataType(dType)
+{
+  voidP = NULL;
+  isFits = 0;
+  siz_x = siz_y = 0;
+  vect.u2 = 0;
+  mInfo = NULL;
+  SetNameId(0, "");
+  SetOrg(0, 0);
+  SetPxSize();
+  SetAtt();
+  END_CONSTRUCTOR
+}
+
+/* --Methode-- */
+RzImage::RzImage(PBaseDataTypes dType, int sizx, int sizy, int imgId, char const* imgName)
+: dataType(dType)
+{
+  isFits = 0;
+  siz_x = siz_y = 0;
+  vect.u2 = 0;
+  voidP = NULL;
+  mInfo = NULL;
+  Allocate(dType, sizx, sizy);
+  SetNameId(imgId, imgName);
+  SetOrg(0, 0);
+  SetPxSize();
+  SetAtt();
+  END_CONSTRUCTOR
+}
+
+/* --Methode-- */
+RzImage::RzImage(const RzImage& src, int sharePixels)
+: dataType(kpbdt_unknown)
+{
+  isFits = 0;
+  siz_x = siz_y = 0;
+  vect.u2 = 0;
+  voidP = NULL;
+  mInfo = NULL;
+  if (sharePixels) {
+    ImgVectP vs = src.vect;
+    Allocate(src.PixelType(), src.XSize(), src.YSize(), &vs); 
+  }
+  else { 
+    Allocate(src.PixelType(), src.XSize(), src.YSize(), NULL);
+    memcpy(voidP, src.voidP, siz_x*siz_y*DataSize(dataType)); 
+  }
+
+  SetNameId(src.id, src.name);
+  SetOrg(src.XOrg(), src.YOrg());
+  SetPxSize(src.XPxSize(), src.YPxSize());    
+  SetAtt(src.nbNul, src.nbSat,
+       src.minPix, src.maxPix, src.moyPix, src.sigPix,
+       src.fond, src.sigmaFond);
+  END_CONSTRUCTOR
+}
+
+/* --Methode-- */
+RzImage::RzImage(char *flnm)
+: dataType(kpbdt_unknown)
+{
+  isFits = 0;
+  vect.u2 = 0;
+  voidP = NULL;
+  mInfo = NULL;
+  PInPersist s(flnm);
+  Read(s);
+  END_CONSTRUCTOR
+}
+
+/* --Methode-- */
+RzImage::~RzImage()
+{
+if (mInfo) delete mInfo;
+DeAllocPixels();
+}
+
+/* --Methode-- */
+RzImage& RzImage::operator = (const RzImage& src)
+{
+
+if (PixelType() >= 0)
+  {
+  if (src.PixelType() != PixelType())
+    THROW(typeMismatchErr);
+  if (siz_x != src.siz_x || siz_y != src.siz_y) 
+    THROW(sizeMismatchErr);
+  } 
+else  Allocate(src.PixelType(), src.siz_x, src.siz_y);
+  
+memcpy(voidP, src.voidP, siz_x*siz_y*DataSize(dataType));
+SetNameId(src.id, src.name);
+SetOrg(src.XOrg(), src.YOrg());
+SetPxSize(src.XPxSize(), src.YPxSize());    
+SetAtt(src.nbNul, src.nbSat,
+       src.minPix, src.maxPix, src.moyPix, src.sigPix,
+       src.fond, src.sigmaFond);
+ 
+return(*this); 
+}
+
+/* --Methode-- */
+void RzImage::Allocate(PBaseDataTypes dType, int sizx, int sizy, ImgVectP* pvpsh)
+// ATTENTION : Si pvpsh non nul, on partage les pixels 
+{
+  DeAllocPixels(); // EA 090998 -- memory leak...
+  siz_x = sizx;
+  siz_y = sizy;
+  if ((int)dataType<=0)  dataType = dType; // Sinon ERREUR. Exception?
+  switch (dataType) {
+  case kuint_1:
+    vect.u1 = NULL;
+    if (pvpsh)
+      if (pvpsh->u1)  
+        { ASSERT(pvpsh->u1->Shareable());
+        vect.u1 = pvpsh->u1;  vect.u1->NImgRef()++; }
+    if (!vect.u1)  vect.u1 = new RzVect<uint_1> (siz_x * siz_y);
+    voidP   = vect.u1->p;
+    IVal_p = &RzImage::IVal_u1;
+    FVal_p = &RzImage::FVal_u1;
+    DVal_p = &RzImage::DVal_u1;
+    break;
+  case kuint_2:
+    vect.u2 = NULL;
+    if (pvpsh)
+      if (pvpsh->u2)  
+        { ASSERT(pvpsh->u2->Shareable());
+        vect.u2 = pvpsh->u2;  vect.u2->NImgRef()++; }
+    if (!vect.u2)  vect.u2 = new RzVect<uint_2> (siz_x * siz_y);
+    voidP   = vect.u2->p;
+    IVal_p = &RzImage::IVal_u2;
+    FVal_p = &RzImage::FVal_u2;
+    DVal_p = &RzImage::DVal_u2;
+    break;
+  case kint_2:
+    vect.i2 = NULL;
+    if (pvpsh)
+      if (pvpsh->i2)  
+        { ASSERT(pvpsh->i2->Shareable());
+        vect.i2 = pvpsh->i2;  vect.i2->NImgRef()++; }
+    if (!vect.i2)  vect.i2 = new RzVect<int_2> (siz_x * siz_y);
+    voidP   = vect.i2->p;
+    IVal_p = &RzImage::IVal_i2;
+    FVal_p = &RzImage::FVal_i2;
+    DVal_p = &RzImage::DVal_i2;
+    break;
+  case kint_4:
+    vect.i4 = NULL;
+    if (pvpsh)
+      if (pvpsh->i4)  
+        { ASSERT(pvpsh->i4->Shareable());
+        vect.i4 = pvpsh->i4;  vect.i4->NImgRef()++; }
+    if (!vect.i4)  vect.i4 = new RzVect<int_4> (siz_x * siz_y);
+    voidP   = vect.i4->p;
+    IVal_p = &RzImage::IVal_i4;
+    FVal_p = &RzImage::FVal_i4;
+    DVal_p = &RzImage::DVal_i4;
+    break;
+  case kr_4:
+    vect.r4 = NULL;
+    if (pvpsh)
+      if (pvpsh->r4)  
+        { ASSERT(pvpsh->r4->Shareable());
+        vect.r4 = pvpsh->r4;  vect.r4->NImgRef()++; }
+    if (!vect.r4)  vect.r4 = new RzVect<r_4> (siz_x * siz_y);
+    voidP   = vect.r4->p;
+    IVal_p = &RzImage::IVal_r4;
+    FVal_p = &RzImage::FVal_r4;
+    DVal_p = &RzImage::DVal_r4;
+    break;
+  case kr_8:
+    vect.r8 = NULL;
+    if (pvpsh)
+      if (pvpsh->r8)  
+        { ASSERT(pvpsh->r8->Shareable());
+        vect.r8 = pvpsh->r8;  vect.r8->NImgRef()++; }
+    if (!vect.r8)  vect.r8 = new RzVect<r_8> (siz_x * siz_y);
+    voidP   = vect.r8->p;
+    IVal_p = &RzImage::IVal_r8;
+    FVal_p = &RzImage::FVal_r8;
+    DVal_p = &RzImage::DVal_r8;
+    break;
+  default:
+    printf("RzImage::Allocate Error - Unsupported DataType= %d \n", (int)dataType);
+    break;    
+  } 
+}
+
+/* --Methode-- */
+void RzImage::SetPixels(PBaseDataTypes dType, int sizx, int sizy, void* data)
+{
+  if (voidP != data)  DeAllocPixels();
+  siz_x = sizx;
+  siz_y = sizy;
+  //  if (dataType<0) (int&) dataType = (int)dType; // Sinon ERREUR. Exception?
+  if (dataType<0)  dataType = dType; // Sinon ERREUR. Exception?
+  switch (dataType) {
+  case kuint_1:
+    vect.u1 = new RzVect<uint_1> (siz_x * siz_y, (uint_1*)data);
+    voidP   = vect.u1->p;
+    IVal_p = &RzImage::IVal_u1;
+    FVal_p = &RzImage::FVal_u1;
+    DVal_p = &RzImage::DVal_u1;
+    break;
+  case kuint_2:
+    vect.u2 = new RzVect<uint_2> (siz_x * siz_y, (uint_2*)data);
+    voidP   = vect.u2->p;
+    IVal_p = &RzImage::IVal_u2;
+    FVal_p = &RzImage::FVal_u2;
+    DVal_p = &RzImage::DVal_u2;
+    break;
+  case kint_2:
+    vect.i2 = new RzVect<int_2> (siz_x * siz_y, (int_2*)data);
+    voidP   = vect.i2->p;
+    IVal_p = &RzImage::IVal_i2;
+    FVal_p = &RzImage::FVal_i2;
+    DVal_p = &RzImage::DVal_i2;
+    break;
+  case kint_4:
+    vect.i4 = new RzVect<int_4> (siz_x * siz_y, (int_4*)data);
+    voidP   = vect.i4->p;
+    IVal_p = &RzImage::IVal_i4;
+    FVal_p = &RzImage::FVal_i4;
+    DVal_p = &RzImage::DVal_i4;
+    break;
+  case kr_4:
+    vect.r4 = new RzVect<r_4> (siz_x * siz_y, (r_4*)data);
+    voidP   = vect.r4->p;
+    IVal_p = &RzImage::IVal_r4;
+    FVal_p = &RzImage::FVal_r4;
+    DVal_p = &RzImage::DVal_r4;
+    break;
+  case kr_8:
+    vect.r8 = new RzVect<r_8> (siz_x * siz_y, (r_8*)data);
+    voidP   = vect.r8->p;
+    IVal_p = &RzImage::IVal_r8;
+    FVal_p = &RzImage::FVal_r8;
+    DVal_p = &RzImage::DVal_r8;
+    break;
+  default:
+    printf("RzImage::SetPixels Error - Unsupported DataType= %d \n", (int)dataType);
+    break;    
+  } 
+}
+
+/* --Methode-- */
+void RzImage::DeAllocPixels()
+{
+if (!voidP)  return;
+  switch (dataType) {
+  case kuint_1:
+    if (! (--vect.u1->NImgRef()))
+      delete vect.u1;
+    vect.u1 = NULL;
+    break;
+  case kuint_2:
+    if (! (--vect.u2->NImgRef()))
+      delete vect.u2;
+    vect.u2 = NULL;
+    break;
+  case kint_2:
+    if (! (--vect.i2->NImgRef()))
+      delete vect.i2;
+    vect.i2 = NULL;
+    break;
+  case kint_4:
+    if (! (--vect.i4->NImgRef()))
+      delete vect.i4;
+    vect.i4 = NULL;
+    break;
+  case kr_4:
+    if (! (--vect.r4->NImgRef()))
+      delete vect.r4;
+    vect.r4 = NULL;
+    break;
+  case kr_8:
+    if (! (--vect.r8->NImgRef()))
+      delete vect.r8;
+    vect.r8 = NULL;
+    break;
+  default:
+    printf("RzImage::DeAllocPixels Error - Unsupported DataType= %d \n", (int)dataType);
+    break;    
+  }
+
+voidP = NULL;
+siz_x = siz_y = 0;
+vect.u2 = NULL;
+}
+
+//++
+// Titre	Informations globales
+//--
+//++
+// int_4  XSize(), YSize()
+//	Taille de l'image en X, Y
+// int_4  XOrg(),  YOrg()
+//	Origines (X,Y) de l'image. Cette origine permet en particulier 
+//	de conserver l'information de decalage, quand l'image est 
+//	extraite d'une image plus grande. Les valeurs de l'origine
+//	peuvent etre modifiees par la methode "SetOrg()"
+// void SetOrg(int_4 orgx, int_4 orgy)
+//	Modifie l'origine de l'image
+// float  XPxSize()  YPxSize()
+//	Taille des pixels (X,Y) de l'image. Peuvent etre modifiees
+//	par la methode "SetPxSize()"
+// void SetPxSize()
+// PBaseDataTypes   PixelType()
+//	Type des pixels de l'image "(kint_2, kint_4, kr_4, ...)"
+// char * PixelNomType()
+//	Nom du Type des pixels de l'image. Chaine de caracteres = kint_2, kint_4, ...
+// char * Nom()
+//	Nom de l'image. "Ident()" retourne l' "id" associe a l'image
+// void SetNameId(int imgid = 0, char const * nom = NULL)
+//	Permet de modifier l'identificateur et le nom d'une image
+// void SetAtt(int nbnul = -1, int nbsat = -1, -
+//             float minpix = 0, float maxpix = -1., -
+//             float moypix = 0, float sigpix = -1., -
+//             float fnd = -1., float sigfnd = -1.)
+//	Des donnees membres du type reels (float) 
+//	"fond, sigmaFond, minPix, moyPix,sigPix" et entier (int) "nbNul, nbSat"
+//	sont associees a chaque image. Leurs valeurs peuvent etre modifiees
+//	a l'aide de la methode "SetAtt()" ou la methode "CheckDyn()" 
+// int   CheckDyn(double min=-9.e19, double max=9.e19)
+//	Cette methode retourne le nombre de pixels hors dynamique "( <min ou >max )"
+//	Met a jour les donnees membres "min/maxPix nbNul/Sat".
+//	Calcule aussi la moyenne et le sigma des pixels -> "moyPix, sigPix"
+//--
+
+//++
+// Titre	I/O
+//--
+//++
+// void  Write(string const& flnm)
+// void  Save(char *flnm)
+//	Ecrit l'image en format PPF (PPersist) dans le fichier "flnm"
+// void  Read(string const& flnm)
+//	Lit le fichier "flnm" (au format PPF)
+//--
+
+/* --Methode-- */
+DVList&  RzImage::Info()
+{
+if (mInfo == NULL)  mInfo = new DVList;
+return(*mInfo);
+}
+
+/* --Methode-- */
+void RzImage::SetOrg(int_4 orgx, int_4 orgy)
+{
+org_x = orgx;   org_y = orgy;
+return;
+}
+
+/* --Methode-- */
+void RzImage::SetPxSize(float szx, float szy)
+{
+if (szx <= 0.)  szx = 1.;
+if (szy <= 0.)  szy = 1.;
+pxsz_x = szx;   pxsz_y = szy;
+return;
+}
+
+/* --Methode-- */
+void RzImage::SetAtt(int nbnul, int nbsat,
+              float minpix, float maxpix,
+              float moypix, float sigpix,
+              float fnd, float sigfnd)
+{
+nbNul = nbnul;  nbSat = nbsat;
+minPix = minpix;   maxPix = maxpix;
+moyPix = moypix; sigPix = sigpix;
+fond = fnd;  sigmaFond = sigfnd;
+return;
+}
+
+
+/* --Methode-- */
+void RzImage::SetNameId(int imgid, char const * nom)
+{
+id = imgid;
+if (nom)  { strncpy(name, nom, 32);  name[31] = '\0'; }
+else name[0] = '\0';
+return;
+}
+
+/* --Methode-- */
+void RzImage::Save(char *flnm)
+{
+POutPersist s(flnm);
+Write(s);
+}
+
+/* --Methode-- */
+void RzImage::WriteSelf(POutPersist& s) const
+
+/*  Ecriture de la structure image ds un fichier de maniere */ 
+/* brute - (Dump memoire)                                   */
+/* Pour utilisation par PPersist::Write()                   */
+
+{
+char buf[256];
+unsigned long sz;
+int i,j;
+int_4 itab[5];
+
+sprintf(buf,"\nRzImage(%s)[%d*%d]  Org: %d %d  PxSz: %g %g (Id=%d Nom=%s)\n",
+        PixelNomType(),siz_x, siz_y, org_x, org_y, pxsz_x, pxsz_y, id, name);
+i = strlen(buf); 
+sprintf(buf+i,"NbSat,Nul=%d %d Min,Max= %g %g Moy,Sig= %g %g Fond,Sig= %g %g\n",
+        nbSat, nbNul, minPix, maxPix, moyPix, sigPix, fond, sigmaFond);
+i += strlen(buf+i);
+for(j=i; j<255; j++)  buf[j] = ' ';  buf[255] = '\0';
+s.PutBytes(buf, 256);
+
+itab[0] = (int)dataType;
+itab[1] = siz_x;  itab[2] = siz_y;
+itab[3] = itab[4] = 0; 
+if (mInfo)  itab[3] = 1;    // Has DVList as info
+s.PutI4s(itab, 5);
+
+s.PutR4(fond);
+s.PutR4(sigmaFond);
+s.PutI4(nbNul);
+s.PutI4(nbSat);
+s.PutR4s(&minPix, 4); // minPix -> sigPix
+
+s.PutI4(org_x);
+s.PutI4(org_y);
+s.PutR4(pxsz_x);
+s.PutR4(pxsz_y);
+s.PutI4(isFits);
+s.PutBytes(name, 32);
+s.PutI4(id);
+
+sz = XSize()*YSize();
+switch (dataType) {
+case kuint_1:
+  s.PutBytes(voidP, sz);
+  break;
+case kuint_2:
+  s.PutU2s((uint_2*)voidP, sz);
+  break;
+case kint_2:
+  s.PutI2s((int_2*)voidP, sz);
+  break;
+case kint_4:
+  s.PutI4s((int_4*)voidP, sz);
+  break;
+case kr_4:
+  s.PutR4s((r_4*)voidP, sz);
+  break;
+case kr_8:
+  s.PutR8s((r_8*)voidP, sz);
+  break;
+default:
+  printf("RzImage::WriteSelf Error - Unsupported DataType= %d \n", (int)dataType);
+  break;    
+} 
+
+if (mInfo) mInfo->Write(s);
+return;
+}
+
+
+/* --Methode-- */
+void RzImage::ReadSelf(PInPersist& s)
+/*  Relecture de fichier cree par WriteSelf()    */
+/*  Pour utilisation par PPersist::Read()        */
+{
+char buf[256];
+unsigned long sz;
+int_4 itab[5];
+int_4 opt;
+
+s.GetBytes(buf, 256);
+s.GetI4s(itab, 5);
+opt = (int_4)PixelType();
+if ((opt > 0) && (opt != itab[0]))  { 
+    cerr << "RzImage::ReadSelf() Image type (=" << opt 
+         << ") mismatch (type in file=" << itab[0] << ")" << endl;
+    THROW(typeMismatchErr); }
+Allocate((PBaseDataTypes)itab[0], itab[1], itab[2]);
+
+s.GetR4(fond);
+s.GetR4(sigmaFond);
+s.GetI4(nbNul);
+s.GetI4(nbSat);
+s.GetR4s(&minPix, 4); // minPix -> sigPix
+
+s.GetI4(org_x);
+s.GetI4(org_y);
+s.GetR4(pxsz_x);
+s.GetR4(pxsz_y);
+s.GetI4(isFits);
+s.GetBytes(name, 32);
+s.GetI4(id);
+
+sz = XSize()*YSize();
+switch (dataType) {
+case kuint_1:
+  s.GetBytes(voidP, sz);
+  break;
+case kuint_2:
+  s.GetU2s((uint_2*)voidP, sz);
+  break;
+case kint_2:
+  s.GetI2s((int_2*)voidP, sz);
+  break;
+case kint_4:
+  s.GetI4s((int_4*)voidP, sz);
+  break;
+case kr_4:
+  s.GetR4s((r_4*)voidP, sz);
+  break;
+case kr_8:
+  s.GetR8s((r_8*)voidP, sz);
+  break;
+default:
+  printf("RzImage::ReadSelf Error - Unsupported DataType= %d \n", (int)dataType);
+  break;    
+} 
+
+if (itab[3])  // has info
+  { if (mInfo == NULL)  mInfo = new DVList;
+  mInfo->Read(s); }
+
+return;
+}
+
+
+//++
+// Titre	Impression
+//--
+//++
+// void  Print(ostream& os)
+//	Imprime sur le flot "os" les informations globales concernant l'image
+// void  Print()
+//	Imprime (sur cout) les informations globales concernant l'image
+// ostream&   operator << (ostream& s, RzImage const & img)
+//      sortie sur flot "s" (Appel a "Print(s)").
+//--
+
+/* --Methode-- */
+void RzImage::Print(ostream& os) const
+{
+char buff[256];
+os << " ---- RzImage::Print() ----- \n";
+sprintf(buff, "RzImage(%s)[%d*%d]  Org: %d %d  PxSz= %g %g (Id=%d Nom=%s)\n",
+       PixelNomType(),siz_x, siz_y, org_x, org_y, pxsz_x, pxsz_y, id, name);
+os << buff;
+sprintf(buff, "NbSat,Nul=%d %d Min,Max= %g %g Moy,Sig= %g %g Fond,Sig= %g %g\n",
+       nbSat, nbNul, minPix, maxPix, moyPix, sigPix, fond, sigmaFond);
+os << buff;
+if (mInfo) mInfo->Print(os);
+os << endl;
+}
+
+/* --Methode-- */
+int RzImage::CheckDyn(double min, double max)
+
+/*  Cette methode retourne le nombre de pixels hors dynamique    */
+/* ds le pave ( <min ou >max )                                   */
+/* Met a jour la structure image Min/MaxPix nbNul/Sat            */
+/* Calcule aussi la moyenne et le sigma des pixels, met a jour   */
+/* moypix et sigpix dans la structure                            */
+
+{
+float pixv=0;
+double dv;
+
+float minadu = PutInRange(min, pixv); 
+float maxadu = PutInRange(max, pixv);
+float minpix = PutInRange(maxadu+1, pixv);
+float maxpix = PutInRange(minadu-1, pixv);
+
+double m = 0.;
+double s = 0.;
+int n9 = 0;
+int n0 = 0;
+int n = XSize()*YSize();
+for(int i=0; i<n; i++) 
+  {
+  pixv = FValue(i);
+  if (pixv <= maxadu && pixv >= minadu) 
+    {  
+    if (pixv < minpix)  minpix = pixv;
+    else if (pixv > maxpix)  maxpix = pixv; 
+    dv = (double)pixv;
+    m += dv;  s += (dv*dv);
+    }
+  else 
+    {  
+    if (pixv > maxadu)  n9++;
+    if (pixv < minadu)  n0++; 
+    }
+  }
+
+nbNul = n0;
+nbSat = n9;
+minPix = minpix;
+maxPix = maxpix;
+
+n -= (n0+n9);
+if (n > 0)
+  { dv = (double)n;  m /= dv;  s = s/dv - m*m;
+  if (s>0.)  s = sqrt(s);  else s = 0.;
+  moyPix = m;  sigPix = s; }
+else { moyPix = 0.;  sigPix = -1.; }
+
+return(n0+n9);
+}
+
+////////////////////////////////////////////////////////////////
+//++
+RzImage* RzImage::FitResidus(GeneralFit& gfit)
+//
+//	Retourne une RzImage R4 contenant les residus du fit ``gfit''.
+//--
+{
+if(XSize()<=0 || YSize()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+RzImage* img = new RzImage(DataType((r_4)0.),XSize(),YSize());
+img->SetOrg(XOrg(),YOrg());
+img->SetPxSize(XPxSize(),YPxSize());
+r_4* ptr = (r_4 *) img->VoidP();
+for(int i=0;i<XSize();i++) {
+  double x[2];
+  x[0] = XOrg()+(i+0.5)*XPxSize();
+  for(int j=0;j<YSize();j++) {
+    x[1] = YOrg()+(j+0.5)*YPxSize();
+    *(ptr+i+j*img->siz_x) = FValue(i,j) - (float) f->Value(x,par.Data());
+  }
+}
+return img;
+}
+
+//++
+RzImage* RzImage::FitFunction(GeneralFit& gfit)
+//
+//	Retourne RzImage R4 contenant la fonction du fit ``gfit''.
+//--
+{
+if(XSize()<=0 || YSize()<=0) return NULL;
+GeneralFunction* f = gfit.GetFunction();
+if(f==NULL) return NULL;
+Vector par = gfit.GetParm();
+RzImage* img = new RzImage(DataType((r_4)0.),XSize(),YSize());
+img->SetOrg(XOrg(),YOrg());
+img->SetPxSize(XPxSize(),YPxSize());
+r_4* ptr = (r_4 *) img->VoidP();
+for(int i=0;i<XSize();i++) {
+  double x[2];
+  x[0] = XOrg()+(i+0.5)*XPxSize();
+  for(int j=0;j<YSize();j++) {
+    x[1] = YOrg()+(j+0.5)*YPxSize();
+    *(ptr+i+j*img->siz_x) = (float) f->Value(x,par.Data());
+  }
+}
+return img;
+}
+
+//++
+// Titre	Acces aux pixels
+//	*Attention:* Les methodes IValue() FValue() et DValue() sont lentes.
+//	Ne pas les utiliser dans les parties du code ou la vitesse de traitement
+//	est critique.
+//--
+//++
+// void * VoidP()
+//	Renvoie un pointeur void sur le tableau des pixels. Doit etre converti
+//	dans le bon type suivant le contenu de l'image.
+// int IValue(int i, int j)
+//	Renvoie la valeur du pixel "(i,j)" converti en int
+// float FValue(int i, int j)
+//	Renvoie la valeur du pixel "(i,j)" converti en float
+// double DValue(int i, int j)
+//	Renvoie la valeur du pixel "(i,j)" converti en double
+// int IValue(int k)
+//	Renvoie la valeur du pixel numero "k" converti en int
+// float FValue(int k)
+//	Renvoie la valeur du pixel numero "k" converti en float
+// double DValue(int k)
+//	envoie la valeur du pixel numero "k" converti en double
+//
+//	Les pixels sont rangees ligne apres ligne 
+//|	{(1,1), (2,1), ... (m, 1), (1,2), ... , (m,2), .... (m,n)}
+//--
+
+/* --Methodes-- */
+int RzImage::IVal_u1(int k) const          {return vect.u1->IElem(k);}
+int RzImage::IVal_u2(int k) const          {return vect.u2->IElem(k);}
+int RzImage::IVal_i2(int k) const          {return vect.i2->IElem(k);}
+int RzImage::IVal_i4(int k) const          {return vect.i4->IElem(k);}
+int RzImage::IVal_r4(int k) const          {return vect.r4->IElem(k);}
+int RzImage::IVal_r8(int k) const          {return vect.r8->IElem(k);}
+
+float RzImage::FVal_u1(int k) const        {return vect.u1->FElem(k);}
+float RzImage::FVal_u2(int k) const        {return vect.u2->FElem(k);}
+float RzImage::FVal_i2(int k) const        {return vect.i2->FElem(k);}
+float RzImage::FVal_i4(int k) const        {return vect.i4->FElem(k);}
+float RzImage::FVal_r4(int k) const        {return vect.r4->FElem(k);}
+float RzImage::FVal_r8(int k) const        {return vect.r8->FElem(k);}
+
+double RzImage::DVal_u1(int k) const       {return vect.u1->DElem(k);}
+double RzImage::DVal_u2(int k) const       {return vect.u2->DElem(k);}
+double RzImage::DVal_i2(int k) const       {return vect.i2->DElem(k);}
+double RzImage::DVal_i4(int k) const       {return vect.i4->DElem(k);}
+double RzImage::DVal_r4(int k) const       {return vect.r4->DElem(k);}
+double RzImage::DVal_r8(int k) const       {return vect.r8->DElem(k);}
+
+
+
+// ******** INSTANCES
+#if defined(__xlC) 
+void instancetemprzimg(int n)
+{
+/* Cette fonction sert uniquement a forcer le compilo a instancier les
+  classes/fonctions template   */
+
+RzVect<uint_1> rzvu1(n);
+RzVect<uint_2> rzvu2(n);
+RzVect<int_2> rzvi2(n);
+RzVect<int_4> rzvi4(n);
+RzVect<r_4> rzvr4(n);
+RzVect<r_8> rzvr8(n);
+return;
+}
+
+#endif
+
+#ifdef __CXX_PRAGMA_TEMPLATES__
+#pragma define_template RzVect<uint_1>
+#pragma define_template RzVect<uint_2>
+#pragma define_template RzVect<int_2>
+#pragma define_template RzVect<int_4>
+#pragma define_template RzVect<r_4>
+#pragma define_template RzVect<r_8>
+#endif
+
+#ifdef __GNU_TEMPLATES__
+template class RzVect<uint_1>;
+template class RzVect<uint_2>;
+template class RzVect<int_2>;
+template class RzVect<int_4>;
+template class RzVect<r_4>;
+template class RzVect<r_8>;
+#endif
+
+#if defined(__ANSI_TEMPLATES__) 
+template class RzVect<uint_1>;
+template class RzVect<uint_2>;
+template class RzVect<int_2>;
+template class RzVect<int_4>;
+template class RzVect<r_4>;
+template class RzVect<r_8>;
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/rzimage.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/rzimage.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/rzimage.h	(revision 1307)
@@ -0,0 +1,232 @@
+// This may look like C code, but it is really -*- C++ -*-
+//  Classe image generique   E.Aubourg , E. Lesquoy     
+//                           Modifs R. Ansari   04/95
+
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef RZIMAGE_SEEN
+#define RZIMAGE_SEEN
+
+#include <iostream.h>
+
+#include "rzvect.h"
+#include "datatypes.h"
+#include "ppersist.h"
+#include "dvlist.h"
+
+class GeneralFit;
+
+// Flags de verifications sur les indices 
+
+//#define IMGRGCHECK
+//#define IMGVOIDCHECK
+
+
+// ------------- Classe RzImage ------------------  
+
+typedef union {   // il faut acceder le bon en fonction de datatype
+  RzVect<uint_1>* u1;
+  RzVect<uint_2>* u2;
+  RzVect<int_2>*  i2;
+  RzVect<int_4>*  i4;
+  RzVect<r_4>*    r4;
+  RzVect<r_8>*    r8;
+} ImgVectP ;
+
+
+
+class RzImage : public PPersist {
+  //class RzImage EXC_AWARE {
+public:
+  enum {classId = ClassId_Image };
+
+                RzImage(PBaseDataTypes dType, int sizx, int sizy, 
+                        int imgId = 0, char const * imgName = 0);
+                RzImage(PBaseDataTypes dType=kpbdt_unknown);
+                RzImage(const RzImage&, int sharePixels=0);
+
+                RzImage(char *flnm);    // Creation/Lecture fichier de obtenu par Write()
+
+  virtual       ~RzImage(); 
+
+  int_4                 ClassId() const         { return classId; }
+  static PPersist*      Create()                { return new RzImage;}
+
+  RzImage&      operator= (RzImage const &);
+
+  inline int_4  XSize() const {return siz_x;}
+  inline int_4  YSize() const {return siz_y;}
+
+  inline int_4  XOrg() const {return org_x;}
+  inline int_4  YOrg() const {return org_y;}
+
+  inline float  XPxSize() const {return pxsz_x;}
+  inline float  YPxSize() const {return pxsz_y;}
+
+  inline ImgVectP    Vect() const {return vect;}
+  inline void * VoidP() const {return voidP;}
+  inline int    IsFits() const {return isFits;}
+
+  inline PBaseDataTypes    PixelType() const { return dataType; }
+  inline char * PixelNomType() const { return DataName(dataType); }
+
+  inline char * Nom()  { return name; }
+  inline const char * Nom() const { return name; }
+  inline int_4  Ident() const { return id; }
+
+  DVList&       Info();
+ 
+  void          Allocate(PBaseDataTypes dType, int sizx, int sizy, ImgVectP* pvpsh=NULL);
+  void          DeAllocPixels();
+  void          SetPixels(PBaseDataTypes dType, int sizx, int sizy, void* data);
+
+  void          SetOrg(int_4 orgx, int_4 orgy);
+  void          SetPxSize(float szx=1, float szy=1);
+  void          SetAtt(int nbnul = -1, int nbsat = -1,
+                       float minpix = 0, float maxpix = -1.,
+                       float moypix = 0, float sigpix = -1., 
+                       float fnd = -1., float sigfnd = -1.);
+
+  void          SetNameId(int imgid = 0, char const * nom = NULL);
+
+// Fonctions d'impressions 
+  virtual void  Print(ostream& os) const;
+  inline void   Print() const { Print(cout); }
+
+  virtual int   CheckDyn(double min=-9.e19, double max=9.e19);
+
+// Resultats d'un GeneralFit
+  RzImage* 	FitResidus(GeneralFit& gfit);
+  RzImage* 	FitFunction(GeneralFit& gfit);
+
+  void          Save(char *flnm);
+  virtual void  WriteSelf(POutPersist&) const;
+  virtual void  ReadSelf(PInPersist&);
+
+//  Fonctions d'acces aux pixels avec conversion 
+// ATTENTION LENT ! EVITER AUX ENDROITS CRITIQUES.
+
+  int           IValue(int i, int j) const ;    
+  int           IValue(int k) const ;           
+  float         FValue(int i, int j) const ;    
+  float         FValue(int k) const ;
+  double        DValue(int i, int j) const ;
+  double        DValue(int k) const ;
+
+// Quelques variables caracterisant la distribution des pixels 
+  r_4       fond;         // Fond de l'image 
+  r_4       sigmaFond;    // Fluctuation du fond
+  int_4     nbNul;        // Nb de pixels < min
+  int_4     nbSat;        // Nb de pixels > max 
+  r_4       minPix;       // Valeur mini des pixels >= min <= max 
+  r_4       maxPix;       // Valeur maxi des pixels >= min <= max 
+  r_4       moyPix;       // Valeur moyenne des pixels
+  r_4       sigPix;       // Sigma distribution des pixels 
+
+protected:
+  PBaseDataTypes  dataType;
+  int_4     siz_x,siz_y;        //  Taille x,y    
+  int_4     org_x,org_y;        //  Origines si image lu ds un fichier   
+  r_4       pxsz_x, pxsz_y;     //  Taille des pixels 
+  int_4     isFits;             //  Beurk. Ah que Reza ne me fait-il pas faire! 
+  char name[32];                //  Nom de l'image (Gestion des objets) 
+  int_4 id;                     //  Identificateur (Gestion des objets) 
+
+  void* voidP;          // un pointeur sans type   -
+                        // Vivement le RTTI qu'on puisse eliminer ces choses
+  ImgVectP vect;        // il faut acceder le bon en fonction de datatype
+
+  DVList* mInfo;        // Infos (variables) attachees a l'image
+      
+private:
+  int (RzImage::* IVal_p)(int) const;
+  float (RzImage::* FVal_p)(int) const;
+  double (RzImage::* DVal_p)(int) const;
+  
+  int IVal_u1(int k) const;
+  int IVal_u2(int k) const;
+  int IVal_i2(int k) const;
+  int IVal_r4(int k) const;
+  int IVal_i4(int k) const;
+  int IVal_r8(int k) const;
+  
+  float FVal_u1(int k) const;
+  float FVal_u2(int k) const;
+  float FVal_i2(int k) const;
+  float FVal_r4(int k) const;
+  float FVal_i4(int k) const;
+  float FVal_r8(int k) const;
+  
+  double DVal_u1(int k) const;
+  double DVal_u2(int k) const;
+  double DVal_i2(int k) const;
+  double DVal_r4(int k) const;
+  double DVal_i4(int k) const;
+  double DVal_r8(int k) const;
+};
+
+// Definition de l'operateur << 
+inline ostream& operator << (ostream& s, RzImage const & img)
+  {  img.Print(s);  return(s);  }
+
+// Implementation des methodes d'acces pixels inline 
+
+#ifdef IMGRGCHECK
+#define RZCHECKIMG2(_x_,_y_)                                  \
+      if ((_x_ >= siz_x) || (_y_ >= siz_y) ||              \
+          (_x_ < 0) || (_y_ < 0)) THROW(rangeCheckErr);  \
+      if (!voidP) THROW(nullPtrErr)
+#define RZCHECKIMG1(_x_)                                  \
+      if ((_x_ >= siz_x*siz_y) || (_x_ < 0)) THROW(rangeCheckErr);  \
+      if (!voidP) THROW(nullPtrErr)
+#else
+#if defined(IMGVOIDCHECK)
+#define RZCHECKIMG2(_x_,_y_) \
+      if (!voidP) THROW(NullPtrErr)
+#define RZCHECKIMG1(_x_,_y_) \
+      if (!voidP) THROW(NullPtrErr)
+#else
+#define RZCHECKIMG2(_x_,_y_)
+#define RZCHECKIMG1(_x_)
+#endif
+#endif /* IMGRGCHECK */
+
+// Methodes d'acces pixels inline 
+
+inline int RzImage::IValue(int k) const
+{ 
+RZCHECKIMG1(k);
+return (this->*IVal_p)(k); 
+}
+
+inline int RzImage::IValue(int i, int j) const
+{ 
+RZCHECKIMG2(i,j);
+return IValue(i+j*siz_x); 
+}
+
+inline float RzImage::FValue(int k) const
+{ 
+RZCHECKIMG1(k);
+return (this->*FVal_p)(k); 
+}
+
+inline float RzImage::FValue(int i, int j) const
+{ 
+RZCHECKIMG2(i,j);
+return FValue(i+j*siz_x); 
+}
+
+inline double RzImage::DValue(int k) const
+{ 
+RZCHECKIMG1(k);
+return (this->*DVal_p)(k); 
+}
+
+inline double RzImage::DValue(int i, int j) const
+{ 
+RZCHECKIMG2(i,j);
+return DValue(i+j*siz_x); 
+}
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/rzvect.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/rzvect.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/rzvect.h	(revision 1307)
@@ -0,0 +1,76 @@
+// This may look like C code, but it is really -*- C++ -*-
+/*  Classe vecteurs de type non constant (template)     */
+/*                    E. Aubourg, E. Lesquoy            */
+/*        Modifs             R. Ansari 04/95            */
+
+#ifndef RZVECT_SEEN
+#define RZVECT_SEEN
+
+#include "machine.h"
+#include "exceptions.h"
+#include "perrors.h"
+
+template <class T>
+class RzVect EXC_AWARE {
+public:
+                    RzVect(int n, T* data);
+                    RzVect(int n);
+  virtual           ~RzVect();
+  inline int&       NImgRef()         {return nImgRef;}
+  inline int&       Shareable()       {return shareable;}   
+  inline T&         operator[](int i);
+  inline const T&   operator[](int i) const;
+  int               IElem(int k) const;
+  float             FElem(int k) const;
+  double            DElem(int k) const;
+  
+  T*                p;
+  int               nElt;
+  
+private:
+  int           nImgRef;    // Combien d'images font reference au meme RzVect ?
+                                                // Le constructeur le met a *** 1 ***
+                                                // Donc une image doit le changer lorsqu'elle pointe sans allouer.
+  int           shareable;  // Dit si le RzVect peut etre partage. Mis a 0 par exemple si
+                            // le tableau de nombres est en memoire partagee.
+  int           ownTable;   // Dit si le RzVect peut faire delete du tableau.
+};
+
+template <class T>
+inline T& RzVect<T>::operator[](int i)
+{
+  #ifdef RGCHECK
+  if (i<0 || i>=nElt) THROW(rangeCheckErr);
+  #endif
+  return p[i];
+}
+
+template <class T>
+inline const T& RzVect<T>::operator[](int i) const
+{
+  #ifdef RGCHECK
+  if (i<0 || i>=nElt) THROW(rangeCheckErr);
+  #endif
+  return p[i];
+}
+
+template <class T>
+inline int RzVect<T>::IElem(int k) const
+{
+  return (int) (*this)[k];
+}
+
+template <class T>
+inline float RzVect<T>::FElem(int k) const
+{
+  return (float) (*this)[k];
+}
+
+template <class T>
+inline double RzVect<T>::DElem(int k) const
+{
+  return (double) (*this)[k];
+}
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/NTools/simplesort.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/simplesort.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/simplesort.cc	(revision 1307)
@@ -0,0 +1,60 @@
+//
+// $Id: simplesort.cc,v 1.1.1.1 1999-04-09 17:57:58 ansari Exp $
+//
+
+#include "defs.h"
+#include "simplesort.h"
+#include <stdlib.h>
+
+//++
+// Class	SimpleSort
+// Lib  	Outils++ 
+// include	simplesort.h
+//
+//	Classe pour trier. Utiliser plutôt la STL.
+//--
+
+
+SimpleSort::SimpleSort(int nElts)
+: numElts(nElts), index(new TRIPAIRE[nElts])
+{END_CONSTRUCTOR}
+			
+SimpleSort::~SimpleSort()
+{
+  delete[] index;
+}
+
+int SimpleSort::Compare(const void* tp1, const void* tp2)
+{ float x=((TRIPAIRE*)tp1)->value - ((TRIPAIRE*)tp2)->value;
+  if (x>0) return(1);
+  else if (x<0) return(-1);
+  else return(0);
+}
+
+#if !ARG_FUNC_CPP_C
+extern "C" int SimpleSortCompare(const void* tp1, const void* tp2);
+
+int SimpleSortCompare(const void* tp1, const void* tp2)
+{ return SimpleSort::Compare(tp1, tp2);
+}
+#endif
+
+void SimpleSort::Sort()
+{
+#if ARG_FUNC_CPP_C
+  qsort(index, numElts, sizeof(TRIPAIRE), SimpleSort::Compare);
+#else
+  qsort(index, numElts, sizeof(TRIPAIRE), SimpleSortCompare);
+#endif
+}
+
+int SimpleSort::Lookup(float val)
+{
+  int a = 0;
+  int b = numElts-1;
+  while (b>a+1) {
+    int c = (b+a)/2;
+    ((val >= index[c].value) ? a : b) = c;
+  }
+  return a;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/simplesort.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/simplesort.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/simplesort.h	(revision 1307)
@@ -0,0 +1,100 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// $Id: simplesort.h,v 1.1.1.1 1999-04-09 17:57:58 ansari Exp $
+//
+
+// Un tri tout bete sur des reels. On donne un tableau de reels,
+// et on recupere un index trie, et on peut faire des recherches.
+
+#ifndef SIMPLESORT_SEEN
+#define SIMPLESORT_SEEN
+
+#include "peida.h"
+
+class SimpleSort EXC_AWARE {
+public:
+  SimpleSort(int nElts);
+  // On donne au constructeur le nombre d'elements a trier.
+  virtual ~SimpleSort();
+
+  void      Set(int i, float value);
+  // Donne la valeur de l'element i
+
+  void      Sort();
+  // Trie. A faire avant d'appeler la suite.
+
+  float    Value(int i) const {return index[i].value;}
+  // La valeur numero i une fois trie.
+
+  int       Num(int i) const   {return index[i].num;}
+  // L'ancien indice qui est le numero i une fois trie
+
+  int       Lookup(float val);
+  // L'indice - trie - le plus proche de val.
+  
+#if ARG_FUNC_CPP_C
+private:
+#endif
+  typedef struct {
+    int num;
+    float value;
+  } TRIPAIRE;
+
+  static int Compare(const void* tp1, const void* tp2);
+    
+  int numElts;
+  TRIPAIRE* index;
+};
+
+// ************ INLINES
+
+inline
+void SimpleSort::Set(int i, float value)   // Check range ?
+{
+  index[i].num = i;
+  index[i].value = value;
+}
+
+
+
+// Une variante avec la STL, a preferer
+#include <functional>
+#include <algorithm>
+#if defined(__KCC__)
+#include <functional.h>
+#include <algorithm.h>
+#endif
+
+
+// On a un vecteur de donnees et un vecteur d'index, on trie les index
+// en comparant les donnees.
+// L'objet-fonction de type dataCompare doit comparer deux objets de type data.
+
+// Comparateur qui agit sur l'index en comparant les donnees avec dataCompare
+template <class data, class index, class dataCompare>
+struct IndexComp : public binary_function<index,index,bool>
+{
+  IndexComp(data* begin_data, index* begin_index, dataCompare comp)
+    : bdata(begin_data), bindex(begin_index), datacomp(comp) {}
+
+  bool operator()(index const& i1, index const& i2)
+    { return datacomp(*(bdata + (&i1 - bindex)), *(bdata + (&i2 - bindex)));}
+    
+  data* bdata;
+  index* bindex;
+  dataCompare datacomp;
+};
+
+// Fonction de tri qui trie un index en comparant des donnees avec dataComp
+template <class data, class index, class dataCompare>
+void TriIndex(data* begin_data, data* end_data, index* begin_index, dataCompare comp)
+{
+  sort(begin_index, begin_index + (end_data-begin_data),
+  	IndexComp<data, index, dataCompare>(begin_data, begin_index, comp));
+}  
+
+
+
+
+
+#endif // SIMPLESORT_SEEN
Index: /tags/DPC_V0/SophyaLib/NTools/simps2d.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/simps2d.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/simps2d.h	(revision 1307)
@@ -0,0 +1,40 @@
+#ifndef SIMPS2D_SEEN
+#define SIMPS2D_SEEN
+
+// Integration 2D domaine carre
+// Selon Abramowitz p892-893 formule 25.462, residu ordre 0.5**6
+// 0.387298=0.5*sqrt(3/5)  0.197531=16/81  0.123457=10/81  0.077160=25/324
+#if defined(SIMPSON9)
+  static int   nd2d = 9;
+  static float dx2d[9] = { 0.000000 ,  0.000000 ,  0.000000
+                         ,-0.387298 ,  0.387298 , -0.387298
+                         , 0.387298 , -0.387298 ,  0.387298 };
+  static float dy2d[9] = { 0.000000 , -0.387298 ,  0.387298
+                         , 0.000000 ,  0.000000 , -0.387298
+                         , 0.387298 ,  0.387298 , -0.387298 };
+  static float  w2d[9] = { 0.197531 ,  0.123457 ,  0.123457
+                         , 0.123457 ,  0.123457 ,  0.077157
+                         , 0.0771605,  0.0771605,  0.0771605};
+#elif defined(SIMPSON4)
+  static int   nd2d = 4;
+  static float dx2d[4] = { 0.288675, 0.288675,-0.288675,-0.288675 };
+  static float dy2d[4] = { 0.288675,-0.288675, 0.288675,-0.288675 };
+  static float  w2d[4] = { 0.250000, 0.250000, 0.250000, 0.250000 };
+#elif defined(INTEG5)
+  static int   nd2d = 5;
+  static float dx2d[5] = { 0. , -0.3, -0.3,  0.3, 0.3 };
+  static float dy2d[5] = { 0. , -0.3,  0.3, -0.3, 0.3 };
+  static float  w2d[5] = { 0.2,  0.2,  0.2,  0.2, 0.2 };
+#elif  defined(NOINTEG)
+  static int   nd2d = 1;
+  static float dx2d[1] = { 0. };
+  static float dy2d[1] = { 0. };
+  static float  w2d[1] = { 1. };
+#else
+  static int   nd2d = 0;
+  static float dx2d[1] = { 999999. };
+  static float dy2d[1] = { 999999. };
+  static float  w2d[1] = { 0. };
+#endif
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/strutil.c
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/strutil.c	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/strutil.c	(revision 1307)
@@ -0,0 +1,530 @@
+/* 
+++ 
+  Module	Strutil (C)
+  Lib	LibsUtil
+  include	strutil.h
+
+	Groupe de fonction de gestion et manipulation
+	des chaines de caracteres.
+--
+*/
+
+/*
+++
+  char* itoc(int in, char* s, int nDigits)
+	conversion entier-chaine de caracteres
+--
+*/
+/*
+++
+  ctoi(const char* cst, int *ipt)
+	convertit une chaine de caractere en entier
+--
+*/
+/*
+++
+  ctol(const char* cst, long int *lpt)
+	convertit une chaine de caractere en entier long
+--
+*/
+/*
+++
+  ctof(const char* cst, double *fpt)
+	convertit une chaine de caractere en flottant
+--
+*/
+/*
+++
+  posc(const char* cst, char sec)
+	trouve la position d'un caractere dans une chaine
+	(premier charactere rencontre)
+--
+*/
+/*
+++
+  poslc(const char* cst, char sec)
+	trouve la position d'un caractere dans une chaine
+	(dernier charactere rencontre)
+--
+*/
+/*
+++
+  strip(char cst[], char opt, char bc)
+	permet d'enlever les blancs au debut ou a la fin d'une
+	chaine de caractere
+--
+*/
+/*
+++
+  padstr(spo,lpa,bc)
+	Cette  fonction  rajoute  des blancs a la fin de la chaine `spo'
+	pour amener la longueur de la chaine a `lpa'. Les caracteres
+	rajoutes a la fin sont `bc'. La fonction retourne le nombre de
+	blancs (caracteres bc)  rajoutes a la fin.
+--
+*/
+/*
+++
+  tomaj(char *cbuff)
+	Changement en majuscule d'une chaine de caracteres
+--
+*/
+/*
+++
+  tomin(char *cbuff)
+	Changement en minuscule d'une chaine de caracteres
+--
+*/
+/*
+++
+  efface(char *cbuff,int lbuff,char c)
+	Remplace un caractere avec des blancs
+--
+*/
+/*
+++
+  csh_parse(const char* x, const char* yp)
+	Compare la chaine de caracteres `x' avec la chaine `yp'
+	comprenant des regles de substitution type c-shell
+	(asterisque et point d'interrogation).
+--
+*/
+/*
+  DecArgList()
+	Decoder une liste du type a,b,c-d,e,f-g,h...
+*/
+ 
+
+#include "strutil.h"
+
+/*            Fonction  itoc()    */
+char* itoc(int in, char* s, int nDigits)
+{
+  int i,j,n;
+  n=abs(in);
+  for(i=0;i<nDigits;i++)
+    s[i]=' ';
+  s[nDigits-1]='\0';
+  j=nDigits-2;
+  for (i=j; i>=0; i--)
+   {
+    int x = n % 10;
+    n /= 10;
+    s[i] = '0' + x;
+    if(n==0) break;
+   }
+  if(in < 0 )
+   {
+    s[i-1]='-';
+   } 
+ return (s);
+ }
+ 
+/*            Fonction  ctoi()    */
+int ctoi(const char* cst, int *ipt)
+{
+int i,j,k,l,ls,isgn;
+ls = strlen(cst)-1;
+if (ls < 0)  return (-1);
+j = -1;
+isgn = l = 1;
+k = 0;
+if(cst[0] == '-')
+  {
+  j = 0;
+  isgn = -1;
+  }
+if(cst[0] == '+') j = 0;
+for(i=ls;i>j;i--)
+  {
+  if(isdigit(cst[i]) == 0)  return (-1);
+  k += (cst[i] - '0')*l;
+  l *= 10;
+  }
+*ipt = k*isgn;
+return (1);
+}
+/*                                                       */
+/*            Fonction  ctol()    */
+int ctol(const char* cst, long int *lpt)
+{
+int i,j,ls,isgn;
+long k,l;
+ls = strlen(cst)-1;
+if (ls < 0)  return (-1);
+j = -1;
+isgn = l = 1;
+k = 0;
+if(cst[0] == '-')
+  {
+  j = 0;
+  isgn = -1;
+  }
+if(cst[0] == '+') j = 0;
+for(i=ls;i>j;i--)
+  {
+  if(isdigit(cst[i]) == 0)  return (-1);
+  k += (cst[i] - '0')*l;
+  l *= 10;
+  }
+*lpt = k*isgn;
+return (1);
+}
+/*              Fonction  ctof()           */
+int ctof(const char* cst, double *fpt)
+{
+int i,jb,pv,ls,isgn;
+double v1,v2;
+ls = strlen(cst);
+if (ls < 0)  return (-1);
+jb = -1;
+isgn = 1;
+v1 = 0.;
+v2 = 1.;
+if (cst[0] == '-')
+  {
+  jb = 0;
+  isgn = -1;
+  }
+if (cst[0] == '+')  jb = 0;
+if ((pv=posc(cst,'.')) != -1)
+  {
+  v2 = 0.1;
+  for(i=pv+1;i<ls;i++)
+    {
+    if(isdigit(cst[i]) == 0)  return (-1);
+    v1 += (cst[i]-'0')*v2;
+    v2 /= 10.;
+    }
+  ls = pv;
+  v2 = 1.;
+  }
+for(i=ls-1;i>jb;i--)
+  {
+  if(isdigit(cst[i]) == 0)  return (-1);
+  v1 += (cst[i]-'0')*v2;
+  v2 *= 10.;
+  }
+*fpt = (isgn == 1)? v1 : -v1;
+return (1);
+}
+/*           Fonction  posc()        */
+int posc(const char* cst, char sec)
+{
+int i,ls;
+ls = strlen(cst);
+for(i=0;i<ls;i++)
+  {
+  if (cst[i] == sec)  return(i);
+  }
+return (-1);
+}
+
+/*           Fonction  poslc()        */
+int poslc(const char* cst, char sec)
+{
+int i,ls;
+ls = strlen(cst);
+for(i=ls-1;i>=0;i--)
+  {
+  if (cst[i] == sec)  return(i);
+  }
+return (-1);
+}
+
+/*                Fonction   strip()             */
+int strip(char cst[], char opt, char bc)
+{
+int i,j,ls;
+ls = strlen(cst);
+if (opt == 'L' || opt == 'B')
+  {
+  i = 0;
+  while(cst[i] == bc) i++;
+  if (i != 0)
+    {
+    for(j=i;j<ls;j++)  cst[j-i] = cst[j];
+    ls -= i;
+    cst[ls] = '\0';
+    }
+  }
+if ((opt == 'T' || opt == 'B') && ls > 0)
+  {
+  i = ls-1;
+  while(cst[i] == bc)  i--;
+  cst[i+1] = '\0';
+  }
+return (0);
+}
+
+/*                Fonction   padstr(spo,lpa,bc)                      */
+/*    Cette  fonction  rajoute  des blancs a la fin de la chaine spo */
+/*   pour amener la longueur de la chaine a lpa. les caracteres      */
+/*   rajoutes a la fin sont bc. La fonction retourne le nombre de    */ 
+/*   blancs (caracteres bc)  rajoutes a la fin.                      */
+
+int padstr(char spo[], char lpa, int bc)
+{
+int li,i;
+li = strlen(spo);
+for(i=li;i<lpa;i++)  spo[i] = bc;
+spo[lpa] = '\0';
+return(lpa-li);
+}
+
+/* Eric L. 11-03-94 */
+/* quelques fonctions utiles */
+
+void tomaj(char *cbuff)
+{
+register int i,l;
+
+l=strlen(cbuff);
+for(i=0; i< l;i++)
+  cbuff[i]=(char) toupper( (int) cbuff[i]);
+}
+
+void tomin(char *cbuff)
+{
+register int i,l;
+
+l=strlen(cbuff);
+for(i=0; i< l;i++)
+  cbuff[i]=(char) tolower( (int) cbuff[i]);
+}
+
+void efface(char *cbuff,int lbuff,char c)
+{
+register int i;
+
+for(i=0; i< lbuff;i++)
+  if(cbuff[i] == c)  cbuff[i] = ' ';
+}
+
+char* rep_char(const char *cbuff,char cin,char crep)
+{
+register int i,l;
+char* buff;
+buff=(char*) cbuff;
+l=strlen(buff);
+for(i=0; i< l;i++)
+  if(buff[i] == cin) buff[i] = crep;
+return(buff);
+}
+
+/* Eric L. 23-03-96 */
+
+int csh_parse(const char* x, const char* yp)
+{
+ int i,lenx,lenyp;
+ int ix,iyp;
+ int faux;
+ char cx, cyp;
+ 
+ lenx=strlen(x);
+ lenyp=strlen(yp);
+ if(!lenx || !lenyp) return(0);
+ faux=0;
+ ix=0;iyp=0;
+ while(ix < lenx && iyp < lenyp)
+  {
+   cx=x[ix];
+   cyp=yp[iyp];
+   if(cx == cyp) 
+    {
+     ix++; 
+     iyp++;
+    }
+   else
+    switch(cyp)
+     {
+       case '?':
+        ix++;
+        iyp++;
+        break;
+       case '*':
+        while((cyp=='*' || cyp=='?') && (iyp < lenyp))
+         {
+          iyp++;
+          if(iyp < lenyp) cyp=yp[iyp];
+         }
+        if(iyp < lenyp)
+         {
+          faux=1;
+          for(i = ix; i < lenx ; i++)
+           {
+            cx=x[i];
+            if(cx == cyp)
+             {
+              faux=0;
+              break;
+             }
+           }
+          ix=i+1;
+          if(ix < lenx) cx=x[ix];
+          iyp++; 
+          if(iyp < lenyp) cyp=yp[iyp];
+         }    
+        break;
+       default:
+        faux=1;
+     }
+    if(faux) return(0);
+  }
+ 
+ for( i= iyp; i < lenyp ; i++)
+  {
+   cyp=yp[i];
+   if( cyp != '*' && cyp != '?') return(0);
+  }
+ 
+ if(cyp == '*') return(1);
+ if((lenx-ix) == 1 && ( cyp == '?' || cx==cyp)) return(1);
+ for( i= ix; i < lenx ; i++)
+  {
+   cx=x[i];
+   if( cx != cyp)  return(0);
+  }
+ return(1);
+}
+ 
+/*-------------------------------------------------------------------*/
+
+/*
+++
+  int DecArgList(char *listin, int *Vec, int nVec)
+	Pour decoder une liste de numeros a,b,c-d,e,f-g,h...
+	avec a,b... entiers
+| Vec est rempli jusqu'a concurrence de nVec elts.
+|     Si Vec==NULL ou nVec<=0 le tableau n'est pas rempli
+|         et seul le nombre d'elements est compte
+| Return: nombre d'elements rempli
+--
+*/
+/*                            (cmv 7/8/97)      */
+int DecArgList(char *listin, int *Vec, int nVec)
+{
+int i,k, num, min, max;
+char *list = NULL, *listfin, *s;
+
+if(strlen(listin) <= 0) return(0);
+list = (char *) malloc(strlen(listin)+1);
+if(list==NULL) return(0);
+strcpy(list,listin); strip(list,'B',' ');
+if( (k=strlen(list)) <= 0 ) {free(list); return(0);}
+for(i=0; i<k; i++) if(list[i] == ',') list[i] = ' ';
+listfin = list + k; *listfin = '\0';
+
+s = list; num = 0; k = 0;
+while(s < listfin) {
+  if ( (k=posc(s,' ')) < 0)  k = strlen(s);
+  s[k] = '\0'; strip(s,'B',' ');
+  sscanf(s,"%d-%d",&min,&max);
+  max = min - 1;
+  sscanf(s,"%d-%d",&min,&max);
+  if(max<min) max = min;
+  for(i=min; i<=max; i++) {
+    if( Vec!=NULL && nVec>0 ) {
+      if( num >= nVec )
+        {printf("DecArgList_Erreur: pas assez de place dans le vecteur (%d)\n"
+               ,nVec); free(list); return(num);}
+      Vec[num] = i;
+    }
+    num++;
+  }
+  s = s+k+1;
+}
+
+free(list);
+return(num);
+}
+ 
+/*-------------------------------------------------------------------*/
+
+/*
+++
+  char *ExtName(char *cout,char *cin,char t)
+	Pour separer les composantes d'un nom de fichier de type unix.
+| cout   = chaine en sortie
+| cin    = chaine en entree
+| t      = type de racine a extraire
+| Return = *cout
+| - Remarque: pas de verification de longeur de la chaine cout!
+| - Exemple: /home/toto.cc  /home/ /home/.cc  .cc  toto.cc
+|    t='d' : /home          /home  /home      ""   ""
+|    t='n' : toto.cc        ""     .cc        .cc  toto.cc
+|    t='r' : toto           ""     ""         ""   toto
+|    t='t' : cc             ""     cc         cc   cc
+--
+*/
+/*                            (cmv 24/4/98)      */
+char *ExtName(char *cout,char *cin,char t)
+{
+int is=-1,ip=-1,i,j;
+int len = strlen(cin);
+/* cas ou le nom se termine par un / qui n'est pas au debut*/
+if(len>1) if(cin[len-1]=='/') len--;
+
+for(i=0;i<len;i++) {
+  if(cin[i]=='/') is=i;         /* position du dernier / */
+  if(cin[i]=='.' && ip<0) ip=i; /* position du 1er point */
+  cout[i]=cin[i];
+}
+cout[len]='\0';
+
+/* mauvais nom de fichier */
+if(is>=0&&ip>=0&&ip<=is) {cout[0]='\0'; return cout;}
+
+/* traitement des differents cas */
+switch(t) {
+  case 'd':
+    if(is==0) {                    /* cas /... */
+      if(ip<0) ip=len-1;             /* cas /home */
+      else ip=0;                     /* cas /toto.c */
+    } else if(is<0) {              /* cas toto.c */
+      is=ip=-1;
+    } else {                       /* cas /home/.../... */
+      ip=is-1; is=0;
+    }
+    break;
+  case 'n':
+    if(is==0) {                        /* cas /... */
+      if(ip<0) ip=is=-1;                 /* cas /home */
+      else {is=1; ip=len-1;}             /* cas /toto.c */
+    } else if(is>0) {                  /* cas /home/toto.c */
+      is++; ip=len-1;
+    } else {                           /* cas toto.c */
+      is=0; ip=len-1;
+    }
+    break;
+  case 'r':
+    if(is==0) {                          /* cas /... */
+      if(ip<0) ip=is=-1;                   /* cas /home */
+      else if(ip==1) is=ip=-1;             /* cas /.c */
+      else {is=1; ip--;}                   /* cas /toto.c */
+    } else if(is>0) {                    /* cas /home/... */
+      if(ip<0) {is++;ip=len-1;}            /* cas /home/toto */
+      else if(ip==is+1) is=ip=-1;          /* cas /home/.c */
+      else {is++; ip--;}                   /* cas /home/toto.c */
+    } else if(is<0) {                    /* cas toto.c */
+      if(ip<0) {is=0;ip=len-1;}            /* cas toto */
+      else if(ip==0) is=ip=-1;             /* cas .c */
+      else {is=0; ip--;}                   /* cas toto.c */
+    }
+    break;
+  case 't':
+    if(ip<0) is=ip=-1;             /* cas sans '.' dans le nom */
+    else {is=ip+1,ip=len-1;}       /* cas blablabla.c */
+    break;
+  default:
+    cout[0]='\0';
+    return cout;
+    break;
+}
+
+j=0;
+if(is>=0&&ip>=is) for(i=is,j=0;i<=ip;i++,j++) cout[j]=cin[i];
+cout[j]='\0';
+/* printf("........ is=%d ip=%d :%s:\n",is,ip,cout); */
+return cout;
+}
Index: /tags/DPC_V0/SophyaLib/NTools/strutil.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/strutil.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/strutil.h	(revision 1307)
@@ -0,0 +1,61 @@
+/*                                                                          */
+/*   Ce fichier contient quelques fonctions de manipulation de caracteres   */
+/*   et autres bricoles utiles                                              */
+/*     # char* itoc() : conversion entier-chaine de caracteres              */ 
+/*     # ctoi()   : convertit une chaine de caractere en entier             */
+/*     # ctol()   : convertit une chaine de caractere en entier long        */
+/*     # ctof()   : convertit une chaine de caractere en flottant           */
+/*     # posc()    : trouve la position d'un caractere dans une chaine      */
+/*     # strip()  : permet d'enlever les blancs au debut ou a la fin d'une  */
+/*                  chaine de caractere                                     */ 
+/*     # padstr() : permet d'ajouter des caracteres a la fin d'une chaine   */
+/*                  de caracteres pour amener la longueur de cette chaine   */
+/*                  a une valeur donnee.                                    */
+/*     # tomaj()  : Changement en majuscule d'une chaine de caracteres      */
+/*     # efface() : Remplace un caractere avec des blancs                   */
+/*     # rep_char() : Remplace un caractere par un autre                    */ 
+/*                                                                          */
+/* Derniere modif: csh_parse, E. Lesquoy, le 23-03-96                       */
+/* DecArgList: Decoder une liste du type a,b,c-d,e,f-g,h...(cmv 7/8/97)     */
+/* ExtName: eclatement des nom de fichiers unix (cmv 24/4/98)               */
+
+#ifndef STRUTIL_H_SEEN
+#define STRUTIL_H_SEEN
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*    Manipulation de chaines de caracteres     */
+/*                    Reza - 92/93              */
+char* itoc(int in, char* s,int nDigits);
+int ctoi(const char* cst, int *ipt);
+int ctol(const char* cst, long int *lpt);
+int ctof(const char* cst, double *fpt);
+/* retour ctox : 1: OK, -1 erreur */
+int posc(const char* cst, char sec);
+int poslc(const char* cst, char sec);
+int strip(char* cst, char opt, char bc);
+int padstr(char* spo, char lpa, int bc);
+
+/* Eric L. 11-03-94 */
+void tomaj(char *cbuff);
+void tomin(char *cbuff);
+void efface(char *cbuff,int lbuff,char c);
+/* Attention rep_char(const char *cbuff ...) c'est declare const cbuff, mais ca modifie cbuff - Reza 2/09/98  */
+char* rep_char(const char *cbuff,char cin,char crep);  
+/* Eric L. 23-03-96 */
+int csh_parse(const char* x, const char* yp);
+/* cmv 7/8/97 */
+int DecArgList(char *listin, int *Vec, int nVec);
+char *ExtName(char *cin,char *cout,char t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/NTools/swapbytes.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/swapbytes.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/swapbytes.h	(revision 1307)
@@ -0,0 +1,40 @@
+/*  Macro pour faire des bytes-swap        */
+/*                   CMV+Reza Fev 98       */
+
+#ifndef  SWAPBYTES_H_SEEN
+#define  SWAPBYTES_H_SEEN
+
+/*  Les arguments des define sont consideres comme pointeur */
+
+#define  Swap_Bytes8(_x8_)                                 \
+{                                                          \
+  uint_8 _tmp_ = *(uint_8*)(_x8_);                         \
+  *(uint_8*)(_x8_) = ((_tmp_ >> (7*8)) & 0x000000FF) |     \
+                     ((_tmp_ >> (5*8)) & 0x0000FF00) |     \
+                     ((_tmp_ >> (3*8)) & 0x00FF0000) |     \
+                     ((_tmp_ >> (1*8)) & 0xFF000000) |     \
+                     ((_tmp_ & 0xFF000000) << (1*8))  |    \
+                     ((_tmp_ & 0x00FF0000) << (3*8))  |    \
+                     ((_tmp_ & 0x0000FF00) << (5*8))  |    \
+                     ((_tmp_ & 0x000000FF) << (7*8));      \
+}
+
+
+#define  Swap_Bytes4(_x4_)                                 \
+{                                                          \
+  uint_4 _tmp_ = *(uint_4*)(_x4_);                         \
+  *(uint_4*)(_x4_) = ((_tmp_ >> 24) & 0x000000FF) |        \
+                     ((_tmp_ >> 8)  & 0x0000FF00) |        \
+                     ((_tmp_ & 0x0000FF00) << 8)  |        \
+                     ((_tmp_ & 0x000000FF) << 24);         \
+}
+
+
+#define  Swap_Bytes2(_x2_)                                 \
+{                                                          \
+  uint_2 _tmp_ = *(uint_2*)(_x2_);                         \
+  *(uint_2*)(_x2_) = ((_tmp_ >> 8) & 0x00FF) |             \
+                     ((_tmp_ & 0x00FF) << 8);              \
+}
+
+#endif
Index: /tags/DPC_V0/SophyaLib/NTools/tabmath.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/tabmath.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/tabmath.cc	(revision 1307)
@@ -0,0 +1,41 @@
+#include "defs.h"
+#include "tabmath.h"
+
+///////////////////////////////
+//  Exponentielles tabulees  //
+///////////////////////////////
+
+TabFExp::TabFExp()
+{
+  tab = new double[10000];
+
+  for(int i=0; i<10000; i++)
+    tab[i] = exp(-(double)i*0.001) ;
+}
+
+TabFExp::~TabFExp()
+{
+  delete[] tab;
+}
+
+TabFExp* ptabFExp;
+
+////////////////////////////////////
+//    Sinus tabules (et Cosinus)  //
+////////////////////////////////////
+
+TabFSin::TabFSin(int n)
+{
+  if(n<=1) n=10000;
+  tab = new double[n];
+  delta = Pi/2. / (double) (n-1);
+  for(int i=0; i<n; i++)
+    tab[i] = sin((double)i* delta) ;
+}
+
+TabFSin::~TabFSin()
+{
+  delete[] tab;
+}
+
+TabFSin* ptabFSin;
Index: /tags/DPC_V0/SophyaLib/NTools/tabmath.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/tabmath.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/tabmath.h	(revision 1307)
@@ -0,0 +1,53 @@
+// This may look like C code, but it is really -*- C++ -*-
+#include <math.h>
+#include "peida.h"
+#include "nbconst.h"
+
+
+///////////////////////////////
+//  Exponentielles tabulees  //
+///////////////////////////////
+
+class TabFExp EXC_AWARE {
+public:
+  TabFExp();
+  ~TabFExp();
+  inline double operator()(double x)
+    { if (x > 0) return exp(x);
+      if (x <= -10) return 0;
+          return tab[int(-x*1000)];
+    }
+private:
+  double* tab;
+};
+
+extern TabFExp* ptabFExp;
+#define tabFExp(_x_) ((*ptabFExp)(_x_))
+
+
+////////////////////////////////////
+//    Sinus tabules (et Cosinus)  //
+////////////////////////////////////
+
+class TabFSin EXC_AWARE {
+public:
+  TabFSin(int ntab = 0);
+  ~TabFSin();
+  inline double operator()(double x)
+    {
+    double s = 1.;
+    if(x<0.) {x *=-1.; s = -1.;}
+    x -= DeuxPi * int(x/DeuxPi);
+    if(x>Pi) {x -= Pi; s *= -1.;}
+    if(x>Pi/2.) x = Pi-x;
+    return s * tab[int(x/delta)];
+    }
+private:
+  int ntab;
+  double delta;
+  double* tab;
+};
+
+extern TabFSin* ptabFSin;
+#define tabFSin(_x_) ((*ptabFSin)(_x_))
+#define tabFCos(_x_) ((*ptabFSin)(_x_+Pis2))
Index: /tags/DPC_V0/SophyaLib/NTools/utils.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/utils.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/utils.cc	(revision 1307)
@@ -0,0 +1,113 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// $Id: utils.cc,v 1.1.1.1 1999-04-09 17:57:57 ansari Exp $
+//
+
+#include "defs.h"
+#include "utils.h"
+#include "exceptions.h"
+#include <string.h>
+
+// MemCpy marche meme en cas de recouvrement.
+
+void* MemCpy(void* dest, const void* source, size_t n)
+{
+  int i;   // THINK C ne veut pas du int i dans chaque for...
+  if (dest < source)
+    for (i=0; i<n; i++)
+      ((char*)dest)[i] = ((char*)source)[i];
+  else 
+    for (i=n-1; i>=0; i--)
+      ((char*)dest)[i] = ((char*)source)[i];
+  
+  return dest;
+}
+
+// Dans parmst.cc
+//int PrtLevel = 0;
+//int DebugLevel = 0;
+
+char const* PeidaWorkPath()
+{
+  char const* envWP = getenv("PEIDAWORKPATH");
+  if (envWP) return envWP;
+  #ifdef __mac__
+  return "WORK";
+  #endif
+  return ".";
+}
+
+#ifndef __mac__
+void buildPath(char* dst, const char* dir, const char* file)
+{
+  strcpy(dst, dir);
+  char *p = dst; while (*p) p++; p--;
+  if (*dir && *p != '/') strcat(dst, "/");
+  strcat(dst, file);
+}
+
+void buildPath(string& dst, const string& dir, const string& file)
+{
+  dst = dir;
+  if (dir != "" && dir[dir.length()-1] != '/') dst += "/";
+  dst += file;
+}
+
+#else
+void buildPath(char* dst, const char* dir, const char* file)
+{
+  if (*dir) {
+    strcpy(dst, ":");
+    strcat(dst, dir);
+    char *p = dst; while (*p) p++; p--;
+    strcat(dst, ":");
+    strcat(dst, file);
+  } else
+    strcpy(dst, file);
+}
+
+void buildPath(string& dst, const string& dir, const string& file)
+{
+  if (dir != "") {
+    dst = ":" + dir + ":" + file;
+  } else
+    dst = file;
+}
+
+#endif
+
+
+void changeSuffix(char* file, const char* suffix)
+{
+  char *p = file;
+  while (*p) p++;
+  while (*p != '.' && p > file) p--;
+  if (*p != '.') 
+    strcat(file, suffix);
+  else
+    strcpy(p,suffix);
+}
+
+void changeSuffix(string& file, const string& suffix)
+{
+  size_t pos = file.rfind('.');
+  //  if (pos != NPOS) file.remove(pos);
+  if (pos != NPOS) file = file.substr(0,pos);
+  file += suffix;
+}
+
+string itos(int i)
+{
+  char s[20];
+  sprintf(s, "%d", i);
+  return s;
+}
+
+string ftos(double f)
+{
+  char s[20];
+  sprintf(s, "%g", f);
+  return s;
+}
+
+
Index: /tags/DPC_V0/SophyaLib/NTools/utils.h
===================================================================
--- /tags/DPC_V0/SophyaLib/NTools/utils.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/NTools/utils.h	(revision 1307)
@@ -0,0 +1,56 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// $Id: utils.h,v 1.1.1.1 1999-04-09 17:57:56 ansari Exp $
+//
+
+#ifndef UTILS_EA
+#define UTILS_EA
+
+#include "defs.h"
+#include <string.h>
+#include <string>
+#include <stdlib.h>
+#include <stdio.h>
+
+#if defined(__KCC__)
+using std::string ;
+#endif
+
+// MemCpy marche meme en cas de recouvrement.
+// #define memcpy MemCpy
+
+void* MemCpy(void* dest, const void* source, size_t n);
+
+char const* PeidaWorkPath();
+void buildPath(char* dst, const char* dir, const char* file);
+void buildPath(string& dst, const string& dir, const string& file);
+void changeSuffix(char* file, const char* suffix);
+void changeSuffix(string& file, const string& suffix);
+string itos(int);
+string ftos(double);
+
+inline void GetIntEnv(char const* s, int& v)
+{
+  char* pdeb = getenv(s);
+  if (pdeb) v = atoi(pdeb);
+}
+
+/* if defined(__DECCXX) || defined(__xlC) */
+#if defined(__xlC) || defined(__DECCXX)
+#define STRUCTCOMP(s)                        \
+  bool operator==(s const& b) const          \
+{ return memcmp(this, &b, sizeof(s)) == 0; } \
+  bool operator<(s const& b) const           \
+{ return memcmp(this, &b, sizeof(s)) < 0; } 
+  
+#define STRUCTCOMPF(s,f)                        \
+  bool operator==(s const& b) const          \
+{ return f == b.f; }                          \
+  bool operator<(s const& b) const           \
+{ return f < b.f; }
+#else
+#define STRUCTCOMP(s) 
+#define STRUCTCOMPF(s,f)
+#endif
+
+#endif // UTILS_EA
Index: /tags/DPC_V0/SophyaLib/Samba/Makefile
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/Makefile	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/Makefile	(revision 1307)
@@ -0,0 +1,93 @@
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libSamba.a
+clean:
+	rm -f $(OBJ)bruit.o $(OBJ)gorfph.o $(OBJ)localmap.o $(OBJ)mlobe.o $(OBJ)scan.o $(OBJ)spheregorski.o $(OBJ)spherethetaphi.o
+	rm $(LIB)libSamba.a
+$(LIB)libSamba.a : $(OBJ)bruit.o $(OBJ)gorfph.o $(OBJ)localmap.o $(OBJ)mlobe.o $(OBJ)scan.o $(OBJ)spheregorski.o $(OBJ)spherethetaphi.o
+	$(AR) $(ARFLAGS) $@ $?
+ifeq ($(CXX),cxx)
+	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS) -L$(LIB) -lSamba -o $(OBJ)xx.x -Hf
+endif 
+ 
+$(OBJ)bruit.o: bruit.cc $(INC)fmath.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)defs.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)perrors.h \
+ $(INC)datatypes.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h bruit.h \
+ $(INC)nbrandom.h \
+ $(INC)hbook.h
+$(OBJ)gorfph.o: gorfph.cc
+$(OBJ)localmap.o: localmap.cc localmap.h pixelmap.h \
+ $(INC)ppersist.h \
+ $(INC)defs.h \
+ $(INC)machine.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h sphericalmap.h \
+ $(INC)nbmath.h \
+ $(INC)cvector.h \
+ $(INC)matrix.h \
+ $(INC)peida.h \
+ $(INC)utils.h \
+ $(INC)fmath.h
+$(OBJ)mlobe.o: mlobe.cc mlobe.h sphericalmap.h \
+ $(INC)nbmath.h pixelmap.h \
+ $(INC)ppersist.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h \
+ $(INC)cvector.h \
+ $(INC)matrix.h \
+ $(INC)peida.h \
+ $(INC)utils.h \
+ $(INC)fmath.h unitvec.h \
+ $(INC)timing.h
+$(OBJ)scan.o: scan.cc scan.h $(INC)ppersist.h \
+ $(INC)defs.h \
+ $(INC)machine.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h \
+ $(INC)nbmath.h
+$(OBJ)spheregorski.o: spheregorski.cc spheregorski.h sphericalmap.h \
+ $(INC)nbmath.h pixelmap.h \
+ $(INC)ppersist.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h \
+ $(INC)cvector.h \
+ $(INC)matrix.h \
+ $(INC)peida.h \
+ $(INC)utils.h \
+ $(INC)fmath.h \
+ $(INC)strutil.h
+$(OBJ)spherethetaphi.o: spherethetaphi.cc spherethetaphi.h sphericalmap.h \
+ $(INC)nbmath.h pixelmap.h \
+ $(INC)ppersist.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h \
+ $(INC)cvector.h \
+ $(INC)matrix.h \
+ $(INC)peida.h \
+ $(INC)utils.h \
+ $(INC)fmath.h pdataarray.h prefcount.h
Index: /tags/DPC_V0/SophyaLib/Samba/Samba.o.list
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/Samba.o.list	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/Samba.o.list	(revision 1307)
@@ -0,0 +1,7 @@
+bruit.o
+gorfph.o
+localmap.o
+mlobe.o
+scan.o
+spheregorski.o
+spherethetaphi.o
Index: /tags/DPC_V0/SophyaLib/Samba/bruit.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/bruit.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/bruit.cc	(revision 1307)
@@ -0,0 +1,457 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "fmath.h"
+#include "cimage.h"
+
+#include "bruit.h"
+#include "nbrandom.h"
+// #include "rancern.h"
+#include "hbook.h"
+
+//  Le code des classes   NoiseGenerator  RWalkNoise
+
+
+/* --Methode-- */
+NoiseGenerator::NoiseGenerator(float sigma)
+{
+if (sigma < 0.)  sigma = 1.;
+mNCoups = 0;
+mSigma = sigma;
+//printf("-- NoiseGenerator::NoiseGenerator(%g) (Constructeur) ---\n", sigma);
+}
+
+/* --Methode-- */
+NoiseGenerator::~NoiseGenerator()
+{
+    //printf("-- NoiseGenerator::~NoiseGenerator() (Destructeur) --- \n");
+}
+
+/* --Methode-- */
+float NoiseGenerator::Noise()
+{
+mNCoups++;
+return(NorRand()*mSigma);
+}
+
+/* --Methode-- */
+RWalkNoise::RWalkNoise(float sigma)
+    : NoiseGenerator(sigma)
+{
+mState = 0.;
+//printf("--  RWalkNoise::RWalkNoise(%g) (Constructeur) ---\n", sigma);
+}
+
+
+/* --Methode-- */
+RWalkNoise::~RWalkNoise()
+{
+//printf("--  RWalkNoise::~RWalkNoise (Destructeur) ---\n");
+
+}
+
+/* --Methode-- */
+float RWalkNoise::Noise()
+{
+mState += NoiseGenerator::Noise();
+return(mState);
+}
+
+
+/* --Methode-- */
+OOFNoise::OOFNoise(float sigma, int typacf, int mem, float tau)
+    : NoiseGenerator(sigma)
+{
+if (typacf != ACF_Exp)   typacf = ACF_Exp;
+// Fonction d'autocorrelation donnant un bruit en 1/f
+//                  
+mTypACF = typacf;
+if (mem < 1)  mem = 1;
+mMemL = mem;
+if (tau < 1.e-6)  tau = 1.e-6;
+mTau = tau;
+mState = new double[mem];
+mDyn = new double[mem];
+int i;
+mDyn[0]=1.;
+mState[0]=0.;
+for(i=1; i<mem; i++) {
+  mState[i] = 0.;   mDyn[i] = 1./sqrt((double)i);
+}
+//printf("--  OOFNoise::OOFNoise(%g,%d,%d,%g) (Constructeur) ---\n", 
+//       sigma, typacf, mem, tau);
+}
+
+
+/* --Methode-- */
+OOFNoise::~OOFNoise()
+{
+delete[] mState;
+delete[] mDyn;
+// printf("--  OOFNoise::~OOFNoise (Destructeur) ---\n");
+}
+
+
+/* --Methode-- */
+float OOFNoise::Noise()
+{
+int i;
+double rn;
+
+for(i=(mMemL-1); i>0; i--)   mState[i] = mState[i-1];
+mState[0] = NoiseGenerator::Noise();
+rn = 0.;
+for(i=0; i< mMemL; i++)  rn += mDyn[i]*mState[i];
+return(rn);
+}
+
+/* --Methode-- */
+void OOFNoise::Print()
+{
+int i,j;
+printf("OOFNoise::Print()  MemL=%d  Tau= %g \n", mMemL, mTau);
+printf("OOFNoise::Print() Vecteur de Dynamique / Etat : \n");
+for(i=0; i<mMemL-1; i+=2) 
+  printf("%d:   D=%g  S=%g   | %d:  D=%g  S=%g \n", i, 
+         mDyn[i], mState[i], i+1, mDyn[i], mState[i]);   
+return;
+}
+
+/* --Methode-- */
+EXPNoise::EXPNoise(float sigma, int typacf, int mem, float tau)
+    : NoiseGenerator(sigma)
+{
+if (typacf != ACF_Exp)   typacf = ACF_Exp;
+// Fonction d'autocorrelation exponentiel disponible uniquement
+//                  Reza , Juillet 97
+mTypACF = typacf;
+if (mem < 1)  mem = 1;
+mMemL = mem;
+if (tau < 1.e-6)  tau = 1.e-6;
+mTau = tau;
+mState = new double[mem];
+mDyn = new double[mem];
+int i;
+for(i=0; i<mem; i++) {
+  mState[i] = 0.;   mDyn[i] = exp(-(double)i/tau);
+}
+//printf("--  EXPNoise::EXPNoise(%g,%d,%d,%g) (Constructeur) ---\n", 
+//       sigma, typacf, mem, tau);
+}
+
+
+/* --Methode-- */
+EXPNoise::~EXPNoise()
+{
+delete[] mState;
+delete[] mDyn;
+//printf("--  EXPNoise::~EXPNoise (Destructeur) ---\n");
+}
+
+
+/* --Methode-- */
+float EXPNoise::Noise()
+{
+int i;
+double rn;
+
+for(i=(mMemL-1); i>0; i--)   mState[i] = mState[i-1];
+mState[0] = NoiseGenerator::Noise();
+rn = 0.;
+for(i=0; i< mMemL; i++)  rn += mDyn[i]*mState[i];
+return(rn);
+}
+
+/* --Methode-- */
+void EXPNoise::Print()
+{
+int i,j;
+printf("EXPNoise::Print()  MemL=%d  Tau= %g \n", mMemL, mTau);
+printf("EXPNoise::Print() Vecteur de Dynamique / Etat : \n");
+for(i=0; i<mMemL-1; i+=2) 
+  printf("%d:   D=%g  S=%g   | %d:  D=%g  S=%g \n", i, 
+         mDyn[i], mState[i], i+1, mDyn[i], mState[i]);   
+
+return;
+}
+/* --Methode-- */
+MemNoise::MemNoise(float sigma, int mem, float tau, int ava)
+    : NoiseGenerator(sqrtf(fabsf(tau))*sigma)
+{
+/* on tire les instants des impulsions successives selon une
+loi de distance exponentielle de duree tau
+*/
+const int place = 1000;
+mTypACF = ACF_Exp;
+if (mem < 1)  mem = 1;
+mMemL = place;
+mCoupHaut=mem;
+if (tau < 1.)  tau = 1.;
+mTau = tau;
+mStPos = new float[place];
+mStNeg = new float[place];
+mTePos = new float[place];
+mTeNeg = new float[place];
+// printf("apres reservation\n");
+int i;
+for(i=0; i<place; i++)
+{
+mStNeg[i] = 0.; mStPos[i] = 0.;
+}
+// printf("apres initialisation tableaux \n");
+
+mNappel=0;
+mNtirage=1;
+mNappLast=0;
+mMemPos=1;
+mMemNeg=1;
+mduree=0.;
+mTePos[0]=0.;
+mTeNeg[0]=0.;
+mTdernier=0.;
+
+Avance(ava);
+// printf("fin du createur MemNoise \n");
+//printf("--  EXPNoise::EXPNoise(%g,%d,%d,%g) (Constructeur) ---\n", 
+//       sigma, typacf, mem, tau);
+}
+
+
+/* --Methode-- */
+MemNoise::~MemNoise()
+{
+delete[] mStPos;
+delete[] mStNeg;
+delete[] mTePos;
+delete[] mTeNeg;
+//printf("--  EXPNoise::~EXPNoise (Destructeur) ---\n");
+}
+
+/* --Methode-- */
+float MemNoise::Noise()
+{
+return(Avance(0));
+}
+
+/* --Methode-- */
+float MemNoise::Avance(long Asauter)
+{
+int i,j;
+float boum;
+float rn;
+float Somme,SbaryT,Poids,BaryT,Approx,Erreur;
+int nReduit;
+const float epsilon=.05;
+// printf("entree dans methode Noise de MemNoise \n");
+long mNsaut;
+for (mNsaut = Asauter ; mNsaut >= 0 ; mNsaut--)
+    {  // debut mNsaut
+	// printf("mNsaut = %ld\n",mNsaut);
+mNappel++;
+mTdernier += 1.;
+for(i=0; i<mMemPos; i++) mTePos[i] += 1.;
+for(i=0; i<mMemNeg; i++) mTeNeg[i] += 1.;
+
+if (mduree < mTdernier)
+    {
+	/* la duree depuis le dernier tirage est maintenant ecoulee
+	   on commence par remettre a jour le temps ecoule entre la derniere
+	   impulsion (celle qu'on va tirer maintenant) et l'instant present  */
+	   
+	   mTdernier = mTdernier - mduree;
+        
+	/* puis on tire une nouvelle impulsion de bruit */
+
+	   boum =  NoiseGenerator::Noise();
+
+        /* on decale la memoire d'une case vers le passe 
+	   puis on met a jour la case [0] */
+
+if(boum>0)
+    {
+	for(i=mMemPos; i>0; i--)
+	    {
+		mStPos[i] = mStPos[i-1];
+		mTePos[i] = mTePos[i-1];
+	    }
+	mTePos[0] = mTdernier;
+	mStPos[0] = boum;
+	if (mMemPos<mMemL) mMemPos++;
+/* a chaque tirage, on regroupe les impulsions precedentes */
+for(i=mMemPos-2 ; i>0 ; i--)
+    {
+	if(mStPos[i]==0.)continue;
+	//	printf("i,temps,bruit %d,%g,%g \n",i,mTePos[i],mStPos[i]);
+	Somme = mStPos[i]/sqrtf(mTePos[i]);
+	    SbaryT = mStPos[i] * mTePos[i];
+	    Poids = mStPos[i];
+	    for(j=i-1 ; j>=0 ; j--)
+		{
+		    //		printf("  j,temps,bruit %d,%g,%g \n",j,mTePos[j],mStPos[j]);
+		Somme += mStPos[j]/sqrtf(mTePos[j]);
+		    Poids += mStPos[j];
+		    SbaryT += mStPos[j] * mTePos[j];
+		    BaryT = SbaryT / Poids;
+		    Approx = Poids / sqrtf(BaryT);
+		    Erreur = (Approx - Somme) / Somme;
+		    //		    		    printf("i,j = %d %d Approx = %g \n",i,j,fabsf(Erreur));
+		    //		    printf("Temps,Bruit = %g %g \n",BaryT,Poids);
+		    if(fabsf(Erreur)<epsilon)
+			{
+			    mStPos[i]=Poids;
+			    mTePos[i]=BaryT;
+			    mStPos[j]=0.;
+			}
+		    else break;
+		}
+    }
+nReduit=0;
+for(i=0; i<mMemPos-1 ; i++)
+    {
+	if(mStPos[i]!=0)
+	    {
+		mStPos[nReduit]=mStPos[i];
+		mTePos[nReduit]=mTePos[i];
+		nReduit++;
+	    }
+    }
+mMemPos=nReduit+1;
+
+    }
+else
+    {
+	for(i=mMemNeg; i>0; i--)
+	    {
+		mStNeg[i] = mStNeg[i-1];
+		mTeNeg[i] = mTeNeg[i-1];
+	    }
+	mTeNeg[0] = mTdernier;
+	mStNeg[0] = boum;
+	if (mMemNeg<mMemL) mMemNeg++;
+    
+
+/* idem pour negatifs */
+for(i=mMemNeg-2 ; i>0 ; i--)
+    {
+	if(mStNeg[i]==0.)continue;
+	//	printf("i,temps,bruit %d,%g,%g \n",i,mTeNeg[i],mStNeg[i]);
+	Somme = mStNeg[i]/sqrtf(mTeNeg[i]);
+	    SbaryT = mStNeg[i] * mTeNeg[i];
+	    Poids = mStNeg[i];
+	    for(j=i-1 ; j>=0 ; j--)
+		{
+		    //		printf("  j,temps,bruit %d,%g,%g \n",j,mTeNeg[j],mStNeg[j]);
+		Somme += mStNeg[j]/sqrtf(mTeNeg[j]);
+		    Poids += mStNeg[j];
+		    SbaryT += mStNeg[j] * mTeNeg[j];
+		    BaryT = SbaryT / Poids;
+		    Approx = Poids / sqrtf(BaryT);
+		    Erreur = (Approx - Somme) / Somme;
+		    //		    printf("i,j = %d %d Approx = %g \n",i,j,Erreur);
+		    //		    printf("Temps,Bruit = %g %g \n",BaryT,Poids);
+		    if(fabsf(Erreur)<epsilon)
+			{
+			    mStNeg[i]=Poids;
+			    mTeNeg[i]=BaryT;
+			    mStNeg[j]=0.;
+			}
+		    else break;
+		}
+    }
+nReduit=0;
+for(i=0; i<mMemNeg-1 ; i++)
+    {
+	if(mStNeg[i]!=0)
+	    {
+		mStNeg[nReduit]=mStNeg[i];
+		mTeNeg[nReduit]=mTeNeg[i];
+		nReduit++;
+	    }
+    }
+mMemNeg=nReduit+1;
+    }
+/* on tire la duree a attendre avant la prochaine impulsion de bruit */
+// $CHECK$ avec Francois - rndm() remplace par Reza 10/01/99
+mduree = -mTau*log(frand01());  
+
+// if(mNtirage<mMemL) mNtirage++;
+mNtirage++;
+/*
+int idn=1;
+float pds=1.;
+float nul=0.;
+hfill_(&idn,&mduree,&nul,&pds);
+*/
+// printf("Ntirage %d,mMemPos,Neg %d,%d, Suppress = %d \n",mNtirage,mMemPos,mMemNeg, Suppress);
+    }
+/* On calcule le bruit total */
+
+//printf("mMemPos,Neg,%d %d\n",mMemPos,mMemNeg);
+//for(i=0;i<mMemPos;i++) printf("mTePos %g \n",mTePos);
+//for(i=0;i<mMemNeg;i++) printf("mTeNeg %g \n",mTeNeg);
+if(mNsaut == 0)
+    {
+	// printf("coucou\n");
+rn = 0.;
+int indlim=0;
+for(i=0; i < mMemPos-1; i++) 
+{
+if(mTePos[i] > .1)break; 
+rn += mStPos[i];
+indlim++;
+}
+// float ajout=0.;
+for(i=indlim; i < mMemPos-1; i++)  rn += mStPos[i]/sqrtf(mTePos[i]);
+indlim=0;
+for(i=0; i < mMemNeg-1; i++) 
+{
+if(mTeNeg[i] > .1) break;
+rn += mStNeg[i];
+indlim++;
+}
+for(i=indlim; i < mMemNeg-1; i++) rn += mStNeg[i]/sqrtf(mTeNeg[i]);
+}
+}
+return(rn);
+}
+/* --Methode-- */
+
+int MemNoise::Print()
+{
+int i,j,rc=0;
+printf("MemNoise::Print()  MemL=%d  Tau= %g \n", mMemL, mTau);
+printf("mNtirage= %d , mMemPos= %d , mMemNeg= %d \n",mNtirage,mMemPos,mMemNeg);
+// printf("MemNoise::Print() Vecteur de Dynamique / Etat : \n");
+/* for(i=0; i<mMemL-1; i+=2) 
+  printf("%d:   D=%g  S=%g   | %d:  D=%g  S=%g \n", i, 
+         mDyn[i], mState[i], i+1, mDyn[i], mState[i]);   
+	 */
+return(rc);
+}
+
+
+// Generateur de bruit blanc + 1/f avec fknee
+
+
+/* --Methode-- */
+SumNoise::SumNoise(float fknee, float sig)
+    : NoiseGenerator(sig)
+{
+// Reza 27/01/98 :
+// Je calcule les sigma du MemNoise d'apres la formule de Francois 
+mn = new MemNoise(sig*fknee);  
+}
+
+
+/* --Methode-- */
+SumNoise::~SumNoise()
+{
+delete mn;
+}
+
+/* --Methode-- */
+float SumNoise::Noise()
+{
+return(NoiseGenerator::Noise() + mn->Noise());
+}
Index: /tags/DPC_V0/SophyaLib/Samba/bruit.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/bruit.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/bruit.h	(revision 1307)
@@ -0,0 +1,108 @@
+#ifndef BRUIT_H_SEEN
+#define BRUIT_H_SEEN
+
+class NoiseGenerator {
+public :
+			NoiseGenerator(float sigma=1.); 
+  virtual		~NoiseGenerator();
+  virtual float		Noise();
+  inline  unsigned long int           NCoups() { return(mNCoups); }
+
+protected :
+unsigned long  int mNCoups;
+  float mSigma;
+};
+
+class  RWalkNoise : public NoiseGenerator {
+public :
+			RWalkNoise(float sigma=1.);
+  virtual		~RWalkNoise();
+  virtual float		Noise();
+
+protected:
+  float mState;
+};
+
+class OOFNoise : public NoiseGenerator {
+public :
+  enum {
+     ACF_Def = 0,
+     ACF_Exp = 1
+  };
+			OOFNoise(float sigma=1., int typacf=ACF_Exp, 
+                                 int mem=128, float tau=1.);
+  virtual		~OOFNoise();
+  virtual float         Noise();
+  void                  Print();
+
+protected:
+  int mTypACF;
+  int mMemL;
+  float mTau; 
+  double* mState;
+  double* mDyn;
+};
+
+class EXPNoise : public NoiseGenerator {
+public :
+  enum {
+     ACF_Def = 0,
+     ACF_Exp = 1
+  };
+			EXPNoise(float sigma=1., int typacf=ACF_Exp, 
+                                 int mem=128, float tau=1.);
+  virtual		~EXPNoise();
+  virtual float         Noise();
+  void                  Print();
+
+protected:
+  int mTypACF;
+long  int mMemL;
+  float mTau; 
+  double* mState;
+  double* mDyn;
+};
+
+class MemNoise : public NoiseGenerator {
+public :
+  enum {
+     ACF_Def = 0,
+     ACF_Exp = 1
+  };
+			MemNoise(float sigma=1., int mem=128, float tau=1., int ava=4096);
+  virtual		~MemNoise();
+  virtual float         Noise();
+  virtual float         Avance(long Asauter);
+  int                   Print();
+ 
+protected:
+  int mTypACF;
+  int mMemL; int mCoupHaut;
+unsigned long   mNappel;
+unsigned long   mNappLast;
+  float mTeappel;
+  float mTau;
+  float mduree;
+  float mTdernier;
+  int mNtirage;
+  int mMemPos;
+  int mMemNeg;
+  float* mStPos;
+  float* mTePos;
+  float* mStNeg;
+  float* mTeNeg;
+};
+
+class  SumNoise : public NoiseGenerator {
+public :
+			SumNoise(float fknee, float sig=1.);
+  virtual		~SumNoise();
+  virtual float		Noise();
+
+protected:
+  MemNoise* mn;
+};
+
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/Samba/gorfph.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/gorfph.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/gorfph.cc	(revision 1307)
@@ -0,0 +1,39 @@
+#include <iostream.h>
+
+extern "C" {
+void anafast_(int&, int&, int&,double&,float*,float*,float*,float*,
+	      float*,float*,float*);
+void synfast_(int&, int&, int&,int&, float&,float*,float*,float*,
+	      double*, double*,double*,double*,double*,float*);
+void  input_map_(char*,float*,int&);
+void  ecrire_fits_(int&,int&,int&,float*,char*,char*,int&,float&,float&);
+
+}
+
+void anafast_(int&, int&, int&,double&,float*,float*,float*,float*,
+	      float*,float*,float*)
+{
+cerr << "anafast_() bidon ... - Fonction vide - Reza 04/99 " << endl;
+throw " Unsupported function - anafast_() bidon ";
+}
+
+void synfast_(int&, int&, int&,int&, float&,float*,float*,float*,
+	      double*, double*,double*,double*,double*,float*)
+{
+cerr << "synfast_() bidon ... - Fonction vide - Reza 04/99 " << endl;
+throw " Unsupported function - synfast_() bidon ";
+}
+
+void  input_map_(char*,float*,int&)
+{
+cerr << "input_map_() bidon ... - Fonction vide - Reza 04/99 " << endl;
+throw " Unsupported function - input_map_() bidon " ;
+}
+
+void  ecrire_fits_(int&,int&,int&,float*,char*,char*,int&,float&,float&)
+{
+cerr << "ecrire_fits_() bidon ... - Fonction vide - Reza 04/99 " << endl;
+throw " Unsupported function - ecrire_fits_() bidon " ;
+}
+
+
Index: /tags/DPC_V0/SophyaLib/Samba/localmap.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/localmap.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/localmap.cc	(revision 1307)
@@ -0,0 +1,453 @@
+#include "localmap.h"
+#include <iostream.h>
+#include "nbmath.h"
+//*****************************************************************************
+//++ 
+// Class	LocalMap
+//
+// include      localmap.h nbmath.h
+//
+//    A local map of a region of the sky, in cartesian coordinates.
+//    It has an origin in (theta0, phi0), mapped to pixel(x0, y0)
+//    (x0, y0 might be outside of this local map)
+//    default value of (x0, y0) is middle of the map, center of 
+//    pixel(nx/2, ny/2)
+//
+//    la carte est consideree comme un tableau a deux indices i et j, i etant 
+//    indice de colonne et j indice de ligne. La carte est supposee resider 
+//    dans un plan tangent, dont le point de tangence est repere (x0,y0) dans 
+//    la carte et (theta0, phi0) sur la sphere celeste. L'extension de la 
+//    carte est definie par les valeurs de deux angles couverts respectivement
+//    par la totalite des pixels en x de la carte et la totalite des pixels 
+//    en y. (SetSize()).
+//    On considere un "plan de reference" : plan tangent a la sphere celeste 
+//    aux angles theta=Pi/2 et phi=0. Dans ce plan L'origine des coordonnees 
+//    est le point de tangence. L'axe Ox est la tangente parallele a 
+//    l'equateur, dirige vers les phi croissants, l'axe Oy est parallele 
+//    au meridien, dirige vers le pole nord.
+//    De maniere interne a la classe une carte est definie dans ce plan de 
+//    reference et transportee  jusqu'au point (theta0, phi0) de sorte que 
+//    les axes restent paralleles aux meridiens et paralleles. L'utilisateur 
+//    peut definir sa carte selon un repere en rotation par rapport au repere 
+//    de reference (par l'angle entre le parallele et l'axe Ox souhaite -- 
+//    methode SetOrigin(...))
+
+//
+//-- 
+//++
+//
+// Links	Parents
+//
+//    PixelMap
+//    
+//-- 
+//++
+//
+// Links	Descendants
+//
+//     
+//-- 
+//++
+// Titre	Constructeurs
+//--
+//++
+
+LocalMap::LocalMap()
+
+//--
+
+{InitNul();}
+
+//++
+
+LocalMap::LocalMap(int_4 nx, int_4 ny) : mSzX_(nx), mSzY_(ny)
+
+//--
+{
+  InitNul();
+  mNPix_=nx*ny;
+  mPix_ = new r_8[mNPix_];
+}
+
+
+//++
+// Titre	Destructeur
+//--
+//++
+LocalMap::~LocalMap()
+
+//--
+{
+  Clear();
+}
+
+
+
+void        LocalMap::WriteSelf(POutPersist& s) const
+{
+  char strg[256];
+  if (mInfo_) {sprintf(strg, "LocalMap: NPixX=%6d  NPixY=%9d HasInfo",  mSzX_, mSzY_);} else  {
+    sprintf(strg, "LocalMap: NPixX=%6d  NPixY=%9d ",  mSzX_, mSzY_);
+  }	    
+  s.PutLine(strg);
+  if (mInfo_)  mInfo_->Write(s);
+  s.PutI4(mSzX_);
+  s.PutI4(mSzY_);
+  s.PutI4(mNPix_);
+  s.PutI4(x0_);
+  s.PutI4(y0_);
+  s.PutI4(originFlag_);
+  s.PutI4(SzFlag_);
+  s.PutR4(cos_angle_);
+  s.PutR4(sin_angle_);
+  s.PutR8(theta0_);
+  s.PutR8( phi0_);
+  s.PutR8( tgAngleX_);
+  s.PutR8(tgAngleY_);
+  s.PutR8s(mPix_, mNPix_);
+}
+void        LocalMap::ReadSelf(PInPersist& s)
+{
+  Clear();
+  char strg[256];
+  s.GetLine(strg, 255);
+// Pour savoir s'il y avait un DVList Info associe
+  bool hadinfo = false;
+  if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0)  hadinfo = true;
+  if (hadinfo) {    // Lecture eventuelle du DVList Info
+    if (mInfo_ == NULL)  mInfo_ = new DVList;
+    mInfo_->Read(s);
+  }
+  s.GetI4(mSzX_);
+  s.GetI4(mSzY_);
+  s.GetI4(mNPix_);
+  s.GetI4(x0_);
+  s.GetI4(y0_);
+  s.GetI4(originFlag_);
+  s.GetI4(SzFlag_);
+  s.GetR4(cos_angle_);
+  s.GetR4(sin_angle_);
+  s.GetR8(theta0_);
+  s.GetR8( phi0_);
+  s.GetR8( tgAngleX_);
+  s.GetR8(tgAngleY_);
+  mPix_ = new r_8[mNPix_+1];
+  s.GetR8s(mPix_, mNPix_);
+}
+
+//++
+// Titre	Methodes
+//--
+
+
+//++
+int_4 LocalMap::NbPixels() const
+
+//    Retourne le nombre de pixels du découpage
+//--
+{
+  return(mNPix_);
+}
+
+//++
+r_8& LocalMap::PixVal(int_4 k)
+
+//    Retourne la valeur du contenu du pixel d'indice k
+//--
+{
+  if ( (k<0) || (k >= mNPix_) ) {
+    cout << " LocalMap::PIxVal : exceptions  a mettre en place" <<endl;
+    //  THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
+  THROW(rangeCheckErr);
+
+    //throw "LocalMap::PIxVal Pixel index out of range";
+  }
+  //return (*(pixel_->Data()+k));
+  return(mPix_[k]);
+}
+
+//++
+
+r_8 const& LocalMap::PixVal(int_4 k) const
+
+//    Retourne la valeur du contenu du pixel d'indice k
+//--
+{
+  if ( (k<0) || (k >= mNPix_) ) {
+    cout << " LocalMap::PIxVal : exceptions  a mettre en place" <<endl;
+  //    THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
+
+    throw "LocalMap::PIxVal Pixel index out of range"; 
+  } 
+  //return *(pixel_->Data()+k);
+  return(mPix_[k]);
+}
+
+//++
+int_4 LocalMap::PixIndexSph(float theta, float phi) const
+
+//    Retourne l'indice du pixel vers lequel pointe une direction définie par 
+//    ses coordonnées sphériques
+//--
+{
+  int i,j;
+  if (!(originFlag_==1) || !(SzFlag_==1) ) {
+    cout << " LocalMap: correspondance carte-sphere non etablie" << endl;
+    exit(0);
+  }
+  // theta et phi en coordonnees relatives (on se ramene a une situation 
+  // par rapport au plan de reference)
+  float theta_aux=theta;
+  float phi_aux=phi;
+  UserToReference(theta_aux, phi_aux);
+  // coordonnees dans le plan local en unites de pixels
+  float x,y;
+  AngleProjToPix(theta_aux, phi_aux, x,y);
+
+  float xmin=-x0_-0.5;
+  float xmax=xmin+mSzX_;
+  if( (x >  xmax) || (x < xmin ) ) return(-1);
+  float xcurrent=xmin;
+  for( i=0; i < mSzX_; i++ ) {
+    xcurrent += 1.;
+    if( x < xcurrent ) break;
+  }
+  float ymin=-y0_-0.5;
+  float ymax=ymin+mSzY_;
+  if( (y >  ymax) || (y < ymin ) ) return(-1);
+  float ycurrent=ymin;
+  for( j=0; j < mSzY_; j++ ) {
+    ycurrent += 1.;
+    if( y < ycurrent ) break;
+  }
+
+
+  return (j*mSzX_+i);
+}
+
+//++
+void  LocalMap::PixThetaPhi(int_4 k, float& theta, float& phi) const
+
+//    Retourne les coordonnées (theta,phi) du milieu du pixel d'indice k
+//--
+{
+  if (!(originFlag_==1) || !(SzFlag_==1) ) {
+    cout << " LocalMap: correspondance carte-sphere non etablie" << endl;
+    exit(0);
+  }
+  int i,j;
+  Getij(k,i,j);
+  float X=float(i-x0_);
+  float Y=float(j-y0_);
+  // situation de ce pixel dans le plan de reference
+  float x=X*cos_angle_-Y*sin_angle_;
+  float y=X*sin_angle_+Y* cos_angle_;
+  // projection sur la sphere
+  PixProjToAngle(x, y,theta, phi);
+  // retour au plan utilisateur
+  ReferenceToUser(theta, phi);
+}
+ 
+//++
+r_8    LocalMap::PixSolAngle(int_4 k) const
+//    Pixel Solid angle  (steradians)
+//    All the pixels have not necessarly the same size in (theta, phi)
+//    because of the projection scheme which is not yet fixed. 
+//    
+//--
+{
+  int i,j;
+  Getij(k,i,j);
+  float X=float(i-x0_);
+  float Y=float(j-y0_);
+  float XR=X+float(i)*0.5;
+  float XL=X-float(i)*0.5;
+  float YU=Y+float(j)*0.5;
+  float YL=Y-float(j)*0.5;
+  // situation  dans le plan de reference
+  float x0=XL*cos_angle_-YL*sin_angle_;
+  float y0=XL*sin_angle_+YL* cos_angle_;
+  float xa=XR*cos_angle_-YL*sin_angle_;
+  float ya=XR*sin_angle_+YL* cos_angle_;
+  float xb=XL*cos_angle_-YU*sin_angle_;
+  float yb=XL*sin_angle_+YU* cos_angle_;
+  // projection sur la sphere
+  float tet0,phi0,teta,phia,tetb,phib;
+  PixProjToAngle(x0, y0,tet0, phi0);
+  PixProjToAngle(xa, ya,teta, phia);
+  PixProjToAngle(xb, yb,tetb, phib);
+  // angle solide
+  float sol=fabs((xa-x0)*(yb-y0)-(xb-x0)*(ya-y0));
+  return r_8(sol);
+}
+
+
+//++
+void  LocalMap::SetOrigin(float theta0, float phi0, float angle)
+
+//    
+//--
+{
+  theta0_=theta0;
+  phi0_=phi0;
+  x0_=mSzX_/2;
+  y0_=mSzY_/2;
+  angle=angle*Pi/180.;
+  cos_angle_=cos(angle);
+  sin_angle_=sin(angle);
+  originFlag_ =1; 
+}
+
+ 
+//++
+void  LocalMap::SetOrigin(float theta0, float phi0, int_4 x0, int_4 y0, float angle)
+
+//    
+//--
+{
+  theta0_=theta0;
+  phi0_=phi0;
+  x0_=x0;
+  y0_=y0;
+  angle=angle*Pi/180.;
+  cos_angle_=cos(angle);
+  sin_angle_=sin(angle);
+  originFlag_ =1; 
+} 
+
+//++
+void  LocalMap::SetSize(float angleX, float angleY)
+
+//    
+//--
+{
+ tgAngleX_=r_8(tan(angleX*Pi/360.));
+ tgAngleY_=r_8(tan(angleY*Pi/360.));
+ SzFlag_=1;
+}
+//++
+void  LocalMap::Project(SphericalMap& sphere) const
+
+//    Projection to spherical map   
+//--
+{
+  for (int m=0; m<mNPix_; m++) {
+    float theta,phi;
+    PixThetaPhi(m,theta,phi);
+    sphere(theta,phi)=mPix_[m];
+    //    cout << "theta " << theta << " phi " << phi << " valeur " << sphere(theta,phi)<< endl;
+  }
+}
+
+void LocalMap::InitNul()
+//
+//    initialise à zéro certaines variables internes
+{ 
+originFlag_=0;
+SzFlag_=0;
+cos_angle_=1.;
+sin_angle_=0.;
+mPix_=NULL;
+}
+
+void LocalMap::Clear()
+//
+//    
+{ 
+  if (mPix_)   delete[] mPix_;
+}
+
+void    LocalMap::Getij(int k, int& i, int& j) const
+{
+  i=(k+1)%mSzX_-1;
+  if (i==-1) i=mSzX_-1;
+  j=(k-i+2)/mSzX_;
+}
+
+void  LocalMap::ReferenceToUser(float &theta, float &phi) const
+
+//       
+{
+  if (theta > (r_4)Pi || theta < 0.  || phi<0. || phi >=2* (r_4)Pi ) {
+    //cout << " LocalMap::ReferenceToUser : exceptions  a mettre en place" <<endl;
+  //    THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
+
+    throw "LocalMap::ReferenceToUser (theta,phi) out of range"; 
+  } 
+  //cout << " ReferenceToUser entree, t= " << theta << " phi= " << phi << endl;
+  theta=(r_4)theta0_+theta-(r_4)Pi*0.5;
+  if (theta<0.) {
+    theta=-theta;
+    phi+=(r_4)Pi;
+  } else 
+    if (theta>(r_4)Pi) {
+      theta=2.*(r_4)Pi-theta;
+      phi+=(r_4)Pi;
+    } 
+  
+  phi=(r_4)phi0_+phi;
+  while (phi>=2.*(r_4)Pi) phi-=2.*(r_4)Pi;
+  if (theta > (r_4)Pi || theta < 0.  || phi<0. || phi >=2* (r_4)Pi ) {
+    cout <<  " LocalMap::ReferenceToUser : erreur bizarre dans le transfert a la carte utilisateur " << endl;
+    cout << " theta= " << theta << " phi= " << phi << endl;
+    exit(0);
+  }
+  //cout << " ReferenceToUser sortie, t= " << theta << " phi= " << phi << endl;
+}
+
+void  LocalMap::UserToReference(float &theta, float &phi) const
+
+//       
+{
+  if (theta > (r_4)Pi || theta < 0.  || phi<0. || phi >=2* (r_4)Pi ) {
+    cout << " LocalMap::UserToReference : exceptions  a mettre en place" <<endl;
+  //    THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
+
+    throw "LocalMap::UserToReference (theta,phi) out of range"; 
+  } 
+  float phi1=phi-(r_4)phi0_;
+  if (phi1<0.) phi1+=2.*(r_4)Pi;
+
+  float theta1=theta-(r_4)theta0_+(r_4)Pi*0.5;
+  if (theta1<0.) {
+    theta=-theta1;
+    phi1+=(r_4)Pi;
+  } else 
+    if (theta1>(r_4)Pi) {
+      theta=2.*(r_4)Pi-theta1;
+      phi1+=(r_4)Pi;
+    }
+  while (phi1>=2.*(r_4)Pi) phi1-=2.*(r_4)Pi;
+  phi=phi1;
+  if (theta > (r_4)Pi || theta < 0.  || phi<0. || phi >=2* (r_4)Pi ) {
+    cout <<  " LocalMap::UserToReference : erreur bizarre dans le transfert a la carte de reference " << endl;
+    cout << " theta= " << theta << " phi= " << phi << endl;
+    exit(0);
+  }
+}
+
+void LocalMap::PixProjToAngle(float x, float y,float &theta, float &phi) const {
+
+// (x,y) representent les coordonnees en unites de pixels d'un point DANS 
+// LE PLAN DE REFERENCE. On recupere (theta,phi) par rapport au repere "absolu"
+// theta=pi/2,phi=0.
+
+theta=(r_4)Pi*0.5-atan(2*y* tgAngleY_/(float) mSzY_);
+phi=atan2(2*x* tgAngleX_,(float) mSzX_);
+if( phi< 0. ) phi+= DeuxPi;
+}
+
+void  LocalMap::AngleProjToPix(float theta, float phi, float& x, float& y) const {
+
+// (theta,phi) par rapport au repere "absolu" theta=pi/2,phi=0. On recupere 
+// (i,j)  DANS LE PLAN DE REFERENCE. 
+  if (phi>=(r_4)Pi) phi-= DeuxPi;
+  //  y=0.5*mSzY_*cot(theta)/tgAngleY_;  $CHECK-REZA-04/99$
+  y=0.5*mSzY_/tan(theta)/tgAngleY_;  // ? cot = 1/tan ?  
+  x=0.5*mSzX_*tan(phi)/tgAngleX_;
+}
+
+
+
+
+
Index: /tags/DPC_V0/SophyaLib/Samba/localmap.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/localmap.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/localmap.h	(revision 1307)
@@ -0,0 +1,123 @@
+#ifndef LOCALMAP_SEEN
+#define LOCALMAP_SEEN
+
+#include "pixelmap.h"
+#include "sphericalmap.h"
+
+// A local map of a region of the sky, in cartesian coordinates.
+// It has an origin in (theta0, phi0), mapped to pixel(x0, y0)
+//   (x0, y0 might be outside of this local map)
+// default value of (x0, y0) is middle of the map, center of pixel(nx/2, ny/2)
+//
+//    la carte est consideree comme un tableau a deux indices i et j, i etant 
+//    indice de colonne et j indice de ligne. La carte est supposee resider 
+//    dans un plan tangent, dont le point de tangence est repere (x0,y0) dans 
+//    la carte et (theta0, phi0) sur la sphere celeste. L'extension de la 
+//    carte est definie par les valeurs de deux angles couverts respectivement
+//    par la totalite des pixels en x de la carte et la totalite des pixels 
+//    en y. (SetSize()).
+//    On considere un "plan de reference" : plan tangent a la sphere celeste 
+//    aux angles theta=Pi/2 et phi=0. Dans ce plan L'origine des coordonnees 
+//    est le point de tangence. L'axe Ox est la tangente parallele a 
+//    l'equateur, dirige vers les phi croissants, l'axe Oy est parallele 
+//    au meridien, dirige vers le pole nord.
+//    De maniere interne a la classe une carte est definie dans ce plan de 
+//    reference et transportee  jusqu'au point (theta0, phi0) de sorte que les //    axes restent paralleles aux meridiens et paralleles. L'utilisateur peut 
+//    definir sa carte selon un repere en rotation par rapport au repere de 
+//    reference (par l'angle entre le parallele et l'axe Ox souhaite -- 
+//    methode SetOrigin(...))
+
+
+
+
+
+
+
+class LocalMap : public PixelMap {
+public:
+   LocalMap();
+   LocalMap(int_4 nx, int_4 ny);
+   virtual ~LocalMap();
+   // Overloading of () to access pixel number k.
+inline  r_8&        operator()(int_4 k)
+                          {return(PixVal(k));}
+inline  r_8 const&  operator()(int_4 k) const
+                          {return(PixVal(k));}
+inline  r_8&        operator()(int ix, int iy)
+                { return PixVal(iy*mSzX_+ix) ; };
+inline  r_8 const&        operator()(int ix, int iy) const
+                { return PixVal(iy*mSzX_+ix) ; };
+   
+// ---------- Persistence handling
+   
+   enum {classId = 0xF003 };
+int_4               ClassId() const        { return classId; }
+
+virtual void        WriteSelf(POutPersist&) const;
+virtual void        ReadSelf(PInPersist&);
+
+// ---------- Definition of PixelMap abstract methods
+
+   // Number of pixels
+   virtual int_4       NbPixels() const;
+   
+   // Value of pixel number k
+   virtual r_8&        PixVal(int_4 k);
+   virtual r_8 const&  PixVal(int_4 k) const;
+
+   // Index of pixel at (theta,phi)
+   virtual int_4       PixIndexSph(float theta, float phi) const;
+   
+   // Spherical coordinates of center of pixel number k
+   virtual void        PixThetaPhi(int_4 k, float& theta, float& phi) const;
+   // Pixel Solid angle  (steradians)
+   virtual r_8         PixSolAngle(int_4 k) const; 
+
+// ---------- Specific methods
+
+   // Origin (with angle between x axis and phi axis, in degrees)
+    virtual void  SetOrigin(float theta0, float phi0, float angle=0.); // x0,y0 default: middle of map
+  virtual void        SetOrigin(float theta0, float phi0, int_4 x0, int_4 y0, float angle=0.);
+   // Pixel size (degres) 
+   virtual void        SetSize(float angleX, float angleY);
+
+   // Projection to/from spherical map
+   //virtual void        Extract(SphericalMap const& sphere);
+   virtual void        Project(SphericalMap& sphere) const;
+  
+   // There should be a more complex algorithm somewhere to combine *several*
+   // local maps to a full sphere.
+   //   -> static method, or separate class
+
+   void Pixelize(int_4,int_4); // Allocate pixel array
+
+// ------------- méthodes internes ----------------------
+          
+private :
+
+   void	     InitNul();
+   void      Clear();
+   void      Getij(int k, int& i, int& j) const;
+   void      ReferenceToUser(float &theta, float &phi) const; 
+   void      UserToReference(float &theta, float &phi) const;
+   void      PixProjToAngle(float x, float y,float &theta, float &phi) const; 
+   void      AngleProjToPix(float theta, float phi, float& x, float& y) const; 
+// ------------- variables internes -----------------------
+
+   int_4   mSzX_, mSzY_;
+   int_4   mNPix_;
+   int_4   x0_;
+   int_4   y0_;
+   int_4    originFlag_;
+   int_4    SzFlag_;
+   r_4   cos_angle_;
+   r_4   sin_angle_;
+   r_8     theta0_;
+   r_8     phi0_;
+   r_8     omeg_;
+   r_8     tgAngleX_;
+   r_8     tgAngleY_;
+   r_8*    mPix_;
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/Samba/mlobe.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/mlobe.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/mlobe.cc	(revision 1307)
@@ -0,0 +1,172 @@
+#include "mlobe.h"
+#include "unitvec.h"
+
+#include "timing.h"
+// #include "nbrandom.h"
+
+/* --Methode-- */
+MainLobe::MainLobe(float sig, float dels, int nc)
+{
+if (sig < 1.e-9)  sig = M_PI/100.;   // Sigma du lobe gaussien (radians)
+mSigma = sig;
+mDels = (dels < 1.e-5) ?  0.5 : dels;   // Epaisseur de chaque couche en unite de sigma
+mNC =  (nc < 1) ? 1 : nc;
+mNpix = 1;    // Nb total de pixels du lobe
+
+int i,j,k;
+for(i=1; i<=mNC; i++)  mNpix += 6*i;
+//  mT0 , mP0  Teta et Phi des pixels, Pixel 0 oriente vers (0, 0)
+mT0 = new float[mNpix];
+mP0 = new float[mNpix];
+//  mTC , mPC  Teta et Phi des pixels, Pixel 0 oriente vers (Teta, phi)
+mTC = new float[mNpix];
+mPC = new float[mNpix];
+mDx = new float[mNpix];
+mDy = new float[mNpix];
+mDr = new float[mNpix];
+// Valeurs des pixels 
+mVal = new double[mNpix];
+
+
+double teta,phi,dphi;
+double val;
+mT0[0] = mP0[0] = mTC[0] = mPC[0] = 0.;
+mVal[0] = 1.;  mDx[0] = mDy[0] = 0.;
+k = 1;  mTotVal = 1.;
+for(i=1; i<=mNC; i++) {
+  teta = (double)i*mDels;
+  val = exp(-teta*teta);
+  teta *= mSigma;
+  if (i%2)  phi = M_PI/6.;
+  else phi = 0.;
+  dphi = M_PI/(3.*i);
+  for(j=0; j<6*i; j++) {
+    mT0[k] = mTC[k] = teta;
+    phi += dphi;
+    mP0[k] = mPC[k] = phi;
+    mVal[k] = val;
+    mTotVal += val;
+    mDx[k] = teta*cos(phi);
+    mDy[k] = teta*sin(phi);
+    mDr[k] = teta;
+    k++;
+    }
+  }
+mDirTet = mDirPhi = 0.;
+return;
+}
+
+
+/* --Methode-- */
+MainLobe::~MainLobe()
+{
+delete mT0;
+delete mP0;
+delete mTC;
+delete mPC;
+delete mDx;
+delete mDy;
+delete mDr;
+delete mVal;
+}
+
+/* --Methode-- */
+void MainLobe::SetDirection(float teta, float phi)
+{
+int k;
+
+mDirTet = teta;
+mDirPhi = phi;
+
+if (teta < 0.1*mDels*mSigma) {
+  for(k=0; k<mNpix; k++) {
+    mTC[k] = mT0[k]; mPC[k] = mP0[k]; 
+    }
+  return;
+  }
+
+
+/*
+if (teta > 10.*mSigma*mDels*mNC) {   // On utilise des formules approchees
+  float stet = sin((double)teta);
+  float ctet = cos((double)teta);
+  for(k=0; k<mNpix; k++) {
+    mTC[k] = teta - mDy[k]*stet - mDr[k]*ctet;
+    mPC[k] = phi + mDx[k];
+    }
+  return;
+  }
+  */
+
+// Formules compliquees 
+
+double dx,dy,dz;
+double sphi = sin((double)phi);
+double cphi = cos((double)phi);
+double stet = sin((double)teta);
+double ctet = cos((double)teta);
+
+UnitVector pd((double)teta, (double)phi);
+UnitVector vc;
+for(k=0; k<mNpix; k++) {
+  dz = mDy[k]*stet;
+  dx = -(mDx[k]*sphi+mDy[k]*ctet*cphi);
+  dy = mDx[k]*cphi-mDy[k]*ctet*sphi;
+  vc.setxyz(pd.x+dx, pd.y+dy, pd.z+dz);
+  mTC[k] = vc.Teta();
+  mPC[k] = vc.Phi();
+  if (mTC[k] < 0.)  printf("ERREUR !!!! mTC[%d] = %g \n", k, mTC[k]);
+  if (mPC[k] < 0.) mPC[k] += M_PI*2.;
+  if (mPC[k] >= M_PI*2.) mPC[k] -= M_PI*2.;
+  }
+return;  
+}
+
+/* --Methode-- */
+double MainLobe::Value(int kpx, float& teta, float& phi)
+{
+if ( (kpx < 0) || (kpx >= mNpix) ) { teta = phi = 0.; return(0.); }
+teta = mTC[kpx];
+phi = mPC[kpx];
+return(mVal[kpx]);
+}
+
+/* --Methode-- */
+double MainLobe::Convol(SphericalMap& sph)
+{
+double ret=0.;
+int k;
+for(k=0; k<mNpix; k++)  ret += mVal[k]*sph(mTC[k], mPC[k]);
+/*
+if( (dbg > 0) && (k%dbg) ) 
+  printf("MainLobe::Convol k= %d T,P= %g %g , Lobe=%g Sph= %g  Ret=%g\n", 
+         k, mTC[k], mPC[k], mVal[k], sph(mTC[k], mPC[k]), ret );
+*/
+return(ret/mTotVal);
+}
+
+/* --Methode-- */
+ostream& operator << (ostream& s, MainLobe const& lob)
+{
+s << "MainLobe_Info() : Sigma= " << lob.mSigma << " Dels= " << lob.mDels << " NC= " 
+  << lob.mNC << " NTotPix= " << lob.mNpix << " Integ= " << lob.mTotVal << endl;
+
+int i,j,k;
+cout << " Direction Teta,Phi = " << lob.mDirTet << " , " << lob.mDirPhi << endl;      
+cout << " Pixel 0 , Teta= " << lob.mT0[0] << " Phi= " << lob.mP0[0] 
+     << " Val= " << lob.mVal[0] << endl;
+k = 1;
+for(i=1; i<lob.mNC; i++) {
+  cout << " Couche # " << i << " NPix= " << i*6 << endl;
+  for(j=0;j<6*i;j++) {
+    cout << "K= " << k << "Teta,Phi= "  << lob.mTC[k] << ", " << lob.mPC[k] 
+         << " (" << lob.mT0[k] << ", " << lob.mP0[k] << ") "
+         << " Val= " << lob.mVal[k] << endl; 
+    k++;
+    }
+  }
+
+
+return s;
+}
+
Index: /tags/DPC_V0/SophyaLib/Samba/mlobe.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/mlobe.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/mlobe.h	(revision 1307)
@@ -0,0 +1,50 @@
+#ifndef SCSKYU_H_SEEN
+#define SCSKYU_H_SEEN
+
+#include <math.h>
+#include <iostream.h>
+
+#include "sphericalmap.h"
+
+
+
+// Classe MainLobe
+// Classe pour calcul du lobe principal
+// Les valeurs du lobe sont calcules dans des pixels
+// disposes sur "nc" couches avec pavage hexagonal autour de Teta=0, Phi=0
+// Le lobe est gaussien, de sigma = "sig" - Les couches sont construites 
+// toutes les "dels" * sigma 
+// NPix() renvoie le nombre total de pixels du lobe 
+// SetDirection() permet d orienter le lobe dans la direction "teta, phi"
+// Value() renvoie la valeur du lobe, ainsi que les teta,phi du pixel "kpx"
+// Convol() renvoie la valeur lobe convolue avec le ciel (sphere) "sph"
+
+class MainLobe {
+public:
+			MainLobe(float sig, float dels=0.5, int nc=3);
+			~MainLobe();
+        inline int      NPix() {return mNpix; }            
+        inline float    Sigma() {return mSigma; }            
+        inline double   Integral() {return mTotVal; }            
+               void     SetDirection(float teta, float phi);
+	       double   Value(int kpx, float& teta, float& phi);
+               double   Convol(SphericalMap& sph);
+        friend ostream& operator << (ostream& s, MainLobe const& lob);
+	inline void     Print() { cout << (*this); } 
+
+float mSigma, mDels;
+int mNpix, mNC;
+double mTotVal;
+float mDirTet, mDirPhi;
+float* mT0; 
+float* mP0; 
+float* mTC; 
+float* mPC; 
+float* mDx;
+float* mDy;
+float* mDr;
+double* mVal;
+};
+
+
+#endif
Index: /tags/DPC_V0/SophyaLib/Samba/pdataarray.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/pdataarray.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/pdataarray.h	(revision 1307)
@@ -0,0 +1,46 @@
+#ifndef PDATAARRAY_H
+#define PDATAARRAY_H
+#include "prefcount.h"
+
+template <class T>
+class PDataArray : public PRefCounted {
+public:
+                            PDataArray(long n, 
+                                       bool isTmp=false)
+                                                    :PRefCounted(isTmp) 
+                                                    {data = new T[n]; sz=n;}
+                            ~PDataArray()           {delete[] data;}
+  
+  T*                        Data()                  {return data;}
+  T const*                  Data() const            {return data;}
+  long                      Size() const            {return sz;}
+  
+  // Pointeurs/iterateurs
+  T*                        begin()                 {return data;}
+  T const*                  begin() const           {return data;}
+  T*                        end()                   {return data+sz;}
+  T const*                  end() const             {return data+sz;}
+
+  
+  PDataArray<T>*            Clone(bool isTmp=false) const;
+  
+private:
+  T*                        data;
+  int                       sz;
+};
+
+
+template <class T>
+PDataArray<T>* PDataArray<T>::Clone(bool isTmp) const
+{
+#ifdef TRACE_COPY
+  cerr << "PDataArray::Clone" << endl;
+#endif
+   PDataArray<T>* p = new PDataArray<T>(sz, isTmp);
+   memcpy(p->data, data, sz*sizeof(T));
+   return p;
+}
+
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/Samba/pixelmap.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/pixelmap.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/pixelmap.h	(revision 1307)
@@ -0,0 +1,70 @@
+#ifndef PIXELMAP_SEEN
+#define PIXELMAP_SEEN
+
+#include "ppersist.h" 
+#include "dvlist.h"
+#include <iostream.h>
+
+// General map of pixels on part of sphere or whole sphere
+// Class hierarchy :
+//   PixelMap
+//      SphericalMap
+//         SphereThetaPhi
+//         SphereGorski
+//         SphereIco
+//      LocalMap
+
+
+class PixelMap : public PPersist {
+public:
+   PixelMap():mInfo_(NULL) {}
+   virtual ~PixelMap() {}
+   
+   // Number of pixels
+   virtual int_4       NbPixels() const=0;
+   
+   // Value of pixel number k
+   virtual r_8&        PixVal(int_4 k)=0;
+   virtual r_8 const&  PixVal(int_4 k) const=0;
+   
+   // Index of pixel at (theta,phi)
+   virtual int_4       PixIndexSph(float theta, float phi) const=0;
+
+   // Value of pixel number at (theta,phi)
+   virtual r_8&        PixValSph(float theta, float phi)
+                           {return PixVal(PixIndexSph(theta,phi));}
+   virtual r_8 const&  PixValSph(float theta, float phi) const
+                           {return PixVal(PixIndexSph(theta,phi));}                           
+   
+   // Spherical coordinates of center of pixel number k
+   virtual void        PixThetaPhi(int_4 k, float& theta, float& phi) const=0;
+
+   // Pixel  (steradians)
+   virtual r_8         PixSolAngle(int_4 k) const =0; 
+
+   // Overloading of () to access pixel number k.
+   inline  r_8&        operator()(int_4 k)
+                          {return(PixVal(k));}
+   inline  r_8 const&  operator()(int_4 k) const
+                          {return(PixVal(k));}
+
+   // Note : no overloading of (float,float) to access pixel (theta,phi).
+   // overloading of (float,float) in SphericalMap
+   // overloading of (int,int)     in CartesianMap
+
+//++
+DVList&  Info()
+//
+//      Renvoie une rM-ifM-irence sur l'objet DVList AssociM-i
+//--
+{
+if (mInfo_ == NULL)  mInfo_ = new DVList;
+return(*mInfo_);
+}
+
+   protected :
+
+  DVList* mInfo_;        // Infos (variables) attachees 
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/Samba/prefcount.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/prefcount.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/prefcount.h	(revision 1307)
@@ -0,0 +1,65 @@
+#ifndef PREFCOUNT_H
+#define PREFCOUNT_H
+
+// Classe d'objet avec comptage de référence.
+// Le nombre de référence est incrémenté lors de la création et lors d'un Attach
+// (inutile d'appeler Attach si on crée l'objet).
+// Si on cree l'objet avec isTmp = true, alors le possesseur est temporaire,
+// et en tout cas, possede le PRefCount en lecture seule.
+// Par exemple, une fonction qui retourne un objet de type PRefCounted le créera
+// en mode temporaire. Un constructeur par copie appelé derrière ne dupliquera pas
+// les données.
+// HasTmpOnly retourne true si un objet n'est référencé que de façon temporaire.
+
+#ifdef TRACE_REFCOUNT
+#define DBG_DESTROY cerr << "PRefCounted destroyed" << endl;
+#define DBG_ATTACH  cerr << "PRefCounted attached" << endl;
+#define DBG_DETACH  cerr << "PRefCounted detached" << endl;
+#else
+#define DBG_DESTROY 
+#define DBG_ATTACH
+#define DBG_DETACH
+#endif
+
+
+class PRefCounted {
+public:
+                               PRefCounted(bool isTmp=false) 
+                                                        :refcount(1), tmpcount(isTmp?1:0) {}
+  virtual                      ~PRefCounted()           {DBG_DESTROY}
+  
+  void                         Attach(bool isTemp=false) 
+                                                        {if (isTemp && HasTmpOnly()) tmpcount++;
+                                                         DBG_ATTACH
+                                                         refcount++;}
+  void                         Detach()                 {refcount--;
+                                                         DBG_DETACH
+                                                         if (!refcount) delete this;}
+  
+  int                          RefCount() const         {return refcount;}
+  bool                         HasTmpOnly() const       {return tmpcount == refcount;}
+  
+private:
+  int refcount;
+  int tmpcount;
+};
+
+// Macro pour les constructeurs par copie d'objets référençant des PRefCounted
+// Il faut que le PRefCounted ait une méthode T* Clone(bool isTmp);
+
+template <class refcount>
+void PRefCountCopy(refcount*& dest, refcount const* src, bool isTmp=false) {
+  if (dest) dest->Detach();
+  if (!src) {
+    dest=0;
+  } else if (src->HasTmpOnly()) {
+    dest = const_cast<refcount*>(src);
+    dest->Attach(isTmp);
+  } else {
+    dest = src->Clone(isTmp);
+  }
+}
+
+
+#endif
+
Index: /tags/DPC_V0/SophyaLib/Samba/scan.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/scan.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/scan.cc	(revision 1307)
@@ -0,0 +1,331 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "scan.h"
+
+// valeurs de Pi, 2*Pi, etc                                              
+#include "nbmath.h"
+
+
+//
+//++
+// Class	Scan
+//
+// include      scan.h  nbmath.h 
+//
+//    Cette classe permet de stocker et traiter les données pour un balayage 
+//    d'une portion de ciel pour un jeu de valeurs fixé des paramètres précisé
+//    dans le constructeur.    
+//--
+//++
+//
+// Links	Parents
+//
+//    
+//-- 
+//++
+//
+// Links	Descendants
+//
+//     
+//-- 
+//++
+// Titre	Constructeurs
+//--
+//++
+Scan::Scan(float Ouv,float* Omega,float Fech,float T, 
+	   float t0=0., float phi0=0.)
+
+//  
+//    * Ouv      = angle d'ouverture (rad)
+//    * Omega[3] = direction de l'axe de rotation du satellite (teta,phi)
+//    et vitesse de rotation (rad/s)
+//    * Fech     = fréquence d'échantillonnage (Hz)
+//    * T        = temps total de prise des données (s)
+//    * t0       = instant de départ (s)
+//    * phi0     = offset antenne (rad)
+//--
+{
+  mInfo_=NULL;
+  // On memorise les arguments d'appel
+  Ouverture_= Ouv;
+  OmegaTeta_= Omega[0];
+  //
+  // je ne comprends pas ce qui se passe ci-apres (GLM)
+  if( (Omega[0]== 0.0) || (Omega[0]==(float)Pi) ) 
+    OmegaPhi_ = Omega[1];
+  else
+    OmegaPhi_ = Omega[1]+(float)Pi/2.;
+  OmegaRad_ = Omega[2];
+  FrequenceEch_  = Fech;
+  TempsFinal_    = T;
+  TempsInitial_  = t0;
+  PhiZero_ = phi0;
+
+  float aux= 0.0;
+  // Nombre total de points
+  aux= (TempsFinal_-TempsInitial_)*FrequenceEch_;
+  NmaxPts_= (int_4)(aux);
+
+  // Nombre total de tours
+  aux= OmegaRad_*(TempsFinal_-TempsInitial_)/(2.*Pi);
+  NmaxTrs_= (int_4)(aux);
+
+  // Nombre de points par tour
+  aux= 2.*Pi*FrequenceEch_/OmegaRad_;
+  NPts1Tr_= (int_4)(aux);
+
+  // Creation et initialisation du vecteur des mesures aux points
+  sPix_ = new r_8[NmaxPts_];
+  for( int_4 i=0; i<NmaxPts_; i++ )  sPix_[i]= 0.;
+
+  // matrice de passage du systeme lie au satellite au systeme fixe
+
+  Rota_[0]=  cos((double)OmegaPhi_);
+  Rota_[1]= -sin((double)OmegaPhi_)*cos((double)OmegaTeta_);
+  Rota_[2]=  sin((double)OmegaPhi_)*sin((double)OmegaTeta_);
+  Rota_[3]=  sin((double)OmegaPhi_);
+  Rota_[4]=  cos((double)OmegaPhi_)*cos((double)OmegaTeta_);
+  Rota_[5]= -cos((double)OmegaPhi_)*sin((double)OmegaTeta_);
+  Rota_[6]=  0.0;
+  Rota_[7]=  sin((double)OmegaTeta_);
+  Rota_[8]=  cos((double)OmegaTeta_);
+
+
+  // printf("%f  %f  %f \n",Rota_[0],Rota_[1],Rota_[2]);
+  // printf("%f  %f  %f \n",Rota_[3],Rota_[4],Rota_[5]);
+  // printf("%f  %f  %f \n",Rota_[6],Rota_[7],Rota_[8]);
+
+}
+//++
+Scan::Scan(const Scan& s)
+
+//    Constructeur de copie
+//--
+{
+  NmaxPts_      = s. NmaxPts_;
+  Ouverture_    = s.Ouverture_;
+  OmegaTeta_    = s.OmegaTeta_;
+  OmegaPhi_     = s.OmegaPhi_;
+  OmegaRad_     = s.OmegaRad_;
+  FrequenceEch_ = s. FrequenceEch_;
+  TempsFinal_ = s.TempsFinal_;
+  TempsInitial_ = s.TempsInitial_;
+  PhiZero_ = s. PhiZero_;
+  sPix_=new r_8[ NmaxPts_];
+  for (int_4 k=0; k<NmaxPts_; k++)  sPix_[k]=s.sPix_[k];
+  for (int k=0; k<9; k++) Rota_[k]=s. Rota_[k];
+}
+//++
+// Titre	Destructeur
+//--
+//++
+Scan::~Scan()
+
+//     
+//--
+{
+  delete[] sPix_ ;
+}
+//++
+void Scan::WriteSelf(POutPersist& s) const
+
+//    créer un fichier persistant
+//--
+{
+  char strg[256];
+  if (mInfo_) {sprintf(strg, "Scan: Theta=%9f Phi=%9f omega=%9f HasInfo", (float)OmegaTeta_, (float)OmegaPhi_, (float)OmegaRad_);
+  }
+  else {sprintf(strg, "Scan: Theta=%9f Phi=%9f omega=%9f ", (float)OmegaTeta_, (float)OmegaPhi_, (float)OmegaRad_); 
+  }
+  s.PutLine(strg);
+  if (mInfo_)  mInfo_->Write(s);
+   s.PutI4( NmaxPts_);
+  s.PutI4(NmaxTrs_);
+  s.PutI4( NPts1Tr_);
+  s.PutR4(Ouverture_);
+  s.PutR4(OmegaTeta_);
+  s.PutR4(OmegaPhi_);
+  s.PutR4(OmegaRad_);
+  s.PutR4(FrequenceEch_);
+  s.PutR4(TempsFinal_);
+  s.PutR4( TempsInitial_);
+  s.PutR4( PhiZero_);
+  s.PutR8s(sPix_,NmaxPts_);
+  s.PutR8s(Rota_, 9);
+  return;
+}
+
+
+//++
+void Scan::ReadSelf(PInPersist& s) 
+
+//    relire un fichier persistant
+//--
+{
+  Clear();
+  char strg[256];
+  s.GetLine(strg,255);
+// Pour savoir s'il y avait un DVList Info associe
+  bool hadinfo = false;
+  if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0)  hadinfo = true;
+// Pour savoir s'il y avait un DVList Info associe
+  if (hadinfo) {    // Lecture eventuelle du DVList Info
+    if (mInfo_ == NULL)  mInfo_ = new DVList;
+  mInfo_->Read(s);
+  }
+  s.GetI4( NmaxPts_);
+  s.GetI4(NmaxTrs_);
+  s.GetI4( NPts1Tr_);
+  s.GetR4(Ouverture_);
+  s.GetR4(OmegaTeta_);
+  s.GetR4(OmegaPhi_);
+  s.GetR4(OmegaRad_);
+  s.GetR4(FrequenceEch_);
+  s.GetR4(TempsFinal_);
+  s.GetR4( TempsInitial_);
+  s.GetR4( PhiZero_);
+  sPix_=new r_8[NmaxPts_];
+  s.GetR8s(sPix_,NmaxPts_);
+  s.GetR8s(Rota_, 9);
+}
+
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+int_4 Scan::NbPoints() const
+
+//    Retourne le nombre de Points du scan
+//--
+{
+  return(NmaxPts_);
+}
+
+/* --Methode-- */
+//++
+int_4 Scan::NbTours() const
+
+//    Retourne le nombre total de tours
+//--
+{
+  return(NmaxTrs_);
+}
+
+/* --Methode-- */
+//++
+int_4 Scan::NbPts1Tr() const
+
+//    Retourne le nombre de points pour 1 tour
+//--
+{
+  return(NPts1Tr_);
+}
+
+/* --Methode-- */
+//++
+int_4 Scan::ValueIndex(float t) const
+
+//    Retourne l'indice du pixel associé au temps t
+//--
+{
+  int_4 k;
+  float eps= 1.0E-06;
+
+  // verification si t est dans [TempsInitial_,TempsFinal_]
+  if( (t< TempsInitial_) || (t> TempsFinal_) ) {
+    printf("\n ValueIndex:: probleme sur le temps t= %f",t);
+    return(-1);
+  }
+
+  k= (int_4)((t-TempsInitial_)*FrequenceEch_+eps);
+  if ( (k< 0) || (k >= NmaxPts_) ) {
+    printf("\n ValueIndex:: probleme sur l'indice du point k= %d",k); 
+    return(-1);
+  }
+  return(k);
+}
+
+/* --Methode-- */
+//++
+void Scan::Direction(float t, float&  teta , float&  phi)
+
+//    Retourne les coordonnées (teta,phi) du pixel lié au temps t
+//--
+{
+  r_8 alfa,xs,ys,zs,x,y,z;
+
+  // coordonnees dans le systeme du satellite
+  alfa= OmegaRad_*(t-TempsInitial_)+PhiZero_;
+  xs = sin((double)Ouverture_)*cos(alfa);
+  ys = sin((double)Ouverture_)*sin(alfa);
+  zs = cos((double)Ouverture_);
+
+  // coordonnees dans le systeme fixe
+  x = Rota_[0]*xs+Rota_[1]*ys+Rota_[2]*zs;
+  y = Rota_[3]*xs+Rota_[4]*ys+Rota_[5]*zs;
+  z = Rota_[6]*xs+Rota_[7]*ys+Rota_[8]*zs;
+
+  // angles teta,phi
+  teta = acos(z);
+  phi  = atan2(y,x);
+  if( phi< 0. ) phi= DeuxPi+phi;
+}
+
+/* --Methode-- */
+//++
+void Scan::DirectionIndex(int_4 k, float&  teta, float&  phi)
+
+//    Retourne les coordonnées (teta,phi) du pixel d'indice k
+//--
+{
+  float t;
+
+  //recupere le temps associe a l'indice k du pixel
+  t= TempsInitial_+(float)k/FrequenceEch_;
+
+  // angles teta,phi 
+  Direction(t, teta, phi);
+}
+
+static r_8 dummy_pixel = 0;
+/* --Methode-- */
+//++
+r_8& Scan::PixelValue(int_4 k) const
+
+//    Retourne la valeur du contenu du pixel d'indice k
+//--
+{
+  if ( (k<0) || (k >=  NmaxPts_) ) {
+    printf("\n ValueIndex::indice du pixel errone k= %d",k); 
+    return(dummy_pixel);
+  }
+  return(sPix_[k]);
+}
+
+void Scan::Clear() {
+  if (sPix_)  delete[] sPix_;
+}         
+void Scan::InitNull() {
+  sPix_=NULL;
+  mInfo_=NULL;
+}         
+
+
+//++
+// Titre	Opérateurs
+//--
+//++
+// Links	double&        operator()(int_4 k)
+//--
+//++
+//    Surcharge de la parenthese a un indice entier : remplit ou/et renvoie 
+//    la valeur du contenu du pixel d'indice k                               
+//--
+
+
+
+
+
Index: /tags/DPC_V0/SophyaLib/Samba/scan.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/scan.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/scan.h	(revision 1307)
@@ -0,0 +1,88 @@
+#ifndef SCAN_H_SEEN
+#define SCAN_H_SEEN
+
+
+// includes PEIDA
+#include "ppersist.h"
+#include <iostream.h>
+#include "dvlist.h"
+class Scan : public PPersist {
+
+  public  :
+    /* 
+arguments du constructeur : 
+  . ouverture (radians), 
+  . un tableau de 3 reels (deux angles-en radians- definissant la direction de 
+                      l'axe de rotation du satellite + vitesse de rotation 
+                      en radians/s),
+  . frequence d'echantillonnage (Hz), 
+  . instant final de prise de donnees (s),
+deux arguments optionnels :
+  . instant initial pour la prise de donnees
+  . offset d'antenne en angle phi
+  */
+Scan(float,float*,float,float,float,float);
+Scan(const Scan& );
+Scan() { 
+  InitNull();
+  cout << " constructeur de scan par defaut" << endl;
+}
+~Scan();
+
+// ------------ Persistence handling
+
+     enum {classId = 0xF003 };
+int_4                  ClassId() const        { return classId; }
+
+virtual void           WriteSelf(POutPersist&) const;
+virtual void           ReadSelf(PInPersist&);
+
+int_4     NbPoints() const;
+int_4     NbTours() const;
+int_4     NbPts1Tr() const; 
+int_4     ValueIndex(float) const;
+void    Direction(float, float& ,float& );
+void    DirectionIndex(int_4,float& ,float& );
+double& PixelValue(int_4 k) const;
+
+/* Surcharge de la parenthese a un indice entier : remplit ou/et renvoie */
+/* la valeur du contenu du pixel d'indice k                              */ 
+
+  inline  double&        operator()(int_4 k)
+                                      { return(PixelValue(k)) ; } ;
+//++
+DVList&  Info()
+//
+//      Renvoie une reference sur l'objet DVList Associe
+//--
+{
+if (mInfo_ == NULL)  mInfo_ = new DVList;
+return(*mInfo_);
+}
+
+
+  private :
+    
+void          Clear();
+void          InitNull();
+
+int_4 NmaxPts_;
+int_4 NmaxTrs_;
+int_4 NPts1Tr_;
+r_4   Ouverture_;
+r_4   OmegaTeta_;     /* direction de l'axe de rotation du satellite */
+r_4   OmegaPhi_;      /* (radians)                                   */
+r_4   OmegaRad_;      /* vitesse de rotation du satellite (radians/s) */
+r_4   FrequenceEch_;  /* frequence d'echantillonnage (Hz)*/
+r_4   TempsFinal_;
+r_4   TempsInitial_;
+r_4   PhiZero_;       /* Offset antenne (radians)  */
+r_8*  sPix_;          /* valeurs contenues dans chaque pixel */ 
+r_8   Rota_[9];       /* matrice de passage : [Xf]=[Rota][Xs] */
+                      /* Xs : coordonnees dans un systeme lie au satellite*/ 
+                      /* Xf : coordonnees dans un repere "fixe"           */ 
+DVList* mInfo_;        // Infos (variables) attachees 
+};
+
+
+#endif /* SCAN_H_SEEN */
Index: /tags/DPC_V0/SophyaLib/Samba/spheregorski.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/spheregorski.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/spheregorski.cc	(revision 1307)
@@ -0,0 +1,1360 @@
+//
+#include "spheregorski.h"
+#include "strutil.h"
+extern "C" {
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+}
+      
+extern "C" {
+  //void ang2pix_ring_(int&,double&,double&,int&);
+  //void pix2ang_ring_(int&, int&, double&, double&);
+//void ang2pix_nest_(int&,double&,double&,int&);
+  //void pix2ang_nest_(int&, int&, double&, double&);
+//void nest2ring_(int&, int&, int&);
+//void ring2nest_(int&, int&, int&);
+void anafast_(int&, int&, int&,double&,float*,float*,float*,float*,
+	      float*,float*,float*);
+void synfast_(int&, int&, int&,int&, float&,float*,float*,float*,
+	      double*, double*,double*,double*,double*,float*);
+void  input_map_(char*,float*,int&);
+void  ecrire_fits_(int&,int&,int&,float*,char*,char*,int&,float&,float&);
+
+}
+//*******************************************************************
+//++ 
+// Class	SphereGorski
+//
+// include      spheregorski.h strutil.h
+//
+//    Pixelisation Gorski  
+//
+//
+//|    -----------------------------------------------------------------------
+//|     version 0.8.2  Aug97 TAC  Eric Hivon, Kris Gorski
+//|    -----------------------------------------------------------------------
+//
+//    the sphere is split in 12 diamond-faces containing nside**2 pixels each
+//
+//    the numbering of the pixels (in the nested scheme) is similar to
+//    quad-cube
+//    In each face the first pixel is in the lowest corner of the diamond
+//
+//    the faces are                    (x,y) coordinate on each face
+//|        .   .   .   .   <--- North Pole
+//|       / \ / \ / \ / \                          ^        ^     
+//|      . 0 . 1 . 2 . 3 . <--- z = 2/3             \      /      
+//|       \ / \ / \ / \ /                        y   \    /  x   
+//|      4 . 5 . 6 . 7 . 4 <--- equator               \  /                     
+//|       / \ / \ / \ / \                              \/        
+//|      . 8 . 9 .10 .11 . <--- z = -2/3              (0,0) : lowest corner  
+//|       \ / \ / \ / \ /                                  
+//|        .   .   .   .   <--- South Pole
+//|
+//    phi:0               2Pi                                 
+//
+//    in the ring scheme pixels are numbered along the parallels
+//    the first parallel is the one closest to the north pole and so on
+//    on each parallel, pixels are numbered starting from the one closest
+//    to phi = 0
+//
+//    nside DOIT OBLIGATOIREMENT ETRE UNE PUISSANCE DE 2 (<= 8192)
+//--
+//++
+//
+// Links	Parents
+//
+//    SphericalMap 
+//-- 
+//++
+//
+// Links	Descendants
+//
+//     
+//-- 
+
+/* --Methode-- */
+//++
+// Titre	Constructeurs
+//--
+//++
+
+SphereGorski::SphereGorski()
+
+//--
+{
+  InitNul();
+}
+
+/* --Methode-- */
+//++
+SphereGorski::SphereGorski(char* flnm)
+
+//    Constructeur : charge une image à partir d'un fichier 
+//--
+{
+  InitNul();
+  PInPersist s(flnm);
+  Read(s);
+}
+
+//++
+SphereGorski::SphereGorski(int_4 m)
+
+//    Constructeur : m est la variable nside de l'algorithme de Gorski
+//    le nombre total de pixels sera Npix =  12*nside**2
+//    m DOIT OBLIGATOIREMENT ETRE UNE PUISSANCE DE 2 (<= 8192)
+//--
+{
+  //printf(" initialisation par defaut SphereGorski \n");
+  if (m<=0 || m> 8192) {
+    cout << "SphereGorski : m hors bornes [0,8192], m= " << m << endl;
+    exit(1);
+  }
+// verifier que m est une puissance de deux 
+  int_4 x=m;
+  while (x%2==0) x/=2;
+  if (x!=1) {  
+    cout << "SphereGorski : m doit etre une puissance de deux, m= " << m << endl;
+    exit(1);
+  }
+
+  InitNul();
+  Pixelize(m);
+  if (pix2x_==NULL) {
+    pix2x_=new int[1024];
+    pix2y_=new int[1024];
+    mk_pix2xy(pix2x_,pix2y_); 
+  }
+  if (x2pix_==NULL) {
+    x2pix_=new int[128];
+    y2pix_=new int[128];
+    mk_xy2pix(x2pix_,y2pix_); 
+  }
+}
+
+
+
+
+
+
+//++
+// Titre	Destructeur
+//--
+//++
+SphereGorski::~SphereGorski()
+
+//--
+{
+  Clear();
+}
+
+//++
+// Titre	Méthodes
+//--
+
+
+
+
+void  SphereGorski::Pixelize( int_4 m) 
+
+//    prépare la pixelisation Gorski (m a la même signification 
+//    que pour le constructeur)
+//
+//    
+//--
+{
+  
+  // On memorise les arguments d'appel
+  nSide_ = m;  
+  
+  
+  // Nombre total de pixels sur la sphere entiere
+  nPix_=12*nSide_*nSide_;
+
+// pour le moment les tableaux qui suivent seront ranges dans l'ordre 
+// de l'indexation GORSKY "RING"
+// on pourra ulterieurement changer de strategie et tirer profit
+// de la dualite d'indexation GORSKY (RING er NEST) : tout dependra 
+// de pourquoi c'est faire
+
+  // Creation et initialisation du vecteur des contenus des pixels 
+  mPix_ = new r_8[nPix_];
+  for(int i=0; i<nPix_; i++)  mPix_[i] = 0.;
+
+  // solid angle per pixel   
+  omeg_=4*Pi/nPix_;
+}
+
+void SphereGorski::InitNul()
+//
+//    initialise à zéro les variables de classe 
+{
+  nlmax_=0;
+  nmmax_=0;
+  iseed_=0;
+  fwhm_=0.;
+  quadrupole_=0.;
+  sym_cut_deg_=0.;
+  for (int k=0; k<128;k++) powFile_[k]=' ';
+  nSide_=0;
+  nPix_ =0;
+  mPix_ = NULL;
+  pix2x_=NULL;
+  pix2y_=NULL;
+  x2pix_=NULL;
+  y2pix_=NULL;
+  pix2xy_=NULL;
+}
+/* --Methode-- */
+void SphereGorski::Clear()
+
+{
+  if (mPix_)   delete[] mPix_;
+  if (pix2x_)  delete[] pix2x_;
+  if (pix2y_)  delete[] pix2y_;
+  if (x2pix_)  delete[] x2pix_;
+  if (y2pix_)  delete[] y2pix_;
+  if (pix2xy_) delete pix2xy_;
+}
+//++
+void SphereGorski::WriteSelf(POutPersist& s) const
+
+//    créer un fichier image
+//--
+{
+  char strg[256];
+  if (mInfo_) sprintf(strg, "SphereGorski: NSlices=%6d  NPix=%9d HasInfo",  
+                   (int_4)nSide_, (int_4)nPix_);
+  else
+    sprintf(strg, "SphereGorski: nSide=%6d  nPix=%9d ", 
+	  (int_4)nSide_, (int_4)nPix_);
+  s.PutLine(strg);
+  if (mInfo_)  mInfo_->Write(s);
+  s.PutI4(nlmax_);
+  s.PutI4(nmmax_);
+  s.PutI4(iseed_);
+  s.PutI4(nSide_);
+  s.PutI4(nPix_);
+  s.PutR4(fwhm_);
+  s.PutR4(quadrupole_);
+  s.PutR4(sym_cut_deg_);
+  s.PutR8(omeg_);
+  s.PutR8s(mPix_, nPix_);
+  s.PutLine(powFile_);
+  return;
+}
+
+/* --Methode-- */
+//++
+void SphereGorski::ReadSelf(PInPersist& s)
+
+//    relit un fichier d'image
+//--
+{
+  Clear();
+  char strg[256];
+  s.GetLine(strg, 255);
+// Pour savoir s'il y avait un DVList Info associe
+  bool hadinfo = false;
+  if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0)  hadinfo = true;
+  if (hadinfo) {    // Lecture eventuelle du DVList Info
+    if (mInfo_ == NULL)  mInfo_ = new DVList;
+    mInfo_->Read(s);
+  }
+  s.GetI4(nlmax_);
+  s.GetI4(nmmax_);
+  s.GetI4(iseed_);
+  s.GetI4(nSide_);
+  s.GetI4(nPix_);
+  s.GetR4(fwhm_);
+  s.GetR4(quadrupole_);
+  s.GetR4(sym_cut_deg_);
+  mPix_=new r_8[nPix_];
+  s.GetR8(omeg_);
+  s.GetR8s(mPix_, nPix_);
+  s.GetLine(powFile_, 127);
+
+  return;
+}
+
+
+/* --Methode-- */
+//++
+void SphereGorski::ReadFits(char flnm[])
+
+//    remplit la sphere a partir d'un fichier FITS
+//--
+{
+  strip(flnm,'B',' ');
+  if (access(flnm,F_OK) != 0) {perror(flnm); exit(1);}
+  if(!nPix_) {
+    cout << " ReadFits : SphereGorski non pixelisee " << endl;
+    exit(1);
+  }
+  int npixtot=nPix_;
+
+// quand map et mPix_ auront le meme type, map ne sera plus necessaire
+
+  float* map=new float[12*nSide_*nSide_];
+  input_map_(flnm,map,npixtot);
+  // Remplissage de la sphère 
+
+  for(int  j=0; j<nPix_; j++ ) mPix_[j]=(r_8)map[j];
+  delete [] map;
+  
+
+}
+
+/* --Methode-- */
+//++
+void SphereGorski::WriteFits(char flnm[])
+
+//    ecrit la sphere sur un fichier FITS
+
+//--
+{
+  strip(flnm,'B',' ');
+  if (access(flnm,F_OK) == 0) {
+    cout << " SphereGorski::WriteFits : le fichier existe deja" << endl; 
+    exit(1);
+  }
+  //else cout << "un fichier sera cree " << endl;
+  if(!nPix_) {
+    cout << " WriteFits : SphereGorski non pixelisee " << endl;
+    exit(1);
+  }
+
+
+  char infile[128];
+  for (int k=0; k< 128; k++) infile[k]=powFile_[k];
+
+// quand map et mPix_ auront le meme type, map ne sera plus necessaire
+
+  float* map=new float[12*nSide_*nSide_];
+
+  for(int  j=0; j<nPix_; j++ ) map[j]=(float)mPix_[j];
+  int nlmax=nlmax_;
+  int nsmax=nSide_;
+  int nmmax=nmmax_;
+  int iseed=iseed_;
+  float fwhm=fwhm_;
+  float quadrupole=quadrupole_;
+  ecrire_fits_(nlmax,nsmax,nmmax,map,infile,flnm,iseed,fwhm,quadrupole);
+  delete [] map;
+  
+}
+
+/* --Methode-- */
+//++
+int_4 SphereGorski::NbPixels() const
+
+//    Retourne le nombre de pixels du découpage
+//--
+{
+  return(nPix_);
+}
+
+//++
+int_4 SphereGorski::NbThetaSlices() const 
+
+//    Retourne le nombre de tranches en theta sur la sphere
+//--
+{return int_4(4*nSide_-1);}
+
+
+//++
+void  SphereGorski::GetThetaSlice(int_4 index, r_4& theta, Vector& phi, Vector& value) const 
+
+//    Retourne, pour la tranche en theta d'indice 'index' le theta 
+//    correspondant, un vecteur (Peida) contenant les phi des pixels de 
+//    la tranche, un vecteur (Peida) contenant les valeurs de pixel 
+//    correspondantes
+//--
+{
+
+cout << "entree GetThetaSlice, couche no " << index << endl;
+  if (index<0 || index > NbThetaSlices()) {
+    // THROW(out_of_range("SphereGorski::PIxVal Pixel index out of range")); 
+    cout << " SphereGorski::GetThetaSlice : exceptions  a mettre en place" <<endl;
+  THROW(rangeCheckErr);
+  }
+  int_4 iring=0;
+  int lring=0;
+  if (index<nSide_-1) {
+    iring=2*index*(index+1);
+    lring=4*(index+1);
+  }else
+    if (index<3*nSide_) {
+      iring=2*nSide_*(2*index-nSide_+1);
+      lring=4*nSide_;
+    }else
+      {
+	int nc=4*nSide_-1-index;
+	iring=nPix_-2*nc*(nc+1);
+	lring=4*nc;
+      }
+  phi.Realloc(lring);
+  value.Realloc(lring);
+  float T=0.;
+  float F=0.;
+  for (int kk=0; kk<lring;kk++) {
+    PixThetaPhi(kk+iring,T,F);
+    phi(kk)=F;
+    value(kk)=PixVal(kk+iring);
+  }
+  theta=T;
+
+}
+
+
+
+/* --Methode-- */
+//++
+r_8& SphereGorski::PixVal(int_4 k)
+
+//    Retourne la valeur du contenu du pixel d'indice "RING" k 
+//--
+{
+  if ( (k<0) || (k >= nPix_) ) {
+    // THROW(out_of_range("SphereGorski::PIxVal Pixel index out of range")); 
+    cout << " SphereGorski::PIxVal : exceptions  a mettre en place" <<endl;
+  THROW(rangeCheckErr);
+  }
+  return(mPix_[k]);
+}
+
+/* --Methode-- */
+//++
+r_8 const& SphereGorski::PixVal(int_4 k) const
+
+//    Retourne la valeur du contenu du pixel d'indice "RING" k 
+//--
+{
+  if ( (k<0) || (k >= nPix_) ) {
+    //THROW(out_of_range("SphereGorski::PIxVal Pixel index out of range")); 
+    cout << " SphereGorski::PIxVal : exceptions  a mettre en place" <<endl;
+  THROW(rangeCheckErr);
+  }
+  return(mPix_[k]);
+}
+
+
+//++
+r_8& SphereGorski::PixValNest(int_4 k)
+
+//    Retourne la valeur du contenu du pixel d'indice "NESTED" k 
+//--
+{
+  if ( (k<0) || (k >= nPix_) ) { 
+   //THROW(out_of_range("SphereGorski::PIxValNest Pixel index out of range")); 
+    cout << " SphereGorski::PIxValNest : exceptions  a mettre en place" <<endl;
+  THROW(rangeCheckErr);
+  }
+  return mPix_[nest2ring(nSide_,k)];
+}
+//++
+
+r_8 const& SphereGorski::PixValNest(int_4 k) const
+
+//    Retourne la valeur du contenu du pixel d'indice "NESTED" k 
+//--
+{
+  if ( (k<0) || (k >= nPix_) ) { 
+   //THROW(out_of_range("SphereGorski::PIxValNest Pixel index out of range")); 
+    cout << " SphereGorski::PIxValNest : exceptions  a mettre en place" <<endl;
+  THROW(rangeCheckErr);
+  }
+  int_4 pix=nest2ring(nSide_,k);
+  return mPix_[pix];
+}
+
+
+
+/* --Methode-- */
+//++
+int_4 SphereGorski::PixIndexSph(r_4 theta, r_4 phi) const
+
+//    Retourne l'indice "RING" du pixel vers lequel pointe une direction 
+//    définie par ses coordonnées sphériques
+//--
+{
+  return ang2pix_ring(nSide_, double(theta), double(phi));
+}
+
+//++
+int_4 SphereGorski::PixIndexSphNest(r_4 theta, r_4 phi) const
+
+//    Retourne l'indice NESTED" du pixel vers lequel pointe une direction 
+//    définie par ses coordonnées sphériques
+//--
+{
+  return ang2pix_nest(nSide_, double(theta), double(phi));
+}
+
+
+/* --Methode-- */
+//++
+void SphereGorski::PixThetaPhi(int_4 k, r_4& teta, r_4& phi) const
+
+//    Retourne les coordonnées (teta,phi) du milieu du pixel d'indice "RING" k
+//--
+{
+  double t;
+  double p;
+  pix2ang_ring(nSide_,k, t,  p);
+  teta=(r_4)t;
+  phi=(r_4)p;
+}
+
+//++
+r_8       SphereGorski::PixSolAngle(int_4 dummy) const
+//    Pixel Solid angle  (steradians)
+//    All the pixels have the same solid angle. The dummy argument is
+//    for compatibility with eventual pixelizations which would not 
+//    fulfil this requirement.
+//--
+{
+  return omeg_;
+}
+
+
+//++
+void SphereGorski::PixThetaPhiNest(int_4 k, float& teta, float& phi)  const
+
+//    Retourne les coordonnées (teta,phi) du milieu du pixel d'indice 
+//    NESTED k
+//--
+{   
+  double t;
+  double p;
+  pix2ang_nest(nSide_, k, t, p);
+  teta=(r_4)t;
+  phi=(r_4)p;
+}
+
+//++
+int_4 SphereGorski::NestToRing(int_4 k) 
+
+//    conversion d'index NESTD en un index RING
+//
+//--
+{
+  return  nest2ring(nSide_,k);
+}
+//++
+int_4 SphereGorski::RingToNest(int_4 k) 
+//
+//    conversion d'index RING en un index NESTED
+//
+//--
+{
+  return  ring2nest(nSide_,k);
+}
+//++
+void SphereGorski::anharm(int nlmax, float sym_c,float* powspec) 
+//
+//    analyse en harmoniques spheriques des valeurs des pixels de la 
+//    sphere : appel du module anafast (Gorski-Hivon)
+//
+//    "nlmax"   : multipole maximum, nlmax <= 2*nsmax (cf. Nyquist)
+//
+//    "sym c"   : coupure symetrique autour de l'equateur (degres)
+//
+//    "powspec" : tableau resultat (a reserver avant l'appel) de C(l) 
+//    (spectre de puissance)
+//
+//--
+//
+// Pb a resoudre : dans cette classe les valeurs de pixel sont "double"
+// dans anafast le tableau correspondant est "float"
+// pour l'instant on duplique les tableaux, il faudra decider quelque chose
+//
+{ 
+  if (nlmax > 2*nSide_) {
+    cout << " anharm : nlmax= " << nlmax << 
+            " doit etre <= 2*nsmax (cf. Nyquist), soit :" << 2*nSide_ << endl;
+    exit(1);
+  }
+  else {
+    nlmax_=nlmax;
+    nmmax_=nlmax_;
+  }
+  sym_cut_deg_=sym_c;
+  float* map=new float[nPix_];
+  for (int k=0; k<nPix_; k++) map[k]=(float)mPix_[k];
+  int nsmax=nSide_;
+  int nmmax=nmmax_;
+  double sc=(double)sym_cut_deg_;
+  float* alm_T=new float[2*(nlmax+1)*(nmmax+1)];
+  if (powspec==NULL) {
+    
+    cout << 
+      " anharm : un tableau de C_l doit etre alloue avant appel " << endl;
+    exit(1);
+  }
+  float* phas_n=new float[2*(nmmax+1)];
+  float* phas_s=new float[2*(nmmax+1)];
+  float*  dataw =new float[16*nsmax];
+  float*  work =new float[16*nsmax];
+
+  anafast_(nsmax,nlmax,nmmax,sc,map,alm_T, powspec,phas_n,phas_s,dataw,work);
+  quadrupole_=powspec[2];
+  delete [] map;
+  delete [] alm_T;
+  delete [] phas_n;
+  delete [] phas_s;
+  delete [] dataw;
+  delete [] work;
+  
+}
+
+
+//++
+void SphereGorski::synharm(int nlmax, int iseed,float fwhm, float* powspec) 
+//
+//    synthese  des valeurs des pixels de la sphere par l'intermediaire 
+//    des coefficients en harmoniques spheriques reconstitues apartir d'un 
+//    spectre en puissance : appel du module synfast (Gorski-Hivon)
+//
+//    powspec est un tableau (a fournir) de C(l) (spectre de puissance)
+//    Ce tableau doit contenir les valeur de C(l) par ordre 
+//    SEQUENTIEL de l (de l=0 a l=nlmax). IL SERA MODIFIE PAR L'ALGORITHME
+//
+//    nlmax : multipole maximum (nlmax <= 2*nsmax (cf. Nyquist)
+//    iseed : initialisation generation aleatoire (negatif, suggere : -1)
+//    fwhm  : largeur totale a mi-hauteur (minutes d'arc, >=0, ex: 5)
+//--
+// Pb a resoudre : dans cette classe les valeurs de pixel sont "double"
+// dans anafast le tableau correspondant est "float"
+// pour l'instant on duplique les tableaux, il faudra decider quelque chose
+
+{
+  if (nlmax > 2*nSide_) {
+    cout << " sphereGorski::synharm: nlmax= " << nlmax << 
+            " doit etre <= 2*nsmax (cf. Nyquist), soit : " << 2*nSide_ << endl;
+    exit(1);
+  }
+  else {
+    nlmax_=nlmax;
+    nmmax_=nlmax_;
+    quadrupole_=powspec[2];
+  }
+  if (powspec==NULL) {
+    
+    cout << 
+      "sphereGorski::synharm : un tableau de C_l doit etre alloue avant appel"
+	 << endl;
+    exit(1);
+  }
+  iseed_=iseed;
+  fwhm_ =fwhm; 
+  float* map=new float[nPix_];
+  int nsmax=nSide_;
+  int nmmax=nmmax_;
+  float* alm_T=new float[2*(nlmax+1)*(nmmax+1)];
+  
+
+//    tableaux de travail 
+  double* b_north=new double[2*(2*nmmax+1)];
+  double* b_south=new double[2*(2*nmmax+1)];
+  double* bw=new double[2*4*nsmax];
+  double* data=new double[2*4*nsmax];
+  double* work=new double[2*4*nsmax];
+  float* lread=new float[nlmax+1];
+  synfast_(nsmax,nlmax,nmmax,iseed,fwhm, map,alm_T, powspec,
+                  b_north,b_south,bw,data,work,lread);
+  for (int k=0; k<nPix_; k++) mPix_[k]=(double)map[k];
+  delete [] map;
+  delete [] alm_T;
+  delete [] b_north;
+  delete [] b_south;
+  delete [] bw; 
+  delete [] data;
+  delete [] work;
+  delete [] lread;
+
+}
+
+int SphereGorski::nest2ring(int nside, int ipnest) const {
+  /*
+    c=======================================================================
+    subroutine nest2ring(nside, ipnest, ipring)
+    c=======================================================================
+    c     conversion from NESTED to RING pixel number
+    c=======================================================================
+  */
+  // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
+  //  (16/12/98)
+
+      int npix, npface, face_num, ncap, n_before;
+      int ipf, ip_low, ip_trunc, ip_med, ip_hi;
+      int ix, iy, jrt, jr, nr, jpt, jp, kshift, nl4;
+      int ns_max=8192;
+      int jrll[12]={2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};
+      int jpll[12]={1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7};
+
+      if(  nside<1 ||  nside>ns_max ) {
+	cout << "nside out of range" << endl;
+	exit(0);
+      }
+      npix = 12 *  nside* nside;
+      if( ipnest<0 || ipnest>npix-1 ) {
+	cout << "ipnest out of range" << endl;
+	exit(0);
+      }
+
+
+      ncap  = 2* nside*( nside-1);// ! number of points in the North Polar cap
+      nl4   = 4* nside;
+
+      //c     finds the face, and the number in the face
+      npface =  nside* nside;
+      //cccccc      ip = ipnest - 1         ! in {0,npix-1}
+
+      face_num = ipnest/npface;//  ! face number in {0,11}
+      ipf =ipnest%npface;//  ! pixel number in the face {0,npface-1}
+      //c     finds the x,y on the face (starting from the lowest corner)
+      //c     from the pixel number
+      ip_low=ipf%1024;                //   ! content of the last 10 bits
+      ip_trunc =   ipf/1024;         //    ! truncation of the last 10 bits
+      ip_med=ip_trunc%1024;         //     ! content of the next 10 bits
+      ip_hi  =     ip_trunc/1024;//   ! content of the high weight 10 bits
+
+      ix = 1024*pix2x_[ip_hi] + 32*pix2x_[ip_med] + pix2x_[ip_low];
+      iy = 1024*pix2y_[ip_hi] + 32*pix2y_[ip_med] + pix2y_[ip_low];
+
+      //c     transforms this in (horizontal, vertical) coordinates
+      jrt = ix + iy;//  ! 'vertical' in {0,2*(nside-1)}
+      jpt = ix - iy;//  ! 'horizontal' in {-nside+1,nside-1}
+
+      //c     computes the z coordinate on the sphere
+      //      jr =  jrll[face_num+1]*nside - jrt - 1;//   ! ring number in {1,4*nside-1}
+      jr =  jrll[face_num]*nside - jrt - 1;
+      nr = nside;//                  ! equatorial region (the most frequent)
+      n_before = ncap + nl4 * (jr - nside);
+      kshift=(jr - nside)%2;
+      if( jr<nside ) {//then     ! north pole region
+         nr = jr;
+         n_before = 2 * nr * (nr - 1);
+         kshift = 0;
+      }
+      else if( jr>3*nside ) {//then ! south pole region
+         nr = nl4 - jr;
+         n_before = npix - 2 * (nr + 1) * nr;
+         kshift = 0;
+      }
+
+      //c     computes the phi coordinate on the sphere, in [0,2Pi]
+      jp = (jpll[face_num]*nr + jpt + 1 + kshift)/2;//  ! 'phi' number in the ring in {1,4*nr}
+
+      if( jp>nl4 ) jp = jp - nl4;
+      if( jp<1 )   jp = jp + nl4;
+
+      int aux=n_before + jp - 1;
+      return (n_before + jp - 1);// ! in {0, npix-1}
+
+}
+
+void SphereGorski::mk_pix2xy(int *pix2x,int *pix2y) {
+  /*
+    c=======================================================================
+    subroutine mk_pix2xy
+    c=======================================================================
+    c     constructs the array giving x and y in the face from pixel number
+    c     for the nested (quad-cube like) ordering of pixels
+    c
+    c     the bits corresponding to x and y are interleaved in the pixel number
+    c     one breaks up the pixel number by even and odd bits
+    c=======================================================================
+  */
+  // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
+  //  (16/12/98)
+
+      int kpix, jpix, IX, IY, IP, ID;
+      for (int i=0;i<1023;i++ ) pix2x[i]=0;
+
+      for( kpix=0;kpix<1024;kpix++ ) {
+	jpix = kpix;
+	IX = 0;
+	IY = 0;
+	IP = 1 ;//              ! bit position (in x and y)
+	while( jpix!=0 ){// ! go through all the bits
+	  ID=jpix%2;//  ! bit value (in kpix), goes in ix
+	  jpix = jpix/2;
+	  IX = ID*IP+IX;
+	  
+	  ID=jpix%2;//  ! bit value (in kpix), goes in iy
+	  jpix = jpix/2;
+	  IY = ID*IP+IY;
+	  
+	  IP = 2*IP;//         ! next bit (in x and y)
+	}
+	
+	pix2x[kpix] = IX;//     ! in 0,31
+	pix2y[kpix] = IY;//     ! in 0,31
+      }
+}
+
+int SphereGorski::ring2nest(int nside, int ipring) const {
+  /*
+    c=======================================================================
+    subroutine ring2nest(nside, ipring, ipnest)
+    c=======================================================================
+    c     conversion from RING to NESTED pixel number
+    c=======================================================================
+    */
+  // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
+  //  (16/12/98)
+
+  double fihip, hip;
+  int npix, nl2, nl4, ncap, ip, iphi, ipt, ipring1;
+  int     kshift, face_num, nr;
+  int irn, ire, irm, irs, irt, ifm , ifp;
+  int ix, iy, ix_low, ix_hi, iy_low, iy_hi, ipf;
+  int ns_max(8192);
+  
+  // coordinate of the lowest corner of each face
+  int jrll[12]={2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};// ! in unit of nside
+  int jpll[12]={1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7};//! in unit of nside/2
+  
+  if( nside<1 || nside>ns_max ) {
+    cout << "nside out of range" << endl;
+    exit(0);
+  }
+  npix = 12 * nside*nside;
+  if( ipring<0 || ipring>npix-1 ) {
+    cout << "ipring out of range" << endl;
+    exit(0);
+  }
+  
+  nl2 = 2*nside;
+  nl4 = 4*nside;
+  npix = 12*nside*nside;//      ! total number of points
+  ncap = 2*nside*(nside-1);// ! points in each polar cap, =0 for nside =1
+  ipring1 = ipring + 1;
+  
+  //c     finds the ring number, the position of the ring and the face number
+  if( ipring1<=ncap ) {//then
+    
+    hip   = ipring1/2.;
+    fihip = (int)floor ( hip );
+    irn   = (int)floor( sqrt( hip - sqrt(fihip) ) ) + 1;// ! counted from North pole
+    iphi  = ipring1 - 2*irn*(irn - 1);
+    
+    kshift = 0;
+    nr = irn   ;//               ! 1/4 of the number of points on the current ring
+    face_num = (iphi-1) / irn;// ! in {0,3}
+  }
+  else if( ipring1<=nl2*(5*nside+1) ) {//then
+    
+    ip    = ipring1 - ncap - 1;
+    irn   = (int)floor( ip / nl4 ) + nside;//               ! counted from North pole
+    iphi  = (int)fmod(ip,nl4) + 1;
+    
+    kshift  = (int)fmod(irn+nside,2);//  ! 1 if irn+nside is odd, 0 otherwise
+    nr = nside;
+    ire =  irn - nside + 1;// ! in {1, 2*nside +1}
+    irm =  nl2 + 2 - ire;
+    ifm = (iphi - ire/2 + nside -1) / nside;// ! face boundary
+    ifp = (iphi - irm/2 + nside -1) / nside;
+    if( ifp==ifm ) {//then          ! faces 4 to 7
+      face_num = (int)fmod(ifp,4) + 4;
+    }
+    else if( ifp + 1==ifm ) {//then ! (half-)faces 0 to 3
+      face_num = ifp;
+    }
+    else if( ifp - 1==ifm ) {//then ! (half-)faces 8 to 11
+      face_num = ifp + 7;
+    }
+  }
+  else {
+    
+    ip    = npix - ipring1 + 1;
+    hip   = ip/2.;
+    fihip = floor ( hip );
+    irs   = (int)floor( sqrt( hip - sqrt(fihip) ) ) + 1;//  ! counted from South pole
+    iphi  = 4*irs + 1 - (ip - 2*irs*(irs-1));
+    
+    kshift = 0;
+    nr = irs;
+    irn   = nl4 - irs;
+    face_num = (iphi-1) / irs + 8;// ! in {8,11}
+  }
+  
+  //c     finds the (x,y) on the face
+  irt =   irn  - jrll[face_num]*nside + 1;//       ! in {-nside+1,0}
+  ipt = 2*iphi - jpll[face_num]*nr - kshift - 1;// ! in {-nside+1,nside-1}
+
+
+  if( ipt>=nl2 ) ipt = ipt - 8*nside;// ! for the face #4
+  
+  ix =  (ipt - irt ) / 2;
+  iy = -(ipt + irt ) / 2;
+  
+  ix_low = (int)fmod(ix,128);
+  ix_hi  = ix/128;
+  iy_low = (int)fmod(iy,128);
+  iy_hi  = iy/128;
+  ipf =  (x2pix_[ix_hi]+y2pix_[iy_hi]) * (128 * 128)
+    + (x2pix_[ix_low]+y2pix_[iy_low]);
+
+  return (ipf + face_num* nside *nside);//   ! in {0, 12*nside**2 - 1}
+}
+
+void SphereGorski::mk_xy2pix(int *x2pix, int *y2pix) {
+  /*
+    c=======================================================================
+    subroutine mk_xy2pix
+    c=======================================================================
+    c     sets the array giving the number of the pixel lying in (x,y)
+    c     x and y are in {1,128}
+    c     the pixel number is in {0,128**2-1}
+    c
+    c     if  i-1 = sum_p=0  b_p * 2^p
+    c     then ix = sum_p=0  b_p * 4^p
+    c          iy = 2*ix
+    c     ix + iy in {0, 128**2 -1}
+    c=======================================================================
+  */
+  // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
+  //  (16/12/98)
+
+  int K,IP,I,J,ID;
+
+  for( int i(0);i<127;i++ ) x2pix[i]=0;
+  for( I=1;I<=128;I++ ) {
+    J  = I-1;//            !pixel numbers
+    K  = 0;//
+    IP = 1;//
+    truc : if( J==0 ) {
+      x2pix[I-1] = K;
+      y2pix[I-1] = 2*K;
+    }
+    else {
+      ID = (int)fmod(J,2);
+      J  = J/2;
+      K  = IP*ID+K;
+      IP = IP*4;
+      goto truc;
+    }
+  }     
+  //c      endif
+  
+}
+
+int SphereGorski::ang2pix_ring(int nside, double theta, double phi) const {
+    /*
+    c=======================================================================
+    c     gives the pixel number ipix (RING) 
+    c     corresponding to angles theta and phi
+    c=======================================================================
+  */
+  // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
+  //  (16/12/98)
+
+  int nl2, nl4, ncap, npix, jp, jm, ipix1;
+  double  z, za, tt, tp, tmp;
+  int ir, ip, kshift;
+
+  double piover2(Pi/2.);
+  double twopi(2.*Pi);
+  double z0(2./3.);
+  int ns_max(8192);
+
+  if( nside<1 || nside>ns_max ) {
+    cout << "nside out of range" << endl;
+    exit(0);
+  }
+
+  if( theta<0. || theta>Pi) {
+    cout << "theta out of range" << endl;
+    exit(0);
+  }
+
+  z = cos(theta);
+  za = fabs(z);
+  if( phi >= twopi)  phi = phi - twopi;
+  if (phi < 0.)     phi = phi + twopi;
+  tt = phi / piover2;//  ! in [0,4)
+
+  nl2 = 2*nside;
+  nl4 = 4*nside;
+  ncap  = nl2*(nside-1);// ! number of pixels in the north polar cap
+  npix  = 12*nside*nside;
+
+  if( za <= z0 ) {
+    
+    jp = (int)floor(nside*(0.5 + tt - z*0.75));// ! index of  ascending edge line 
+    jm = (int)floor(nside*(0.5 + tt + z*0.75));// ! index of descending edge line
+
+    ir = nside + 1 + jp - jm;// ! in {1,2n+1} (ring number counted from z=2/3)
+    kshift = 0;
+    if (fmod(ir,2)==0.) kshift = 1;// ! kshift=1 if ir even, 0 otherwise
+    
+    ip = (int)floor( ( jp+jm - nside + kshift + 1 ) / 2 ) + 1;// ! in {1,4n}
+    if( ip>nl4 ) ip = ip - nl4;
+    
+    ipix1 = ncap + nl4*(ir-1) + ip ;
+  }
+  else {
+
+    tp = tt - floor(tt);//      !MOD(tt,1.d0)
+    tmp = sqrt( 3.*(1. - za) );
+
+    jp = (int)floor( nside * tp * tmp );// ! increasing edge line index
+    jm = (int)floor( nside * (1. - tp) * tmp );// ! decreasing edge line index
+
+    ir = jp + jm + 1;//        ! ring number counted from the closest pole
+    ip = (int)floor( tt * ir ) + 1;// ! in {1,4*ir}
+    if( ip>4*ir ) ip = ip - 4*ir;
+      
+    ipix1 = 2*ir*(ir-1) + ip;
+      if( z<=0. ) {
+	ipix1 = npix - 2*ir*(ir+1) + ip;
+      }
+  }
+    return (ipix1 - 1);// ! in {0, npix-1}
+  
+}
+
+int SphereGorski::ang2pix_nest(int nside, double theta, double phi) const {
+  /*
+    c=======================================================================
+    subroutine ang2pix_nest(nside, theta, phi, ipix)
+    c=======================================================================
+    c     gives the pixel number ipix (NESTED) 
+    c     corresponding to angles theta and phi
+    c
+    c     the computation is made to the highest resolution available (nside=8192)
+    c     and then degraded to that required (by integer division)
+    c     this doesn't cost more, and it makes sure 
+    c     that the treatement of round-off will be consistent 
+    c     for every resolution
+    c=======================================================================
+  */
+  // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
+  //  (16/12/98)
+    
+      double    z, za, z0, tt, tp, tmp;
+      int face_num,jp,jm;
+      int ifp, ifm;
+      int  ix, iy, ix_low, ix_hi, iy_low, iy_hi, ipf, ntt;
+      double piover2(Pi/2.), twopi(2.*Pi);
+      int ns_max(8192);
+
+      if( nside<1 || nside>ns_max ) {
+	cout << "nside out of range" << endl;
+	exit(0);
+      }
+      if( theta<0 || theta>Pi ) {
+	cout << "theta out of range" << endl;
+	exit(0);
+      }
+      z  = cos(theta);
+      za = fabs(z);
+      z0 = 2./3.;
+      if( phi>=twopi ) phi = phi - twopi;
+      if( phi<0. )    phi = phi + twopi;
+      tt = phi / piover2;// ! in [0,4[
+      if( za<=z0 ) { // then ! equatorial region
+	
+	//(the index of edge lines increase when the longitude=phi goes up)
+	jp = (int)floor(ns_max*(0.5 + tt - z*0.75));// !  ascending edge line index
+	jm = (int)floor(ns_max*(0.5 + tt + z*0.75));// ! descending edge line index
+
+	//c        finds the face
+	ifp = jp / ns_max;//  ! in {0,4}
+	ifm = jm / ns_max;
+        if( ifp==ifm ) face_num = (int)fmod(ifp,4) + 4; //then          ! faces 4 to 7
+	else if( ifp<ifm ) face_num = (int)fmod(ifp,4); // (half-)faces 0 to 3
+	else face_num = (int)fmod(ifm,4) + 8;//! (half-)faces 8 to 11
+
+	ix = (int)fmod(jm, ns_max);
+	iy = ns_max - (int)fmod(jp, ns_max) - 1;
+      }
+      else { //! polar region, za > 2/3
+	     
+	ntt = (int)floor(tt);
+	if( ntt>=4 ) ntt = 3;
+	tp = tt - ntt;
+	tmp = sqrt( 3.*(1. - za) );//  ! in ]0,1]
+
+	//(the index of edge lines increase when distance from the closest pole goes up)
+	jp = (int)floor( ns_max * tp          * tmp );// ! line going toward the pole as phi increases
+	jm = (int)floor( ns_max * (1. - tp) * tmp );// ! that one goes away of the closest pole
+	jp = (int)min(ns_max-1, jp);// ! for points too close to the boundary
+	jm = (int)min(ns_max-1, jm);
+
+	 // finds the face and pixel's (x,y)
+         if( z>=0 ) {
+	   face_num = ntt;//  ! in {0,3}
+            ix = ns_max - jm - 1;
+            iy = ns_max - jp - 1;
+	 }
+         else {
+	   face_num = ntt + 8;// ! in {8,11}
+            ix =  jp;
+            iy =  jm;
+	 }
+      }
+
+      ix_low = (int)fmod(ix,128);
+      ix_hi  =     ix/128;
+      iy_low = (int)fmod(iy,128);
+      iy_hi  =     iy/128;
+      ipf =  (x2pix_[ix_hi]+y2pix_[iy_hi]) * (128 * 128)+ (x2pix_[ix_low]+y2pix_[iy_low]);
+      ipf = ipf / pow(ns_max/nside,2);//  ! in {0, nside**2 - 1}
+      return ( ipf + face_num*pow(nside,2));//    ! in {0, 12*nside**2 - 1}
+}
+
+
+void SphereGorski::pix2ang_ring(int nside, int ipix, double& theta,  double& phi) const {
+  /*
+    c=======================================================================
+    c     gives theta and phi corresponding to pixel ipix (RING) 
+    c     for a parameter nside
+    c=======================================================================
+  */
+  // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
+  //  (16/12/98)
+  
+  int nl2, nl4, npix, ncap, iring, iphi, ip, ipix1;
+  double  fact1, fact2, fodd, hip, fihip;
+  
+  int ns_max(8192);
+  
+  if( nside<1 || nside>ns_max ) {
+    cout << "nside out of range" << endl;
+    exit(0);
+  }
+  npix = 12*nside*nside;      // ! total number of points
+  if( ipix<0 || ipix>npix-1 ) {
+    cout << "ipix out of range" << endl;
+    exit(0);
+  }
+  
+  ipix1 = ipix + 1; // in {1, npix}
+  nl2 = 2*nside;
+  nl4 = 4*nside;
+  ncap = 2*nside*(nside-1);// ! points in each polar cap, =0 for nside =1
+  fact1 = 1.5*nside;
+  fact2 = 3.0*nside*nside;
+  
+  if( ipix1 <= ncap ) {  //! North Polar cap -------------
+    
+    hip   = ipix1/2.;
+    fihip = floor(hip);
+    iring = (int)floor( sqrt( hip - sqrt(fihip) ) ) + 1;// ! counted from North pole
+    iphi  = ipix1 - 2*iring*(iring - 1);
+    
+    theta = acos( 1. - iring*iring / fact2 );
+    phi   = (1.*iphi - 0.5) * Pi/(2.*iring);
+    //    cout << theta << " " << phi << endl;
+  }
+  else if( ipix1 <= nl2*(5*nside+1) ) {//then ! Equatorial region ------
+    
+    ip    = ipix1 - ncap - 1;
+    iring = (int)floor( ip / nl4 ) + nside;// ! counted from North pole
+    iphi  = (int)fmod(ip,nl4) + 1;
+    
+    fodd  = 0.5 * (1 + fmod((double)(iring+nside),2));//  ! 1 if iring+nside is odd, 1/2 otherwise
+    theta = acos( (nl2 - iring) / fact1 );
+    phi   = (1.*iphi - fodd) * Pi /(2.*nside);
+  }
+  else {//! South Polar cap -----------------------------------
+    
+    ip    = npix - ipix1 + 1;
+    hip   = ip/2.;
+    fihip = 1.*hip;
+    iring = (int)floor( sqrt( hip - sqrt(fihip) ) ) + 1;//     ! counted from South pole
+    iphi  = (int)(4.*iring + 1 - (ip - 2.*iring*(iring-1)));
+    
+    theta = acos( -1. + iring*iring / fact2 );
+    phi   = (1.*iphi - 0.5) * Pi/(2.*iring);
+    //    cout << theta << " " << phi << endl;
+  }
+}
+
+void SphereGorski::pix2ang_nest(int nside, int ipix, double& theta, double& phi) const {
+  /*
+    c=======================================================================
+    subroutine pix2ang_nest(nside, ipix, theta, phi)
+    c=======================================================================
+    c     gives theta and phi corresponding to pixel ipix (NESTED) 
+    c     for a parameter nside
+    c=======================================================================
+  */
+  // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
+  //  (16/12/98)
+    
+      int npix, npface, face_num;
+      int  ipf, ip_low, ip_trunc, ip_med, ip_hi;
+      int     ix, iy, jrt, jr, nr, jpt, jp, kshift, nl4;
+      double z, fn, fact1, fact2;
+      double piover2(Pi/2.);
+      int ns_max(8192);
+      
+      
+      // ! coordinate of the lowest corner of each face
+      int jrll[12]={2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};//! in unit of nside
+      int jpll[12]={1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7};// ! in unit of nside/2
+      
+      if( nside<1 || nside>ns_max ) {
+	cout << "nside out of range" << endl;
+	exit(0);
+      }
+      npix = 12 * nside*nside;
+      if( ipix<0 || ipix>npix-1 ) {
+	cout << "ipix out of range" << endl;
+	exit(0);
+      }
+
+      fn = 1.*nside;
+      fact1 = 1./(3.*fn*fn);
+      fact2 = 2./(3.*fn);
+      nl4   = 4*nside;
+
+      //c     finds the face, and the number in the face
+      npface = nside*nside;
+
+      face_num = ipix/npface;//  ! face number in {0,11}
+      ipf = (int)fmod(ipix,npface);//  ! pixel number in the face {0,npface-1}
+
+      //c     finds the x,y on the face (starting from the lowest corner)
+      //c     from the pixel number
+      ip_low = (int)fmod(ipf,1024);//       ! content of the last 10 bits
+      ip_trunc =   ipf/1024 ;//       ! truncation of the last 10 bits
+      ip_med = (int)fmod(ip_trunc,1024);//  ! content of the next 10 bits
+      ip_hi  =     ip_trunc/1024   ;//! content of the high weight 10 bits
+
+      ix = 1024*pix2x_[ip_hi] + 32*pix2x_[ip_med] + pix2x_[ip_low];
+      iy = 1024*pix2y_[ip_hi] + 32*pix2y_[ip_med] + pix2y_[ip_low];
+
+      //c     transforms this in (horizontal, vertical) coordinates
+      jrt = ix + iy;//  ! 'vertical' in {0,2*(nside-1)}
+      jpt = ix - iy;//  ! 'horizontal' in {-nside+1,nside-1}
+
+      //c     computes the z coordinate on the sphere
+      //      jr =  jrll[face_num+1]*nside - jrt - 1;//   ! ring number in {1,4*nside-1}
+      jr =  jrll[face_num]*nside - jrt - 1;
+      nr = nside;//                  ! equatorial region (the most frequent)
+      z  = (2*nside-jr)*fact2;
+      kshift = (int)fmod(jr - nside, 2);
+      if( jr<nside ) { //then     ! north pole region
+         nr = jr;
+         z = 1. - nr*nr*fact1;
+         kshift = 0;
+      }
+      else {
+	if( jr>3*nside ) {// then ! south pole region
+         nr = nl4 - jr;
+         z = - 1. + nr*nr*fact1;
+         kshift = 0;
+	}
+      }
+      theta = acos(z);
+      
+      //c     computes the phi coordinate on the sphere, in [0,2Pi]
+      //      jp = (jpll[face_num+1]*nr + jpt + 1 + kshift)/2;//  ! 'phi' number in the ring in {1,4*nr}
+      jp = (jpll[face_num]*nr + jpt + 1 + kshift)/2;
+      if( jp>nl4 ) jp = jp - nl4;
+      if( jp<1 )   jp = jp + nl4;
+
+      phi = (jp - (kshift+1)*0.5) * (piover2 / nr);
+
+}
+
+
+void SphereGorski::Pix2XY::pix2ang_nest(int nside, int ipix, double& theta, double& phi) const {
+  /*
+    c=======================================================================
+    subroutine pix2ang_nest(nside, ipix, theta, phi)
+    c=======================================================================
+    c     gives theta and phi corresponding to pixel ipix (NESTED) 
+    c     for a parameter nside
+    c=======================================================================
+  */
+  // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
+  //  (16/12/98)
+    
+      int npix, npface, face_num;
+      int  ipf, ip_low, ip_trunc, ip_med, ip_hi;
+      int     ix, iy, jrt, jr, nr, jpt, jp, kshift, nl4;
+      double z, fn, fact1, fact2;
+      double piover2(Pi/2.);
+      int ns_max(8192);
+      
+      
+      // ! coordinate of the lowest corner of each face
+      int jrll[12]={2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};//! in unit of nside
+      int jpll[12]={1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7};// ! in unit of nside/2
+      
+      if( nside<1 || nside>ns_max ) {
+	cout << "nside out of range" << endl;
+	exit(0);
+      }
+      npix = 12 * nside*nside;
+      if( ipix<0 || ipix>npix-1 ) {
+	cout << "ipix out of range" << endl;
+	exit(0);
+      }
+
+      fn = 1.*nside;
+      fact1 = 1./(3.*fn*fn);
+      fact2 = 2./(3.*fn);
+      nl4   = 4*nside;
+
+      //c     finds the face, and the number in the face
+      npface = nside*nside;
+
+      face_num = ipix/npface;//  ! face number in {0,11}
+      ipf = (int)fmod(ipix,npface);//  ! pixel number in the face {0,npface-1}
+
+      //c     finds the x,y on the face (starting from the lowest corner)
+      //c     from the pixel number
+      ip_low = (int)fmod(ipf,1024);//       ! content of the last 10 bits
+      ip_trunc =   ipf/1024 ;//       ! truncation of the last 10 bits
+      ip_med = (int)fmod(ip_trunc,1024);//  ! content of the next 10 bits
+      ip_hi  =     ip_trunc/1024   ;//! content of the high weight 10 bits
+
+      ix = 1024*pix2x_[ip_hi] + 32*pix2x_[ip_med] + pix2x_[ip_low];
+      iy = 1024*pix2y_[ip_hi] + 32*pix2y_[ip_med] + pix2y_[ip_low];
+
+      //c     transforms this in (horizontal, vertical) coordinates
+      jrt = ix + iy;//  ! 'vertical' in {0,2*(nside-1)}
+      jpt = ix - iy;//  ! 'horizontal' in {-nside+1,nside-1}
+
+      //c     computes the z coordinate on the sphere
+      //      jr =  jrll[face_num+1]*nside - jrt - 1;//   ! ring number in {1,4*nside-1}
+      jr =  jrll[face_num]*nside - jrt - 1;
+      nr = nside;//                  ! equatorial region (the most frequent)
+      z  = (2*nside-jr)*fact2;
+      kshift = (int)fmod(jr - nside, 2);
+      if( jr<nside ) { //then     ! north pole region
+         nr = jr;
+         z = 1. - nr*nr*fact1;
+         kshift = 0;
+      }
+      else {
+	if( jr>3*nside ) {// then ! south pole region
+         nr = nl4 - jr;
+         z = - 1. + nr*nr*fact1;
+         kshift = 0;
+	}
+      }
+      theta = acos(z);
+      
+      //c     computes the phi coordinate on the sphere, in [0,2Pi]
+      //      jp = (jpll[face_num+1]*nr + jpt + 1 + kshift)/2;//  ! 'phi' number in the ring in {1,4*nr}
+      jp = (jpll[face_num]*nr + jpt + 1 + kshift)/2;
+      if( jp>nl4 ) jp = jp - nl4;
+      if( jp<1 )   jp = jp + nl4;
+
+      phi = (jp - (kshift+1)*0.5) * (piover2 / nr);
+
+}
+
+
+
Index: /tags/DPC_V0/SophyaLib/Samba/spheregorski.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/spheregorski.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/spheregorski.h	(revision 1307)
@@ -0,0 +1,154 @@
+#ifndef SPHEREGORSKI_SEEN
+#define SPHEREGORSKI_SEEN
+
+#include "sphericalmap.h"
+#include "cvector.h"
+
+// les attributs de classe pix2x_ et pix2y_ sont relatifs a la traduction des 
+// indices  RING en indices NESTED (ou l'inverse). Ce sont des tableaux 
+// d'entiers initialises et remplis par le constructeur. Dans la version 
+// FORTRAN de healpix, il s'agissait de tableaux mis en COMMON. Ils etaient 
+// initialises au premier appel d'une conversion d'indice. Je ne peux pas 
+// garder cette procedure car, par exemple, la fonction PixValNest() const 
+// n'autorisera pas la constitution de ces tableaux (a cause du const). Ainsi, 
+// des la creation d'un objet SphereGorski ces tableaux sont calcules, ce qui 
+// est, certes, inutile si on ne se sert pas des indices NESTED. Ca ne me 
+// rejouit pas, mais c'est le seul moyen que j'ai trouve pour temir compte de 
+// toutes les demandes et des options prises.
+// 
+//                                                G. Le Meur 
+
+class SphereGorski : public SphericalMap {
+public :
+
+
+SphereGorski();
+SphereGorski(int_4 m);
+SphereGorski(char* flnm);
+virtual ~SphereGorski();
+
+// ------------ Persistence handling
+     enum {classId = 0xF002 };
+
+int_4                  ClassId() const        { return classId; }
+
+virtual void           WriteSelf(POutPersist&) const;
+virtual void           ReadSelf(PInPersist&);
+
+// -----------   FITS IO (1D FITS ARRAY)
+void ReadFits(char flnm[] );
+void WriteFits(char flnm[]);
+
+// ------------------ Definition of PixelMap abstract methods
+
+/* Nombre de pixels du decoupage                                         */
+virtual  int_4           NbPixels() const;
+
+/* Valeur du contenu du pixel d'indice "RING" k                                 */
+virtual  r_8&       PixVal(int_4 k);
+virtual  r_8  const&     PixVal(int_4 k) const;
+
+int_4 NbThetaSlices() const;
+void  GetThetaSlice(int_4 index, r_4& theta, Vector& phi, Vector& value) const;
+
+/* Indice "RING" du pixel vers lequel pointe une direction definie par 
+ses  coordonnees spheriques */                                    
+virtual  int_4           PixIndexSph(float theta, float phi) const;
+
+/* Coordonnees spheriques du milieu du pixel d'indice "RING" k       */
+virtual  void          PixThetaPhi(int_4 k, float& teta, float& phi) const;
+
+// Pixel Solid angle  (steradians)
+virtual r_8         PixSolAngle(int_4 dummy) const; 
+
+
+// --------------- Specific methods 
+
+    // NEST indexing
+/* Valeur du contenu du pixel d'indice "NEST" k                                 */
+virtual  r_8&       PixValNest(int_4 k);
+virtual  r_8 const&       PixValNest(int_4 k) const;
+
+/* Indice "NEST" du pixel vers lequel pointe une direction definie par 
+ses  coordonnees spheriques */                                    
+virtual  int_4      PixIndexSphNest(float theta, float phi) const;
+
+/* Coordonnees spheriques du milieu du pixel d'indice "NEST" k       */
+virtual  void       PixThetaPhiNest(int_4 k, float& teta, float& phi) const;
+
+   // algorithme de pixelisation
+void Pixelize(int_4); 
+
+
+/* convertit index nested en ring  */
+int_4 NestToRing(int_4 );
+
+
+/* convertit index ring en nested" */
+int_4 RingToNest(int_4 );
+
+
+/*    analyse en harmoniques spheriques des valeurs des pixels de la 
+   sphere : appel du module anafast (Gorski-Hivon) */
+void anharm(int, float, float*);
+ 
+/*synthese  des valeurs des pixels de la sphere par l'intermediaire 
+  des coefficients en harmoniques spheriques reconstitues apartir d'un 
+  spectre en puissance : appel du module synfast (Gorski-Hivon) */
+void synharm(int , int, float, float* ); 
+
+
+// ------------- méthodes internes ----------------------
+          
+private :
+
+void	      InitNul();
+void          Clear();
+int           nest2ring(int nside, int ipnest) const;
+void          mk_pix2xy(int *pix2x,int *pix2y);
+int           ring2nest(int nside, int ipring) const;
+void          mk_xy2pix(int *x2pix, int *y2pix);
+int           ang2pix_ring(int nside, double theta, double phi) const;
+int           ang2pix_nest(int nside, double theta, double phi) const;
+void          pix2ang_ring(int nside, int ipix, double& theta,  double& phi) const;
+void          pix2ang_nest(int nside, int ipix, double& theta, double& phi) const;
+// ------------- variables internes -----------------------
+		   private :
+class Pix2XY {
+  public :
+Pix2XY() { 
+    pix2x_=new int[1024];
+    pix2y_=new int[1024];
+    mk_pix2xy(pix2x_,pix2y_); 
+  }
+~Pix2XY() {
+  if (pix2x_)  delete[] pix2x_;
+  if (pix2y_)  delete[] pix2y_;
+  }
+void          pix2ang_nest(int nside, int ipix, double& theta, double& phi) const;
+
+private : 
+int *pix2x_;
+int *pix2y_;
+void          mk_pix2xy(int *pix2x,int *pix2y);
+
+};
+
+int nlmax_;
+int nmmax_;
+int iseed_;
+int  nSide_;
+int_4  nPix_;
+int *pix2x_;
+int *pix2y_;
+int *x2pix_;
+int *y2pix_;
+float fwhm_;
+float quadrupole_;
+float sym_cut_deg_;
+r_8  omeg_;
+r_8*    mPix_;
+char powFile_[128];
+Pix2XY *pix2xy_;
+};
+#endif
Index: /tags/DPC_V0/SophyaLib/Samba/spherethetaphi.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/spherethetaphi.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/spherethetaphi.cc	(revision 1307)
@@ -0,0 +1,635 @@
+//
+// 
+#include "spherethetaphi.h"
+#include "nbmath.h"
+#include <iostream.h>
+//***************************************************************
+//++ 
+// Class	SphereThetaPhi
+// 
+//
+// include      spherethetaphi.h nbmath.h 
+//
+//    Découpage de la sphère selon theta et phi, chaque 
+//    hémisphère étant découpé en (m-1) parallèles (l'équateur compte pour du 
+//    beurre), chacune des m bandes de theta ainsi définies étant découpée par 
+//    des méridiens équirepartis, ce découpage étant fait de sorte que tous 
+//    les pixels aient la même surface et soient le plus carré possible.
+//    On commence par découper l'hémisphère de z positif en partant du pôle et 
+//    en allant vers l'équateur. Le premier pixel est la calotte polaire, 
+//    il est circulaire et centré sur theta=0.
+//--
+//++
+//
+// Links	Parents
+//
+//    SphericalMap 
+//-- 
+//++
+//
+// Links	Descendants
+//
+//     
+//-- 
+
+/* --Methode-- */
+//++
+// Titre	Constructeurs
+//--
+//++
+
+
+SphereThetaPhi::SphereThetaPhi()
+
+//--
+{
+  InitNul();
+}
+
+/* --Methode-- */
+//++
+SphereThetaPhi::SphereThetaPhi(char* flnm)
+
+//    Constructeur : charge une image à partir d'un fichier 
+//--
+{
+  InitNul();
+  PInPersist s(flnm);
+  Read(s);
+}
+
+/* --Methode-- */
+
+//++
+SphereThetaPhi::SphereThetaPhi(int_4 m, int_4 pet)
+
+//    Constructeur : m est le nombre de bandes en theta sur un hémisphère 
+//    (la calotte constituant la premiere bande).
+//    pet est le nombre de pixels (pétales) de la bande en contact avec la 
+//    calotte polaire. Pour l'instant pet est inopérant! 
+//--
+{
+  InitNul();
+  Pixelize(m,pet);
+}
+
+
+//++
+// Titre	Destructeur
+//--
+//++
+SphereThetaPhi::~SphereThetaPhi()
+
+//--
+{
+  Clear();
+}
+
+//++
+// Titre	Méthodes
+//--
+void SphereThetaPhi::InitNul()
+//
+//    initialise à zéro les variables de classe pointeurs
+{
+  mTheta = NULL;
+  mNphi = NULL;
+  mTNphi = NULL;
+  // mPix = NULL;
+  _pixel=NULL;
+  mNTheta = mNPet = 0;
+  mNPix = 0;
+}
+
+/* --Methode-- */
+void SphereThetaPhi::Clear()
+
+{
+  if (mTheta)  delete[] mTheta;
+  if (mNphi)  delete[] mNphi;
+  if (mTNphi) delete[] mTNphi;
+  //if (mPix)   delete[] mPix;
+  if (_pixel) _pixel->Detach();
+  mTheta = NULL;
+  mNphi = NULL;
+  mTNphi = NULL;
+  //mPix = NULL;
+  _pixel=NULL;
+  mNTheta = mNPet = 0;
+  mNPix = 0;
+}
+
+/* --Methode-- */
+//++
+void SphereThetaPhi::WriteSelf(POutPersist& s) const
+
+//    créer un fichier image
+//--
+{
+  char strg[256];
+  if (mInfo_) {sprintf(strg, "SphereThetaPhi: NSlices=%6d  NPix=%9d HasInfo", (int_4)mNTheta, (int_4)mNPix);
+  }
+  else { sprintf(strg, "SphereThetaPhi: NSlices=%6d  NPix=%9d ", 
+               (int_4)mNTheta, (int_4)mNPix);
+  }
+  s.PutLine(strg);
+  if (mInfo_)  mInfo_->Write(s);
+   s.PutI4(mNTheta);
+  s.PutI4(mNPet);
+  s.PutI4(mNPix);
+  s.PutR8(mOmeg);
+  s.PutR4s(mTheta, mNTheta+1);
+  s.PutI4s(mNphi, mNTheta);
+  s.PutI4s(mTNphi, mNTheta+1);
+  s.PutR8s(_pixel->Data(), mNPix);
+  //s.PutR8s(mPix, mNPix);
+  return;
+}
+
+/* --Methode-- */
+//++
+void SphereThetaPhi::ReadSelf(PInPersist& s)
+
+//    relit un fichier d'image
+//--
+{
+  Clear();
+  char strg[256];
+  s.GetLine(strg, 255);
+// Pour savoir s'il y avait un DVList Info associe
+  bool hadinfo = false;
+  if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0)  hadinfo = true;
+  if (hadinfo) {    // Lecture eventuelle du DVList Info
+    if (mInfo_ == NULL)  mInfo_ = new DVList;
+    mInfo_->Read(s);
+  }
+  s.GetI4(mNTheta);
+  s.GetI4(mNPet);
+  s.GetI4(mNPix);
+  s.GetR8(mOmeg);
+  mTheta = new r_4[mNTheta+1];
+  mNphi = new int_4[mNTheta];
+  mTNphi = new int_4[mNTheta+1];
+  //mPix = new r_8[mNPix+1];
+  _pixel=new PDataArray<r_8>(mNPix,true);
+  s.GetR4s(mTheta, mNTheta+1);
+  s.GetI4s(mNphi, mNTheta);
+  s.GetI4s(mTNphi, mNTheta+1);
+  s.GetR8s(_pixel->Data(), mNPix);
+  //s.GetR8s(mPix, mNPix);
+  return;
+}
+
+
+/* --Methode-- */
+//++
+int_4 SphereThetaPhi::NbPixels() const
+
+//    Retourne le nombre de pixels du découpage
+//--
+{
+  return(mNPix);
+}
+
+
+static r_8 dummy_pixel = 0;
+
+/* --Methode-- */
+//++
+r_8& SphereThetaPhi::PixVal(int_4 k)
+
+//    Retourne la valeur du contenu du pixel d'indice k
+//--
+{
+  if ( (k<0) || (k >= mNPix) ) {
+    //  THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range"));
+    cout << " SphereThetaPhi::PIxVal : exceptions  a mettre en place" <<endl;
+  THROW(rangeCheckErr);
+
+    //throw "SphereThetaPhi::PIxVal Pixel index out of range";
+  }
+  return (*(_pixel->Data()+k));
+  //return(mPix[k]);
+}
+//++
+r_8 const& SphereThetaPhi::PixVal(int_4 k) const
+
+//    Retourne la valeur du contenu du pixel d'indice k
+//--
+{
+  if ( (k<0) || (k >= mNPix) ) {
+    cout << " SphereThetaPhi::PIxVal : exceptions  a mettre en place" <<endl;
+  //    THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range"));
+
+    throw "SphereThetaPhi::PIxVal Pixel index out of range"; 
+  } 
+  return *(_pixel->Data()+k);
+  //return(mPix[k]);
+}
+
+
+/* --Methode-- */
+//++
+int_4 SphereThetaPhi::PixIndexSph(r_4 theta, r_4 phi) const
+
+//    Retourne l'indice du pixel vers lequel pointe une direction définie par 
+//    ses coordonnées sphériques
+//--
+{
+  r_4 dphi;
+  int_4 i,j,k;
+  bool fgzn = false;
+
+  if( (theta > (r_4)Pi) || (theta < 0. ) ) return(-1);
+  if( (phi < 0.) || (phi > DeuxPi) )  return(-1);
+  if( theta > (r_4)Pi*0.5)  { fgzn = true;  theta = Pi-theta; }
+  
+  // La bande d'indice kt est limitée par les valeurs de theta contenues dans
+  // mTheta[kt] et mTheta[kt+1]
+  for( i=1; i< mNTheta; i++ ) 
+    if( theta < mTheta[i] ) break;
+  
+  dphi= (r_4)DeuxPi/(r_4)mNphi[i-1];
+  
+  if (fgzn)  k= mNPix-mTNphi[i]+(int_4)(phi/dphi);
+  else k= mTNphi[i-1]+(int_4)(phi/dphi); 
+  
+  return(k);
+}
+
+
+/* --Methode-- */
+//++
+void SphereThetaPhi::PixThetaPhi(int_4 k, r_4& theta, r_4& phi) const
+
+//    Retourne les coordonnées (theta,phi) du milieu du pixel d'indice k
+//--
+{
+  int_4 i; 
+  bool fgzn = false;
+  
+  if( (k < 0) || (k >= mNPix) ) {theta = -99999.; phi = -99999.;  return; }
+  if( k >= mNPix/2)  {fgzn = true;  k = mNPix-1-k; }
+
+  // recupère l'indice i de la tranche qui contient le pixel k
+  for( i=0; i< mNTheta; i++ ) 
+    if( k < mTNphi[i+1] ) break;
+
+  // angle theta
+  theta= 0.5*(mTheta[i]+mTheta[i+1]);
+  if (fgzn) theta= Pi-theta;
+  
+  // angle phi
+  k -= mTNphi[i];
+  phi= (r_4)DeuxPi/(r_4)mNphi[i]*(r_4)(k+.5);
+  if (fgzn) phi= DeuxPi-phi;
+
+  return;
+}
+
+
+//++
+r_8         SphereThetaPhi::PixSolAngle(int_4 dummy) const
+//    Pixel Solid angle  (steradians)
+//    All the pixels have the same solid angle. The dummy argument is
+//    for compatibility with eventual pixelizations which would not 
+//    fulfil this requirement.
+//--
+{
+  return mOmeg;
+}
+
+
+/* --Methode-- */
+//++
+void SphereThetaPhi::Limits(int_4 k, r_4& tetMin, r_4& tetMax, 
+			   r_4& phiMin, r_4& phiMax) 
+
+//    Retourne les valeurs de theta et phi limitant le pixel d'indice k
+//--
+  {
+  int_4 j;
+  r_4 dphi;
+  bool fgzn= false;
+  
+  if( (k< 0) || (k >= mNPix) ) {
+    tetMin= -99999.; 
+    phiMin= -99999.;  
+    tetMax= -99999.; 
+    phiMax= -99999.;  
+    return;
+  }
+  
+  // si on se trouve dans l'hémisphère Sud
+  if( k >= mNPix/2 ) { 
+    fgzn= true; 
+    k= mNPix-1-k; 
+  }
+  
+  // on recupere l'indice i de la tranche qui contient le pixel k
+  int i;
+  for( i=0; i< mNTheta; i++ ) 
+    if( k< mTNphi[i+1] ) break;
+  
+  // valeurs limites de theta dans l'hemisphere Nord
+  tetMin= mTheta[i];
+  tetMax= mTheta[i+1];
+  // valeurs limites de theta dans l'hemisphere Sud
+  if (fgzn) {
+    tetMin= Pi-mTheta[i+1];
+    tetMax= Pi-mTheta[i];
+  }
+  
+  // pixel correspondant dans l'hemisphere Nord
+  if (fgzn) k= mTNphi[i+1]-k+mTNphi[i]-1;
+  
+  // indice j de discretisation ( phi= j*dphi )
+  j= k-mTNphi[i];
+  dphi= (r_4)DeuxPi/(r_4)mNphi[i];
+  
+  // valeurs limites de phi 
+  phiMin= dphi*(r_4)(j);
+  phiMax= dphi*(r_4)(j+1);
+  return;
+}
+
+/* --Methode-- */
+//++
+int_4 SphereThetaPhi::NbThetaSlices() const
+
+//    Retourne le nombre de tranches en theta sur la sphere
+//--
+{
+  int_4 nbslices;
+  nbslices= 2*mNTheta;
+  return(nbslices);
+}
+
+/* --Methode-- */
+//++
+int_4 SphereThetaPhi::NPhi(int_4 kt) const
+
+//    Retourne le nombre de pixels en phi de la tranche kt
+//-- 
+{
+  
+  int_4 nbpix;
+  
+  // verification
+  if( (kt< 0) || (kt>= 2*mNTheta) ) return(-1);
+  
+  // si on se trouve dans l'hemisphere Sud
+  if( kt >= mNTheta ) {
+    kt= 2*mNTheta-1-kt; 
+  }
+  
+  // nombre de pixels
+  nbpix= mNphi[kt];
+  return(nbpix);
+}
+
+
+/* --Methode-- */
+//++
+void SphereThetaPhi::Theta(int_4 kt,r_4& tetMin,r_4& tetMax) 
+
+//    Retourne les valeurs de theta limitant la tranche kt
+//--
+{
+  
+  bool fgzn= false;
+  
+  // verification
+  if( (kt< 0) || (kt>= 2*mNTheta) ) {
+    tetMin= -99999.; 
+    tetMax= -99999.; 
+    return;
+  }
+
+  // si on se trouve dans l'hemisphere Sud
+  if( kt >= mNTheta ) {
+    fgzn= true;
+    kt= 2*mNTheta-1-kt; 
+  }
+  
+  // valeurs limites de theta dans l'hemisphere Nord
+  tetMin= mTheta[kt];
+  tetMax= mTheta[kt+1];
+  // valeurs limites de theta dans l'hemisphere Sud
+  if (fgzn) {
+    tetMin= Pi-mTheta[kt+1];
+    tetMax= Pi-mTheta[kt];
+  }  
+}
+
+/* --Methode-- */
+//++
+void SphereThetaPhi::Phi(int_4 kt,int_4 jp,r_4& phiMin,r_4& phiMax) 
+
+//    Retourne les valeurs de phi limitant le pixel jp de la tranche kt
+//--
+{
+  
+  r_4 dphi;
+  
+  // verification
+  if( (kt< 0) || (kt>= 2*mNTheta) ) {
+    phiMin= -99999.; 
+    phiMax= -99999.; 
+    return;
+  }
+  
+  // si on se trouve dans l'hemisphere Sud
+  if( kt >= mNTheta ) kt= 2*mNTheta-1-kt;
+  
+  // verifie si la tranche kt contient au moins jp pixels
+  if( (jp< 0) || (jp >= mNphi[kt]) ) {
+    phiMin= -88888.; 
+    phiMax= -88888.; 
+    return;
+  }
+  
+  dphi= (r_4)DeuxPi/(r_4)mNphi[kt];
+  phiMin= dphi*(r_4)(jp);
+  phiMax= dphi*(r_4)(jp+1);
+  return;
+}
+
+/* --Methode-- */
+//++
+int_4 SphereThetaPhi::Index(int_4 kt,int_4 jp) const
+
+//    Retourne l'indice du pixel d'indice jp dans la tranche kt 
+//--
+{
+  
+  int_4 k;
+  bool fgzn= false;
+  
+  // si on se trouve dans l'hemisphere Sud
+  if( kt >= mNTheta ) {
+    fgzn= true; 
+    kt= 2*mNTheta-1-kt;
+  }
+  
+  // si la tranche kt contient au moins i pixels
+  if( (jp>=0) && (jp<mNphi[kt]) ) {
+    // dans l'hemisphere Sud
+    if (fgzn) k= mNPix-mTNphi[kt+1]+jp;
+    // dans l'hemisphere Nord
+    else k= mTNphi[kt]+jp;
+  }
+  else{
+    k= 9999;
+    printf("\n la tranche %d ne contient pas un pixel de rang %d",kt,jp);
+  }
+  return(k);
+}
+
+/* --Methode-- */
+//++
+void SphereThetaPhi::ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp) 
+
+//    Retourne les indices kt et jp du pixel d'indice k
+//--
+{
+  
+  bool fgzn= false;
+  
+  // si on se trouve dans l'hemisphere Sud
+  if( k >= mNPix/2 ) { 
+    fgzn= true; 
+    k= mNPix-1-k; 
+  }
+  
+  // on recupere l'indice kt de la tranche qui contient le pixel k
+  int i;
+  for( i=0; i< mNTheta; i++ ) 
+    if( k< mTNphi[i+1] ) break;
+  
+  // indice  kt de tranche
+  if (fgzn) kt= 2*mNTheta-1-i;
+  else kt= i;
+  
+  // indice jp de pixel
+  if (fgzn) jp= mTNphi[i+1]-k-1;
+  else jp= k-mTNphi[i];
+  
+}
+//++
+void  SphereThetaPhi::Pixelize( int_4 m, int_4 pet) 
+
+//    effectue le découpage en pixels (m et pet ont la même signification 
+//    que pour le constructeur)
+//
+//    Chaque bande de theta sera découpée en partant de phi=0 ...
+//    L'autre hémisphère est parcourue dans le même sens en phi et de
+//    l'équateur vers le pôle (le pixel qui suit le dernier de la bande la plus
+//    proche de l'équateur a z>0 est celui de plus petit phi de la bande la 
+//    plus proche de l'equateur a z<0).
+//--
+{
+  int_4 ntotpix,i,j;
+  //r_8 x, omeg, omeg2pi, teti, tetm, tet, nphi, costeti;
+  r_8 omeg2pi;
+  // Decodage et controle des arguments d'appel :
+  // au moins 2 et au plus 16384 bandes d'un hemisphere en theta
+  if (m < 2) m = 2;
+  if (m > 16384) m = 16384;
+  
+  // Au moins 4 et au plus 256 pixels dans la premiere bande decoupee en phi
+  if (pet < 4) pet = 4;
+  if (pet > 256) pet = 256;
+  
+  // On memorise les arguments d'appel
+  mNTheta = m;  mNPet = pet;
+  
+  // On commence par decouper l'hemisphere z>0.
+  // Creation des vecteurs contenant :
+  // Les valeurs limites de theta (une valeur de plus que le nombre de bandes...)
+  mTheta = new r_4[m+1];
+  
+  // Le nombre de pixels en phi de chacune des bandes en theta
+  mNphi = new int_4[m];
+  
+  // Le nombre/Deuxpi total des pixels contenus dans les bandes de z superieur a une
+  // bande donnee (mTPphi[m] contient le nombre de pixels total de l'hemisphere)
+  mTNphi = new int_4[m+1];
+  
+  // Calcul du nombre total de pixels dans chaque bande pour optimiser
+  // le rapport largeur/hauteur des pixels 
+  
+  //calotte polaire
+  mTNphi[0]=0;
+  mNphi[0] = 1;
+  
+  //bandes jusqu'a l'equateur
+  for(j=1; j < m; j++) {
+    mTNphi[j] = mTNphi[j-1]+mNphi[j-1];
+    mNphi[j]  = (int_4)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ;
+  }
+  
+  // Nombre total de pixels sur l'hemisphere
+  ntotpix = mTNphi[m-1]+mNphi[m-1];
+  mTNphi[m] = ntotpix;
+  // et sur la sphere entiere
+  mNPix=2*ntotpix;
+  
+  // Creation et initialisation du vecteur des contenus des pixels 
+  //mPix = new r_8[mNPix];
+  //for(i=0; i<mNPix; i++)  mPix[i] = 0.;
+  _pixel=new PDataArray<r_8>(mNPix,true);
+  for(i=0; i<mNPix; i++)  *(_pixel->Data()+i)=0.;
+  // Determination des limites des bandes en theta :
+  // omeg est l'angle solide couvert par chaque pixel,
+  // une bande donnee kt couvre un angle solide mNphi[kt]*omeg
+  // egal a 2* Pi*(cos mTheta[kt]-cos mTheta[kt+1]). De meme, l'angle solide 
+  //de la
+  // calotte allant du pole a la limite haute de la bande kt vaut
+  // 2* Pi*(1.-cos mTheta[kt+1])= mTNphi[kt]*omeg...
+  
+  omeg2pi = 1./(r_8)ntotpix;
+  mOmeg = omeg2pi*DeuxPi;
+  
+  for(j=0; j <= m; j++) {
+    mTheta[j] = acos(1.-(double)mTNphi[j]*omeg2pi);
+  }
+}
+
+
+//++
+void  SphereThetaPhi::GetThetaSlice(int_4 index, r_4& theta, Vector& phi, Vector& value) const 
+
+//    Retourne, pour la tranche en theta d'indice 'index' le theta 
+//    correspondant, un vecteur (Peida) contenant les phi des pixels de 
+//    la tranche, un vecteur (Peida) contenant les valeurs de pixel 
+//    correspondantes
+//--
+
+{
+  cout << "entree GetThetaSlice, couche no " << index << endl;
+  if (index<0 || index > NbThetaSlices()) {
+    // THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 
+    cout << " SphereThetaPhi::GetThetaSlice : exceptions  a mettre en place" <<endl;
+  THROW(rangeCheckErr);
+  }
+  int_4 iring=Index(index,0);
+  int_4 bid=this->NPhi(index);
+  int lring=bid;
+  cout << " iring= " << iring << " lring= " << lring << endl;
+  phi.Realloc(lring);
+  value.Realloc(lring);
+  float T=0.;
+  float F=0.;
+  for (int kk=0; kk<lring;kk++) {
+    PixThetaPhi(kk+iring,T,F);
+    phi(kk)=F;
+    value(kk)=PixVal(kk+iring);
+  }
+  theta=T;
+
+}
+
+
+/* --Methode-- */
+
Index: /tags/DPC_V0/SophyaLib/Samba/spherethetaphi.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/spherethetaphi.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/spherethetaphi.h	(revision 1307)
@@ -0,0 +1,100 @@
+#ifndef SPHERETHETAPHI_SEEN
+#define SPHERETHETAPHI_SEEN
+
+#include "sphericalmap.h"
+#include "pdataarray.h"
+#include "cvector.h"
+
+// ***************** CLASSE SphereThetaPhi *****************************
+
+
+class SphereThetaPhi : public SphericalMap {
+public :
+
+
+SphereThetaPhi(int_4 m, int_4 pet);
+SphereThetaPhi();
+SphereThetaPhi(char* flnm);
+virtual ~SphereThetaPhi();
+
+// ------------ Persistence handling
+
+     enum {classId = 0xF001 };
+int_4                  ClassId() const        { return classId; }
+
+virtual void           WriteSelf(POutPersist&) const;
+virtual void           ReadSelf(PInPersist&);
+
+// ------------------ Definition of PixelMap abstract methods
+
+// number of pixels
+virtual  int_4           NbPixels() const;
+
+// Value of pixel number k
+virtual  r_8&       PixVal(int_4 k);
+virtual  r_8 const&       PixVal(int_4 k) const;
+
+// Index of pixel at (theta,phi)
+virtual  int_4           PixIndexSph(float theta, float phi) const;
+
+// Spherical coordinates of center of pixel number k
+virtual  void          PixThetaPhi(int_4 k, float& theta, float& phi) const;
+
+// Pixel Solid angle  (steradians)
+virtual r_8         PixSolAngle(int_4 dummy) const; 
+// --------------- Specific methods 
+
+
+/* Valeurs de theta des paralleles et phi des meridiens limitant          */
+/* le pixel d'indice k                                                   */
+virtual  void          Limits(int_4 k, float& tet1, float& tet2, 
+				float& phi1, float& phi2 );
+
+/* Nombre de tranches en theta                                           */
+int_4           NbThetaSlices() const;
+
+/* Nombre de pixels en phi de la tranche d'indice kt                     */
+int_4           NPhi(int_4 kt) const;
+
+/* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max  */
+/* de la tranche d'indice kt                                             */
+void          Theta(int_4 kt, float& t1, float& t2);
+
+/* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp  */
+/* dans la tranche d'indice kt                                           */
+void          Phi(int_4 kt, int_4 jp, float& p1, float& p2);
+
+/* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt   */
+int_4           Index(int_4 kt, int_4 jp) const;
+
+
+/* Indice kt de la tranche et indice jp du pixel d'indice k            */
+void          ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp);
+
+void Pixelize(int_4,int_4); 
+void GetThetaSlice(int_4 index, r_4& theta, Vector& phi, Vector& value) const; 
+
+
+private :
+// ------------- méthodes internes ----------------------
+          
+
+void	      InitNul();
+void          Clear();
+
+// ------------- variables internes -----------------------
+int_4 mNTheta,mNPet;
+int_4 mNPix;
+r_4* mTheta;
+r_8  mOmeg;
+int_4* mNphi;
+int_4* mTNphi;
+//r_8* mPix;
+PDataArray<r_8>* _pixel;
+
+
+};
+
+
+
+#endif
Index: /tags/DPC_V0/SophyaLib/Samba/sphericalmap.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/sphericalmap.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/sphericalmap.h	(revision 1307)
@@ -0,0 +1,45 @@
+#ifndef SPHERICALMAP_SEEN
+#define SPHERICALMAP_SEEN
+
+// valeurs de Pi, 2*Pi, etc                                              
+#include "nbmath.h"
+#include <math.h>
+#include "pixelmap.h"
+#include "cvector.h" 
+// Map of pixels on a whole sphere.
+// Class hierarchy :
+//   PixelMap
+//      SphericalMap
+//         SphereThetaPhi
+//         SphereGorski
+//         SphereIco
+//      LocalMap
+
+class SphericalMap : public PixelMap {
+
+public :
+SphericalMap() {};
+virtual	 ~SphericalMap() {};
+
+   // Overloading of () to access pixel number k.
+   inline  r_8&        operator()(int_4 k)
+                          {return(PixVal(k));}
+   inline  r_8 const&  operator()(int_4 k) const
+                          {return(PixVal(k));}
+inline  r_8&        operator()(float theta, float phi)
+                { return(PixValSph(theta, phi)) ; };
+inline  r_8 const&        operator()(float theta, float phi) const
+                { return(PixValSph(theta, phi)) ; };
+
+
+virtual int_4 NbThetaSlices() const=0;
+virtual void GetThetaSlice(int_4 index, r_4& theta, Vector& phi, Vector& value) const=0; 
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/DPC_V0/SophyaLib/Samba/unitvec.h
===================================================================
--- /tags/DPC_V0/SophyaLib/Samba/unitvec.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/Samba/unitvec.h	(revision 1307)
@@ -0,0 +1,57 @@
+#ifndef UNITVEC_H_SEEN
+#define UNIITVEC_H_SEEN
+
+#include <math.h>
+#include <iostream.h>
+
+
+
+//  Classe pour faire des vecteurs normes x,y,z a partir de Teta,Phi
+//  et l inverse.  On peut calculer le produit scalaire et les vecteurs 
+//  perpendiculaires.
+//  Exemple:
+//  UnitVector u1(0.5, 0.7);   // Vers Teta=0.5 Phi = 0.7 Rad.
+//  UnitVector u2(1.,2.,1.);   // Vecteur norme parallele a (x=1., y=2., z=1.)
+//  u2.Teta();                 // Direction teta de u2
+//  u1.psc(u2);                // u1 prod. scalaire u2
+//  UnitVector vp1 = u2.vperp();   // Vecteur perpendiculaire a u1 , meme phi (ou a 180 deg)
+//  UnitVector vp2 = u2.vperp2();  // Vecteur perpendiculaire a u1 , a phi+90 deg
+
+//  
+class UnitVector {
+public:
+  UnitVector(double teta=0., double phi=0.) 
+    {  set(teta, phi); }
+  UnitVector(double vx, double vy, double vz) 
+      { setxyz(vx, vy, vz); }
+
+  inline void set(double teta, double phi) 
+    { t=teta; p=phi; z = cos(teta); x = sin(teta)*cos(phi);  y =  sin(teta)*sin(phi); }
+  inline void setxyz(double vx, double vy, double vz) 
+    { double r = sqrt(vx*vx+vy*vy+vz*vz); x = vx/r; y = vy/r; z = vz/r;
+    t = acos(z); p = atan2(y,x); }
+
+  inline double psc(UnitVector& u) { return(x*u.x+y*u.y+z*u.z); }
+
+  inline double Teta() { return(t); }
+  inline double Phi() { return(p); }
+  inline double X() { return(x); }
+  inline double Y() { return(y); }
+  inline double Z() { return(z); }
+
+  inline UnitVector vperp() {double tp, pp; pp = p;  
+     tp = t+0.5*M_PI; if (tp > M_PI) { tp = tp-M_PI; pp += M_PI*0.5; }
+     return(UnitVector(tp, pp)); }
+  inline UnitVector vperp2() {double tp, pp; tp = M_PI*0.5;  pp = p + 0.5*M_PI; 
+     return(UnitVector(tp, pp)); }
+
+  inline friend ostream& operator << (ostream& s, UnitVector const& u)
+      { s << "UnitVector: X,Y,Z= (" << u.x << "," << u.y << "," << u.z 
+          << ") Teta,Phi= " << u.t << "," << u.p << endl ;  return(s); }
+
+  double x,y,z;
+  double t,p;
+};
+
+
+#endif
Index: /tags/DPC_V0/SophyaLib/SysTools/ctimer.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/ctimer.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/ctimer.cc	(revision 1307)
@@ -0,0 +1,92 @@
+//
+// $Id: ctimer.cc,v 1.1.1.1 1999-04-09 17:57:04 ansari Exp $
+//
+
+#include "defs.h"
+#include "ctimer.h"
+
+//++
+// Class	Timer
+// Lib  	Outils++
+// include	ctimer.h
+//
+//	Chronométrage de programmes. Le constructeur mémorise l'heure et
+//      le temps CPU, ainsi qu'un message éventuel.
+//
+//	Split affiche le temps partiel.
+//
+//	Le destructeur affiche le temps total (CPU, et écoulé).
+//    
+//      Des macros permettent une utilisation simplifiée :
+//      * TIMEF   crée un objet de type Timer, avec le nom de la function 
+//	courante comme message. Le temps écoulé sera affiché à la sortie 
+//	de la function.
+//      * SPLITTIME affiche le temps partiel du compteur crée par TIMEF
+//      * TIMEN(nom) permet de donner un autre nom que le nom de la fonction.
+//--
+
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+// Timer::Timer(const char* name)
+//	Crée un objet qui mémorise l'heure et le temps CPU du process courant.
+//	Le destructeur affiche les temps écoulé et CPU utilisé.
+//--
+
+Timer::Timer(const char* name)
+: timerName(name)
+{
+  cpu0 = cpuSplit = clock();
+  elapse0 = elapseSplit = time(0);
+  END_CONSTRUCTOR
+}
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+// Timer::Split(const char* comm)
+//	Affiche le temps partiel.
+//--
+
+
+void Timer::Split(const char* comm)
+{
+  time_t elapse = time(0);
+  clock_t cpu   = clock();
+
+  float cpuSecT = ((float)cpu - (float)cpu0) / (float)(CLOCKS_PER_SEC);
+  float cpuSecP = ((float)cpu - (float)cpuSplit) / (float)(CLOCKS_PER_SEC);
+  
+  int etm  = elapse - elapseSplit;
+  int etmt = elapse - elapse0;
+
+  cout << "***Timing " << (comm ? comm : timerName) << endl;
+
+// Pour des formats comme ca, la syntaxe printf est plus agreable.
+// Pour ne pas melanger stdio/iostream (pb de desynchronisation sur
+// autres C++ que GNU), on fait un cout << chaine.
+
+  char out[200];
+  sprintf(out,"CPU     Time: Total= %g (Partial= %g) Sec.",
+	  cpuSecT, cpuSecP);
+  cout << out << endl;
+
+  sprintf(out,"Elapsed Time: Total= %02d:%02d:%02d (Partial=%02d:%02d:%02d)",
+	  etmt/3600, (etmt%3600)/60, etmt%60, 
+	  etm/3600,  (etm%3600)/60,  etm%60);
+
+  cout << out << endl;
+
+  elapseSplit = elapse;
+  cpuSplit    = cpu;
+}
+
+Timer::~Timer()
+{
+  Split();
+}
Index: /tags/DPC_V0/SophyaLib/SysTools/ctimer.h
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/ctimer.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/ctimer.h	(revision 1307)
@@ -0,0 +1,49 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// $Id: ctimer.h,v 1.1.1.1 1999-04-09 17:57:04 ansari Exp $
+//
+
+
+#ifndef CTIMER_SEEN
+#define CTIMER_SEEN
+
+#include <sys/types.h>
+#include <time.h>
+#include <iostream.h>
+#include <stdio.h>
+#include "peida.h"
+
+// <summary> Permet de chronometrer des fonctions. </summary>
+// La macro TIMEF cree un objet de class Timer qui memorise
+// l'heure de sa creation, et le temps CPU.
+
+// A la fin du bloc ou de la procedure, l'objet est detruit,
+// et son destructeur affiche le temps ecoule.
+
+// La macro SPLITTIME lui permet d'afficher des temps partiels.
+class Timer EXC_AWARE {
+public:
+  // L'objet memorise le temps CPU et l'heure, et le nom donne
+  Timer(const char* name=0);
+
+  // Le destructeur appelle split sans parametre.
+  virtual ~Timer();
+
+  // Affiche le temps ecoule total/partiel, avec le nom eventuel.
+  // Si pas de parametre affiche le nom donne a la creation.
+  void Split(const char* comm=0);
+
+  // Sert a eviter que GNU ne pretende qu'on utilise pas l'objet...
+  void Nop() {}
+
+private:
+  clock_t cpu0, cpuSplit;
+  time_t  elapse0, elapseSplit;
+  const char* timerName;
+};
+
+#define TIMEN(x)  Timer timer(x); timer.Nop();
+#define TIMEF     Timer timer(__PRETTY_FUNCTION__); timer.Nop();
+#define SPLITTIME timer.Split();
+
+#endif // CTIMER_SEEN
Index: /tags/DPC_V0/SophyaLib/SysTools/pdlmgr.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/pdlmgr.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/pdlmgr.cc	(revision 1307)
@@ -0,0 +1,152 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Gestionnaire de lien dynamique   -   R. Ansari 12/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <iostream.h>
+
+#include "pdlmgr.h"
+
+// Extension de noms de fichiers Shared libs
+static const char* sofext = ".so";
+static const char* sofext_HPUX = ".sl";
+
+// Variables et methodes static
+int PDynLinkMgr::numSO = 0;
+string*  PDynLinkMgr::tmpDir = NULL;
+
+/* --Methode-Static-- */
+void PDynLinkMgr::SetTmpDir(string const & path)
+{
+if ( (path.length() > 0) && (path[path.length()] != '/')  ) GetTmpDir() = path + '/';
+else GetTmpDir() = path;
+return;
+}
+
+/* --Methode-Static-- */
+string& PDynLinkMgr::GetTmpDir()
+{
+if (tmpDir == NULL) { 
+  tmpDir = new string("");
+  char* varenv;
+  if ( (varenv=getenv("PEIDA_TMP")) != NULL )  *tmpDir = varenv; 
+  else if ( (varenv=getenv("TMPDIR")) != NULL )  *tmpDir = varenv; 
+  }
+return(*tmpDir);
+}
+
+/* --Methode-Static-- */
+PDynLinkMgr* PDynLinkMgr::BuildFromCFile(string const & fname)
+{
+size_t l = fname.length();
+if (l < 1)  return(NULL);
+string fnameobj = GetTmpDir()+"tmp_pdl.o";
+
+string cmd;
+int rc;
+
+// Compilation du fichier
+#if defined(OSF1) || defined(Linux)
+cmd = "cc -c -o " + fnameobj + " " + fname;
+#endif
+rc = system(cmd.c_str());
+if (rc != 0)  { 
+  cerr << "PDynLinkMgr::BuildFromCFile() Error Rc(" << cmd <<")= "<< rc << endl; 
+  return(NULL);
+  }
+
+char buff[32];
+numSO++;
+#ifndef HPUX
+sprintf(buff,"pdlmgr%d%s", numSO,sofext);
+#endif
+string fnameso = GetTmpDir()+buff;
+
+// Creation du shared-lib
+#if defined(OSF1) 
+  cmd = "ld -shared -o " + fnameso + " -all " + fnameobj + " -none -lm -lc";
+#else
+  cmd = "ld -shared -o " + fnameso + " " + fnameobj + " -lm -lc";
+#endif
+rc = system(cmd.c_str());
+if (rc != 0)  { 
+  cerr << "PDynLinkMgr::BuildFromCFile() Error Rc(" << cmd <<")= "<< rc << endl; 
+  return(NULL);
+  }
+
+return(new PDynLinkMgr(fnameso, false));
+
+}
+
+/* --Methode-- */
+PDynLinkMgr::PDynLinkMgr(string& soname, bool cp)
+{
+dlhandle = NULL;
+soName = "";
+
+if (soname.find_last_of(".") > soname.length())  
+#ifdef HPUX
+  soname += sofext_HPUX;
+#else
+  soname += sofext;
+#endif
+
+string fnameso;
+if (cp) {
+  numSO++;
+  char buff[32];
+#ifndef HPUX
+  sprintf(buff,"pdlmgr%d%s", numSO,sofext);
+#else
+  sprintf(buff,"pdlmgr%d%s", numSO,sofext_HPUX);
+#endif
+  fnameso = GetTmpDir()+buff;
+  string cmd = "cp " + soname + " " + fnameso;
+  int rc = system(cmd.c_str());
+  if (rc != 0)  { 
+    cerr << "PDynLinkMgr::PDynLinkMgr() Error Rc(" << cmd <<")= "<< rc << endl; 
+    return;
+    }
+  } 
+else fnameso = soname;
+copy = cp;
+soName = fnameso;
+
+#if defined(OSF1) || defined(Linux)
+dlhandle =  dlopen(fnameso.c_str(), RTLD_NOW);
+if (dlhandle == NULL) { 
+  cerr << "PDynLinkMgr::PDynLinkMgr(): Error opening SO " << fnameso 
+       << " (" << soname << ")" << endl; 
+  string sn = dlerror();
+  cerr << "Loader Error (dlerror()) :" << sn << endl;
+  return; 
+  }
+#endif
+}
+
+/* --Methode-- */
+PDynLinkMgr::~PDynLinkMgr()
+{
+#if defined(OSF1) || defined(Linux)
+if (dlhandle) dlclose(dlhandle);    dlhandle = NULL;
+#endif
+if (copy) {
+  string cmd = "rm " + soName;
+  system(cmd.c_str());
+  }
+}
+
+/* --Methode-- */
+DlFunction PDynLinkMgr::GetFunction(string const & funcname)
+{
+DlFunction f = NULL;
+#if defined(OSF1) || defined(Linux)
+if (dlhandle != NULL)  
+  f = (DlFunction)dlsym(dlhandle, funcname.c_str());
+#endif
+if (f == NULL) cerr << "PDynLinkMgr::PDynLinkMgr(): Error linking " << funcname << endl;
+return(f);
+}
+
Index: /tags/DPC_V0/SophyaLib/SysTools/pdlmgr.h
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/pdlmgr.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/pdlmgr.h	(revision 1307)
@@ -0,0 +1,52 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Gestionnaire de lien dynamique   -   R. Ansari 12/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PDYNLINKMGR_SEEN
+#define PDYNLINKMGR_SEEN
+
+#include "defs.h"
+#include <string>
+#if defined(__KCC__)
+using std::string ;
+#endif
+
+#if defined(OSF1) || defined(Linux) || defined(AIX)
+#include <dlfcn.h>
+#endif
+
+#if defined(HPUX)
+#include <dl.h>
+#endif
+
+typedef void (* DlFunction) (void);
+
+class PDynLinkMgr {
+public:
+  // ---- Methodes globales (static)
+  static PDynLinkMgr*   BuildFromCFile(string const & fname);  // Compil+link fichier C
+  static void		SetTmpDir(string const & path);        // Repertoire des fichiers temporaires
+
+  // ---- Constructeur et methodes 
+  // Constructeur a partir d'un shared lib - copie en zone temporaire si cp==true
+			PDynLinkMgr(string& soname, bool cp=true);  
+  virtual		~PDynLinkMgr();
+
+  virtual DlFunction	GetFunction(string const & funcname);              
+
+protected :
+  static string&	GetTmpDir();
+  static int	  numSO;
+  static string*  tmpDir;
+
+#if defined(OSF1) || defined(Linux) || defined(AIX)
+  void * dlhandle;
+#endif
+#if defined(HPUX)
+  shl_t dlhandle;
+#endif
+  string soName;
+  bool copy;
+};
+
+#endif
Index: /tags/DPC_V0/SophyaLib/SysTools/periodic.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/periodic.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/periodic.cc	(revision 1307)
@@ -0,0 +1,109 @@
+/* Classe d'objets avec une methode (DoPeriodic()) appelee periodiquement */
+/*                                  Eric Aubourg     04/96                */
+/*                                  Reza Ansari      06/96                */
+/*                      LAL/IN2P3 (Orsay)  DAPNIA/CEA (Saclay)            */
+
+#include "defs.h"
+#include <signal.h>
+#include <unistd.h>
+
+#include "periodic.h"
+
+/* --Methode-- */
+Periodic::Periodic(int dt, UsPeriodicAction act, void * usp)
+{
+mDt = dt;
+mAct = act;
+mUsp = usp;
+if (mDt < 1)  mDt = 5;
+mDtms = 1000*mDt;
+mFgact = false;
+it = -1;
+}
+
+/* --Methode-- */
+Periodic::~Periodic()
+{
+if (mFgact) Stop();
+}
+
+/* --Methode-- */
+void Periodic::SetAction(UsPeriodicAction act, void * usp)
+{
+mAct = act;
+mUsp = usp;
+}
+
+/* --Methode-- */
+void Periodic::SetInterval(int dt)
+{
+mDt = dt;
+if (mDt < 1)  mDt = 5;
+mDtms = 1000*mDt;
+}
+
+/* --Methode-- */
+void Periodic::SetIntervalms(int dtms)
+{
+if (dtms < 1) dtms = 5;
+mDtms = dtms;
+mDt = mDtms/1000;
+if (mDt < 1)  mDt = 1;
+}
+
+/* --Methode-- */
+void Periodic::Start(int dt)
+{
+if (mFgact)  return;
+if (dt > 0)  { mDt = dt;  mDtms = dt*1000; }
+if (!actifs) actifs = new PeriodicList;
+it = 0;
+if (actifs->size() == 0) {
+  signal(SIGALRM, CallBack);
+  alarm(1);
+  }
+actifs->push_back(this);
+mFgact = true;
+return;
+}
+
+/* --Methode-- */
+void Periodic::Stop()
+{
+if (!mFgact)  return;
+
+//remove(actifs->begin(), actifs->end(), this);  // $CHECK$ - Reza
+actifs->remove(this);    // $CHECK$ 
+if (actifs->size() == 0) {
+  signal(SIGALRM, SIG_IGN);
+  alarm(0);
+  delete actifs;
+  actifs = NULL;
+  }
+it = -1;  mFgact = false;
+return;
+}
+
+/* --Methode-- */
+void Periodic::DoPeriodic()
+{
+if (mAct)   mAct(mUsp);
+}
+
+PeriodicList* Periodic::actifs = NULL;
+
+void Periodic::CallBack(int)
+{
+  if (!actifs) return;
+
+  for (PeriodicList::iterator i = actifs->begin(); i != actifs->end(); i++) {
+    Periodic* p = (Periodic*) *i;
+    p->it ++;
+    if (p->it >= p->mDt) {
+      p->it = 0;
+      p->DoPeriodic();
+    }
+  }
+  alarm(1);
+}
+
Index: /tags/DPC_V0/SophyaLib/SysTools/periodic.h
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/periodic.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/periodic.h	(revision 1307)
@@ -0,0 +1,47 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe d'objets avec une methode (DoPeriodic()) appelee periodiquement 
+#ifndef PERIODIC_H
+#define PERIODIC_H
+
+#include "defs.h"
+#include <list>
+#if defined(__KCC__)
+#include <list.h>
+#endif
+
+class Periodic;
+typedef list<Periodic*> PeriodicList;
+
+typedef void (* UsPeriodicAction) (void *);
+
+class Periodic 
+{
+public:
+  Periodic(int dt, UsPeriodicAction act=NULL, void * usp=NULL);
+  virtual ~Periodic();
+
+  void SetAction(UsPeriodicAction act, void * usp=NULL);
+
+  virtual void SetInterval(int dt);
+  virtual void SetIntervalms(int dtms);
+
+  inline int Interval() { return(mDt); }
+  inline int Intervalms() { return(mDtms); }
+
+  virtual void Start(int dt=-1);
+  virtual void Stop();
+
+  virtual void DoPeriodic();
+
+  static PeriodicList* actifs;
+  static void CallBack(int);
+
+protected:
+  int mDt, mDtms, it;
+  UsPeriodicAction mAct;
+  void * mUsp;
+  bool mFgact;
+};
+
+
+#endif
Index: /tags/DPC_V0/SophyaLib/SysTools/psighand.cc
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/psighand.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/psighand.cc	(revision 1307)
@@ -0,0 +1,120 @@
+//  Pour la gestion des signaux a travers des exceptions
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+#include "psighand.h"
+#include "perrors.h"
+
+static bool sigprstate[5] = {false, false, false, false};
+
+void PeidaProcessSignal(int s);
+
+/* Nouvelle-Fonction */
+void PeidaConfigureSignalhandling(bool cfpe, bool csegv, bool cquit, bool cusr1, bool cusr2) 
+{
+  struct sigaction ae, ad;
+
+  ae.sa_handler = PeidaProcessSignal;
+  ad.sa_handler = SIG_DFL;
+  memset( &(ae.sa_mask), 0, sizeof(sigset_t) ); 
+  ae.sa_flags = 0;
+  memset( &(ad.sa_mask), 0, sizeof(sigset_t) ); 
+  ad.sa_flags = 0;
+#ifdef  OSF1
+  ae.sa_flags = SA_RESTART;
+  ad.sa_mask = 0;
+#endif
+
+// SIGFPE 
+  if (sigprstate[0] != cfpe) {
+    if (cfpe)   { 
+      sigaction(SIGFPE, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGFPE handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGFPE, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGFPE handling ...");
+      }
+    sigprstate[0] = cfpe;
+    }
+// SIGSEGV 
+  if (sigprstate[1] != csegv) {
+    if (csegv)   { 
+      sigaction(SIGSEGV, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGSEGV handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGSEGV, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGSEGV handling ...");
+      }
+    sigprstate[1] = csegv;
+    }
+// SIGQUIT
+  if (sigprstate[2] != cquit) {
+    if (cquit)   { 
+      sigaction(SIGQUIT, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGQUIT handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGQUIT, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGQUIT handling ...");
+      }
+    sigprstate[2] = cquit; 
+    }
+  
+// SIGUSR1
+  if (sigprstate[3] != cusr1) {
+    if (cusr1)   { 
+      sigaction(SIGUSR1, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGUSR1 handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGUSR1, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGUSR1 handling ...");
+      }
+    sigprstate[3] = cusr1;
+    }
+// SIGUSR1
+  if (sigprstate[4] != cusr2) {
+    if (cusr2)   { 
+      sigaction(SIGUSR2, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGUSR2 handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGUSR2, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGUSR2 handling ...");
+      }
+    sigprstate[4] = cusr2;
+    }    
+}
+/* Nouvelle-Fonction */
+void PeidaProcessSignal(int s)
+{
+switch(s)
+  {
+  case SIGFPE :
+    puts("PeidaProcessSignal: ###Signal SIGFPE catched, throw catchedSIGFPE ###");
+    THROW(catchedSIGFPE);
+  case SIGSEGV :
+    puts("PeidaProcessSignal: ###Signal SIGSEGV catched, throw catchedSIGSEGV ###");
+    THROW(catchedSIGSEGV);
+  case SIGINT :
+    puts("PeidaProcessSignal: ###Signal SIGINT catched, throw catchedSIGINT ###");
+    THROW(catchedSIGINT);
+  case SIGQUIT :
+    puts("PeidaProcessSignal: ###Signal SIGQUIT catched, throw catchedSIGQUIT ###");
+    THROW(catchedSIGQUIT);
+  case SIGUSR1 :
+    puts("PeidaProcessSignal: ###Signal SIGUSR1 catched, throw catchedSIGUSR1 ###");
+    THROW(catchedSIGQUIT);
+  case SIGUSR2 :
+    puts("PeidaProcessSignal: ###Signal SIGUSR2 catched, throw catchedSIGUSR2 ###");
+    THROW(catchedSIGQUIT);
+  default :
+    printf("PeidaProcessSignal: ###Signal %d catched, throw  inconsistentErr ### \n", s);
+    THROW(inconsistentErr);
+  }
+
+return;
+}
Index: /tags/DPC_V0/SophyaLib/SysTools/psighand.h
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/psighand.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/psighand.h	(revision 1307)
@@ -0,0 +1,9 @@
+// This may look like C code, but it is really -*- C++ -*-
+//  Pour la gestion des signaux a travers des exceptions
+
+#ifndef PSIGHANDLE_SEEN
+#define PSIGHANDLE_SEEN
+
+#include "defs.h"
+void PeidaConfigureSignalhandling(bool cfpe=false, bool csegv=false, bool cquit=false, bool cusr1=false, bool cusr2=false); 
+#endif
Index: /tags/DPC_V0/SophyaLib/SysTools/timing.c
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/timing.c	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/timing.c	(revision 1307)
@@ -0,0 +1,69 @@
+/*    Fonction d'impression de temps de calcul et de temps passe  */
+/*                               R.Ansari    Juin 93              */
+
+/*
+++
+  Module	Temps CPU, passé (C)
+  Lib	LibsUtil
+  include	timing.h
+
+	Fonctions permettant d'imprimer le temps CPU consommé et le temps 
+	passé.
+--
+*/ 
+
+/*
+++
+  void InitTim()
+	Initialisation des chronomètres
+  void PrtTim(char *comm)
+	Imprime le temps CPU, et le temps passé depuis 
+	le dernier appel à "PrtTim()" avec le commentaire
+	"comm". Imprime aussi le cumul du temps CPU et du 
+	temps passé depuis l'appel à "InitTim()".
+--
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+ 
+clock_t CPUT0, CPUT;
+time_t ELT0, ELT;
+ 
+void InitTim(void);
+void PrtTim(char *Comm);
+ 
+/* Nouvelle-Fonction */
+void InitTim(void)
+{
+CPUT0 = CPUT = clock();
+ELT0 = ELT = time(NULL);
+return;
+}
+ 
+/* Nouvelle-Fonction */
+void PrtTim(char *Comm)
+{
+float tcal,tcalt;
+clock_t cput;
+time_t elt;
+int etm,etmt;
+ 
+elt = time(NULL);  cput = clock();
+tcalt = ( (float)(cput) - (float)(CPUT0) ) / (float)(CLOCKS_PER_SEC);
+tcal = ( (float)(cput) - (float)(CPUT) ) / (float)(CLOCKS_PER_SEC);
+etm = elt - ELT;
+etmt = elt - ELT0;
+printf("%s CPUTime: Total= %g  (Partial= %g) Sec. \n",
+       Comm, tcalt, tcal);
+printf("ElapsedTime(hh:mm:ss): Total= %02d:%02d:%02d ",
+       etmt/3600, (etmt%3600)/60, etmt%60);
+printf(" (Partial= %02d:%02d:%02d)\n",
+       etm/3600, (etm%3600)/60, etm%60);
+ 
+ELT = elt;
+CPUT = cput;
+return;
+}
Index: /tags/DPC_V0/SophyaLib/SysTools/timing.h
===================================================================
--- /tags/DPC_V0/SophyaLib/SysTools/timing.h	(revision 1307)
+++ /tags/DPC_V0/SophyaLib/SysTools/timing.h	(revision 1307)
@@ -0,0 +1,19 @@
+/*   Impression temps elapsed / Temps CPU     */
+/*                           Reza  -  93/94   */
+
+#ifndef TIMING_H_SEEN
+#define TIMING_H_SEEN
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void InitTim(void);                                                             
+void PrtTim(char *Comm);                                                        
+                                                                                
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /tags/DPC_V0/SophyaPI/ProgPI/piapp.cc
===================================================================
--- /tags/DPC_V0/SophyaPI/ProgPI/piapp.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaPI/ProgPI/piapp.cc	(revision 1307)
@@ -0,0 +1,168 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream.h>
+
+#include "pistdimgapp.h"
+#include "piacmd.h"
+#include "piversion.h"
+#include "piaversion.h"
+
+#include "timing.h"
+#include "skyinit.h"
+
+
+// ---- Pour charger automatiquement le module sopiamodule 
+extern "C" {
+void sopiamodule_init();
+void sopiamodule_end();
+}
+
+
+/*  ================================ MAIN() =================================  */
+
+int main(int narg, char *arg[])
+{
+int ofa;
+int fgfpe, fgsegv, fgred, fgexec;
+
+SkyTInitiator skyinit;
+   
+InitTim();
+
+ofa = 1;   
+if (narg > 1)
+  {
+  if (strcmp(arg[1],"-h") == 0) 
+    {
+    puts("\n piapp: Programme d'analyse interactive ");
+    puts("Usage: piapp [-nored] [-nosig] [-nosigfpe] [-nosigsegv] [-help2tex] [-exec file [args]]");
+    puts("  -nored : NoRedirect StdOut/StdErr");
+    puts("  -nosig : Don't catch SigFPE, SigSEGV");
+    puts("  -nosigfpe -nosigsegv: Don't catch SigFPE / SigSEGV");
+    puts("  -help2tex: Create a LaTeX help file (piahelp.tex)");
+    puts("  -exec file [args] : Execute command file \n");
+    exit(0);
+    }
+  }
+
+ofa = 1;
+fgred = fgfpe = fgsegv = true;
+fgexec = false;
+string exfc;
+// Pour fabriquer le help
+bool fgtexh = false;
+int ka;
+for(ka=1; ka<narg; ka++) {
+  if (strcmp(arg[ka],"-nored") == 0)   fgred=false; 
+  else if (strcmp(arg[ka],"-nosig") == 0)   fgfpe=fgsegv=false; 
+  else if (strcmp(arg[ka],"-nosigfpe") == 0)   fgfpe=false; 
+  else if (strcmp(arg[ka],"-nosigsegv") == 0)   fgsegv=false; 
+  else if (strcmp(arg[ka],"-help2tex") == 0) { fgtexh=true; fgred=false; }
+  else if (strcmp(arg[ka],"-exec") == 0) {
+    if (ka < narg-1) {
+      fgexec = true;
+      exfc = "exec";
+      for(int kaa=ka+1; kaa<narg; kaa++)  { exfc += ' ';  exfc +=  arg[kaa]; }
+      }
+    break;
+    }
+  }
+
+if (fgexec) printf(">>>>> Starting piapp , Executing %s \n", exfc.c_str()); 
+else printf(">>>>> Starting piapp <<<<< \n");
+printf("Version: piapp=%g  PI=%g  SOPHYA=%g \n", (double)PIAPP_VERSIONNUMBER, 
+              (double)PI_VERSIONNUMBER, (double)skyinit.Version());
+
+PIStdImgApp * app = new PIStdImgApp(narg, arg);
+
+// Gestion de redirection stdout/err et Signaux
+if (fgred) app->RedirectStdOutErr(true);
+else app->RedirectStdOutErr(false);
+app->CatchSignals(fgfpe, fgsegv);
+
+// S'il y a un fichier de commande a executer
+if (fgexec) app->CmdInterpreter()->Interpret(exfc);
+
+// On charge le module sopiamodule
+sopiamodule_init();
+
+// S'il y a besoin de faire le fichier Help
+if (fgtexh) { 
+  string thf = "piahelp.tex";
+  app->CmdInterpreter()->HelptoLaTex(thf);
+  printf("piapp : Help file piahelp.tex created --> exit(0) \n"); 
+  delete app;
+  exit(0);
+}
+
+int rc = 0;
+bool cont = true;
+char ans[32],rep;
+int excnt = 0;
+while(cont) {
+  rc = 0;   cont = false;
+  app->SetReady();
+  if (fgred) app->RedirectStdOutErr(true);
+  try {
+  app->Run();
+  }  
+  catch(PThrowable exc) {  // Catching SOPHYA exceptions 
+    app->Stop();
+    app->RedirectStdOutErr(false);  
+    //BUG ? fait planter OSF-cxx     fflush(stdout); 
+    cout << endl;      cerr << endl;
+    cout << "\n piapp/main() PThrowable catched ! " << exc.Msg() << endl;
+    cout << ++excnt << "- continue <CR>, Close Windows, "
+         << " continue C<CR> Stop program S<CR> ? " << endl; 
+    gets(ans);
+    rep = toupper(ans[0]);  
+    if (rep == 'S')  { 
+      cout << " !!!! Stopping piapp !!!! " << endl;
+      rc = 78;
+      cont = false;
+    }
+    else { 
+      if (rep == 'C') {
+	cout << "piapp/main() Closing all windows ... " << endl;
+	app->CloseAllWindows();
+      }
+      cout << " *** piapp - Continuing event loop *** " << endl;
+      cont = true;
+    }
+  }
+  catch(...) { // Catching all other exceptions 
+    app->Stop();
+    app->RedirectStdOutErr(false);  
+    cout << endl;      cerr << endl;
+    cout << "\n piapp/main() exception catched ! " << endl;
+    cout << ++excnt << "- continue <CR>, Close Windows, "
+         << " continue C<CR> Stop program S<CR> ? " << endl; 
+    gets(ans);
+    rep = toupper(ans[0]);  
+    if (rep == 'S')  { 
+      cout << " !!!! Stopping piapp !!!! " << endl;
+      rc = 78;
+      cont = false;
+    }
+    else { 
+      if (rep == 'C') {
+	cout << "piapp/main() Closing all windows ... " << endl;
+	app->CloseAllWindows();
+      }
+      cout << " *** piapp - Continuing event loop *** " << endl;
+      cont = true;
+    }
+  }
+}
+
+app->RedirectStdOutErr(false);  
+// On de-charge le module sopiamodule
+sopiamodule_end();
+delete app;
+
+cout << "\n------------------------------------------------ \n"
+     << "-------- piapp : Exiting .... Rc= " << rc << " -----------\n"
+     << "------------------------------------------------ " << endl; 
+return(rc);
+}
+
Index: /tags/DPC_V0/SophyaPI/ProgPI/programs
===================================================================
--- /tags/DPC_V0/SophyaPI/ProgPI/programs	(revision 1307)
+++ /tags/DPC_V0/SophyaPI/ProgPI/programs	(revision 1307)
@@ -0,0 +1,1 @@
+spiapp piapp.o sopiamodule.o
Index: /tags/DPC_V0/SophyaPI/ProgPI/sopiamodule.cc
===================================================================
--- /tags/DPC_V0/SophyaPI/ProgPI/sopiamodule.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaPI/ProgPI/sopiamodule.cc	(revision 1307)
@@ -0,0 +1,121 @@
+#include "machdefs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <math.h>
+
+#include <typeinfo>
+
+#include <vector>
+#include <string>
+
+#include "piacmd.h"
+#include "nobjmgr.h"
+#include "pistdimgapp.h"
+#include "servnobjm.h"
+#include "tvector.h"
+#include "pitvmaad.h"
+#include "fftpserver.h"
+#include "bruit.h"
+#include "piscdrawwdg.h"
+#include "ctimer.h"
+
+extern "C" {
+void sopiamodule_init();
+void sopiamodule_end();
+}
+
+void SophyaFFT(string& nom, string& nomout, string dopt);
+
+class sopiamoduleExecutor : public CmdExecutor {
+public:
+                sopiamoduleExecutor();
+  virtual       ~sopiamoduleExecutor();
+  virtual int   Execute(string& keyw, vector<string>& args);
+};
+
+/* --Methode-- */
+sopiamoduleExecutor::sopiamoduleExecutor()
+{
+
+PIACmd * mpiac;
+NamedObjMgr omg;
+mpiac = omg.GetImgApp()->CmdInterpreter();
+
+string hgrp = "SophyaCmd";
+string kw = "powerspec";
+string usage = "FFT on a vector -> Plots power spectrum ";
+usage += "\n Usage: fftp vecName vecFFT [graphic_att] ";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+
+}
+
+/* --Methode-- */
+sopiamoduleExecutor::~sopiamoduleExecutor()
+{
+}
+
+/* --Methode-- */
+int sopiamoduleExecutor::Execute(string& kw, vector<string>& tokens)
+{
+
+if (kw == "powerspec") {
+  if (tokens.size() < 2) {
+    cout << "Usage: powerspec nameVec vecFFT [graphic_att]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 3)  tokens.push_back((string)"n");
+  SophyaFFT(tokens[0], tokens[1], tokens[2]);
+  }
+
+return(0);
+
+}
+
+static sopiamoduleExecutor * piaerex = NULL;
+/* Nouvelle-Fonction */
+void sopiamodule_init()
+{
+// Fonction d'initialisation du module
+// Appele par le gestionnaire de modules de piapp (PIACmd::LoadModule())
+if (piaerex) delete piaerex;
+piaerex = new sopiamoduleExecutor;
+}
+
+/* Nouvelle-Fonction */
+void sopiamodule_end()
+{
+// Desactivation du module
+if (piaerex) delete piaerex;
+piaerex = NULL;
+}
+
+
+/* --Methode-- */
+void SophyaFFT(string& nom, string& nomout, string dopt)
+{
+NamedObjMgr omg;
+AnyDataObj* obj=omg.GetObj(nom);
+if (obj == NULL) {
+  cout << "SophyaFFT() Error , Pas d'objet de nom " << nom << endl;
+  return;
+}
+
+Vector* vin = dynamic_cast<Vector *>(obj);
+if (vin == NULL) {
+  cout << "SophyaFFT() Error , Objet n'est pas un vecteur " <<  endl;
+  return;
+  }
+
+TVector< complex<double> > * vout = new TVector< complex<double> > (1) ;
+FFTPackServer ffts;
+cout << "SophyaFFT() - Executing FFT of vector size " << vin->NElts() << endl;
+ffts.FFTForward(*vin, *vout);
+Timer tm;
+tm.Split(" FFT done ");
+
+omg.AddObj(vout, nomout);
+omg.DisplayObj(nomout, dopt);
+return;
+
+}
Index: /tags/DPC_V0/SophyaPI/ProgPI/usedlibs
===================================================================
--- /tags/DPC_V0/SophyaPI/ProgPI/usedlibs	(revision 1307)
+++ /tags/DPC_V0/SophyaPI/ProgPI/usedlibs	(revision 1307)
@@ -0,0 +1,6 @@
+SysTools
+NTools
+Samba
+SkyT
+PI
+PIext
Index: /tags/DPC_V0/SophyaPI/ProgPI/usedslibs
===================================================================
--- /tags/DPC_V0/SophyaPI/ProgPI/usedslibs	(revision 1307)
+++ /tags/DPC_V0/SophyaPI/ProgPI/usedslibs	(revision 1307)
@@ -0,0 +1,2 @@
+PI
+tools
Index: /tags/DPC_V0/SophyaProg/PrgUtil/Makefile
===================================================================
--- /tags/DPC_V0/SophyaProg/PrgUtil/Makefile	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/PrgUtil/Makefile	(revision 1307)
@@ -0,0 +1,82 @@
+MODULECXXREPNAME :=  PrgUtil
+include ../Mgr/Makefile.h
+ 
+ifdef NOSHLIB
+LIBF =  $(LIB)libTArray.a $(LIB)libSysTools.a $(LIB)libNTools.a $(LIB)libSkyMap.a $(LIB)libSamba.a $(LIB)libSkyT.a $(LIB)lib.a $(LIB)lib.a
+LIBS = -L$(LIB) -lTArray -lSysTools -lNTools -lSkyMap -lSamba -lSkyT -l -l  -lm
+ifeq ($(CXX),cxx)
+# librairie des instances de templates cxx
+LIBS := $(LIBS) -lertcxx
+endif
+else
+LIBF =  $(SLB)libsophya.so $(SLB)libextsophya.so
+LIBS = -L$(SLB) -lsophya -lextsophya  -lm
+endif
+LIBSORA := $(LIBS)
+ifdef ORACLE_HOME
+LIBSORA := -L$(LIB) -lDb++ $(LIBS) -lErosDb -L$(ORACLE_HOME)/lib -lclntsh
+endif
+LDLIBS := $(LIBS) $(LDLIBS)
+PROGS = $(EXE)runcxx $(EXE)scanppf
+ 
+all: $(PROGS)
+
+clean:
+	rm -f $(PROGS)
+	if [ -d $(OBJ)cxxrep_PrgUtil ] ; then cd $(OBJ)cxxrep_PrgUtil ; rm -f *.o ; fi
+
+runcxx: $(EXE)runcxx
+	
+$(EXE)runcxx: $(OBJ)runcxx.o
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+  
+scanppf: $(EXE)scanppf
+	
+$(EXE)scanppf: $(OBJ)scanppf.o
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+  
+scanfits: $(EXE)scanfits
+	
+$(EXE)scanfits: $(OBJ)scanfits.o
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+  
+$(OBJ)runcxx.o: runcxx.cc $(INC)sambainit.h \
+ $(INC)skymapinit.h \
+ $(INC)sophyainit.h \
+ $(INC)machdefs.h \
+ $(INC)ntoolsinit.h \
+ $(INC)tarrinit.h \
+ $(INC)skyinit.h \
+ $(INC)pexceptions.h \
+ $(INC)cxxcmplnk.h \
+ $(INC)pdlmgr.h \
+ $(INC)timing.h
+$(OBJ)scanfits.o: scanfits.cc $(INC)histinit.h \
+ $(INC)ntoolsinit.h \
+ $(INC)tarrinit.h \
+ $(INC)sophyainit.h \
+ $(INC)machdefs.h \
+ $(INC)dvlist.h \
+ $(INC)objfio.h \
+ $(INC)anydataobj.h \
+ $(INC)ppersist.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)mutyv.h \
+ $(INC)ntuple.h \
+ $(INC)ntupintf.h \
+ $(INC)xntuple.h \
+ $(INC)fitsxntuple.h \
+ $(INC)fitsfile.h \
+ $(INC)ndatablock.h \
+ $(INC)fitsntuple.h
+$(OBJ)scanppf.o: scanppf.cc $(INC)ppersist.h \
+ $(INC)machdefs.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)anydataobj.h \
+ $(INC)sambainit.h \
+ $(INC)skymapinit.h \
+ $(INC)sophyainit.h \
+ $(INC)ntoolsinit.h \
+ $(INC)tarrinit.h
Index: /tags/DPC_V0/SophyaProg/PrgUtil/programs
===================================================================
--- /tags/DPC_V0/SophyaProg/PrgUtil/programs	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/PrgUtil/programs	(revision 1307)
@@ -0,0 +1,3 @@
+runcxx runcxx.o
+scanppf scanppf.o
+scanfits scanfits.o
Index: /tags/DPC_V0/SophyaProg/PrgUtil/runcxx.cc
===================================================================
--- /tags/DPC_V0/SophyaProg/PrgUtil/runcxx.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/PrgUtil/runcxx.cc	(revision 1307)
@@ -0,0 +1,246 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <iostream.h>
+#include <fstream.h>
+
+#include <string>
+#include <vector>
+
+#include <typeinfo>
+
+#include "sambainit.h"
+#include "skyinit.h"
+#include "tarrinit.h"
+
+#include "pexceptions.h"
+#include "cxxcmplnk.h"
+#include "pdlmgr.h"
+#include "timing.h"
+
+typedef void (* DlFunctionOfVecStr) (vector<string> & args, int & rc);
+
+static void Usage(bool fgerr);
+static int  GetInput(string & codeflnm);
+static int  FillCxxFile(string & codeflnm, string & cxxfile);
+
+/* --Fonction-- */
+void Usage(bool fgerr)
+{
+  if (fgerr) 
+    cout << " runcxx : Argument Error ! " << endl; 
+  else
+    cout << " runcxx : compiling and running of a piece of C++ code " << endl;
+ 
+  cout << "   Usage: runcxx [-compopt CompileOptions] [-linkopt LinkOptions] \n"
+       << "                 [-tmpdir TmpDirectory] [-f C++CodeFileName] \n"
+       << "                 [-uarg UserArg1 UserArg2 ...] \n"
+       << "   if no file name is specified, read from standard input \n" << endl;
+  exit(0);
+}
+
+
+
+/* --Main-- */
+int main(int narg, char *arg[])
+{
+  if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
+
+  // Decoding options   
+  string codefile;
+  string compoption;
+  string linkoption;
+  string tmpdir;
+
+  bool fgco = false;
+  bool fglo = false;
+  bool fgcofn = false;
+  bool fgtmp = false;
+
+  vector<string> uarg;
+  
+  cout << " runcxx: Decoding command line options ... " << endl;
+  for (int k=1; k<narg; k++)   {
+    if (strcmp(arg[k], "-compopt") == 0)  {
+      if (k == narg-1) Usage(true);
+      fgco = true;  k++;
+      compoption = arg[k];
+    }
+    else if (strcmp(arg[k], "-linkopt") == 0) {
+      if (k == narg-1) Usage(true);
+      fglo = true;  k++;
+      linkoption = arg[k];
+    }
+    else if (strcmp(arg[k], "-tmpdir") == 0) {
+      if (k == narg-1) Usage(true);
+      fgtmp = true;  k++;
+      tmpdir = arg[k];
+    }
+    else if (strcmp(arg[k], "-f") == 0) {
+      if (k == narg-1) Usage(true);
+      fgcofn = true;  k++;
+      codefile = arg[k];
+    }
+    else if (strcmp(arg[k], "-uarg") == 0) {
+      if (k == narg-1) Usage(true);
+      for(int kk=k+1; kk<narg; kk++)
+	uarg.push_back(arg[kk]);
+      break;
+    }
+    else Usage(true);
+  }
+
+  // Checking TMPDIR
+  if (!fgtmp) {  // TMPDIR pas defini par option de ligne de commande
+    char* varenv;
+    if ( (varenv=getenv("TMPDIR")) != NULL )  { 
+      tmpdir = varenv;
+      fgtmp = true;
+    }
+  }
+  if (tmpdir.length() > 0)
+    if (tmpdir[tmpdir.length()-1] != '/') tmpdir += '/';
+  
+  int rc = 0;
+
+  try {
+    SophyaInit();
+    InitTim();
+
+    if (!fgcofn) {  // Pas de fichier specifie - Lecture de fichier sur stdin
+      codefile = tmpdir + "aucode.icc";
+      rc = GetInput(codefile);
+    }
+    string flnm;
+    if (rc == 0) {
+      flnm = tmpdir + "acxxrun.cc";
+      rc = FillCxxFile(codefile, flnm);
+    }
+
+    PrtTim(" End of FillCxxFile ");
+
+    string oname, soname;
+    if (rc == 0) {
+
+      CxxCompilerLinker cxx;
+      if (fgtmp) cxx.SetTmpDir(tmpdir);
+      if (fgco) cxx.AddCompileOptions(compoption);
+      if (fglo) cxx.AddLinkOptions(linkoption);
+      cxx.SetVerbose(true);
+
+      rc = cxx.Compile(flnm, oname);
+      cout << " RC from cxx.Compile() = " << rc << " oname= " << oname << endl;
+      rc = cxx.BuildSO(oname, soname);
+      cout << " RC from cxx.BuildSO() = " << rc << " soname= " << soname << endl;
+      PrtTim(" End of Compile-Link ");
+    }
+    if (rc == 0) {
+      string funcname = "runcxx_usercode";
+      if (fgtmp) PDynLinkMgr::SetTmpDir(tmpdir);
+      PDynLinkMgr dyl(soname);
+      DlFunction f = dyl.GetFunction(funcname);  
+      if (f != NULL) {
+	cout << "DlFunctionOfVecStr  f linked OK - calling f(uarg) ... \n" << endl;
+	DlFunctionOfVecStr fvs = (DlFunctionOfVecStr)f;
+	int rcu = 0;
+	fvs(uarg, rcu);
+	cout << "\n RC from UserCode() = " << rcu << endl;
+	rc = rcu;
+      } 
+      else {
+	cout << " ERROR linking DlFunction f !!! " << endl;
+      }
+    }
+  } 
+ 
+  catch (PThrowable & exc) {
+    cerr << " Catched Exception " << (string)typeid(exc).name()
+         << " - Msg= " << exc.Msg() << endl;
+  }
+  catch (...) {
+    cerr << " some other exception was caught ! " << endl;
+  }
+
+  PrtTim(" End of runcxx ");
+  return(rc);
+}
+
+/* --Fonction-- */
+int  GetInput(string & codeflnm)
+{
+  cout << " runcxx/GetInput() : Type in your C++ code, \n" 
+       << "     end with a blanck line OR <Cntl>D " << endl;
+  int line = 0;
+  ofstream os(codeflnm.c_str(),ios::out); 
+  os << "\n" ; 
+  bool fg = true;
+  char buff[512];
+  char * ret;
+  while (fg) {
+    printf("L%d ? ", line+1);
+    fflush(stdout);
+    buff[0] = '\0';
+    ret = fgets(buff, 512, stdin);
+    buff[511] = '\0';
+    if (ret && ( (buff[0] != '\0') && (buff[0] != '\n') && (buff[0] != '\r')) ) { 
+      os << buff << endl;  line++;
+    }
+    else fg = false;
+  }
+  os << "\n" ; 
+  cout << " \n Total " << line << " lines copied to file " <<  codeflnm << endl;
+  if (line > 0) return(0);
+  else return(1);
+}
+
+/* --Fonction-- */
+int  FillCxxFile(string & code, string & cxxfile)
+{
+  ofstream os(cxxfile.c_str(),ios::out); 
+  
+  os<<"#include \"machdefs.h\" \n"<<endl;
+
+  os<<"//---- System et stdc++ include files \n"
+    <<"#include <stdio.h> \n"
+    <<"#include <stdlib.h> \n"
+    <<"#include <math.h> \n"
+    <<"#include <ctype.h> \n"
+    <<"#include <string.h> \n"
+    <<"#include <iostream.h> \n"
+    <<"#include <fstream.h> \n"
+    <<"#include <complex> \n"
+    <<endl
+
+    <<"#include <typeinfo> \n"
+    <<"#include <string> \n"
+    <<"#include <vector> \n"
+    <<"#include <map> \n"
+    <<"#include <functional> \n"
+    <<"#include <list> \n"
+    <<endl
+    
+    <<"//---- Sophya include files \n"
+    <<"#include \"systools.h\" \n"
+    <<"#include \"ntools.h\" \n"
+    <<"#include \"array.h\" \n"
+    <<"#include \"histats.h\" \n"
+    <<"#include \"skymap.h\" \n"
+    <<"#include \"samba.h\" \n"
+    <<"#include \"skyt.h\" \n"
+    <<endl;
+
+  os << "extern \"C\" { \n" 
+     << " void runcxx_usercode(vector<string>& arg, int & rc); \n" 
+    //     << " void runcxx_usercode(); \n"
+     << " } \n " << endl;
+  
+  os << "// ---- User Code function ----- \n" 
+     << " void runcxx_usercode(vector<string>& arg, int & rc) \n" 
+    //     << " void runcxx_usercode() \n" 
+     << "{ \n"
+     << "#include \"" << code << "\" \n"
+     << "} \n" << endl;
+
+  return(0);
+}
+
Index: /tags/DPC_V0/SophyaProg/PrgUtil/scanfits.cc
===================================================================
--- /tags/DPC_V0/SophyaProg/PrgUtil/scanfits.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/PrgUtil/scanfits.cc	(revision 1307)
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <iostream.h>
+
+#include "histinit.h"
+#include "dvlist.h"
+#include "ntuple.h"
+#include "xntuple.h"
+#include "fitsxntuple.h"
+#include "fitsntuple.h"
+
+int main(int narg, char *arg[])
+{
+  if (narg < 2) {
+    cerr << "scanfits/Erreur arg - Usage scanfits nomfits \n" << endl;
+    exit(0);
+  }
+  try {
+    SophyaInit();
+    string flnm = arg[1];
+    int nbblk = FitsInFile::NbBlocks(arg[1]);
+    cout << " :::: File " << flnm << " has " << nbblk << " blocks " << endl;
+    DVList header;
+    FitsFile::FitsExtensionType exttype;
+    FitsFile::FitsDataType datatype;
+
+    cout << " FitsFile::FitsExtensionType : FitsExtensionType_IMAGE= " <<
+      (int)FitsFile::FitsExtensionType_IMAGE << 
+      "  FitsExtensionType_ASCII_TBL= " << (int)FitsFile::FitsExtensionType_ASCII_TBL <<
+      "  FitsExtensionType_BINARY_TBL= " << (int)FitsFile::FitsExtensionType_BINARY_TBL << endl;
+    cout << " FitsFile::FitsDataType: FitsDataType_double= " <<
+      (int)FitsFile::FitsDataType_double << 
+      " FitsDataType_float= " << (int)FitsFile::FitsDataType_float <<
+      " FitsDataType_int= " << (int)FitsFile::FitsDataType_int <<
+      " FitsDataType_char= " << (int)FitsFile::FitsDataType_char <<
+      " FitsDataType_ASCII= " << (int)FitsFile::FitsDataType_ASCII << endl << endl;
+
+    int naxis;
+    vector<int> axis;
+    for(int i=1; i<=nbblk; i++) {
+      FitsInFile::GetBlockType(arg[1], i, exttype, naxis, axis, datatype, header);
+      cout << " --------- Header Num " << i << " Type " << (int)exttype 
+	   << " NAxis= " << naxis << " (" << axis.size() << " )" 
+	   << " DataType= " << (int)datatype << endl;
+      for(int j=0; j<axis.size(); j++) cout  << axis[j] << " x "  ;
+      cout << endl;
+      cout << header << endl;
+      cout << "----------------------------------------------------" << endl;
+    } 
+ 
+  }
+  catch (PThrowable & exc) {
+    cerr << " Catched Exception " << (string)typeid(exc).name()
+         << " - Msg= " << exc.Msg() << endl;
+  }
+  catch (...) {
+    cerr << " some other exception was caught ! " << endl;
+  }
+
+}
Index: /tags/DPC_V0/SophyaProg/PrgUtil/scanppf.cc
===================================================================
--- /tags/DPC_V0/SophyaProg/PrgUtil/scanppf.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/PrgUtil/scanppf.cc	(revision 1307)
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+
+#include "ppersist.h"
+#include "anydataobj.h"
+#include "sambainit.h"
+
+#ifdef __MWERKS__
+#include <console.h>
+#endif
+
+int main(int narg, char* arg[])
+{
+
+#ifdef __MWERKS__
+narg = ccommand(&arg);
+#endif
+
+SambaInitiator smbinit;
+
+if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
+  cerr << " Usage: scanppf filename [s/n/a0/a1/a2/a3] \n" 
+       << "   s[=default} : Sequential reading of objects \n" 
+       << "   n : Object reading at NameTags \n"
+       << "   a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n" << endl;
+  exit(0);
+  }
+
+try {
+  string flnm = arg[1];
+  bool seq=true;
+  bool ana=false;
+  int analev = 0;
+  string opt = "s";
+  if (narg > 2) opt = arg[2];
+  
+  if (opt == "n")  seq = false;
+  else if (opt[0] == 'a') {  ana = true;  analev = opt[1]-'0'; }
+
+  if (ana)   cout << " Analyse PInPersist( " << flnm << ")  Level=" << analev << endl;
+  else { 
+    if (!seq) cout << "PInPersist( " << flnm << ") Object Reading at NameTags " << endl;
+    else  cout << "PInPersist( " << flnm << ") Sequential Object Reading " << endl;
+  }
+   
+  PPersist* op = NULL;
+  cout << " Opening PPF file " << flnm << endl; 
+  PInPersist s(flnm);
+
+  if (ana) s.AnalyseTags(analev);   // Analysing all tags in file 
+
+  else {
+    cout << " Version= " << s.Version() << " CreationDate= " << s.CreationDateStr() << endl;
+    int nt = s.NbTags();
+    cout << " Number of tags in file = " << nt << endl;
+    if ( seq || (nt < 1) ) {
+      while (1) {
+	op = s.ReadObject();
+	cout << " Object Type " << typeid(*op).name() << endl;
+	if (op) delete op;
+      }
+    }
+    for(int i=0; i<nt; i++) {
+      cout << ">>> TagNum= " << i << " TagName= " << s.GetTagName(i) << endl;
+      s.GotoTagNum(i);
+      op = s.ReadObject();
+      cout << " Object Type " << typeid(*op).name() << endl;
+      if (op) delete op;
+    }
+  }
+}
+catch (PThrowable pex) {
+  cerr << " scanppf/Error - Exception catched " << pex.Msg() << endl;
+}
+
+cout << " ----------- End of scanppf ------------- " << endl;
+}
Index: /tags/DPC_V0/SophyaProg/PrgUtil/usedlibs
===================================================================
--- /tags/DPC_V0/SophyaProg/PrgUtil/usedlibs	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/PrgUtil/usedlibs	(revision 1307)
@@ -0,0 +1,8 @@
+TArray
+SysTools
+NTools
+SkyMap
+Samba
+SkyT
+
+
Index: /tags/DPC_V0/SophyaProg/PrgUtil/usedslibs
===================================================================
--- /tags/DPC_V0/SophyaProg/PrgUtil/usedslibs	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/PrgUtil/usedslibs	(revision 1307)
@@ -0,0 +1,2 @@
+sophya
+extsophya
Index: /tags/DPC_V0/SophyaProg/Tests/Makefile
===================================================================
--- /tags/DPC_V0/SophyaProg/Tests/Makefile	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/Tests/Makefile	(revision 1307)
@@ -0,0 +1,48 @@
+include $(DPCDEVREP)/Include/Makefile.h
+
+
+ifdef NOSHLIB
+LIBF =  $(LIB)libSysTools.a $(LIB)libNTools.a $(LIB)libBlitz.a $(LIB)libPI.a $(LIB)libPIext.a 
+LIBS = -L$(LIB) -lPIext -lPI -lSysTools -lNTools -lBlitz -lm
+ifeq ($(CXX),cxx)
+# librairie des instances de templates cxx
+LIBS := $(LIBS) -lertcxx
+endif
+else
+LIBF =  $(SLB)libtools.so 
+LIBS = -L$(SLB) -lPI -ltools -lm -ldl
+endif
+
+ifndef (NOSHLIB)
+LIBS := $(SLIBS) $(LIBS)
+endif
+
+LDLIBS := $(LIBS) $(LDLIBS)
+
+%:%.cc
+%:%.o
+%.o:%.cc
+%.o:%.c
+%:%.c
+
+.PRECIOUS: $(EXE)% $(OBJ)%.o
+
+%:$(EXE)%
+	echo $@ " done"
+
+$(EXE)%:$(OBJ)%.o
+	$(LINK.cc)  -o $@ $< $(LIBS)
+
+$(OBJ)%.o:%.cc
+	$(COMPILE.cc)   $(USERFLAGS) -o $@ $<
+
+$(EXE)%:$(OBJ)%.cc
+	$(LINK.cc) $(USERFLAGS)  -o $@ $< $(LIBS) 
+
+$(EXE)%:$(OBJ)%.c
+	$(LINK.c)  $(USERFLAGS) -o $@ $< $(LIBS) 
+
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -c $(CFLAGS) $(USERFLAGS) -o $@ $< 
+
+
Index: /tags/DPC_V0/SophyaProg/Tests/piapp.cc
===================================================================
--- /tags/DPC_V0/SophyaProg/Tests/piapp.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/Tests/piapp.cc	(revision 1307)
@@ -0,0 +1,84 @@
+#include <stdlib.h>
+#include <stdio.h>
+#ifdef OSF1
+#include <dlfcn.h>
+#else
+#define C_NO_SHLIBS
+#endif
+
+#include <string>
+#include "psighand.h"
+#include "dynccd.h"
+
+#include "timing.h"
+#include "piinit.h"
+
+#include "pistdimgapp.h"
+
+
+
+/*  ================================ MAIN() =================================  */
+
+int main(int narg, char *arg[])
+{
+int ofa;
+int fgsig, fgred;
+
+PeidaInteractiveInitiator piinit;
+   
+InitTim();
+
+ofa = 1;   
+if (narg > 1)
+  {
+  if (strcmp(arg[1],"-h") == 0) 
+    {
+    puts("\n piapp: Programme d'analyse interactive ");
+    puts("Usage: piapp [-nored] [-nosig]");
+    exit(0);
+    }
+  }
+
+ofa = 1;
+fgred = fgsig = true;
+if (  (narg > 1) && (strcmp(arg[1],"-nored") == 0) )  { fgred=false;  ofa = 2; }
+if (  (narg > 1) && (strcmp(arg[1],"-nosig") == 0) )  { fgsig=false;  ofa = 2; }
+if (  (narg > 2) && (strcmp(arg[2],"-nored") == 0) )  { fgred=false;  ofa = 3; }
+if (  (narg > 2) && (strcmp(arg[2],"-nosig") == 0) )  { fgsig=false;  ofa = 3; }
+
+
+PIStdImgApp * app = new PIStdImgApp(narg-ofa, arg+ofa);
+if (!fgred) app->RedirectStdOutErr(false);
+else app->RedirectStdOutErr(true);
+if (fgsig)  app->CatchSignals(true);
+
+int rc = 0;
+bool cont = true;
+while(cont) {
+  rc = 0;   cont = false;
+  app->SetReady();
+  if (fgred) app->RedirectStdOutErr(true);
+  TRY {
+  app->Run();
+  }  CATCH(merr) {
+     char ans[32],rep;
+     app->Stop();
+     app->RedirectStdOutErr(false);  
+     fflush(stdout); 
+     cout << endl; 
+     cerr << endl;
+     printf("PIStdImg/main() Exception catched ! = %ld (%s) \n", (long)merr, PeidaExc(merr));
+     printf(" exit <CR> , continue c<CR> , close-windows, continue k<cr> ? ");  gets(ans);
+     rc = merr;
+     rep = toupper(ans[0]);  
+     if ((rep != 'C')||(rep != 'K'))  cont = false;
+     else { cont = true; if (rep == 'K') app->CloseAllWindows(); }
+  } ENDTRY;
+}
+
+app->RedirectStdOutErr(false);  
+delete app;
+printf("piapp : Exiting .... Rc= %d \n", rc); 
+exit(rc);
+}
+
Index: /tags/DPC_V0/SophyaProg/Tests/tblitz.cc
===================================================================
--- /tags/DPC_V0/SophyaProg/Tests/tblitz.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/Tests/tblitz.cc	(revision 1307)
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <iostream.h>
+#include "nbrandom.h"
+#include "timing.h"
+#include "cimage.h"
+
+#include "blitz/array.h"
+using namespace blitz ;
+
+main(int narg, char *arg[])
+{
+PeidaInit();
+InitTim();
+
+char strg[128];
+int N1,N2, k, kk, i, j;
+N1 = 1;
+N2 = 10;
+if (narg > 1)  N1 = atoi(arg[1]);
+if (narg > 2)  N2 = atoi(arg[2]);
+
+cout << N1 << " Tests avec " << N2 << " multiplications" << endl; 
+
+int sx = 300;
+int sy = 200;
+
+ImageR4  img(sx, sy), i2(sx, sy), ir(sx, sy);
+for(kk=0; kk<N1; kk++) {
+  cout << kk << " - Remplissage image (" << sx << "x" << sy << ") , " << N2 << " mult. " << endl;
+  for(i=0; i<sx; i++)
+    for(j=0; j<sy; j++) img(i,j) = frand01()*10.*j+20.*i;
+  for(i=0; i<sx; i++)
+    for(j=0; j<sy; j++) i2(i,j) =  frand01()*10.*j+20.*i;
+
+  for(k=0; k<N2; k++) ir = img * i2;
+  sprintf(strg, "Img T[%d] ", kk);
+  PrtTim(strg);
+}
+
+
+ cout << "\n ====  Test avec Blitz++ " << endl;
+
+Array<float,2> a1(sy, sx), a2(sy, sx), a3(sy, sx);
+firstIndex ii;
+secondIndex jj;
+
+for(kk=0; kk<N1; kk++) {
+  cout << kk << " BlitzArray (" << sx << "x" << sy << ") , " << N2 << " mult. " << endl;
+  a1 = frand01()*10.*jj+20.*ii;
+  a2 = frand01()*10.*jj+20.*ii;
+  for(k=0; k<N2; k++) a3 = a1*a2;
+  sprintf(strg, "Blitz-Array T[%d] ", kk);
+  PrtTim(strg);
+}
+
+
+exit(0);
+}
Index: /tags/DPC_V0/SophyaProg/Tests/timg.cc
===================================================================
--- /tags/DPC_V0/SophyaProg/Tests/timg.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/Tests/timg.cc	(revision 1307)
@@ -0,0 +1,61 @@
+// Utilisation des flots d'entree-sortie C++
+#include <iostream.h>
+// Utilisation de la classe Image<T>
+#include "cimage.h"
+// Utilisation des generateurs aleatoires
+#include "nbrandom.h"
+
+
+// -------- Le programme principal ---------
+
+main(int narg, char *arg[])
+{
+int i,j;
+
+// ----- ATTENTION -------
+// Initialisation de Peida
+// A faire au debut de main()
+PeidaInit();
+
+cout << " ........ Debut de timg.cc ....... " << endl;
+// declaration et creation d'une image de type flottant 300x200
+ImageR4  img(300, 200);
+// Remplissage de l'image Tirage aleatoire plat entre 1000-2000
+for(i=0; i<300; i++)
+  for(j=0; j<200; j++) img(i,j) =  frand01()*1000.+1000.;
+// Verification de la dynamique de l'image
+img.CheckDyn();
+img.Print();
+// On sauve l'image ds img.ppf (fichier  format PPersist)
+img.Write("img.ppf");
+
+// On rajoute du bruit a l'image (Gaussienne de sigma=3)
+for(i=0; i<300; i++)
+  for(j=0; j<200; j++) img(i,j) += NorRand()*3. ;
+
+// Verification de la dynamique de l'image
+img.CheckDyn();
+img.Print();
+
+// On verifie la date de creation du fichier .ppf
+  {
+  string ppfname = "img.ppf";
+  PInPersist pin(ppfname, false);
+  cout << "Fichier PPF: " << ppfname << " Version= " << pin.Version() 
+       << " Created: " << pin.CreationDate() << endl;
+  }
+// On cree une nouvelle image 
+ImageR4  img2;
+// On lit le contenu du fichier imgin.ppf
+img2.Read("img.ppf");
+// On calcule la difference entre les images img et img2
+//    Apres et avant ajout de bruit
+img -= img2;
+
+// Verification de la dynamique de l'image soustraite
+img.CheckDyn();
+img.Print();
+
+cout << " ========= Fin de timg.cc ======== " << endl;
+exit(0);
+}
Index: /tags/DPC_V0/SophyaProg/Tests/tnt.cc
===================================================================
--- /tags/DPC_V0/SophyaProg/Tests/tnt.cc	(revision 1307)
+++ /tags/DPC_V0/SophyaProg/Tests/tnt.cc	(revision 1307)
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <iostream.h>
+
+#include "ntuple.h"
+
+int main(int, char **)
+{
+PeidaInit();
+
+char * names[3] = {"XPos", "YPos", "Val"};
+int i,j, k;
+float xnt[3];
+
+printf("Creation Ntuple avec X,Y,Val ... \n");
+NTuple  nt1(3, names, 20);
+
+k = 0;
+for(j=0; j<8; j++)
+  for(i=0; i<12; i++)
+    { xnt[0] = i+0.5;  xnt[1] = j+0.5;  xnt[2] = k;
+    nt1.Fill(xnt); k++; }
+
+nt1.Show(cout);
+nt1.Print(0, 5);
+nt1.Print(18, 5);
+nt1.Print(94, 5);
+
+printf("Ecriture NTuple ds nt.ppf ... \n");
+nt1.Write("nt.ppf");
+
+printf("Lecture NTuple (nt2) ds nt.ppf ... \n");
+
+NTuple nt2("nt.ppf");
+nt2.Show(cout);
+nt2.Print(0, 5);
+nt2.Print(18, 5);
+nt2.Print(94, 5);
+
+printf("ReLecture NTuple (nt1) ds nt.ppf ... \n");
+
+nt1.Read("nt.ppf");
+nt1.Show(cout);
+nt1.Print(0, 5);
+nt1.Print(18, 5);
+nt1.Print(94, 5);
+
+printf("Creation/Lecture Lecture NTuple (nt1) ds nt.ppf ... \n");
+NTuple nt3;
+nt3.Read("nt.ppf");
+nt3.Show(cout);
+nt3.Print(0, 5);
+nt3.Print(18, 5);
+nt3.Print(94, 5);
+
+exit(0);
+}
+
+
