示例#1
0
unsigned TagWriter::Write(const std::string& filename, 
			  const db::Recordset *tags)
{
    util::Mutex::Lock lock(s_taglib_mutex);

//    TRACE << "Opening '" << filename << "'\n";
	    
    typedef std::map<std::string, std::string> tagmap_t;
    tagmap_t tagmap;
    for (unsigned int i=0; i<mediadb::FIELD_COUNT; ++i)
    {
	const char *s = import::GetVorbisTagForField(i);
	if (s)
	{
	    std::string val = tags->GetString(i);
	    if (!val.empty())
		tagmap[s] = val;
	}
    }

    TagLib::FLAC::File tff(filename.c_str());
    TagLib::Ogg::XiphComment *oxc = tff.xiphComment(true);
    for (tagmap_t::const_iterator i = tagmap.begin(); i != tagmap.end(); ++i)
    {
	if (!i->second.empty())
	    oxc->addField(i->first, TagLib::String(i->second, 
						   TagLib::String::UTF8));
    }
    tff.save();
    TRACE << "FLAC file tagged\n";
    return 0;
}
示例#2
0
void cbSideBySideCtrl::ShowDiff(wxDiff diff)
{
    wxArrayInt right_added = diff.GetAddedLines();
    wxArrayInt right_empty = diff.GetRightEmptyLines();
    wxArrayInt left_empty = diff.GetLeftEmptyLines();
    wxArrayInt left_removed = diff.GetRemovedLines();

    /* Left Textctrl (m_fromfile) */
    TCLeft->SetReadOnly(false);
    TCLeft->ClearAll();
    wxTextFile tff(diff.GetFromFilename());
    tff.Open();
    bool refill = false;
    wxString str = tff.GetFirstLine();
    int linecount = tff.GetLineCount() + left_empty.GetCount();
    int linenumber = 1;
    for (int i = 0; i < linecount; i++)
    {
        if(refill && !tff.Eof())
            str = tff.GetNextLine();
        if(left_removed.Index(i+1) != wxNOT_FOUND)
        {
            TCLeft->AppendText(str + _T("\n"));
            refill = true;
            TCLeft->MarginSetStyle(i, wxSCI_STYLE_LINENUMBER);
            TCLeft->MarginSetText(i,wxString::Format(_T("%d"),linenumber));
            TCLeft->MarkerAdd(i, MINUS_MARKER);
            TCLeft->MarkerAdd(i, RED_BKG_MARKER);
            linenumber++;
            continue;
        }
        if(left_empty.Index(i+1) != wxNOT_FOUND)
        {
            TCLeft->AppendText(_T("\n"));
            TCLeft->MarkerAdd(i, GREY_BKG_MARKER);
            refill = false;
            continue;
        }
        TCLeft->AppendText(str + _T("\n"));
        refill = true;
        TCLeft->MarginSetStyle(i, wxSCI_STYLE_LINENUMBER);
        TCLeft->MarginSetText(i,wxString::Format(_T("%d"),linenumber));
        TCLeft->MarkerAdd(i, EQUAL_MARKER);
        linenumber++;
    }
    TCLeft->SetReadOnly(true);

    /* Right Textctrl (m_tofile) */
    TCRight->SetReadOnly(false);
    TCRight->ClearAll();
    wxTextFile tft(diff.GetToFilename());
    tft.Open();
    refill = false;
    str = tft.GetFirstLine();
    linecount = tft.GetLineCount() + right_empty.GetCount();
    linenumber = 1;
    for (int i = 0; i < linecount; i++)
    {
        if(refill && !tft.Eof())
            str = tft.GetNextLine();
        if(right_added.Index(i+1) != wxNOT_FOUND)
        {
            TCRight->AppendText(str + _T("\n"));
            refill = true;
            TCRight->MarginSetStyle(i, wxSCI_STYLE_LINENUMBER);
            TCRight->MarginSetText(i, wxString::Format(_T("%d"),linenumber));
            linenumber++;
            TCRight->MarkerAdd(i, PLUS_MARKER);
            TCRight->MarkerAdd(i, GREEN_BKG_MARKER);
            continue;
        }
        if(right_empty.Index(i+1) != wxNOT_FOUND)
        {
            TCRight->AppendText(_T("\n"));
            TCRight->MarkerAdd(i, GREY_BKG_MARKER);
            refill = false;
            continue;
        }
        TCRight->AppendText(str + _T("\n"));
        refill = true;
        TCRight->MarginSetStyle(i, wxSCI_STYLE_LINENUMBER);
        TCRight->MarginSetText(i, wxString::Format(_T("%d"),linenumber));
        TCRight->MarkerAdd(i, EQUAL_MARKER);
        linenumber++;
    }
    TCRight->SetReadOnly(true);
}
示例#3
0
void Histogram_gui::changeCurve(const QString & s)
{
	std::map<float,int>::iterator itr;

	int total = histogram_->rawDataSize();
	int i = 0;
	QwtText tfp("Probability");
	tfp.setFont(plot_->axisFont(QwtPlot::yLeft));	

	QwtText tff("Frequency");
	tff.setFont(plot_->axisFont(QwtPlot::yLeft));	

	QColor blueColor(Qt::blue);
	const QPen pen(blueColor);
	std::pair<double*,double*> curve = histogram_->plotting_data();
	if (!curve.first) {
		appli_message("No data present");
		return;
	}

	if (s == "cdf") {
	    std::map<float, int> freqCount = histogram_->frequency();

		_cdfCurve->setAxis(QwtPlot::xBottom, QwtPlot::yLeft);


		plot_->setAxisTitle(QwtPlot::yLeft, tfp);
		plot_->enableAxis(QwtPlot::yRight,false);

		curve_grid_->enableY(true);
		curve_grid_->setYAxis(QwtPlot::yLeft);
		
		plot_->enableAxis(QwtPlot::yLeft);

		curve_id_->setStyle(QwtPlotCurve::NoCurve);
		_cdfCurve->setStyle(QwtPlotCurve::Lines);

		double * x = new double[freqCount.size()+1];
		double * y = new double[freqCount.size()+1];

		y[0] = 0;
		for (itr = freqCount.begin(); itr != freqCount.end(); ++itr,++i) {
			x[i+1] = itr->first;
			y[i+1] = y[i]+(double)(itr->second)/(double)(total);
		}
		x[0] = x[1];

		_cdfCurve->setPen(pen);
		_cdfCurve->setData(  x, y, freqCount.size()+1 );
		refresh_plot( _cdfCurve, std::make_pair( x,y ), freqCount.size()+1 );
		refresh_stats();


		delete []x;
		delete []y;
	}
	else if (s == "pdf") {
	        //_cdfCurve->detach();
		
		plot_->enableAxis(QwtPlot::yRight, false);
		plot_->setAxisTitle(QwtPlot::yLeft, tff);
		plot_->enableAxis(QwtPlot::xBottom);
		
		curve_id_->setAxis(QwtPlot::xBottom, QwtPlot::yLeft);
		curve_grid_->setYAxis(QwtPlot::yLeft);
		curve_grid_->enableY(true);

		curve_grid_->setXAxis(QwtPlot::xBottom);
		curve_grid_->enableX(true);

		_cdfCurve->setStyle(QwtPlotCurve::NoCurve);
		curve_id_->setStyle(QwtPlotCurve::Histogram);

		int size = histogram_->bins()+1;
		double* x = new double[size+1];
		double* y = new double[size+1];
		for( int i =0 ; i < size ; i++ ) {
			x[i+1] = curve.first[i];
			y[i+1] = curve.second[i];
		}
		x[0] = x[1];
		y[0] = 0.0;

		refresh_plot(  std::make_pair( x,y ), size+1 );
		refresh_stats();
		delete []x;
		delete []y;
	}
	else {

	    std::map<float, int> freqCount = histogram_->frequency();

	    _cdfCurve->setAxis(QwtPlot::xBottom, QwtPlot::yRight);

	    plot_->enableAxis(QwtPlot::yRight, true);
	    plot_->enableAxis(QwtPlot::yLeft, true);
				   
	    curve_grid_->setYAxis(QwtPlot::yLeft);


	    plot_->setAxisTitle(QwtPlot::yLeft, tff);
	    plot_->setAxisTitle(QwtPlot::yRight, tfp);

	    _cdfCurve->setStyle(QwtPlotCurve::Lines);
	    curve_id_->setStyle(QwtPlotCurve::Histogram);

	    double * x = new double[freqCount.size()+1];
	    double * y = new double[freqCount.size()+1];

	    y[0] = 0;
	    for (itr = freqCount.begin(); itr != freqCount.end(); ++itr,++i) {
	      x[i+1] = itr->first;
	      y[i+1] = y[i]+(double)(itr->second)/(double)(total);
	    }
	    x[0] = x[1];

	    _cdfCurve->setPen(pen);
	    _cdfCurve->setData( x, y, freqCount.size()+1 );
	    refresh_plot( _cdfCurve, std::make_pair( x,y ), freqCount.size()+1 );
	    //refresh_stats();


	    int size = histogram_->bins()+1;
	    double* x1 = new double[size+1];
	    double* y1 = new double[size+1];
	    for( int i =0 ; i < size ; i++ ) {
	      x1[i+1] = curve.first[i];
	      y1[i+1] = curve.second[i];
	    }
	    x1[0] = x1[1];
	    y1[0] = 0.0;

	    refresh_plot(  std::make_pair( x1,y1 ), size+1 );
	    refresh_stats();

	    delete []x1;
	    delete []y1;
	    delete []x;
	    delete []y;

	}
		  //plot_->replot();

}
void testSymmetrize(Pooma::Tester &tester)
{

  tester.out() << std::endl << "========= " << D << "D =========" << std::endl;

  // Create Full, Antisymmetric, Symmetric, and Diagonal Tensors as inputs:
  Tensor<D,double,Full> tf;
  double value = 1.0;
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < D; j++) {
      tf(i,j) = value;
      value++;
    }
  }
  tester.out() << "tf: " << tf << std::endl;
  Tensor<D,double,Antisymmetric> ta;
  value = 1.0;
  for (int i = 0; i < TensorStorageSize<D,Antisymmetric>::Size; i++) {
    ta(i) = i + 1.0;
  }
  tester.out() << "ta: " << ta << std::endl;
  Tensor<D,double,Symmetric> ts;
  for (int i = 0; i < TensorStorageSize<D,Symmetric>::Size; i++) {
    ts(i) = i + 1.0;
  }
  tester.out() << "ts: " << ts << std::endl;
  Tensor<D,double,Diagonal> td;
  for (int i = 0; i < TensorStorageSize<D,Diagonal>::Size; i++) {
    td(i) = i + 1.0;
  }
  tester.out() << "td: " << td << std::endl;

  //---------------------------------------------------------------------------
  // Make Fields of these types, to test forwarding of symmetrize<>() function:
  // Create the physical Domains:
  const int nVerts = 6;
  const int nCells = nVerts - 1;
  int nCellsTot = 1;
  Interval<D> vertexDomain;
  for (int d = 0; d < D; d++) {
    vertexDomain[d] = Interval<1>(nVerts);
    nCellsTot *= nCells;
  }

  // Create the (uniform, logically rectilinear) mesh.
  Vector<D> origin(0.0), spacings(0.2);
  typedef UniformRectilinearMesh<D> Mesh_t;
  DomainLayout<D> layout(vertexDomain, GuardLayers<D>(0));

  // Create the Fields:
  Centering<D> cell = canonicalCentering<D>(CellType, Continuous);

  // Full, Antisymmetric, Symmetric, Diagonal Tensor Fields:
  Field<Mesh_t,Tensor<D,double,Full> > tff(cell, layout, origin, spacings);
  Field<Mesh_t,Tensor<D,double,Symmetric> >
    tfs(cell, layout, origin, spacings);
  Field<Mesh_t,Tensor<D,double,Antisymmetric> >
    tfa(cell, layout, origin, spacings);
  Field<Mesh_t,Tensor<D,double,Diagonal> > tfd(cell, layout, origin, spacings);

  // Assign to the single-Tensor values:
  tff = tf;
  tfs = ts;
  tfa = ta;
  tfd = td;

