From 56809b0359af7e9108adeb1fd21823a225edf6fa Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Wed, 20 Jan 2016 18:08:59 +0100
Subject: Remove dependency of libastra on libpython by refactoring
 PluginAlgorithm

---
 include/astra/AstraObjectFactory.h |  7 +++--
 include/astra/PluginAlgorithm.h    | 57 +++++++++++---------------------------
 2 files changed, 21 insertions(+), 43 deletions(-)

(limited to 'include')

diff --git a/include/astra/AstraObjectFactory.h b/include/astra/AstraObjectFactory.h
index 325989e..6af9cd8 100644
--- a/include/astra/AstraObjectFactory.h
+++ b/include/astra/AstraObjectFactory.h
@@ -155,8 +155,11 @@ class _AstraExport CAlgorithmFactory : public CAstraObjectFactory<CAlgorithm, Al
 template <>
 inline CAlgorithm* CAstraObjectFactory<CAlgorithm, AlgorithmTypeList>::findPlugin(std::string _sType)
 	{
-		CPluginAlgorithmFactory *fac = CPluginAlgorithmFactory::getSingletonPtr();
-		return fac->getPlugin(_sType);
+		CPluginAlgorithmFactory *fac = CPluginAlgorithmFactory::getFactory();
+		if (fac)
+			return fac->getPlugin(_sType);
+		else
+			return 0;
 	}
 #endif
 
diff --git a/include/astra/PluginAlgorithm.h b/include/astra/PluginAlgorithm.h
index 667e813..cbd80fc 100644
--- a/include/astra/PluginAlgorithm.h
+++ b/include/astra/PluginAlgorithm.h
@@ -29,62 +29,37 @@ $Id$
 #ifndef _INC_ASTRA_PLUGINALGORITHM
 #define _INC_ASTRA_PLUGINALGORITHM
 
-#ifdef ASTRA_PYTHON
-
-#include "astra/Algorithm.h"
-#include "astra/Singleton.h"
-#include "astra/XMLDocument.h"
-#include "astra/XMLNode.h"
-
-// Slightly hackish forward declaration of PyObject
-struct _object;
-typedef _object PyObject;
+#include "astra/Globals.h"
 
