Esempio n. 1
0
void nyx_set_audio_params(double rate, long len)
{
   LVAL flo;
   LVAL con;

   xlstkcheck(2);
   xlsave(flo);
   xlsave(con);

   /* Bind the sample rate to the "*sound-srate*" global */
   flo = cvflonum(rate);
   setvalue(xlenter("*SOUND-SRATE*"), flo);

   /* Bind selection len to "len" global */
   flo = cvflonum(len);
   setvalue(xlenter("LEN"), flo);

   /* Set the "*warp*" global based on the length of the audio */
   con = cons(NULL, NULL);
   flo = cvflonum(len > 0 ? (double) len / rate : 1.0);
   con = cons(flo, con);
   flo = cvflonum(0);
   con = cons(flo, con);
   setvalue(xlenter("*WARP*"), con);

   xlpopn(2);
}
Esempio n. 2
0
File: xleval.c Progetto: 8l/csolve
/* evalhook - call the evalhook function */
LOCAL NODE *evalhook(NODE *expr)
{
    NODE ***oldstk,*ehook __HEAPIFY,*ahook __HEAPIFY,*args __HEAPIFY,*val;

    /* create a new stack frame */
    oldstk = xlsave3(&ehook,&ahook,&args);

    /* make an argument list */
    args = consa(expr);
    rplacd(args,consa(xlenv));

    /* rebind the hook functions to nil */
    ehook = getvalue(s_evalhook);
    setvalue(s_evalhook,NIL);
    ahook = getvalue(s_applyhook);
    setvalue(s_applyhook,NIL);

    /* call the hook function */
    val = xlapply(ehook,args);

    /* unbind the symbols */
    setvalue(s_evalhook,ehook);
    setvalue(s_applyhook,ahook);

    /* restore the previous stack frame */
    xlstack = oldstk;

    /* return the value */
    return (val);
}
Esempio n. 3
0
LOCAL VOID set_hardware_address P3C(CPTR, ptr, LVAL, object, int *, type)
{
  LVAL t, p, last, result, oblistsym, newoblist;
  
  if (! objectp(object)) xlerror("not an object", object);
  
  oblistsym = s_hardware_objects;
  if (! consp(getvalue(oblistsym))) setvalue(oblistsym, NIL);
  
  xlstkcheck(4);
  xlsave(t);
  xlsave(p);
  xlsave(result);
  xlsave(newoblist);
  
  t = cvfixnum((FIXTYPE) time_stamp);
  p = cvfixnum((FIXTYPE) ptr);
  result = last = consa(object);
  result = cons(p, result);
  result = cons(t, result);
  
  newoblist = cons(result, getvalue(oblistsym));
  setvalue(oblistsym, newoblist);
  set_slot_value(object, s_hardware_address, result);
  
  for (;*type != NONE; type++, last = cdr(last)) {
    t = cvfixnum((FIXTYPE) *type);
    t = consa(t);
    rplacd(last, t);
  }
  xlpopn(4);
}
Esempio n. 4
0
char *askUserPass(const char *title)
{
    static window win = NULL;
    dialog_data *d;
    window prev = current_window;

    if (! win) {
	int tw, bw, h, middle;

	tw = strwidth(SystemFont, G_("Cancel")) * 8;
	h = getheight(SystemFont);
	if (tw < 150) tw = 150;
	win = newwindow(title, rect(0, 0, tw+30, h*9+12),
			Titlebar | Centered | Modal);
	setbackground(win, dialog_bg());
	add_data(win);
	d = data(win);
	d->question = newlabel(G_("User"), rect(10, h, tw+4, h*2+2), AlignLeft);
	bw = strwidth(SystemFont, G_("Password"));
	d->text = newfield("", rect(20+bw, h, tw-6-bw, h*3/2));
	newlabel(_("Password"), rect(10, h*4, tw+4, h*2+2), AlignLeft);
	d->pass = newpassword("", rect(20+bw, h*4, tw-6-bw, h*3/2));
	middle = (tw+30)/2;
	bw = strwidth(SystemFont, G_("Cancel")) * 3/2;

	d->yes = newbutton(G_("OK"),
			   rect(middle-bw-10, h*7, bw, h+10), hit_button);
	setvalue(d->yes, YES);

	d->cancel = newbutton(G_("Cancel"),
			      rect(middle+10, h*7, bw, h+10), hit_button);
	setvalue(d->cancel, CANCEL);

	setkeydown(win, hit_key);
    } else {
	d = data(win);
	settext(d->text, "");
	settext(d->pass, "");
    }
    if (TopmostDialogs & MB_TOPMOST)
	BringToTop(win, 1);
    handle_message_dialog(win);
    current_window = prev;
    {
	char *user, *pass;
	static char buf[1000];
	if (d->hit < YES) /* cancelled */ return "";
	if (d->text) user = new_string(GA_gettext(d->text));
	else return "";
	if (d->pass) pass = new_string(GA_gettext(d->pass));
	else return "";
	snprintf(buf, 1000, "%s:%s", user, pass);
	return buf;
    }
    return ""; /* -Wall */
}
Esempio n. 5
0
/* parse - read and parse an input line */
int parse()
{
    if (!parse1())
	return (FALSE);
    setvalue(V_ACTOR,actor);
    setvalue(V_ACTION,action);
    setvalue(V_DOBJECT,dobject);
    setvalue(V_NDOBJECTS,ndobjects);
    setvalue(V_IOBJECT,iobject);
    return (TRUE);
}
Esempio n. 6
0
menu newmdimenu()
{
    menu m ;
    if (!ismdi()) return NULL;
    m = newmenu(G_("Windows"));
    setvalue(newmenuitem(G_("Cascade"),0,mdimenu),1);
    setvalue(newmenuitem(G_("Tile &Horizontally"),0,mdimenu),2);
    setvalue(newmenuitem(G_("Tile &Vertically"),0,mdimenu),3);
    setvalue(newmenuitem(G_("Arrange Icons"),0,mdimenu),4);
    current_menubar->menubar = m;
    return m;
}
Esempio n. 7
0
/* next - get the next command (next direct object) */
int next()
{
    if (getvalue(V_NDOBJECTS) > 1) {
	setvalue(V_ACTOR,actor);
	setvalue(V_ACTION,action);
	setvalue(V_DOBJECT,getvalue(V_DOBJECT) + 1);
	setvalue(V_NDOBJECTS,getvalue(V_NDOBJECTS) - 1);
	setvalue(V_IOBJECT,iobject);
	return (TRUE);
    }
    else
	return (FALSE);
}
Esempio n. 8
0
File: xlsym.c Progetto: 8l/csolve
/* xlmakesym - make a new symbol node */
NODE *xlmakesym(char *name,int type)
{
    NODE *sym;
    sym = (type == DYNAMIC ? cvsymbol(name) : cvcsymbol(name));
    setvalue(sym,*name == ':' ? sym : s_unbound);
    return (sym);
}
ArrayOfMatrices::ArrayOfMatrices (const mxArray* ptrs[], int numptrs)
  : Array<Matrix*>(numptrs) {
  setvalue(0);
  
  for (int i = 0; i < numptrs; i++)
    elems[i] = new Matrix(ptrs[i]);
  }