#ifndef __MWERKS__ // This whole module is too much for CW5 to compile
  // --------------------------------------------------------------------------
  // Symmetrize from Full tensor to {Antisymmetric, Symmetric, Diagonal}:

  // To Antisymmetric:
  if (!tester.check("symmetrize<Antisymmetric>(tf): ", 
                    (symmetrize<Antisymmetric>(tf) == 
                     makeAntisymmetric(tf)))) {
    tester.out() << "symmetrize<Antisymmetric>(tf) = " 
                 << symmetrize<Antisymmetric>(tf) 
                 << " != makeAntisymmetric(tf) = " 
                 << makeAntisymmetric(tf) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Antisymmetric>(tff)): ", 
                    (sum(symmetrize<Antisymmetric>(tff)) == 
                     nCellsTot*makeAntisymmetric(tf)))) {
    tester.out() << "sum(symmetrize<Antisymmetric>(tff)) = " 
                 << sum(symmetrize<Antisymmetric>(tff)) 
                 << " != nCellsTot*makeAntisymmetric(tf) = "
                 << nCellsTot*makeAntisymmetric(tf) << std::endl;
  }


  // To Symmetric:
  if (!tester.check("symmetrize<Symmetric>(tf): ", 
                    (symmetrize<Symmetric>(tf) == 
                     makeSymmetric(tf)))) {
    tester.out() << "symmetrize<Symmetric>(tf) = " 
                 << symmetrize<Symmetric>(tf) 
                 << " != makeSymmetric(tf) = " 
                 << makeSymmetric(tf) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Symmetric>(tff)): ", 
                    (sum(symmetrize<Symmetric>(tff)) == 
                     nCellsTot*makeSymmetric(tf)))) {
    tester.out() << "sum(symmetrize<Symmetric>(tff)) = " 
                 << sum(symmetrize<Symmetric>(tff)) 
                 << " != nCellsTot*makeSymmetric(tf) = "
                 << nCellsTot*makeSymmetric(tf) << std::endl;
  }

  // To Diagonal::
  if (!tester.check("symmetrize<Diagonal>(tf): ", 
                    (symmetrize<Diagonal>(tf) == 
                     makeDiagonal(tf)))) {
    tester.out() << "symmetrize<Diagonal>(tf) = " 
                 << symmetrize<Diagonal>(tf) 
                 << " != makeDiagonal(tf) = " 
                 << makeDiagonal(tf) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Diagonal>(tff)): ", 
                    (sum(symmetrize<Diagonal>(tff)) == 
                     nCellsTot*makeDiagonal(tf)))) {
    tester.out() << "sum(symmetrize<Diagonal>(tff)) = " 
                 << sum(symmetrize<Diagonal>(tff)) 
                 << " != nCellsTot*makeDiagonal(tf) = "
                 << nCellsTot*makeDiagonal(tf) << std::endl;
  }

  // --------------------------------------------------------------------------
  // Symmetrize from Antisymmetric tensor to {Full, Symmetric, Diagonal}:

  // To Full:
  if (!tester.check("symmetrize<Full>(ta): ", 
                    (symmetrize<Full>(ta) == 
                     makeFull(ta)))) {
    tester.out() << "symmetrize<Full>(ta) = " 
                 << symmetrize<Full>(ta) 
                 << " != makeFull(ta) = " 
                 << makeFull(ta) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Full>(tfa)): ", 
                    (sum(symmetrize<Full>(tfa)) == 
                     nCellsTot*makeFull(ta)))) {
    tester.out() << "sum(symmetrize<Full>(tfa)) = " 
                 << sum(symmetrize<Full>(tfa)) 
                 << " != nCellsTot*makeFull(ta) = "
                 << nCellsTot*makeFull(ta) << std::endl;
  }

  // To Symmetric:
  if (!tester.check("symmetrize<Symmetric>(ta): ", 
                    (symmetrize<Symmetric>(ta) == 
                     makeSymmetric(ta)))) {
    tester.out() << "symmetrize<Symmetric>(ta) = " 
                 << symmetrize<Symmetric>(ta) 
                 << " != makeSymmetric(ta) = " 
                 << makeSymmetric(ta) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Symmetric>(tfa)): ", 
                    (sum(symmetrize<Symmetric>(tfa)) == 
                     nCellsTot*makeSymmetric(ta)))) {
    tester.out() << "sum(symmetrize<Symmetric>(tfa)) = " 
                 << sum(symmetrize<Symmetric>(tfa)) 
                 << " != nCellsTot*makeSymmetric(ta) = "
                 << nCellsTot*makeSymmetric(ta) << std::endl;
  }

  // To Diagonal::
  if (!tester.check("symmetrize<Diagonal>(ta): ", 
                    (symmetrize<Diagonal>(ta) == 
                     makeDiagonal(ta)))) {
    tester.out() << "symmetrize<Diagonal>(ta) = " 
                 << symmetrize<Diagonal>(ta) 
                 << " != makeDiagonal(ta) = " 
                 << makeDiagonal(ta) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Diagonal>(tfa)): ", 
                    (sum(symmetrize<Diagonal>(tfa)) == 
                     nCellsTot*makeDiagonal(ta)))) {
    tester.out() << "sum(symmetrize<Diagonal>(tfa)) = " 
                 << sum(symmetrize<Diagonal>(tfa)) 
                 << " != nCellsTot*makeDiagonal(ta) = "
                 << nCellsTot*makeDiagonal(ta) << std::endl;
  }
