示例#1
0
/* the output "m" is size of: 
 *   colum = t->order;
 *   row = v->size
 */
void DvectorArrayDotProduct(array* t, dvector* v, matrix* m)
{
  /*We do not need tests because getMatrixValue and setMatrixValue and getArrayValue handle some errors*/
  size_t i, j, k;
  double res;
  /* m = v't
  *
  * k = order of array
  * j = column size
  * i = row size
  * 
  * m[j][k] =   Σ v[i] * t[k][i][j]
  * 
  */
  for(k = 0; k < t->order; k++){
    for(i = 0; i < t->m[k]->row; i++){
      for(j = 0; j < t->m[k]->col; j++){
        if(v->size == t->m[k]->row && t->m[k]->col == m->row && t->order == m->col){
          res = getDVectorValue(v, i) * getArrayValue(t, k, i, j);
          if(_isnan_(res) || _isinf_(res)){
            setMatrixValue(m, j, k, (getMatrixValue(m, j, k) + 0));
          }
          else{
            setMatrixValue(m, j, k, (getMatrixValue(m, j, k) + res));
          }
        }
        else{
          fprintf(stderr, "Error while computing DvectorArrayDotProduct.\n");
          fflush(stderr);
          abort();
        }
      }
    }
  }
}
示例#2
0
void setArrayValue(array *t, size_t i, size_t j, size_t k, double val)
{
  if(i < (*t).order){
    if(j < (*t).m[i]->row){
      if(k < (*t).m[i]->col){
        setMatrixValue((*t).m[i], j, k, val);
      }
      else{
        fprintf(stderr, "setArrayValue Error! Wrong colum index.\n");
        fflush(stderr);
        abort();
      }
    }
    else{
      fprintf(stderr, "setArrayValue Error! Wrong row index.\n");
      fflush(stderr);
      abort();
    }
  }
  else{
    fprintf(stderr, "setArrayValue Error! Wrong order.\n");
    fflush(stderr);
    abort();
  }
}
示例#3
0
ExceptionOr<Ref<WebKitCSSMatrix>> WebKitCSSMatrix::create(const String& string)
{
    auto result = adoptRef(*new WebKitCSSMatrix);
    auto setMatrixValueResult = result->setMatrixValue(string);
    if (setMatrixValueResult.hasException())
        return setMatrixValueResult.releaseException();
    return WTFMove(result);
}
示例#4
0
/*
 * k = order
 * i = row
 * j = column
 * 
 * E'(j,i,k) = E(i,j,k)
 * 
 * P(k,j) = Sum_i[ E'(j,i,k)*t(i) ]
 * 
 */
void TransposedArrayDVectorProduct(array *t, dvector *v, matrix *p)
{
  size_t i, j, k;
  double res;
  for(k = 0; k < t->order; k++){
    for(i = 0; i < t->m[k]->row; i++){
      for(j = 0; j < t->m[k]->col; j++){
        res = getArrayValue(t, k, i, j)*getDVectorValue(v, j);
        if(_isnan_(res) || _isinf_(res)){
          setMatrixValue(p, k, i, getMatrixValue(p, k, i) + 0);
        }
        else{
          setMatrixValue(p, k, i, getMatrixValue(p, k, i) + res);
        }
      }
    }
  }
}
示例#5
0
void test5()
{
  matrix *m; /* Data matrix */
  PCAMODEL *model;

  NewMatrix(&m, 3, 4);

  setMatrixValue(m, 0, 0, 0.424264);  setMatrixValue(m, 0, 1, 0.565685);  setMatrixValue(m, 0, 2, 0.565685);  setMatrixValue(m, 0, 3, 0.424264);
  setMatrixValue(m, 1, 0, 0.565685);  setMatrixValue(m, 1, 1, 0.424264);  setMatrixValue(m, 1, 2, 0.424264);  setMatrixValue(m, 1, 3, 0.565685);
  setMatrixValue(m, 2, 0, 0.707101);  setMatrixValue(m, 2, 1, 0.707101);  setMatrixValue(m, 2, 2, 0.707101);  setMatrixValue(m, 2, 3, 0.707101);


  NewPCAModel(&model);

  printf("Test PCA 5\n");
  PCA(m, 1, 5, model, NULL);

  PrintPCA(model);

  DelPCAModel(&model);
  DelMatrix(&m);
}
示例#6
0
void test4()
{
  matrix *m; /* Data matrix */
  PCAMODEL *model;
  int run = SIGSCIENTIFICRUN;
  NewMatrix(&m, 3, 2);

  setMatrixValue(m, 0, 0, 0.424264);  setMatrixValue(m, 0, 1, 0.565685);
  setMatrixValue(m, 1, 0, 0.565685);  setMatrixValue(m, 1, 1, 0.424264);
  setMatrixValue(m, 2, 0, 0.707101);  setMatrixValue(m, 2, 1, 0.707101);

  NewPCAModel(&model);


  printf("Test PCA 4\n");
  PCA(m, 1, 5, model, &run);

  PrintPCA(model);

  DelPCAModel(&model);
  DelMatrix(&m);
}
示例#7
0
CSSMatrix::CSSMatrix(const String& s, ExceptionState& exceptionState)
{
    ScriptWrappable::init(this);
    setMatrixValue(s, exceptionState);
}
示例#8
0
WebKitCSSMatrix::WebKitCSSMatrix(const String& s, ExceptionCode& ec)
    : StyleBase(0)
{
    setMatrixValue(s, ec);
}
示例#9
0
CSSMatrix::CSSMatrix(const String& s, ExceptionState& exceptionState)
    : m_matrix(TransformationMatrix::create()) {
  setMatrixValue(s, exceptionState);
}
示例#10
0
WebKitCSSMatrix::WebKitCSSMatrix(const String& s, ExceptionCode& ec)
{
    ScriptWrappable::init(this);
    setMatrixValue(s, ec);
}
示例#11
0
CSSMatrix::CSSMatrix(const String& s, ExceptionState& exceptionState)
    : m_matrix(adoptPtr(new TransformationMatrix))
{
    setMatrixValue(s, exceptionState);
}
示例#12
0
CSSMatrix::CSSMatrix(const String& s, ExceptionState& exceptionState)
{
    setMatrixValue(s, exceptionState);
}