All pastes #2071363 Raw Edit

Anonymous

public c v1 · immutable
#2071363 ·published 2011-05-28 21:37 UTC
rendered paste body
/*    The question is, how to initialize prob.x?   Q) What is struct feature_node **x ?   A) <cortexman> declare x as pointer to pointer to struct feature_node      <candide> struct feature_node **x;   Q) The docs below say x is an array of pointers to array of feature_node. What does that look like?   A) <cortexman> declare x as array 10 of pointer to array 5 of struct feature_node      <candide> struct feature_node (*x[10])[5];   Q) The docs don't seem very helpful. I definitely need a pointer to a pointer somehow..   A) <cortexman> declare x as pointer to array 10 of pointer to array 7 of struct feature_node      <candide> struct feature_node (*(*x)[10])[7];   Q) But pointer to pointer to struct feature_node is not really the same as a pointer to array 10 of pointer to array 7 of struct feature_node.      But according to the code I need a pointer to pointer..*/struct feature_node{        int index;        double value;};struct problem{        struct feature_node **x;};problem prob;/* The documentation describing what is going on:  `x' is an array of pointers,    each of which points to a sparse representation (array of feature_node) of one    training vector.    For example, if we have the following training data:    LABEL       ATTR1   ATTR2   ATTR3   ATTR4   ATTR5    -----       -----   -----   -----   -----   -----    1           0       0.1     0.2     0       0    2           0       0.1     0.3    -1.2     0    1           0.4     0       0       0       0    2           0       0.1     0       1.4     0.5    3          -0.1    -0.2     0.1     1.1     0.1    and bias = 1, then the components of problem are:   l = 5    n = 6    y -> 1 2 1 2 3    x -> [ ] -> (2,0.1) (3,0.2) (6,1) (-1,?)         [ ] -> (2,0.1) (3,0.3) (4,-1.2) (6,1) (-1,?)         [ ] -> (1,0.4) (6,1) (-1,?)         [ ] -> (2,0.1) (4,1.4) (5,0.5) (6,1) (-1,?)         [ ] -> (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (6,1) (-1,?)*/