Esempio n. 10
0
void
GAParameter::copy(const GAParameter& orig)
{
    if(&orig == this)
    {
        return;
    }

    delete [] fname;
    delete [] sname;
    if(orig.fname)
    {
        fname = new char[strlen(orig.fname) + 1];
        strcpy(fname, orig.fname);
    }
    else
    {
        fname = (char *)0;
    }
    if(orig.sname)
    {
        sname = new char[strlen(orig.sname) + 1];
        strcpy(sname, orig.sname);
    }
    else
    {
        sname = (char *)0;
    }

    t = orig.t;
    setvalue(orig.value());	/// do this directly...
}
Esempio n. 11
0
/* xlsetvalue - set the value of a symbol */
void xlsetvalue(LVAL sym, LVAL val)
{
    register LVAL fp,ep;

    /* look for the symbol in the environment list */
    for (fp = xlenv; fp; fp = cdr(fp))

        /* check for an instance variable */
        if ((ep = car(fp)) && objectp(car(ep))) {
            if (xlobsetvalue(ep,sym,val))
                return;
        }

        /* check an environment stack frame */
        else {
            for (; ep; ep = cdr(ep))
                if (sym == car(car(ep))) {
                    rplacd(car(ep),val);
                    return;
                }
        }

    /* store the global value */
    setvalue(sym,val);
}
Esempio n. 12
0
/* xlrinit - initialize the reader */
void xlrinit(void)
{
    LVAL rtable;
    char *p;
    int ch;

    /* create the read table */
    rtable = newvector(256);
    setvalue(s_rtable,rtable);

    /* initialize the readtable */
    for (p = WSPACE; ch = *p++; )
        setelement(rtable,ch,k_wspace);
    for (p = CONST1; ch = *p++; )
        setelement(rtable,ch,k_const);
    for (p = CONST2; ch = *p++; )
        setelement(rtable,ch,k_const);

    /* setup the escape characters */
    setelement(rtable,'\\',k_sescape);
    setelement(rtable,'|', k_mescape);

    /* install the read macros */
    defmacro('#', k_nmacro,FT_RMHASH);
    defmacro('\'',k_tmacro,FT_RMQUOTE);
    defmacro('"', k_tmacro,FT_RMDQUOTE);
    defmacro('`', k_tmacro,FT_RMBQUOTE);
    defmacro(',', k_tmacro,FT_RMCOMMA);
    defmacro('(', k_tmacro,FT_RMLPAR);
    defmacro(')', k_tmacro,FT_RMRPAR);
    defmacro(';', k_tmacro,FT_RMSEMI);
}
Esempio n. 13
0
GAParameter::GAParameter(const char* fn, const char* sn,
                         Type tp, const void* v)
{
    if(fn)
    {
        fname = new char[strlen(fn) + 1];
        strcpy(fname, fn);
    }
    else
    {
        fname = (char*)0;
    }

    if(sn)
    {
        sname = new char[strlen(sn) + 1];
        strcpy(sname, sn);
    }
    else
    {
        sname = (char*)0;
    }

    t = tp;
    memset(&val, 0, sizeof(Value));
    setvalue(v);
}
Esempio n. 14
0
// Make a copy of the original obarray, leaving the original in place
LOCAL void nyx_save_obarray()
{
   LVAL newarray;
   int i;

   // This provide permanent protection for nyx_obarray as we do not want it
   // to be garbage-collected.
   xlprot1(nyx_obarray);
   nyx_obarray = getvalue(obarray);

   // Create and set the new vector.  This allows us to use xlenter() to
   // properly add the new symbol.  Probably slower than adding directly,
   // but guarantees proper hashing.
   newarray = newvector(HSIZE);
   setvalue(obarray, newarray);

   // Scan all obarray vectors
   for (i = 0; i < HSIZE; i++) {
      LVAL sym;

      // Scan all elements
      for (sym = getelement(nyx_obarray, i); sym; sym = cdr(sym)) {
         LVAL syma = car(sym);
         char *name = (char *) getstring(getpname(syma));
         LVAL nsym = xlenter(name);

         // Ignore *OBARRAY* since there's no need to copy it
         if (strcmp(name, "*OBARRAY*") == 0) {
            continue;
         }

         // Ignore *SCRATCH* since it's allowed to be updated
         if (strcmp(name, "*SCRATCH*") == 0) {
            continue;
         }

         // Duplicate the symbol's values
         setvalue(nsym, nyx_dup_value(getvalue(syma)));
         setplist(nsym, nyx_dup_value(getplist(syma)));
         setfunction(nsym, nyx_dup_value(getfunction(syma)));
      }
   }

   // Swap the obarrays, so that the original is put back into service
   setvalue(obarray, nyx_obarray);
   nyx_obarray = newarray;
}
static int decode_array( rabbit * r, rawbuffer * buf, TValue * tv )
{
	int c = decode_read_byte( buf );	// skip ":"
	if(c != PHP_COLON) {
		kLOG(r, 0, "PHP Deserialize : Expect ':' After 'a'\n");
		return -1;
	}

	int len;
	int count = stoi(buf->buf + buf->pos, buf->len - buf->pos, &len);
	buf->pos += len;

	c = decode_read_byte( buf );
	if(c != PHP_COLON) {
		kLOG(r, 0, "PHP Deserialize : Expect ':' After 'a:count'\n");
		return -1;
	}

	c = decode_read_byte( buf );
	if(c != PHP_LBRACE) {
		kLOG(r, 0, "PHP Deserialize : Expect '{' in Decode Array\n");
		return -1;
	}

	Table * t = rbtH_init(r, 1, 4);

	int i;
	TValue key, val;
	for(i = 0; i < count; ++i) {
		if(php_deserialize(r, buf, &key) < 0) {
			return -1;
		}
		c = decode_read_byte( buf );
		if(c != PHP_SEMICOLON) {
			kLOG(r, 0, "PHP Deserialize : Expect ';' Between 'key' and 'value' in Decode Array\n");
			return -1;
		}
		if(php_deserialize(r, buf, &val) < 0) {
			return -1;
		}

		c = decode_read_byte( buf );
		if(c != PHP_SEMICOLON) {
			buf->pos--;
		}

		setvalue(rbtH_set(r, t, &key), &val);
	}

	c = decode_read_byte( buf );
	if(c != PHP_RBRACE) {
		kLOG(r, 0, "PHP Deserialize : Expect '}' when Array close\n");
		return -1;
	}

	settblvalue(tv, t);

	return 0;
}
Esempio n. 16
0
File: xlsym.c Progetto: 8l/csolve
/* xlsinit - symbol initialization routine */
void xlsinit(void)
{
    NODE *array,*p;

    /* initialize the obarray */
    obarray = xlmakesym("*OBARRAY*",STATIC);
    array = newvector(HSIZE);
    setvalue(obarray,array);

    /* add the symbol *OBARRAY* to the obarray */
    p = consa(obarray);
    setelement(array,hash("*OBARRAY*",HSIZE),p);

    /* enter the unbound symbol indicator */
    s_unbound = xlsenter("*UNBOUND*");
    setvalue(s_unbound,s_unbound);
}
Esempio n. 17
0
/* xlmakesym - make a new symbol node */
LVAL xlmakesym(char *name)
{
    LVAL sym;
    sym = cvsymbol(name);
    if (*name == ':')
        setvalue(sym,sym);
    return (sym);
}
Esempio n. 18
0
void variables::setvalue(std::string name, int value)
{
	std::string val;
	std::stringstream ostr;

	ostr << value << std::ends;
	val = ostr.str();
	setvalue(name, val);
}
Esempio n. 19
0
	void drawMulti(int startloop, int endloop, int plusplus)
	{
		int val = 0;
		for (int i = startloop; i < endloop; i++){
			setvalue(x, y, cartype);
			val +=plusplus;

		}
	}
