void switch_pmode(char *name) { FILE * pcmd; FILE * pout; if(access(P_FIFO, F_OK) != 0){ _ERROR_(); return; } pcmd = fopen(P_FIFO,"w"); if (pcmd == NULL) { _ERROR_(); return; } fputs(CMD_SET_PMODE, pcmd); fputs(" ", pcmd); fputs(name, pcmd); fclose(pcmd); pcmd = NULL; pout = fopen(FIFO_OUT, "r"); if (pout == NULL) { _ERROR_(); return; } while (fgets(read_buff, READ_BUFF_SIZE, pout) > 0) { printf("%s", read_buff); } fclose(pout); }
void getlist() { FILE * pcmd; FILE * pout; if(access(P_FIFO, F_OK) != 0){ _ERROR_(); return; } pcmd = fopen(P_FIFO,"w"); if (pcmd == NULL) { _ERROR_(); return; } fputs(CMD_GETLIST, pcmd); fclose(pcmd); pcmd = NULL; pout = fopen(FIFO_OUT, "r"); if (pout == NULL) { _ERROR_(); return; } while (fgets(read_buff, READ_BUFF_SIZE, pout) > 0) { printf("%s", read_buff); } fclose(pout); }
void setfilter(char *expr) { int i; FILE * pcmd; FILE * pout; if(access(P_FIFO, F_OK) != 0){ _ERROR_(); return; } pcmd = fopen(P_FIFO,"w"); if (pcmd == NULL) { _ERROR_(); return; } fputs(CMD_SETFILTER, pcmd); fputs(" ", pcmd); //fputs(expr,pcmd); for (i = 0; expr[i]; i++) { if (expr[i] == ' ') expr[i] = '_'; } fputs(expr, pcmd); fclose(pcmd); pcmd = NULL; pout = fopen(FIFO_OUT, "r"); if (pout == NULL) { _ERROR_(); return; } while (fgets(read_buff, READ_BUFF_SIZE, pout) > 0) { printf("%s", read_buff); } fclose(pout); }
VCSP read_new<VCS>(Reader& reader) { // there must be a type specified String type; reader.handle(_("type"), type); if (type == _("none")) return intrusive(new VCS); else if (type == _("subversion")) return intrusive(new SubversionVCS); else if (type.empty()) { reader.warning(_ERROR_1_("expected key", _("version control system"))); throw ParseError(_ERROR_("aborting parsing")); } else { reader.warning(format_string(_("Unsupported version control type: '%s'"), type)); throw ParseError(_ERROR_("aborting parsing")); } }
matrix<T> operator-(const matrix<T> &c1, const matrix<T> &c2) { matrix<T> result(c1.nrow,c1.ncol); if ( (c1.nrow != c2.nrow)||(c1.ncol != c2.ncol)) _ERROR_("you are summing two matrices with different size",result); for (int i=0;i<c1.nrow*c1.ncol;++i) result.pointer[i] = c1.pointer[i] - c2.pointer[i]; return result; }
matrix<T>& matrix<T>::operator=( const matrix<T> &source) { if (this == &source){ _WARNING_("you are assigning a matrix to itself"); return *this; } if ( (nrow != source.nrow)||(ncol != source.ncol)) _ERROR_("you are assigning two matrix with different size",*this); for (int i=0;i<nrow*ncol;++i) this->pointer[i] = source.pointer[i]; return *this; }
void getcap() { FILE * pout = fopen(FIFO_CAP, "r"); if (pout == NULL) { _ERROR_(); if (pout) fclose(pout); return; } printf("[{}"); while (fgets(read_buff, READ_BUFF_SIZE, pout) > 0) { printf("%s", read_buff); } printf("]"); fclose(pout); }
matrix<T> gemm( const matrix<T> &a, const char transa, const matrix<T> &\ b, const char transb) { int M = ( (transa=='N')||(transa=='n') ) ? a.nrow : a.ncol; int N = ( (transb=='N')||(transb=='n') ) ? b.ncol : b.nrow; int K = ( (transa=='N')||(transa=='n') ) ? a.ncol : a.nrow; int Kcheck = ( (transb=='N')||(transb=='n') ) ? b.nrow : b.ncol; matrix<T> result(M,N); /* check for dimension errors */ if ( (K != Kcheck) ) _ERROR_("incompatible matrices",result); matrix<T> c1(M,K),c2(K,N); if ( ( (transa=='N')||(transa=='n') ) ) c1 = a; else if ( ( (transa=='T')||(transa=='t') ) ) c1 = a.transpose(); else c1 = a.daga(); if ( ( (transb=='N')||(transb=='n') ) ) c2 = b; else if ( ( (transb=='T')||(transb=='t') ) ) c2 = b.transpose(); else c2 = b.daga(); result = 0.0; for (int irow=0;irow<M;++irow) for (int icol=0;icol<N;++icol) for (int ik=0;ik<K;++ik) result(irow,icol) += c1.pointer[c1.index(irow,ik)]*c2.pointer[c2.index(ik,icol)]; return result; }
T matrix<T>::det() { _ERROR_("determinant is not yet implemented for this kind of matrices",0); }
T* matrix<T>::diagonalize( bool evect) { _ERROR_("diagonalization is not yet implemented for this kind of matrices",NULL); }
int matrix<T>::index( const int irow, const int icol ) const { if ((irow>=nrow)||(icol>=ncol)) _ERROR_("matrices index are outside of range",0); return irow*ncol+icol; }