+#include <map>
+#include <string>
 
 namespace astra {
-class _AstraExport CPluginAlgorithm : public CAlgorithm {
-
-public:
-
-    CPluginAlgorithm(PyObject* pyclass);
-    ~CPluginAlgorithm();
-
-    bool initialize(const Config& _cfg);
-    void run(int _iNrIterations);
-
-private:
-    PyObject * instance;
 
-};
+class CAlgorithm;
 
-class _AstraExport CPluginAlgorithmFactory : public Singleton<CPluginAlgorithmFactory> {
+class _AstraExport CPluginAlgorithmFactory {
 
 public:
+    CPluginAlgorithmFactory() { }
+    virtual ~CPluginAlgorithmFactory() { }
 
-    CPluginAlgorithmFactory();
-    ~CPluginAlgorithmFactory();
+    virtual CAlgorithm * getPlugin(const std::string &name) = 0;
 
-    CPluginAlgorithm * getPlugin(std::string name);
+    virtual bool registerPlugin(std::string name, std::string className) = 0;
+    virtual bool registerPlugin(std::string className) = 0;
 
-    bool registerPlugin(std::string name, std::string className);
-    bool registerPlugin(std::string className);
-    bool registerPluginClass(std::string name, PyObject * className);
-    bool registerPluginClass(PyObject * className);
+    virtual std::map<std::string, std::string> getRegisteredMap() = 0;
     
-    PyObject * getRegistered();
-    std::map<std::string, std::string> getRegisteredMap();
-    
-    std::string getHelp(std::string name);
+    virtual std::string getHelp(const std::string &name) = 0;
+
+    static void registerFactory(CPluginAlgorithmFactory *factory) { m_factory = factory; }
+	static CPluginAlgorithmFactory* getFactory() { return m_factory; }
 
 private:
-    PyObject * pluginDict;
-    PyObject *inspect, *six;
+    static CPluginAlgorithmFactory *m_factory;
 };
 
-PyObject* XMLNode2dict(XMLNode node);
-
 }
 
 #endif
-
-#endif
-- 
cgit v1.2.3


From 838cfae58d825fb8915dc7d3c974d96e6a4f981c Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Fri, 12 Feb 2016 16:27:08 +0100
Subject: Also split volumes in X/Y directions to respect CUDA limits

---
 include/astra/CompositeGeometryManager.h | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

(limited to 'include')

diff --git a/include/astra/CompositeGeometryManager.h b/include/astra/CompositeGeometryManager.h
index 4338994..18dd72f 100644
--- a/include/astra/CompositeGeometryManager.h
+++ b/include/astra/CompositeGeometryManager.h
@@ -79,7 +79,9 @@ public:
 
 		bool uploadToGPU();
 		bool downloadFromGPU(/*mode?*/);
-		virtual TPartList split(size_t maxSize, int div) = 0;
+		virtual void splitX(TPartList& out, size_t maxSize, size_t maxDim, int div) = 0;
+		virtual void splitY(TPartList& out, size_t maxSize, size_t maxDim, int div) = 0;
+		virtual void splitZ(TPartList& out, size_t maxSize, size_t maxDim, int div) = 0;
 		virtual CPart* reduce(const CPart *other) = 0;
 		virtual void getDims(size_t &x, size_t &y, size_t &z) = 0;
 		size_t getSize();
@@ -93,7 +95,9 @@ public:
 
 		CVolumeGeometry3D* pGeom;
 
-		virtual TPartList split(size_t maxSize, int div);
+		virtual void splitX(TPartList& out, size_t maxSize, size_t maxDim, int div);
+		virtual void splitY(TPartList& out, size_t maxSize, size_t maxDim, int div);
+		virtual void splitZ(TPartList& out, size_t maxSize, size_t maxDim, int div);
 		virtual CPart* reduce(const CPart *other);
 		virtual void getDims(size_t &x, size_t &y, size_t &z);
 
@@ -107,7 +111,9 @@ public:
 
 		CProjectionGeometry3D* pGeom;
 
-		virtual TPartList split(size_t maxSize, int div);
+		virtual void splitX(TPartList& out, size_t maxSize, size_t maxDim, int div);
+		virtual void splitY(TPartList& out, size_t maxSize, size_t maxDim, int div);
+		virtual void splitZ(TPartList& out, size_t maxSize, size_t maxDim, int div);
 		virtual CPart* reduce(const CPart *other);
 		virtual void getDims(size_t &x, size_t &y, size_t &z);
 
-- 
cgit v1.2.3


From bc2e4018054f494fcba01e6a27a63e151bf1e9a4 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Tue, 16 Feb 2016 15:15:13 +0100
Subject: Refactor AstraObjectManager to add an AstraIndexManager

The new AstraIndexManager can be used to obtain information about objects
without knowing their type.
---
 include/astra/Algorithm.h          |   4 +-
 include/astra/AstraObjectManager.h | 104 ++++++++++++++++++++++++++++---------
 include/astra/Projector2D.h        |   4 +-
 include/astra/Projector3D.h        |   4 +-
 4 files changed, 86 insertions(+), 30 deletions(-)

(limited to 'include')

diff --git a/include/astra/Algorithm.h b/include/astra/Algorithm.h
index 049417c..18c465f 100644
--- a/include/astra/Algorithm.h
+++ b/include/astra/Algorithm.h
@@ -81,7 +81,7 @@ public:
 	 *
 	 * @return initialized
 	 */
-	bool isInitialized();
+	bool isInitialized() const;
 
 	/** get a description of the class
 	 *
@@ -133,7 +133,7 @@ private:
 
 // inline functions
 inline std::string CAlgorithm::description() const { return "Algorithm"; };
-inline bool CAlgorithm::isInitialized() { return m_bIsInitialized; }
+inline bool CAlgorithm::isInitialized() const { return m_bIsInitialized; }
 
 } // end namespace
 
diff --git a/include/astra/AstraObjectManager.h b/include/astra/AstraObjectManager.h
index 895f955..eab3f03 100644
--- a/include/astra/AstraObjectManager.h
+++ b/include/astra/AstraObjectManager.h
@@ -52,17 +52,41 @@ namespace astra {
  * among all ObjectManagers.
  */
 
+class CAstraObjectManagerBase {
+	virtual std::string getInfo(int index) const =0;
+	virtual void remove(int index) =0;
+	virtual std::string getType() const =0;
+};
 
-class CAstraIndexManager {
-protected:
-	/** The index of the previously stored data object.
+
+class CAstraIndexManager : public Singleton<CAstraIndexManager> {
+public:
+	CAstraIndexManager() : m_iLastIndex(0) { }
+
+	int store(CAstraObjectManagerBase* m) {
+		m_table[++m_iLastIndex] = m;
+		return m_iLastIndex;
+	}
+
+	CAstraObjectManagerBase* get(int index) const {
+		std::map<int, CAstraObjectManagerBase*>::const_iterator i;
+		i = m_table.find(index);
+		if (i != m_table.end())
+			return i->second;
+		else
+			return 0;
+	}
+
+private:
+	/** The index last handed out
 	 */
-	static int m_iPreviousIndex;
+	int m_iLastIndex;
+	std::map<int, CAstraObjectManagerBase*> m_table;
 };
 
 
 template <typename T>
-class CAstraObjectManager : public Singleton<CAstraObjectManager<T> >, CAstraIndexManager {
+class CAstraObjectManager : public CAstraObjectManagerBase {
 
 public:
 
@@ -117,7 +141,11 @@ public:
 	 */
 	void clear();
 
-	/** Get info.
+	/** Get info of object.
+	 */
+	std::string getInfo(int index) const;
+
+	/** Get list with info of all managed objects.
 	 */
 	std::string info();
 
@@ -149,9 +177,9 @@ CAstraObjectManager<T>::~CAstraObjectManager()
 template <typename T>
 int CAstraObjectManager<T>::store(T* _pDataObject) 
 {
-	m_iPreviousIndex++;
-	m_mIndexToObject[m_iPreviousIndex] = _pDataObject;
-	return m_iPreviousIndex;
+	int iIndex = CAstraIndexManager::getSingleton().store(this);
+	m_mIndexToObject[iIndex] = _pDataObject;
+	return iIndex;
 }
 
 //----------------------------------------------------------------------------------------
@@ -219,20 +247,30 @@ void CAstraObjectManager<T>::clear()
 
 //----------------------------------------------------------------------------------------
 // Print info to string
+template <typename T>
+std::string CAstraObjectManager<T>::getInfo(int index) const {
+	typename map<int,T*>::const_iterator it = m_mIndexToObject.find(index);
+	if (it == m_mIndexToObject.end())
+		return "";
+	const T* pObject = it->second;
+	std::stringstream res;
+	res << index << " \t";
+	if (pObject->isInitialized()) {
+		res << "v     ";
+	} else {
+		res << "x     ";
+	}
+	res << pObject->description();
+	return res.str();
+}
+
 template <typename T>
 std::string CAstraObjectManager<T>::info() {
 	std::stringstream res;
 	res << "id  init  description" << std::endl;
 	res << "-----------------------------------------" << std::endl;
-	for (typename map<int,T*>::iterator it = m_mIndexToObject.begin(); it != m_mIndexToObject.end(); it++) {
-		res << (*it).first << " \t";
-		T* pObject = m_mIndexToObject[(*it).first];
-		if (pObject->isInitialized()) {
-			res << "v     ";
-		} else {
-			res << "x     ";
-		}
-		res << pObject->description() << endl;
+	for (typename map<int,T*>::const_iterator it = m_mIndexToObject.begin(); it != m_mIndexToObject.end(); it++) {
+		res << getInfo(it->first) << endl;
 	}
 	res << "-----------------------------------------" << std::endl;
 	return res.str();
@@ -247,42 +285,60 @@ std::string CAstraObjectManager<T>::info() {
  * assigned to each data object by which it can be accessed in the future.
  * Indices are always >= 1.
  */
-class _AstraExport CProjector2DManager : public CAstraObjectManager<CProjector2D>{};
+class _AstraExport CProjector2DManager : public Singleton<CProjector2DManager>, public CAstraObjectManager<CProjector2D>
+{
+	virtual std::string getType() const { return "projector2d"; }
+};
 
 /**
  * This class contains functionality to store 3D projector objects.  A unique index handle will be 
  * assigned to each data object by which it can be accessed in the future.
  * Indices are always >= 1.
  */
-class _AstraExport CProjector3DManager : public CAstraObjectManager<CProjector3D>{};
+class _AstraExport CProjector3DManager : public Singleton<CProjector3DManager>, public CAstraObjectManager<CProjector3D>
+{
+	virtual std::string getType() const { return "projector3d"; }
+};
 
 /**
  * This class contains functionality to store 2D data objects.  A unique index handle will be 
  * assigned to each data object by which it can be accessed in the future.
  * Indices are always >= 1.
  */
-class _AstraExport CData2DManager : public CAstraObjectManager<CFloat32Data2D>{};
+class _AstraExport CData2DManager : public Singleton<CData2DManager>, public CAstraObjectManager<CFloat32Data2D>
+{
+	virtual std::string getType() const { return "data2d"; }
+};
 
 /**
  * This class contains functionality to store 3D data objects.  A unique index handle will be 
  * assigned to each data object by which it can be accessed in the future.
  * Indices are always >= 1.
  */
-class _AstraExport CData3DManager : public CAstraObjectManager<CFloat32Data3D>{};
+class _AstraExport CData3DManager : public Singleton<CData3DManager>, public CAstraObjectManager<CFloat32Data3D>
+{
+	virtual std::string getType() const { return "data3d"; }
+};
 
 /**
  * This class contains functionality to store algorithm objects.  A unique index handle will be 
  * assigned to each data object by which it can be accessed in the future.
  * Indices are always >= 1.
  */
-class _AstraExport CAlgorithmManager : public CAstraObjectManager<CAlgorithm>{};
+class _AstraExport CAlgorithmManager : public Singleton<CAlgorithmManager>, public CAstraObjectManager<CAlgorithm>
+{
+	virtual std::string getType() const { return "algorithm"; }
+};
 
 /**
  * This class contains functionality to store matrix objects.  A unique index handle will be 
  * assigned to each data object by which it can be accessed in the future.
  * Indices are always >= 1.
  */
-class _AstraExport CMatrixManager : public CAstraObjectManager<CSparseMatrix>{};
+class _AstraExport CMatrixManager : public Singleton<CMatrixManager>, public CAstraObjectManager<CSparseMatrix>
+{
+	virtual std::string getType() const { return "matrix"; }
+};
 
 
 } // end namespace
diff --git a/include/astra/Projector2D.h b/include/astra/Projector2D.h
index a1ea0ce..c7a899d 100644
--- a/include/astra/Projector2D.h
+++ b/include/astra/Projector2D.h
@@ -174,7 +174,7 @@ public:
 	 *
 	 * @return initialized successfully
 	 */
-	bool isInitialized();
+	bool isInitialized() const;
 
 	/** get a description of the class
 	 *
@@ -191,7 +191,7 @@ private:
 };
 
 // inline functions
-inline bool CProjector2D::isInitialized() { return m_bIsInitialized; }
+inline bool CProjector2D::isInitialized() const { return m_bIsInitialized; }
 inline CProjectionGeometry2D* CProjector2D::getProjectionGeometry() { return m_pProjectionGeometry; }
 inline CVolumeGeometry2D* CProjector2D::getVolumeGeometry() { return m_pVolumeGeometry; }
 
diff --git a/include/astra/Projector3D.h b/include/astra/Projector3D.h
index 1ef1ba7..88ca2be 100644
--- a/include/astra/Projector3D.h
+++ b/include/astra/Projector3D.h
@@ -153,7 +153,7 @@ public:
 	 *
 	 * @return initialized successfully
 	 */
-	bool isInitialized();
+	bool isInitialized() const;
 
 	/** get a description of the class
 	 *
@@ -174,7 +174,7 @@ private:
 };
 
 // inline functions
-inline bool CProjector3D::isInitialized() { return m_bIsInitialized; }
+inline bool CProjector3D::isInitialized() const { return m_bIsInitialized; }
 inline CProjectionGeometry3D* CProjector3D::getProjectionGeometry() { return m_pProjectionGeometry; }
 inline CVolumeGeometry3D* CProjector3D::getVolumeGeometry() { return m_pVolumeGeometry; }
 
-- 
cgit v1.2.3


From 9847d2c4a8287f220f169236b4fa1962d50d1187 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Tue, 16 Feb 2016 15:22:59 +0100
Subject: Also remove objects from index manager

---
 include/astra/AstraObjectManager.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'include')

diff --git a/include/astra/AstraObjectManager.h b/include/astra/AstraObjectManager.h
index eab3f03..8b9da30 100644
--- a/include/astra/AstraObjectManager.h
+++ b/include/astra/AstraObjectManager.h
@@ -77,6 +77,13 @@ public:
 			return 0;
 	}
 
+	void remove(int index) {
+		std::map<int, CAstraObjectManagerBase*>::iterator i;
+		i = m_table.find(index);
+		if (i != m_table.end())
+			m_table.erase(i);
+	}
+
 private:
 	/** The index last handed out
 	 */
@@ -216,7 +223,9 @@ void CAstraObjectManager<T>::remove(int _iIndex)
 	// delete data
 	delete (*it).second;
 	// delete from map
-	m_mIndexToObject.erase(it);  
+	m_mIndexToObject.erase(it);
+
+	CAstraIndexManager::getSingleton().remove(_iIndex);
 }
 
 //----------------------------------------------------------------------------------------
-- 
cgit v1.2.3


From 8cfe13a410a051e5a6b9835e3a4cd6c808cf5d29 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Tue, 16 Feb 2016 15:34:08 +0100
Subject: Add astra_mex delete/info based on index manager

---
 include/astra/AstraObjectManager.h | 1 +
 1 file changed, 1 insertion(+)

(limited to 'include')

diff --git a/include/astra/AstraObjectManager.h b/include/astra/AstraObjectManager.h
index 8b9da30..35b4534 100644
--- a/include/astra/AstraObjectManager.h
+++ b/include/astra/AstraObjectManager.h
@@ -53,6 +53,7 @@ namespace astra {
  */
 
 class CAstraObjectManagerBase {
+public:
 	virtual std::string getInfo(int index) const =0;
 	virtual void remove(int index) =0;
 	virtual std::string getType() const =0;
-- 
cgit v1.2.3


From 7b6d74bd403f5bb0e4c8ba451eefa13193e7ed34 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Tue, 16 Feb 2016 16:19:26 +0100
Subject: Slightly simplify CAstraObjectManager::remove

---
 include/astra/AstraObjectManager.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'include')

diff --git a/include/astra/AstraObjectManager.h b/include/astra/AstraObjectManager.h
index 35b4534..ad89c2a 100644
--- a/include/astra/AstraObjectManager.h
+++ b/include/astra/AstraObjectManager.h
@@ -216,11 +216,10 @@ T* CAstraObjectManager<T>::get(int _iIndex) const
 template <typename T>
 void CAstraObjectManager<T>::remove(int _iIndex)
 {
-	if (!hasIndex(_iIndex)) {
-		return;
-	}
 	// find data
 	typename map<int,T*>::iterator it = m_mIndexToObject.find(_iIndex);
+	if (it == m_mIndexToObject.end())
+		return;
 	// delete data
 	delete (*it).second;
 	// delete from map
-- 
cgit v1.2.3


From 37e1c06154362e26acdb4b09c4a251ec2ad0a316 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Tue, 8 Mar 2016 16:29:00 +0100
Subject: Fix Windows build

---
 include/astra/Utilities.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'include')

diff --git a/include/astra/Utilities.h b/include/astra/Utilities.h
index 3ae0e6c..8d7c44d 100644
--- a/include/astra/Utilities.h
+++ b/include/astra/Utilities.h
@@ -50,40 +50,40 @@ public:
 
 //< Parse string as int.
 //< Throw exception on failure.
-int stringToInt(const std::string& s);
+_AstraExport int stringToInt(const std::string& s);
 
 //< Parse string as float.
 //< Throw exception on failure.
-float stringToFloat(const std::string& s);
+_AstraExport float stringToFloat(const std::string& s);
 
 //< Parse string as double.
 //< Throw exception on failure.
-double stringToDouble(const std::string& s);
+_AstraExport double stringToDouble(const std::string& s);
 
 template<typename T>
-T stringTo(const std::string& s);
+_AstraExport T stringTo(const std::string& s);
 
 //< Parse comma/semicolon-separated string as float vector.
 //< Throw exception on failure.
-std::vector<float> stringToFloatVector(const std::string& s);
+_AstraExport std::vector<float> stringToFloatVector(const std::string& s);
 
 //< Parse comma/semicolon-separated string as double vector.
 //< Throw exception on failure.
-std::vector<double> stringToDoubleVector(const std::string& s);
+_AstraExport std::vector<double> stringToDoubleVector(const std::string& s);
 
 template<typename T>
-std::vector<T> stringToVector(const std::string& s);
+_AstraExport std::vector<T> stringToVector(const std::string& s);
 
 
 
 //< Generate string from float.
-std::string floatToString(float f);
+_AstraExport std::string floatToString(float f);
 
 //< Generate string from double.
-std::string doubleToString(double f);
+_AstraExport std::string doubleToString(double f);
 
 template<typename T>
-std::string toString(T f);
+_AstraExport std::string toString(T f);
 
 }
 
-- 
cgit v1.2.3


From 495903529d473a9968c1333d5a515e3b94732f0b Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Wed, 23 Mar 2016 15:29:43 +0100
Subject: Move CUDA algorithm initialization to its own function

---
 include/astra/CudaReconstructionAlgorithm2D.h | 3 +++
 include/astra/CudaSirtAlgorithm.h             | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

(limited to 'include')

diff --git a/include/astra/CudaReconstructionAlgorithm2D.h b/include/astra/CudaReconstructionAlgorithm2D.h
index dc93a1a..bb5f2a7 100644
--- a/include/astra/CudaReconstructionAlgorithm2D.h
+++ b/include/astra/CudaReconstructionAlgorithm2D.h
@@ -141,6 +141,9 @@ protected:
 	 */
 	bool setupGeometry();
 
+	/** Initialize CUDA algorithm. For internal use only.
+	 */
+	virtual void initCUDAAlgorithm();
 
 	/** The internally used CUDA algorithm object
 	 */ 
diff --git a/include/astra/CudaSirtAlgorithm.h b/include/astra/CudaSirtAlgorithm.h
index 929ac30..91cc206 100644
--- a/include/astra/CudaSirtAlgorithm.h
+++ b/include/astra/CudaSirtAlgorithm.h
@@ -93,8 +93,6 @@ public:
 	 */
 	virtual bool initialize(const Config& _cfg);
 
-	virtual void run(int _iNrIterations);
-
 	/** Initialize class.
 	 *
 	 * @param _pProjector		Projector Object. (Optional)
@@ -114,6 +112,8 @@ public:
 protected:
 	CFloat32VolumeData2D* m_pMinMask;
 	CFloat32VolumeData2D* m_pMaxMask;
+
+	virtual void initCUDAAlgorithm();
 };
 
 // inline functions
-- 
cgit v1.2.3


From f03ceb16d2dbde0c43e8c90683c5feafe01e5356 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Wed, 23 Mar 2016 15:30:47 +0100
Subject: Rename ART lambda option to Relaxation

---
 include/astra/ArtAlgorithm.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'include')

diff --git a/include/astra/ArtAlgorithm.h b/include/astra/ArtAlgorithm.h
index d232b95..1ad9f3f 100644
--- a/include/astra/ArtAlgorithm.h
+++ b/include/astra/ArtAlgorithm.h
@@ -59,7 +59,7 @@ namespace astra {
  * \astra_xml_item_option{MinConstraintValue, float, 0, Minimum constraint value.}
  * \astra_xml_item_option{UseMaxConstraint, bool, false, Use maximum value constraint.}
  * \astra_xml_item_option{MaxConstraintValue, float, 255, Maximum constraint value.}
- * \astra_xml_item_option{Lamda, float, 1, The relaxation factor.}
+ * \astra_xml_item_option{Relaxation, float, 1, The relaxation factor.}
  * \astra_xml_item_option{RayOrder, string, "sequential", the order in which the rays are updated. 'sequential' or 'custom'}
  * \astra_xml_item_option{RayOrderList, n by 2 vector of float, not used, if RayOrder='custom': use this ray order.  Each row consist of a projection id and detector id.}
  * 
@@ -73,7 +73,7 @@ namespace astra {
  *		cfg.option.UseMinConstraint = 'yes';\n 
  *		cfg.option.UseMaxConstraint = 'yes';\n
  *		cfg.option.MaxConstraintValue = 1024;\n
- *		cfg.option.Lamda = 0.7;\n
+ *		cfg.option.Relaxation = 0.7;\n
  *		cfg.option.RayOrder = 'custom';\n
  *		cfg.option.RayOrderList = [0\,0; 0\,2; 1\,0];\n
  *		alg_id = astra_mex_algorithm('create'\, cfg);\n
-- 
cgit v1.2.3


From 5edb35edc2c721b458334a65512b534912c2c542 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Wed, 23 Mar 2016 15:30:56 +0100
Subject: Add relaxation parameters to SIRT, SART

---
 include/astra/CudaSartAlgorithm.h       | 10 ++++++++++
 include/astra/CudaSirtAlgorithm.h       |  6 ++++++
 include/astra/DataProjectorPolicies.h   |  4 +++-
 include/astra/DataProjectorPolicies.inl |  6 ++++--
 include/astra/SartAlgorithm.h           |  8 ++++++--
 include/astra/SirtAlgorithm.h           |  9 ++++++++-
 6 files changed, 37 insertions(+), 6 deletions(-)

(limited to 'include')

diff --git a/include/astra/CudaSartAlgorithm.h b/include/astra/CudaSartAlgorithm.h
index c22dc4f..e5e18f0 100644
--- a/include/astra/CudaSartAlgorithm.h
+++ b/include/astra/CudaSartAlgorithm.h
@@ -46,6 +46,7 @@ namespace astra {
  * \astra_xml_item{ProjectionDataId, integer, Identifier of a projection data object as it is stored in the DataManager.}
  * \astra_xml_item{ReconstructionDataId, integer, Identifier of a volume data object as it is stored in the DataManager.}
  * \astra_xml_item_option{ReconstructionMaskId, integer, not used, Identifier of a volume data object that acts as a reconstruction mask. 0 = reconstruct on this pixel. 1 = don't reconstruct on this pixel.}
+ * \astra_xml_item_option{Relaxation, float, 1, The relaxation factor.}
  *
  * \par MATLAB example
  * \astra_code{
@@ -53,6 +54,7 @@ namespace astra {
  *		cfg.ProjectionDataId = sino_id;\n
  *		cfg.ReconstructionDataId = recon_id;\n
  *		cfg.option.ReconstructionMaskId = mask_id;\n
+ *		cfg.option.Relaxation = 1.0;\n
  *		alg_id = astra_mex_algorithm('create'\, cfg);\n
  *		astra_mex_algorithm('iterate'\, alg_id\, 10);\n
  *		astra_mex_algorithm('delete'\, alg_id);\n
@@ -97,6 +99,14 @@ public:
 	 * @return description string
 	 */
 	virtual std::string description() const;
+
+protected:
+
+	/** Relaxation factor
+	 */
+	float m_fLambda;
+
+	virtual void initCUDAAlgorithm();
 };
 
 // inline functions
diff --git a/include/astra/CudaSirtAlgorithm.h b/include/astra/CudaSirtAlgorithm.h
index 91cc206..3cd8acc 100644
--- a/include/astra/CudaSirtAlgorithm.h
+++ b/include/astra/CudaSirtAlgorithm.h
@@ -53,6 +53,7 @@ namespace astra {
  * \astra_xml_item{ProjectionDataId, integer, Identifier of a projection data object as it is stored in the DataManager.}
  * \astra_xml_item{ReconstructionDataId, integer, Identifier of a volume data object as it is stored in the DataManager.}
  * \astra_xml_item_option{ReconstructionMaskId, integer, not used, Identifier of a volume data object that acts as a reconstruction mask. 0 = reconstruct on this pixel. 1 = don't reconstruct on this pixel.}
+ * \astra_xml_item_option{Relaxation, float, 1, Relaxation parameter.}
  *
  * \par MATLAB example
  * \astra_code{
@@ -62,6 +63,7 @@ namespace astra {
  *		cfg.ProjectionDataId = sino_id;\n
  *		cfg.ReconstructionDataId = recon_id;\n
  *		cfg.option.ReconstructionMaskId = mask_id;\n
+ *		cfg.option.Relaxation = 1.0;\n
  *		alg_id = astra_mex_algorithm('create'\, cfg);\n
  *		astra_mex_algorithm('iterate'\, alg_id\, 10);\n
  *		astra_mex_algorithm('delete'\, alg_id);\n
@@ -113,6 +115,10 @@ protected:
 	CFloat32VolumeData2D* m_pMinMask;
 	CFloat32VolumeData2D* m_pMaxMask;
 
+	/** Relaxation factor
+	 */
+	float m_fLambda;
+
 	virtual void initCUDAAlgorithm();
 };
 
diff --git a/include/astra/DataProjectorPolicies.h b/include/astra/DataProjectorPolicies.h
index c258f5c..acfb36f 100644
--- a/include/astra/DataProjectorPolicies.h
+++ b/include/astra/DataProjectorPolicies.h
@@ -319,10 +319,12 @@ class SIRTBPPolicy {
 	CFloat32ProjectionData2D* m_pTotalRayLength;
 	CFloat32VolumeData2D* m_pTotalPixelWeight;
 
+	float m_fRelaxation;
+
 public:
 
 	FORCEINLINE SIRTBPPolicy();
-	FORCEINLINE SIRTBPPolicy(CFloat32VolumeData2D* _pReconstruction, CFloat32ProjectionData2D* _pSinogram, CFloat32VolumeData2D* _pTotalPixelWeight, CFloat32ProjectionData2D* _pTotalRayLength); 
+	FORCEINLINE SIRTBPPolicy(CFloat32VolumeData2D* _pReconstruction, CFloat32ProjectionData2D* _pSinogram, CFloat32VolumeData2D* _pTotalPixelWeight, CFloat32ProjectionData2D* _pTotalRayLength, float _fRelaxation);
 	FORCEINLINE ~SIRTBPPolicy();
 
 	FORCEINLINE bool rayPrior(int _iRayIndex);
diff --git a/include/astra/DataProjectorPolicies.inl b/include/astra/DataProjectorPolicies.inl
index 0c0eddd..f300761 100644
--- a/include/astra/DataProjectorPolicies.inl
+++ b/include/astra/DataProjectorPolicies.inl
@@ -712,12 +712,14 @@ SIRTBPPolicy::SIRTBPPolicy()
 SIRTBPPolicy::SIRTBPPolicy(CFloat32VolumeData2D* _pReconstruction, 
 						   CFloat32ProjectionData2D* _pSinogram, 
 						   CFloat32VolumeData2D* _pTotalPixelWeight, 
-						   CFloat32ProjectionData2D* _pTotalRayLength) 
+						   CFloat32ProjectionData2D* _pTotalRayLength,
+						   float _fRelaxation)
 {
 	m_pReconstruction = _pReconstruction;
 	m_pSinogram = _pSinogram;
 	m_pTotalPixelWeight = _pTotalPixelWeight;
 	m_pTotalRayLength = _pTotalRayLength;
+	m_fRelaxation = _fRelaxation;
 }
 //----------------------------------------------------------------------------------------	
 SIRTBPPolicy::~SIRTBPPolicy() 
@@ -739,7 +741,7 @@ void SIRTBPPolicy::addWeight(int _iRayIndex, int _iVolumeIndex, float32 _fWeight
 {
 	float32 fGammaBeta = m_pTotalPixelWeight->getData()[_iVolumeIndex] * m_pTotalRayLength->getData()[_iRayIndex];
 	if ((fGammaBeta > 0.001f) || (fGammaBeta < -0.001f)) {
-		m_pReconstruction->getData()[_iVolumeIndex] += _fWeight * m_pSinogram->getData()[_iRayIndex] / fGammaBeta;
+		m_pReconstruction->getData()[_iVolumeIndex] += _fWeight * m_fRelaxation * m_pSinogram->getData()[_iRayIndex] / fGammaBeta;
 	}
 }
 //----------------------------------------------------------------------------------------
diff --git a/include/astra/SartAlgorithm.h b/include/astra/SartAlgorithm.h
index eb4c61e..cdae029 100644
--- a/include/astra/SartAlgorithm.h
+++ b/include/astra/SartAlgorithm.h
@@ -49,7 +49,7 @@ namespace astra {
  *
  * The update step of pixel \f$v_j\f$ for projection \f$phi\f$ and iteration \f$k\f$ is given by:
  * \f[
- *	v_j^{(k+1)} = v_j^{(k)} + \frac{\sum_{p_i \in P_\phi} \left(  \lambda \frac{p_i - \sum_{r=1}^{N} w_{ir}v_r^{(k)}} {\sum_{r=1}^{N}w_{ir} }    \right)} {\sum_{p_i \in P_\phi}w_{ij}}
+ *	v_j^{(k+1)} = v_j^{(k)} + \lambda \frac{\sum_{p_i \in P_\phi} \left(  \frac{p_i - \sum_{r=1}^{N} w_{ir}v_r^{(k)}} {\sum_{r=1}^{N}w_{ir} }    \right)} {\sum_{p_i \in P_\phi}w_{ij}}
  * \f]
  *
  * \par XML Configuration
@@ -64,6 +64,7 @@ namespace astra {
  * \astra_xml_item_option{MaxConstraintValue, float, 255, Maximum constraint value.}
  * \astra_xml_item_option{ProjectionOrder, string, "sequential", the order in which the projections are updated. 'sequential', 'random' or 'custom'}
  * \astra_xml_item_option{ProjectionOrderList, vector of float, not used, if ProjectionOrder='custom': use this order.}
+ * \astra_xml_item_option{Relaxation, float, 1, The relaxation parameter.}
  *
  * \par MATLAB example
  * \astra_code{
@@ -76,7 +77,8 @@ namespace astra {
  *		cfg.option.UseMaxConstraint = 'yes';\n
  *		cfg.option.MaxConstraintValue = 1024;\n
  *		cfg.option.ProjectionOrder = 'custom';\n
-*		cfg.option.ProjectionOrderList = randperm(100);\n
+ *		cfg.option.ProjectionOrderList = randperm(100);\n
+ *		cfg.option.Relaxation = 1.0;\n
  *		alg_id = astra_mex_algorithm('create'\, cfg);\n
  *		astra_mex_algorithm('iterate'\, alg_id\, 10);\n
  *		astra_mex_algorithm('delete'\, alg_id);\n
@@ -215,6 +217,8 @@ protected:
 	//< Current index in the projection order array.
 	int m_iCurrentProjection;
 
+	//< Relaxation parameter
+	float m_fLambda;
 };
 
 // inline functions
diff --git a/include/astra/SirtAlgorithm.h b/include/astra/SirtAlgorithm.h
index 05b3fa9..8044d09 100644
--- a/include/astra/SirtAlgorithm.h
+++ b/include/astra/SirtAlgorithm.h
@@ -49,7 +49,7 @@ namespace astra {
  *
  * The update step of pixel \f$v_j\f$ for iteration \f$k\f$ is given by:
  * \f[
- *	v_j^{(k+1)} = v_j^{(k)} + \alpha \sum_{i=1}^{M} \left( \frac{w_{ij}\left( p_i - \sum_{r=1}^{N} w_{ir}v_r^{(k)}\right)}{\sum_{k=1}^{N} w_{ik}} \right) \frac{1}{\sum_{l=1}^{M}w_{lj}}
+ *	v_j^{(k+1)} = v_j^{(k)} + \lambda \sum_{i=1}^{M} \left( \frac{w_{ij}\left( p_i - \sum_{r=1}^{N} w_{ir}v_r^{(k)}\right)}{\sum_{k=1}^{N} w_{ik}} \right) \frac{1}{\sum_{l=1}^{M}w_{lj}}
  * \f]
  *
  * \par XML Configuration
@@ -62,6 +62,7 @@ namespace astra {
  * \astra_xml_item_option{MinConstraintValue, float, 0, Minimum constraint value.}
  * \astra_xml_item_option{UseMaxConstraint, bool, false, Use maximum value constraint.}
  * \astra_xml_item_option{MaxConstraintValue, float, 255, Maximum constraint value.}
+ * \astra_xml_item_option{Relaxation, float, 1, The relaxation factor.}
  *
  * \par XML Example
  * \astra_code{
@@ -74,6 +75,7 @@ namespace astra {
  *		&lt;Option key="UseMinConstraint" value="yes"/&gt;\n
  *		&lt;Option key="UseMaxConstraint" value="yes"/&gt;\n
  *		&lt;Option key="MaxConstraintValue" value="1024"/&gt;\n
+ *		&lt;Option key="Relaxation" value="1"/&gt;\n
  *		&lt;/Algorithm&gt;
  * }
  *
@@ -88,6 +90,7 @@ namespace astra {
  *		cfg.option.UseMinConstraint = 'yes';\n 
  *		cfg.option.UseMaxConstraint = 'yes';\n
  *		cfg.option.MaxConstraintValue = 1024;\n
+ *		cfg.option.Relaxation = 1.0;\n
  *		alg_id = astra_mex_algorithm('create'\, cfg);\n
  *		astra_mex_algorithm('iterate'\, alg_id\, 10);\n
  *		astra_mex_algorithm('delete'\, alg_id);\n
@@ -136,6 +139,10 @@ protected:
 	 */
 	int m_iIterationCount;
 
+	/** Relaxation parameter
+	 */
+	float m_fLambda;
+
 public:
 	
 	// type of the algorithm, needed to register with CAlgorithmFactory
-- 
cgit v1.2.3


From 16430239d04ff738a21146c410918c285552543f Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Wed, 23 Mar 2016 15:50:24 +0100
Subject: Add relaxation parameters to SIRT3D

---
 include/astra/CudaSirtAlgorithm3D.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'include')

diff --git a/include/astra/CudaSirtAlgorithm3D.h b/include/astra/CudaSirtAlgorithm3D.h
index 379720e..60191cd 100644
--- a/include/astra/CudaSirtAlgorithm3D.h
+++ b/include/astra/CudaSirtAlgorithm3D.h
@@ -50,7 +50,7 @@ class AstraSIRT3d;
  *
  * The update step of pixel \f$v_j\f$ for iteration \f$k\f$ is given by:
  * \f[
- *	v_j^{(k+1)} = v_j^{(k)} + \alpha \sum_{i=1}^{M} \left( \frac{w_{ij}\left( p_i - \sum_{r=1}^{N} w_{ir}v_r^{(k)}\right)}{\sum_{k=1}^{N} w_{ik}} \right) \frac{1}{\sum_{l=1}^{M}w_{lj}}
+ *	v_j^{(k+1)} = v_j^{(k)} + \lambda \sum_{i=1}^{M} \left( \frac{w_{ij}\left( p_i - \sum_{r=1}^{N} w_{ir}v_r^{(k)}\right)}{\sum_{k=1}^{N} w_{ik}} \right) \frac{1}{\sum_{l=1}^{M}w_{lj}}
  * \f]
  *
  * \par XML Configuration
@@ -175,6 +175,7 @@ protected:
 	bool m_bAstraSIRTInit;
 	int m_iDetectorSuperSampling;
 	int m_iVoxelSuperSampling;
+	float m_fLambda;
 
 	void initializeFromProjector();
 };
-- 
cgit v1.2.3