#endif // __MWERKS__ 

  // --------------------------------------------------------------------------
  // Symmetrize from Symmetric tensor to {Full, Antisymmetric, Diagonal}:

  // To Full:
  if (!tester.check("symmetrize<Full>(ts): ", 
                    (symmetrize<Full>(ts) == 
                     makeFull(ts)))) {
    tester.out() << "symmetrize<Full>(ts) = " 
                 << symmetrize<Full>(ts) 
                 << " != makeFull(ts) = " 
                 << makeFull(ts) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Full>(tfs)): ", 
                    (sum(symmetrize<Full>(tfs)) == 
                     nCellsTot*makeFull(ts)))) {
    tester.out() << "sum(symmetrize<Full>(tfs)) = " 
                 << sum(symmetrize<Full>(tfs)) 
                 << " != nCellsTot*makeFull(ts) = "
                 << nCellsTot*makeFull(ts) << std::endl;
  }

  // To Antisymmetric:
  if (!tester.check("symmetrize<Antisymmetric>(ts): ", 
                    (symmetrize<Antisymmetric>(ts) == 
                     makeAntisymmetric(ts)))) {
    tester.out() << "symmetrize<Antisymmetric>(ts) = " 
                 << symmetrize<Antisymmetric>(ts) 
                 << " != makeAntisymmetric(ts) = " 
                 << makeAntisymmetric(ts) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Antisymmetric>(tfs)): ", 
                    (sum(symmetrize<Antisymmetric>(tfs)) == 
                     nCellsTot*makeAntisymmetric(ts)))) {
    tester.out() << "sum(symmetrize<Antisymmetric>(tfs)) = " 
                 << sum(symmetrize<Antisymmetric>(tfs)) 
                 << " != nCellsTot*makeAntisymmetric(ts) = "
                 << nCellsTot*makeAntisymmetric(ts) << std::endl;
  }

  // To Diagonal::
  if (!tester.check("symmetrize<Diagonal>(ts): ", 
                    (symmetrize<Diagonal>(ts) == 
                     makeDiagonal(ts)))) {
    tester.out() << "symmetrize<Diagonal>(ts) = " 
                 << symmetrize<Diagonal>(ts) 
                 << " != makeDiagonal(ts) = " 
                 << makeDiagonal(ts) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Diagonal>(tfs)): ", 
                    (sum(symmetrize<Diagonal>(tfs)) == 
                     nCellsTot*makeDiagonal(ts)))) {
    tester.out() << "sum(symmetrize<Diagonal>(tfs)) = " 
                 << sum(symmetrize<Diagonal>(tfs)) 
                 << " != nCellsTot*makeDiagonal(ts) = "
                 << nCellsTot*makeDiagonal(ts) << std::endl;
  }

  // --------------------------------------------------------------------------
  // Symmetrize from Diagonal tensor to {Full, Antisymmetric, Symmetric}:

  // To Full:
  if (!tester.check("symmetrize<Full>(td): ", 
                    (symmetrize<Full>(td) == 
                     makeFull(td)))) {
    tester.out() << "symmetrize<Full>(td) = " 
                 << symmetrize<Full>(td) 
                 << " != makeFull(td) = " 
                 << makeFull(td) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Full>(tfd)): ", 
                    (sum(symmetrize<Full>(tfd)) == 
                     nCellsTot*makeFull(td)))) {
    tester.out() << "sum(symmetrize<Full>(tfd)) = " 
                 << sum(symmetrize<Full>(tfd)) 
                 << " != nCellsTot*makeFull(td) = "
                 << nCellsTot*makeFull(td) << std::endl;
  }

  // To Antisymmetric:
  if (!tester.check("symmetrize<Antisymmetric>(td): ", 
                    (symmetrize<Antisymmetric>(td) == 
                     makeAntisymmetric(td)))) {
    tester.out() << "symmetrize<Antisymmetric>(td) = " 
                 << symmetrize<Antisymmetric>(td) 
                 << " != makeAntisymmetric(td) = " 
                 << makeAntisymmetric(td) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Antisymmetric>(tfd)): ", 
                    (sum(symmetrize<Antisymmetric>(tfd)) == 
                     nCellsTot*makeAntisymmetric(td)))) {
    tester.out() << "sum(symmetrize<Antisymmetric>(tfd)) = " 
                 << sum(symmetrize<Antisymmetric>(tfd)) 
                 << " != nCellsTot*makeAntisymmetric(td) = "
                 << nCellsTot*makeAntisymmetric(td) << std::endl;
  }

  // To Symmetric:
  if (!tester.check("symmetrize<Symmetric>(td): ", 
                    (symmetrize<Symmetric>(td) == 
                     makeSymmetric(td)))) {
    tester.out() << "symmetrize<Symmetric>(td) = " 
                 << symmetrize<Symmetric>(td) 
                 << " != makeSymmetric(td) = " 
                 << makeSymmetric(td) << std::endl;
  }
  if (!tester.check("sum(symmetrize<Symmetric>(tfd)): ", 
                    (sum(symmetrize<Symmetric>(tfd)) == 
                     nCellsTot*makeSymmetric(td)))) {
    tester.out() << "sum(symmetrize<Symmetric>(tfd)) = " 
                 << sum(symmetrize<Symmetric>(tfd)) 
                 << " != nCellsTot*makeSymmetric(td) = "
                 << nCellsTot*makeSymmetric(td) << std::endl;
  }

}
示例#5
0
void testTrace(Pooma::Tester &tester)
{
  // Create the physical Domains:
  const int nVerts = 6;
  const int nCells = nVerts - 1;
  int nCellsTot = 1;
  Interval<Dim> vertexDomain;
  for (int d = 0; d < Dim; d++) {
    vertexDomain[d] = Interval<1>(nVerts);
    nCellsTot *= nCells;
  }

  // Create the (uniform, logically rectilinear) mesh.
  Vector<Dim> origin(0.0), spacings(0.2);
  typedef UniformRectilinearMesh<Dim> Mesh_t;
  DomainLayout<Dim> layout(vertexDomain, GuardLayers<Dim>(0));

  // Create the Fields:
  Centering<Dim> cell = canonicalCentering<Dim>(CellType, Continuous);

  // Full, Antisymmetric, Symmetric, Diagonal Tensor Fields:
  Field<Mesh_t,Tensor<Dim,double,Full> > tff(cell, layout, origin, spacings);
  Field<Mesh_t,Tensor<Dim,double,Antisymmetric> >
    tfa(cell, layout, origin, spacings);
  Field<Mesh_t,Tensor<Dim,double,Symmetric> >
    tfs(cell, layout, origin, spacings);
  Field<Mesh_t,Tensor<Dim,double,Diagonal> >
    tfd(cell, layout, origin, spacings);

  // Assign values:
  Tensor<Dim,double,Full> tf(0.0);
  Tensor<Dim,double,Antisymmetric> ta(0.0);
  Tensor<Dim,double,Symmetric> ts(0.0);
  Tensor<Dim,double,Diagonal> td(0.0);
  double fullSymDiagTrace = 0.0;
  for (int i = 0; i < Dim; i++) {
    for (int j = 0; j < Dim; j++) {
      tf(i,j) = (i+1)*(i+1) + (j+1)*(j+1) + (i+4)*(j+4) + i;
      if (i == j) fullSymDiagTrace += tf(i,j);
    }
  }
  //  tester.out() << "tf = " << tf << std::endl;
  ta = symmetrize<Antisymmetric>(tf);
  ts = symmetrize<Symmetric>(tf);
  td = symmetrize<Diagonal>(tf);
  tff = tf;
  tfa = ta;
  tfs = ts;
  tfd = td;

  // Test trace of Full Tensor:
  double traceValue;
  traceValue = sum(trace(tff));
  tester.out() << "traceValue = sum(trace(tff)): " << traceValue << std::endl;
  tester.check("traceValue", traceValue, fullSymDiagTrace*nCellsTot);

  // Test trace of Symmetric Tensor:
  traceValue = sum(trace(tfs));
  if (!tester.check("traceValue", traceValue, fullSymDiagTrace*nCellsTot)) {
    tester.out() << Dim << "D, sum(trace(tfs)): " << traceValue 
                 << " != fullSymDiagTrace*nCellsTot = " 
                 << fullSymDiagTrace*nCellsTot << std::endl;
  }

  // Test trace of Antisymmetric Tensor:
  traceValue = sum(trace(tfa));
  if (!tester.check("traceValue", traceValue, 0.0*nCellsTot)) {
    tester.out() << Dim << "D, sum(trace(tfa)): " << traceValue 
                 << " != 0.0" << std::endl;
  }

  // Test trace of Diagonal Tensor:
  traceValue = sum(trace(tfd));
  if (!tester.check("traceValue", traceValue, fullSymDiagTrace*nCellsTot)) {
    tester.out() << Dim << "D, sum(trace(tfd)): " << traceValue 
                 << " != fullSymDiagTrace*nCellsTot = " 
                 << fullSymDiagTrace*nCellsTot << std::endl;
  }

}