Esempio n. 20
0
static window init_askstr_dialog(const char *title, const char *question,
				 const char *default_str)
{
    window win;
    dialog_data *d;
    int tw, bw, h, middle;

    if (! question)
	question= "";
    if (! default_str)
	default_str = "";

    tw = strwidth(SystemFont, G_("Cancel")) * 8;
    h = getheight(SystemFont);

    if (tw < 150) tw = 150;

    win = newwindow(title, rect(0,0,tw+30,h*9+12),
		    Titlebar | Centered | Modal);
    setbackground(win, dialog_bg());
    add_data(win);
    d = data(win);
    d->question = newlabel(question, rect(10,h,tw+4,h*2+2),
			   AlignLeft);
    if (title == PASSWORD_TITLE)
	d->text = newpassword(default_str, rect(10,h*4,tw+4,h*3/2));
    else
	d->text = newfield(default_str, rect(10,h*4,tw+4,h*3/2));

    middle = (tw+30)/2;
    bw = strwidth(SystemFont, G_("Cancel")) * 3/2;

    d->yes = newbutton(G_("OK"),
		       rect(middle-bw-10, h*7, bw, h+10), hit_button);
    setvalue(d->yes, YES);

    d->cancel = newbutton(G_("Cancel"),
			  rect(middle+10, h*7, bw, h+10), hit_button);
    setvalue(d->cancel, CANCEL);

    setkeydown(win, hit_key);

    return win;
}
Esempio n. 21
0
// Restore the symbol values to their original value and remove any added
// symbols.
LOCAL void nyx_restore_obarray()
{
   LVAL obvec = getvalue(obarray);
   int i;

   // Scan all obarray vectors
   for (i = 0; i < HSIZE; i++) {
      LVAL last = NULL;
      LVAL dcon;

      // Scan all elements
      for (dcon = getelement(obvec, i); dcon; dcon = cdr(dcon)) {
         LVAL dsym = car(dcon);
         char *name = (char *)getstring(getpname(dsym));
         LVAL scon;

         // Ignore *OBARRAY* since setting it causes the input array to be
         // truncated.
         if (strcmp(name, "*OBARRAY*") == 0) {
            continue;
         }

         // Ignore *SCRATCH* since it's allowed to be updated
         if (strcmp(name, "*SCRATCH*") == 0) {
            continue;
         }

         // Find the symbol in the original obarray.
         for (scon = getelement(nyx_obarray, hash(name, HSIZE)); scon; scon = cdr(scon)) {
            LVAL ssym = car(scon);

            // If found, then set the current symbols value to the original.
            if (strcmp(name, (char *)getstring(getpname(ssym))) == 0) {
               setvalue(dsym, nyx_dup_value(getvalue(ssym)));
               setplist(dsym, nyx_dup_value(getplist(ssym)));
               setfunction(dsym, nyx_dup_value(getfunction(ssym)));
               break;
            }
         }

         // If we didn't find the symbol in the original obarray, then it must've
         // been added and must be removed from the current obarray.
         if (scon == NULL) {
            if (last) {
               rplacd(last, cdr(dcon));
            }
            else {
               setelement(obvec, i, cdr(dcon));
            }
         }

         // Must track the last dcon for symbol removal
         last = dcon;
      }
   }
}
Esempio n. 22
0
/* db_restart - restart the current game */
int db_restart()
{
    glk_stream_set_position(datafd,saveoff,seekmode_Start);
    if (glk_get_buffer_stream(datafd,save,slen) != slen)
		return (NIL);
    complement(save,slen);
    setvalue(V_OCOUNT,ocount);
    
	longjmp(restart,1);
}
Esempio n. 23
0
inline int fdct3d_lowpasscompute(float XL1, float XL2, float XL3, DblOffTns& lowpass)
{
  int XS1 = 2*int(floor(XL1/2))+1;
  int XS2 = 2*int(floor(XL2/2))+1;
  int XS3 = 2*int(floor(XL3/2))+1;
  //number of samples
  int XF1 = int(floor(XL1/2));
  int XF2 = int(floor(XL2/2));
  int XF3 = int(floor(XL3/2));
  //offset on either side
  float XR1 = XL1/2;
  float XR2 = XL2/2;
  float XR3 = XL3/2;
  
  DblOffVec lowpass1(XS1); setvalue(lowpass1,float(1.0));
  for(int i=-XF1; i<-XR1/2; i++) {
	 float x = (i+XR1)/(XR1/2);
	 float l,r; fdct3d_window(x, l, r);
	 lowpass1(i) = l;
	 lowpass1(-i) = l;
  }  //cerr<<lowpass1;
  DblOffVec lowpass2(XS2); setvalue(lowpass2,float(1.0));
  for(int i=-XF2; i<-XR2/2; i++) {
	 float x = (i+XR2)/(XR2/2);
	 float l,r; fdct3d_window(x, l, r);
	 lowpass2(i) = l;
	 lowpass2(-i) = l;
  }  //cerr<<lowpass2;
  DblOffVec lowpass3(XS3); setvalue(lowpass3,float(1.0));
  for(int i=-XF3; i<-XR3/2; i++) {
	 float x = (i+XR3)/(XR3/2);
	 float l,r; fdct3d_window(x, l, r);
	 lowpass3(i) = l;
	 lowpass3(-i) = l;
  }  //cerr<<lowpass3;
  
  for(int i=-XF1; i<-XF1+XS1; i++)
	 for(int j=-XF2; j<-XF2+XS2; j++)
		for(int k=-XF3; k<-XF3+XS3; k++)
		  lowpass(i,j,k) = lowpass1(i) * lowpass2(j) * lowpass3(k);
  
  return 0;
}
Esempio n. 24
0
ArrayOfMatrices::ArrayOfMatrices (double* data, 
				  const ArrayOfMatrices& model) 
  : Array<Matrix*>(model.length()) {
  setvalue(0);
  
  // Repeat for each matrix.
  for (int i = 0; i < n; i++) {
    const Matrix* A = model[i];
    elems[i]        = new Matrix(data,A->height(),A->width());
    data           += A->length();
  }
}
Esempio n. 25
0
LVAL Native_Init()
{	
    LVAL     	pXReturn;
    int		iPort;
    TVeosErr	iErr;
    
    xlsave1(pXReturn);

    if (!moreargs())
	iPort = TALK_BOGUS_FD;
    else
	iPort = getfixnum(xlgafixnum());

    xllastarg();


    /** invoke veos kernel inialization **/
    
    iErr = Kernel_Init(iPort, Native_MessageToLSpace);
    if (iErr == VEOS_SUCCESS) {


	/** create a lisp based inspace for messages **/

	s_InSpace = xlenter("VEOS_INSPACE");
	setvalue(s_InSpace, NIL);
	NATIVE_INSPACE = &getvalue(s_InSpace);


	/** create keyword symbols for nancy prims **/

	k_TestTime = xlenter(":TEST-TIME"); /* use with copy only */
	k_Freq = xlenter(":FREQ"); 	    /* use with copy, put or get */


	/** setup invariant matcher settings in global param blocks **/

	Native_InitMatcherPBs();


	/** make a uid return value to signify success **/


	Uid2XVect(&IDENT_ADDR, &pXReturn);
	}


    xlpop();


    return(pXReturn);

    }  /* Native_Init */
