小编the*_*tna的帖子

使用Arraylist的2D数组表示

我想实现数据的2D表示,其中每行代表高斯分布的特征.我做了以下事情:

     public ArrayList<ArrayList<Double>> getFeature( BufferedReader buffer1)

  {   ArrayList<Double> arrList1 = new ArrayList<Double>();
    ArrayList<ArrayList<Double>> arrList2 = new ArrayList<ArrayList<Double>>();
    String[] strArr = getWords(buff1); 
    for(int j=0 ; j< strArr.length; j++){
    for(int i =0 ;i < 50 ; i++){
        arrList1.add(rand.nextGaussian());
    }
    arrList2.add(arrList1);
    }
    System.out.println("size of arrList2:"+ arrList2.size());       
    System.out.println(arrList2.toArray()[0]);
    System.out.println(arrList2.toArray()[1]);
    return arrList2;
}
Run Code Online (Sandbox Code Playgroud)

当我编译并想要获得每一行的值时,我得到了输出.谁能告诉我可能是什么原因?

预期的产出是:

  System.out.println(arrList2.toArray()[0]);

 [0.08,1.1 .............,0.98]
Run Code Online (Sandbox Code Playgroud)

尺寸为50的数组填充了上述值.

以下是我们的输出.太大了

[0.46462618324716254,-0.7461971643031985,0.11198107553318244,-0.5445576195764561,-0.09170153174710902,1.0599085675813804,-0.5121868425685772,0.6578194527724543,0.07180836719554716,-0.8711795090831688,-1.1685999674955914,-0.8467566589850426,-0.9464559617558149,-0.25455126102711567,0.6880497852836619,0.05802417861623583,0.7605219159096197,0.5573206594413265,-0.6464485036951102,0.9928577372480463 ,0.769468353755745,-1.0349221359588956,1.7475686681406222,0.7286721770852165,1.1938115793074722,0.05051321258899094,-1.5274223735062666,-0.10652710930319426,-2.1566969444968622,1.4572264331572156,-0.07630289414615696,0.2776127747056551,-0.3009457462994894,0.9554273666202241,-2.1190393953455047,0.4580572585843065,-0.6413109094169921,-0.4978755907488374,0.353842909950826,-1.257672808328245 ,-0.3236234929243931,-0.8899339209743886,0.347442395255124,-0.48611580230648704,1.219007569267497,-1.1789975566918134,-0.01825901882420379,-1.6486718275722763,-0.3819 056170192554,0.6042625214995715,0.33415986866928,-0.07450314651627132,1.1181610738837455,-0.44555621990204264,2.2166172691235473,-0.6944430028545253,1.7804248652436612,-0.3801297513557677,0.1603379135566103,0.4370378823762644,0.6537078245920281,-0.5909651262165042,-0.09079544840341715,-0.4588221391142408,0.3191257940850721,0.851481629251832,1.5836138371905788,-0.9214851789009444,-0.40274669796854634 ,0.33137905198405093,0.22048511721877453,-1.6107690385201552,-2.2293481002062734,-1.5862880920203761,-3.021081392986815,0.4806258491486294,-1.4404361309735374,-0.11292399203207835,-1.3927949945851505,-0.999380367686273,-0.34942295299214127,0.9614226886733961,-0.011646872308462626,-1.314757063583407,-0.5894619210755432,-0.018747975733725518,0.7847736709271301, -0.5673683910852766,0.4350772179247941,-2.310707468789298,-1.3594784507734978,-0.420522194159102,0.8723173566610757,0.08704331777378478,0.19156519877684638,1.13490819832362,2.26583242405553 7,0.08824246678795156,1.3416771872818614,2.0113403780125716,-0.6591827547030255,-2.1221005234426045,0.22388389358930083,-0.35281199160944976,1.57513125025632,-0.5543596830360817,0.24276349413614184,-0.6933647399153053,2.1733561712603406,-1.1295984403806556,0.978199373546278,1.4765841816237413,-0.23614652784978474,0.6860841664188477,1.724839793220621,0.09890307698728121,1.1759901942152857, - 0.11367559429189428,0.03751374982321288,-0.706440448714537,1.1162223672467126,0.029899521729224297,-1.0524377764950592,-1.272575346202225,0.05911556504138499,2.5567151468399905,-0.0876438255791631,0.7405000550984376,-0.4653784955900584,1.0347442227437538,-0.7400874338357808,-1.9149762503590055,-0.23253357169676564,-0.027095878580104853,1.3433163962194588,0.6380374697876411,0.239540766344537,0.15521652189382637 ,1.6840845846495722,-1.2654453459207138,-0.37480522158157953,-0.35072194870832607,-0.13003189765184803,-0.3777510145240076,1.7368696932480285,1.59 6933980850992,0.8903554445814371,1.5595823556184982,-1.6215290944712​​14,-1.1200493175424486,-0.40963276102036,0.616137661053976,0.21520038251543913,-0.10766640285845859,-2.3431682923959283,0.8376474132653909,-1.624204670319171,-1.53​​39135491664488,0.5745962643679627,-1.8672864673583596,0.5893904049046332,1.6101909333097806,1.4942863128478316,0.4393934760020643,0.4543320364876582,-2.1477119468636756 ,-0.8675089134938178,-1.304347506660454,0.265582855165904,-0.43315684866326853,1.396958388154523,-0.0366978863358013,0.7573031920372403,-0.3082978848734662,-1.3293560483520508,-0.014314267765796158,0.9963287565650347,0.4441330376836758,-1.1259260419189727,-0.3065655686534148,-1.5814425299338561,-0.6665968885053599,0.5294914314697337,-0.7787448187072923, - 0.5793543872028564,-0.7709908841891148,-0.2752441993676809,1.0127096639099775,0.72923535829487908,0.72774343974269051,-0.3572327111704678,-0.3635339942400348,-1.5135817949705679,-0.8096606039385091,-2.028809935367818,-0.2383975926640008,0.9888240231357164,-0.46822533717671233,0.12555572481497712,0.9249518473038246,-0.7696485018788267,0.7104271113662229,0.462549756020218,0.4661108737616203,-1.3393695430612715,1.3127387014622585,-0.7204635871833611,-0.15541156481308024,0.8706609146104812,-2.153190620432126,-1.7876591648613624,-0.08553271346380187,-0.6393327592272366, - 1.55129717824011,-0.0068777633683922285,1.3326516059681166, - 0.36987435658432716,-0.23254064940739874,0.4093041605249441,-0.22152432261151883,0.11956045271155907,0.817312179186691,-1.109714930373252,1.6919073761823942,-2.477322936459778,-0.8041619336754456,0.5354776432522204,-1.3994286642549634,0.7621208634646848,0.3168358861977863,0.5654315361895403,0.19188988525917902,-1.8959135432065441, - 0.8883163800042816,-0.07396400493233038,-1.811056975930386,0.8323666750629728,0.16495843660377815,0.9180073204622988,-0.18482724669045245,-0.926597451803997,-0.37373162068547583,1.2784 981694766253,-0.9622089382124651,0.36846446000890226,1.7781522414929132,0.22598541140652853,0.0698645511906671,0.32437679311726797,-1.2473606786833797,-0.4098009718556575,0.04826245169132581,0.7412730519089504,-0.2550533401514563,-0.16038376756843503,-1.7248853346384536,-0.9996464058972109,-0.6041936215771648,0.7012791176135328,0.2634365350229634,1.6681642878727803,0.5006091547003853,0.8625317708776815, 0.1915138247321982,0.2611860227007197,1.1701209557262373,0.9057134706410637,-1.7953870540423091,1.2544035731509018,-0.8592198056076387,-0.7480509518320575,-1.4509156168191215,-0.6256261144134664,-0.3991019440510313,0.665093736894838,0.8193871205290613,0.3194454906105449,-0.7766590102568899,-0.4368566309637124,-0.5917671696216537,0.8311430693910862,-0.03873251937784431,0.12352685387320661, -1.3032763393594495,-1.3089664655879443,1.0600394162534208,-1.0448890523458283,0.06485611850874347,0.9952192969393494,0.7564433698789398,-0.129343789502656 82,-2.455965368428643,0.32562880194284605,1.0608150376407195,-0.5856546412601992,0.04459245589226094,-1.0485199770272802,0.171758532083598,-0.15219755725779346,0.22588623160615964,-0.8866303888277965,0.18071263060711168,-0.8101056664306856,0.40109990179114574,-1.2052661486349423,-0.7063493195672804,0.3790905532531173,0.6187801708754183,0.8973661967856524,-0.5094785611904082, - …

java arraylist multidimensional-array

2
推荐指数
1
解决办法
822
查看次数

抑制内联警告

我正在收到警告,例如:

  warning: inlining failed in call to ‘symbol_Arity’: call is unlikely and code size would grow
Run Code Online (Sandbox Code Playgroud)

为了摆脱这个我改变了makefile删除-Winline来摆脱这个.我没有得到任何内联警告.但是,我不知道在表现方面做得多么明智.任何人都可以向我推荐一下吗?

添加了一些更多信息:

这是警告:

search.c: In function ‘prfs_InsertInSortTheories’:
list.h:254: warning: inlining failed in call to ‘list_Delete’: call is unlikely and code size would grow
search.c:187: warning: called from here
list.h:254: warning: inlining failed in call to ‘list_Delete’: call is unlikely and code size would grow
search.c:189: warning: called from here
Run Code Online (Sandbox Code Playgroud)

相应的代码是:

来自list.h

254 static __inline__ void list_Delete(LIST L)
255 {
256   LIST Current;
257 
258 …
Run Code Online (Sandbox Code Playgroud)

c inlining

1
推荐指数
1
解决办法
4118
查看次数

在执行整个代码后获得"分段错误"

我执行所有C代码后出现了分段错误.它生成带有零字节内存泄漏的获取输出.之后,它显示"分段错误".以下是 gdb 输出.

 Program received signal SIGSEGV, Segmentation fault.
 0x08060f90 in _GLOBAL_OFFSET_TABLE_ ()
(gdb) bt 
#0  0x08060f90 in _GLOBAL_OFFSET_TABLE_ ()
#1  0xffbecd18 in ?? ()  
#2  0x15048815 in ?? ()
#3  0xcd0fbecd in ?? ()
#4  0x0610ffbe in ?? () 
#5  0xffbecd08 in ?? ()
#6  0xf7f79ff4 in ?? () from /lib/tls/libc.so.6
#7  0x00000000 in ?? ()
(gdb)
Run Code Online (Sandbox Code Playgroud)

编辑

    char **Connections,**Doors,**Zones;
    char *s1,*s2;
    char con[] = "c_";
    char zon[] = "z_";
    char dor[] = "d_";


   for (i=0; i<nc ; i++){ …
Run Code Online (Sandbox Code Playgroud)

c gdb segmentation-fault

1
推荐指数
1
解决办法
1113
查看次数

在 Visual Studio 2010 中遇到 C 中的计时问题

我有一个获取系统时间的功能。该函数定义如下。

  int getSystemTime(struct timeval tv, void * tz);{
  DWORD milliseconds;
  milliseconds = timeGetTime();
  tv->tv_sec = milliseconds / 1000;
  tv->tv_usec = (milliseconds % 1000) * 1000;
  return 0;
  }
Run Code Online (Sandbox Code Playgroud)

问题具体如下:

 1.error: identifier DWORD is undentified .
 2.error: identifier timeGetTime() is undefined.
 3.error: identifier suseconds_t is undefined. 
Run Code Online (Sandbox Code Playgroud)

我试图包括windef.h定义 DWORD 的位置。但问题是,我收到了如下错误:

 1. error: identifier PCONTEXT is undefined.
Run Code Online (Sandbox Code Playgroud)

包含时间的头文件是time.h. 这里定义的时间值是:

#ifndef _WINSOCK_H
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};
Run Code Online (Sandbox Code Playgroud)

你能告诉我我该怎么做才能让这个功能在windows环境中运行?

[编辑]

 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif

#ifdef HAVE_WINDOWS_H
#include …
Run Code Online (Sandbox Code Playgroud)

c visual-studio-2010 compiler-warnings visual-studio

1
推荐指数
1
解决办法
3324
查看次数

在java中操纵arraylist的部分

我有以下问题.

我有一个大行和列维度的W矩阵.每行代表特征值(用双值填充).矩阵的构造如下:

  Hashmap<Integer,Arraylist<Double>> W = new Hashmap<Integer,Arraylist<Double>>();
Run Code Online (Sandbox Code Playgroud)

在进行计算时,我需要取每行的某些部分并在矩阵中更新它们.我在寻找subList方法.Arraylist但问题是它只返回列表,但我需要arraylist.因为我已经实现的许多方法都作为参数.那么这个案例的解决方案是什么呢?

 w1 = [1,3 ,4,6,9,1,34,5,21,5,2,5,1]
 w11 = [1,3,4]
 w11 = w11 +1 = [2,4,5]
 This changes w1 to = [2,4 ,5,6,9,1,34,5,21,5,2,5,1]
Run Code Online (Sandbox Code Playgroud)

java resize arraylist

1
推荐指数
1
解决办法
97
查看次数

从构造函数传递许多参数会减慢程序的速度吗?

我一直用以下方式设计课程:

public class add{
      private int firstEntry;
      private int secondEntry;

      public add(int a , int b){
          this.firstEntry= a;
          this.secondEntry=b
      }

      public int makeAddition(){
          return firstEntry+secondEntry;
      }

}
Run Code Online (Sandbox Code Playgroud)

这种程序模式是否会减慢java中的程序?

java performance

1
推荐指数
1
解决办法
283
查看次数

java中字符串拆分的正则表达式

我有以下形式的字符串:

HOME(SPADE0) HOME(HEART0) HOME(CLUB0) BOTTOMCOL(CLUBA) ON(HEART2 CLUBA)
Run Code Online (Sandbox Code Playgroud)

我会把它分成两部分

    HOME(SPADE0)
    HOME(HEART0)
    HOME(CLUB0)
    BOTTOMCOL(CLUBA)
    ON(HEART2 CLUBA)
Run Code Online (Sandbox Code Playgroud)

在空间分裂也分裂了最后一个标记,这是我不想要的.什么可以是一个合适的正则表达式?

提前致谢!

编辑

  String[] tokens = line.split("[)]\\s+"); 
Run Code Online (Sandbox Code Playgroud)

java regex

1
推荐指数
1
解决办法
122
查看次数

ImportError:运行从pyinstaller获取的可执行文件时,没有名为geometry的模块

Traceback (most recent call last):
 File "<string>", line 1, in <module>
File py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File py_installer/PyInstaller-2.1/FaceMatcher/build/FaceMatcher/out00-PYZ.pyz/proj_code", line 11, in <module>
File PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File PyInstaller-2.1/FaceMatcher/build/FaceMatcher/out00-PYZ.pyz/skimage.transform", line 1, in <module>
File py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File py_installer/PyInstaller-2.1/FaceMatcher/build/FaceMatcher/out00-PYZ.pyz/skimage.transform.hough_transform", line 7, in <module>
File py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 409, in load_module
File "_hough_transform.pyx", line 13, in init skimage.transform._hough_transform (skimage/transform/_hough_transform.c:7337)
File "py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File "py_installer/PyInstaller-2.1/FaceMatcher/build/FaceMatcher/out00-PYZ.pyz/skimage.draw", line 1, in <module>
File "py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 409, in  load_module
File …
Run Code Online (Sandbox Code Playgroud)

python pyinstaller

1
推荐指数
1
解决办法
4284
查看次数

以下C代码中的内存丢失

我在以下代码中获得了16字节的内存丢失以进行排队.能不能让我知道如何摆脱这个问题?代码是:

      void enqueue( enqueuenode * queueNode1 ,bplus *bplusNew){
      [98] -> enqueue *queue=NULL;
              queue = malloc(sizeof(enqueue_node));
              queue->bplus = bplusNew;
              queue->next= NULL;
                if(queueNode1->headNode == NULL){
                   queueNode1->headNode=queueNode1->tailNode = queue ;
                   }
                 else{
                 queueNode1->tailNode->next = queue;
                 queueNode1->tailNode = queue;
                 }
            }
Run Code Online (Sandbox Code Playgroud)

以下是两个结构

         typedef struct enqueue_help{
           bplus bplusNode;
           struct enqueue_help * next;
         }*enqueue,enqueue_node;

        typedef struct enqueuenode_help{
          enqueue  headNode;
          enqueue  tailNode;
        }*enqueuenode,enqueuenode_node;
Run Code Online (Sandbox Code Playgroud)

对于上面的代码,以下是valgrind输出:

             =23800== 272 (16 direct, 256 indirect) bytes in 1 blocks are definitely lost in loss record 8 of 12
             ==23800==    at 0x4C2260E: malloc …
Run Code Online (Sandbox Code Playgroud)

c valgrind memory-leaks

0
推荐指数
1
解决办法
218
查看次数

在Stringtokenizer中使用句点作为字符串分隔符

我想.从字符串标记中排除完全停止,如下例所示:

 I go to school.
Run Code Online (Sandbox Code Playgroud)

想生成令牌为:

        [ I] [go] [to] [school]
Run Code Online (Sandbox Code Playgroud)

我使用stringTokenizer作为:

List<String> listStr = new ArrayList<String>();
StringTokenizer strToken = new StringTokenizer(str);                    
int i =0;
while(strToken.hasMoreTokens()){
    listStr.add(i, strToken.nextToken());
    i=i+1;
}   
Run Code Online (Sandbox Code Playgroud)

但最后一个标志是school.我不想要的.我该怎么办?

java stringtokenizer

0
推荐指数
1
解决办法
1419
查看次数