Blitz logo

Blitz Support :

From: Faheem Mitha (faheem_at_[hidden])
Date: 2004-12-19 00:29:15


Hi,

I'm trying to do the following

************************************************
#include <blitz/array.h>
#include <string>
#include <iostream>

main()
{
   blitz::Array<std::string, 2> A(2,2), B(2,2);
   A = "a", "b",
     "c", "d";

   B = "a", "b",
     "c", "d";

   blitz::Array<std::string, 2> C;
   C = A + B;
   std::cout << C << std::endl;
}
*************************************************

If my understanding is correct, this is supposed to print a matrix like

aa bb
cc dd

but instead I get

0 x 0
[ ]

Furthermore, the seemingly harmless modification

*****************************************************
#include <blitz/array.h>
#include <string>
#include <iostream>

main()
{
   blitz::Array<std::string, 2> A(2,2), B(2,2);
   A = "a", "b",
     "c", "d";

   B = "a", "b",
     "c", "d";

   blitz::Array<std::string, 2> C = A + B;
   std::cout << C << std::endl;
}
******************************************************

gives

error: conversion from `

blitz::_bz_ArrayExpr<blitz::_bz_ArrayExprBinaryOp<blitz::FastArrayIterator<std::string,
    2>, blitz::FastArrayIterator<std::string, 2>, blitz::Add<std::string,
    std::string> > >' to non-scalar type `blitz::Array<std::string, 2>'
    requested

Can someone tell me what I'm doing wrong? Thanks.

                                                         Faheem.