Esempio n. 26
0
/* cvsymbol - convert a string to a symbol */
LVAL cvsymbol(char *pname)
{
    LVAL val;
    xlsave1(val);
    val = newvector(SYMSIZE);
    val->n_type = SYMBOL;
    setvalue(val,s_unbound);
    setfunction(val,s_unbound);
    setpname(val,cvstring(pname));
    xlpop();
    return (val);
}
Esempio n. 27
0
void nyx_set_input_audio(nyx_audio_callback callback,
                         void *userdata,
                         int num_channels,
                         long len, double rate)
{
   LVAL val;
   int ch;

   nyx_set_audio_params(rate, len);

   if (num_channels > 1) {
      val = newvector(num_channels);
   }

   xlprot1(val);

   for (ch = 0; ch < num_channels; ch++) {
      nyx_susp_type susp;
      sound_type snd;

      falloc_generic(susp, nyx_susp_node, "nyx_set_input_audio");

      susp->callback = callback;
      susp->userdata = userdata;
      susp->len = len;
      susp->channel = ch;

      susp->susp.fetch = nyx_susp_fetch;
      susp->susp.keep_fetch = NULL;
      susp->susp.free = nyx_susp_free;
      susp->susp.mark = NULL;
      susp->susp.print_tree = nyx_susp_print_tree;
      susp->susp.name = "nyx";
      susp->susp.toss_cnt = 0;
      susp->susp.current = 0;
      susp->susp.sr = rate;
      susp->susp.t0 = 0.0;
      susp->susp.log_stop_cnt = 0;
      
      snd = sound_create((snd_susp_type) susp, 0.0, rate, 1.0);
      if (num_channels > 1) {
         setelement(val, ch, cvsound(snd));
      }
      else {
         val = cvsound(snd);
      }
   }

   setvalue(xlenter("S"), val);

   xlpop();
}
Esempio n. 28
0
/*
 *  Create a new static text label. Now implemented using
 *  GraphApp code instead of native MS-Windows "static"
 *  text. This gives more flexibility, better cross-platform
 *  support and there are no 'look and feel' issues with
 *  labels, so no problems are introduced by doing this.
 */
