class Point : public Tensor<1,dim> {
public:
/**
- * Default constructor.
- */
- /**
* Constructor. Initialize all entries
- * to zero.
+ * to zero if #initialize==true#; this
+ * is the default behaviour.
*/
- explicit Point ();
+ explicit Point (const bool initialize = true);
/**
* Convert a tensor to a point. Since no
template <int dim>
inline
-Point<dim>::Point () :
- Tensor<1,dim>() {};
+Point<dim>::Point (const bool initialize) :
+ Tensor<1,dim>(initialize) {};
template <int dim>
*/
static const unsigned int rank = rank_;
+ /**
+ * Declare an array type which can
+ * be used to initialize statically
+ * an object of this type.
+ */
+ typedef typename Tensor<rank_-1,dim>::array_type array_type[dim];
+
+ /**
+ * Constructor. Initialize all entries
+ * to zero.
+ */
+ Tensor ();
+
+ /**
+ * Copy constructor, where the data is
+ * copied from a C-style array.
+ */
+ Tensor (const array_type &initializer);
+
/**
* Read-Write access operator.
*/
/*--------------------------- Inline functions -----------------------------*/
+
+template <int rank_, int dim>
+inline
+Tensor<rank_,dim>::Tensor () {
+// default constructor. not specifying an initializer list calls
+// the default constructor of the subobjects, which initialize them
+// selves. therefore, the tensor is set to zero this way
+};
+
+
+
+template <int rank_, int dim>
+inline
+Tensor<rank_,dim>::Tensor (const array_type &initializer) {
+ for (unsigned int i=0; i<dim; ++i)
+ subtensor[i] = Tensor<rank_-1,dim>(initializer[i]);
+};
+
+
+
+
template <int rank_, int dim>
inline
Tensor<rank_-1,dim> &
*/
static const unsigned int rank = 1;
+ /**
+ * Declare an array type which can
+ * be used to initialize statically
+ * an object of this type.
+ */
+ typedef double array_type[dim];
+
/**
* Constructor. Initialize all entries
- * to zero.
+ * to zero if #initialize==true#; this
+ * is the default behaviour.
*/
- explicit Tensor ();
+ explicit Tensor (const bool initialize = true);
+
+ /**
+ * Copy constructor, where the data is
+ * copied from a C-style array.
+ */
+ Tensor (const array_type &initializer);
/**
* Copy constructor.
template <int dim>
inline
-Tensor<1,dim>::Tensor () {
+Tensor<1,dim>::Tensor (const bool initialize) {
Assert (dim>0, ExcDimTooSmall(dim));
+ if (initialize)
+ for (unsigned int i=0; i<dim; ++i)
+ values[i] = 0;
+};
+
+
+
+template <int dim>
+inline
+Tensor<1,dim>::Tensor (const array_type &initializer) {
for (unsigned int i=0; i<dim; ++i)
- values[i] = 0;
+ values[i] = initializer[i];
};