Dynamic creation of new Vector with Vector of Vectors

All java gurus,
I am trying to write an application that will generate a vector where at each index there is another vector that contains a set of random float values. So, that is where the Vector of Vectors part comes in. I have figured out by multiple trial and error that inevitably I will need to generate (initialize new Vectors) for as many indicies that I want in the larger vector. Is there a way to do this such that I don't have to type so many calls of Vector x = new Vector(); This is overall going to be used in a Neural Network project and I am trying to write a WeightMatrix whereas each index in the large vector WeightMatrix contain another vector of random float values. Here below is some sample code that I tried but I know doesn't work, but maybe it will give you a better idea of what I am trying to do. Please also respond to [email protected]
Vector weightMatrix = new Vector(10);
Vector weights = new Vector(10);
Random rand = new Random();
for (int i=0; i < 10; i++) {
     this.weights.clear();
     for (int j=0; j < 10; j++)
          this.weights.add(j, new Float(this.rand.nextFloat()));
     this.weightMatrix.add(i, this.weights);
}This code is under a class, so the "this" statements are not the problem.
If you need more info or know of a solution, please email me ([email protected]). Thanks in advance!
Keith Pemberton

I figured it out, but this is for future reference for other people that have the same problem. You can use one vector over and over, you just have to set it as a new vector in the 1st for loop. So, you don't need to create tons of individual vectors (ie. Vector1, Vector2, etc...). So, my final code looks like this
Vector weightMatrix = new Vector(10);
Vector weights = new Vector(10);
Random rand = new Random();
for (int i=0; i < 10; i++) {
    this.weights = new Vector(10);
    for (int j=0; j < 10; j++)
        this.weights.add(j, new Float(this.rand.nextFloat()));
    this.weightMatrix.add(i, this.weights);
}Hope this helps anyone out there!
Keith