control newlabel(char *text, rect r, int alignment)
{
	control obj = newcontrol(text, r);
	if (obj) {
		obj->kind = LabelObject;
		setredraw(obj, draw_label);
		setvalue(obj, alignment);
		setbackground(obj, getbackground(parentwindow(obj)));
		settextfont(obj, SystemFont);
		show(obj);
	}
	return obj;
}
Esempio n. 29
0
/* xlsinit - symbol initialization routine */
void xlsinit(void)
{
    LVAL array,p;

    /* initialize the obarray */
    obarray = xlmakesym("*OBARRAY*");
    array = newvector(HSIZE);
    setvalue(obarray,array);

    /* add the symbol *OBARRAY* to the obarray */
    p = consa(obarray);
    setelement(array,hash("*OBARRAY*",HSIZE),p);
}
Esempio n. 30
0
ArrayOfMatrices::ArrayOfMatrices (mxArray* ptrs[], 
				  const ArrayOfMatrices& source) 
  : Array<Matrix*>(source.length()) {
  setvalue(0);
  
  // Create the new Matlab matrices and copy the data from the
  // source.
  for (int i = 0; i < n; i++) {
    int h     = source[i]->height();
    int w     = source[i]->width();
    elems[i]  = new Matrix(ptrs[i],h,w);
    *elems[i] = *source[i];
  }
}