Similar Messages

  • Creation of new program with reference to IW31Transaction

    Hello Experts,
    I have a unique requierement where I need to create a zprogram which is similar to create plant Maintenance Order Tcode IW31.
    My requirement is in my new zprogram I just need one screen with the header data which includes order type, Functional location. Plant , main work center area and Text.
    Below that I just need to create a table control which is of components similar to component tabstrip in IW31.
    I have created a new screen with these inputs but I am unable to know how can i run the logic similar to iw31.
    Can anyone let me know the  how to go about this since I cannot make a copy of standard Transaction as I am new to module pool/Programs.
    Thanks and Regards,
    Nikhil.

    Hi,
    ... but if you prefer FM, then you can use BAPI_MATERIAL_MAINTAINDATA_RT or BAPI_MATERIAL_SAVEDATA, depending if you are using Retail or not. BDC is usually not possible for all views - which you would need for complete creation.
    Regards,
    Christian

  • Replicate in the Master controller and creation of new user with cisco prime infrastructure 2.1.

    Hello!!
    We have multiple controllers Cisco WLC 5508 (all running software version 7.6.120.0) distributed in various buildings and a controller in other control building (also Cisco WLC 7.6.120.0 5508) operating as Master and backup of the buildings's controllers . 
    Each building is radiated such an SSID that is used as a validation of the user connected to that SSID web portal each controller (in the WLAN, Security -> Layer 3 -> Web Policy), using the local database to validate the user. 
    The problem is that the local database of users is not being replicated between controllers buildings and the Master controller, so if you drop the controller of a building, the Master controller begins to provide service to the buildings access points, but the equivalent radiated SSID cannot able to validate users. 
    I need know if it's possible through Cisco Prime Infrastruture 2.1, first replicate in the Master controller on the basis of existing controllers buildings each local data and, second, that the creation of new users are automatically perform both the controllers like to the Master .
    Thanks.

    As noted earlier, it is not advisable to use the root user to log in for normal use. New users and groups can be created by navigating to Administration > Users, Roles & AAA as shown in the preceding figures. It would help to chalk out what are the various levels at which you want to distribute the users, and to create those roles first. It doesn’t really matter whether you create users or groups first. New users can be easily added by going to Administration > Users, Roles & AAA > Users > Add Users > Select “Add Users” from the drop-down on the right side. Once you get into the add user workflow, fill in the username, password, and local authorization for this user as shown in the figure below.
    A virtual domain can also be assigned to the users when you define their roles by selecting the virtual domain on the left side and moving it to the right side as shown in the image below (left).

  • Creation of new table with attributes of another ??

    how can i create a new table which has the same attributes as another ? Please note that the records/tuples in the already existing table shouldn't be copied into the new table.
    Illustration:
    Table Employee_Details with attributes/fields Name and IDno is present.
    A new table Supervisor should have the same attributes/fields Name and IDno.
    But the data in Employee_Details table shouldn't be copied into this table (Supervisor).
    Can anyone write a query in SQL that does the same i.e. use the attributes of another table during the creation of a new one?
    Also can anyone explain why the following query is erroneous ?
    sql> create table supervisor as (desc employee_details);
    Thanks for your help!

    create table new_table as select * from old_table
    where 0=1;This statement doesn't create the new_table in the same tablespace than old_table... to take for example only the tablespace, but that's right for storage clause too.
    Assuming TITI is my old table, and TOTO my new table :
    SQL> show user
    USER is "H89UCBAC"
    SQL> select default_tablespace from dba_users where username='H89UCBAC';
    DEFAULT_TABLESPACE
    PSDEFAULT
    SQL> create table titi(coltiti number) tablespace tools;
    Table created.
    SQL> create table toto as select * from titi;
    Table created.
    SQL> ed
    Wrote file afiedt.buf
      1* select table_name,tablespace_name from dba_tables where table_name in ('TITI','TOTO')
    SQL> /
    TABLE_NAME                     TABLESPACE_NAME
    TOTO                           PSDEFAULT
    TITI                           TOOLS
    SQL>   1* select replace(dbms_metadata.get_ddl('TABLE','TITI'),'TITI','TOTO') from dual
    SQL> /
    REPLACE(DBMS_METADATA.GET_DDL('TABLE','TITI'),'TITI','TOTO')
      CREATE TABLE "H89UCBAC"."TOTO"
       (    "COLTOTO" NUMBER
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 65536 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TOOLS"
    SQL> drop table toto;
    Table dropped.
    SQL> CREATE TABLE "H89UCBAC"."TOTO"
      2   (    "COLTOTO" NUMBER
      3   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      4  STORAGE(INITIAL 65536 NEXT 65536 MINEXTENTS 1 MAXEXTENTS 2147483645
      5  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      6  TABLESPACE "TOOLS"
      7  /
    Table created.
    SQL> select table_name,tablespace_name from dba_tables where table_name in ('TITI','TOTO');
    TABLE_NAME                     TABLESPACE_NAME
    TITI                           TOOLS
    TOTO                           TOOLS
    SQL> HTH,
    Nicolas.
    Message was edited by:
    N. Gasparotto

  • Creation of new material with reference to other material

    Hi All,
    I have requirement where i have to create new selling unit material with reference to the given material.
    Now, can any buddy suggest which FM or BADI i have to use to read BOM and ROUTING  info of reference material and same to create BOM and ROUTING for new material.
    Doing this with BDC after reading data directally from tables is one option, But i am looking for any BADI or Fm which will serve the purpose.
    Thanks in Advance,
    Rahul

    Hi,
    ... but if you prefer FM, then you can use BAPI_MATERIAL_MAINTAINDATA_RT or BAPI_MATERIAL_SAVEDATA, depending if you are using Retail or not. BDC is usually not possible for all views - which you would need for complete creation.
    Regards,
    Christian

  • Creation of "New Badi" with Multiple Use

    Hi,
    I am trying to create New badi within enhancement spot which is multiple use, problem here is the badi interface method has got some exporting parameters.
    when i try to activate badi definition it is showing the error this type of interface which is having exporting or returning parameters cannot be used, however if i remove export parameters in the interface method, then i am able to activate the BADI definition.
    Please suggest me, is it not possible to have badi interface method with exporting or returning parameters if it is Multiple Use Badi???
    Thanks,
    Kranthi.

    Answered my self.
    it is the restriction. below is SAP documentations that explains the same
    http://help.sap.com/saphelp_nw70/helpdata/en/e4/5c3642eca5033be10000000a1550b0/frameset.htm

  • Dynamic Creation of Internal table WITH HEADER LINE

    Dear,
    Please show me the way of creating Internal table WITH HEADER LINE dynamically..
    Thanks,
    Nirav

    <font color='blue'>Hi Parekh,
    Have a look at the sample program for Dynamic internal table
    This program has been developed to update any table data in the dictionary. We give table name and File name as Input fields.
    <pre>
    REPORT znpmmm0201.
    *Types
    TYPES:
          BEGIN OF ty_file,
            data(4096) TYPE c,
          END OF ty_file.
    *Type-pools
    TYPE-POOLS:
          truxs.
    *Work areas
    DATA:
          wa_file      TYPE ty_file.
    *Internal tables
    DATA:
          it_file      TYPE STANDARD TABLE OF ty_file,
          it_data      TYPE truxs_t_text_data.
    DATA:
          gv_dref TYPE REF TO data,
          file_name TYPE string.
    *FIELD-SYMBOLS
    FIELD-SYMBOLS:
                   <gf_itab> TYPE STANDARD TABLE,
                   <wa>      TYPE ANY.
    *& Selection-screen
    PARAMETERS:
          p_table TYPE rsrd1-tbma_val,
          p_file  TYPE ibipparms-path.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM f4_for_p_file CHANGING file_name .
    *& START-OF-SELECTION
    START-OF-SELECTION.
      CREATE DATA gv_dref TYPE TABLE OF (p_table).
      ASSIGN gv_dref->* TO <gf_itab>.
      PERFORM upload_data USING file_name.
      MODIFY (p_table) FROM TABLE <gf_itab>.
    *&      Form  UPLOAD_DATA
    FORM upload_data USING file.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = file
          filetype                = 'ASC'
        TABLES
          data_tab                = it_file.
      APPEND LINES OF it_file TO it_data.
      CLASS cl_abap_char_utilities DEFINITION LOAD.
      DATA: l_field_seperator.
      l_field_seperator = cl_abap_char_utilities=>horizontal_tab.
      REPLACE ALL OCCURRENCES OF '|' IN TABLE it_data WITH l_field_seperator.
      CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
        EXPORTING
          i_field_seperator    = l_field_seperator
          i_tab_raw_data       = it_data
        TABLES
          i_tab_converted_data = <gf_itab>.
    ENDFORM.                    " UPLOAD_DATA
    *&      Form  F4_FOR_p_file
    FORM f4_for_p_file CHANGING file.
      DATA:
            l_field_name LIKE  dynpread-fieldname VALUE 'P_FILE'.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = l_field_name
        IMPORTING
          file_name     = p_file.
      file = p_file.
    ENDFORM.                    " F4_FOR_p_file </pre>
    Thanks,
    Venkat.O</font>

  • Creation of new field with the absense of user exit

    Helllo Abapians,
    For one of the T.Code , i dont find any user exits for that T.code.but one customized field is there to that T.CODE.
    How it is possible???

    hi,
    Plz refer to the program on the link to find the user exit.
    http://www.erpgenie.com/abap/code/abap26.htm
    Regards
    Sumit Agarwal

  • If a need to ammend one contact, how can i do to void the creation of new contact with the new info?

    I have iPhone, iPad and macbook, need to ammend all the contacts the phone number adding a digit in between the phone number.(telephone number increase one digit in my country, from 088888888 to 098888888), adding the 9

    Deauthorize all.
    Then authorize the active computers.

  • Dynamic creation of ComponentUsage

    Hi people,
    I want to reuse a view (ViewA) in different views (ViewB, ViewC, ViewD).ViewA has a quite complex logic, so it is necessary to outsource this view.  Not only the logic, but also the count of UIElements and contextelements is quite large, for this I don't want to implement this part redundant in the views A, C and D.
    I have to use ViewA in a table in  the TablePopin UIElement. Every line of the table should have its own instance of ViewA. Is that possible?
    My idea is it, to put the view in an own component. For every tableline I need an instance of the componentUsage. My problem is now, that I'm not able to create at runtime a ComponentUsage and at designtime I don't know how many instances I need. Is it possible in webdynpro to create dynamic instances of ComponentUsage?
    If you know an other way, that prevents me from implementing the view and its logic more times, please tell me!
    Thanks in  advance,
    Thomas Morandell

    Hi Thomas,
    just for clarification. Principally it is possible in Web Dynpro to dynamically create new component usages of the same type like an existing, statically declared one. This means after having defined a component usage of type ISomeComp (component interface definition) you can dynamically create new component usages which all point to the same component interface definition ISomeComp:
    wdThis.wdGetISomeCompUsage().createComponentUsageOfSameType();
    But this dynamic creation approach implies, that you must also embed the component interface view of this component usage to the view composition dynamically; and this is (unfortunately) quite cumbersome and complicated based on the existing Web Dynpro Java API (it is not yet optimized for a simple dynamic view composition modification.
    Additionally, like Valery pointed out, the dynamic creation of new component usages is not compatible with table popins.
    Regards, Bertram

  • List v = new Vector() how can i write this ?

    List v = new Vector() how can i write this ?
    vector does not 'extends' List rather it 'implements' only ......so how can write this way ? ( polymorphism applies only for 'extends' ).

    my question in a simple way is :
    List some_list extends Vector
    No, List is an interface; Vector is a concrete class. Read the javadocs.
    Vector implements List
    >
    AND
    List some_list implements Vector
    are these two same in behaviour
    our  apart from theoretical differences ?thanks
    Interfaces don't have any implementation; they're pure method signatures. When a concrete class implements an interface, it makes a promise that says "I will provide implementations for exactly these methods. Any client can call a method from the interface and I will do something 'sensible' if I'm written correctly."
    From the point of view of static and dynamic types, there's no difference between interfaces and classes.
    C++ has interfaces, too - they're classes with all pure virtual methods. If you understand how C++ works, the concept shouldn't be hard.
    ArrayList is preferred precisely because it isn't synchronized by default. (You can always make it so using java.util.Collections if you wish later on.) If you don't need synchronization, why pay the performance penalty?

  • How do I "un-invert" new Vector Masks?

    This is driving me crazy.
    If I select a Path or Work Path from the Paths Panel,
    then select a Layer from the Layers Panel,
    then Command-click the Make New Mask button (at the bottom of the Layers Panel),
    I get a new Vector Mask applied to my Layer....
    But it's inverted. The shape of the Vector Mask is hiding that portion of the layer. In other words it's like my mask is a cookie cutter and just made a hole in my layer.
    How do I create a new Vector Mask and hide everything else on that layer except the area of the mask?

    Flexesss wrote:
    Why not use the first option?
    Isn't that obvious?  You've had the wrong button pushed by accident, you've spent time drawing a complete complex path, and now you really would like that path to be the OUTSIDE of a shape, and by gosh you really don't want to switch the options then draw it again.
    John has listed the proper restorative answer.  Select the path, then change the option button.
    Keep in mind all this is changing in Photoshop CS6 with the advent of shape layers, which are kinda sorta the same under the covers.  But different. 
    -Noel

  • [svn] 1191: ASC side of the new vector implementation .

    Revision: 1191
    Author: [email protected]
    Date: 2008-04-11 07:56:10 -0700 (Fri, 11 Apr 2008)
    Log Message:
    ASC side of the new vector implementation . Strict mode checking now works for all vector types.
    ASC test, tamarin tests, and flex checkintests pass
    Modified Paths:
    flex/sdk/trunk/modules/asc/src/java/macromedia/abc/AbcParser.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/LintEvaluator.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/avmplus/ActionBlockConstants .java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/avmplus/ActionBlockEmitter.j ava
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/avmplus/ByteCodeFactory.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/avmplus/GlobalBuilder.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/Evaluator.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/MetaDataEvaluator.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/Node.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/NodeFactory.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/NodePrinter.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/Parser.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/TypeIdentifierNode.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/CodeGenerator.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/ConfigurationEvaluator.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/ConstantEvaluator.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/Emitter.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/FlowAnalyzer.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/QName.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/ReferenceValue.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/TypeValue.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/util/Context.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/util/ContextStatics.java
    Added Paths:
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/ApplyTypeExprNode.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/ParameterizedName.java

    please can you send in yr email address.
    I am attaching the code right now with an explanation!!!

  • Problem with creation of purchase order with new implementation.

    Hi Guru's of SAP MM,
    i got this error when i implemented a new company with all co-code, plant and storage location.
    i craeted the PO. even though i have assigned sloc to plant and plant to co-code. and co-code to purchasing org. it is telling in PO that,  the purchasing organisation not assigned to the plant.
    i checked regarding the org- structure with Enterprise Structure.

    Hi,
    As per your posting it is clear that you are maintaining purchase organization at company code level. which means the same purchase organization can cater the needs of all plants which are under that company code, provided if the purchase organization is assigned to the plants which are under the company code.
    bye
    sridhar thota`

  • Dynamically fill the internal table with new fileds

    Hi Friends,
    I have the internal table like
    Data:begin of i_data occurs 0,
               a(60),
                b(60),
                c(60),
                d(60),
                 e(60),
            end of i_data.
    I need to fill the internal table dynamically like
    Data:begin of i_data occurs 0,
               a(60),
                b(60),
                c(60),
                 c1(60),  "new filed dynamically
                 c2(60),  "new field dynamically
                d(60),
                 e(60),
            end of i_data.
    Please suggest me how to do this.
    Regards,
    Sunny.
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 1:55 PM

    You can not add new fields to a statically defined internal table, instead you must create the entrie internal table at runtime.
    Search this forum for Dynamic Internal tables, you will get a lot of example programs.
    Regards,
    Rich Heilman

Maybe you are looking for

  • Yoga 2 Pro tablet performance is slow

    I don't know why, but the performance for my new Yoga 2 Pro is extremely slow when in Tablet Mode. It runs perfectly when in laptop mode. The performance is also poor in Stand mode and Tent mode. Is there a way to fix this or is this how it is suppos

  • Got Windows 8 Questions? HP Win8 Expert Day – November 28, 2012

    Thank you for coming to Expert Day – the event has now concluded. **To find out about future HP Expert Day events, check out this page** On behalf of the Experts, I would like to thank you for coming to the Forum to connect with us.  We hope you will

  • Whats the best ssd drive to get for a macbook pro mid 2012 model

    Hi i am thinking of upgrading my 500 GB HDD drive on my macbook pro to either a 256 GB SSD or a 500 GB SSD i really need some advice on which SSD should i buy . would anyone be able to advice which one is the best i was looking at a samsung 840 serie

  • People Search without My Sites

    Hi, We are building our corporate intranet and trying to implement people search in our SharePoint 2013 Enterprise edition environment. The environment has been updated up to August CU and I am implementing host-named site collections. The challenge

  • Starting WebLogic Commerce as an NT Service

    Hi. I have tried running the WebLogicCommerce Server as an NT service, using the wlservice from the weblogic/bin directory, and setting correctly the environment properties needed for running the commerce. It seems to start.... When I run the portal